这是代码,没有任何错误,它有什么问题?
我编译它,命令提示符打开,窗口打开,窗口全是白色的,我将它重新着色为灰色..,它也没有绘制我的形状,那是什么问题?
#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 renderScene(void) {
glClearColor(0.3f, 0.3f, 0.3f, 0.3f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
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();
glFlush();
glClearColor(0.3f,0.3f,0.3f,0.3f);
glClear(GL_COLOR_BUFFER_BIT);
}
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 1;
}