tags:

views:

15

answers:

0

Hi all,

I hope someone can see what I've done wrong here. I'm trying to draw text using openGL. I have set up the 2D projection as follows, but the problem is that the text only appears when I draw to raster position (0,0) and the text appears in the centre of the window instead of at the bottom left.

All other raster positions are reported as invalid by glGet(GL_CURRENT_RASTER_POSITION_VALID) and no text appears in the window.

I really hope someone discovers what mistake I've made here, since I've tried many different things...

    //set up uppercase letters A-Z 
    wglUseFontBitmaps (hdc, 65, 26, 1065); 

    glListBase (1000); 

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0.0, 571.0, 571.0, 0.0, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glPushAttrib(GL_DEPTH_TEST);
    glDisable(GL_DEPTH_TEST);
    glColor3f(1.0,1.0,1.0);

    GLboolean posValid;
    x = 0.0;
    y = 0.0;
    for (int i = 0; i <100; ++i)
    {
        //test to see which raster positions are valid.
        glRasterPos2d(x, y);
        glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &posValid);
        //only position 0.0 is valid, all other positions are invalid!
        glCallLists (1, GL_UNSIGNED_BYTE, "A");
        x += 0.1;
    }

    glDeleteLists(1065, 26);
    glPopAttrib();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

Many thanks in advance for the help!