Exit

Slice exits when you call slQuit, not on its own (unless there is a critical error). You are in direct control of the lifetime of the application.

bool slGetExitReq () returns true if an exit request has been signaled, false otherwise. For fun, it's also #defined as slGetReqt.

void slRejectExit () clears the exit request flag to false.

void slSignalExit () sets the exit request flag to true.

Basic Application Loop

void slInit (char* appname = "Slice Game Engine", char* settings_path = "settings") initializes the engine. The game window's title will be set to appname and settings will be loaded from settings_path. If settings can't be loaded from that location, they will be set to default values.

void slCycle () cycles the engine for one frame.

void slQuit () exits the engine. Settings will be saved to the location specified in the settings_path argument supplied to slInit.

The simplest Slice application would look like this:

#include <slice.h>

int main ()

{

slInit();

while (!slGetExitReq())

slCycle();

slQuit();

}

Basic Memory Functions

void slSetMemLimit (size_t limit) will cause subsequent calls to sl_malloc and sl_realloc to fail if the requested buffer size is greater than or equal to limit, unless limit is 0 (no limit), which is the default. Can be useful for finding the location of erroneously very large allocations (such as due to incorrect arithmetic).

void* sl_malloc (size_t len) and void* sl_realloc (void* buf, size_t len) wrap the the standard library's malloc and realloc in some code which checks whether allocation succeeded, and if not, shows the user an error message and then throws an assertion. They replace their standard library counterparts using #define macros.

void slFatal (char* msg, int returncode) shows msg to the user as an error message, then exits the program with returncode. Mainly for internal use.