Renders on Dolphin also.

This commit is contained in:
2026-03-10 15:07:50 -05:00
parent c5f5b025a6
commit 9a98348582
8 changed files with 114 additions and 75 deletions

View File

@@ -8,6 +8,7 @@
#include "display/mesh/mesh.h"
#include "display/texture/texture.h"
#include "assert/assert.h"
#include "debug/debug.h"
errorret_t meshInitDolphin(
meshdolphin_t *mesh,
@@ -38,22 +39,28 @@ errorret_t meshDrawDolphin(
vertexOffset + vertexCount <= mesh->vertexCount,
"Requested vertex range is invalid"
);
assertTrue(vertexCount <= UINT16_MAX, "Vertex count exceeds GX limit");
// 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");
textureDolphinUploadTEV();
// Prepare Vertex descriptor
DCFlushRange(
(void*)&mesh->vertices[vertexOffset],
sizeof(meshvertex_t) * vertexCount
);
const u8 stride = (u8)sizeof(meshvertex_t);
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, stride);
GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride);
GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride);
textureDolphinUploadTEV();
GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount);
for(u16 i = 0; i < (u16)vertexCount; ++i) {
for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) {
GX_Position1x16(i);
GX_Color1x16(i);
GX_TexCoord1x16(i);