Jump to content
  • Advertisement
Sign in to follow this  

OpenGL gluUnProject always failing?

This topic is 3705 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm working through some simple examples but for some reason gluUnProject seems to always fail. I am following the example from the OpenGL Programming Guide and it seems pretty straight forward. I am testing this in wxWidgets (although I doubt that matters), here is the code I am using: void TestGLCanvas::OnMouseEvent(wxMouseEvent& event) { if (event.LeftDown()) { GLint viewport[4]; GLdouble mvmatrix[16], projmatrix[16]; glGetIntegerv(GL_VIEWPORT, viewport); glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix); glGetDoublev(GL_PROJECTION_MATRIX, projmatrix); int x = event.GetX(); int y = event.GetY(); GLdouble rx, ry, rz; if (gluUnProject((GLdouble) x, (GLdouble) y, 0.0, mvmatrix, projmatrix, viewport, &rx, &ry, &rz) == GLU_FALSE) { return; } assert(0); _RPT2(_CRT_WARN, "Window Coordinates: (%f, %f)\n", x, y); _RPT3(_CRT_WARN, "World Coordinates: (%f, %f, %f)\n", rx, ry, rz); } } All I am doing is calling gluUnProject with all the parameters passed in and it never hits that assert no matter where I click on the canvas. Am I doing something wrong?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!