OpenGL bitmap text fails after drawing polygon

Posted by kaykun on Stack Overflow See other posts from Stack Overflow or by kaykun
Published on 2010-04-04T00:38:19Z Indexed on 2010/04/04 0:43 UTC
Read the original article Hit count: 337

Filed under:
|

Hi, I'm using Win32 and OpenGL to to draw text onto a window. I'm using the bitmap font method, with wglUseFontBitmaps. Here is my main rendering function:

glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();
    glColor3f(1.0f, 0.0f, 1.0f);
    glBegin(GL_QUADS);
        glVertex2f(0.0f, 0.0f);
        glVertex2f(128.0f, 0.0f);
        glVertex2f(128.0f, 128.0f);
        glVertex2f(0.0f, 128.0f);
    glEnd();
glPopMatrix();

glPushMatrix();
    glColor3f(1.0f, 1.0f, 1.0f);
    glRasterPos2i(200, 200);
    glListBase(fontList);
    glCallLists(5, GL_UNSIGNED_BYTE, "Test.");
glPopMatrix();

SwapBuffers(hDC);

As you can see it's very simple and the only thing that it's supposed to do is draw a quadrilateral and draw the text "Test.". But the problem is that drawing a polygon seems to mess up any text operations I try to do after it. If I place the text drawing functions before the polygon, both the text and the polygon draw fine. Is there something I'm missing here? Any help is appreciated.

© Stack Overflow or respective owner

Related posts about win32

Related posts about opengl