Sign in to follow this  

SDL and Windows

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

This topic is 4021 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.

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