View Full Version : Rendering fonts in OpenGL 3

04-07-2011, 02:39 PM
I am trying to find out how to do this. Of course, it is possible to do it the hard way using bitmaps.

But there should be portable solutions that someone else did?

The problem with searching on Internet is that almost everything you find is based on deprecated or removed functionality, without explicitly stating so.

04-07-2011, 02:46 PM
Most games ive seen do this with a texture that contains the alphabet.
These can be easily generated (for example with freetype).
Quality isnt all that great, but its enough for most apparently plus its very simple to do.

04-07-2011, 08:43 PM
OGLFT library can be modified to use the core GL 3 and over functionality.

This one issue we should address. Removed OpenGL functionality should have been moved instead to glu or an alive auxiliary library, otherwise that was a backward step.

Alfonse Reinheart
04-07-2011, 10:10 PM
It's not a "step" at all; you can just create a compatibility context and it all magically comes back.

04-08-2011, 01:05 AM
Using a compatibility context looks more easy to me than porting OGLFT to GL 3. How do you define a compatibility context?

What should I do with the shader program? Disable it, or use a special shader for OGLFT?

At first, I checked the documentation and it said that glUseProgram (0) is legal but undefined. But the 2.1 documentation says that rendering will go back to fixed functionality. Maybe that is all that is needed?

04-08-2011, 01:40 AM
Use WGL_ARB_create_context_profile extension to create the compatability profile.

see here (http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt)

Alfonse Reinheart
04-08-2011, 01:49 AM
How do you define a compatibility context?

If you're using WGL directly, a guide (http://www.opengl.org/wiki/Creating_an_OpenGL_Context) is available. If you're using GLX, it's a matter of using GLX_ARB_create_context_profile. So you have to get the function pointers (probably through an extension loading library) and use them.

In both cases, you must provide the CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB flag through the CONTEXT_PROFILE_MASK_ARB attribute.

So your context creation attributes would look something like this:

int context_attribs[] =

At first, I checked the documentation and it said that glUseProgram (0) is legal but undefined.

What they mean is that you can't render with no program bound. Which is true, since the fixed-function pipeline is removed in core.

04-08-2011, 02:33 PM
Thanks, got fonts working now!