Reputation: 7835
Basically, I've got a colour matrix defined as such:
struct ColourXForm
{
float4 mul;
float4 add;
float4 Transform(float4 colour)
{
return float4(
colour.x * mul.x + add.x,
colour.y * mul.y + add.y,
colour.z * mul.z + add.z,
colour.w * mul.w + add.w);
}
}
What I want to do is to apply the function 'Transform' to each pixel in the texture as it is rendered onto the screen. I can't actually modify the texture as different colour transform matrices can be applied to the same image multiple times in a frame (and I don't know what will be applied until it is time to render the texture), and I can't use shaders either.
Is there a way this could be done given these requirements? (my only idea so far is multi-texturing, but can't figure out how to apply it)
Also, I'm new to OpenGL, so it would be helpful to post some code as well, or point me to a tutorial or even the required functions/parameters.
Thanks
Edit: One more thing I should mention, is that the texture contains pre-multiplied alpha, so blending is setup as glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
Upvotes: 2
Views: 1813
Reputation: 25710
If not shaders (crazy demand that, homework or non-PC platform?) then you could probably set this up using texture stages or something. Your function is pretty simple (tex * a + b) so it ought to be doable, althogh not very fun. :-P
Upvotes: 2
Reputation: 400069
If you're using a recent-enough version of OpenGl, you could of course user shader programming to do this.
If you don't want to use that, but are using OpenGL 2.0 or higher, you can use the glMatrixMode()
function to set OpenGL's color matrix to something matching your desired transform.
Upvotes: 1