Sign in to follow this  
Followers 0
MylesEvans

OpenGL
Help getting Mouse offsets using SDL/Opengl

1 post in this topic

I'm using SDL and when I try and assign a drawn objects offsets to the position of the mouse (so it moves with mouse) it seems that it works for the x axis but the y axis seems to be inverted. When I move mouse up, Object goes down. When I move mouse down objects goes up. X-axis is fine though.


Is there a way for me to get the x/yaxis of mouse using Opengl? I need them individually. Does opengl allow a way to get the offsets of the mouse like in sdl? Where I can get x using mouse.motion.x and Y using mouse.motion.y?
0

Share this post


Link to post
Share on other sites
OpenGL doesn't have anything to do with the mouse, that is only handled by SDL. SDL gives the mouse position in window coordinates, you need to handle converting the window coordinates to whatever scale openGL is using on your own. By default openGL has the top of the window as positive y, while SDL has it as 0, which explains why it seemed inverted. The easiest way would just be to invert your y axis and be done with it
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0