diff options
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; } |