static 2d text while camera's moving
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.
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:
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
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 loopif(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
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
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
May 21, 2006 11:37 AM
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement