【问题标题】:How do I get the current mouse position in C++ / OpenGL?如何在 C++/OpenGL 中获取当前鼠标位置?
【发布时间】:2009-02-11 21:09:51
【问题描述】:

我知道我可以在用户点击鼠标时使用鼠标回调函数,但是如果我想知道当前 x/y 位置而不需要用户点击怎么办?

我是否必须使用在任何鼠标移动时调用的不同回调并自己跟踪 x/y,还是我可以在 GLUT/OpenGL 中调用一个函数来获取它?

【问题讨论】:

  • 这更多地与 glut 相关,而不是 OpenGL。鼠标位置之类的事情通常由操作系统处理,与 OpenGL 或 C++ 无关。

标签: c++ opengl mouse glut


【解决方案1】:

注册一个 glutPassiveMotionFunc 回调函数

查看有关callbacks的信息

【讨论】:

    【解决方案2】:

    您需要使用 glutMotionFunc/glutPassiveMotionFunc 回调来跟踪独立于鼠标点击的鼠标移动。

    7.6 glutMotionFunc, glutPassiveMotionFunc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多