Curve text rendering and glBindVertexArray(0)

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

Curve text rendering and glBindVertexArray(0)

amitshesh
I'm using JOGL and the new curve text rendering library. Everything works well on Windows. But on Mac OSX Sierra 10.12.6, the text rendering simply does not appear. I have isolated it to a call to glBindVertexArray(0) in my code, which I do after I am done rendering my own models but before JOGL text rendering takes over (in every frame). Doing this results in a "Pre GL error 0x502" from the curve renderer's shader code somewhere. Commenting out the glBindVertexArray(0) makes the text appear, but my own rendering disappears.

After trial and error, I found that surprisingly changing glBindVertexArray(0) to glBindVertexArray(1) makes everything appear with no errors. This is very bizarre, and this is a problem that I am facing only on Mac.

Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

gouessej
Administrator
Hi

What is the vertex array object name of your own rendering?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

amitshesh
If you mean the VAO id, it is 2 (found by stepping through the program).
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

gouessej
Administrator
Then, calling glBindVertexArray(1) probably binds the VAO used by the text rendering.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

amitshesh
Yes, I suspect so. My problem is that this workaround is not portable (I don't know if this workaround will always work on windows and linux). What if on windows it binds my vao to 1 (my code uses glgenvertexarray)? Does jogl assume or hardcode vao id 1 to its text renderer?

On Sep 20, 2017 3:55 AM, "gouessej [via jogamp]" <[hidden email]> wrote:
Then, calling glBindVertexArray(1) probably binds the VAO used by the text rendering.
Julien Gouesse | Personal blog | Website



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Curve-text-rendering-and-glBindVertexArray-0-tp4038188p4038191.html
To unsubscribe from Curve text rendering and glBindVertexArray(0), click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

Amit Shesh
OK, more information.

I tried to print all the vertex array objects currently in use at various points of my program:

Here is what I had right after the GLEventListener's init is called (before I do anything OpenGL-related):

VAO 1 is being used before any initialization!
VAO 2 is not being used before any initialization!
VAO 3 is not being used before any initialization!
VAO 4 is not being used before any initialization!
VAO 5 is not being used before any initialization!
VAO 6 is not being used before any initialization!
VAO 7 is not being used before any initialization!
VAO 8 is not being used before any initialization!
VAO 9 is not being used before any initialization!
VAO 10 is not being used before any initialization!

Curiously it shows that VAO id 1 is being used. I have no idea for what, but I assume this is some JOGL stuff.

Here is what I had after I do all the initialization of my code, but not the curve text renderer:

VAO 1 is being used after view initialization!
VAO 2 is being used after view initialization!
VAO 3 is not being used after view initialization!
VAO 4 is not being used after view initialization!
VAO 5 is not being used after view initialization!
VAO 6 is not being used after view initialization!
VAO 7 is not being used after view initialization!
VAO 8 is not being used after view initialization!
VAO 9 is not being used after view initialization!
VAO 10 is not being used after view initialization!

It shows that VAO 2 is now being used. I confirmed that this is used in my code, as it is using only one VAO.

Finally here is what I had after I initialized stuff for the curve text renderer (TextRegionUtil and RegionRenderer):

VAO 1 is being used after text renderer initialization!
VAO 2 is being used after text renderer initialization!
VAO 3 is not being used after text renderer initialization!
VAO 4 is not being used after text renderer initialization!
VAO 5 is not being used after text renderer initialization!
VAO 6 is not being used after text renderer initialization!
VAO 7 is not being used after text renderer initialization!
VAO 8 is not being used after text renderer initialization!
VAO 9 is not being used after text renderer initialization!
VAO 10 is not being used after text renderer initialization!

---

This last step shows that the curve renderer did not request any new VAOs. Thus, I suspect that the curve renderer code is using vertex buffer objects without using a vertex array object. This seems to make sense because when I say glBindVertexArray(1) instead of glBindVertexArray(0), it seems to work because it finds a valid VAO bound to the context.

As I understand it, using VBO without VAO is not allowed in the OpenGL core profiles. Mac OS X does not support OpenGL compatibility profiles, which may be why this error shows up only on a Mac but not windows.

Does this provide you any insight as to what may be going wrong?
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

gouessej
Administrator
JOGL creates a VAO and uses it with the VBOs without VAOs when using the core profile.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

amitshesh
Hmmm ok, is that what that vao id 1 is for?

It still does not explain why I get a 0x5032 Pre GL error from within the curve rendering code when I say glBindVertexArray(0) before calling that code. That leads me to suspect that it gets this error when it attempts to do something VBO-related, and there isn't a VAO bound to the context at that time because of using glBindVertexArray(0).

On Wed, Sep 20, 2017 at 3:22 PM, gouessej [via jogamp] <[hidden email]> wrote:
JOGL creates a VAO and uses it with the VBOs without VAOs when using the core profile.
Julien Gouesse | Personal blog | Website



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Curve-text-rendering-and-glBindVertexArray-0-tp4038188p4038194.html
To unsubscribe from Curve text rendering and glBindVertexArray(0), click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

gouessej
Administrator
Call this method to know whether JOGL needs to create a default VAO:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLContext.html#hasNoDefaultVAO()
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

jmaasing
If I interpret the original poster correctly the problem seems to be that the text renderer assumes (wrongly) that it can use VBOs without binding a VAO.
So I guess it doesn't really matter if JOGL creates a 'default' VAO or not unless that 'default' VAO is bound by the text renderer.
Reply | Threaded
Open this post in threaded view
|

Re: Curve text rendering and glBindVertexArray(0)

amitshesh
I will use hasnoDefaultVAO() as you suggested. But as jmaasing says, this allows me a better workaround for the problem that I think exists in JOGL: it seems to use VBOs without VAO.

My workaround was as follows: generate a new VAO id before initializing the curve text renderer, and then bind that one before using the text renderer in any way, and unbind it afterwards. With this workaround the code seems to work correctly with glBindVertexArray(0) on Windows and Mac OSX. However it is not perfect, because my code now manages a VAO that is really used by JOGL, and not my rendering. Using hasNoDefaultVAO() will make this design slightly better, but it still sidesteps the original problem.