add first fe_renderlist function

This commit is contained in:
Milang 2019-10-30 19:49:59 +01:00
parent 3c66554835
commit 51d65485ac
1 changed files with 36 additions and 0 deletions

36
src/renderlist.c Normal file
View File

@ -0,0 +1,36 @@
#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(int));
list[0]=object;
}
else
{
list_size++;
list=realloc(list, list_size*sizeof(int));
list[list_size-1]=object;
}
}