Usage of GLContex.useContext()

I’m confused about the usage of GLContex.useContext(). Can someone explain me its purpose ?

Is it useful for transferring textures to GL in a thread ?

For any particular thread there can be only one current GL context. Without a current GL context no GL commands will work and this will variously either crash the machine, do nothing, do something unexpected, or return an error code, depending on the driver quality.

Therefore, before doing any GL commands in a thread, always make sure you have a GLContext.makeCurrent() call. Use some unique object related to the context as the argument, eg. the pbuffer.

Cas :slight_smile:

I’m encountering a bunch of difficulties in creating textures from threads.

I think that the main problem is the Display, which doesn’t want to share his context with a previously allocated PBuffer (while vice-versa is possible).

With this feature I could create textures from any thread by simply pre-allocating a singletone “shared” pbuffer at program start.

Ok, maybe I’m making wrong deductions, but I already tried to allocate textures from threads and it works very well with pbuffers.