Hi,
I'm trying to use TextRenderer (from com.jogamp.opengl.util.awt) to draw a label on screen; My application makes use of PBOs to render a video stream on a texture. When I call textRenderer.beginRendering(width, height) it throws the following exception: "Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: unpack pixel_buffer_object must be disabled to call this method." Is there a way to render the text even if using Pixel Buffer Objects? Thanks in advance |
Administrator
|
Hi
Disable PBO before calling beginRendering() and reenable PBO after calling endRendering().
Julien Gouesse | Personal blog | Website
|
How should I do that?
There isn't any glEnable(...) for pixel buffer objects... I just generate them and then bind the appropriate one to be rendered on the texture; should I unbind it? 2011/10/14 gouessej [via jogamp] <ml-node+s762907n3422006h25@n3.nabble.com> > Hi > > Disable PBO before calling beginRendering() and reenable PBO after calling > endRendering(). > Julien Gouesse > http://tuer.sourceforge.net > http://gouessej.wordpress.com > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://forum.jogamp.org/JOGL2-TextRenderer-throws-GLException-if-using-Pixel-Buffer-Objects-tp3421923p3422006.html > To unsubscribe from JOGL2 TextRenderer throws GLException if using Pixel > Buffer Objects, click here<http://forum.jogamp.org/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3421923&code=bWFkYmF0ODdAZ21haWwuY29tfDM0MjE5MjN8LTEyODA1OTQ5Njk=>. > > -- Matteo Battaglio |
Administrator
|
No, you can disable this extension: ARB_pixel_buffer_object
http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt
Julien Gouesse | Personal blog | Website
|
I apologize for my ignorance, but I'can't figure out how to disable extensions
2011/10/14 gouessej [via jogamp] <[hidden email]> No, you can disable this extension: ARB_pixel_buffer_object Matteo Battaglio |
Administrator
|
In reply to this post by Matteo Battaglio
On Friday, October 14, 2011 04:49:57 PM Matteo Battaglio [via jogamp] wrote:
> > Hi, > I'm trying to use TextRenderer (from com.jogamp.opengl.util.awt) to draw a > label on screen; > My application makes use of PBOs to render a video stream on a texture. > When I call textRenderer.beginRendering(width, height) it throws the > following exception: > "Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: > unpack pixel_buffer_object must be disabled to call this method." > > Is there a way to render the text even if using Pixel Buffer Objects? since I am not so familiar w/ the ole text renderer, let me explain our buffer validation code which throws the exception .. 1st the GL spec for the motivation - check for GL_PIXEL_UNPACK_BUFFER: - http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml - http://www.opengl.org/sdk/docs/man/xhtml/glBitmap.xml ie. in glBitmap, the buffer pointer semantics will change to a byte offset of the mapped PBO. This is what the spec calls a latched state, where one command changed a state and impacts [many] other command[s semantic]. In JOGL we have 2 types of those methods (generated source code): +++ public void glBitmap(int width, int height, float xorig, float yorig, float xmove, float ymove, ByteBuffer bitmap) { checkUnpackPBODisabled(true); .. +++ and +++ public void glBitmap(int width, int height, float xorig, float yorig, float xmove, float ymove, long bitmap_buffer_offset) { checkUnpackPBOEnabled(true); +++ So you see, we have check proper usage of each function types which cannot be mixed while a PBO is enabled. I know, it kind of sucks that there is only one data channel in one GL context, so you cannot lets say stream data here async .. and push bitmaps there. However, this limitation is OpenGL related, not JOGLs fault. There are a few solutions to this though: - maybe it's possible to unbind your buffer ? - maybe use a 2nd shared GL context ? - maybe use direct_state_access http://www.opengl.org/registry/specs/EXT/direct_state_access.txt The last one, direct state access, works around this whole latched state confinement, allowing you to name buffers directly. For direct state access: check 'NamedBufferDataEXT(..)' which provide you equal functionality .. I have to admit, I haven't read the spec towards async data streaming (PBO) maybe we continue looking for it in the direct state extension here and create a unit test. > > Thanks in advance Thank you for your question, which motivates me to go deeper into the last named extension. We knew for years it's great. To bad it's not in ES2 .. but I guess that will changes soon with the next ES release. Hope the above pointers help a bit, let's discuss it here. Cheers, Sven > |
Administrator
|
In reply to this post by Matteo Battaglio
On Friday, October 14, 2011 05:49:06 PM Matteo Battaglio [via jogamp] wrote:
> > I apologize for my ignorance, but I'can't figure out how to disable > extensions as you have enabled it, but passing a 0 buffer id: http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); ~Sven |
In reply to this post by Sven Gothel
Thank you for the detailed explanation.
I've actually just tried to unbind the buffer, and doing so I can see the text rendered, but then when it's time for the decoder to obtain the buffer in which to store the first decoded video frame, the application crashes. It is surely caused by the unbinding of the buffer, even if I thought it still should have worked because when I attempt to draw the video frames on the texture, I first bind the right buffer object, and then call glTexImage2D() with its handle, so even if I later unbind it, it shouldn't create problems. However it is highly probable that the problem it's me not knowing exactly what effects glBindBuffer(..., 0) might have on currently-mapped buffer objects... (which are being filled in parallel by the decoder's thread). So, it seems that I'd better look at how to implement your 2nd solution, use a 2nd shared GL context. I'll try it and let you know! Thanks again |
OK, I played around with glBindBuffer and I found that I was forgetting to unbind the buffer in some parts of the code.
After fixing that, now the behaviour is that I can see the text until I try to display the first video frame texture because then my application crashes. If however I comment the 3 lines involving TextRenderer my application runs well (without rendering the text obviously). Then I tried replacing those lines with a piece of code which draws a texture image without using PBOs/VBOs (using vertex and texture arrays, like TextRenderer does if I'm not wrong), and all works fine. Could it possibly be an issue of TextRenderer? |
Administrator
|
On Monday, October 17, 2011 11:44:19 AM Matteo Battaglio [via jogamp] wrote:
> > OK, I played around with glBindBuffer and I found that I was forgetting to > unbind the buffer in some parts of the code. > After fixing that, now the behaviour is that I can see the text until I try > to display the first video frame texture because then my application > crashes. > If however I comment the 3 lines involving TextRenderer my application runs > well (without rendering the text obviously). > Then I tried replacing those lines with a piece of code which draws a > texture image without using PBOs/VBOs (using vertex and texture arrays, like > TextRenderer does if I'm not wrong), and all works fine. > Could it possibly be an issue of TextRenderer? sure .. how about setting the active texture when you toggle between your texture upload/usage and the text renderer ? can you provide a little unit test .. ie stream in a png file for example. ~Sven |
I found the problem: if I call textRenderer.setUseVertexArrays(false) everything runs well!
Actually I found that this issue happens if I make use of VBOs to render vertices, so it doesn't specifically involve PBOs (which I know are the same thing as VBOs to the GPU), neither textures. It is also worth noting that the application doesn't always crash at the first display of the panel, but sometimes at the 2nd or 3rd dispay. I attached an example code: at line 54 there's the line "textRenderer.setUseVertexArrays(true);" JOGLTextRenderingCanvas.java |
Free forum by Nabble | Edit this page |