vinodpatel, if you have a complex drawing operation, just do it on your main thread, then pass the optimized data over to the GL thread as raw vertex, color, normal, etc.
to visualize how a JOGL app looks in terms of threads google ThreadLister.java. it’s a small snippet of code that poles the current VM threads and shows their hierarchy and priority. or you can roll your own from calls to Runtime.
if you do so, you’ll see that the generic setup is something like:
-
some virtual machine threads ( secret stuff for running the VM )
-
some AWT threads ( mouse, windows, etc. ) – this is where your GLEventListener is working and living ( your renderer that responds to display() .
-
then you get some threads under main. this is your app. so in a way, you already have a thread going… your app. so unless this thing you’re drawing is so complex ( a 20 dimensional super surface, or some mathematical insanity ), there’s no reason to spawn a thread to draw it. and you MOST definitely don’t want to do it inside your display() method!!!
what you are looking to do probably is create an object which knows how to “draw” what you want, that is convert meaningful data from you into a big list of vertices, colors, normals, etc. this all happens in your main thread. then, every frame over at the JOGL thread, display() can call some method in your main thread, something like public synchronized BigListType getAllTheInfoNeedToDrawAThingy(). Then, the renderer can speedily whip through your data plugging your vertex info into raw OpenGL calls.
you’ll want to limit the amount of data you send to the opengl thread as much as possible. so if you are drawing the same thing over and over and just moving it around, etc. just make an opengl list, or vertex array, or vertex buffer.
hope that helps, and i hope i have the information i’ve given correct – please say so if i have it wrong gurus…
cheers