refactor SDL out of core files
This commit is contained in:
parent
82ed6b4ea9
commit
9d183341ae
21 changed files with 1419 additions and 1028 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pxl8_vfx.h"
|
||||
|
||||
|
|
@ -82,10 +81,10 @@ void pxl8_vfx_rotozoom(pxl8_gfx* gfx, f32 angle, f32 zoom, i32 cx, i32 cy) {
|
|||
f32 cos_a = cosf(angle);
|
||||
f32 sin_a = sinf(angle);
|
||||
|
||||
u8* temp_buffer = (u8*)SDL_malloc(pxl8_gfx_get_width(gfx) * pxl8_gfx_get_height(gfx));
|
||||
u8* temp_buffer = (u8*)malloc(pxl8_gfx_get_width(gfx) * pxl8_gfx_get_height(gfx));
|
||||
if (!temp_buffer) return;
|
||||
|
||||
SDL_memcpy(temp_buffer, pxl8_gfx_get_framebuffer(gfx), pxl8_gfx_get_width(gfx) * pxl8_gfx_get_height(gfx));
|
||||
memcpy(temp_buffer, pxl8_gfx_get_framebuffer(gfx), pxl8_gfx_get_width(gfx) * pxl8_gfx_get_height(gfx));
|
||||
|
||||
for (i32 y = 0; y < pxl8_gfx_get_height(gfx); y++) {
|
||||
for (i32 x = 0; x < pxl8_gfx_get_width(gfx); x++) {
|
||||
|
|
@ -104,7 +103,7 @@ void pxl8_vfx_rotozoom(pxl8_gfx* gfx, f32 angle, f32 zoom, i32 cx, i32 cy) {
|
|||
}
|
||||
}
|
||||
|
||||
SDL_free(temp_buffer);
|
||||
free(temp_buffer);
|
||||
}
|
||||
|
||||
void pxl8_vfx_tunnel(pxl8_gfx* gfx, f32 time, f32 speed, f32 twist) {
|
||||
|
|
@ -145,7 +144,7 @@ void pxl8_vfx_water_ripple(pxl8_gfx* gfx, f32* height_map, i32 drop_x, i32 drop_
|
|||
|
||||
static f32* prev_height = NULL;
|
||||
if (!prev_height) {
|
||||
prev_height = (f32*)SDL_calloc(w * h, sizeof(f32));
|
||||
prev_height = (f32*)calloc(w * h, sizeof(f32));
|
||||
if (!prev_height) return;
|
||||
}
|
||||
|
||||
|
|
@ -169,12 +168,12 @@ void pxl8_vfx_water_ripple(pxl8_gfx* gfx, f32* height_map, i32 drop_x, i32 drop_
|
|||
}
|
||||
|
||||
pxl8_particles* pxl8_particles_create(u32 max_count) {
|
||||
pxl8_particles* particles = SDL_calloc(1, sizeof(pxl8_particles));
|
||||
pxl8_particles* particles = calloc(1, sizeof(pxl8_particles));
|
||||
if (!particles) return NULL;
|
||||
|
||||
particles->particles = SDL_calloc(max_count, sizeof(pxl8_particle));
|
||||
particles->particles = calloc(max_count, sizeof(pxl8_particle));
|
||||
if (!particles->particles) {
|
||||
SDL_free(particles);
|
||||
free(particles);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -188,8 +187,8 @@ pxl8_particles* pxl8_particles_create(u32 max_count) {
|
|||
|
||||
void pxl8_particles_destroy(pxl8_particles* particles) {
|
||||
if (!particles) return;
|
||||
SDL_free(particles->particles);
|
||||
SDL_free(particles);
|
||||
free(particles->particles);
|
||||
free(particles);
|
||||
}
|
||||
|
||||
void pxl8_particles_clear(pxl8_particles* particles) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue