Jump to content
  • Advertisement
Sign in to follow this  
Daniel Lee

static 2d text while camera's moving

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

allo one and all, in my Linux openGL application, the scene is moved with the camera parameters in glLookAt(...) changes, but i need to fix the positions of hte text info on the screen while the scence is moving. Please advise how that can be achieved. thanks.

Share this post


Link to post
Share on other sites
Advertisement
are you saying you want the text to move around with the camera? if you want to do that, then just move the camera variable along with another variable, like this:

float textX,textY;
float cameraX,cameraY;
gluLookAt(cameraX,cameraY,40,cameraX,cameraY,0,0,1,0);
glRasterPos2f(textX,textY);
glPrint("Test"); //this is the print function for openGL text i use, but you may use something different
//...inside the loop
if(keyPressed[VK_RIGHT])
{
textX += 20 * deltaTime;
cameraX += 20 * deltaTime;
}
//...move it around accordingly

maybe that's the answer your looking for, glRasterPos2f(); but then again, i don't know if thats what your question is

hope that helps,

--nathan

Share this post


Link to post
Share on other sites
I had the same problem, this is what I use,

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(...);

//--Draw Screen

glFlush();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//Draw Text

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

return TRUE;
}

Hope that helps

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The problem with your way of rendering text is that you are changing the coordinate system, so it ignores the camera. You have to render the text in the 3d modelview parameters, and that way it will move according to the camera.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!