StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
Object.hpp
1#pragma once
2#include "utilities/Range3.hpp"
3#ifdef StevEngine_RENDERER_GL
4#include <vector>
5#include <cstdint>
6#include <SDL.h>
7#include <glad/gl.h>
8
9#include "utilities/Vertex.hpp"
10#include "utilities/Matrix4.hpp"
11#include "visuals/Material.hpp"
12#include "visuals/shaders/ShaderProgram.hpp"
13
14namespace StevEngine::Renderer {
22 public:
27 virtual void Draw(Utilities::Matrix4 transform) const = 0;
28 };
29
30 enum RenderType {
31 SOLID,
32 WIREFRAME
33 };
34
41 class Object : public CustomObject {
42 public:
48 Object(const std::vector<Utilities::Vertex>& vertices, const Visuals::Material& material, RenderType renderType = SOLID);
49
56 Object(const std::vector<Utilities::Vertex>& vertices, const std::vector<uint32_t>& indices, const Visuals::Material& material, RenderType renderType = SOLID);
57
62 Object(const Object& instance);
63
66
72
77 void RemoveShader(Renderer::ShaderType type);
78
83 void Draw(Utilities::Matrix4 transform) const;
84
88 void UpdateBuffers() const;
89
93 void UpdateShaderMaterial() const;
94
99 uint32_t GetIndexCount() const { return indexCount; }
104 uint32_t GetVertexCount() const { return vertexCount; }
109 Utilities::Range3 GetBoundingBox() const { return boundingBox; }
114 RenderType GetRenderType() const { return renderType; }
119 void SetRenderType(RenderType type);
120
121 private:
122 float* vertices;
123 uint32_t vertexCount;
124 uint32_t* indices;
125 uint32_t indexCount;
126 std::map<Renderer::ShaderType, Renderer::ShaderProgram> shaders;
127 Utilities::Range3 boundingBox;
128 RenderType renderType;
129 };
130}
131#endif
Base interface for renderable objects.
Definition Object.hpp:21
virtual void Draw(Utilities::Matrix4 transform) const =0
Draw the object with transform.
void AddShader(Renderer::ShaderProgram program)
Add shader program.
Definition Object.cpp:103
RenderType GetRenderType() const
Get the type of rendering used by this object.
Definition Object.hpp:114
uint32_t GetVertexCount() const
Get the number of indices in object.
Definition Object.hpp:104
void SetRenderType(RenderType type)
Set the type of rendering used by this object.
Definition Object.cpp:91
void UpdateBuffers() const
Update GPU buffers with object vertex and index data.
Definition Object.cpp:169
void RemoveShader(Renderer::ShaderType type)
Remove shader of specified type.
Definition Object.cpp:108
void UpdateShaderMaterial() const
Update Fragment shader with material data.
Definition Object.cpp:174
Utilities::Range3 GetBoundingBox() const
Get bouning box of object.
Definition Object.hpp:109
uint32_t GetIndexCount() const
Get the number of indices in object.
Definition Object.hpp:99
Visuals::Material material
Material used for rendering.
Definition Object.hpp:65
Object(const std::vector< Utilities::Vertex > &vertices, const Visuals::Material &material, RenderType renderType=SOLID)
Create object from vertices.
Definition Object.cpp:24
void Draw(Utilities::Matrix4 transform) const
Draw object with transform.
Definition Object.cpp:113
Compiled and linked shader program.
Definition ShaderProgram.hpp:22
4x4 matrix for 3D transformations
Definition Matrix4.hpp:12
Axis-aligned bounding box in 3D space.
Definition Range3.hpp:18
Material properties for rendering.
Definition Material.hpp:14
Core rendering system.
Definition Object.cpp:19