Hello, I’m trying to get this display list working but it doesn’t draw, and I’m stumped.
#include <gl\glut.h>
#include <gl\GL.h>
GLuint DrawDL(0);
void WindowInitGL(float Width, float Height, int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("Box Test");
}
void DisplayList()
{
DrawDL = glGenLists(2);
glNewList(DrawDL, GL_COMPILE);
glBegin(GL_TRIANGLES);
glVertex2f( -1, 1);
glVertex2f( -1,-1);
glVertex2f( 1,-1);
glVertex2f( 1, 1);
glColor3f(1, 0, 1);
glEnd();
glEndList();
}
void DrawFrame()
{
glClearColor(1,1,1,1);
glClearDepth(0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glOrtho(-10, 10, -10, 10, -1, 1);
glCallList(DrawDL);
glFlush();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
WindowInitGL(800, 600, argc, argv);
DisplayList();
glutDisplayFunc(DrawFrame);
glutMainLoop();
}