-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the guisan wiki!
Guisan is an updated version of Guichan for SDL2.
Once you have cloned the repository, build the library and its examples by typing
scons
Note: this will not build the demo. To install, type
sudo scons install
which will install the library, its header files and the pkg-config file at the appropriate places. The authors of Guichan have made an amazing work in documenting their code, but to generate a more user-friendly documentation in HTML, type
doxygen Doxyfile
As is the case with most libraries, make sure you link your program with the -lguisan
option. Because guisan requires SDL2, SDL2_image and SDL2_ttf, guisan needs to appear before them in the compilation command. It may also be necessary to indicate the correct directory where the headers are installed.
If your project uses autotools, you can check for the presence of guisan on the system with pkg-config using the PKG_CHECK_MODULES
macro in your configure.ac
file.
Note: this part builds upon the knowledge gained from reading the examples provided.
The first step is to add the necessary headers in your source file:
#include <guisan.hpp> /* mandatory */
#include <guisan/sdl.hpp> /* needed for SDL-specific implementations */
Please note: guisan is not compatible (yet) with the new SDL2 Render API!
The next step is to include guisan in your game event loop.
- At the end of your event processing code, add a call to the
pushInput(SDL_Event event)
method of thegcn::SDLInput
object to make guisan aware of this event. - Then, we would like the GUI to process this event. To do so, call the
logic()
method of theGui
object. No parameter is needed. - Next, it is time to draw the updates to the target surface, using the
draw()
method of theGui
object. Again, no parameter is needed. - Finally, we tell SDL to display the changes on the screen with a call to
SDL_UpdateWindowSurface()
.