refactor a bit into pxl8 sys struct
This commit is contained in:
parent
b2682a2d40
commit
f19b06d705
10 changed files with 217 additions and 148 deletions
|
|
@ -135,11 +135,9 @@ u32 pxl8_gfx_get_palette_size(const pxl8_gfx* gfx) {
|
|||
|
||||
pxl8_gfx* pxl8_gfx_create(
|
||||
const pxl8_hal* hal,
|
||||
void* platform_data,
|
||||
pxl8_color_mode mode,
|
||||
pxl8_resolution resolution,
|
||||
const char* title,
|
||||
i32 window_width,
|
||||
i32 window_height
|
||||
pxl8_resolution resolution
|
||||
) {
|
||||
pxl8_gfx* gfx = (pxl8_gfx*)calloc(1, sizeof(pxl8_gfx));
|
||||
if (!gfx) {
|
||||
|
|
@ -148,6 +146,7 @@ pxl8_gfx* pxl8_gfx_create(
|
|||
}
|
||||
|
||||
gfx->hal = hal;
|
||||
gfx->platform_data = platform_data;
|
||||
|
||||
gfx->color_mode = mode;
|
||||
pxl8_gfx_get_resolution_dimensions(
|
||||
|
|
@ -156,9 +155,8 @@ pxl8_gfx* pxl8_gfx_create(
|
|||
&gfx->framebuffer_height
|
||||
);
|
||||
|
||||
gfx->platform_data = gfx->hal->create(mode, resolution, title, window_width, window_height);
|
||||
if (!gfx->platform_data) {
|
||||
pxl8_error("Failed to create platform context");
|
||||
pxl8_error("Platform data cannot be NULL");
|
||||
free(gfx);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -213,11 +211,6 @@ void pxl8_gfx_destroy(pxl8_gfx* gfx) {
|
|||
|
||||
pxl8_atlas_destroy(gfx->atlas);
|
||||
free(gfx->sprite_cache);
|
||||
|
||||
if (gfx->hal && gfx->platform_data) {
|
||||
gfx->hal->destroy(gfx->platform_data);
|
||||
}
|
||||
|
||||
free(gfx->framebuffer);
|
||||
free(gfx->palette);
|
||||
free(gfx->zbuffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue