OpenGL Color Effects

General FreeBASIC programming questions.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

MrSwiss wrote:
mrToad wrote:Not sure how to fix these yet.
I haven't heard of FBPNG (it may be, a old lib. = 32bit only?).
I'd try to use the more recent FBImage (by D.J.Peters), see Libraries Section.
Yep, it's a very early lib. FBImage is, as you stated, a more modern alternative.

@mrToad: Joshy also coded a sound library, IIRC. Have a look at this thread:
viewtopic.php?f=7&t=24922&p=226821#p222923

(damn, forum search engine is thiiiiiiis short of useless)
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: OpenGL Color Effects

Post by mrToad »

paul doe wrote:@mrToad: Joshy also coded a sound library, IIRC. Have a look at this thread:
viewtopic.php?f=7&t=24922&p=226821#p222923

(damn, forum search engine is thiiiiiiis short of useless)
I often have trouble with the search, perhaps I'm not the only one. Also I'm not able to find a sound lib there under D.J. Peters name.
Although, really nice collection of stuff by Joshy and many others.

I've been having fun changing the speed of sound fx using FBSound. For example footsteps can use a single sample and sound different each time because of subtle pitch changes via speed of playback. I hope to retain that feature in another library. Now I'm getting off topic. :]

Appreciate everyone's replies.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: OpenGL Color Effects

Post by BasicCoder2 »

paul doe wrote:(damn, forum search engine is thiiiiiiis short of useless)
Try the google search engine with FreeBasic as one of the search words.
.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

BasicCoder2 wrote:
paul doe wrote:(damn, forum search engine is thiiiiiiis short of useless)
Try the google search engine with FreeBasic as one of the search words.
Effectively, Google found it at the first try, in the first place. Who would have thought =D Thanks.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

mrToad wrote:Appreciate everyone's replies.
I'm glad =D

I finished with the demo. You can see it here. Hope you like it, and find it useful ;)
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: OpenGL Color Effects

Post by mrToad »

Awesome! Very impressive, paul doe. That's a lot of blend modes. Clean code, too. That should be put in the Tips and Tricks section I would imagine. Should come in handy for many a folk. Thanks for your work!

Now, doing this using OpenGL is a mystery for me. The overlay blend is most desirable, as I can't think of any other way to do a light source. Going to have to do some research.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

mrToad wrote:Awesome! Very impressive, paul doe. That's a lot of blend modes. Clean code, too. That should be put in the Tips and Tricks section I would imagine. Should come in handy for many a folk. Thanks for your work!

Now, doing this using OpenGL is a mystery for me. The overlay blend is most desirable, as I can't think of any other way to do a light source. Going to have to do some research.
Thanks. As I told you, you can do it with shaders (those particular shaders are called fragment shaders in OpenGL jargon), but that would require you to rewrite almost all your library. I'll post an example here soon so you see how it can be done.
For now, to integrate it with your framework, you can use the blitter to put an image directly on a fb.image buffer, and bind that buffer to a texture to do the final rendering. The technique is pretty much the same as the one you described to me when you explained how you compose the clothing for your characters ;)
I'll explain how to code your own blending functions in that thread, as well as doing some lightning effects and other cool stuff that you can do with it (and indeed, many effects have its equivalent in GIMP, too). Stay tuned ;)
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: OpenGL Color Effects

Post by mrToad »

paul doe wrote:(those particular shaders are called fragment shaders in OpenGL jargon), but that would require you to rewrite almost all your library. I'll post an example here soon so you see how it can be done.
I really didn't mean to imply that you should provide an example, you have done quite a lot already. Although indeed I'm not sure anyone else has provided examples of FB OpenGL fragment shaders. Surely whatever you do will be helpful to many. But I somehow feel responsible for putting you to all this work.

I chose OpenGL because of it's speed and versatility with scaling, rotation, and other things. For my particular game a lot of those things could probably be done without it, and the speed unnecessary. I do like OpenGL but sometimes I wonder if it makes sense for such a low-res and non-taxing game. There's so many ways to accomplish the same thing. It seems like an acceptable choice in any case.
paul doe wrote:For now, to integrate it with your framework, you can use the blitter to put an image directly on a fb.image buffer, and bind that buffer to a texture to do the final rendering.
The issue with this is the light source needs to move. Otherwise I could just create the light via pixel art. I would have to rebind the texture every cycle to render a moving light source. Heck, maybe that's not as bad as I imagine, at least for special occasions in the game.

Many thanks. :)
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

mrToad wrote:I really didn't mean to imply that you should provide an example, you have done quite a lot already. Although indeed I'm not sure anyone else has provided examples of FB OpenGL fragment shaders. Surely whatever you do will be helpful to many. But I somehow feel responsible for putting you to all this work.
Hahaha don't worry about it. Yes, there are examples, but for 3D and aren't exactly versatile. The code I show you is code that I had to port anyway, so don't feel bad about it ;)
mrToad wrote:I chose OpenGL because of it's speed and versatility with scaling, rotation, and other things. For my particular game a lot of those things could probably be done without it, and the speed unnecessary. I do like OpenGL but sometimes I wonder if it makes sense for such a low-res and non-taxing game. There's so many ways to accomplish the same thing. It seems like an acceptable choice in any case.
Yep, it is. Rel's lib is unfortunately outdated (nobody updated it to take advantage of shaders or some other capabilities found in GL > 2.0). In the meantime, take a look here http://www.opengl-tutorial.org/ to see how to really do OpenGL ;)
The code is in C++, but the FB code is equivalent.
mrToad wrote:The issue with this is the light source needs to move. Otherwise I could just create the light via pixel art. I would have to rebind the texture every cycle to render a moving light source. Heck, maybe that's not as bad as I imagine, at least for special occasions in the game.
Hahaha, indeed. I think you took me way too literally when I said that texture binding is a relatively slow operation. You can get away perfectly fine with a couple hundreds of bindings per frame, so your game should slice through it like a knife in hot butter ;)
See the demo to have an idea of what I tell you. The slowest blending mode is capable of doing several hundreds of blits per second, and that in pure FB and in a piece of crap box like mine ;)
mrToad wrote:Many thanks. :)
You're welcome. Did I sneaked into the credits section yet? =D
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: OpenGL Color Effects

Post by mrToad »

paul doe wrote:Hahaha don't worry about it. [...] The code I show you is code that I had to port anyway, so don't feel bad about it ;)
Okay :D I was telling my wife this dude from Argentina was helping doing some really cool graphics stuff that took days to complete. Then I started to feel guilty, haha.
paul doe wrote:Yep, it is. Rel's lib is unfortunately outdated (nobody updated it to take advantage of shaders or some other capabilities found in GL > 2.0). In the meantime, take a look here http://www.opengl-tutorial.org/ to see how to really do OpenGL ;)
Well that is reassuring. Since I am so behind I sometimes wonder if I'm going in a completely wrong direction, like a dead-end, after all the hard work. But anyway, cool, I will definitely read up on that tutorial.
paul doe wrote:Hahaha, indeed. I think you took me way too literally when I said that texture binding is a relatively slow operation. You can get away perfectly fine with a couple hundreds of bindings per frame, so your game should slice through it like a knife in hot butter ;)
Wow... I'm way too concerned with speed. You would think I was trying to code in the original BASIC on a 486 for Dos. I even avoid using strings sometimes because I got it in my head that they are slower. I should be doing what is more comfortable rather than being so concerned with these little things. :P
paul doe wrote:You're welcome. Did I sneaked into the credits section yet? =D
Sure, but you have to include a mug-shot with a huge grin.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: OpenGL Color Effects

Post by paul doe »

mrToad wrote:Okay :D I was telling my wife this dude from Argentina was helping doing some really cool graphics stuff that took days to complete. Then I started to feel guilty, haha.
Haha nah, it took me 4 or 5 hours (most of them to ensure that the formulas were the GIMP equivalents). It just so happens that I don't have that much time to code these days.
mrToad wrote:Wow... I'm way too concerned with speed. You would think I was trying to code in the original BASIC on a 486 for Dos. I even avoid using strings sometimes because I got it in my head that they are slower. I should be doing what is more comfortable rather than being so concerned with these little things. :P
Hahaha perhaps. It's not so easy to put things in perspective sometimes. Especially concerning speed. Have a look at this to get a rough idea of what you can do with FB alone, no libraries. You can use that as a measure of how much content you can comfortably display on screen at once, and the framerates you will get.
mrToad wrote:Sure, but you have to include a mug-shot with a huge grin.
I'll see what I can do ;)
Post Reply