fxengine/include/fxengine/texture.h

85 lines
2.2 KiB
C

#ifndef FE_TEXTURE
#define FE_TEXTURE
#include <stdint.h>
#include <stdbool.h>
/**
* @brief texture rich type
* transparency is in the layout
* @warning Monochrome only !
*/
struct fe_texture_rich
{
uint32_t size_px_x;
uint32_t size_px_y;
uint32_t size_o_y;
uint32_t * color;
bool color_dynamic;
uint32_t * layout;
bool layout_dynamic;
};
typedef struct fe_texture_rich fe_texture_rich;
/**
* @brief { function_description }
*
* @param[in] size_px_x The width in px
* @param[in] size_px_y The height in px
* @param color color origin
* @param[in] copy_color if you want to make a copy, or only to make a link
* @param layout layout origin -> can be set as 0 if it isn't needed
* @param[in] copy_layout if you want to make a copy, or to make a link
*
* @return a rich texture, ready to use !
*/
fe_texture_rich* fe_texture_new_rich(uint32_t size_px_x, uint32_t size_px_y, uint32_t* color, bool copy_color,
uint32_t *layout, bool copy_layout);
/**
* @brief delete a rich texture created with texture_new_rich()
*
* @param txtr The texture to delete
*/
void fe_texture_delete_rich(fe_texture_rich * txtr);
/**
* @brief get the color of pixel from rich texture
*
* @param[in] txtr The texture
* @param[in] x The texture x coordinate (in pixels)
* @param[in] y The texture y coordinate (in pixels)
*
* @return the color coded in a unsigned char :
* if (color >> 1)
* switch (color%2)
* {
* case 0:
* // WHITE
* break;
* case 1:
* // BLACK
* }
* else
*/
uint8_t fe_texture_get_pixel_r(const fe_texture_rich * txtr, uint32_t x, uint32_t y);
/**
* @brief display a specific rich texture pixel on the screen (on vram)
*
* @param[in] txtr The texture
* @param[in] txtr_x The texture x coordinate (in pixels)
* @param[in] txtr_y The texture y coordinate (in pixels)
* @param[in] x screen : x coordinate
* @param[in] y screen : y coordinate
*/
void fe_texture_display_pixel_r(const fe_texture_rich * txtr, uint32_t txtr_x, uint32_t txtr_y, uint32_t x, uint32_t y);
void fe_texture_debug(fe_texture_rich * txtr);
#endif