Jump to content


gluProject issues


2 replies to this topic

#1 boombatower

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 June 2007 - 09:18 PM

DoubleBuffer model = DoubleBuffer.allocate(16);
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, model);

DoubleBuffer proj = DoubleBuffer.allocate(16);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, proj);

IntBuffer view = IntBuffer.allocate(4);
gl.glGetIntegerv(GL.GL_VIEWPORT, view);

DoubleBuffer winPos = DoubleBuffer.allocate(3);
glu.gluProject(x, y, z, model, proj, view, winPos);

Everywhere else I see this it works, but for me it doesn't. I get something that is [(same as object's x), 1024, 3]

Example matrices that OpenGL is returning:
MODELVIEW_MATRIX:
[1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]

PROJECTION_MATRIX
[0.0015625000232830644, 0.0, 0.0, 0.0, 0.0, -0.001953125, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 1.0, -0.0, 1.0]

VIEWPORT
[0, 0, 1280, 1024]

I am using Java and JOGL. Any suggestions on how to debug this?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 14 June 2007 - 03:31 AM

Make sure you set the matrix mode (glMatrixMode), and load the identity (glLoadIdentity) before calling gluProject.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 boombatower

    New Member

  • Members
  • Pip
  • 5 posts

Posted 16 June 2007 - 08:36 PM

The problem was that I was attempting to get the matrices from OpenGL after I had set it up to render 2d. Thus the matrices were not what they are for 3d. I already have a camera class that contained the matrices and after using them it worked.

Thanks for the response.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users