3d renderer

This commit is contained in:
Erris
2026-03-01 17:06:15 +01:00
parent abe8016f84
commit 90a6ea00c0
21 changed files with 365 additions and 76 deletions

View File

@@ -0,0 +1,61 @@
#ifndef RENDERER3D_HPP
#define RENDERER3D_HPP
#include "open_engine/renderer/editor_camera.hpp"
#include "open_engine/renderer/vertex_array.hpp"
#include "open_engine/renderer/camera.hpp"
#include "open_engine/renderer/buffer.hpp"
#include <cstdint>
namespace OpenEngine {
// SHOULD BE MOVED ==================================
struct MeshVertex
{
glm::vec3 position;
glm::vec4 color;
glm::vec3 normal;
glm::vec2 text_coords;
uint32_t id = -1;
};
struct Mesh
{
Ref<VertexArray> vertex_array;
Ref<VertexBuffer> vertex_buffer;
Ref<IndexBuffer> index_buffer;
// TODO: Make them a ptr or something
std::vector<MeshVertex> vertices;
std::vector<uint32_t> indices;
};
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
const std::vector<uint32_t>& indices);
Ref<Mesh> CreateCube(uint32_t id = -1);
// ==================================================
class Renderer3D
{
public:
static void Init();
static void Shutdown();
static void BeginScene(const Camera& camera, const glm::mat4& transform);
static void BeginScene(const EditorCamera& camera);
static void EndScene();
static void DrawMesh(const Ref<Mesh>& mesh, const glm::mat4& transform);
/*
static void DrawCube(const glm::mat4& transform, const glm::vec4& color,
int entity_id);
static void DrawCube(const glm::mat4& transform, Ref<Texture2D>,
int entity_id);
static void DrawCube(const glm::mat4& transform, Ref<Texture2D>,
const glm::vec4& color, int entity_id);
*/
};
}
#endif // RENDERER3D_HPP