Jump to content

  • Log In with Google      Sign In   
  • Create Account

Problem mixing GL_LINE_LOOP and Textures


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Mibran   Members   -  Reputation: 122

Like
0Likes
Like

Posted 09 April 2007 - 06:12 AM

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

Sponsor:

#2 matt_j   Members   -  Reputation: 106

Like
1Likes
Like

Posted 09 April 2007 - 06:33 AM

glDisable(GL_TEXTURE_2D);

Put it in before you draw lines.

#3 Mibran   Members   -  Reputation: 122

Like
0Likes
Like

Posted 10 April 2007 - 04:45 AM

Great, thanks for the help! :)

cu,
Mibran




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS