59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
#include "pxl8_glows.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
struct pxl8_glows {
|
|
pxl8_glow_source* data;
|
|
u32 capacity;
|
|
u32 count;
|
|
};
|
|
|
|
pxl8_glows* pxl8_glows_create(u32 capacity) {
|
|
pxl8_glows* glows = calloc(1, sizeof(pxl8_glows));
|
|
if (!glows) return NULL;
|
|
|
|
glows->data = calloc(capacity, sizeof(pxl8_glow_source));
|
|
if (!glows->data) {
|
|
free(glows);
|
|
return NULL;
|
|
}
|
|
|
|
glows->capacity = capacity;
|
|
glows->count = 0;
|
|
|
|
return glows;
|
|
}
|
|
|
|
void pxl8_glows_destroy(pxl8_glows* glows) {
|
|
if (!glows) return;
|
|
free(glows->data);
|
|
free(glows);
|
|
}
|
|
|
|
void pxl8_glows_add(pxl8_glows* glows, i16 x, i16 y, u8 radius, u16 intensity, u8 color, u8 shape) {
|
|
if (!glows || glows->count >= glows->capacity) return;
|
|
|
|
pxl8_glow_source* g = &glows->data[glows->count++];
|
|
g->x = x;
|
|
g->y = y;
|
|
g->radius = radius;
|
|
g->intensity = intensity;
|
|
g->color = color;
|
|
g->shape = shape;
|
|
g->depth = 0xFFFF;
|
|
g->height = 0;
|
|
}
|
|
|
|
void pxl8_glows_clear(pxl8_glows* glows) {
|
|
if (!glows) return;
|
|
glows->count = 0;
|
|
}
|
|
|
|
u32 pxl8_glows_count(const pxl8_glows* glows) {
|
|
return glows ? glows->count : 0;
|
|
}
|
|
|
|
void pxl8_glows_render(pxl8_glows* glows, pxl8_gfx* gfx) {
|
|
if (!glows || !gfx || glows->count == 0) return;
|
|
pxl8_gfx_apply_effect(gfx, PXL8_GFX_EFFECT_GLOWS, glows->data, glows->count);
|
|
}
|