当我编译它时,它会出现一个空白的黑屏,如果我从任何一个位置取出 glut 交换缓冲区,或者同时我得到一个空白的白屏,有什么问题?
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
void ProcessSpecialKeys(int key, int x, int y){
switch(key){
case GLUT_KEY_RIGHT:
exit(0);
case GLUT_KEY_LEFT:
exit(0);
case GLUT_KEY_UP:
exit(0);
case GLUT_KEY_DOWN:
exit(0);
default:
exit(0);
}
}
void renderPrimitive(void){
glBegin(GL_QUADS);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(-1.0f,1.0f,0.0f);
glVertex3f(1.0f,1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
}
void display(void){
glTranslatef(0.0f,0.0f,-0.5f);
renderPrimitive();
glutSwapBuffers();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Dimension");
glutDisplayFunc(display);
glLoadIdentity();
glutSpecialFunc(ProcessSpecialKeys);
glutMainLoop();
return 0;
}