opengl如何实现鼠标拖动物体

就不交话费 2015-03-12 11:12:12
我是从http://blog.csdn.net/yulinxx/article/details/39256965文章仿照改的我程序如下,我想使用鼠标左键实现拖动,但是我写的这个不报错,但是运行的时候鼠标一点击就消失了,我改怎么改改呢?
void CDrawCubeDemoView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_MouseDownPoint=point;
SetCapture();
CView::OnLButtonDown(nFlags, point);
}

void CDrawCubeDemoView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//m_MouseDownPoint=CPoint(0,0);
ReleaseCapture();
CView::OnLButtonUp(nFlags, point);
}

void CDrawCubeDemoView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_xPos+=(point.x-m_MouseDownPoint.x)*2;
m_yPos+=(m_MouseDownPoint.y-point.y)*2;
m_MouseDownPoint=point;
glTranslated(m_xPos, m_yPos, -10.0);

CView::OnMouseMove(nFlags, point);
}
...全文
262 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,448

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧