Jump to content
  • Advertisement
Sign in to follow this  
Lightstrike

gluBuild2DMipmaps mess up colors

This topic is 3680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm just rendering a few simple primitives (GL_LINES, GL_LINELOOP, GL_QUAD) and a textured quad and it works fine. However if I use gluBuild2DMipmaps everything turns green except the textured quad which renders perfectly. Here's the call to it:
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,(GLsizei)_width,(GLsizei)_height,GL_RGBA,GL_UNSIGNED_BYTE,pSurface->pixels);

I normally set color like this before rendering a primitive:
glColor4f(red, green, blue, alpha);
I tried this:
    glColor4f(1.0f,1.0f,1.0f,1.0f);
    glColor4f(red, green, blue, alpha);

and this in the initialization code (another old thread suggested it in another situation)
    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);

I'd appreciate anyone pointing me in the right direction as to what affects the colors in gluBuild2DMipmaps and how to prevent it.

Share this post


Link to post
Share on other sites
Advertisement
Might be that for untextured primitives the last used texture is used. GL_REPLACE would then replace the color with the texel. I bet your texture has a green pixel at (0,0) ;)

Try unbinding the texture or disabling textures for untextured primitives.

Share this post


Link to post
Share on other sites
heh spot on. I have a green cell grid :)

ah and the last texcoord used for the textured quad applied to all following vertices.

a simple glBindTexture(GL_TEXTURE_2D, 0); on all the primitive draw calls did the trick. the opengl doc gave me some trouble. I didn't know what the default texture was.

I'm an old directx guy trying to make a new framework for my games based on opengl.

Well thanks a lot for your help!

Share this post


Link to post
Share on other sites
short follow up question. Is my solution the faster choice as opposed to doing glDisable on the primitives and glEnable on the textured quad?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!