// Copyright (c) 2025 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "dusksdl2.h" #define MESH_VERTEX_COLOR_SIZE 4 #define MESH_VERTEX_UV_SIZE 2 #define MESH_VERTEX_POS_SIZE 3 typedef struct { GLubyte color[MESH_VERTEX_COLOR_SIZE]; GLfloat uv[MESH_VERTEX_UV_SIZE]; GLfloat pos[MESH_VERTEX_POS_SIZE]; } meshvertex_t; typedef struct { const meshvertex_t *vertices; int32_t vertexCount; GLenum primitiveType; } mesh_t; /** * Initializes a mesh. * * @param mesh The mesh to initialize. * @param primitiveType The OpenGL primitive type (e.g., GL_TRIANGLES). * @param vertexCount The number of vertices in the mesh. * @param vertices The vertex data for the mesh. */ void meshInit( mesh_t *mesh, const GLenum primitiveType, const int32_t vertexCount, const meshvertex_t *vertices ); /** * Draws a mesh. * * @param mesh The mesh to draw. * @param vertexOffset The offset in the vertex array to start drawing from. * @param vertexCount The number of vertices to draw. If -1, draws all vertices. */ void meshDraw( const mesh_t *mesh, const int32_t vertexOffset, const int32_t vertexCount ); /** * Disposes a mesh. * * @param mesh The mesh to dispose. */ void meshDispose(mesh_t *mesh);