ProfEich
05-07-2003, 04:09 AM
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 ?
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 ?