Skip to content

Commit

Permalink
Clear texture slot
Browse files Browse the repository at this point in the history
  • Loading branch information
roeas committed Nov 5, 2024
1 parent 571f1d4 commit a2902af
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Engine/Source/Editor/Layer/RendererLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void UploadMaterialPropertyGroup(sl::Shader *pShader, const auto &propertyGroup)
}
else
{
sl::RenderCore::ClearTextureSlot(propertyGroup.m_textureSlot);
pShader->UploadUniform(propertyGroup.m_useTextureLocation, false);
}

Expand Down
5 changes: 5 additions & 0 deletions Engine/Source/Engine/Platform/OpenGL/OpenGLRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void OpenGLRenderAPI::ClearStencil()
glClear(GL_STENCIL_BUFFER_BIT);
}

void OpenGLRenderAPI::SetTextureSlot(uint32_t slot, uint32_t handle)
{
glBindTextureUnit(slot, handle);
}

void OpenGLRenderAPI::EnableDepthTest()
{
glEnable(GL_DEPTH_TEST);
Expand Down
2 changes: 2 additions & 0 deletions Engine/Source/Engine/Platform/OpenGL/OpenGLRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class OpenGLRenderAPI : public RenderAPI
virtual void ClearDepth() override;
virtual void ClearStencil() override;

virtual void SetTextureSlot(uint32_t slot, uint32_t handle) override;

virtual void EnableDepthTest() override;
virtual void SetDepthBufferWriteable(bool writeable) override;
virtual void SetDepthFunc(CompareFunction func) override;
Expand Down
2 changes: 2 additions & 0 deletions Engine/Source/Engine/RenderCore/RenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class RenderAPI
virtual void ClearDepth() = 0;
virtual void ClearStencil() = 0;

virtual void SetTextureSlot(uint32_t slot, uint32_t handle) = 0;

virtual void EnableDepthTest() = 0;
virtual void SetDepthBufferWriteable(bool writeable) = 0;
virtual void SetDepthFunc(CompareFunction func) = 0;
Expand Down
5 changes: 5 additions & 0 deletions Engine/Source/Engine/RenderCore/RenderCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ UniformBuffer *RenderCore::GetUniformBuffer(std::string_view name)
return it->second.get();
}

void RenderCore::ClearTextureSlot(uint32_t slot)
{
m_pRenderAPI->SetTextureSlot(slot, 0);
}

void RenderCore::SetDefaultState()
{
m_pRenderAPI->EnableDepthTest();
Expand Down
2 changes: 2 additions & 0 deletions Engine/Source/Engine/RenderCore/RenderCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class RenderCore final
static void SetUniformBuffer(std::string_view name, UniformBuffer *pUniformBuffer);
static UniformBuffer *GetUniformBuffer(std::string_view name);

static void ClearTextureSlot(uint32_t slot);

static void SetDefaultState();

static void ClearColor(float r, float g, float b, float a);
Expand Down

0 comments on commit a2902af

Please sign in to comment.