Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

lukej
I've had some issues with the com.jogamp.opengl.util.awt.TextRenderer.  Namely, it seems to leave something in a strange state such that my own VBO code crashes after using this class to render text on some ATI graphics cards.  For now I have a workaround that calling setUseVertexArrays(false) fixes my issues.

I did a little research and it seems that this class has been abandoned for the better com.jogamp.graph.curve.opengl.TextRenderer.  However, I am unable to figure out exactly how to use this class and I can't find a good example either.  Can anyone provide an example of how to use this class to draw text on the screen.

Specifically I'm interested in 2 scenarios:
1. Drawing text on a Heads Up Display with statistics.  This will always be done in Ortho 2D.
2. Drawing labels near items in my 3D scene.  These labels will always be "billboarded" toward the camera, but they will move with respect to the camera.  This will be done in Perspective 3D, but as mentioned they will always face the camera.

Thanks!

Luke
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

gouessej
Administrator
Hi

I had the same problem, it didn't occur anymore once I unbind my VBOs correctly, I didn't try to use another text renderer. The best way to avoid these crash consists in avoiding using VBOs when the text renderer uses only vertex arrays, which happens with graphics cards supporting VBOs but not OpenGL 1.5, it was the case of my previous graphics card ATI Radeon 9250 Pro.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

lukej
Can you elaborate on what you mean by "unbind my VBOs correctly"?

After every glBindBuffer call, I have a matching glBindBuffer call that binds it to 0.  Is that what you mean?  I'm still getting issues though.  

Also, the ATI graphics card and driver I'm using have GL 1.5 available.  The card is a Radeon HD 5700 series with the latest driver.
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

gouessej
Administrator
That's what I meant. I think that you get crash because of interlacing calls to the text renderer and calls to other drawings. Do you use some VBOs between the beginning and the end of text rendering?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

lukej
So I wasn't actually getting a crash (though I've seen the issue you are talking about on the older ATI cards).  My vertex array was just getting messed up and things weren't displaying where they should be.  I have tracked it down and I figured out that it was because I was not calling glVertexAttribPointer before every glDrawElements.  I was just calling it once after every glBufferData.

For some reason on NVidia hardware, this wasn't a problem, but on ATI hardware I have to call glVertexAttribPointer again before every glDrawElements when I use the TextRenderer.  My guess is that this is a property that gets push'd/pop'd on NVidia hardware and not on ATI hardware, probably due to some ambiguity in the OpenGL specification.

I would still like to know how the other TextRenderer class works though, especially if it performs better.  It's in the code base, why not have an example showing how to use it, right?

Thanks!
Luke
Reply | Threaded
Open this post in threaded view
|

Re: Can anyone provide an example of how to use com.jogamp.graph.curve.opengl.TextRenderer

Sven Gothel
Administrator
In reply to this post by lukej