14 Renderer::RendererStorage Renderer::s_data = RendererStorage();
15 RenderState Renderer::s_currentState = RenderState();
16 RendererAPI* Renderer::s_API =
new OpenGLRendererAPI();
17 RenderCommandQueue Renderer::s_commands = RenderCommandQueue();
18 uint32_t Renderer::s_currentShaderID = 0;
19 uintptr_t Renderer::s_textures[16];
24 s_currentShaderID = 0;
27 s_data.ActiveLighting = scene->GetSceneLighting();
32 uint32_t
id = shader->GetID();
33 if (s_currentShaderID !=
id)
36 s_currentShaderID = id;
47 shader->SetProjectionViewMatrix(s_data.ViewProj);
48 shader->SetCameraPosition(s_data.CameraPosition);
109 s_currentState = newState;
118 uint32_t prevshader = s_currentShaderID;
125 shader->SetModelMatrix(command.
Transform);
126 s_data.ActiveLighting->UploadToShader(shader);
136 s_commands.
Submit(type, command);
157 Submit(bucketType, command);
163 uintptr_t textureID = texture ?
reinterpret_cast<uintptr_t
>(texture->GetNativeHandle()) : 0;
164 if (s_textures[slot] != textureID)
170 s_textures[slot] = textureID;
177 for (
int i = 0; i < std::size(s_textures); i++) {
178 s_textures[i] = (uintptr_t)-1;
glm::mat4 GenViewProjectionMatrix() const
std::shared_ptr< Shader > GetShader()
void Submit(RenderBucket::Type type, const RenderCommand &command)
virtual void SetCullingState(bool enabled) const =0
virtual void SetViewport(int x, int y, int width, int height) const =0
virtual void FlushBuffers() const =0
virtual void DrawArray(const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles) const =0
virtual void Clear() const =0
virtual void SetClearColor(const glm::vec4 &color) const =0
virtual void SetDepthWrittingState(bool enabled) const =0
virtual void ClearTextureBindings() const =0
virtual void SetDepthTestingState(bool enabled) const =0
static void PushRenderState(const RenderState &newState)
static void FlushBuffers()
static void SetClearColor(const glm::vec4 &color)
static void SetViewport(int x, int y, int width, int height)
static void BindTexture(const std::shared_ptr< Texture > &texture, uint8_t slot=0)
static void SubmitMesh(const std::shared_ptr< VertexArray > &vao, const std::shared_ptr< Material > &material, const glm::mat4 &transform, RenderBucket::Type bucketType=RenderBucket::Opaque)
static void BeginFrame(const ScenePtr scene, const Camera &cam)
static void InvalidateStateCache()
static bool BindShader(const std::shared_ptr< Shader > &shader)
static void Submit(RenderBucket::Type type, const RenderCommand &command)
static void DrawArray(const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles)
static void Dispatch(const RenderCommand &command)
Immediatly process a RenderCommand. Do not use directly unless you know what you are donig.
static void ApplySystemUniforms(const std::shared_ptr< Shader > &shader)
std::shared_ptr< Scene > ScenePtr
Material * m_MaterialInstance
VertexArray * m_VertexArray