Skip to content

Commit

Permalink
Merge pull request ddnet#7162 from Jupeyy/pr_fix_clipping_chat
Browse files Browse the repository at this point in the history
Disable scissor for clearing the framebuffer
  • Loading branch information
Robyt3 authored Sep 10, 2023
2 parents e8f17aa + ca29263 commit 36867df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/engine/client/backend/opengl/backend_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,18 @@ void CCommandProcessorFragment_OpenGL::Cmd_TextTextures_Create(const CCommandBuf

void CCommandProcessorFragment_OpenGL::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand)
{
// if clip is still active, force disable it for clearing, enable it again afterwards
bool ClipWasEnabled = m_LastClipEnable;
if(ClipWasEnabled)
{
glDisable(GL_SCISSOR_TEST);
}
glClearColor(pCommand->m_Color.r, pCommand->m_Color.g, pCommand->m_Color.b, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(ClipWasEnabled)
{
glEnable(GL_SCISSOR_TEST);
}
}

void CCommandProcessorFragment_OpenGL::Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand)
Expand Down
10 changes: 10 additions & 0 deletions src/engine/client/backend/opengl/backend_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,22 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_TextTextures_Create(const CCommand

void CCommandProcessorFragment_OpenGL3_3::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand)
{
// if clip is still active, force disable it for clearing, enable it again afterwards
bool ClipWasEnabled = m_LastClipEnable;
if(ClipWasEnabled)
{
glDisable(GL_SCISSOR_TEST);
}
if(pCommand->m_Color.r != m_ClearColor.r || pCommand->m_Color.g != m_ClearColor.g || pCommand->m_Color.b != m_ClearColor.b)
{
glClearColor(pCommand->m_Color.r, pCommand->m_Color.g, pCommand->m_Color.b, 0.0f);
m_ClearColor = pCommand->m_Color;
}
glClear(GL_COLOR_BUFFER_BIT);
if(ClipWasEnabled)
{
glEnable(GL_SCISSOR_TEST);
}
}

void CCommandProcessorFragment_OpenGL3_3::UploadStreamBufferData(unsigned int PrimitiveType, const void *pVertices, size_t VertSize, unsigned int PrimitiveCount, bool AsTex3D)
Expand Down

0 comments on commit 36867df

Please sign in to comment.