Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL textures with multiple display contexts

I have an undefined number of display context and each will display a texture. When I call glGenTextures I get the same name returned across all display contexts. Will this work? Even though they have the same name will they still store and display different textures? If not what should do to get around this?

like image 406
Dan Vogel Avatar asked Oct 24 '08 02:10

Dan Vogel


3 Answers

Getting the same name from glGenTexture and having the same texture displayed is not the same thing.

Texture names are just integers at a context's discretion, usually starting with 1, and incrementing with every glGenTexture, but not necessarily so. An implementation is not required to work like that (although most do). However, you could in theory also get any more or less "random" number, such for example an integer that increments for any kind of object (i.e. not just textures, but also buffers and shaders), or even a 32 bit pointer address in the driver's address space, or some other esotheric thing. There is no requirement that a name must be something specific.

In legacy OpenGL, you could even make up your own names instead of using glGenTexture, but that is no longer legal now. I'm not sure what they thought when that was allowed, but anyway... :)

The same number (name) in a different context will usually be a different texture, or possibly no texture at all. So, if you do see the same texture in different context with the same texture name, then you either have shared contexts, or the driver is buggy.

Note that if you use wglCreateContextAttribsARB, the second parameter is the handle of an already existing context (or null). If you supply a context handle here, you will have shared contexts even without explicitly calling glShareLists. Maybe that is what happened by accident.

like image 111
Damon Avatar answered Nov 09 '22 05:11

Damon


Textures are not (by default) shared across contexts - you have to explicitly enable this, but how you do so is platform-specific.

On win32, it's wglShareLists, and on most other platforms it's specified when you create the context (eg. with the share parameter to aglCreateContext on OS-X).

like image 44
Menkboy Avatar answered Nov 09 '22 07:11

Menkboy


To my knowledge I have not enabled any texture sharing. however, the same texture is being displayed across all display contexts.

like image 1
Dan Vogel Avatar answered Nov 09 '22 06:11

Dan Vogel