Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ OpenGL
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 1-Oct-11 10:21am
Edited 3-Oct-11 9:28am
v2
Comments
Santhosh_G at 2-Oct-11 0:07am
   
How you are displaying image? Texture mappping may cause such isues.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sweety Khan at 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)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 3 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100