Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenGL Streaming Text

  • You cannot reply to this topic
1 reply to this topic

#1 TRONJon   Members   -  Reputation: 191

Like
0Likes
Like

Posted 11 June 2014 - 03:27 PM

Hey everyone, just wanted to find out how everyone else would tackle this problem in the industry...

In my effort to convert my engine to newer OpenGl standards, I'm moving my text renderer from Immediate mode to using vertex buffers.

 

I've made a Text class which you create and pass a String to it's constructor along with other arguments... this object will generate a Vertex Array Object, and a Buffer Object and render the quads/triangles needed to draw the string of text into the buffer.

This works... until I need to change the text, like with a live FPS counter for example.

 

I have a setValue() function/method which lets me change the value of an existing Text object, by simply generating a new vertex array, and using glBufferData to swap it in the VAO. Problem is, it's losing all of the pointers to the vertex data, I have a feeling this is because glBufferData actually replaces the buffer altogether losing the pointers... 

 

I've tried using glBufferSubData() but that still shows the same symptoms (Quads are drawn all over the game in random places and colours, totally nonsense).

 

 

Basically, can someone tell me whats the best way they know of rendering live text in OpenGL nowadays? :)

 

 - Jonathan



Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3226

Like
2Likes
Like

Posted 11 June 2014 - 05:26 PM

i allocate 1 large buffer for my ui mesh on the gpu, and the same size buffer locally for the cpu.  i draw all my ui stuff(this includes dynamic text) into the local buffer, mark the buffer complete when the frame has finished.  then on the next render frame, i check if the buffer has been updated, if so i update the gpu buffer, and clear the local one for writing again.

 

this is pretty much the only way i know to do dynamic ui stuff, since it's constantly changing.


Edited by slicer4ever, 11 June 2014 - 05:34 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.





PARTNERS