Add scissor support to IFrameBuffer.

This commit is contained in:
Paul Chote
2019-11-03 17:25:41 +00:00
committed by reaperrr
parent e7de7b4c05
commit 0c8a47b5af
3 changed files with 40 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Platforms.Default
readonly Color clearColor;
uint framebuffer, depth;
bool disposed;
bool scissored;
public FrameBuffer(Size size, ITextureInternal texture, Color clearColor)
{
@@ -100,6 +101,9 @@ namespace OpenRA.Platforms.Default
public void Unbind()
{
if (scissored)
throw new InvalidOperationException("Attempting to unbind FrameBuffer with an active scissor region.");
VerifyThreadAffinity();
OpenGL.glFlush();
OpenGL.CheckGLError();
@@ -109,6 +113,25 @@ namespace OpenRA.Platforms.Default
OpenGL.CheckGLError();
}
public void EnableScissor(Rectangle rect)
{
VerifyThreadAffinity();
OpenGL.glScissor(rect.X, rect.Y, Math.Max(rect.Width, 0), Math.Max(rect.Height, 0));
OpenGL.CheckGLError();
OpenGL.glEnable(OpenGL.GL_SCISSOR_TEST);
OpenGL.CheckGLError();
scissored = true;
}
public void DisableScissor()
{
VerifyThreadAffinity();
OpenGL.glDisable(OpenGL.GL_SCISSOR_TEST);
OpenGL.CheckGLError();
scissored = false;
}
public ITexture Texture
{
get