From d34e8779adeff6e92f2583bf94a7766725acd453 Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Sun, 15 Jun 2025 14:21:24 -0400 Subject: [PATCH] Handle uint vs ulong for 3ds target --- LEGO1/tgl/d3drm/mesh.cpp | 15 ++++++++++++--- LEGO1/tgl/d3drm/meshbuilder.cpp | 6 +++++- miniwin/src/d3drm/backends/sdl3gpu/renderer.cpp | 2 +- miniwin/src/d3drm/backends/software/renderer.cpp | 2 +- miniwin/src/internal/d3drmmesh_impl.h | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/LEGO1/tgl/d3drm/mesh.cpp b/LEGO1/tgl/d3drm/mesh.cpp index 52a633a4..2fdad9d5 100644 --- a/LEGO1/tgl/d3drm/mesh.cpp +++ b/LEGO1/tgl/d3drm/mesh.cpp @@ -95,15 +95,24 @@ inline Tgl::Result MeshDeepClone(MeshImpl::MeshData* pSource, MeshImpl::MeshData // Query information from old group DWORD dataSize; +#if defined(__3DS__) + unsigned long vcount, fcount, vperface; +#else unsigned int vcount, fcount, vperface; +#endif Tgl::Result result = - ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, (long unsigned int*)&vcount, (long unsigned int*)&fcount, (long unsigned int*)&vperface, &dataSize, NULL)); + ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL)); assert(Succeeded(result)); + +#if defined(__3DS__) + unsigned long* faceBuffer = new unsigned long[dataSize]; +#else unsigned int* faceBuffer = new unsigned int[dataSize]; +#endif result = - ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, (long unsigned int*)&vcount, (long unsigned int*)&fcount, (long unsigned int*)&vperface, &dataSize, (long unsigned int*)&faceBuffer) + ResultVal(pSource->groupMesh->GetGroup(pSource->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer) ); assert(Succeeded(result)); @@ -122,7 +131,7 @@ inline Tgl::Result MeshDeepClone(MeshImpl::MeshData* pSource, MeshImpl::MeshData // Push information to new group D3DRMGROUPINDEX index; - result = ResultVal(pMesh->AddGroup(vcount, fcount, 3, (long unsigned int*)&faceBuffer, &index)); + result = ResultVal(pMesh->AddGroup(vcount, fcount, 3, faceBuffer, &index)); assert(Succeeded(result)); rpTarget->groupIndex = index; diff --git a/LEGO1/tgl/d3drm/meshbuilder.cpp b/LEGO1/tgl/d3drm/meshbuilder.cpp index 18701001..8981e556 100644 --- a/LEGO1/tgl/d3drm/meshbuilder.cpp +++ b/LEGO1/tgl/d3drm/meshbuilder.cpp @@ -63,7 +63,11 @@ inline Tgl::Result CreateMesh( int count = faceCount * 3; int index = 0; +#if defined(__3DS__) + unsigned long* fData = new unsigned long[count]; +#else unsigned int* fData = new unsigned int[count]; +#endif D3DRMVERTEX* vertices = new D3DRMVERTEX[vertexCount]; memset(vertices, 0, sizeof(*vertices) * vertexCount); @@ -97,7 +101,7 @@ inline Tgl::Result CreateMesh( } Tgl::Result result; - result = ResultVal(pD3DRM->AddGroup(vertexCount, faceCount, 3, (long unsigned int*)fData, &groupIndex)); + result = ResultVal(pD3DRM->AddGroup(vertexCount, faceCount, 3, fData, &groupIndex)); if (Succeeded(result)) { rpMesh->groupIndex = groupIndex; diff --git a/miniwin/src/d3drm/backends/sdl3gpu/renderer.cpp b/miniwin/src/d3drm/backends/sdl3gpu/renderer.cpp index 37bd0beb..2b24cc9b 100644 --- a/miniwin/src/d3drm/backends/sdl3gpu/renderer.cpp +++ b/miniwin/src/d3drm/backends/sdl3gpu/renderer.cpp @@ -517,7 +517,7 @@ SDL3MeshCache Direct3DRMSDL3GPURenderer::UploadMesh(const MeshGroup& meshGroup) FlattenSurfaces( meshGroup.vertices.data(), meshGroup.vertices.size(), - meshGroup.indices.data(), + (const DWORD*)meshGroup.indices.data(), meshGroup.indices.size(), meshGroup.texture != nullptr, finalVertices, diff --git a/miniwin/src/d3drm/backends/software/renderer.cpp b/miniwin/src/d3drm/backends/software/renderer.cpp index dd9513a5..065aea21 100644 --- a/miniwin/src/d3drm/backends/software/renderer.cpp +++ b/miniwin/src/d3drm/backends/software/renderer.cpp @@ -600,7 +600,7 @@ MeshCache UploadMesh(const MeshGroup& meshGroup) FlattenSurfaces( meshGroup.vertices.data(), meshGroup.vertices.size(), - meshGroup.indices.data(), + (const DWORD*) meshGroup.indices.data(), meshGroup.indices.size(), meshGroup.texture != nullptr, cache.vertices, diff --git a/miniwin/src/internal/d3drmmesh_impl.h b/miniwin/src/internal/d3drmmesh_impl.h index e06192e4..e9c9e747 100644 --- a/miniwin/src/internal/d3drmmesh_impl.h +++ b/miniwin/src/internal/d3drmmesh_impl.h @@ -13,7 +13,7 @@ struct MeshGroup { int vertexPerFace = 0; int version = 0; std::vector vertices; - std::vector indices; + std::vector indices; MeshGroup() = default;