Solved

Mouse Control - OpenGL

Posted on 2003-11-20
4
1,938 Views
Last Modified: 2011-09-20
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
Comment
Question by:Paladin_VB
  • 2
4 Comments
 
LVL 4

Expert Comment

by:n_fortynine
Comment Utility
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
 
LVL 1

Expert Comment

by:Imhotep
Comment Utility
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
 
LVL 1

Author Comment

by:Paladin_VB
Comment Utility
I managed to solve it myself although what you said fortynine did help me. You can have the points
0
 
LVL 4

Accepted Solution

by:
n_fortynine earned 149 total points
Comment Utility
Paladin_VB you can finalise the question by clicking Accept Comment I hope you've already known that. :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now