Jump to content
  • Advertisement
Sign in to follow this  
Mibran

Problem mixing GL_LINE_LOOP and Textures

This topic is 4182 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

Hi there, I'm trying to do two things in my drawing method: First draw a simple polygon using GL_LINE_LOOP Then draw a texture and map it to an GL_QUADS I encounter the problem that the polygon becomes the same color as the texture, although I am clearing color and depth buffer before painting. Even a glColor does not help here. It seems the texture remains selected and that I have to "unselect" the texture every time before drawing the simple polygon, but how? Here's to source:
void draw()
{
    // clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    // should be white
    glColor3f(1.0f,1.0f,1.0f);

    // but this polygon gets the texture's color ??
    glBegin(GL_LINE_LOOP); 
    glVertex3i(150,150,0);
    glVertex3i(200,150,0);
    glVertex3i(200,200,0);
    glEnd();

    /* Select Our Texture */
    glBindTexture( GL_TEXTURE_2D, texture[0] );

    glBegin(GL_QUADS);
        /* Bottom Left Of The Texture and Quad */
        glTexCoord2f( 0.0f, 1.0f );
        glVertex3i(50,50,0);
        /* Bottom Right Of The Texture and Quad */
        glTexCoord2f( 1.0f, 1.0f );
        glVertex3i(100,50,0);
        /* Top Right Of The Texture and Quad */
        glTexCoord2f( 1.0f, 0.0f );
        glVertex3i(100,100,0);
        /* Top Left Of The Texture and Quad */
        glTexCoord2f( 0.0f, 0.0f );
        glVertex3i(50,100,0);
    glEnd();

    // show the drawings (bring backbuffer to front)
    SDL_GL_SwapBuffers();
}


Thanks in advance, Michael

Share this post


Link to post
Share on other sites
Advertisement
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!