#ifndef GLERMINAL_H #define GLERMINAL_H #ifdef __cplusplus extern "C" { #endif enum { GLERMINAL_CELL_SIZE = 8, GLERMINAL_CELL_AREA = GLERMINAL_CELL_SIZE * GLERMINAL_CELL_SIZE }; typedef void (*glerminal_init_cb)(); typedef void (*glerminal_main_cb)(float dt); typedef struct glerminal_sprite { unsigned int data[GLERMINAL_CELL_AREA]; } glerminal_sprite; /** * @brief Call init once, then run the application's mainloop * @param init initialization callback * @param main main calllback */ void glerminal_run(glerminal_init_cb init, glerminal_main_cb main); /** * @brief Update the displayed screen contents to the current state of the library */ void glerminal_flush(); /** * @brief Set a cell's sprite * @param x position of the cell in the range [0, 40) * @param y position of the cell in the range [0, 25) * @param layer layer of the cell in the range [0, 8) * @param sprite sprite's index in the range [0, 256) */ void glerminal_set(unsigned char x, unsigned char y, unsigned char layer, unsigned char sprite); /** * @brief Get a cell's sprite * @param x position of the cell in the range [0, 40) * @param y position of the cell in the range [0, 25) * @param layer layer of the cell in the range [0, 8) * @return sprite index currently assigned to the cell */ unsigned char glerminal_get(unsigned char x, unsigned char y, unsigned char layer); /** * @brief Set a cell's offset * @param x position of the cell in the range [0, 40) * @param y position of the cell in the range [0, 25) * @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); /** * @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 Upload sprite to the given sprite ID * @param id The ID of the sprite to change * @param sprite The new sprite */ void glerminal_update_sprite(unsigned char id, glerminal_sprite sprite); #ifdef __cplusplus } #endif #endif//GLERMINAL_H