views:

747

answers:

1

I have been writing an OpenGL game engine for a while which uses SDL for all the window management and for portability. I would like to create a level editor using the full engine. The engine itself isn't at all tied in with SDL except for input. I would like to use wxWidgets for the GUI and I have been looking at some OpenGL samples which are quite simple and easy to understand.

Would it be simpler to try and integrate SDL with wxWidgets and use both or switch between them for use in different applications? What would be the best way to switch between the two systems?

+3  A: 

In all likelihood it would be easier to use one GUI API per application as opposed to merging the two together (i.e. easier to have SDL/OpenGL in your game and wxWidgets/OpenGL in your level editor). Usually these libraries are not built to be merged together or used in conjunction with other libraries so it would be nearly impossible to use them both in one program. For example, I don't know much about SDL, but a correctly-written wxWidgets program uses internal macros to generate int main() and start up its message pump, among other things. If SDL required you to do the same thing (run some special initialization code in your int main() or allow SDL to generate its own int main()) you would be unable to initialize SDL properly without breaking wxWidgets, and vice versa. Again, I don't know if this particular conflict actually exists between the two libraries, but it's just an example of how the two can interact and interfere with each other.

That said, in a perfect world it would be better to choose one of the libraries and use it both for your engine and level editor (i.e. use SDL/OpenGL for the engine and editor, or wxWidgets/OpenGL for the engine and editor), but if you're happy maintaining two different API codebases, then if it ain't broke, don't fix it.

GRB
SDL doesn't use a main() macro and can be initialized in parts, but I'd guess that the message loops would overlap. (SDL requires you to implement your own loop.)
aib
Yeah, if not at int main() then at the message loop will there be issues. wxWidgets creates its own native message loop completely hidden from the end-user; modifying it even slightly would easily break the library.
GRB