Hi everyone, I’m a newbie of OpenGL.
I’m testing a very simple code from “the OpenGL Red Book”, but get this error “0xC0000005 Access Violation”.
My environment is : Win 7 32bit, Visual Studio 2010
The code is as followed:
#include <glut.h>
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,200.0,0.0,150.0);
}
void lineSegment(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2i(100,0);
glVertex2i(0,75);
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,300);
glutCreateWindow("test");
init();
glutDisplayFunc(lineSegment);
glutMainLoop();
return 0;
}
I’d be very grateful if you can give any piece of advise. Thanks in advance!