Picking and Threads

Started by ksullivan, September 20, 2010, 11:59:43

Previous topic - Next topic

ksullivan

Hi

I'm trying to decide between two methods of solving a picking problem.

I am rendering a quad which can be rotated, scaled and translated. I want to be able to click on the screen and determine where on the quad I have clicked (I.E. Intersect a ray created from the mouse location with the plane in which the quad lies)

To calculate the ray, I need the viewport, modelview matrix and projection matrix.

When the mouse is clicked, the event comes through on another Thread (The AWT/Swing Thread). My question is which would be better:

A) Call AWTGLCanvas.makeCurrent(), use GL11.glGetInteger and GL11.glGetFloat to obtain the information we need to calculate the ray and do the intersection. Finish by calling AWTGLCanvas.releaseContext().

B) Keep the calculations "offline" by storing the modelview and projection matrices outside of OpenGLs state so that no OpenGL calls are neccessary.

I have a feeling that option B is the better and more modern style (I.E. The modelview and projection matrices should be managed "client side" or "offline" with you're own math library as methods such as glRotate, glTranslate, ... are being depricated)

My worry with A is threading issues=crash.

Does anyone have any opinions on this?

Thanks

KSullivan

Matthias

Yes, calculate all matrices using a math library and upload the finished matrix to OpenGL for rendering. You should not ask OpenGL for data you already know.
Why do you still use AWTGLCanvas ?

ksullivan

Quote from: Matthias on September 20, 2010, 12:32:50
Yes, calculate all matrices using a math library and upload the finished matrix to OpenGL for rendering. You should not ask OpenGL for data you already know.
Why do you still use AWTGLCanvas ?

I want to draw to an AWT/Swing component which I can integrate into the main JFrame of my application along side other AWT/Swing components. Is there another (better?) way for me to achieve this? Maybe Display.setParent(java.awt.Canvas) ? Is there any reason why using Display with Display.setParent(java.awt.Canvas) would be any better or worse than using AWTGLCanvas?

Hmm it seems this opinion has been voiced here aswell http://lwjgl.org/forum/index.php/topic,3406.msg18859.html#msg18859