From d154b48f99aa7cf50cb6e50b4a7668b0e8489cb5 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Tue, 18 Nov 2025 10:26:52 -0500 Subject: pke: static-ui pixel size in UV != screen --- assets/shaders/ui-base.frag | 13 +++++++------ src/static-ui.cpp | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/assets/shaders/ui-base.frag b/assets/shaders/ui-base.frag index 815e1c8..6fa0758 100644 --- a/assets/shaders/ui-base.frag +++ b/assets/shaders/ui-base.frag @@ -7,17 +7,18 @@ layout(location = 3) in vec3 in_uv; layout(location = 0) out vec4 out_color; +const float border_px = 1.f; + bool is_in_border() { - return in_uv.x <= in_px_scale.x - || in_uv.x >= 1.0-in_px_scale.x - || in_uv.y <= in_px_scale.y - || in_uv.y >= 1.0-in_px_scale.y; + return (in_uv.x <= ((in_px_scale.x*border_px))) + || (in_uv.x >= 1.0-((in_px_scale.x*border_px))) + || (in_uv.y <= (in_px_scale.y*border_px)) + || (in_uv.y >= 1.0- (in_px_scale.y*border_px)); } void main() { + out_color = in_background_color; if (is_in_border()) { out_color = in_border_color; - } else { - out_color = in_background_color; } } diff --git a/src/static-ui.cpp b/src/static-ui.cpp index e1585a9..6858905 100644 --- a/src/static-ui.cpp +++ b/src/static-ui.cpp @@ -407,10 +407,8 @@ bool pke_ui_calc_px(pk_arr_t &buffer, pk_arr_t< box->internal.px_corner.y -= t; box->internal.px_size.x += l; box->internal.px_size.y += t; - l = fmod(box->internal.px_size.x, 1.0); - t = fmod(box->internal.px_size.y, 1.0); - box->internal.px_size.x += 1.0 - l; - box->internal.px_size.y += 1.0 - t; + box->internal.px_size.x = floor(box->internal.px_size.x); + box->internal.px_size.y = floor(box->internal.px_size.y); } // type-specific changes @@ -485,8 +483,8 @@ bool pke_ui_calc_px(pk_arr_t &buffer, pk_arr_t< tmp.color_border = PKE_UI_CLR_DISABLED_BORDER; tmp.color_background = PKE_UI_CLR_DISABLED_BACKGROUND; } - tmp.px_scale.x = (1.0 / (float)Extent.width); - tmp.px_scale.y = (1.0 / (float)Extent.height); + tmp.px_scale.x = (1.f / box->internal.px_size.x); + tmp.px_scale.y = (1.f / box->internal.px_size.y); tmp.depth = (float)box->layer; tmp.texture_layer = -1; if (PK_HAS_FLAG(box->type, PKE_UI_BOX_TYPE_BUTTON_IMAGE)) { -- cgit v1.2.3