From 8dd6adc5543de65f70b87dad0191e5e8ca82e6ec Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 19 Dec 2023 23:06:14 -0600 Subject: [PATCH] [nostalgia/core] Specify a maximum for priority level --- src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp | 3 +++ src/nostalgia/modules/core/src/opengl/gfx.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp index 5f246dd1..d47763cd 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp @@ -23,6 +23,9 @@ struct Sprite { unsigned spriteShape = 0; unsigned spriteSize = 0; unsigned flipX = 0; + /** + * Valid priorities: 0-3 + */ unsigned priority = 0; }; diff --git a/src/nostalgia/modules/core/src/opengl/gfx.cpp b/src/nostalgia/modules/core/src/opengl/gfx.cpp index 30b20b44..5931c02c 100644 --- a/src/nostalgia/modules/core/src/opengl/gfx.cpp +++ b/src/nostalgia/modules/core/src/opengl/gfx.cpp @@ -113,7 +113,7 @@ static void setSpriteBufferObject( y *= -ymod; x -= 1.f; y += 1.f - ymod; - auto const prif = static_cast(priority) * 0.1f; + auto const prif = static_cast(priority) * 0.01f; auto const textureRowf = static_cast(textureRow); float const L = flipX ? 1 : 0; float const R = flipX ? 0 : 1; @@ -416,7 +416,7 @@ static void setSprite( fY, s.tileIdx + i, s.flipX, - s.priority, + s.priority & 0b11, vbo, ebo); ++i;