MarsaPalas
MarsaPalas

Reputation: 415

glGenBuffers() object names in different OpenGL contexts

Let's say there is a GUI program with two windows. Each window has its own OpenGL context. There is only one thread.

At some point we want to render stuff in the first and in the second window, so we allocate one buffer for each of the OpenGL contexts with glGenBuffers(1, &buffer_) (among other stuff).

My question is, does the glGenBuffers() function returns unique object names globally, or is it local for each of the OpenGL contexts? In other words, can these two OpenGL contexts have the same object names given by the glGenBuffers()? Apart from object name == 0 of course, which is a special object name.

In case they can, does it mean they share this object name? What would happen if one of the OpenGL contexts deallocates the object by glDeleteBuffers(1, &buffer_)?

Upvotes: 0

Views: 101

Answers (2)

MarsaPalas
MarsaPalas

Reputation: 415

The two contexts in my example were not shared (according to genpfault it's the default behavior). Yet, the VBO object names acquired by the glGenBuffers() function were the same in both contexts.

Everything runs smoothly, I can switch between two windows and modify object VBOs presented there (like colors) or their shader uniforms (like camera position)).

I'm using PyQt5 biding for Qt framework and the graphics renderer is Intel(R) UHD Graphics 630. The program had one QMdiSubWindow with two instances of QMdiSubWindow, each containing one rendered object.

I can only conclude that in this case, when contexts are not shared, object names are unique for the context.

Upvotes: 0

genpfault
genpfault

Reputation: 52082

Depends if the contexts are in the same share group or not.

See chapter 5 of the OpenGL 4.6 Core Profile specification, "Shared Objects and Multiple Contexts".

Upvotes: 2

Related Questions