SetupProgram

static bool SetupProgram(
bool setupKeyboard = true,
bool setupMouse = true,
bool setupTimer = true );

Sets up OpenLayer, Allegro, AllegroGL and the specified input devices. Returns true on success.

static bool SetupProgram(
int devices );

Same as above but the parameters are passed by using the bitwise "or" of any of the following devices: KEYBOARD, MOUSE and TIMER.

The first thing you should be doing in your program is to call this function. That's because you can't call any other OpenLayer function or any Allegro or AllegroGL function before you call this one.

Besides setting up the libraries it also sets up the specified input devices. It's usually recommended to set up the keyboard even if you're not using keyboard functions anywhere. Also setting up the mouse will also set up timer functions even if you pass false as setupTimer. That's because the mouse handling routines require the timer routines.

Calling the function with no parameters will by default set up all possible input devices and the timer routines.

It's best to call Setup::SetupScreen right after calling this function because you can't load any Bitmaps or TextRenderers before you've set up the screen!

Examples

// Setup the libraries and all drivers //
Setup::SetupProgram();

// Setup the libraries and the keyboard but not the mouse //
Setup::SetupProgramtruefalse );

// Same as above by using the named arguments //
Setup::SetupProgram( KEYBOARD );

// Setup the libraries and the keyboard and timer routines but not the mouse //
Setup::SetupProgramtruefalsetrue );

// Same as above by using the named arguments //
Setup::SetupProgram( KEYBOARD | TIMER );

// The function sets up all input devices and timer routines by default //
Setup::SetupProgram();
// Now the keyboard, mouse and timer routines are all set up //


Other functions of the class Setup
SetupProgram
Sets up OpenLayer and the other libraries
SetupScreen
Sets up the program window or the fullscreen mode
GetWindowWidth
Returns the width of the program window
GetWindowHeight
Returns the height of the program window
GetColorDepth
Returns the color depth of the program window
GetExecutablePath
Returns the path of the program executable
ToAbsolutePathname
Converts the relative pathname to an absolute one

Advanced functions

IsProgramSetUp
Returns true if SetupProgram is called
IsScreenSetUp
Returns true if SetupScreen is called


Questions about SetupProgram? Click here.