Jump to content
  • Advertisement
Sign in to follow this  
TRONJon

Immediate mode text alternative.

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!