renamed ATlAS_RGBA32 to ATLAS_R8G8B8A8

This commit is contained in:
Alessandro Mauri 2025-02-06 23:51:15 +01:00
parent e09107af98
commit 52f3929a42
3 changed files with 7 additions and 6 deletions

View File

@ -130,7 +130,7 @@ fn int main(String[] args)
defer ui.free(); defer ui.free();
ui.load_font("font1", "resources/hack-nerd.ttf", 16)!!; ui.load_font("font1", "resources/hack-nerd.ttf", 16)!!;
ui.sprite_atlas_create("icons", AtlasType.ATLAS_RGBA32, 512, 512)!!; ui.sprite_atlas_create("icons", AtlasType.ATLAS_R8G8B8A8, 512, 512)!!;
ui.import_sprite_file_qoi("tux", "resources/tux.qoi")!!; ui.import_sprite_file_qoi("tux", "resources/tux.qoi")!!;
ui.import_sprite_file_qoi("tick", "resources/tick_sdf.qoi", SpriteType.SPRITE_MSDF)!!; ui.import_sprite_file_qoi("tick", "resources/tick_sdf.qoi", SpriteType.SPRITE_MSDF)!!;

View File

@ -9,7 +9,7 @@ fault UgAtlasError {
enum AtlasType { enum AtlasType {
ATLAS_GRAYSCALE, ATLAS_GRAYSCALE,
ATLAS_RGBA32, ATLAS_R8G8B8A8,
} }
// black and white atlas // black and white atlas
@ -29,7 +29,7 @@ macro usz AtlasType.bpp(type)
{ {
switch (type) { switch (type) {
case ATLAS_GRAYSCALE: return 1; case ATLAS_GRAYSCALE: return 1;
case ATLAS_RGBA32: return 4; case ATLAS_R8G8B8A8: return 4;
} }
} }

View File

@ -36,13 +36,13 @@ struct ElemSprite {
// name: some examples are "icons" or "images" // name: some examples are "icons" or "images"
fn void! SpriteAtlas.init(&this, String name, AtlasType type, ushort width, ushort height) fn void! SpriteAtlas.init(&this, String name, AtlasType type, ushort width, ushort height)
{ {
// FIXME: for now only RGBA32 format is supported // FIXME: for now only R8G8B8A8 format is supported
if (type != ATLAS_RGBA32) { if (type != ATLAS_R8G8B8A8) {
return UgAtlasError.INVALID_TYPE?; return UgAtlasError.INVALID_TYPE?;
} }
this.id = name.hash(); this.id = name.hash();
this.atlas.new(this.id, AtlasType.ATLAS_RGBA32, width, height)!; this.atlas.new(this.id, AtlasType.ATLAS_R8G8B8A8, width, height)!;
this.sprites.new_init(capacity: SRITES_PER_ATLAS); this.sprites.new_init(capacity: SRITES_PER_ATLAS);
this.should_update = false; this.should_update = false;
} }
@ -54,6 +54,7 @@ fn void! SpriteAtlas.free(&this)
} }
// FIXME: this should throw an error when a different pixel format than the atlas' is used // FIXME: this should throw an error when a different pixel format than the atlas' is used
// or convert from the source's pixel format to the atlas'
fn Sprite*! SpriteAtlas.insert(&this, String name, SpriteType type, char[] pixels, ushort w, ushort h, ushort stride) fn Sprite*! SpriteAtlas.insert(&this, String name, SpriteType type, char[] pixels, ushort w, ushort h, ushort stride)
{ {
Sprite s; Sprite s;