Jump to content
  • Advertisement
Sign in to follow this  
coolkehon

FTGL (ttf lib) in orthographic projection

This topic is 3298 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 trying to use the FTGL library in ortho projection because my game is purely 2D but i'm having problems with it. I had a function to make the screen's top left corner 0,0 called enable 2D but when i used it FTGL drew the fonts upside down. So i used a function in FTGL's demo and now it draw's in the center of the screen. I don't understand the projection matrices either so some help would be greatly appreciated.
    glMatrixMode (GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity ();
		gluPerspective(90, (float)GraphicsInstance::SCREEN_WIDTH / (float)GraphicsInstance::SCREEN_HEIGHT, 1, 1000);

    glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glLoadIdentity();
		gluLookAt(0.0, 0.0, (float)GraphicsInstance::SCREEN_HEIGHT / 2.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

float res = (font->Render(text,length,FTPoint(x,y,0))).X();
	
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

Share this post


Link to post
Share on other sites
Advertisement
For startskis you're using a perspective projection and frankly that isn't reconciled readily with the fact that you want an orthographic one (i.e. glOrtho). On flipping your y, just reverse the sense of the 3rd and 4th arguments.

Share this post


Link to post
Share on other sites
i got it fixed :D

i did this

//glEnable2D() called before this. Got it from gamedev.net
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glScalef(1,-1,1);

float res = (font->Render(text,length,FTPoint(x,-(y+abs(font->Descender())),0))).X();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();

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!