I have just started doing openGL programming a week back and came across a problem in the very beginning…I wanna make a simple flat surface(floor)in openGL for which i am using Visual C++ 2008 express edition…
But when i debug my program, the following exception occurs :
Unhandled exception at 0x1000fdac in first project.exe: 0xC0000005: Access violation reading location 0x00000000.
Blow is my code…Please tell me if the code is wrong
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
void drawFloor(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glVertex3f(-18.0, 0.0, 27.0);
glVertex3f(27.0, 0.0, 27.0);
glVertex3f(27.0, 0.0, -18.0);
glVertex3f(-18.0, 0.0, -18.0);
glEnd();
glFlush();
}
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
int main(int argc,char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(20,60);
glutInitWindowSize(360, 360);
glutCreateWindow(“Project”);
init();
glutDisplayFunc(drawFloor);
glutMainLoop();
return (0);
}