Hello Guest

AWTGLCanvas Trouble (modelviewmatrix nullpointer)

  • 2 Replies
  • 2923 Views
AWTGLCanvas Trouble (modelviewmatrix nullpointer)
« 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.

*

Offline Rene

  • **
  • 78
Re: AWTGLCanvas Trouble (modelviewmatrix nullpointer)
« Reply #1 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
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

Re: AWTGLCanvas Trouble (modelviewmatrix nullpointer)
« Reply #2 on: April 07, 2010, 21:30:53 »
Hah, when you mentioned it i actually realized my erroneus thinking! Thanks :)