地球随着窗口的拉伸而变化长宽比例的问题解决了,方法如下:
void COpenGLSpaceCtrl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
m_aspectRatio = (double)cx/cy;
CSize size(cx,cy);
glViewport(0,0,size.cx,size.cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, m_aspectRatio, 1.0f, 128.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDrawBuffer(GL_BACK);
glEnable(GL_DEPTH_TEST);
}