Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1959
  • Last Modified:

Mouse Control - OpenGL

Ok my question is simple enouph as many people have gatherd I've been making a 3d pong game. I am trying to add mouse control however its proving rather difficult as the OpenGL coidinates are different to the mouse cordinates on the screen . This means I can't say ptx(player translate x) = x (passive mouse motiion x) the same with the y.  Could someone help me liike tell me an equation or something . If you need anyinfo don't hessitate to ask . Im stuck until I get this done. No your not doing my uni homework either because im still in secodary school (year 10).

PS. I took a break from my game a while ago im not that slow

Thank you please help.

0
Paladin_VB
Asked:
Paladin_VB
  • 2
1 Solution
 
n_fortynineCommented:
Well, what OpenGL returns to you as the y coor will be the distance from the top of your (program) window to the current position of the mouse, while your supposed screen coord y will start from the bottom of your window and go up.
For example:
-------------------TOP OF WINDOW -----------------------




   Mouse -->  + (x, WIN_HEIGHT - y)






------------------BOTTOM OF WINDOW-------------------
If that's not what you're looking for please be more specific.
0
 
ImhotepCommented:
you could use the new glut functions for mouse control: at the beginning you plave the mouse at the center of the window by using glutWarpPointer. Then, every frame you take the difference between the mouse position and the window center and move your player, maybe in z-direction for mouse movement in the x-direction or so. Finally you warp the cursor back to the window center.

Imhotep
0
 
Paladin_VBAuthor Commented:
I managed to solve it myself although what you said fortynine did help me. You can have the points
0
 
n_fortynineCommented:
Paladin_VB you can finalise the question by clicking Accept Comment I hope you've already known that. :)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now