Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
System

Enumerations

enum  bj_system { BJ_NO_SYSTEM = 0x00 , BJ_AUDIO_SYSTEM = 0x01 , BJ_VIDEO_SYSTEM = 0x02 }

Functions

bj_bool bj_begin (int systems, struct bj_error **error)
void bj_end (void)
bj_bool bj_begin_system (enum bj_system system, struct bj_error **error)
void bj_end_system (enum bj_system system, struct bj_error **error)
void * bj_load_library (const char *path)
void bj_unload_library (void *handle)
void * bj_library_symbol (void *handle, const char *name)

Detailed Description

Abstraction to usual system calls such as library loading and time.

Enumeration Type Documentation

◆ bj_system

enum bj_system
Enumerator
BJ_NO_SYSTEM 
BJ_AUDIO_SYSTEM 
BJ_VIDEO_SYSTEM 

Function Documentation

◆ bj_begin()

bj_bool bj_begin ( int systems,
struct bj_error ** error )

Initializes the system.

Parameters
systemsAn OR combination of bj_system to initialize.
errorAn optional location to an error object.

The initialization process will iteratively try to initialize a subsystem among the ones available and returns on the first that succeeded.

Returns
true if the system is properly initialized, BJ_FALSE otherswise.

◆ bj_begin_system()

bj_bool bj_begin_system ( enum bj_system system,
struct bj_error ** error )

Initializes a single system with reference counting.

Parameters
systemA single bj_system value to initialize.
errorAn optional location to an error object.

This function retains the specified system, incrementing its reference count. Time and event subsystems are always retained as dependencies. Multiple calls to this function must be balanced with matching calls to bj_end_system.

Returns
true if the system is successfully retained, BJ_FALSE otherwise.
See also
bj_end_system, bj_begin

◆ bj_end()

void bj_end ( void )

De-initializes the system.

This function forcefully shuts down all subsystems and resets all reference counts to zero, regardless of how many times they were retained. Errors during shutdown are ignored.

◆ bj_end_system()

void bj_end_system ( enum bj_system system,
struct bj_error ** error )

De-initializes a single system with reference counting.

Parameters
systemA single bj_system value to release.
errorAn optional location to an error object.

This function releases the specified system, decrementing its reference count. Time and event subsystems are also released. When a system's reference count reaches zero, it is fully shut down.

See also
bj_begin_system, bj_end

◆ bj_library_symbol()

void * bj_library_symbol ( void * handle,
const char * name )

Get the address of a function exported by handle given its name.

This function is an abstraction over the platform specific function like dlsym and GetProcAddress.

Parameters
handleA library handle provided by bj_load_library.
nameC-String name of the function to retrieve
Returns
0 or the address of the retrieved function.
Behaviour
  • On Unix platforms, handle and name are passed to dlsym().
  • On Windows, handle and name are passed to GetProcAddress().
Memory Management

The caller is responsible for release the loaded function using bj_unload_library with handle.

See also
bj_load_library, bj_unload_library
dlsym(), GetProcAddress()

◆ bj_load_library()

void * bj_load_library ( const char * path)

Load the provided dynamic library and returns and opaque handle to it.

This function is an abstraction over the platform specific function like dlopen and LoadLibrary. The provided pointer can be used with bj_library_symbol to get a function from the loaded library.

Parameters
pathA C-string path to the library to load.
Returns
0 or a handle to the loaded library.
Behaviour
  • On Unix platforms, path is passed to dlopen() with RTLD_LAZY and RTLD_LOCAL flags.
  • On Windows, path is passed to LoadLibraryA().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_library_symbol, bj_unload_library
dlopen(), LoadLibraryA()

◆ bj_unload_library()

void bj_unload_library ( void * handle)

Unload a library loaded with bj_load_library from memory.

This function is an abstraction over the platform specific function like dlclose and FreeLibrary.

Parameters
handleThe library to unload.
Behaviour
  • On Unix platforms, handle is passed to dlclose().
  • On Windows, path is passed to FreeLibrary().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_library_symbol, bj_unload_library
dlclose(), FreeLibrary()