Results 1 to 9 of 9

Thread: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Rennes, France
    Posts
    7

    Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Hi everybody, I'm new to this forum.
    I tried to compile the 1st source code given in the GLUT tutorial in VC++6, everything seems to be fine, the console and the GL window appear, *but* I then got the exception 0xC0000005: Access Violation...

    Could anyone help ?? TIA.

    ----------------
    Here's the code:

    #include <gl/glut.h>
    #include<gl/gl.h>

    void renderScene(void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_TRIANGLES);
    glVertex3f(-0.5,-0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
    glEnd();
    glFlush();
    }

    void main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("3D Tech- GLUT Tutorial");
    glutDisplayFunc(renderScene);
    glutMainLoop();
    }

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Rennes, France
    Posts
    7

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Sorry. I noticed after posting my previous message that this had been discussed in a thread before about exceptions... (read the answer from kilam)...

  3. #3
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    I too get an "unhandled exception in program.exe (GLUT32.DLL): 0xC0000005 Access Violation" from GLUT.

    Unfortunatley, I could not find the soultion by "kilam". It would have been better to place a link to the solution or gave the full description of where it is rather then only the name of someone who may have made a thousand posts.

    This problem is caused by glutMouseFunc. I passed in an address to my function and it crashed. I passed NULL and it also crashed.

    I am using the glut-3.7.6 binary for windows. I got it from http://www.xmission.com/~nate/glut.html .

    Thanks in advance for the help.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    586

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    What is the prototype of the function you passed to glutMouseFunc? It should be defined as

    Code :
     
    void somefuncname(int button, int state, int x, int y)//not necessarily those variable names
    {
    ...
    }
     
    int main(int argc, char** argv)
    {
    ...
    glutMouseFunc(somefuncname);
    ...
    }
    Hope that helps. If not post some code and someone will probably be able to help you.

  5. #5
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Here is my code.

    Code :
     
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
    {
       ...
       glutMouseFunc( onMousePress); // Set callback function
       glutMouseFunc( NULL); // Disable callback function
       ...
    }
     
    void onMousePress( int button, int state, int x, int y)
    {
    }

    I am calling it correctly, I think there may be a problem with the "GLUT32.DLL" file or it is somehow not compatible with my program.

    Now I didn't place my entire real code because it is far too much. It is also possible that I may have setup an incompatible enviornment that causes glut functions not to work (that is other GL functions may produce an incompatable state).

    I am also interested in knowing if glut has these kinds of compatability problems.

    Thanks

    [This message has been edited by hkyProgrammer88 (edited 04-26-2003).]

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    586

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    It is impossible, to my knowledge, to mix GLUT and Win32/MFC app. Not in the way you are trying to do it. You can use win32 functions, etc, but glut has its own framework and it conflicts with the Win32/MFC framework. If you want to use GLUT, do so in a console type application.

    int main(int argc, char** argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(...);
    ....
    glutCreateWindow("A GLUT Window"):
    ...
    glutDisplayFunc(display);
    ...
    glutMainLoop();
    }

    Or, write a Win32 or MFC app but do not use GLUT. You can use gl or glu functions.

    [This message has been edited by shinpaughp (edited 04-26-2003).]

  7. #7
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Thanks! Its a good thing I put "winMain" instead of "main".

    Unfortunatley this is not ideal. I wanted to use glut to save me time, now it looks like I am going to have to manually code everything again.

    If there is another library that already has tedious functions (like mouse routines) implemented I would like to know.

    Thanks for the help,

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    586

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Actually, glut will allow you to do it quickly. You could write an entire glut app in hours what would take days/weeks to do in Win32 with all messaging and stuff. And the code will be smaller also.

    Or, is it that you have built the Win32 app and just want to add mouse handling functions. If so, go to http://msdn.microsoft.com and look up WM_MOUSE_MOVE, WM_LBUTTON_DOWN, etc. Should be just as easy to handle.

  9. #9
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Exception 0xC0000005: Access Violation in the GLUT tutorial... Why ?

    Thats right. In fact, my core custom library is based on Win32/MFC so it is not easy to switch.

    In any event, I will both try to reprogram the library and add the utilities in another way.

    Thanks for the help, I understand completely now.

Similar Threads

  1. Access violation Exception with DrawElements
    By WorldDj in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-22-2018, 09:19 AM
  2. Access Violation Exception [VC++]
    By Zababa! xD in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-02-2011, 09:17 PM
  3. Access Violation Exception on registering MouseFun
    By Jacek Gajek in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-04-2009, 04:14 AM
  4. Unhandled exception : Access Violation
    By Al Grant in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-06-2006, 01:27 PM
  5. Replies: 0
    Last Post: 05-20-2004, 08:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean