Fixed some camera bugs.
This commit is contained in:
83
src/display/spritebatch/spritebatch.h
Normal file
83
src/display/spritebatch/spritebatch.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "display/mesh/quad.h"
|
||||
#include "display/texture/texture.h"
|
||||
|
||||
#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 r The red color component of the sprite.
|
||||
* @param g The green color component of the sprite.
|
||||
* @param b The blue color component of the sprite.
|
||||
* @param a The alpha component of the sprite.
|
||||
* @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 uint8_t r,
|
||||
const uint8_t g,
|
||||
const uint8_t b,
|
||||
const uint8_t a,
|
||||
const float_t u0,
|
||||
const float_t v0,
|
||||
const float_t u1,
|
||||
const float_t v1
|
||||
);
|
||||
|
||||
/**
|
||||
* 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();
|
Reference in New Issue
Block a user