Are buffers created with glGenBuffersARB bound to the current context?

Started by
5 comments, last by Aks9 13 years ago
I'm writing an API and I need to render to user created windows. I'm having a problem where if I create another window and context my program will crash when I try to render buffers that were created while another context was current. I can only assume this is because the buffers are bound to the context that was current at the time. If this is the case then how do I create a vertex or index buffer that is independent of the context?
Advertisement
Everything in OpenGL operates on, and is bound to, the current context. Look up context sharing if you need to share buffers between contexts. This, however, is outside OpenGL and is tied to the glue layer for your specific platform (wgl for Windows for example), and does really not change that resources are bound to contexts. You cannot make global resources not tied to any context in OpenGL.

You're not giving very specific descriptions of your setup, so can only give you a general hint; consider if using a single context for all windows is working for you.
The answer is quite simple: Create sharing context group, and all buffers created in one of them can be accessed from the others.
What version of OpenGL are you using, and on which OS? Answers to these questions enables more precise and concrete hints. ;)

If you are on Windows
http://www.opengl.org/wiki/Platform_specifics:_Windows#wglShareLists
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

If you are on Windows
http://www.opengl.or...s#wglShareLists


wglShareLists() is deprecated approach. Further more it doesn't work any more. I've already mentioned that share group is the only valid way to deal with sharing on GL 3.0+ contexts. That's why I ask for more details about the OS and GL version. It's about the time to update Wiki on OpenGL.org. ;)

[quote name='V-man' timestamp='1304353895' post='4805529']
If you are on Windows
http://www.opengl.or...s#wglShareLists


wglShareLists() is deprecated approach. Further more it doesn't work any more. I've already mentioned that share group is the only valid way to deal with sharing on GL 3.0+ contexts. That's why I ask for more details about the OS and GL version. It's about the time to update Wiki on OpenGL.org. ;)
[/quote]

What the heck is a share group? :)
I'll update it when and if I learn something new.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

What the heck is a share group? :)
I'll update it when and if I learn something new.


Should I teach you? :cool:


I really doubt it is necessary. Well, in shot, sharing should be defined at context creation time. Take a look at WGL_ARB_create_context spec, or more precisely at function:

HGLRC wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext, const int *attribList);


The second parameter is a rendering context handle which belongs to the same share-group as created one.

You probably haven't used sharing recently (several passed years). The whole OpenGL spec is huge. If there is something you don't need you'll probably never notice that even exists. That's why I'm sniffing through the forums, hoping that I'll find something I'm mot aware of but can be useful ... :)

This topic is closed to new replies.

Advertisement