Even though I have no errors showing from the compiler, the program starts a console and shows the following:
Process returned -1073741819 (0xC0000005) execution time : 2.266 s
Press any key to continue.
I don't know why. I have tried Visual Studio, Codeblocks, and DEV C++
#include <GL/glut.h>
#define RATIO 1.2
#define WW 100
#define WH (WW/RATIO)
#define HALFX ((int)(WW/2))
#define HALFY ((int)(WH/2))
#define deltat 0.001
int WindowWidth;
int WindowHeight;
void Display() {
glLineWidth(4.0);
float StartShape[12][2] = { {-15,-15},{-5,-15},{0,-5},{5,-15},{15,-15},{15,25},{5,25},
{5,-5},{0,0},{-5,-5},{-5,25},{-15,25} };
float EndShape[12][2] = { {-15,-15},{-5,-15},{-5,10},{0,0},{5,10},{5,-15},{15,-15},
{15,25},{5,25},{0,15},{-5,25},{-15,25} };
float IntermediateShape[12][2];
float VertexColors[12][3] = { {1,0,0},{1,1,0},{1,0,1},{0,1,0},{0,1,1},{0,0,1},{1,0.5,0},
{1,0,0.5},{0.5,1,0},{0.5,0,1},{1,0,0.5},{0,1,0.5} };
static float Tween = 0.0 - deltat;
if (Tween < 1) {
Tween += deltat;
}
for (int i = 0; i < 12; i++) {
IntermediateShape[i][0] = (1 - Tween) * StartShape[i][0] + Tween * EndShape[i][0];
IntermediateShape[i][1] = (1 - Tween) * StartShape[i][1] + Tween * EndShape[i][1];
}
glVertexPointer(2, GL_FLOAT, 0, IntermediateShape);
glColorPointer(3, GL_FLOAT, 0, VertexColors);
for (int i = 0; i < 1000000; i++) {
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_LINE_LOOP, 0, 12);
glutSwapBuffers();
glutPostRedisplay();
}
}
void InitGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-HALFX, HALFX, -HALFY, HALFY);
glMatrixMode(GL_MODELVIEW);
glClearColor(0, 0, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glShadeModel(GL_SMOOTH);
glViewport(0, 0, WindowWidth, WindowHeight);
}
void Reshape(int w, int h) {
glutReshapeWindow(w, (int)(w / RATIO));
WindowWidth = w;
WindowHeight = (int)(w / RATIO);
InitGL();
}
int main(int& argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
WindowWidth = (int)(glutGet((GLenum)GLUT_SCREEN_WIDTH) * 0.4);
WindowHeight = (int)(WindowWidth / RATIO);
glutInitWindowSize(WindowWidth, WindowHeight);
glutInitWindowPosition(((int)glutGet((GLenum)GLUT_SCREEN_WIDTH) * 0.1),
(glutGet((GLenum)GLUT_SCREEN_WIDTH) / 2) - (WindowHeight / 2));
glutCreateWindow("Bilguun Erdenebaatar Tweening Midterm Exam");
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
InitGL();
glutMainLoop();
return 0;
}