C -> CPP
Some checks failed
Build Dusk / build-linux (push) Failing after 1m47s
Build Dusk / build-psp (push) Failing after 1m40s

This commit is contained in:
2025-12-22 11:41:49 +10:00
parent a495179e5f
commit 76b5c51ab6
162 changed files with 751 additions and 740 deletions

View File

@@ -0,0 +1,97 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/mesh/quad.hpp"
#include "display/texture.hpp"
#define SPRITEBATCH_SPRITES_MAX 1
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
typedef struct {
mesh_t mesh;
int32_t spriteCount;
texture_t *currentTexture;
meshvertex_t vertices[SPRITEBATCH_VERTEX_COUNT];
} spritebatch_t;
extern spritebatch_t SPRITEBATCH;
/**
* Initializes a sprite batch.
*
* @param spriteBatch The sprite batch to initialize.
*/
void spriteBatchInit();
/**
* Pushes a sprite to the batch. This basically "queues" it to render (well
* technically it is buffering the vertices to the mesh at the moment, but
* that is likely to change when we switch to VAOs or VBOs or even Shader UBOs).
*
* Currently changing texture pointer will cause the buffer to flush but this is
* also likely to change in the future.
*
* @param texture The texture to use for the sprite.
* @param minX The minimum x coordinate of the sprite.
* @param minY The minimum y coordinate of the sprite.
* @param maxX The maximum x coordinate of the sprite.
* @param maxY The maximum y coordinate of the sprite.
* @param color The color to tint the sprite with.
* @param u0 The texture coordinate for the top-left corner of the sprite.
* @param v0 The texture coordinate for the top-left corner of the sprite.
* @param u1 The texture coordinate for the bottom-right corner of the sprite.
* @param v1 The texture coordinate for the bottom-right corner of the sprite.
*/
void spriteBatchPush(
texture_t *texture,
const float_t minX,
const float_t minY,
const float_t maxX,
const float_t maxY,
const color_t color,
const float_t u0,
const float_t v0,
const float_t u1,
const float_t v1
);
/**
* Pushes a 3D sprite to the batch. This is like spriteBatchPush but takes
* 3D coordinates instead of 2D.
*
* @param texture The texture to use for the sprite.
* @param min The minimum (x,y,z) coordinate of the sprite.
* @param max The maximum (x,y,z) coordinate of the sprite.
* @param color The color to tint the sprite with.
* @param uvMin The texture coordinate for the top-left corner of the sprite.
* @param uvMax The texture coordinate for the bottom-right corner of the sprite.
*/
void spriteBatchPush3D(
texture_t *texture,
const vec3 min,
const vec3 max,
const color_t color,
const vec2 uvMin,
const vec2 uvMax
);
/**
* Clears the sprite batch. This will mean calling flush renders nothing.
*/
void spriteBatchClear();
/**
* Flushes the sprite batch, rendering all queued sprites.
*/
void spriteBatchFlush();
/**
* Disposes of the sprite batch, freeing any allocated resources.
*/
void spriteBatchDispose();