From fd82486431e64384b249bc146becdace59718d5a Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 13 Apr 2026 12:37:54 -0500 Subject: [PATCH] Fix dolphin color-less --- src/duskdolphin/display/displaydolphin.c | 8 ++++++-- src/duskdolphin/display/mesh/meshdolphin.c | 22 +++++++++++++++++----- src/duskgl/display/shader/shadergl.c | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/duskdolphin/display/displaydolphin.c b/src/duskdolphin/display/displaydolphin.c index 30f976fb..8a407764 100644 --- a/src/duskdolphin/display/displaydolphin.c +++ b/src/duskdolphin/display/displaydolphin.c @@ -85,10 +85,14 @@ errorret_t displayInitDolphin(void) { // Describe mesh vertex format. GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_INDEX16); - GX_SetVtxDesc(GX_VA_CLR0, GX_INDEX16); + #if MESH_ENABLE_COLOR + GX_SetVtxDesc(GX_VA_CLR0, GX_INDEX16); + #endif GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + #if MESH_ENABLE_COLOR + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + #endif GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); errorOk(); diff --git a/src/duskdolphin/display/mesh/meshdolphin.c b/src/duskdolphin/display/mesh/meshdolphin.c index 6c43ad88..99455be6 100644 --- a/src/duskdolphin/display/mesh/meshdolphin.c +++ b/src/duskdolphin/display/mesh/meshdolphin.c @@ -43,9 +43,14 @@ errorret_t meshDrawDolphin( // Matches vertex format described in displaydolphin.c assertTrue(sizeof(color_t) == 4, "color_t must be exactly 4 bytes"); - assertTrue(offsetof(meshvertex_t, color) == 0, "color offset wrong"); - assertTrue(offsetof(meshvertex_t, uv) == 4, "uv offset wrong"); - assertTrue(offsetof(meshvertex_t, pos) == 12, "pos offset wrong"); + #if MESH_ENABLE_COLOR + assertTrue(offsetof(meshvertex_t, color) == 0, "color offset wrong"); + assertTrue(offsetof(meshvertex_t, uv) == 4, "uv offset wrong"); + assertTrue(offsetof(meshvertex_t, pos) == 12, "pos offset wrong"); + #else + assertTrue(offsetof(meshvertex_t, uv) == 0, "uv offset wrong"); + assertTrue(offsetof(meshvertex_t, pos) == 8, "pos offset wrong"); + #endif DCFlushRange( (void*)&mesh->vertices[vertexOffset], @@ -57,7 +62,12 @@ errorret_t meshDrawDolphin( const uint8_t stride = (uint8_t)sizeof(meshvertex_t); GX_SetArray(GX_VA_POS, (void*)&mesh->vertices[vertexOffset].pos[0], stride); - GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride); + #if MESH_ENABLE_COLOR + GX_SetArray( + GX_VA_CLR0, + (void*)&mesh->vertices[vertexOffset].color.r, stride + ); + #endif GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride); GX_InvVtxCache(); @@ -65,7 +75,9 @@ errorret_t meshDrawDolphin( GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount); for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) { GX_Position1x16(i); - GX_Color1x16(i); + #if MESH_ENABLE_COLOR + GX_Color1x16(i); + #endif GX_TexCoord1x16(i); } GX_End(); diff --git a/src/duskgl/display/shader/shadergl.c b/src/duskgl/display/shader/shadergl.c index 54d560a0..d3ada530 100644 --- a/src/duskgl/display/shader/shadergl.c +++ b/src/duskgl/display/shader/shadergl.c @@ -311,6 +311,7 @@ errorret_t shaderSetColorGL( // errorChain(errorGLCheck()); // glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); // errorChain(errorGLCheck()); + #else GLint location; errorChain(shaderParamGetLocationGL(shader, name, &location));