Sign in to follow this  
coolkehon

FTGL text upside down

Recommended Posts

I had a problem similar to this before while using devIL and i switched to raw image loading since then. When I loaded an image with devIL the image was filliped horizontally and I was able to get a quick fix by simply flipping the texture matrix. This time the problem seems to be with FTGL where textured, polygon, and well vector loaded font's don't work correctly and are flipped. The bitmap, and pixmap font's work fine. I tried flipping the texture matrix and that did no good here. Also I'm using opengl for a 2D game so I enable 2D to do so. Here is some source code of a sample file. Text still upside down;
/*
 * main.cpp
 *
 *  Created on: Aug 31, 2009
 *      Author: kurt
 */
#include "Window.h"
#include <cstdlib>
#include <FTGL/FTGLPolygonFont.h>
#include <iostream>
using namespace std;
using namespace objdraw;

void redraw_callback();
void control_callback(PadControls controls);
void main_callback();

Window win;
DrawingCanvas * canvas = new DrawingCanvas();
FTFont * font = NULL;

int main(int argc, char * argv[])
{
	win = Window();
	win.init();
	
//	font = new FTPolygonFont("./Kingdom_Hearts_Font.ttf");
	font = new FTPolygonFont("./MAGNUMP.TTF");
	if(font->Error())
	{
		cout << "error loading font" << endl;
		exit(0);
	}
	font->FaceSize(39);
	font->UseDisplayList(false);
	
	win.setMainLoopCallback(main_callback);
	win.setControlCallback(control_callback);
	win.setRedrawCallback(redraw_callback);
	
	win.main();
	exit(0);
	return 0;
}
void redraw_callback()
{
//	canvas->clearScreen(Color(255,255,0));
//	canvas->redraw();
	glColor3ub(255,0,0);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);
	glEnable2D();
//	flipTextureMatrix();
	font->Render("Hello World");
}
void control_callback(PadControls controls)
{
	if(controls.pressed()[SDLK_ESCAPE] ||
	   controls.cross())
	{
		win.exitMain();
	}
	if(controls.circle())
	{
		(new FilledRect(0,0,100,100,canvas))->setColor(Color(255,0,0,255));
	}
	if(controls.pressed()[SDLK_c])
	{
		ImageUtil::loadImageFile("lan_hp2.png",canvas);
	}
	
}
void main_callback()
{
	
}


and an example image. Note i offset the text a little in this one so you could see it better. Photobucket

Share this post


Link to post
Share on other sites
went and looked at demo again and found this


switch(current_font)
{
case FTGL_BITMAP:
case FTGL_PIXMAP:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, w_win, 0, h_win);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
break;
case FTGL_OUTLINE:
case FTGL_POLYGON:
case FTGL_EXTRUDE:
case FTGL_TEXTURE:
case FTGL_BUFFER:
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(90, (float)w_win / (float)h_win, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, (float)h_win / 2.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
break;
}



it works but can someone explain how and how do I copy the current matrix, then modify it, and then return to the previous one. I need that so that I can render stuff then return the matrix to it's original form.

I think i should use pushMatrix and popMatrix. I'll look it up until someone post in case they find the answer before me.

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