mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 04:21:50 +00:00
Refactor mesh handling to use templated vertex structures for improved type safety and flexibility
This commit is contained in:
parent
bba647db5c
commit
1ffbeb8148
28 changed files with 591 additions and 521 deletions
|
|
@ -1,19 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stdlib.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "commons.hpp"
|
||||
#include "maths/UVRegion.hpp"
|
||||
#include "MeshData.hpp"
|
||||
|
||||
template<typename VertexStructure>
|
||||
class Mesh;
|
||||
class Texture;
|
||||
|
||||
struct Batch2DVertex {
|
||||
glm::vec2 position;
|
||||
glm::vec2 uv;
|
||||
glm::vec4 color;
|
||||
|
||||
static constexpr VertexAttribute ATTRIBUTES[] {
|
||||
{GL_FLOAT, false, 2},
|
||||
{GL_FLOAT, false,2},
|
||||
{GL_FLOAT, false, 4},
|
||||
{0}
|
||||
};
|
||||
};
|
||||
|
||||
class Batch2D : public Flushable {
|
||||
std::unique_ptr<float[]> buffer;
|
||||
std::unique_ptr<Batch2DVertex[]> buffer;
|
||||
size_t capacity;
|
||||
std::unique_ptr<Mesh> mesh;
|
||||
std::unique_ptr<Mesh<Batch2DVertex>> mesh;
|
||||
std::unique_ptr<Texture> blank;
|
||||
size_t index;
|
||||
glm::vec4 color;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue