#include <iostream>#include <vector>#include <GLUT/GLUT.h>#include <OpenGL/OpenGL.h>#define X_SIZE 640#define Y_SIZE 480class Square {private:public: Square() { GLdouble square[] = { -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0 -1.0, -1.0, -1.0, 1.0, -1.0 }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_DOUBLE, 0, square); glDrawArrays(GL_QUADS, 0, 12); glDisableClientState(GL_VERTEX_ARRAY); }};void draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); Square mySquare; glutSwapBuffers();}int main (int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(X_SIZE, Y_SIZE); glutCreateWindow("Lol"); glutDisplayFunc(draw); glutMainLoop(); return 0;}
I don't get why this doesn't display a square. I am first initializing glut in int main then, I am drawing the stuff in void draw where I make my object mySquare which by initialization should draw a square. But, I get this weird shaped polygon instead.
Thanks in advance.