Implement spritebatch properly.

This commit is contained in:
2026-03-22 09:13:42 -05:00
parent 66ebcb1608
commit ca0e9fc3b2
19 changed files with 205 additions and 142 deletions

View File

@@ -21,9 +21,10 @@ errorret_t meshInitGL(
mesh->primitiveType = primitiveType;
mesh->vertexCount = vertexCount;
mesh->vertices = vertices;
#ifdef DUSK_OPENGL_LEGACY
mesh->vertices = vertices;
// Nothing needed.
#else
// Generate Vertex Buffer Object
glGenBuffers(1, &mesh->vboId);
@@ -34,7 +35,7 @@ errorret_t meshInitGL(
GL_ARRAY_BUFFER,
vertexCount * sizeof(meshvertex_t),
vertices,
GL_STATIC_DRAW
GL_DYNAMIC_DRAW
);
errorChain(errorGLCheck());
@@ -93,6 +94,27 @@ errorret_t meshInitGL(
errorOk();
}
errorret_t meshFlushGL(
meshgl_t *mesh,
const int32_t vertOffset,
const int32_t vertCount
) {
#ifdef DUSK_OPENGL_LEGACY
// Nothing doing, we use the glClientState stuff.
#else
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId);
errorChain(errorGLCheck());
glBufferData(
GL_ARRAY_BUFFER,
vertCount * sizeof(meshvertex_t),
&mesh->vertices[vertOffset],
GL_DYNAMIC_DRAW
);
errorChain(errorGLCheck());
#endif
errorOk();
}
errorret_t meshDrawGL(
const meshgl_t *mesh,
const int32_t offset,