The last few days I experimented a bit with fragment shaders and their use in a 2D game development library like Gosu, and with the help of jlnr I came up with this extension header for Gosu, that simplifies the use of fragment shader.
With the use of
GLEW to check for shader support this should work on Windows, Mac OS X and Linux aswell.
What the class does is, that each time a fragment shader is executed Gosu is forced to draw everything (=> flush the DrawOpQueue) and then the framebuffer contents are copied to a texture. This texture is rendered with the shader applied, and thus the PostProcessing class can handle multiple shaders.
If no shader support is available the class does not create a texture and simply does not execute the shader.
It should be even possible to apply the shader to only certain parts of a game, i.e. running a shader not at the end of your draw function, but in between it. This maybe even necessary for parts of the game that should not have the shader applied to, like on-screen text and HUDs.
I included a few sample shaders (Which I found on the internet and modified to get them working, and I really don't recall where I got them, sorry) which demonstrate the usage of the shaders.
Here is a video on YouTube demonstrating a few simple shadersI am looking forward to test further applications of fragment shader in 2D games (per-pixel lighting and bloom comes to my mind). Feel free to post suggestions and criticism about the extension, implementation of it or new shaders.
This is C++ only for now, until jlnr figures a way to wrap this to ruby *hinthint* ;)