Click here to Skip to main content
15,886,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I display an image as background for my game.
Now if I display any image or polygon etc its colour is different from what I specified, how to get rid of this problem?
Posted
Updated 3-Oct-11 8:28am
v2
Comments
Santhosh G_ 2-Oct-11 0:07am    
How you are displaying image? Texture mappping may cause such isues.

1 solution

Please check blending is enabled before drawing polygon.
Blending will create an intermediate color of previous image available in framebuffer(background image) and current image.

Please call glDisable( GL_BLEND ) before rendering your polygon and other images.

In texture mapping another tricky thing exists, if you are not specified the texture environment properly, it will consider GL_MODULATE texture environment. The default texture environment is GL_MODULATE, which multiplies the texture color by the primitive (or lighting) color.

For example you are not changed texture environment, and changed color using glColor.

glColor3f( 1.0, 0.0, 0.0 );

// texture mapping code.
// this texture mapping outputs red color and ignores green, and blue channels.

This problem can be solved by providing proper texture environment parameter.
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );



Your problem is not much clear in the question, please provide more information to solve your problem.
 
Share this answer
 
Comments
Sweety Khan 4-Oct-11 10:43am    
dont know wht was the reason of problem but the problem is solved when i make the fn of tht code n just call it where it is required. btw thanx for telling me about GL_BLEND and GL_MODULATE :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900