Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

OpenGL Text in Ortho problem...

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

I'm getting a very strange error with my bitmap text (txt is being rendered in ortho). This is my rendering pipeline:
void OpenGLOps::RenderFrame() 
{ 
        // Process all input and set up frame accordingly 
        SetUpFrame(); 
         
        // Draw the world from the Display List 
        glCallList(WorldLoader.GetDisplayListID()); 
         
        // Temp lighting function 
        // Lighting(); 
         
        // Draw grid for the hell of it 
        DrawGrid(35.0); 
 
        // Print out debug info 
        DebugPrinter(txt); 
}







I have it at a point in my rendering pipeline so it IS affected by the mouse movement (eg as I turn the cam the text moves on the screen), no pushing or poping to keep it w\ the cam. But no matter where I start the raster pos I can't see the text untill I move the cam. The second I move the cam even just a bit I can see the text. Here's the whole Ortho/Text setup and print func:
void OpenGLOps::DebugPrinter(char *txt)
{
    // Set text color
    glColor3f(1.0f, 1.0f, 1.0f);
    
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    
    // Select Projection Matrix
    glMatrixMode(GL_PROJECTION);
    // Save Matrix State
    glPushMatrix();
    // Switch to Orthographic mode
    glOrtho(0, 1023, 0, 767, -1.0, 1.0);
    // Select Model View Matrix
    glMatrixMode(GL_MODELVIEW);

    // Reset the matrix!
    //glLoadIdentity(); <- not doing this, want cam move to affect text for now. Untill the bug is fixed.
    // Set the possition to draw to
    glRasterPos2i(400, 400);
    
    // Push Attribute? uh wtf is this...
    glPushAttrib(GL_LIST_BIT);
        // this code sux wtf does it do? why - 32?!
        glListBase(base - 32);
        // sigh...
        glCallLists((int)strlen(txt), GL_UNSIGNED_BYTE, txt);
    glPopAttrib();

    // Select Projection Matrix again
    glMatrixMode(GL_PROJECTION);
    // Load previous Matrix state
    glPopMatrix();
    // Select Model View Matrix again
    glMatrixMode(GL_MODELVIEW);
    
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
}







It's a very strange error, if you want to see for your self I have a build of it uploaded here: http://www.talentopoly.com/adam/UPLOADS/cpp/BlackEngine.zip Thanks again guys! [Edited by - Wavesonics on October 6, 2004 4:46:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
Hey man!

This chunk of code isn't quite right


glOrtho(0, 1023, 0, 767, -1.0, 1.0);
// Select Model View Matrix
glMatrixMode(GL_MODELVIEW);

// Reset the matrix!
//glLoadIdentity(); <- not doing this, want cam move to affect text for now. Untill the bug is fixed.



It should read like this


//old statement, you should see the differences between
//the old one and the new one.. Just some parameters flipped
//around!
//glOrtho(0, 1023, 0, 767, -1.0, 1.0);
glOrtho(0, 1023, 767, 0, 0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();



This should take care of it!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!