Sign in to follow this  
serratemplar

SDL and Windows

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this