Skip to content

feat(models): add opt-in u32 mesh index support - #6105

Closed
jvkabum wants to merge 2 commits into
raysan5:masterfrom
jvkabum:feat/mesh-u32-indices
Closed

feat(models): add opt-in u32 mesh index support#6105
jvkabum wants to merge 2 commits into
raysan5:masterfrom
jvkabum:feat/mesh-u32-indices

Conversation

@jvkabum

@jvkabum jvkabum commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Adds opt-in 32-bit mesh index support while preserving the existing 16-bit index path and API behavior.

Mesh.indices remains unsigned short * for backward compatibility. Meshes that require indices above 65535 can use the new indices32 field together with MESH_INDEX_UINT32.

Changes

  • Added MeshIndexType with MESH_INDEX_UINT16 and MESH_INDEX_UINT32.
  • Added Mesh.indices32 and Mesh.indexType.
  • Appended the new Mesh fields to preserve the offsets of existing public fields.
  • Updated mesh upload and draw paths to select the correct OpenGL index type:
    • GL_UNSIGNED_SHORT for u16
    • GL_UNSIGNED_INT for u32
  • Updated indexed and instanced drawing paths.
  • Updated mesh cleanup, validation, export, and collision-related index access.
  • Updated the glTF loader to preserve UNSIGNED_INT index accessors instead of narrowing them to u16.
  • Added a regression example containing an index value of 65536.

Compatibility

Existing applications and models using Mesh.indices continue to use 16-bit indices unchanged.

The new format is opt-in:

mesh.indices32 = indices;
mesh.indexType = MESH_INDEX_UINT32;

## Summary

Adds opt-in 32-bit mesh index support while preserving the existing 16-bit index path and API behavior.

`Mesh.indices` remains `unsigned short *` for backward compatibility. Meshes that require indices above `65535` can use the new `indices32` field together with `MESH_INDEX_UINT32`.

## Changes

- Added `MeshIndexType` with `MESH_INDEX_UINT16` and `MESH_INDEX_UINT32`.
- Added `Mesh.indices32` and `Mesh.indexType`.
- Appended the new `Mesh` fields to preserve the offsets of existing public fields.
- Updated mesh upload and draw paths to select the correct OpenGL index type:
  - `GL_UNSIGNED_SHORT` for `u16`
  - `GL_UNSIGNED_INT` for `u32`
- Updated indexed and instanced drawing paths.
- Updated mesh cleanup, validation, export, and collision-related index access.
- Updated the glTF loader to preserve `UNSIGNED_INT` index accessors instead of narrowing them to `u16`.
- Added a regression example containing an index value of `65536`.

## Compatibility

Existing applications and models using `Mesh.indices` continue to use 16-bit indices unchanged.

The new format is opt-in:

```c
mesh.indices32 = indices;
mesh.indexType = MESH_INDEX_UINT32;
@raysan5

raysan5 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

@jvkabum thanks but I prefer to avoid two paths to maintain

@raysan5 raysan5 closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants