diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 21:44:49 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 21:44:49 +0100 |
| commit | 952dc19e0eeec2b0ba695970ac3f5a2997e39c77 (patch) | |
| tree | 10a484496fc9c8acf9b389c9d9a78c6637d803c8 /src/rendering.cc | |
| parent | 29805da671f7dd13f9e1b25800ac6a846391d355 (diff) | |
working on atlas
Diffstat (limited to 'src/rendering.cc')
| -rw-r--r-- | src/rendering.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rendering.cc b/src/rendering.cc index 356c6b3..8044688 100644 --- a/src/rendering.cc +++ b/src/rendering.cc @@ -4,7 +4,6 @@ #include <cstring> -#include "cglm/ivec2.h" #include "utils.h" bool wayc_image_init(texture_t* texture, image_type_e type, @@ -74,15 +73,15 @@ void wayc_sampler_use(sampler_t sampler, u32 slot) { void wayc_sampler_deinit(sampler_t* sampler) { glDeleteSamplers(1, sampler); } -bool wayc_atlas_init(atlas_s* atlas, u32 width, u32 height) { +bool wayc_atlas_init(atlas_s* atlas, image_format_e format, u32 width, + u32 height) { wayc_notnull(atlas); memset(atlas, 0, sizeof(*atlas)); bool success = false; texture_t texture; - bool ok = wayc_image_init(&texture, IMAGE_TYPE_2D, IMAGE_FORMAT_RGBA, width, - height); + bool ok = wayc_image_init(&texture, IMAGE_TYPE_2D, format, width, height); if (!ok) return false; wayc_defer_cond(wayc_image_deinit(&texture);, success, true); @@ -95,7 +94,6 @@ bool wayc_atlas_init(atlas_s* atlas, u32 width, u32 height) { atlas->sampler = sampler; atlas->width = width; atlas->height = height; - glm_ivec2_zero(atlas->cursor); success = true; return true; @@ -106,6 +104,15 @@ void wayc_atlas_use(atlas_s* atlas, u32 slot) { wayc_sampler_use(atlas->sampler, slot); } +void wayc_atlas_set(atlas_s* atlas, image_data_type_e data_type, ivec2 offset, + u32 width, u32 height, const u8* data) { + wayc_notnull(atlas); + wayc_notnull(data); + + wayc_image_upload(atlas->texture, offset, width, height, IMAGE_TYPE_2D, + IMAGE_FORMAT_RGBA, data_type, data); +} + void wayc_atlas_deinit(atlas_s* atlas) { wayc_notnull(atlas); wayc_sampler_deinit(&atlas->sampler); |
