restructure headers, and source files
This commit is contained in:
parent
03166b0a17
commit
08a5a5f8ac
|
@ -1,8 +1,8 @@
|
|||
#ifndef RENDER_TRIANGLE_H
|
||||
#define RENDER_TRIANGLE_H
|
||||
#ifndef FE_FACE
|
||||
#define FE_FACE
|
||||
|
||||
#include <render/translate.h>
|
||||
#include <render/bitmap.h>
|
||||
#include <fxengine/point.h>
|
||||
#include <fxengine/bitmap.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,8 @@ struct render_triangle
|
|||
};
|
||||
typedef struct render_triangle render_triangle;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Renders a triangle with perspective deformation
|
||||
*
|
||||
|
@ -36,11 +38,9 @@ void render_display_triangle(const render_triangle * face);
|
|||
* @brief Clears vram, zbuffer
|
||||
*
|
||||
* @param[in] libprof_channel The libprof channel to be used to count_fps
|
||||
* @param[in] dh Horizontal direction (rad)
|
||||
* @param[in] dv Vertical direction (rad)
|
||||
* @param[in] roulis The roulis (rad)
|
||||
* @param[in] camera Pointer to the camera
|
||||
*/
|
||||
void render_update(const uint32_t libprof_channel);
|
||||
void fe_render_update(const uint32_t libprof_channel);
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef RENDER_PARAM
|
||||
#define RENDER_PARAM
|
||||
#ifndef FE_RENDER_PARAM
|
||||
#define FE_RENDER_PARAM
|
||||
|
||||
|
||||
// Render param
|
||||
|
@ -14,4 +14,4 @@
|
|||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef FE_POINT
|
||||
#define FE_POINT
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fxengine/parameters.h>
|
||||
|
||||
/**
|
||||
* @brief this struct is a point in 3d, which has coords save as uint32_t
|
||||
* this is the recommended type for high performance rendering, because the sh3eb-elf architecture
|
||||
* is 32 bits
|
||||
* This is also the type used by the rendering triangles.
|
||||
*/
|
||||
struct render_integer_position
|
||||
{
|
||||
int32_t x,
|
||||
y,
|
||||
z;
|
||||
};
|
||||
typedef struct render_integer_position render_integer_position;
|
||||
|
||||
/**
|
||||
* @brief this struct is a point in 3d, which has coords save as double
|
||||
* it is not recommended to use it for high performances rendering,
|
||||
* because of the sh3eb-elf architecture, which does not support natively floating calculation
|
||||
*/
|
||||
struct render_floating_position
|
||||
{
|
||||
double x,
|
||||
y,
|
||||
z;
|
||||
};
|
||||
typedef struct render_floating_position render_floating_position;
|
||||
|
||||
|
||||
/**
|
||||
* @brief This is a point which is used for 3d translations and rendering
|
||||
* integer mode is the best solution to increase perfs, and that's why I didn't have implemented
|
||||
* the floating_points yet. (Maybe I will never add them)
|
||||
* To render a triangle, you have to set &point.translated as s1, s2 or even s3
|
||||
*/
|
||||
struct render_integer_point
|
||||
{
|
||||
render_integer_position real;
|
||||
render_integer_position translated;
|
||||
};
|
||||
typedef struct render_integer_point render_integer_point;
|
||||
|
||||
/**
|
||||
* mathematics constants
|
||||
*/
|
||||
extern const double pi, pi2, pi_sur_2;
|
||||
|
||||
|
||||
#endif
|
|
@ -1,56 +1,7 @@
|
|||
#ifndef RENDER_TRANSLATE_H
|
||||
#define RENDER_TRANSLATE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <render/parameters.h>
|
||||
|
||||
/**
|
||||
* @brief this struct is a point in 3d, which has coords save as uint32_t
|
||||
* this is the recommended type for high performance rendering, because the sh3eb-elf architecture is 32 bits
|
||||
*/
|
||||
struct render_integer_position
|
||||
{
|
||||
int32_t x,
|
||||
y,
|
||||
z;
|
||||
};
|
||||
typedef struct render_integer_position render_integer_position;
|
||||
|
||||
/**
|
||||
* @brief this struct is a point in 3d, which has coords save as double
|
||||
* it is not recommended to use it for high performances rendering, because of the sh3eb-elf architecture, which does not support natively floating calculation
|
||||
*/
|
||||
struct render_floating_position
|
||||
{
|
||||
double x,
|
||||
y,
|
||||
z;
|
||||
};
|
||||
typedef struct render_floating_position render_floating_position;
|
||||
|
||||
|
||||
/**
|
||||
* @brief This is a point which is used for 3d translations and rendering
|
||||
* integer mode is the best solution to increase perfs, and that's why I didn't have implemented te floating_points yet.
|
||||
*/
|
||||
struct render_integer_point
|
||||
{
|
||||
render_integer_position real;
|
||||
render_integer_position translated;
|
||||
};
|
||||
|
||||
typedef struct render_integer_point render_integer_point;
|
||||
|
||||
|
||||
// applique la matrice de rotation et les deltas sur les coordonnées d'un point
|
||||
|
||||
/**
|
||||
* @brief This function rotates and applies perspective on an integer point
|
||||
*
|
||||
* @param point The point which needs to be translated
|
||||
*/
|
||||
void render_translate(render_integer_point * point);
|
||||
|
||||
#include <fxengine/point.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -65,13 +16,6 @@ void render_translate(render_integer_point * point);
|
|||
void render_set(const double dh, const double dv, const double roulis, const render_integer_position * camera);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* mathematics constants
|
||||
*/
|
||||
extern const double pi, pi2, pi_sur_2;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets up an angle mesure between -pi and +pi
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef RENDER_ZBUFFER
|
||||
#define RENDER_ZBUFFER
|
||||
|
||||
#include <render/parameters.h>
|
||||
#include <fxengine/parameters.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/** FE_zbuffer_clear
|
||||
|
|
BIN
libfxengine.a
BIN
libfxengine.a
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
#include <gint/display.h>
|
||||
#include <render/bitmap.h>
|
||||
#include <fxengine/bitmap.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
|
64
src/object.c
64
src/object.c
|
@ -1,64 +0,0 @@
|
|||
#include <fxengine/object.h>
|
||||
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/std/stdio.h>
|
||||
#include <gint/std/string.h>
|
||||
|
||||
void fxe_object_init(fxe_object * object)
|
||||
{
|
||||
memset(object, 0, sizeof(fxe_object));
|
||||
}
|
||||
|
||||
|
||||
void fxe_object_set_points(fxe_object * object, render_integer_point * points, uint32_t n, bool copy)
|
||||
{
|
||||
|
||||
if (copy)
|
||||
{
|
||||
object->points = malloc(n*sizeof(render_integer_point));
|
||||
if (!object->points)
|
||||
return;
|
||||
memcpy(object->points, points, n*sizeof(render_integer_point));
|
||||
//memcpy()
|
||||
}
|
||||
|
||||
object->p_owner = copy;
|
||||
object->p_size = n;
|
||||
}
|
||||
|
||||
|
||||
void fxe_object_set_faces(fxe_object * object, render_triangle * faces, uint32_t n, bool copy)
|
||||
{
|
||||
if (copy)
|
||||
{
|
||||
object->faces = malloc(n*sizeof(render_integer_point));
|
||||
if (!object->faces)
|
||||
return;
|
||||
memcpy(object->faces, faces, n*sizeof(render_integer_point));
|
||||
}
|
||||
|
||||
object->f_owner = copy;
|
||||
object->f_size = n;
|
||||
}
|
||||
|
||||
|
||||
void fxe_object_delete(fxe_object * object)
|
||||
{
|
||||
if (object->points && object->p_owner)
|
||||
free(object->points);
|
||||
|
||||
if (object->faces && object->f_owner)
|
||||
free(object->faces);
|
||||
|
||||
fxe_object_init(object);
|
||||
}
|
||||
|
||||
|
||||
void fxe_object_display(fxe_object * object)
|
||||
{
|
||||
for (int i = 0; i < object->p_size; i++)
|
||||
render_translate(&object->points[i]);
|
||||
|
||||
for (int i = 0; i < object->f_size; i++)
|
||||
render_display_triangle(&object->faces[i]);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include <render/translate.h>
|
||||
#include <fxengine/point.h>
|
||||
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/std/string.h>
|
|
@ -1,6 +1,6 @@
|
|||
#include <render/triangle.h>
|
||||
#include <render/bitmap.h>
|
||||
#include <render/translate.h>
|
||||
#include <fxengine/face.h>
|
||||
#include <fxengine/bitmap.h>
|
||||
#include <fxengine/point.h>
|
||||
#include <render/zbuffer.h>
|
||||
|
||||
#ifdef USE_LIBPROF
|
|
@ -1,5 +1,5 @@
|
|||
#include <render/zbuffer.h>
|
||||
#include <render/parameters.h>
|
||||
#include <fxengine/parameters.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
@ -22,7 +22,7 @@ static int32_t *zbuffer = (void *)0x88080000 - (((size_char >> 5) << 5) + 1);
|
|||
|
||||
// gint doesn't provide any prototype for that function which is implemented
|
||||
|
||||
/// extern void dma_memset(void *dst, uint32_t l, size_t size);
|
||||
extern void dma_memset(void *dst, uint32_t l, size_t size);
|
||||
|
||||
void render_zbuffer_clear()
|
||||
{
|
Loading…
Reference in New Issue