From 8141d9906aecd6be9190dda283eb23db4ad99a04 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:16:40 +1000 Subject: [PATCH] test fixes for djui tile offsets [build] --- src/pc/djui/djui_gfx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 80efc5fda..6bbded3a3 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -131,13 +131,16 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, } f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; - f32 halfPxX = font && configWindow.msaa > 0 ? 1024.0f / (f32)w : 0; - f32 halfPxY = font && configWindow.msaa > 0 ? 1024.0f / (f32)h : 0; + bool msaa = configWindow.msaa > 0; + // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... - vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w - halfPxX, ((tileY + tileH) * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w - halfPxX, ((tileY + tileH) * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w - halfPxX, ( tileY * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w - halfPxX, ( tileY * 2048.0f) / (f32)h - halfPxY }, { 0xff, 0xff, 0xff, 0xff }}}; + // this should be tested carefully. it definitely fixes some stuff, but what does it break? + f32 offsetX = (font && msaa ? -1024.0f / (f32)w : 0) + 1; + f32 offsetY = (font && msaa ? -1024.0f / (f32)h : 0) + 1; + vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA);