Making a Smooth OpenGL Mouse Camera

So I've looked through some camera classes and none of them seem to address the fact that you should be able to keep rotating even if your mouse hits the edge of the screen. I've been doing a hack job to make it work in the past, but I was wondering what the correct way of actually doing it was.

Answers


The best way is to use mouse api that provides you both relative and absolute mouse movement. "Absolute" is current cursor position, "relative" means difference between current and previous position. For rotating camera (when cursor is at the edge) you should use "relative" mouse movement.

SDL can do that (but only if it "grabbed" mouse), and DirectInput can also do it. I don't remember if "relative cursor movement" data is available via standard system APIs, though.


The best way is to re-position the actual mouse cursor to the center of the screen when it moves, and obviously also hide it.


Need Your Help

UnitOfWork with Unity and Entity Framework

c# .net entity-framework dependency-injection unity-container

Hi I am using Unity to manage my service layers, which in turn speak to UnitOfWork which manages all the repositories.

c# - Using objects deleted from context in Entity Framework

c# entity-framework sql-delete

Using code-first, I had doubts over what would happen if I obtained an object by querying the database, but kept using it after having it deleted or removed from the database.