33#ifdef SLEAK_HOT_RELOAD
35 bool ReloadShaders(
const std::vector<std::string>& stems)
override;
42 virtual void Resize(uint32_t
width, uint32_t
height)
override;
44 virtual bool CreateImGUI()
override;
46 void ApplyMSAAChange()
override;
47 void ApplyVSyncChange()
override;
52 virtual void Draw(uint32_t vertexCount)
override;
53 virtual void Draw(uint32_t vertexCount, uint32_t firstVertex)
override;
54 virtual void DrawIndexed(uint32_t indexCount)
override;
55 virtual void DrawIndexed(uint32_t indexCount, uint32_t firstIndex,
56 int32_t baseVertex)
override;
57 virtual void DrawInstance(uint32_t instanceCount,
58 uint32_t vertexPerInstance)
override;
59 virtual void DrawIndexedInstance(uint32_t instanceCount,
60 uint32_t indexPerInstance)
override;
61 virtual void DrawIndexedInstance(uint32_t instanceCount,
62 uint32_t indexPerInstance,
64 int32_t baseVertex)
override;
66 virtual void SetRenderFace(
RenderFace face)
override;
67 virtual void SetRenderMode(
RenderMode mode)
override;
69 float minDepth = 0.0f,
70 float maxDepth = 1.0f)
override;
73 virtual void ClearDepthStencil(
bool clearDepth,
bool clearStencil,
74 float depth, uint8_t stencil)
override;
76 virtual void SetDepthWrite(
bool enabled)
override;
77 virtual void SetDepthCompare(
DepthCompare compare)
override;
78 virtual void SetCullEnabled(
bool enabled)
override;
82 uint32_t slot = 0)
override;
84 uint32_t slot = 0)
override;
86 uint32_t slot = 0)
override;
89 virtual void BeginDebugLinePass()
override;
90 virtual void EndDebugLinePass()
override;
94 virtual Shader* CreateShader(
const std::string& shaderSource)
override;
95 virtual Texture* CreateTexture(
const std::string& TexturePath)
override;
100 Texture* CreateCubemapTexture(
const std::array<std::string, 6>& facePaths);
102 Texture* CreateCubemapTextureFromPanorama(
const std::string& panoramaPath);
106 SDL_GLContext m_GLContext =
nullptr;
107 bool m_Initialized =
false;
110 bool m_debugLineMode =
false;
113 static constexpr uint32_t NO_CONFIGURED_LAYOUT = UINT32_MAX;
114 uint32_t m_configuredLayout = NO_CONFIGURED_LAYOUT;
116 uint32_t m_enabledAttribMask = 0;
119 std::array<GLint, 4> m_viewport = {};
121 void ApplyViewport(GLint x, GLint y, GLsizei
width, GLsizei
height);
124 GLuint m_msaaFBO = 0;
125 GLuint m_msaaColorRBO = 0;
126 GLuint m_msaaDepthRBO = 0;
128 void CreateMSAAFramebuffer();
129 void CleanupMSAAFramebuffer();
131 virtual void ConfigureRenderMode()
override;
132 virtual void ConfigureRenderFace()
override;
135 void SetupVertexLayout();
141 GLuint m_shadowFBO = 0;
142 GLuint m_shadowDepthTex = 0;
143 GLuint m_shadowUBO = 0;
144 bool m_shadowMapCreated =
false;
145 bool m_shadowUBOCreated =
false;
146 float m_lightVP[16] = {};
147 float m_pendingLightVP[16] = {};
148 bool m_hasPendingLightVP =
false;
150 float m_shadowMapLightVP[16] = {};
151 bool m_shadowMapRendered =
false;
152 bool m_inShadowPass =
false;
153 GLuint m_shadowTransformUBO = 0;
155 float m_shadowTransformCache[32] = {};
156 float m_shadowWorldCache[16] = {};
157 bool m_shadowTransformCacheValid =
false;
158 void SetLightVP(
const float* mat)
override;
161 void UpdateShadowLightUBO(
const void* data, uint32_t size)
override;
163 bool CreateShadowMapResources();
165 bool CreateShadowUBO();
167 void RenderShadowPass();
171 virtual bool IsDeferredEnabled()
const override;
172 virtual bool IsInGeometryPass()
const override {
return m_inGeometryPass; }
173 virtual void BindGBufferShader()
override;
174 virtual void BindPBRMaterial(Sleak::Material* material)
override;
175 virtual void ExecuteDeferredLightingPass()
override;
176 virtual void BeginForwardTransparentPass()
override;
177 virtual void EndForwardTransparentPass()
override;
178 virtual void UpdateDeferredCB(
const void* data, uint32_t size)
override;
181 GLuint m_gbufferFBO = 0;
182 GLuint m_gbufferAlbedoAO = 0;
183 GLuint m_gbufferNormalRough = 0;
184 GLuint m_gbufferMetalEmit = 0;
185 GLuint m_gbufferDepth = 0;
186 bool m_gbufferCreated =
false;
187 int m_gbufferWidth = 0;
188 int m_gbufferHeight = 0;
191 class OpenGLShader* m_gbufferShader =
nullptr;
192 class OpenGLShader* m_lightingShader =
nullptr;
193 GLuint m_lightingVAO = 0;
196 GLuint m_deferredCBUBO = 0;
197 bool m_deferredCBCreated =
false;
199 bool m_inGeometryPass =
false;
200 bool m_inForwardTransparentPass =
false;
203 bool CreateGBufferResources();
204 void CleanupGBufferResources();
206 void RecreateGBufferOnResize(
int width,
int height);
209 GLuint m_ssaoFBO = 0;
210 GLuint m_ssaoTexture = 0;
211 GLuint m_ssaoBlurFBO = 0;
212 GLuint m_ssaoBlurTex = 0;
213 GLuint m_ssaoNoiseTex = 0;
214 GLuint m_ssaoSettingsUBO = 0;
215 GLuint m_ssaoKernelUBO = 0;
216 GLuint m_ssaoCameraUBO = 0;
217 class OpenGLShader* m_ssaoShader =
nullptr;
218 class OpenGLShader* m_ssaoBlurShader =
nullptr;
219 bool m_ssaoCreated =
false;
222 bool CreateSSAOResources();
223 void CleanupSSAOResources();
227 void ExecuteSSAOPass();
230 class OpenGLIBL* m_ibl =
nullptr;
231 GLuint m_iblSettingsUBO = 0;
232 GLuint m_iblBoundCubemap = 0;
238 static constexpr GLuint SCENE_COLOR_UNIT = 4;
239 static constexpr GLuint SCENE_DEPTH_UNIT = 5;
240 static constexpr GLuint SCENE_SKY_UNIT = 6;
241 static constexpr GLuint SCENE_READ_UBO_BINDING = 4;
242 GLuint m_sceneCopyTex = 0;
243 int m_sceneCopyWidth = 0;
244 int m_sceneCopyHeight = 0;
245 GLuint m_sceneReadUBO = 0;
246 GLuint m_sceneFallbackCube = 0;
247 GLuint m_sceneSkyCube = 0;
248 bool m_sceneReadPrepared =
false;
249 float m_cachedInvViewProj[16] = {};
250 float m_cachedNearPlane = 0.0f;
251 float m_cachedFarPlane = 0.0f;
253 GLuint FindSkyboxCubemap()
const;
256 void PrepareSceneRead();
258 void CleanupSceneRead();
Abstract interface for high-level graphics command execution and resource management.