Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


OpenGL single Point picking

This topic is 5458 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

Hi! I''ve a problem! i want to pick a single point! the X and Y coordinates are ok, but i get the wrong z-value! here is my c++-code: wx=0;wy=0;wz=0; LX->Caption = X-FrMain->ClientWidth/2; LY->Caption = Y-FrMain->ClientHeight/2; float depth; GLint viewport[4]; GLdouble mvmatrix[16], projmatrix[16]; glGetIntegerv (GL_VIEWPORT, viewport); glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix); glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); GLint realy = viewport[3] - (GLint) Y - 1; glReadPixels(X,realy,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&depth); gluUnProject ((GLdouble) X, (GLdouble) realy, depth, mvmatrix, projmatrix, viewport, &wx, &wy, &wz); if(depth!=1) { wx = (wx+minx)+(dimx/2); wy = (wy+miny)+(dimy/2); wz = (wz)+(2*dimz); }else { wx = 0; wy = 0; wz = 0; } LX->Caption = wx; LY->Caption = wy; LZ->Caption = wz; maybe someone has/had the same problem! Thanks Laird

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!