Hello Guest

TrueTypeFont problem

  • 0 Replies
  • 2870 Views
TrueTypeFont problem
« on: January 01, 2011, 22:44:05 »
I'm trying to use TrueTypeFont like this tutorial suggest.

Rendering only the text is working fine. Including the drawing of a Quad, doesn't make any shape visible.
As soon as I comment the line [font = new TrueTypeFont(awtFont,true);], I can see the square as expect.

Init code
Code: (Init) [Select]
Display.setTitle(GAME_TITLE);
Display.setFullscreen(fullscreen);
Display.setDisplayMode(new DisplayMode(600, 400));

// Enable vsync if we can (due to how OpenGL works, it cannot be
// guarenteed to always work)
Display.setVSyncEnabled(true);

Display.create();

width = Display.getDisplayMode().getWidth();
height = Display.getDisplayMode().getHeight();

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, width, height, 0, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

//Font
Font awtFont = new Font("Verdana", Font.BOLD, 20);
font = new TrueTypeFont(awtFont,true);

GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);


//Background color
GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

Code: (Render method) [Select]
// clear the screen
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

//Text
//font.drawString(10, height/2-20, "Hello World",Color.black);

// rotate square according to angle
GL11.glPushMatrix();
GL11.glTranslatef(width / 2, height / 2, 0.0f);
GL11.glRotatef(angle, 0, 0, 1.0f);

GL11.glColor4f(0.0f, 1.0f, 0.0f, 0.5f);

GL11.glBegin(GL11.GL_QUADS);
{
GL11.glVertex2i(-50, -50);
GL11.glVertex2i(50, -50);
GL11.glVertex2i(50, 50);
GL11.glVertex2i(-50, 50);
}
GL11.glEnd();

GL11.glPopMatrix();

The problem should be reproducible from this class alone, by commenting and uncommenting [font = new TrueTypeFont(awtFont,true);]
Complete code : http://slexy.org/view/s2tomSoeLG