Immediate mode text alternative.

This topic is 1570 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm moving away from Immediate mode rendering and display lists, and started using vertex buffers... but I've hit a problem when it comes to rendering text.

For example when drawing my FPS meter, the value changes all the time, so currently my text render sends a texture mapped quad to the GPU for each character, and this works exactly as I want... but if immediate mode rendering is deprecated... how am I supposed to draw data that changes every frame?

Surely using buffers would be a bit overkill? What does everyone else use for this?

- Jonathan

Share on other sites

Assuming you have a four digit counter, the vertices for the 4 quads (8 tris) will be static, but the texture coordinates will change each frame. Say each characters uses a 16x16 section of the texture: if you initially assign the texture coordinates based on [0,0] to [15,15], you only need to send in 4 new [x,y] offset values to add to the existing ones.

However, when debugging, there's actually nothing inherently wrong with immediate mode, and it could be argued that it makes you're code cleaner and leaner in release mode. Use whatever is most convenient.

Edited by mark ds

Share on other sites

As stated already in this thread, buffers are the way to go!

For some example text-rendering code (plus some goodies like SDF scalable rendering + effects) take a look at:

https://github.com/rougier/freetype-gl

Personally I use a hybrid approach of using a plain pre-rendered texture-atlas for small font sizes (8-12) and a single pre-rendered signed-distance-field texture-atlas scaled to all other sizes. All using VBO's of course, only difference between rendering both variants being the fragment shader code.

Edited by h3xl3r

Share on other sites

look at my signature ;)

Share on other sites

look at my signature ;)

Awesome =)

Btw. don't use if (variable) delete variable;

ptr
A pointer to the memory block to be released, type-casted to a void*.
If this is a null-pointer, the function does nothing.

Edited by Kaptein

Share on other sites

look at my signature ;)

Awesome =)

Btw. don't use if (variable) delete variable;

ptr
A pointer to the memory block to be released, type-casted to a void*.
If this is a null-pointer, the function does nothing.


whoa, I actually know about this, dunno how it got into my code... where did you find it?

Share on other sites

look at my signature ;)

Awesome =)

Btw. don't use if (variable) delete variable;

ptr
A pointer to the memory block to be released, type-casted to a void*.
If this is a null-pointer, the function does nothing.


whoa, I actually know about this, dunno how it got into my code... where did you find it?

Not a big deal at all. Nice library though.

The extraneous if() I just happened upon is in new_raytracer/material.h

Share on other sites

look at my signature ;)

Awesome =)

Btw. don't use if (variable) delete variable;

ptr
A pointer to the memory block to be released, type-casted to a void*.
If this is a null-pointer, the function does nothing.


whoa, I actually know about this, dunno how it got into my code... where did you find it?

Not a big deal at all. Nice library though.

The extraneous if() I just happened upon is in new_raytracer/material.h

thanks, will correct it :)
btw it shouldn't affect libmymath, it's just an experimental raytracer I fiddled with.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 13
• 10
• Forum Statistics

• Total Topics
632582
• Total Posts
3007208

×