不使用 glutWarpPointer 移动鼠标
我尝试在 OpenGL 应用程序中通过 gluLookAt 移动相机,类似于相机在 FPS 游戏中的移动方式。但是,它有效,我想在移动鼠标后将其居中,以防止鼠标到达屏幕边缘。经过一些研究,我发现 glutWarpPointer 是一个可行的选择,但是,我感觉到专业游戏开发人员只使用基本的 OpenGL 命令,而不是像 glutWarpPointer、 glutSolidCube 或 glutSolidSphere 这样的命令。我的假设正确吗?
在我的 WndProc 函数中,我在开关块中的 WM_MOUSEMOVE 消息下设置了 gluLookAt 的外观。我还意识到 SendInput 会实现我想要的,但根据我的理解,当光标移动到屏幕中间时,SendInput 会触发另一个 WM_MOUSEMOVE ,本质上反转了鼠标的原始移动,并且根本不移动相机的外观。
有什么想法吗?
编辑:我认为不存在不调用 WM_MOUSEMOVE 消息的函数。我认为正确的方法是创建一个标志来确定 WM_MOUSEMOVE 是否由 SetCursorPos 调用,如果是,则不要更改相机的外观。
I'm attempting to move the camera via gluLookAt in my OpenGL app similar to how the camera moves in a FPS game. It works, however, I would like to center the mouse after moving it, to disallow the mouse from ever reaching the edge of the screen. After doing some research, I found glutWarpPointer is a viable option, however, I get the sense that professional game developers only utilize the basic OpenGL commands, instead of something like glutWarpPointer, or glutSolidCube, or glutSolidSphere. Am I correct in assuming this?
In my WndProc function, I set the look for my gluLookAt under the WM_MOUSEMOVE message in my switch block. I also realize that SendInput would achieve what I want, but from my understanding SendInput would trigger another WM_MOUSEMOVE when the cursor goes to the middle of the screen, essentially reversing my original movement of the mouse, and not moving the camera's look at all.
Any ideas?
Edit: I don't think there exists a function that does not call a WM_MOUSEMOVE message. I think the proper route is to create a flag that determines whether the WM_MOUSEMOVE was invoked by a SetCursorPos, and if it was, do not change the camera's look.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
SetCursorPos
来重新定位鼠标光标(如果您使用的是 Windows)。
Use
SetCursorPos
to relocate the mouse cursor if you're on Windows.