在控制台程序上就是display和reshape两个,在reshape中重新定义视口。
在MFC中部分代码如下:
void COpenGLMFCView::OnDraw(CDC* pDC)
{
COpenGLMFCDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); wglMakeCurrent(pDC->m_hDC,m_hRC);
Drawscene();
wglMakeCurrent(pDC->m_hDC,NULL);
// TODO: add draw code for native data here
}void COpenGLMFCView::Drawscene()
{
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT); glPointSize(10); glLoadIdentity();
gluLookAt(0,0,50,0,0,-50,0,1,0);
glBegin(GL_POINTS);
glColor3f(1,0,0);
glVertex3f(0,0,5);
glVertex3f(0,0,-5);
glEnd();
glFlush();
}void COpenGLMFCView::OnSize(UINT nType, int cx, int cy) 
{
CView::OnSize(nType, cx, cy); // TODO: Add your message handler code here
glViewport(0, 0, cx, cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60,(double)cx/cy,10,50); glMatrixMode(GL_MODELVIEW);
}可是这样怎么也显示不了了,无非是在中间画一个点而已啊