Adding doc, and organizing the structure
This commit is contained in:
parent
6324b32867
commit
da72997a6e
|
@ -0,0 +1,52 @@
|
|||
#ifndef FE_MODEL_BITMAP
|
||||
#define FE_MODEL_BITMAP
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* bitmap model
|
||||
transparency is in the layout
|
||||
this color type is monochrome only ! */
|
||||
typedef struct fe_bitmap
|
||||
{
|
||||
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;
|
||||
} fe_bitmap;
|
||||
|
||||
|
||||
/* fe_bitmap_new_rich()
|
||||
creates a new bitmap in the ram
|
||||
with this function, the bmp is dynamic only, but there is still a way tou create it staticly :
|
||||
you create a dynamic bmp
|
||||
you create a static bmp <fe_bitmap bmp;>
|
||||
you do a memcpy*/
|
||||
fe_bitmap_rich* fe_bitmap_new_rich(
|
||||
uint32_t size_px_x, uint32_t size_px_y, // bitmap size
|
||||
uint32_t* color, bool copy_color, // color table address and type (static | dynamic)
|
||||
uint32_t *layout, bool copy_layout // layout table address and type (static | dynamic)
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief delete a rich bitmap created with bitmap_new_rich()
|
||||
*
|
||||
* @param txtr The bitmap to delete
|
||||
*/
|
||||
void fe_bitmap_delete_rich(fe_bitmap_rich * txtr);
|
||||
|
||||
|
||||
/* fe_bitmap_get_pixel()
|
||||
returns the color of a pixel in the gint's type*/
|
||||
uint8_t fe_bitmap_get_pixel_r(const fe_bitmap_rich * txtr, uint32_t x, uint32_t y);
|
||||
|
||||
|
||||
/* fe_bitmap_display_pixel()
|
||||
display a specific rich bitmap pixel on the screen (on vram) */
|
||||
void fe_bitmap_display_pixel_r(const fe_bitmap_rich * txtr, uint32_t txtr_x, uint32_t txtr_y, uint32_t x, uint32_t y);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
# Bitmap data
|
||||
```c
|
||||
#include <fxengine/model/bitmap.h>
|
||||
```
|
||||
## What is it ?
|
||||
The `fe_bitmap` data structure is a way to use pictures in fxengine. These pictures are saved with a format which is near to the `*.bmp` type.
|
||||
|
||||
## Detail
|
||||
```c
|
||||
typedef struct fe_bitmap
|
||||
{
|
||||
uint32_t size_px_x;
|
||||
uint32_t size_px_y;
|
||||
|
||||
uint32_t * color;
|
||||
uint32_t * layout;
|
||||
|
||||
bool color_dynamic;
|
||||
bool layout_dynamic;
|
||||
uint16_t size_o_y;
|
||||
} fe_bitmap;
|
||||
```
|
||||
Here are the most used parameters :
|
||||
- `size_px_x` and `size_px_y` are the bitmap's height and width, in pixels.
|
||||
- `*color` is a pointer to a monochrome bitmap.
|
||||
The format is the following : one bit is on pixel => 1 means black, 0 means white.
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef FE_MODEL_TRIANGLE
|
||||
#define FE_MODEL_TRIANGLE
|
||||
|
||||
|
||||
|
||||
/* fe_triangle model
|
||||
this struct makes 3d displaying easier */
|
||||
typedef struct fe_triangle
|
||||
{
|
||||
fe_integer_vertex * s1;
|
||||
fe_integer_vertex * s2;
|
||||
fe_integer_vertex * s3;
|
||||
|
||||
fe_bitmap * texture1;
|
||||
fe_bitmap * texture2;
|
||||
} fe_triangle;
|
||||
|
||||
|
||||
|
||||
/* fe_display_triangle()
|
||||
displays a triangle from the previous model */
|
||||
void fe_display_triangle(const fe_triangle * face);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,84 +0,0 @@
|
|||
#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
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef FE_TRIANGLE
|
||||
#define FE_TRIANGLE
|
||||
|
||||
#include <fxengine/space.h>
|
||||
#include <fxengine/texture.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Triangle struct used to render fonctions
|
||||
* @param[out] part choose the used texture half
|
||||
* @param[out] clockwised choose the visible side of the face
|
||||
* @param[out] s1,s2,s3 three points
|
||||
* @param[out] texture used texture
|
||||
*/
|
||||
struct fe_triangle
|
||||
{
|
||||
fe_ipoint * s1;
|
||||
fe_ipoint * s2;
|
||||
fe_ipoint * s3;
|
||||
|
||||
fe_texture_rich * texture;
|
||||
|
||||
bool part;
|
||||
bool clockwised;
|
||||
};
|
||||
typedef struct fe_triangle fe_triangle;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Renders a triangle with perspective deformation
|
||||
*
|
||||
* @param[in] face pointer to the face to draw
|
||||
*/
|
||||
void fe_display_triangle(const fe_triangle * face);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef RENDER_TRIANGLE
|
||||
#define RENDER_TRIANGLE
|
||||
|
||||
#include <fxengine/models/vertex.h>
|
||||
#include <fxengine/models/bitmap.h>
|
||||
|
||||
/* render_triangle()
|
||||
renders a face supporting backface culling, or dual textures */
|
||||
void render_triangle(fe_integer_vertex const s1, fe_integer_vertex const s2, fe_integer_vertex const s3,
|
||||
fe_bitmap const * side_0, fe_bitmap const * side_1);
|
||||
|
||||
/* render_triangle_nobfc()
|
||||
renders a face without backface culling */
|
||||
void render_triangle_nobfc(fe_integer_vertex const s1, fe_integer_vertex const s2, fe_integer_vertex const s3,
|
||||
fe_bitmap const * side);
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue