AWTGLCanvas Trouble (modelviewmatrix nullpointer)

Started by Yohanu, April 07, 2010, 18:46:27

Previous topic - Next topic

Yohanu

Hello, i have a pretty big problem related to the modelviewmatrix and an AWTGLCanvas.
"GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, bufferModelviewMatrix);" throws a nullpointer (possibly because of threading issues?)

My problem is that this acts as a "map editor" and whenever i click on the canvas it is supposed to calculate screen to world coordinates. I am not sure how to get around this problem without overdesigning things (implementing a queue and everytime user clicks, add the action to a queue which is executed during the paintloop).

Any hints on how to circumvent this nasty problem? Thank you.

Rene

Mouse clicks are handled on the EventQueue. All OpenGL calls must be made from the same thread you created the context on.

You could try the following solutions:
- Calculate transformation matrices yourself (what you should be doing anyway IMHO ;) ), and make the matrix available to your mouse handlers
- Let OpenGL calculate the matrix using lookAt, translatef, etc., then get the matrix from OpenGL and make it available to your mouse handlers
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

Yohanu

Hah, when you mentioned it i actually realized my erroneus thinking! Thanks :)