Jump to content
  • Advertisement
Sign in to follow this  
TheNobleOne

SDL and MessageBoxes

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

Ok I am making a 2D Isometric engine. I am using SDL for windowing and OpenGL for rendering. My problem is that I want to implement MessageBoxes to my windowing piece of the engine. I was wondering if there was a way I can do a message box with SDL or do I have to use Win32? I would much prefer to avoid Win32 because of portability issues of doing so.

Share this post


Link to post
Share on other sites
Advertisement
There's no way of creating message boxes directly from SDL, what you can do instead is create a function PrintError(const string &Error) or something like that, inside the function you could use something like this:


void PrintError(const string &Error)
{
#ifdef WIN32
//use message box
#else
//use cout/cerr instead
}


This hides away all the Win32 specific stuff inside a function to make the code a little cleaner instead of loads of #ifdefs.

Share this post


Link to post
Share on other sites
Quote:
Original post by Spudder
There's no way of creating message boxes directly from SDL, what you can do instead is create a function PrintError(const string &Error) or something like that, inside the function you could use something like this:


void PrintError(const string &Error)
{
#ifdef WIN32
//use message box
#else
//use cout/cerr instead
}


This hides away all the Win32 specific stuff inside a function to make the code a little cleaner instead of loads of #ifdefs.


I think this will work.

Share this post


Link to post
Share on other sites
Quote:
Original post by samuraicrow
I think it's possible to open a second window using SDL but you may need a derived C++ library called HXRender


AFAIK you can't create multiple windows in SDL. HxRender is a completely different library which provides some functionality for using SDL with OpenGL. I haven't really looked into any GUI libraries for SDL so I'm not sure if any do exist but this could be one approach, but for a simple message box it might be overkill.

Share this post


Link to post
Share on other sites
Is there a way I can check to see what os is in use so I know whether or not to include they windows header file. Because if I include the windows header file and it does not exist it will not link and compile correct.

Share this post


Link to post
Share on other sites
You can use #ifdef WIN32 to check to see if you compiling on windows, something like this:


#ifdef WIN32
#include <windows.h>
#endif


That'll prevent the compiler from tryin to include windows.h on non win32 platforms as WIN32 will only be defined on Windows (obviously).

Share this post


Link to post
Share on other sites
There are a few SDL gui libraries available. You may wish to consider using one, so that you get their message box capabilities across all your platforms.

Share this post


Link to post
Share on other sites
Well I will eventually maybe look for refinements on my window manager for my Engine however, for now error pushing into the linux console on linux will work for now. If worse comes to worse I could alwasy use GTK or something for the message box on linux. But my window manager is working :D it is compiled and tested and works wonderfully. I however, need to learn some more about isometrics as my engine is going to be 2D isometric.

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!