glerminal/include/glerminal.h

88 lines
2.7 KiB
C
Raw Normal View History

2024-05-09 19:42:12 +00:00
#ifndef GLERMINAL_H
#define GLERMINAL_H
2024-05-24 01:33:15 +00:00
#include <glerminal-config.h>
2024-05-09 19:42:12 +00:00
#ifdef __cplusplus
extern "C"
{
#endif
2024-05-14 21:46:30 +00:00
typedef void (*glerminal_init_cb)();
typedef void (*glerminal_main_cb)(float dt);
2024-05-30 14:57:36 +00:00
typedef void (*glerminal_keys_cb)(int key);
2024-05-09 19:42:12 +00:00
/**
2024-05-14 21:46:30 +00:00
* @brief Call init once, then run the application's mainloop
2024-05-16 18:48:24 +00:00
* @param init initialization callback
* @param main main calllback
2024-05-30 14:57:36 +00:00
* @param pressed key pressed callback (can be null)
* @param released key released callback (can be null)
*/
2024-05-30 14:57:36 +00:00
void glerminal_run(glerminal_init_cb init, glerminal_main_cb main, glerminal_keys_cb pressed, glerminal_keys_cb released);
2024-05-09 19:42:12 +00:00
2024-05-26 03:16:23 +00:00
void glerminal_quit();
/**
* @brief Update the displayed screen contents to the current state of the library
*/
2024-05-09 19:42:12 +00:00
void glerminal_flush();
/**
* @brief Set a cell's sprite
2024-05-15 03:03:45 +00:00
* @param x position of the cell in the range [0, 40)
* @param y position of the cell in the range [0, 25)
2024-05-15 02:42:49 +00:00
* @param layer layer of the cell in the range [0, 8)
* @param sprite sprite's index in the range [0, 256)
*/
2024-06-02 18:34:07 +00:00
void glerminal_set(unsigned char x, unsigned char y, unsigned char layer, unsigned short sprite);
/**
* @brief Get a cell's sprite
2024-05-15 03:03:45 +00:00
* @param x position of the cell in the range [0, 40)
* @param y position of the cell in the range [0, 25)
2024-05-15 02:42:49 +00:00
* @param layer layer of the cell in the range [0, 8)
* @return sprite index currently assigned to the cell
*/
2024-06-02 18:34:07 +00:00
unsigned char glerminal_get(unsigned char x, unsigned char y, unsigned short layer);
2024-05-15 02:42:49 +00:00
/**
* @brief Set a cell's offset
2024-05-15 03:03:45 +00:00
* @param x position of the cell in the range [0, 40)
* @param y position of the cell in the range [0, 25)
2024-05-15 02:42:49 +00:00
* @param layer layer of the cell in the range [0, 8)
* @param x_offset offset of the cell on the x axis in the range [-128, 127], where 0 is no offset
* @param y_offset offset of the cell on the y axis in the range [-128, 127], where 0 is no offset
*/
void glerminal_offset(unsigned char x, unsigned char y, unsigned char layer, float x_offset, float y_offset);
2024-05-17 04:51:45 +00:00
/**
* @brief Set a layer's color
* @param layer The layer to modify
* @param color The new color
*/
void glerminal_layer_color(unsigned char layer, unsigned int color);
/**
* @brief Set a layer's scale
* @param layer The layer to modify
* @param scale The new scale
*/
void glerminal_layer_scale(unsigned char layer, float scale);
/**
* @brief Load sprites from a png file
* @param filename Name of the png file
*/
2024-05-29 11:16:01 +00:00
int glerminal_load_sprites_file(const char* filename);
2024-05-20 02:46:56 +00:00
/**
* @brief Load sprites from memory
* @param width width of the atlas in sprites
* @param height height of the atlas in sprites
* @param buffer the in-memory atlas
*/
2024-05-29 11:16:01 +00:00
int glerminal_load_sprites_buffer(unsigned char width, unsigned char height, const unsigned int* buffer);
2024-05-14 21:46:30 +00:00
2024-05-09 19:42:12 +00:00
#ifdef __cplusplus
}
#endif
#endif//GLERMINAL_H