65 lines
1.4 KiB
C
65 lines
1.4 KiB
C
#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]);
|
|
}
|