2.9.4
Functions
Setup

Basic setup and management. More...

Description

Basic setup and management.

Functions

TLN_Engine TLN_Init (int hres, int vres, int numlayers, int numsprites, int numanimations)
 Initializes the graphic engine. More...
 
void TLN_Deinit (void)
 Deinitialises current engine context and frees used resources.
 
bool TLN_DeleteContext (TLN_Engine context)
 Deletes explicit context. More...
 
bool TLN_SetContext (TLN_Engine context)
 Sets current engine context. More...
 
TLN_Engine TLN_GetContext (void)
 Returns the current engine context.
 
int TLN_GetWidth (void)
 Returns the width in pixels of the framebuffer. More...
 
int TLN_GetHeight (void)
 Returns the height in pixels of the framebuffer. More...
 
uint32_t TLN_GetNumObjects (void)
 Returns the number of objets used by the engine so far. More...
 
uint32_t TLN_GetUsedMemory (void)
 Returns the total amount of memory used by the objects. More...
 
uint32_t TLN_GetVersion (void)
 Retrieves Tilengine dll version. More...
 
int TLN_GetNumLayers (void)
 Returns the number of layers specified during initialisation. More...
 
int TLN_GetNumSprites (void)
 Returns the number of sprites specified during initialisation. More...
 
void TLN_SetBGColor (uint8_t r, uint8_t g, uint8_t b)
 Sets the background color. More...
 
bool TLN_SetBGColorFromTilemap (TLN_Tilemap tilemap)
 Sets the background color from a Tilemap defined color. More...
 
void TLN_DisableBGColor (void)
 Disales background color rendering. If you know that the last background layer will always cover the entire screen, you can disable it to gain some performance. More...
 
bool TLN_SetBGBitmap (TLN_Bitmap bitmap)
 Sets a static bitmap as background. More...
 
bool TLN_SetBGPalette (TLN_Palette palette)
 Changes the palette for the background bitmap. More...
 
void TLN_SetRenderTarget (uint8_t *data, int pitch)
 Sets the output surface for rendering. More...
 
void TLN_UpdateFrame (int frame)
 Draws the frame to the previously specified render target. More...
 
void TLN_SetLoadPath (const char *path)
 Sets base path for TLN_LoadXXX functions. More...
 
void TLN_SetCustomBlendFunction (TLN_BlendFunction)
 Sets custom blend function to use when BLEND_CUSTOM mode is selected. More...
 
void TLN_SetLogLevel (TLN_LogLevel log_level)
 Sets logging level for current instance. More...
 
bool TLN_OpenResourcePack (const char *filename, const char *key)
 Open the resource package with optional aes-128 key and binds it. More...
 
void TLN_CloseResourcePack (void)
 Closes current resource package and unbinds it. More...
 

Function Documentation

◆ TLN_Init()

TLN_Engine TLN_Init ( int  hres,
int  vres,
int  numlayers,
int  numsprites,
int  numanimations 
)

Initializes the graphic engine.

Parameters
hreshorizontal resolution in pixels
vresvertical resolution in pixels
numlayersnumber of layers
numspritesnumber of sprites
numanimationsnumber of palette animation slots

Performs initialisation of the main engine, creates the viewport with the specified dimensions and allocates the number of layers, sprites and animation slots

◆ TLN_DeleteContext()

bool TLN_DeleteContext ( TLN_Engine  context)

Deletes explicit context.

Parameters
contextcontext reference to delete

◆ TLN_SetContext()

bool TLN_SetContext ( TLN_Engine  context)

Sets current engine context.

Parameters
contextTLN_Engine object to set as current context, returned by TLN_Init()
Returns
true if success or false if wrong context is supplied

◆ TLN_GetWidth()

int TLN_GetWidth ( void  )

Returns the width in pixels of the framebuffer.

See also
TLN_Init(), TLN_GetHeight()

◆ TLN_GetHeight()

int TLN_GetHeight ( void  )

Returns the height in pixels of the framebuffer.

See also
TLN_Init(), TLN_GetWidth()

◆ TLN_GetNumObjects()

uint32_t TLN_GetNumObjects ( void  )

Returns the number of objets used by the engine so far.

Remarks
The objects is the total amount of tilesets, tilemaps, spritesets, palettes or sequences combined
See also
TLN_GetUsedMemory()

◆ TLN_GetUsedMemory()

uint32_t TLN_GetUsedMemory ( void  )

Returns the total amount of memory used by the objects.

See also
TLN_GetNumObjects()

◆ TLN_GetVersion()

uint32_t TLN_GetVersion ( void  )

Retrieves Tilengine dll version.

Returns
Returns a 32-bit integer containing three packed numbers: bits 23:16 -> major version bits 15: 8 -> minor version bits 7: 0 -> bugfix revision
Remarks
Compare this number with the TILENGINE_HEADER_VERSION macro to check that both versions match!

◆ TLN_GetNumLayers()

int TLN_GetNumLayers ( void  )

Returns the number of layers specified during initialisation.

See also
TLN_Init()

◆ TLN_GetNumSprites()

int TLN_GetNumSprites ( void  )

Returns the number of sprites specified during initialisation.

See also
TLN_Init()

◆ TLN_SetBGColor()

void TLN_SetBGColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the background color.

Parameters
rred component (0-255)
ggreen component (0-255)
bblue component (0-255)

The background color is the color of the pixel when there isn't any layer or sprite at that position.

Remarks
This funcion can be called during a raster callback to create gradient backgrounds

◆ TLN_SetBGColorFromTilemap()

bool TLN_SetBGColorFromTilemap ( TLN_Tilemap  tilemap)

Sets the background color from a Tilemap defined color.

Parameters
tilemapReference to the tilemap with the background color to set

◆ TLN_DisableBGColor()

void TLN_DisableBGColor ( void  )

Disales background color rendering. If you know that the last background layer will always cover the entire screen, you can disable it to gain some performance.

See also
TLN_SetBGColor()

◆ TLN_SetBGBitmap()

bool TLN_SetBGBitmap ( TLN_Bitmap  bitmap)

Sets a static bitmap as background.

Parameters
bitmapReference to bitmap for the background. Set NULL to disable

Sets an optional bitmap instead of a solid color where there is no layer or sprite. Unlike tilemaps or sprites, this bitmap cannot be moved and has no transparency

See also
TLN_SetBGPalette()

◆ TLN_SetBGPalette()

bool TLN_SetBGPalette ( TLN_Palette  palette)

Changes the palette for the background bitmap.

Parameters
paletteReference to palette
See also
TLN_SetBGBitmap()

◆ TLN_SetRenderTarget()

void TLN_SetRenderTarget ( uint8_t *  data,
int  pitch 
)

Sets the output surface for rendering.

Parameters
dataPointer to the start of the target framebuffer
pitchNumber of bytes per each scanline of the framebuffer

Sets the output surface for rendering. Tilengine doesn't provide a windowing or hardware video access. The application is responsible of allocating and maintaining the surface where tilengine does the rendering. It can be a SDL surface, a locked DirectX surface, an OpenGL texture, or whatever the application has access to.

Remarks
The render target pixel format must be 32 bits RGBA
See also
TLN_UpdateFrame()

◆ TLN_UpdateFrame()

void TLN_UpdateFrame ( int  frame)

Draws the frame to the previously specified render target.

Parameters
frameOptional frame number. Set to 0 to autoincrement from previous value
See also
TLN_SetRenderTarget()

◆ TLN_SetLoadPath()

void TLN_SetLoadPath ( const char *  path)

Sets base path for TLN_LoadXXX functions.

Parameters
pathBase path. Files will load at path/filename. Can be NULL

◆ TLN_SetCustomBlendFunction()

void TLN_SetCustomBlendFunction ( uint8_t(*)(uint8_t src, uint8_t dst)  blend_function)

Sets custom blend function to use when BLEND_CUSTOM mode is selected.

Parameters
blend_functionpointer to a user-provided function that takes two parameters: source component intensity, destination component intensity, and returns the desired intensity. This function is called for each RGB component when blending is enabled
Remarks
This function is not called in realtime, but its result is precomputed into a look-up table when TLN_SetCustomBlendFunction() is called, so the performance impact is minimal, just as low as the other built-in blending modes
See also
TLN_SetSpriteBlendMode()|TLN_SetLayerBlendMode()

◆ TLN_SetLogLevel()

void TLN_SetLogLevel ( TLN_LogLevel  log_level)

Sets logging level for current instance.

Parameters
log_levelvalue to set, member of the TLN_LogLevel enumeration

◆ TLN_OpenResourcePack()

bool TLN_OpenResourcePack ( const char *  filename,
const char *  key 
)

Open the resource package with optional aes-128 key and binds it.

Parameters
filenamefile with the resource package (.dat extension)
keyoptional null-terminated ASCII string with aes decryption key
Returns
true if package opened and made current, or false if error
Remarks
When the package is opened, it's globally bind to all TLN_LoadXXX functions. The assets inside the package are indexed with their original path/file as when they were plain files. As long as the structure used to build the package matches the original structure of the assets, the TLN_SetLoadPath() and the TLN_LoadXXX functions will work transparently, easing the migration with minimal changes.
See also
TLN_CloseResourcePack

◆ TLN_CloseResourcePack()

void TLN_CloseResourcePack ( void  )

Closes current resource package and unbinds it.

See also
TLN_OpenResourcePack