new to OpenGL: glutMouseFunc

天大地大妈咪最大 提交于 2019-12-03 17:12:49

The x and y that the mouse function gives you are in screen pixel coordinates, not in the coordinates that your scene uses. In order to do this, you have to center your coordinates (by subtracting by half your screen size) and scaling them to about your screen size (by dividing them by something on the order of your screen size).

Thus, you probably want to do something like

XSphere = (x - 450) * 3.0 / 900;
YSphere = (450 - y) * 3.0 / 900;

and play around with the 3.0 until it gives you something reasonable.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!