Ray Kelm

  • About
    • Home
    • News

User Login

  • Create account
  • Reset password

Projects

  • SDL_gui
  • Cyclone
  • roaddemo
  • rtChess
  • exemel
  • gp2x
  • robot

Options

Recent News

  • leJOS NXJ for Mindstorms NXT
  • Chumby at work
  • Chumby!
  • And...
  • Busy busy busy...

News Tags

  • news (46)
  • cyclone (15)
  • SDL_gui (14)
  • robot (7)
  • chumby (3)
  • lego (3)
  • exemel (2)
  • nms (1)
  • work (1)
  • dev (1)
  • robofest (1)
  • rtChess (1)
  • roaddemo (1)
  • osgi (1)

Links

  • DataSlab Hosting
  • SellMySoftwareOnline!
  • SDL
  • YAAARC
  • FIRST
  • Arduino

SDL_gui conversion guide

Version 0.9.x of SDL_gui was implemented in C.

Version 0.10.x is implemented in C++, but still includes the original C api. In order to create new widgets, you will need to use C++, however.

In order to get a 0.9.9 app to run using 0.10.0, you need to make a few changes, which are not related to the C to C++ conversion.

0.10.0 requires that SDL be initialized before calling GUI_Init. This was done to allow the application more control over how SDL is used. If SDL_ttf is used, then it also needs to be initialized before calling GUI_Init. An example follows:

/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
    return 1;
atexit(SDL_Quit);
/* Initialize the TTF library */
if (TTF_Init() < 0)
    return 1;
atexit(TTF_Quit);
if (GUI_Init() < 0)
    return 1;

Another difference which this points out is that the screen object is no longer created by the call to GUI_Init. You can use the following code to create a screen: (This must be done after the call to GUI_Init.)

GUI_Screen *screen = GUI_ScreenCreate(w, h, d, v); if (screen == NULL) return 1; GUI_SetScreen(screen);

These are the only required changes to get a 0.9.9 app to run using 0.10.0. There are other changes that can be made, which allow more control over how SDL is used, but they are not required.

Copyright © Ray Kelm. All rights reserved.

Valid XHTML 1.0 Strict Valid CSS!