Committing progress.

This commit is contained in:
2025-08-21 07:33:08 -05:00
parent 3a753b1299
commit c8390bdb12
7 changed files with 267 additions and 1 deletions

66
src/display/mesh/mesh.h Normal file
View File

@@ -0,0 +1,66 @@
// Copyright (c) 2025 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "display/render.h"
typedef enum {
#if DUSK_DISPLAY_SDL2
MESH_PRIMITIVE_TRIANGLES = GL_TRIANGLES,
MESH_PRIMITIVE_LINES = GL_LINES,
MESH_PRIMITIVE_POINTS = GL_POINTS,
#endif
} meshprimitivetype_t;
#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;
meshprimitivetype_t 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 meshprimitivetype_t 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);