Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
graphite/engine/renderer/include/drawlist.hpp
2024-01-03 16:05:02 -05:00

74 lines
No EOL
1.3 KiB
C++

#pragma once
#include <vector>
#include <string>
#include <functional>
#include <map>
#include <glm/glm.hpp>
#include <mesh.hpp>
#include <material.hpp>
struct DrawCommand
{
~DrawCommand()
{
geometryData.clear();
indices.clear();
vertices.clear();
models.clear();
}
struct Data
{
int vertexCount;
int instanceCount;
int firstVertex;
int baseVertex;
int baseInstance;
};
std::vector<Data> geometryData;
std::vector<unsigned int> indices;
std::vector<Vertex> vertices;
std::vector<glm::mat4> models;
};
struct StaticGeometry
{
std::map<Material*, DrawCommand> drawCommands;
};
//reserved for future use
struct InstancedGeometry {};
struct DynamicGeometry
{
std::string name;
Mesh* mesh;
Material* material;
glm::mat4 model;
};
class DrawList
{
public:
void RebuildDynamicLists();
void RebuildStaticLists();
static void InvalidateNextFrame();
StaticGeometry GetStaticGeometry();
std::vector<InstancedGeometry> GetInstancedGeometry();
std::vector<DynamicGeometry*> GetDynamicGeometry();
static std::function<void()> onStaticGeometryUpdate;
private:
std::vector<DynamicGeometry*> m_dynamicGeometry;
StaticGeometry m_staticGeometry;
static bool m_frameInvalidated;
};