问题描述
我使用普通的OpenGL(没有外部工具)创建一个使用C ++编写的游戏,但我可以使用GLUT。我画了一个游泳池线索,我想跟随鼠标光标,但我不知道该怎么做。
我知道如何使用键盘输入移动东西相机位置或绘制对象,但I
m不知道如何使用鼠标输入移动对象。
这是我想通过鼠标输入移动的提示:
void cue(){
glBegin;
glTranslatef(-10,5,0);
glRotatef(90,0,1,0);
glutSolidCone(0.25,15,20,20);
glEnd();
}
Glut有一些鼠标回调function 0047
/ p>
您可以使用回调来找出鼠标的移动,其余的是纯数学。
I am creating a pool game written in C++ using plain OpenGL (no external tools), but I can use GLUT. I have drawn a pool cue which I want to follow the mouse cursor but I am not sure how to do this.
I know how to use keyboard input to move things e.g camera position or draw an object but Im not sure how to move an object using mouse input.
This is the cue i am trying to move via mouse input:
void cue () {
glBegin;
glTranslatef(-10,5,0);
glRotatef(90,0,1,0);
glutSolidCone(0.25, 15, 20, 20);
glEnd();
}
Glut has a few mouse callback function
Mouse callback
Motion callback
You could use the callback to figure out the movement of the mouse, the rest is pure math.
这篇关于鼠标移动opengl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!