Glut: Screen to world corrodinate mapping
I''m trying to map from mouse clicks on the screen to the openGl world corrident system,(ie, 0,0 is the middle of the screen)
this is the system I currently use.
x,y are supplied by glut.
float mappedX=((x/512.0f)-1.0f)*5.6;
float mappedY=((y/384.0f)-1.0f)*-4.2;
as anyone can see this only works when the screen resolution is 1024x768.
So I have a two part question,
1) is there a way to retrive the screen size using glut?
2) is there a better way to map screen to world?
-----------------------------------------------------
Writer, Programer, Cook, I''m a Jack of all Trades
Current Design project
Chaos Factor Design Document
1) Register a reshape function call back (glutReshapeFunc, as I recall), it takes two arguements, the screen width and the screen height. Store that someplace you can access it.
2)Well, if yer in 3d I would think that you would just use divide the mouse click height by total height and then use that as a modifier for your world coords, but that has more to do with 2d mouse to 3d world coords and I never was too good at that.
If you're in 2d you could change the coords displayed on the screen to something thats slighty easier to map to..
[edited by - _buu_ on January 5, 2004 1:00:04 PM]
2)Well, if yer in 3d I would think that you would just use divide the mouse click height by total height and then use that as a modifier for your world coords, but that has more to do with 2d mouse to 3d world coords and I never was too good at that.
If you're in 2d you could change the coords displayed on the screen to something thats slighty easier to map to..
[edited by - _buu_ on January 5, 2004 1:00:04 PM]
Once upon a time I made a small program what would let you drag shapes around the screen. It''s not glut, but it might still be useful.
It can be found here, and is entitled ''Dragging by Smart Idiot''.
It can be found here, and is entitled ''Dragging by Smart Idiot''.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement