You might have to lock the surface screen before you can modify it.
You shouldn't have to lock to do a FillRect. You typically only need to lock if you are doing pixel-level access.
I assume GetScreen returns screen?
Are you sure screen is non-null?
@Disch yup it is defined when a Graphics object is instantiated.
Right, but I don't see any if(screen)
checks.
Have you confirmed that screen is non-null at the time ClearScreen is called?
EDIT: i forgot accidentally fucked something up before. Now when it gets to the bolded line it says the error below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
SDL_Surface* Graphics::LoadImage( std::string filename )
{
//The image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized surface that will be used
SDL_Surface* optimizedImage = NULL;
//Load the image
loadedImage = SDL_LoadBMP( filename.c_str() );
//If the image loaded
if( loadedImage != NULL )
{
//Create an optimized surface
optimizedImage = SDL_DisplayFormat( loadedImage );
//Free the old surface
SDL_FreeSurface( loadedImage );
//If the surface was optimized
if( optimizedImage != NULL )
{
//Color key surface
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 255, 0, 255 ) );
}
}
//Return the optimized surface
return optimizedImage;
}
|
1 2
|
First-chance exception at 0x68129d00 in MyGame.exe: 0xC0000005: Access violation reading location 0x0000013c.
Unhandled exception at 0x68129d00 in MyGame.exe: 0xC0000005: Access violation reading location 0x0000013c.
|
lol okay ill try that and edit this post with results
Last edited on