Jump to content
  • Advertisement
Sign in to follow this  

Resetting render states

This topic is 4080 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've just been in the process of converting my texture code from supporting TGA files to Direct Draw Surfaces. When I came to test the DDS loader I noticed something strange about the final rendered image. Here's the render function:
void render_scene(void)

    glTranslatef(0.0f, 0.0f, -3.0f);

    glBindTexture(GL_TEXTURE_2D, texture->id);


        glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.5f);
        glTexCoord2f(1.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.5f);
        glTexCoord2f(1.0f, 1.0f); glVertex3f(0.5f, 0.5f, 0.5f);
        glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, 0.5f);


    glInterleavedArrays( GL_C4UB_V3F, 0, g_lineVertices );
    glDrawArrays( GL_LINES, 0, 6 );


Earlier in my program, I load the Texture from a DDS file and enable Texturing via glEnable(GL_TEXTURE_2D); the thing is, unless I enable texturing again in the rendering function and then disable it immediately after drawing my textured quad the colors of the axis lines that I draw using the interleaved arrays are distorted (they look darker). Is it really necessary that I enable and disable texturing within my rendering function every time? Also, when drawing the vertex array the current color is set using glColor3ub(0, 0, 255). When the function is called again the texture is tinged blue - do I just have to make a call to glColor**() again and set it to white?

Share this post

Link to post
Share on other sites
OpenGL is a state machine. If you enable texturing, it's on until you turn it off. When you set a color, that color is your active color forever until you change it again.

When you are done with the color, reset it to 1,1,1

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!