Elevate Engine 1
Loading...
Searching...
No Matches
Renderer.h
Go to the documentation of this file.
1#pragma once
2#include "RendererAPI.h"
5
6namespace Elevate
7{
8 class Camera;
9 class Shader;
10
11 class Scene;
12 using ScenePtr = std::shared_ptr<Scene>;
13 class SceneLighting;
14
15 class LayerStack;
16 class Layer;
17
18 class Shader;
19 class Texture;
20
22 {
23 public:
25
26 // RENDER API STATIC WRAPPER
27 static void BeginFrame(const ScenePtr scene, const Camera& cam);
28 // Performant function to bind a shader and to minimize API calls
29 static bool BindShader(const std::shared_ptr<Shader>& shader); // Return true if the shader just changed
30 static void ApplySystemUniforms(const std::shared_ptr<Shader>& shader);
31 static void SetClearColor(const glm::vec4& color);
32 static void Clear();
33 static void FlushBuffers();
34 static void SetViewport(int x, int y, int width, int height);
35 static void DrawArray(const VertexArray* vao, DrawPrimitiveType primitive = DrawPrimitiveType::Triangles);
36 static void DrawArray(const std::shared_ptr<VertexArray>& vao, DrawPrimitiveType primitive = DrawPrimitiveType::Triangles);
37 static void DrawStack();
38 static void PushRenderState(const RenderState& newState);
39
44 static void Dispatch(const RenderCommand& command);
45 // todo doc here
46 static void Submit(RenderBucket::Type type, const RenderCommand& command);
47 static void SubmitMesh(const std::shared_ptr<VertexArray>& vao, const std::shared_ptr<Material>& material, const glm::mat4& transform, RenderBucket::Type bucketType = RenderBucket::Opaque);
48
49 // Textures
50 static void BindTexture(const std::shared_ptr<Texture>& texture, uint8_t slot = 0);
51
52 static void InvalidateStateCache();
53 private:
54 struct RendererStorage {
55 glm::mat4 ViewProj;
56 glm::vec3 CameraPosition;
57 const SceneLighting* ActiveLighting = nullptr;
58 };
59
60 static RendererAPI* s_API;
61 static RenderCommandQueue s_commands;
62
63 // Current States
64 static RendererStorage s_data;
65 static RenderState s_currentState;
66 static uint32_t s_currentShaderID;
67 static uintptr_t s_textures[];
68 };
69}
static GraphicAPI GetAPI()
Definition RendererAPI.h:49
static void PushRenderState(const RenderState &newState)
Definition Renderer.cpp:91
static void FlushBuffers()
Definition Renderer.cpp:63
static void SetClearColor(const glm::vec4 &color)
Definition Renderer.cpp:53
static void SetViewport(int x, int y, int width, int height)
Definition Renderer.cpp:68
static void BindTexture(const std::shared_ptr< Texture > &texture, uint8_t slot=0)
Definition Renderer.cpp:160
static void SubmitMesh(const std::shared_ptr< VertexArray > &vao, const std::shared_ptr< Material > &material, const glm::mat4 &transform, RenderBucket::Type bucketType=RenderBucket::Opaque)
Definition Renderer.cpp:139
static void BeginFrame(const ScenePtr scene, const Camera &cam)
Definition Renderer.cpp:21
static void InvalidateStateCache()
Definition Renderer.cpp:174
static void DrawStack()
Definition Renderer.cpp:86
static bool BindShader(const std::shared_ptr< Shader > &shader)
Definition Renderer.cpp:30
static void Submit(RenderBucket::Type type, const RenderCommand &command)
Definition Renderer.cpp:134
static void DrawArray(const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles)
Definition Renderer.cpp:73
static void Dispatch(const RenderCommand &command)
Immediatly process a RenderCommand. Do not use directly unless you know what you are donig.
Definition Renderer.cpp:112
static void ApplySystemUniforms(const std::shared_ptr< Shader > &shader)
Definition Renderer.cpp:42
static RendererAPI::GraphicAPI GetAPI()
Definition Renderer.h:24
static void Clear()
Definition Renderer.cpp:58
std::shared_ptr< Scene > ScenePtr
Definition Renderer.h:12
DrawPrimitiveType
Definition RendererAPI.h:17