Reputation: 175
I'm trying to use the mouse listener in Haskell using OpenGL and have run into a problem. Apparently the return given for the x and y coordinates is a GLint. The problem is in then using these because I need a GLfloat. Simple parsing doesn't appear to fix the problem. On a more technical note, why would this return an int at all when the entire size of the screen is represented in OpenGL as only 1 square unit?
Upvotes: 1
Views: 289
Reputation: 26167
GLUT or GLFW, which are the toolkits that you're probably using to access OpenGL, manage windows for you. They have no idea about what the current view port looks like -- heck, you could even be rendering to only a quarter of the window; that'd mess up your coordinates pretty badly if GLUT/GLFW cared about OpenGL coordinates! Luckily, they do not; the x
and y
coordinates that you're getting are actual pixel coordinates on the window, and I think that (0, 0)
even is in the top left, with the Y axis going downwards. The mouse coordinates are completely separate from OpenGL.
Nonetheless, you can convert a GLint
into a GLfloat
using fromIntegral
.
Upvotes: 3