Jump to content
  • Advertisement
TMII

OpenGL Text rendering really slow

Recommended Posts

It is not the amount of data you are rendering, it is simple the amount of different render passes you have that causes performance impact. Rendering 1000 Quads makes a difference to rendering a VBO including 1000 quads.

For UI in general there is an approach used by AAA games to batch as much of the UI as possible. So a large UI can be handled in a smal count of render passes. Everytime something changes the VBO is updated calculating the whole component tree and add as much vertices into the buffer as possible.

Text has two different states, static text or text intended to change a few times but not more is batched into the VBO too while dynamic text has it's own render-pass together with all the other dynamic text. An example for one or the other is a Button or Menu title against a Timer for example.

Either you update the VBO for the dynamic text too like you do for the static one or you have for example certain shader that consumes a Uniform-Array. Every entry in that array is a character value or texCoord (this depends on your font) and the Shader finally just shifts the texCoord of the currently rendered quad the character currently in range.

I use the Shader solution for debug text drawn in OpenGL 4+

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)
On 7/11/2019 at 12:51 PM, TMII said:

Thank you. I am going to avoid uniforms then. It's the same with glBufferSubData it seems.

I didn't mean you should avoid uniforms, just not use them as a substitute for VAOs, because it seems to me that is the case. Maybe my opinion differs here from @Shaarigan's ?

glBufferSubData is the correct function to update a buffer object, whatever binding point it might be bound to. It can be used when the cost of reallocating buffer storage is too high. It may be the case though that a buffer update can stall the pipeline, in which case multiple buffer objects or mapping and updating of regions of a buffer may be the better solution.

I also think that instancing may not be the right way for drawing text, because there are more modern and flexible techniques than drawing sprites or bitmaps. I found another link that describes some details. But i personally am content with the functionality imgui provides. I doubt i can do it faster.

Edited by Green_Baron

Share this post


Link to post
Share on other sites

The OpenGL SuperBible has an example of rendering quads and bitmaps, called "alienrain". The source is on github.

Just for completeness, maybe it can be helpful .... 🙂

Edited by Green_Baron

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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!