PDA

View Full Version : Rendering fonts in OpenGL 3



Kopelrativ
04-07-2011, 03: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.

kyle_
04-07-2011, 03: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.

glfreak
04-07-2011, 09: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, 11:10 PM
It's not a "step" at all; you can just create a compatibility context and it all magically comes back.

Kopelrativ
04-08-2011, 02: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?

BionicBytes
04-08-2011, 02: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, 02: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[] =
{
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.

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