LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Need help with text rendering  (Read 2974 times)

Oflor

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
Need help with text rendering
« on: March 30, 2012, 06:51:38 »

Hi there.
Could someone tell me how to render text in OpenGL? We don't want to use any other libs like slick.
We have found one example but we can't get it to work with our own rendering code. It just doesn't draw anything.

This is our gl-init code:
Code: [Select]
private void glInit()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, h, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0f, 0.0f, 0.1f, 1.0f);
buildFont();
}
And we run this before any renderings:
Code: [Select]
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
Actually, we are new to OpenGL. Thanks, Oflor.
Logged

kappa

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1301
Re: Need help with text rendering
« Reply #1 on: March 30, 2012, 09:08:10 »

OpenGL has no built in mechanism for drawing fonts or text, so you'll have to create your own. The most common approach is to usually use Bitmap Fonts similar to how the Slick Util library does it.
Logged