我想用鼠标画一个点:
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
CRect rect;
GetClientRect(&rect);
pt.x = point.x - rect.right/2;
pt.y = -(point.y - rect.bottom/2); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glPointSize(3);
glBegin(GL_POINTS);
glVertex2f(pt.x,pt.y);
glEnd(); CView::OnLButtonUp(nFlags, point);
}
最后却看不到结果。请大家帮忙想想办法
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
CRect rect;
GetClientRect(&rect);
pt.x = point.x - rect.right/2;
pt.y = -(point.y - rect.bottom/2); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glPointSize(3);
glBegin(GL_POINTS);
glVertex2f(pt.x,pt.y);
glEnd(); CView::OnLButtonUp(nFlags, point);
}
最后却看不到结果。请大家帮忙想想办法
CClientDC dc(this);
wglMakeCurrent(dc.m_hDC,m_hGLContext);
其中m_hGLContext 是你在OnCreate里面创建的在函数结尾这么写一句 wglMakeCurrent(NULL,NULL);
pt.x = point.x - rect.right/2;
pt.y = -(point.y - rect.bottom/2);
这样得到的点还是显示不出来
pt.y = -(point.y - rect.bottom/2)/(rect.bottom/2);应该就可以了把
pt.y = -(point.y - rect.bottom/2.0)/(rect.bottom/2.0);这样会产生数据丢失,该如何解决呢?