diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 22:25:43 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 22:25:43 +0100 |
| commit | 64b0664a648ec4a6c424e932b605f09dc4ee6151 (patch) | |
| tree | d690116c192dd5d29567e849935645cecc6753b8 /src | |
| parent | 673211e7d3d4f1921a3323bdc2818caf4e73a696 (diff) | |
check bounds
Diffstat (limited to 'src')
| -rw-r--r-- | src/rendering.cc | 7 | ||||
| -rw-r--r-- | src/rendering.h | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/rendering.cc b/src/rendering.cc index a34e01c..89a64ac 100644 --- a/src/rendering.cc +++ b/src/rendering.cc @@ -107,13 +107,18 @@ 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, +bool wayc_atlas_set(atlas_s* atlas, image_data_type_e data_type, ivec2 offset, u32 width, u32 height, i32 alignment, const u8* data) { wayc_notnull(atlas); wayc_notnull(data); + u32 final_x = offset[0] + width; + u32 final_y = offset[1] + height; + if (final_x > atlas->width || final_y > atlas->height) return false; + wayc_image_upload(atlas->texture, offset, width, height, IMAGE_TYPE_2D, atlas->format, data_type, alignment, data); + return true; } void wayc_atlas_deinit(atlas_s* atlas) { diff --git a/src/rendering.h b/src/rendering.h index 7e5e46e..98f70ce 100644 --- a/src/rendering.h +++ b/src/rendering.h @@ -64,6 +64,6 @@ struct atlas_s { bool wayc_atlas_init(atlas_s* atlas, image_format_e format, u32 width, u32 height); void wayc_atlas_use(atlas_s* atlas, u32 slot); -void wayc_atlas_set(atlas_s* atlas, image_data_type_e data_type, ivec2 offset, +bool wayc_atlas_set(atlas_s* atlas, image_data_type_e data_type, ivec2 offset, u32 width, u32 height, i32 alignment, const u8* data); void wayc_atlas_deinit(atlas_s* atlas); |
