🔒 Locked
SDL and MessageBoxes
Advertisement
Original Post
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.
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:
This hides away all the Win32 specific stuff inside a function to make the code a little cleaner instead of loads of #ifdefs.
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 it's possible to open a second window using SDL but you may need a derived C++ library called HXRender
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.
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.
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.
Ok thanks a bunch that should do the trick then.
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement