Jump to content

View more

Image of the Day

Project built to test Unity's networking
#gamedev #indiedev #screenshotsaturday #indiedevhour #madewithunity https://t.co/vcsky4QFKr
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Help getting Mouse offsets using SDL/Opengl

2: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 GDsnakes   Members   

151
Like
0Likes
Like

Posted 03 November 2012 - 11:21 AM

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?

#2 zacaj   Members   

663
Like
0Likes
Like

Posted 03 November 2012 - 11:34 AM

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




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.