Using Mouse with GLUT
Posted: Fri Mar 27, 2009 8:16 am
I figured it'd be wise to have mouse functionality when I'm making a map editor for my little RPG so I started looking at the glut mouse funcs.
Pretty easy, it seemed, but I ran into a problem pretty quickly:
The passive mouse func gives me numbers that are pretty useless as it is now... Glut thinks that the upper left corner of my program is 0,0 and the lower right corner is (the current width),(the current height) <--- Of the window. I really like having the lower left corner as 0,0 so that's how I want it, this isn't very hard to do, I could probably have it working by the time I finish writing this topic but solving scaling of the window is harder...
Is there a function similar to gluOrtho2D that sets glut to "think" the way I tell it to? Something like this
glutMouseCoordinateOrientation(0, 240, 0, 160); <----- Game Boy Advance screen size, with Lower Left as 0,0
Is this possible or do I have to set up functions to calculate and track the window size and then us division to find the "correct" mouse position?
Pretty easy, it seemed, but I ran into a problem pretty quickly:
The passive mouse func gives me numbers that are pretty useless as it is now... Glut thinks that the upper left corner of my program is 0,0 and the lower right corner is (the current width),(the current height) <--- Of the window. I really like having the lower left corner as 0,0 so that's how I want it, this isn't very hard to do, I could probably have it working by the time I finish writing this topic but solving scaling of the window is harder...
Is there a function similar to gluOrtho2D that sets glut to "think" the way I tell it to? Something like this
glutMouseCoordinateOrientation(0, 240, 0, 160); <----- Game Boy Advance screen size, with Lower Left as 0,0
Is this possible or do I have to set up functions to calculate and track the window size and then us division to find the "correct" mouse position?