代码从控制台程序移到MFC出现问题
在控制台程序上就是display和reshape两个,在reshape中重新定义视口。
在MFC中部分代码如下:
- C/C++ code
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}- C/C++ code
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();}- C/C++ code
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);}可是这样怎么也显示不了了,无非是在中间画一个点而已啊
[解决办法]
初始化了么?
[解决办法]
记得要Link opengl啥的