【发布时间】:2018-05-27 15:40:48
【问题描述】:
三角形没有出现在屏幕上。 我正在使用 Dev c++ 4.9.9.2(我知道你不喜欢它,但对我来说它仍然是最好的:) 免费过剩。
代码如下:
#include <GL/glut.h>
void display(){
glClear ( GL_COLOR_BUFFER_BIT );
glutSwapBuffers();
glBegin ( GL_TRIANGLES );
glColor3f ( 0.0, 1.0, 0.0);
glVertex2f (-0.5,-0.5);
glVertex2f (0.5,-0.5);
glVertex2f (0.0, 0.5);
glEnd();
}
void reshape ( int width, int height ){
glViewport ( 0, 0, width, height );
}
void initOpenGL(){
glClearColor ( 1.0, 0.1, 0.0, 1.0 );
}
int main (int argc, char **argv){
glutInit ( &argc , argv );
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
glutInitWindowSize ( 500, 500 );
glutInitWindowPosition ( 100, 100 );
glutCreateWindow ( "OpenGl" );
initOpenGL();
glutDisplayFunc ( display );
glutIdleFunc ( display );
glutReshapeFunc ( reshape );
glutMainLoop ();
return 0;
}
【问题讨论】: