diff options
author | quou <quou@disroot.org> | 2024-12-29 18:39:09 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-29 18:39:51 +1100 |
commit | 4123d42aee69537f6fcede748a5d7b88277ef4af (patch) | |
tree | 2873af4aed3aba320ddb127b8dd2653f577bd57c /ui.cpp | |
parent | ee50c66126d56d4b456046ed533f90abb0075363 (diff) |
functions to destroy objects immediately
Diffstat (limited to 'ui.cpp')
-rw-r--r-- | ui.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -77,10 +77,13 @@ static unsigned font_data[] = { static Texture_Id create_atlas(Device* d, Arena* a) { int x, y; int size = 10 * font_w; - uint8_t* pixels = (uint8_t*)arena_alloc(a, size); - void* bufmem; - Buffer_Id buf; + Buffer_Id buf = d->create_buffer( + size, + Buffer_Flags::copy_src | + Buffer_Flags::cpu_readwrite + ); Texture_Id tex; + uint8_t* pixels = (uint8_t*)d->map_buffer(buf, 0, size); for (y = 0; y < 10; y++) { for (x = 0; x < font_w; x++) { int si = x + y * font_w; @@ -89,13 +92,6 @@ static Texture_Id create_atlas(Device* d, Arena* a) { pixels[si] = bit? 0xff: 0x00; } } - buf = d->create_buffer( - size, - Buffer_Flags::copy_src | - Buffer_Flags::cpu_readwrite - ); - bufmem = d->map_buffer(buf, 0, size); - memcpy(bufmem, pixels, size); d->unmap_buffer(buf); tex = d->create_texture( texture_format_r8i, @@ -104,7 +100,7 @@ static Texture_Id create_atlas(Device* d, Arena* a) { 10, buf ); - d->destroy_buffer(buf); + d->destroy_bufferi(buf); clear_arena(a); return tex; } |