Bitmap Text Rendering Trouble in Fullscreen

Hi, I’m trying to draw text onto a fullscreen window that’s been set by ChangeDisplaySettings. I’m using wglUseFontBitmaps to work with bitmap fonts. However, it seems that when I go to actually render it, drawing a polygon before the text seems to hide the text. This 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, the only thing it’s supposed to do is draw a rectangle then display “Test.”, however it does not display the text at all. I noticed that if I place the the text functions before the rectangle, it will display both the rectangle and the text fine, but I want to display the text last.

I also noticed that if I don’t change the display settings using ChangeDisplaySettings, it will work fine even if the text is being rendered last. But this is obviously not what I want since I want it fullscreen.

Does anybody know what I’m doing wrong? Any help is appreciated.

Edit: Also, if I call glClear(GL_COLOR_BUFFER_BIT); between the rectangle and the font functions, the font displays properly, but not the rectangle obviously.

Edit2: After much rigorous experimenting, I found out that it works if I call more than once to glBegin() before the text. Where’s the logic in that? I have no idea. Here’s how I got it to work:

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();
    glBegin(GL_QUADS);
        glVertex2f(0.0f, 0.0f);
        glVertex2f(256.0f, 0.0f);
        glVertex2f(256.0f, 256.0f);
        glVertex2f(0.0f, 256.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);

I can get it to work now, but I’m still bothered as to why I need the second glBegin/glEnd. Could somebody shed some light as to why this is?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.