Greetings, and a question

Greetings fellow SDLians,

I’m currently working on my arcade emulator, Retrocade (sorry, home page
was hijacked by a search engine), and have a mostly completed SDL "port"
of it. I’m pleased to say that things are working great! If it matters,
I’m running under Windows and it’ll eventually be ported to the MacOS and
a few Linuxen, too.

What I’m wondering about is a “clean” way for my app to realize that it is
about ready to have focus taken away from it so it can go to sleep, and
later wake up when focus has been restored? I’m aware of the method of
checking the return code of the blit call, but that seems like throwing a
rock through a window to see if a light comes on. Does the system pump an
event through by chance?

Also, is there a way to effectively “shut down” SDL and return the desktop
to normal without doing an SQL_Quit()? I’d like to be able to spew out an
ASSERT() dialog box on a restored desktop to find out just what happened,
and to make it clean for my end users just in case this happens.

Thanks!

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

Greetings fellow SDLians,

I’m currently working on my arcade emulator, Retrocade (sorry, home page
was hijacked by a search engine), and have a mostly completed SDL "port"
of it. I’m pleased to say that things are working great! If it matters,
I’m running under Windows and it’ll eventually be ported to the MacOS and
a few Linuxen, too.

What I’m wondering about is a “clean” way for my app to realize that it is
about ready to have focus taken away from it so it can go to sleep, and
later wake up when focus has been restored? I’m aware of the method of
checking the return code of the blit call, but that seems like throwing a
rock through a window to see if a light comes on. Does the system pump an
event through by chance?
Events are sent for the mouse & input focus and blur (seperately) as
well as for iconifying (which I can only assume translates directly to
minimize) and restore/maximize.

Check the event structure in the documentation
http://sdldoc.csn.ul.ie/event.phpOn Thu, 2002-07-11 at 16:01, Neil Bradley wrote:

Also, is there a way to effectively “shut down” SDL and return the desktop
to normal without doing an SQL_Quit()? I’d like to be able to spew out an
ASSERT() dialog box on a restored desktop to find out just what happened,
and to make it clean for my end users just in case this happens.

Thanks!

–>Neil


Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

End of Rant.

Jimmy
Jimmy’s World (http://www.jimmysworld.org)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020711/5f9fdd7c/attachment.pgp

What I’m wondering about is a “clean” way for my app to realize that it is
about ready to have focus taken away from it so it can go to sleep, and
later wake up when focus has been restored? I’m aware of the method of
checking the return code of the blit call, but that seems like throwing a
rock through a window to see if a light comes on. Does the system pump an
event through by chance?

SDL_ACTIVEEVENT, but you should be checking blit returns, too.

Also, is there a way to effectively “shut down” SDL and return the desktop
to normal without doing an SQL_Quit()? I’d like to be able to spew out an
ASSERT() dialog box on a restored desktop to find out just what happened,
and to make it clean for my end users just in case this happens.

SDL_Quit() shuts down SDL and returns the desktop to normal. :slight_smile:

Why is that a problem? I don’t understand.

If you just want to kill the video subsystem, use SDL_QuitSubSystem().

–ryan.

event through by chance?
SDL_ACTIVEEVENT, but you should be checking blit returns, too.

Yes, as I understand they can get interleaved. Thanks!

to normal without doing an SQL_Quit()? I’d like to be able to spew out an
ASSERT() dialog box on a restored desktop to find out just what happened,
and to make it clean for my end users just in case this happens.
SDL_Quit() shuts down SDL and returns the desktop to normal. :slight_smile:
Why is that a problem? I don’t understand.

Sorry for not being clear. I wanted to restore the desktop and put up a
Windows dialog box (ala MessageBox()) but SDL_Quit() exits the entire
program!

If you just want to kill the video subsystem, use SDL_QuitSubSystem().

I don’t know why I didn’t see this before - thank you!

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

Sorry for not being clear. I wanted to restore the desktop and put up a
Windows dialog box (ala MessageBox()) but SDL_Quit() exits the entire
program!

It shouldn’t. It sounds like you may have a memory corruption in your
program that is causing a crash when the video subsystem is being shut
down.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Windows dialog box (ala MessageBox()) but SDL_Quit() exits the entire
program!
It shouldn’t. It sounds like you may have a memory corruption in your
program that is causing a crash when the video subsystem is being shut
down.

I had thought this considering I am debugging a new graphics layer (and
it’s prone to corruption because of boundary overwrites), but a simple
program that does SDL_Initialize()/SDL_Quit() and anything afterward
doesn’t get executed. Go figger.

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

I had thought this considering I am debugging a new graphics layer (and
it’s prone to corruption because of boundary overwrites), but a simple
program that does SDL_Initialize()/SDL_Quit() and anything afterward
doesn’t get executed. Go figger.

What version operating system and compiler are you using? Can you post a
minimal compilable example that I can use to replicate the problem?

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

program that does SDL_Initialize()/SDL_Quit() and anything afterward
doesn’t get executed. Go figger.
What version operating system and compiler are you using? Can you post a
minimal compilable example that I can use to replicate the problem?

Hi Sam -

Sorry for taking eons to get back to you. I’m using MSVC++ 6.0 (SP2) under
Windows 2000 and XP. Here’s a quickie test program. I’ve found out (after
tracing through it) that the app is NOT quitting prematurely, rather my
MessageBox() commands aren’t working. Here’s the sample app:

#define PROGRAM_TITLE “Test”

int WINAPI WinMain(HINSTANCE eInst,
HINSTANCE ePreviousInstance,
LPSTR pu8CmdLine,
int s32CmdShow)
{
int iReturn;

SDL_Init(SDL_INIT_VIDEO);
iReturn = MessageBox(NULL, (const char *) "After SDL_Init()", PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
iReturn = MessageBox(NULL, (const char *) "After SDL_SetVideoMode()", PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
iReturn = MessageBox(NULL, (const char *) "After SDL_QuitSubSystem()", PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_Quit();
iReturn = MessageBox(NULL, (const char *) "After SDL_Quit()", PROGRAM_TITLE, MB_ICONSTOP | MB_OK);

}

I get the message boxes after SDL_Init() and SDL_VideoMode(), however
after I do the SDL_QuitSubSystem(SDL_INIT_VIDEO), the “After
SDL_QuitSubSystem()” message box returns a 1 (IDOK) immediately. It never
displays the message box. Same deal after SDL_Quit(). The above example
uses a windowed display - it makes no difference if it’s full screen or
windowed, but I’m running full screen with my game.

It’s driving me a bit crazy, because I’d like to be able to get messages
back to my game players/beta testers after I’ve restored their desktop -
asserts and the like. If I just do a MessageBox() in the middle of the
game, most often the video mode causes it to be off the screen (I’m
running full screen, BTW).

Forgive me if this is Windows idiocy on my part, but I can’t figure out
what’s going on, or why SQL_QuitSubSystem()/SQL_Quit() causes me to no
longer be able to display message boxes.

Thanks in advance!

–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me

Hi,

I had a problem with this a while back when trying to pop-up an
error message box after the windows message-loop had quit.

Flushing the message-queue seemed to work :

-----8<------------------------------------------------------

void FlushMessageQueue()
{
MSG msg;

while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT ) break;
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}

------------------------------------------------------>8-----

e.g.

SDL_Quit();
FlushMessageQueue();
iReturn = MessageBox(NULL, (const char *) “After SDL_Quit()”, …

cheers,
John.
PS this was originally posted back in May.> ----- Original Message -----

From: nb@synthcom.com (Neil Bradley)
To:
Sent: Monday, July 22, 2002 4:22 AM
Subject: [SDL] Unable to MessageBox…

program that does SDL_Initialize()/SDL_Quit() and anything afterward
doesn’t get executed. Go figger.
What version operating system and compiler are you using? Can you post
a

minimal compilable example that I can use to replicate the problem?

Hi Sam -

Sorry for taking eons to get back to you. I’m using MSVC++ 6.0 (SP2) under
Windows 2000 and XP. Here’s a quickie test program. I’ve found out (after
tracing through it) that the app is NOT quitting prematurely, rather my
MessageBox() commands aren’t working. Here’s the sample app:

#define PROGRAM_TITLE “Test”

int WINAPI WinMain(HINSTANCE eInst,
HINSTANCE ePreviousInstance,
LPSTR pu8CmdLine,
int s32CmdShow)
{
int iReturn;

SDL_Init(SDL_INIT_VIDEO);
iReturn = MessageBox(NULL, (const char *) “After SDL_Init()”,
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
iReturn = MessageBox(NULL, (const char *) “After SDL_SetVideoMode()”,
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
iReturn = MessageBox(NULL, (const char *) “After SDL_QuitSubSystem()”,
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
SDL_Quit();
iReturn = MessageBox(NULL, (const char *) “After SDL_Quit()”,
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
}

I get the message boxes after SDL_Init() and SDL_VideoMode(), however
after I do the SDL_QuitSubSystem(SDL_INIT_VIDEO), the “After
SDL_QuitSubSystem()” message box returns a 1 (IDOK) immediately. It never
displays the message box. Same deal after SDL_Quit(). The above example
uses a windowed display - it makes no difference if it’s full screen or
windowed, but I’m running full screen with my game.

It’s driving me a bit crazy, because I’d like to be able to get messages
back to my game players/beta testers after I’ve restored their desktop -
asserts and the like. If I just do a MessageBox() in the middle of the
game, most often the video mode causes it to be off the screen (I’m
running full screen, BTW).

Forgive me if this is Windows idiocy on my part, but I can’t figure out
what’s going on, or why SQL_QuitSubSystem()/SQL_Quit() causes me to no
longer be able to display message boxes.

Thanks in advance!

–>Neil



Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,

I had a problem with this a while back when trying to pop-up an
error message box after the windows message-loop had quit.

Flushing the message-queue seemed to work :

Thanks! I’ve added this to CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment