glWindow.getContext().makeCurrent();

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

glWindow.getContext().makeCurrent();

Mike
I've got a doozie for you guys. I'm using jogl2.0-rc10 and GLWindow. I want to load some textures on a different thread, so I use glWindow.getContext().makeCurrent(); to make the context current. The loading of the textures works fine, however, after I do this if i turn vsync on, my rendering becomes horribly choppy and crappy. If I load the textures in the GLEventListener.init() everything works fine.

Any idea whats going on here? My guess is that there is some locking issue with the context or something like that. Ive tried calling glWindow.getContext().release() after im done loading the textures but that doesnt seem to help at all.
Reply | Threaded
Open this post in threaded view
|

Re: glWindow.getContext().makeCurrent();

Sven Gothel
Administrator
On 10/04/2012 11:38 PM, Mike [via jogamp] wrote:

> I've got a doozie for you guys. I'm using jogl2.0-rc10 and GLWindow. I want to
> load some textures on a different thread, so I use
> glWindow.getContext().makeCurrent(); to make the context current. The loading
> of the textures works fine, however, after I do this if i turn vsync on, my
> rendering becomes horribly choppy and crappy. If I load the textures in the
> GLEventListener.init() everything works fine.
>
> Any idea whats going on here? My guess is that there is some locking issue
> with the context or something like that. Ive tried calling
> glWindow.getContext().release() after im done loading the textures but that
> doesnt seem to help at all.
The locking is intentional and required
since the drawable -> surface -> GLWindow is used as it's back buffer.

To have truly proper multithreaded texture loading,
you want to create an offscreen drawable (-> GLDrawableFactory),
probably PBuffer since you don't care for the actual back buffer[1].
Then you create a new context sharing your onscreen context, i.e.
   offscreenDrawable.createContext(glWindow.getContext())

Now you have 2 lock-free context, sharing it's resources.

Maybe we need a chapter in our Wiki about this :)
If unsure, pls check our unit test in JOGL repo,
they have the name 'Shared' in it's class name.

Note [1]: FBO would be a bit more expensive here,
since it creates an extra dummy surface. FBO is desired if you need to
use it as the back buffer.)

~Sven



signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: glWindow.getContext().makeCurrent();

Mike
yessss this works awesome. you are a god sir, thank you. I am also definitely going to give all you jogl guys a free copy of my game when it is finally done. Check its progress out here http://silvergoblet.tumblr.com/