1

How would one "lock" the mouse to a certain OpenGL window. Sort of like how it is done in Minecraft. Is GameDev a better place to ask?

genpfault
  • 51,148
  • 11
  • 85
  • 139
YourGamerMom
  • 377
  • 3
  • 13
  • 4
    OpenGL doesn't handle user input, as input is platform-dependent. A very simple solution is to just hide the cursor and set it's position to the center of the window every frame. However, this will leave you with less accurate and OS-accelerated mouse values. The other solutions will depend on which platform you're using. – Robert Rouhani Jul 06 '12 at 04:19

2 Answers2

0

Like Robert said in the comment, OpenGL doesn't actually do user input.

However, there are libraries that can abstract the platform dependent part away, such as LibSDL. You can use it to grab the mouse to your window.

cha0site
  • 10,517
  • 3
  • 33
  • 51
0

A similar question has been asked here, where a programmer used a class called robot to change the mouse position.

Code: Robot.moveMouse(x,y)

This code was written in java, however, There are several classes like robot that can do the trick!

One option is to constantly move the mouse to the center of the screen or wherever you want it.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83