在openGL中旋转对象 [英] Rotate an object in openGL

查看:96
本文介绍了在openGL中旋转对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个用openGL绘制的矩形.我想根据鼠标移动旋转矩形
我的意思是,当我按顺时针方向移动鼠标时,则矩形应按顺时针方向移动;如果我按逆时针方向移动鼠标,则矩形应按逆时针方向移动.
我该如何在vc ++中做到这一点

提前谢谢您.

hi all,
i have a rectangle drawn with openGL. I want to rotate that rectangle based on mouse movement
i mean,when i move mouse on clockwise diretion, then the rectangle should move clockwise direction, and if i move the mouse on anticlockwise direction, then the rectangle should move on anticlockwise direction.
how can i do this in vc++

thank you in advance

推荐答案

根据在X或Y方向上的运动来查找nAngle ...

Find the nAngle based on movement in X or Y direction...

glRotatef( nAngle, 0,0, 1 );
glRectf( -0.5, -0.5, 0.5, 0.5 );


这篇关于在openGL中旋转对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆