diff options
Diffstat (limited to 'source/Renderer.hpp')
-rw-r--r-- | source/Renderer.hpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/source/Renderer.hpp b/source/Renderer.hpp index 18a1e6e..b4ca735 100644 --- a/source/Renderer.hpp +++ b/source/Renderer.hpp @@ -1,46 +1,61 @@ #pragma once +#include "Camera.hpp" #include "Material.hpp" -#include "Mesh.hpp" #include "RcPtr.hpp" +#include "VertexIndex.hpp" #include <glad/glad.h> +#include <cstddef> #include <glm/glm.hpp> +// TODO add optional support for OpenGL separate attrib binding & only depend on vertex format + +// By default, RenderObject sets a default material but not data buffers. class RenderObject { public: glm::mat4 worldMatrix; private: RcPtr<Material> mMaterial; - RcPtr<GpuMesh> mMesh; + RcPtr<GpuIndexBuffer> mIndexBuf; + RcPtr<VertexFormat> mVertexFormat; + BufferBindings mVertexBufBinding; GLuint mVao; public: - RenderObject(GpuMesh* mesh, Material* material); + RenderObject(); ~RenderObject(); - GLuint GetGLVao() const { return mVao; } + GLuint GetGLVao() const; + void RebuildIfNecessary(); + Material* GetMaterial() const { return mMaterial.Get(); } - GpuMesh* GetMesh() const { return mMesh.Get(); } -}; + void SetMaterial(Material* material); -class Camera { -public: - glm::mat4 viewMatrix; - glm::mat4 projectionMatrix; + GpuIndexBuffer* GetIndexBuffer() const { return mIndexBuf.Get(); } + const VertexFormat* GetVertexFormat() const { return mVertexFormat.Get(); } + const BufferBindings& GetVertexBufferBindings() const { return mVertexBufBinding; } + void UpdateIndexBuffer(GpuIndexBuffer* indexBuffer); + void UpdateVertexFormat(VertexFormat* vertexFormat); + // Assumes the fetched BufferBinding object is modified + void UpdateVertexBufferBindings(BufferBindings** bindingsOut); + void SetFormat(VertexFormat* vertexFormat, Tags::IndexType indexFormat); -public: - void Move(glm::vec3 pos); - void LookAt(glm::vec3 pos); +private: + void DeleteGLObjects(); }; class Renderer { private: - Camera* mCam; + Camera* mFrame_Cam; + glm::mat4 mFrame_Transform; + float mFrame_Time; + float mFrame_DeltaTime; + bool mInsideFrame = false; public: - void BeginFrame(); + void BeginFrame(Camera& camera, float currentTime, float deltaTime); + void Draw(const RenderObject* objects, size_t count); void EndFrame(); - void Draw(RenderObject& object); }; |