Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Mouse Control - OpenGL

Posted on 2003-11-20
4
1,945 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
ID: 9791906
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
ID: 9796532
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
ID: 9798263
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
ID: 9801872
Paladin_VB you can finalise the question by clicking Accept Comment I hope you've already known that. :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

789 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