Jump to content
  • Advertisement
Sign in to follow this  
DeadXorAlive

BSOD with SDL: what is safe and unsafe? ['solved' - broken directx]

This topic is 4829 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

I managed to get my very first BSOD with XP, using SDl with C++. It says: IRQL_NOT_LESS_OR_EQUAL, and Stop 0x0000000A with some memory adresses. I specially like this "To prevent damage to your monitor windows has been shut down." According to some site: "The message indicates that a kernel mode process or driver attempted to access a memory address that it did not have access to." It occurs in a part of my code where there's a switch from full screen to windowed mode, something like this:
GameLoop
{
//Event handling and bunch of other stuff happens here
//...
case SDLK_F9:
    SetParameters(true);
break;
//..
SDL_BlitSurface(Background, NULL, Screen, NULL);

//This blits things to Screen and updates the display, even though it still blits beyond
//the Screen surface, it should not give a BSOD, or should it? See below.
Board.Blit(Screen); 
SDL_Flip(Screen);
}

SetParameters (bool IsWindowed)
{
    //Just to show what is the idea, there's more in actual code:
    if (IsWindowed == true)
    {
        Screen = SDL_SetVideoMode (WIDTH, HEIGHT, BPP, SDL_HWSURFACE | SDL_DOUBLEBUF); //Screen is a SDL_Surface*
        Background = SDL_DisplayFormat(IMG_Load("images\\smallbackground.jpg"));
        SDL_ShowCursor(SDL_ENABLE);
        TBlock::Square1 = SDL_DisplayFormat(IMG_Load("images\\smallblock.bmp")); //static member
    }
}

//This doesn't give a BSOD, not even some error, though it looks real crappy:
GameLoop
{
//...
case SDLK_F9:
    Screen = SDL_SetVideoMode (WIDTH, HEIGHT, BPP, SDL_HWSURFACE | SDL_DOUBLEBUF);
break;
//..
SDL_BlitSurface(Background, NULL, Screen, NULL);
Board.Blit(Screen); //this blits the board to Screen, out of bounds. 
SDL_Flip(Screen);
}

Windows crashes only when switching from full screen to windowed, switching from windowed to full screen is okay. I know my code is still buggy, but I sort of don't like the idea of playing around and getting BSOD's every time I test the code. Maybe somebody happens to know what could really screw things up? What is very unsafe to do, what should be avoided all times? Any clue what I'm doing wrong here? For example, is it *very* unsafe to blit to a position out of the screen, or to change the display format and then call SDL_Flip()? [Edited by - DeadXorAlive on September 25, 2005 8:21:27 PM]

Share this post


Link to post
Share on other sites
Advertisement
1) Make ultra-sure the width, height, and bpp you're passing to your SDL_SetVideoMode() is correct. Monitors only support certain resolutions, especially in full-screen.

2) I'm not completely sure how it works, but I would advise against calling SDL_SetVideoMode() more than once. Though this is really just avoiding the problem, not fixing it.

I don't know if blitting outside of a surface's bounds will cause a BSOD, but it certainly seems possible. I know for a fact it will probably kill your program.

Share this post


Link to post
Share on other sites
Quote:
Original post by DeadXorAlive
Maybe somebody happens to know what could really screw things up? What is very unsafe to do, what should be avoided all times? Any clue what I'm doing wrong here? For example, is it *very* unsafe to blit to a position out of the screen, or to change the display format and then call SDL_Flip()?


If you create a SDL_surface that is 1024 pixels wide and then blit at somewhere like 1500, depending on how SDL handles things, bad things may happen.

Another thing to check is that the surface returned by SDL_SetVideoMode() != NULL

Share this post


Link to post
Share on other sites
Quote:
Original post by Icefox
1) Make ultra-sure the width, height, and bpp you're passing to your SDL_SetVideoMode() is correct. Monitors only support certain resolutions, especially in full-screen.


From the SDL Docs
Quote:
SDL_FULLSCREEN SDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), the next higher resolution will be used and the display window centered on a black background.


However, i'm not sure what would happen if you requested a resolution larger than the monitor could support.

Quote:
2) I'm not completely sure how it works, but I would advise against calling SDL_SetVideoMode() more than once. Though this is really just avoiding the problem, not fixing it.


The SDL Windows FAQ suggests that it is ok to use SDL_SetVideoMode() for switching between full screen and windowed mode. However, make sure you're familiar with the documentation for the function.

Share this post


Link to post
Share on other sites
Quote:
Original post by Will F
Another thing to check is that the surface returned by SDL_SetVideoMode() != NULL


Okay, thanx for the replies. I was a bit hasty in coding this function, so it's still real sloppy on the error checking side. I should do some error checking.

I made windows kill my game many times, just to see what would happen. But that's something different than a BSOD.
I forgot to mention that I build SDL and SDL_image from source code, it might just be that I screwed up something in there.

Share this post


Link to post
Share on other sites
Quote:
Original post by Icefox
I don't know if blitting outside of a surface's bounds will cause a BSOD, but it certainly seems possible. I know for a fact it will probably kill your program.


It doesn't even kill my app, just makes it look crappy. Though I might of course by accident be lucky that it didn't, I really don't know how unsafe these things are.

EDIT: I'm sorry, this seems to have nothing to do with SDL or my code. My DirectX installation seems to be broken and that probably is the cause. This is a major pain, I can't reinstall or uninstall it.
If anybody happens to read this and knows a way to reinstall DirectX without 'format C:' then I would be grateful if you'd let me know how.

[Edited by - DeadXorAlive on September 25, 2005 8:53:40 PM]

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!