Jump to content
  • Advertisement
Sign in to follow this  
brich744

OpenGL SDL_Surface 0xC0000005: Access violation reading location 0x00000000.

This topic is 2565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone,

I have created a project in SDL which has a skybox, ray tracing, and an .obj loader. My program will run fine for about 20 compiles and after that I will receive the following error

Unhandled exception at 0x02f5374d in ex1.exe: 0xC0000005: Access violation reading location 0x00000000.


This is coming from the SDL_Surface* screen=SDL_SetVideoMode(640,480,32,SDL_SWSURFACE|SDL_OPENGL); which is the second line in my main function. This happened the other day and I was playing around with the logs in visual studios and it just started to work (At least I think that is what fixed it). I tried to do the same steps that I did the other day but it did not work. Below is the first few line of my main.cpp file. If you need to see more code just let me know. Thanks!!



int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface* screen=SDL_SetVideoMode(640,480,32,SDL_SWSURFACE|SDL_OPENGL);
if(!screen)
{
std::cout << "Image load didn't work correctly";
return 1;
}



Share this post


Link to post
Share on other sites
Advertisement
SDL_Init returns a status code, 0 for success, or -1 for failure.

You should check this before calling any other SDL functions.

Share this post


Link to post
Share on other sites
The weirdest thing just happened I changed the project from debug to release and back to debug and it started to work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!