From 8af961c6d3fa4ee9dcb64efee2964a0de4a60939 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 29 Mar 2026 18:53:42 -0500 Subject: [PATCH] Fixed knulli rendering --- src/dusk/display/display.c | 22 +--------------------- src/duskgl/display/shader/shaderunlitgl.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/dusk/display/display.c b/src/dusk/display/display.c index 43b451c..b8ad73b 100644 --- a/src/dusk/display/display.c +++ b/src/dusk/display/display.c @@ -68,7 +68,6 @@ errorret_t displayInit(void) { errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat)); errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, NULL)); - errorChain(meshInit(&mesh, MESH_PRIMITIVE_TYPE_TRIANGLES, 3, vertices)); errorOk(); @@ -90,26 +89,7 @@ errorret_t displayUpdate(void) { SCREEN.background ); - camera_t cam; - cameraInitOrthographic(&cam); - cam.orthographic.right = SCREEN.width; - cam.orthographic.top = SCREEN.height; - cam.orthographic.left = 0; - cam.orthographic.bottom = 0; - - mat4 mat; - cameraGetProjectionMatrix(&cam, mat); - errorChain(shaderBind(&SHADER_UNLIT)); - errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, mat)); - cameraGetViewMatrix(&cam, mat); - errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, mat)); - glm_mat4_identity(mat); - errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat)); - - textDraw(32, 32, "Hello World", COLOR_WHITE, &DEFAULT_FONT_TILESET, &DEFAULT_FONT_TEXTURE); - spriteBatchFlush(); - - // errorChain(sceneRender()); + errorChain(sceneRender()); // Render UI // uiRender(); diff --git a/src/duskgl/display/shader/shaderunlitgl.c b/src/duskgl/display/shader/shaderunlitgl.c index a400862..95cbbf2 100644 --- a/src/duskgl/display/shader/shaderunlitgl.c +++ b/src/duskgl/display/shader/shaderunlitgl.c @@ -122,7 +122,7 @@ // Uniforms "uniform sampler2D u_Texture;\n" "uniform int u_TextureType;\n" - "uniform vec4 u_Colors[256];\n"// For paletted textures. + "uniform uint u_Colors[256];\n"// For paletted textures. "uniform int u_ColorCount;\n" // Fragment shader inputs "in vec4 v_Color;\n" @@ -140,8 +140,13 @@ " }\n" " if(u_TextureType == 2) {\n"// Paletted texture " vec4 texColor = texture(u_Texture, v_TexCoord);\n" - " int index = int(floor(texColor.r * 255.0));\n" - " vec4 paletteColor = u_Colors[index];\n" + " uint index = uint(floor(texColor.r * 255.0));\n" + " uint palColor = u_Colors[index];\n" + " float r = float((palColor >> 24) & 0xFFu) / 255.0;\n" + " float g = float((palColor >> 16) & 0xFFu) / 255.0;\n" + " float b = float((palColor >> 8) & 0xFFu) / 255.0;\n" + " float a = float((palColor >> 0) & 0xFFu) / 255.0;\n" + " vec4 paletteColor = vec4(r, g, b, a);\n" " FragColor = paletteColor;\n" " return;\n" " }\n"