Rendering fonts in OpenGL 3

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.

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.

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.

It’s not a “step” at all; you can just create a compatibility context and it all magically comes back.

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?

Use WGL_ARB_create_context_profile extension to create the compatability profile.

see here

How do you define a compatibility context?

If you’re using WGL directly, a guide 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[] =
  {
    WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
    WGL_CONTEXT_MINOR_VERSION_ARB, 3,
    WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
  }
};

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.

Thanks, got fonts working now!