Sign in to follow this  
diginerd

Text won't render in screen space

Recommended Posts

Hey guys, I have a text problem. I use outlined fonts using wglUseOutlinedFonts. Any text I want to draw will draw perfectly if I draw it in world space, but when I want to draw it directly in screen space for my HUD, it will not draw. Here is my text drawing function (I'm just testing it by printing hello for now:

void FontManager::Draw()
{
	GLfloat curCol[4];

	// Store the current ogl color
	glGetFloatv(GL_CURRENT_COLOR, curCol);
	
	glViewport(0, 0, GFX_DEFAULT_WINDOW_WIDTH, GFX_DEFAULT_WINDOW_HEIGHT);

	// Change the projection to ortho
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0.0, GFX_DEFAULT_WINDOW_WIDTH, 0.0, GFX_DEFAULT_WINDOW_HEIGHT, -1.0f, 1.0f);

	// Disable Depth Testing
	glDisable(GL_DEPTH_TEST);

	glMatrixMode(GL_MODELVIEW);

        glColor3f(1.0, 1.0, 1.0);

	while(begin != end)
	{	
		glPushMatrix();
		glLoadIdentity();

		glTranslatef(100, 100, 0);

		glListBase(dlID);
		glCallLists(5, GL_UNSIGNED_BYTE, "hello");

		glPopMatrix();

		++begin;
	}

	// Restore the current ogl color
	// Disable Depth Testing, and Enable alpha blending
	glEnable(GL_DEPTH_TEST);
	
	glMatrixMode(GL_PROJECTION);
	glPopMatrix(); // Projection Push


	glColor4f(curCol[0], curCol[1], curCol[2], curCol[3]);

}

Every tutorial I have looked at does it like this, and I can't figure out why it isn't drawing. If I don't change the projection mode and just glLoadIdentity() in the modelview, it maps to the camera's position, but that's not what I want, since the position of the text would still be in world space, not screen space. I need to be able to specify screen space coordinates to draw the text to. Any help would be appreciated. Diginerd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this