add save and bundle pxl8 with game for standalone game distribution
This commit is contained in:
parent
b1e8525c3e
commit
04d3af11a9
25 changed files with 1173 additions and 346 deletions
|
|
@ -141,14 +141,14 @@ static void pxl8_skyline_compact(pxl8_skyline* skyline) {
|
|||
}
|
||||
}
|
||||
|
||||
pxl8_atlas* pxl8_atlas_create(u32 width, u32 height, pxl8_color_mode color_mode) {
|
||||
pxl8_atlas* pxl8_atlas_create(u32 width, u32 height, pxl8_pixel_mode pixel_mode) {
|
||||
pxl8_atlas* atlas = (pxl8_atlas*)calloc(1, sizeof(pxl8_atlas));
|
||||
if (!atlas) return NULL;
|
||||
|
||||
atlas->height = height;
|
||||
atlas->width = width;
|
||||
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(color_mode);
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(pixel_mode);
|
||||
atlas->pixels = (u8*)calloc(width * height, bytes_per_pixel);
|
||||
if (!atlas->pixels) {
|
||||
free(atlas);
|
||||
|
|
@ -199,10 +199,10 @@ void pxl8_atlas_destroy(pxl8_atlas* atlas) {
|
|||
free(atlas);
|
||||
}
|
||||
|
||||
bool pxl8_atlas_expand(pxl8_atlas* atlas, pxl8_color_mode color_mode) {
|
||||
bool pxl8_atlas_expand(pxl8_atlas* atlas, pxl8_pixel_mode pixel_mode) {
|
||||
if (!atlas || atlas->width >= 4096) return false;
|
||||
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(color_mode);
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(pixel_mode);
|
||||
u32 new_size = atlas->width * 2;
|
||||
u32 old_width = atlas->width;
|
||||
|
||||
|
|
@ -278,14 +278,14 @@ u32 pxl8_atlas_add_texture(
|
|||
const u8* pixels,
|
||||
u32 w,
|
||||
u32 h,
|
||||
pxl8_color_mode color_mode
|
||||
pxl8_pixel_mode pixel_mode
|
||||
) {
|
||||
if (!atlas || !pixels) return UINT32_MAX;
|
||||
|
||||
pxl8_skyline_fit fit =
|
||||
pxl8_skyline_find_position(&atlas->skyline, atlas->width, atlas->height, w, h);
|
||||
if (!fit.found) {
|
||||
if (!pxl8_atlas_expand(atlas, color_mode)) {
|
||||
if (!pxl8_atlas_expand(atlas, pixel_mode)) {
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ u32 pxl8_atlas_add_texture(
|
|||
entry->w = w;
|
||||
entry->h = h;
|
||||
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(color_mode);
|
||||
i32 bytes_per_pixel = pxl8_bytes_per_pixel(pixel_mode);
|
||||
for (u32 y = 0; y < h; y++) {
|
||||
for (u32 x = 0; x < w; x++) {
|
||||
u32 src_idx = y * w + x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue