Sign in to follow this  
Vortez

Inneficient text rendering...

Recommended Posts

Hi, i've been using a slighly modified version of nehe font tutorial(lesson 43 i think) and it work just great. I modified it so it can render fonts the same way with differant screen size(stretching and such). The problem is, im rendering all the text over and over again every frame, and i was wondering if i should use a PBO or something similar to render them instead, to avoid wasting time, and update it only when something change. The problem is, i have really no idea how the PBO work... Would that require a lot of work to implement? Where can i find some basic example? Thx in advance.

Share this post


Link to post
Share on other sites
You're probably thinking of FBOs (Frame Buffer Objects) They aren't hard to do, you just need to make sure you have the correct extensions and that your FBO is complete. Look at Gamedev.net OpenGL FBO 101 When you enable a FBO, you just do your rendering operations like normal, except it will render into a texture rather than the main video buffer for the screen, so it should be trivial to extend this to your applications.

Indeed, this is how I do text, draw the characters to a framebuffer and just map that framebuffer onto a quad. Not only does this get you better performance rendering text (but it takes more memory) but it also makes it very easy to incorporate dynamic text as a decal for a model or a wall or something.

But it suddenly becomes trickier when you want to handle resizing the screen gracefully. When changing the resolution of the main window, you will probably want to change the resolution of the FBOs proportionally as well. This means reallocating the attached renderbuffers and textures with the new sizes. This is as simple as calling glRenderbufferStorage() or glTexImage2D() for each attached image but you must be sure that they overwrite the old buffers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this