Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to solve problem "0xC0000005 Access Violation"

  1. #1
    Newbie Newbie
    Join Date
    Jan 2014
    Posts
    1

    How to solve problem "0xC0000005 Access Violation"

    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:

    Code :
    #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!

  2. #2
    Intern Newbie
    Join Date
    Dec 2013
    Posts
    45
    Try running it with debugging, so you can get more information on where the error is occurring.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2011
    Location
    USA
    Posts
    14
    Quote Originally Posted by onethreeninetwo View Post
    Hi everyone, I'm a newbie of OpenGL.
    I'm testing a very simple code from "the OpenGL Red Book", ...
    You're not using the current 8th edition Red Book source code. For the latest code, download the Red Book examples from this website: http://www.opengl-redbook.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •