Main Menu

Text overlay

Started by technik3k, August 30, 2015, 02:02:39

Previous topic - Next topic

technik3k

How do I overlay Text in my window using openGL.

Cornix

You render text the same way you render everything else. You get a texture with the text and render it. And if you want it to be an overlay you render it on top of everything else with an orthogonal projection and depth testing disabled.

spasi

See the Truetype and EasyFont stb demos.

technik3k

Talking about text is there an easy way to read individual charachters from a string? ::)

pop_cs

Quote from: technik3k on September 17, 2015, 01:02:53
Talking about text is there an easy way to read individual charachters from a string? ::)

I would say:

char a_char = a_text_string.charAt(i);

technik3k

Would it work If I disable render with deapth when rendering text? And would I just do
glDisable(GL_DEPTH_TEST);
then when I'm done
glEnable(GL_DEPTH_TEST);

abcdef

yes, you also need to change your projection matrix to map coordinates to 2D instead of 3D