glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 500.0*aspect, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void CGLSample2View::OnPaint()
{ CPaintDC DC(this); // device context for painting (added by ClassWizard)
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glVertex2f(100.0f, 50.0f);
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glVertex2f(450.0f, 400.0f);
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glVertex2f(450.0f, 50.0f);
glEnd();
glFlush();
}
文章来源于领测软件测试网 https://www.ltesting.net/