#include <Renderer.h>
|
| static RendererAPI::GraphicAPI | GetAPI () |
| |
| static void | BeginFrame (const ScenePtr scene, const Camera &cam) |
| |
| static bool | BindShader (const std::shared_ptr< Shader > &shader) |
| |
| static void | ApplySystemUniforms (const std::shared_ptr< Shader > &shader) |
| |
| static void | SetClearColor (const glm::vec4 &color) |
| |
| static void | Clear () |
| |
| static void | FlushBuffers () |
| |
| static void | SetViewport (int x, int y, int width, int height) |
| |
| static void | DrawArray (const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles) |
| |
| static void | DrawArray (const std::shared_ptr< VertexArray > &vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles) |
| |
| static void | DrawStack () |
| |
| static void | PushRenderState (const RenderState &newState) |
| |
| static void | Dispatch (const RenderCommand &command) |
| | Immediatly process a RenderCommand. Do not use directly unless you know what you are donig.
|
| |
| static void | Submit (RenderBucket::Type type, const RenderCommand &command) |
| |
| 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 | BindTexture (const std::shared_ptr< Texture > &texture, uint8_t slot=0) |
| |
| static void | InvalidateStateCache () |
| |
Definition at line 21 of file Renderer.h.
◆ ApplySystemUniforms()
| void Elevate::Renderer::ApplySystemUniforms |
( |
const std::shared_ptr< Shader > & |
shader | ) |
|
|
static |
Definition at line 42 of file Renderer.cpp.
43 {
44
46 {
47 shader->SetProjectionViewMatrix(s_data.ViewProj);
48 shader->SetCameraPosition(s_data.CameraPosition);
49 }
50 }
static bool BindShader(const std::shared_ptr< Shader > &shader)
◆ BeginFrame()
| void Elevate::Renderer::BeginFrame |
( |
const ScenePtr |
scene, |
|
|
const Camera & |
cam |
|
) |
| |
|
static |
Definition at line 21 of file Renderer.cpp.
22 {
24 s_currentShaderID = 0;
25 s_data.CameraPosition = cam.gameObject->GetPosition();
26 s_data.ViewProj = cam.GenViewProjectionMatrix();
27 s_data.ActiveLighting = scene->GetSceneLighting();
28 }
virtual void ClearTextureBindings() const =0
◆ BindShader()
| bool Elevate::Renderer::BindShader |
( |
const std::shared_ptr< Shader > & |
shader | ) |
|
|
static |
Definition at line 30 of file Renderer.cpp.
31 {
32 uint32_t id = shader->GetID();
33 if (s_currentShaderID != id)
34 {
35 shader->Bind();
36 s_currentShaderID = id;
37 return true;
38 }
39 return false;
40 }
◆ BindTexture()
| void Elevate::Renderer::BindTexture |
( |
const std::shared_ptr< Texture > & |
texture, |
|
|
uint8_t |
slot = 0 |
|
) |
| |
|
static |
Definition at line 160 of file Renderer.cpp.
161 {
162
163 uintptr_t textureID = texture ? reinterpret_cast<uintptr_t>(texture->GetNativeHandle()) : 0;
164 if (s_textures[slot] != textureID)
165 {
166 if (texture)
167 {
168 texture->Bind(slot);
169 }
170 s_textures[slot] = textureID;
171 }
172 }
◆ Clear()
| void Elevate::Renderer::Clear |
( |
| ) |
|
|
static |
Definition at line 58 of file Renderer.cpp.
59 {
61 }
virtual void Clear() const =0
◆ Dispatch()
| void Elevate::Renderer::Dispatch |
( |
const RenderCommand & |
command | ) |
|
|
static |
Immediatly process a RenderCommand. Do not use directly unless you know what you are donig.
- Parameters
-
Definition at line 112 of file Renderer.cpp.
113 {
114
116
117
118 uint32_t prevshader = s_currentShaderID;
119 if (command.m_MaterialInstance)
120 {
121 auto shader = command.m_MaterialInstance->GetShader();
122 if (shader)
123 {
125 shader->SetModelMatrix(command.Transform);
126 s_data.ActiveLighting->UploadToShader(shader);
127 command.m_MaterialInstance->Apply();
128 }
129 }
130
132 }
static void PushRenderState(const RenderState &newState)
static void DrawArray(const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles)
static void ApplySystemUniforms(const std::shared_ptr< Shader > &shader)
◆ DrawArray() [1/2]
◆ DrawArray() [2/2]
Definition at line 73 of file Renderer.cpp.
74 {
75 if (vao)
76 {
78 }
79 }
virtual void DrawArray(const VertexArray *vao, DrawPrimitiveType primitive=DrawPrimitiveType::Triangles) const =0
◆ DrawStack()
| void Elevate::Renderer::DrawStack |
( |
| ) |
|
|
static |
◆ FlushBuffers()
| void Elevate::Renderer::FlushBuffers |
( |
| ) |
|
|
static |
Definition at line 63 of file Renderer.cpp.
64 {
66 }
virtual void FlushBuffers() const =0
◆ GetAPI()
Definition at line 24 of file Renderer.h.
static GraphicAPI GetAPI()
◆ InvalidateStateCache()
| void Elevate::Renderer::InvalidateStateCache |
( |
| ) |
|
|
static |
Definition at line 174 of file Renderer.cpp.
175 {
176
177 for (int i = 0; i < std::size(s_textures); i++) {
178 s_textures[i] = (uintptr_t)-1;
179 }
180 }
◆ PushRenderState()
| void Elevate::Renderer::PushRenderState |
( |
const RenderState & |
newState | ) |
|
|
static |
Definition at line 91 of file Renderer.cpp.
92 {
93
94 if (newState.Cullface != s_currentState.
Cullface)
95 {
97 }
98
99 if (newState.DepthWrite != s_currentState.
DepthWrite)
100 {
102 }
103
104 if (newState.DepthTest != s_currentState.
DepthTest)
105 {
107 }
108
109 s_currentState = newState;
110 }
virtual void SetCullingState(bool enabled) const =0
virtual void SetDepthWrittingState(bool enabled) const =0
virtual void SetDepthTestingState(bool enabled) const =0
◆ SetClearColor()
| void Elevate::Renderer::SetClearColor |
( |
const glm::vec4 & |
color | ) |
|
|
static |
Definition at line 53 of file Renderer.cpp.
54 {
56 }
virtual void SetClearColor(const glm::vec4 &color) const =0
◆ SetViewport()
| void Elevate::Renderer::SetViewport |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
width, |
|
|
int |
height |
|
) |
| |
|
static |
Definition at line 68 of file Renderer.cpp.
69 {
71 }
virtual void SetViewport(int x, int y, int width, int height) const =0
◆ Submit()
Definition at line 134 of file Renderer.cpp.
135 {
136 s_commands.
Submit(type, command);
137 }
void Submit(RenderBucket::Type type, const RenderCommand &command)
◆ SubmitMesh()
Definition at line 139 of file Renderer.cpp.
140 {
141 RenderCommand command;
142 command.m_VertexArray = vao.get();
143 command.m_MaterialInstance = material.get();
144 command.Transform = transform;
145
147 {
148 command.m_State.BlendEnable = true;
149 command.m_State.DepthWrite = false;
150 }
151 else
152 {
153 command.m_State.BlendEnable = false;
154 command.m_State.DepthWrite = true;
155 }
156
157 Submit(bucketType, command);
158 }
static void Submit(RenderBucket::Type type, const RenderCommand &command)
The documentation for this class was generated from the following files: