JacksEscape/render_component.c

33 lines
801 B
C
Raw Permalink Normal View History

2024-03-30 21:25:39 +08:00
#include "render_component.h"
#include "app.h"
#include "render_bundle.h"
#include "types.h"
2024-04-22 04:50:06 +08:00
#include "util/vector.h"
2024-03-30 21:25:39 +08:00
Component_Render *render_NewComponent(Entity *super, const char *bundle_name) {
2024-03-30 21:25:39 +08:00
render_Bundle *b = render_FindBundle(bundle_name);
if (b == NULL) // Not found
return NULL;
Component_Render *r = zero_malloc(sizeof(Component_Render));
r->super = super;
2024-03-30 21:25:39 +08:00
r->bundle = b;
return r;
}
Component_Render *render_NewComponentFunc(Entity *super, render_CustomFunc func, void *data) {
2024-03-30 21:25:39 +08:00
Component_Render *r = zero_malloc(sizeof(Component_Render));
r->super = super;
2024-03-30 21:25:39 +08:00
r->custom = func;
r->custom_data = data;
return r;
}
void render_DeleteComponent(Component_Render *r) {
2024-04-22 04:50:06 +08:00
if (r->fillpoly)
vector_Destroy(r->fillpoly);
2024-03-30 21:25:39 +08:00
free(r);
}