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.
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
Hah, when you mentioned it i actually realized my erroneus thinking! Thanks :)