From 737b790869bd6c309cd4fd2ef4dd5077337841c0 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 20 Apr 2023 12:41:34 -0700 Subject: [PATCH] Fixed some text rendering issues --- src/pc/djui/djui_gfx.c | 9 +++++---- src/pc/djui/djui_inputbox.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 26a185f3..80b41331 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -104,10 +104,11 @@ void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize) { void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH) { Vtx *vtx = alloc_display_list(sizeof(Vtx) * 4); f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; - vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 512) / w, ((tileY + tileH) * 512) / h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 512) / w, ((tileY + tileH) * 512) / h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 512) / w, ( tileY * 512) / h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 512) / w, ( tileY * 512) / h }, { 0xff, 0xff, 0xff, 0xff }}}; + // 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 * 512) / w + 1, ((tileY + tileH) * 512) / h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 512) / w + 1, ((tileY + tileH) * 512) / h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 512) / w + 1, ( tileY * 512) / h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 512) / w + 1, ( tileY * 512) / h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index 662f8464..7843e714 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -369,9 +369,9 @@ static void djui_inputbox_render_char(struct DjuiInputbox* inputbox, char* c, f3 struct DjuiBaseRect* comp = &inputbox->base.comp; const struct DjuiFont* font = gDjuiFonts[0]; f32 dX = comp->x + *drawX; - f32 dY = comp->y + DJUI_INPUTBOX_YOFF; + f32 dY = comp->y; f32 dW = font->charWidth * font->defaultFontScale; - f32 dH = font->charHeight * font->defaultFontScale; + f32 dH = font->charHeight * font->defaultFontScale - inputbox->base.borderWidth.value * 2; char* dc = inputbox->passwordChar[0] ? inputbox->passwordChar : c;