Jump to content
  • Advertisement
Sign in to follow this  

Keeping the text in one place

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

Hi. I'm having difficulties keeping the text static on the screen as I move around my view all the time in 3D.
int GraphicHandler::RenderGLScene(GLvoid)									// Here's Where We Do All The Drawing
{								// Finished Drawing The Triangle
	finish = clock();
	duration += (double)(finish - start) / CLOCKS_PER_SEC ;
	frames ++ ;
	FPS = frames / duration ;
	start = clock() ;

	if(frames > 60){ duration = 0; frames = 0; }
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

	glLoadIdentity();									// Reset The Current Modelview Matrix
	//Render models



	//Render our fonts
	if(font != NULL)
		glColor3f(0.0f, 0.5f, 1.0f);
		glTranslatef(0.0f, 0.0f, 0.0f);

		glRasterPos2f(0.0f, 0.0f);
		font->Print("FPS: %7.2f", FPS);
	return TRUE;										// Keep Going
The camera render is basically a translation and rotation for the entire view, the question is how do I prevent the text from being manipulated by this?

Share this post

Link to post
Share on other sites
I can't really give you an answer because there really isn't enough information without seeing the details of how you're drawing things. However, I can give you a method to do what you want to do.

First you draw your scene as you normally would. Then you switch to an orthographic projection (if you weren't already), load the identity matrix, disable depth testing, and then render your text. Finally swap buffers and you're done!

Share this post

Link to post
Share on other sites
I agree. Seems like your text is influenced by the camera matrix. I assume you have glPushMatrix() / glPopMatrix() pairs for the model but there's still the camera transform.

Use the method CrimsonSun suggests. The modelview matrix will be the identity matrix and not transform the text. The orthographic projection matrix allows you to provide the text position in pixels.

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!