#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
void display( void ){}
void reshape( int w, int h ){}
void key( unsigned char key, int x, int y )
{
switch (key)
{
case 27:
exit(0);
case 32:
glutIdleFunc( NULL ); display( );
break;
default:
glutIdleFunc( display );
}
}
int main( int argc, char **argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE );
glutInitWindowSize( 200, 200 );
glutCreateWindow( "Test" );
glutKeyboardFunc( key );
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutIdleFunc( display );
glutMainLoop( );
}
🔒 Locked
glutCreateWindow( ) - "Access violation"
Advertisement
Original Post
Hello. I am currently trying to get OpenGL to run on my computer. Everything should be setup fine, I have written a short app and it builds fine with MS Visual Studio 2008. However, as soon as I run the app, it crashes with "Unhandled exception at 0x6954a66e in OpenGLTest.exe: 0xC0000005: Access violation reading location 0x00000000." Here is the source code (all of it), I've kept it as short as possible: As you can see, I'm not really trying to do much, I just want it to run. With the help of the debugger, I've found out that the code crashes on "glutCreateWindow( "Test" );". Beyond that, when I look at the call stack, it would seem the problem would be related to "atioglxx.dll" which is a part of my drivers for my ATI Radeon 9800 Pro. I've tried looking for a solution in a bunch of places, but I can't seem to find any information that would help me solve this. I am running Windows XP Professional and I was able to do OpenGL before I reformatted my computer not too long ago. Any assistance would be appreciated. If you require more information please ask and I will do my best to provide details.
Quote:
Try
glutInit(&argc, argv);
glutInitWindowPosition(10, 10);
glutInitWindowSize(200, 200);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA );
glutCreateWindow("Test");
If that doesn't work, use something else such as SDL instead of GLUT.
V-man, I'm afraid your suggested code solution did not work (same results are observed). However, I have yet to try the SDL library or another substitute for GLUT. I will post my results once I've tried. Thank you for the suggestion.
P.S. I am interested in the rationale behind your suggested code solution. If it's not too much trouble, would you care to elaborate your reasoning on why you though that would work? I just want to take note of it as a personal reference. Thanks.
Quote:
it might be your compiler. It works for me. what compiler are you runngin?
Also, to answer tnutty: I'm not sure what to tell you beyond the fact that I am using the CPP compiler that is bundled with MS Visual Studio 2008. I was under the impression that this compiler should be adequate, but please let me know if there is another one I should be trying out. All I can tell you is that all the GLUT code I've tried to run thus far has compiled successfully, it just doesn't run (I know that you might be suggesting that there could be a kink in the compilation process that could be mucking things up at runtime, but I just wanted to let you know this much).
V-man, as per your recommendation, I've setup SDL and I have made a few test apps that compile. However, I get the same error when attempting to run and "atioglxx.dll" is still at the top of the call stack in the debug. I will attempt to use the standard "windows.h" procedures to see what I get. I will also see if I can revert my video card drivers without causing too many issues to see what I get.
Hello, I just run your code on my computer, and it is compiled successful only having a warning that the main function needs a return value.
I am also running Windows XP Professional but using MS Visual C++ 6.0;
I think something wrong has happened to your operating systerm, and some system files (such as DLL files) may be destroyed. If you had not solved the problem,reparing or reinstalling your OS may have an effect on it.
I am also running Windows XP Professional but using MS Visual C++ 6.0;
I think something wrong has happened to your operating systerm, and some system files (such as DLL files) may be destroyed. If you had not solved the problem,reparing or reinstalling your OS may have an effect on it.
Looks like the error I get every time I run openGL too, I figure out thats because my video card is shit ( sys 32 MB )..
But is not really an error, after press ok the program runs normally, also if I run the program directly at the .exe file it dont happens..
A curious thing is that when I setup opengl by myself ( using windows api ) this dont happens..I guess theres some commom configuration that glut and SDL does that cause this..
But is not really an error, after press ok the program runs normally, also if I run the program directly at the .exe file it dont happens..
A curious thing is that when I setup opengl by myself ( using windows api ) this dont happens..I guess theres some commom configuration that glut and SDL does that cause this..
Interesting. I will try that once I get home. Thank you for the information.
It doesn't crash when I use the windows API either. However, if I try to run the .exe on its own, it will crash anyway. I think I'll be able to figure things out on my own eventually. Thanks for your help everyone. If I find a solid solution to this, I'll be sure to post it to help anyone experiencing similar issues.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement