75 lines
1.3 KiB
C
75 lines
1.3 KiB
C
#include <fxengine/renderlist.h>
|
|
#include <fxengine/model/object.h>
|
|
#include <gint/std/stdlib.h>
|
|
|
|
static fe_object ** list = 0;
|
|
static int list_size = 0;
|
|
|
|
int fe_renderlist_add(fe_object * const object)
|
|
{
|
|
if (object==0)
|
|
return -1;
|
|
for (int i=0; i<list_size; i++)
|
|
if (list[i]==object)
|
|
return -1;
|
|
for (int i=0; i<list_size; i++)
|
|
{
|
|
if (list[i]==0)
|
|
{
|
|
list[i]=object;
|
|
return i;
|
|
}
|
|
}
|
|
|
|
if (list==0)
|
|
{
|
|
list_size++;
|
|
list=malloc(sizeof(fe_object*));
|
|
list[0]=object;
|
|
}
|
|
else
|
|
{
|
|
list_size++;
|
|
list=realloc(list, list_size*sizeof(fe_object*));
|
|
list[list_size-1]=object;
|
|
}
|
|
}
|
|
|
|
int fe_renderlist_remove(fe_object * const object)
|
|
{
|
|
if (object==0)
|
|
return -1;
|
|
for (int i=0; i<list_size; i++)
|
|
if (list[i]==object)
|
|
{
|
|
list[i]=0;
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
fe_object * fe_renderlist_remove_id(int id)
|
|
{
|
|
if (id>=list_size)
|
|
return 0;
|
|
else
|
|
{
|
|
fe_object * tmp = list[id];
|
|
list[id]=0;
|
|
return tmp;
|
|
}
|
|
}
|
|
|
|
void fe_renderlist_clear(void)
|
|
{
|
|
free(list);
|
|
list_size=0;
|
|
return;
|
|
}
|
|
|
|
void fe_render(void)
|
|
{
|
|
for (int i=0; i<list_size; i++)
|
|
if (list[i])
|
|
fe_object_display(list[i]);
|
|
} |