glerminal/include/glerminal.h

101 lines
3.1 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)();
2024-06-11 04:40:43 +00:00
typedef void (*glerminal_main_cb)(double dt);
2024-05-30 14:57:36 +00:00
typedef void (*glerminal_keys_cb)(int key);
2024-06-11 04:40:43 +00:00
typedef void (*glerminal_mousemoved_cb)(double x, double y);
typedef void (*glerminal_mousepress_cb)(int button, double x, double y);
typedef struct {
glerminal_init_cb init;
glerminal_main_cb main;
glerminal_keys_cb keypress, keyrelease;
glerminal_mousemoved_cb moved;
glerminal_mousepress_cb mousepress, mouserelease;
} glerminal_init_params;
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-06-11 04:40:43 +00:00
* @param params Initialization parameters
*/
2024-06-11 04:40:43 +00:00
void glerminal_run(glerminal_init_params params);
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-06-11 04:40:43 +00:00
* @param x position of the cell in the range [0, GRID_WIDTH)
* @param y position of the cell in the range [0, GRID_HEIGHT)
* @param layer layer of the cell in the range [0, LAYER_COUNT)
* @param sprite sprite's index in the range [0, 4096)
*/
void glerminal_set(int x, int y, int layer, unsigned short sprite);
/**
* @brief Get a cell's sprite
2024-06-11 04:40:43 +00:00
* @param x position of the cell in the range [0, GRID_WIDTH)
* @param y position of the cell in the range [0, GRID_HEIGHT)
* @param layer layer of the cell in the range [0, LAYER_COUNT)
* @return sprite index currently assigned to the cell
*/
unsigned short glerminal_get(int x, int y, int layer);
2024-05-15 02:42:49 +00:00
/**
* @brief Set a cell's offset
2024-06-11 04:40:43 +00:00
* @param x position of the cell in the range [0, GRID_WIDTH)
* @param y position of the cell in the range [0, GRID_HEIGHT)
* @param layer layer of the cell in the range [0, LAYER_COUNT)
* @param x_offset offset of the cell on the x axis in cells
* @param y_offset offset of the cell on the y axis in cells
2024-05-15 02:42:49 +00:00
*/
void glerminal_offset(int x, int y, int layer, float x_offset, float y_offset);
2024-05-17 04:51:45 +00:00
/**
2024-06-11 04:40:43 +00:00
* @brief Set a cell's color
* @param x position of the cell in the range [0, GRID_WIDTH)
* @param y position of the cell in the range [0, GRID_HEIGHT)
* @param layer layer of the cell in the range [0, LAYER_COUNT)
2024-05-17 04:51:45 +00:00
* @param color The new color
*/
void glerminal_color(int x, int y, int layer, unsigned int color);
2024-05-17 04:51:45 +00:00
/**
2024-06-11 04:40:43 +00:00
* @brief Set a cell's scale
* @param x position of the cell in the range [0, GRID_WIDTH)
* @param y position of the cell in the range [0, GRID_HEIGHT)
* @param layer layer of the cell in the range [0, LAYER_COUNT)
2024-05-17 04:51:45 +00:00
* @param scale The new scale
*/
void glerminal_scale(int x, int y, int layer, float scale);
2024-05-17 04:51:45 +00:00
/**
* @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-07-17 16:08:58 +00:00
void glerminal_sound(const char* name);
2024-05-09 19:42:12 +00:00
#ifdef __cplusplus
}
#endif
#endif//GLERMINAL_H