Jump to content
  • Advertisement
Sign in to follow this  
serratemplar

SDL and Windows

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

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!