improve sw renderer

This commit is contained in:
asrael 2026-01-21 23:19:50 -06:00
parent 415d424057
commit 39ee0fefb7
89 changed files with 9380 additions and 2307 deletions

View file

@ -1,3 +1,4 @@
#include "pxl8_mem.h"
#include "pxl8_mesh.h"
#include <stdlib.h>
#include <string.h>
@ -6,16 +7,16 @@ pxl8_mesh* pxl8_mesh_create(u32 vertex_capacity, u32 index_capacity) {
if (vertex_capacity > PXL8_MESH_MAX_VERTICES) vertex_capacity = PXL8_MESH_MAX_VERTICES;
if (index_capacity > PXL8_MESH_MAX_INDICES) index_capacity = PXL8_MESH_MAX_INDICES;
pxl8_mesh* mesh = calloc(1, sizeof(pxl8_mesh));
pxl8_mesh* mesh = pxl8_calloc(1, sizeof(pxl8_mesh));
if (!mesh) return NULL;
mesh->vertices = calloc(vertex_capacity, sizeof(pxl8_vertex));
mesh->indices = calloc(index_capacity, sizeof(u16));
mesh->vertices = pxl8_calloc(vertex_capacity, sizeof(pxl8_vertex));
mesh->indices = pxl8_calloc(index_capacity, sizeof(u16));
if (!mesh->vertices || !mesh->indices) {
free(mesh->vertices);
free(mesh->indices);
free(mesh);
pxl8_free(mesh->vertices);
pxl8_free(mesh->indices);
pxl8_free(mesh);
return NULL;
}
@ -29,9 +30,9 @@ pxl8_mesh* pxl8_mesh_create(u32 vertex_capacity, u32 index_capacity) {
void pxl8_mesh_destroy(pxl8_mesh* mesh) {
if (!mesh) return;
free(mesh->vertices);
free(mesh->indices);
free(mesh);
pxl8_free(mesh->vertices);
pxl8_free(mesh->indices);
pxl8_free(mesh);
}
void pxl8_mesh_clear(pxl8_mesh* mesh) {