Login  Register

OpenGL & multi-threading...

Posted by AlexRNL on Mar 11, 2011; 4:47pm
URL: https://forum.jogamp.org/OpenGL-multi-threading-tp2665744.html

Hi there,

I am having some difficulties (concerning JOGL & OpenGL ^^) with solving a problem and I'm not sure which way is the best.

My problem is the following: I have to map a texture on a surface (a square). This texture is built from a BufferedImage that is updated permanently. To avoid obvious performance issues, i'm not building the texture each time i'm going in the draw loop.

So I was thinking of put the method which loads the texture in an other thread which can be called regularly. When I tried to set up a simple TimerTask (just as a test), I had a problem with GLContext. It seems that only one thread may have a GLContext at a time.

My idea was to pre-load the TextureData with a thread (this function doesn't seems to need a GLContext) and notify the OpenGL thread when the texture needs to be refreshed.

So I was wondering if my method for texturing an image (which is updating continuously) was fine or if this is totally nuts (I don't have a lot of experience with OpenGL and JOGL so...). If there is a more appropriate technique to realize that, I'd really like to know about it :)

Thanks in advance for your answer,
Alex.