Browse Source

correct object's bug and add debug functions

undefined
milang 3 weeks ago
parent
commit
8f5af09bd6
12 changed files with 73 additions and 70 deletions
  1. 0
    48
      face.h
  2. 46
    1
      object.c
  3. 6
    2
      object.h
  4. 1
    0
      parameters.h
  5. 1
    1
      point.h
  6. 7
    7
      texture.c
  7. 1
    1
      translate.c
  8. 1
    1
      translate.h
  9. 4
    4
      triangle.c
  10. 3
    2
      triangle.h
  11. 2
    2
      zbuffer.c
  12. 1
    1
      zbuffer.h

+ 0
- 48
face.h View File

@@ -1,48 +0,0 @@
#ifndef FE_TRIANGLE
#define FE_TRIANGLE

#include <fxengine/point.h>
#include <fxengine/texture.h>
#include <stdbool.h>

/**
* @brief Triangle struct used to render fonctions
* @param[out] part choose the used texture half // currently not implemented
* @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_integer_position * s1;
fe_integer_position * s2;
fe_integer_position * 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);

/**
* @brief Clears vram, zbuffer
*
* @param[in] libprof_channel The libprof channel to be used to count_fps
* if you don't use libprof channel, (default), you send what you want,
* it doesn't matters ;)
*/
void fe_render_update(const uint32_t libprof_channel);



#endif

+ 46
- 1
object.c View File

@@ -1,8 +1,9 @@
#include <fxengine/object.h>
#include "object.h"

#include <gint/std/stdlib.h>
#include <gint/std/stdio.h>
#include <gint/std/string.h>
#include <gint/display.h>

void fe_object_init(fe_object * object)
{
@@ -21,6 +22,10 @@ void fe_object_set_points(fe_object * object, fe_integer_point * points, uint32_
memcpy(object->points, points, n*sizeof(fe_integer_point));
//memcpy()
}
else
{
object->points = points;
}

object->p_owner = copy;
object->p_size = n;
@@ -36,6 +41,11 @@ void fe_object_set_faces(fe_object * object, fe_triangle * faces, uint32_t n, bo
return;
memcpy(object->faces, faces, n*sizeof(fe_integer_point));
}
else
{
object->faces = faces;
}


object->f_owner = copy;
object->f_size = n;
@@ -62,3 +72,38 @@ void fe_object_display(fe_object * object)
for (int i = 0; i < object->f_size; i++)
fe_display_triangle(&object->faces[i]);
}

void fe_object_debug(const fe_object * object)
{
dclear(C_WHITE);
if (object)
{
char text[21];
sprintf(text, "ADDRESS : %p", object);
dtext(1,1, text, C_BLACK, C_NONE);

sprintf(text, "f-t %p %d", object->faces, object->f_owner);
dtext(1,9, text, C_BLACK, C_NONE);

sprintf(text, " -size = %d", object->f_size);
dtext(1,17, text, C_BLACK, C_NONE);

sprintf(text, "v-t %p %d", object->points, object->p_owner);
dtext(1,25, text, C_BLACK, C_NONE);

sprintf(text, " -size = %d", object->p_size);
dtext(1,33, text, C_BLACK, C_NONE);
}
else
{
dtext(1,1, "No object sent !", C_BLACK, C_NONE);
}
dupdate();
getkey();
}


fe_integer_point* fe_object_get_vertex(const fe_object * object, const int n)
{
return &object->points[n];
}

+ 6
- 2
object.h View File

@@ -1,8 +1,8 @@
#ifndef FE_OBJECT
#define FE_OBJECT

#include <fxengine/point.h>
#include <fxengine/triangle.h>
#include "point.h"
#include "triangle.h"
#include <stdint.h>
#include <stdbool.h>

@@ -28,4 +28,8 @@ void fe_object_delete(fe_object * object);

void fe_object_display(fe_object * object);

void fe_object_debug(const fe_object * object);

fe_integer_point* fe_object_get_vertex(const fe_object * object, const int n);

#endif

+ 1
- 0
parameters.h View File

@@ -3,6 +3,7 @@


// Render param
// You change it as you want before compiling ;)

#define fe_width 128
#define fe_height 64

+ 1
- 1
point.h View File

@@ -3,7 +3,7 @@


#include <stdint.h>
#include <fxengine/parameters.h>
#include "parameters.h"

/**
* @brief this struct is a point in 3d, which has coords save as uint32_t

+ 7
- 7
texture.c View File

@@ -1,4 +1,4 @@
#include <fxengine/texture.h>
#include "texture.h"

#include <gint/display.h>
#include <gint/std/string.h>
@@ -61,14 +61,14 @@ void fe_texture_debug(fe_texture_rich * txtr)
sprintf(text, "ADDRESS : %p", txtr);
dtext(1,1, text, C_BLACK, C_NONE);

sprintf(text, " - size : %d x %d", txtr->size_px_x, txtr->size_px_y);
dtext(1,8, text, C_BLACK, C_NONE);
sprintf(text, "size %d %d", txtr->size_px_x, txtr->size_px_y);
dtext(1,9, text, C_BLACK, C_NONE);

sprintf(text, " - color : %p x %d", txtr->color, txtr->color_dynamic);
dtext(1,15, text, C_BLACK, C_NONE);
sprintf(text, "color %p %d", txtr->color, txtr->color_dynamic);
dtext(1,17, text, C_BLACK, C_NONE);

sprintf(text, " - layout : %p x %d", txtr->layout, txtr->layout_dynamic);
dtext(1,15, text, C_BLACK, C_NONE);
sprintf(text, "layout %p %d", txtr->layout, txtr->layout_dynamic);
dtext(1,25, text, C_BLACK, C_NONE);
}
else
{

+ 1
- 1
translate.c View File

@@ -1,4 +1,4 @@
#include <fxengine/point.h>
#include "point.h"

#include <gint/std/stdlib.h>
#include <gint/std/string.h>

+ 1
- 1
translate.h View File

@@ -1,7 +1,7 @@
#ifndef RENDER_TRANSLATE_H
#define RENDER_TRANSLATE_H

#include <fxengine/point.h>
#include "point.h"


/**

+ 4
- 4
triangle.c View File

@@ -1,7 +1,7 @@
#include <fxengine/face.h>
#include <fxengine/texture.h>
#include <fxengine/point.h>
#include <render/zbuffer.h>
#include "triangle.h"
#include "texture.h"
#include "point.h"
#include "zbuffer.h"

#ifdef USE_LIBPROF
#include <libprof.h>

+ 3
- 2
triangle.h View File

@@ -1,8 +1,9 @@
#ifndef FE_TRIANGLE
#define FE_TRIANGLE

#include <fxengine/point.h>
#include <fxengine/texture.h>
#include "point.h"
#include "texture.h"

#include <stdbool.h>

/**

+ 2
- 2
zbuffer.c View File

@@ -1,5 +1,5 @@
#include <render/zbuffer.h>
#include <fxengine/parameters.h>
#include "zbuffer.h"
#include "parameters.h"

#include <stdbool.h>
#include <stdint.h>

+ 1
- 1
zbuffer.h View File

@@ -1,7 +1,7 @@
#ifndef RENDER_ZBUFFER
#define RENDER_ZBUFFER

#include <fxengine/parameters.h>
#include "parameters.h"
#include <stdint.h>

/** FE_zbuffer_clear

Loading…
Cancel
Save