SDL and Windows

Started by
6 comments, last by serratemplar 17 years, 4 months ago
The examples in the SDL tutorials for Windows use main() instead of WinMain, and make no mention of a "WndProc" callback procedure or equivalent (as I'm accustomed to having around in Windows programs). Will SDL work as it should if I use WinMain instead of main, and respond to messages? Does SDL wrap this somehow? (That I doubt, but it had occurred to me.) If anyone's seen example code on the web that uses SDL in Windows and also monitors messages that might come in, I'd like very much to see a link =) Thanks in advance.
Advertisement
SDL has an entire event wrapper that will take care of all that for you.

As for doing your own message loop monitoring seperate from SDL, I don't know.
I believe that one of the major purposes to SDL is to completely hide all of the windows garbage from you. AFAIK it handles everything magically so you can be at peace and just write your game.

-me
Yes, SDL wraps it all. Hence why it's neccasary to declare int main() as int main(int argc, char* args[]) as SDL is expecting that. (Anything else SDL won't understand)

If you want to mix SDL and Win32, you can get the HWND to the SDL window like this:
SDL_SysWMinfo wmInfo;SDL_VERSION(&wmInfo.version);SDL_GetWMInfo(&wmInfo);HWND hWnd = wmInfo.window;
(Stolen from the libSDL.org forum)

But be warned that you would lose crossplatform support in that app. (Win32 is Windows OS only, I'm sure you know)
I do like being at peace =) I used SDL in Linux and got into its event handler there; didn't occur to me that the same thing would be built for Windows as well, but that makes more sense now that you both say so.
Say I want to have multiple windows open? One with the game in it and one for console style I/O (say for debugging). Does SDL have built in support for that?
If you build a Console application in MSVC, the Console pops up by default along with the SDL window, and you can use it for input/output.

Just happened to use it that way the other day.
Interesting. I'll give that a go; thank you.

This topic is closed to new replies.

Advertisement