Page 1 of 1

OpenGL and color effects

Posted: Thu Apr 02, 2009 5:51 am
by Spikey
I'm trying to decide and figure out how to change the color tone of screen with opengl. I need functions to change the whole screen (minus characters) to a reddish tone, negative, and grayscale. I haven't tried yet, but I'm guessing I can use shaders, which I'm not familiar with. Or I can somehow use the glDrawPixel command, but I think it might be an expensive call. Or I can make a color vertex array from the game objects and blend from that. I do have DevIL, developers image library included in my project, and there are functions such as saturation and filters like in photoshop, but these functions are meant for while building textures and not dynamically changing them during game play. Did I miss any other ways? Does anyone have any hints how I could accomplish this or what route I should take?

Edit: This is in a Opengl / win32 project, no SDL.

Re: OpenGL and color effects

Posted: Thu Apr 02, 2009 7:10 am
by MarauderIIC
What would the cost be if you did a glColor3f call before you drew anything? Is that possible? Sort of like how a camera can be handled by calling glTranslate3f before you do anything.

Re: OpenGL and color effects

Posted: Thu Apr 02, 2009 9:18 am
by qpHalcy0n
Not sure EXACTLY what you want to do here, but I suspect I have an idea.

If you want to do all three of those in combination, the best solution would be as an image based post-processing effect. This involves rendering the scene to an offscreen render target as a forward rendering pass, then in a separate pass render a full screen quad to an intermediate render target sampling the offscreen target as a texture in an image processing effect. (Yes, this would involve shaders).

If you wanted to give it a reddish hue, you could clear the backbuffer to a desired colour and accumulate the final result via alpha blending into the framebuffer from the processed scene texture. IE: glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE);

Investigate screen space effects and image processing.

Re: OpenGL and color effects

Posted: Thu Apr 02, 2009 10:49 am
by Spikey
What would the cost be if you did a glColor3f call before you drew anything?
That's what I was doing in the first place, and it worked, but then when I changed my render function into calling a DisplayList, it stopped working. I still don't have it working yet, I'm playing around with GL_COLOR_ARRAY vertex array, hopefully it works.


@ qpHalcy0n
Thanks for the ideas, I'll look into it!

Re: OpenGL and color effects

Posted: Thu Apr 02, 2009 4:11 pm
by Spikey
Sweet, I got it working. I was misusing the color array.