Hexmap SDL Bindings Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up |
int hex_sdl_init (Uint32 flags, GMainContext *context_in); void hex_sdl_run (); void hex_sdl_quit (); struct HexPollSDL; gboolean (*HexPollSDLSourceFunc) (SDL_Event *event, gpointer data); HexPollSDL* hex_poll_sdl_add (Uint32 event_mask, HexPollSDLSourceFunc callback, gpointer data, GDestroyNotify notify); HexPollSDL* hex_poll_sdl_add_object (Uint32 event_mask, HexPollSDLSourceFunc callback, GObject *data); void hex_poll_sdl_remove (HexPollSDL *poll); |
These functions are a convienience for people writing programs from scratch. If you already have your own mainloop, you can provide equivalent functionality by: 1) Creating a Glib mainloop and polling it regularly. This will update the various timeouts used by the library. 2) Pass events which match HEX_DISPLAY_SDL_EVENT_MASK through hex_display_sdl_handle_event(). 3) Handle SDL_QUIT. The functions in this section do all of the above, and also provide a mechanism for you to add additional event handlers.
int hex_sdl_init (Uint32 flags, GMainContext *context_in); |
Initialize SDL, and set up the Glib mainloop to poll for SDL events
flags to be passed to SDL_Init()
the GMainContext to run in, or NULL for the default context
0 on success, -1 on failure
void hex_sdl_quit (); |
Shut down the Glib mainloop and SDL. This function is called by the default handler for SDL_QUIT.
gboolean (*HexPollSDLSourceFunc) (SDL_Event *event, gpointer data); |
A callback function for an SDL_Event handler. It is called after HexDisplaySDL has had a chance to handle mouse events, but before the default handler for SDL_QUIT.
an SDL_Event
the callback user data
TRUE if the event should no longer be propagated
HexPollSDL* hex_poll_sdl_add (Uint32 event_mask, HexPollSDLSourceFunc callback, gpointer data, GDestroyNotify notify); |
Add an event handler for SDL events.
which SDL events to poll for
the poll callback function
the user data to pass to the callback function
the function to call to free the user data when the poll is removed
the newly created HexPollSDL
HexPollSDL* hex_poll_sdl_add_object (Uint32 event_mask, HexPollSDLSourceFunc callback, GObject *data); |
Add an event handler for SDL events.
which SDL events to poll for
the poll callback function
a Gobject to pass as user data to the callback function
the newly created HexPollSDL
void hex_poll_sdl_remove (HexPollSDL *poll); |
Remove an event handler for SDL events.
the event handler to remove