diff --git a/src/gx/glsdl/GLSDLDevice.cpp b/src/gx/glsdl/GLSDLDevice.cpp index 9bf1283..81bfa15 100644 --- a/src/gx/glsdl/GLSDLDevice.cpp +++ b/src/gx/glsdl/GLSDLDevice.cpp @@ -2468,8 +2468,26 @@ void GLSDLDevice::SetModelView(GLEnum transform) { } } -void GLSDLDevice::SetScissor(bool a2, const GLRect& a3) { - // TODO +void GLSDLDevice::SetScissor(bool enable, const GLRect& rect) { + if (enable) { + if (this->m_States.rasterizer.scissorEnable) { + glEnable(GL_SCISSOR_TEST); + } + + if (rect.left == this->m_States.rasterizer.scissor.left && + rect.top == this->m_States.rasterizer.scissor.top && + rect.width == this->m_States.rasterizer.scissor.width && + rect.height == this->m_States.rasterizer.scissor.height) { + return; + } + + glScissor(rect.left, rect.top, rect.width, rect.height); + + this->m_States.rasterizer.scissor = rect; + } else if (this->m_States.rasterizer.scissorEnable) { + glDisable(GL_SCISSOR_TEST); + this->m_States.rasterizer.scissorEnable = false; + } } void GLSDLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) { diff --git a/src/gx/glsdl/GLSDLDevice.hpp b/src/gx/glsdl/GLSDLDevice.hpp index fd7cd1f..045199c 100644 --- a/src/gx/glsdl/GLSDLDevice.hpp +++ b/src/gx/glsdl/GLSDLDevice.hpp @@ -171,7 +171,7 @@ class GLSDLDevice { void SetIndexBuffer(GLBuffer* buffer); void SetLightingEnable(bool enable); void SetModelView(GLEnum transform); - void SetScissor(bool a2, const GLRect& a3); + void SetScissor(bool enable, const GLRect& rect); void SetShader(GLShader::ShaderType shaderType, GLShader* shader); void SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count); void SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count);