LWJGL Forum

Programming => OpenGL => Topic started by: Yohanu on April 07, 2010, 18:46:27

Title: AWTGLCanvas Trouble (modelviewmatrix nullpointer)
Post by: Yohanu on April 07, 2010, 18:46:27
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.
Title: Re: AWTGLCanvas Trouble (modelviewmatrix nullpointer)
Post by: Rene on April 07, 2010, 20:46:58
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
Title: Re: AWTGLCanvas Trouble (modelviewmatrix nullpointer)
Post by: Yohanu on April 07, 2010, 21:30:53
Hah, when you mentioned it i actually realized my erroneus thinking! Thanks :)