为什么我得到一个完整的白色窗口作为这个程序的输出
代码在这里
#include<Gl/glut.h>
static GLfloat vertices[] = {0.0, 0.0, 0.0,
0.5, 0.0, 0.0,
0.5, 0.5, 0.0,
0.0, 0.5, 0.0,
};
void reshape(int w, int h)
{
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 0.0);
}
void Draw()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBegin(GL_LINES);
glArrayElement(0);
glArrayElement(1);
glArrayElement(2);
glArrayElement(3);
glEnd();
glDisableClientState(GL_VERTEX_ARRAY);
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(400,400);
glutInitWindowPosition(100,100);
glutCreateWindow("vectors");
glClearColor(0.0,0.0,0.0,0.0);
glutReshapeFunc(reshape);
glutDisplayFunc(Draw);
glutMainLoop();
}
将 GL_LINES 更正为 GL_QUADS