Archived

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

Mouseposition on heightmap

This topic is 5339 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 like to read the mouseposition on a heightmap but it doesn''t work. Here is the code to read the mouseposition after drawing:
  
    GLdouble winz;
    glReadPixels(MouseX, MouseY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winz);
    GLdouble objx, objy, objz;
    GLint viewport[4];
    GLdouble modelMatrix[16];
    GLdouble projMatrix[16];

    glGetIntegerv(GL_VIEWPORT, viewport);
    glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
    glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);

    gluUnProject((GLdouble)MouseX, (GLdouble)MouseY, winz, modelMatrix, projMatrix, viewport, &objx, &objy, &objz);

    double x = objx;
    double y = objy;
    double z = objz;

    SetWindowText(g_window->hWnd, (FloatToStr(float(x)) + " - " + FloatToStr(float(y)) + " - " + FloatToStr(z)).c_str());  
If I follow a line with my mouse the Y-Position shouldn''t change but it does. (Even if there is no different height on the heightmap) Is there maybe an example how to read the mouseposition ?

Share this post


Link to post
Share on other sites