Browse Source

add object notion

master
milang 9 months ago
parent
commit
94145db9dc
No known key found for this signature in database GPG Key ID: D287C9D6C33D9035
12 changed files with 98 additions and 15 deletions
  1. +29
    -0
      include/fxengine/object.h
  2. +0
    -0
      include/render/bitmap.h
  3. +0
    -0
      include/render/parameters.h
  4. +1
    -1
      include/render/translate.h
  5. +2
    -2
      include/render/triangle.h
  6. +1
    -1
      include/render/zbuffer.h
  7. BIN
      libfxengine.a
  8. +54
    -0
      src/object.c
  9. +1
    -1
      src/render/bitmap.c
  10. +1
    -1
      src/render/translate.c
  11. +4
    -4
      src/render/triangle.c
  12. +5
    -5
      src/render/zbuffer.c

+ 29
- 0
include/fxengine/object.h View File

@@ -0,0 +1,29 @@
#ifndef FXE_OBJECT
#define FXE_OBJECT

#include <fxengine/render/translate.h>
#include <fxengine/render/triangle.h>
#include <stdint.h>
#include <stdbool.h>


struct fxe_object
{
render_triangle * faces;
uint32_t f_size;
bool f_owner;
render_integer_point * points;
uint32_t p_size;
bool p_owner;
};
typedef struct fxe_object fxe_object;

void fxe_object_init(fxe_object * object);

void fxe_object_set_points(fxe_object * object, render_integer_point * points, uint32_t n, bool copy);

void fxe_object_set_faces(fxe_object * object, render_triangle * faces, uint32_t n, bool copy);

void fxe_object_delete(fxe_object * object);

#endif

include/fxengine/render/bitmap.h → include/render/bitmap.h View File


include/fxengine/render/parameters.h → include/render/parameters.h View File


include/fxengine/render/translate.h → include/render/translate.h View File

@@ -2,7 +2,7 @@
#define RENDER_TRANSLATE_H

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

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

include/fxengine/render/triangle.h → include/render/triangle.h View File

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

#include <fxengine/render/translate.h>
#include <fxengine/render/bitmap.h>
#include <render/translate.h>
#include <render/bitmap.h>
#include <stdbool.h>

/**

include/fxengine/render/zbuffer.h → include/render/zbuffer.h View File

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

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

/** FE_zbuffer_clear

BIN
libfxengine.a View File


+ 54
- 0
src/object.c View File

@@ -0,0 +1,54 @@
#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);
}

+ 1
- 1
src/render/bitmap.c View File

@@ -1,5 +1,5 @@
#include <gint/display.h>
#include <fxengine/render/bitmap.h>
#include <render/bitmap.h>
#include <gint/std/string.h>
#include <gint/std/stdlib.h>



+ 1
- 1
src/render/translate.c View File

@@ -1,4 +1,4 @@
#include <fxengine/render/translate.h>
#include <render/translate.h>

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


+ 4
- 4
src/render/triangle.c View File

@@ -1,7 +1,7 @@
#include <fxengine/render/triangle.h>
#include <fxengine/render/bitmap.h>
#include <fxengine/render/translate.h>
#include <fxengine/render/zbuffer.h>
#include <render/triangle.h>
#include <render/bitmap.h>
#include <render/translate.h>
#include <render/zbuffer.h>

#ifdef USE_LIBPROF
#include <libprof.h>


+ 5
- 5
src/render/zbuffer.c View File

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

#include <stdbool.h>
#include <stdint.h>
@@ -28,11 +28,11 @@ void render_zbuffer_clear()
{
uint32_t indice = 0;

/// if (isSH3())
if (isSH3())
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = render_max_dist;
/// else
/// dma_memset(zbuffer, render_max_dist, size_char);
else
dma_memset(zbuffer, render_max_dist, size_char);

}



Loading…
Cancel
Save