diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 22:03:38 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-11 22:03:38 +0100 |
| commit | f1e9a3fa502843f0f3092e4bbb016c14eec43fcc (patch) | |
| tree | b96e84f9717d185a4e03b829c5bb173d6d432eb7 /src | |
| parent | 616d099498ec573ec32ec1eb91ddc076c7622d31 (diff) | |
add ability to choose custom alignment
Diffstat (limited to 'src')
| -rw-r--r-- | src/rendering.cc | 9 | ||||
| -rw-r--r-- | src/rendering.h | 10 | ||||
| -rw-r--r-- | src/text.cc | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/rendering.cc b/src/rendering.cc index 3870cf6..a34e01c 100644 --- a/src/rendering.cc +++ b/src/rendering.cc @@ -27,9 +27,12 @@ bool wayc_image_init(texture_t* texture, image_type_e type, bool wayc_image_upload(texture_t texture, ivec2 offset, u32 width, u32 height, image_type_e type, image_format_e format, - image_data_type_e data_type, const u8* data) { + image_data_type_e data_type, i32 alignment, + const u8* data) { wayc_notnull(data); + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + switch (type) { case IMAGE_TYPE_2D: // TODO: add error checking @@ -105,12 +108,12 @@ void wayc_atlas_use(atlas_s* atlas, u32 slot) { } void wayc_atlas_set(atlas_s* atlas, image_data_type_e data_type, ivec2 offset, - u32 width, u32 height, const u8* data) { + u32 width, u32 height, i32 alignment, const u8* data) { wayc_notnull(atlas); wayc_notnull(data); wayc_image_upload(atlas->texture, offset, width, height, IMAGE_TYPE_2D, - atlas->format, data_type, data); + atlas->format, data_type, alignment, data); } void wayc_atlas_deinit(atlas_s* atlas) { diff --git a/src/rendering.h b/src/rendering.h index 85d3d88..7e5e46e 100644 --- a/src/rendering.h +++ b/src/rendering.h @@ -19,6 +19,11 @@ enum image_data_type_e { IMAGE_DATA_TYPE_UNSIGNED_BYTE = GL_UNSIGNED_BYTE, }; +enum { + IMAGE_FORMAT_RGBA_ALIGNMENT = 4, + IMAGE_FORMAT_RED_ALIGNMENT = 1, +}; + typedef u32 texture_t; bool wayc_image_init(texture_t* texture, image_type_e type, @@ -26,7 +31,8 @@ bool wayc_image_init(texture_t* texture, image_type_e type, bool wayc_image_upload(texture_t texture, ivec2 offset, u32 width, u32 height, image_type_e type, image_format_e format, - image_data_type_e data_type, const u8* data); + image_data_type_e data_type, i32 alignment, + const u8* data); void wayc_image_use(texture_t texture, u32 slot); void wayc_image_deinit(texture_t* texture); @@ -59,5 +65,5 @@ 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, - u32 width, u32 height, const u8* data); + u32 width, u32 height, i32 alignment, const u8* data); void wayc_atlas_deinit(atlas_s* atlas); diff --git a/src/text.cc b/src/text.cc index 0a48d6c..ff9b833 100644 --- a/src/text.cc +++ b/src/text.cc @@ -100,7 +100,7 @@ enum font_error_e wayc_font_lookup(struct font_s* font, struct atlas_s* atlas, ivec2 size = {(i32)bitmap.width, (i32)bitmap.rows}; wayc_atlas_set(atlas, IMAGE_DATA_TYPE_UNSIGNED_BYTE, font->cursor, size[0], - size[1], bitmap.buffer); + size[1], IMAGE_FORMAT_RED_ALIGNMENT, bitmap.buffer); struct glyph_s glyph = {}; glm_ivec2(font->cursor, glyph.uv0); |
