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);
}