public void EnableScissor(int left, int top, int width, int height) { VerifyThreadAffinity(); if (width < 0) { width = 0; } if (height < 0) { height = 0; } var bottom = WindowSize.Height - (top + height); if (WindowSize != SurfaceSize) { left = (int)Math.Round(WindowScale * left); bottom = (int)Math.Round(WindowScale * bottom); width = (int)Math.Round(WindowScale * width); height = (int)Math.Round(WindowScale * height); } OpenGL.glScissor(left, bottom, width, height); OpenGL.CheckGLError(); OpenGL.glEnable(OpenGL.GL_SCISSOR_TEST); OpenGL.CheckGLError(); }
public void EnableScissor(int x, int y, int width, int height) { VerifyThreadAffinity(); if (width < 0) { width = 0; } if (height < 0) { height = 0; } var windowSize = window.WindowSize; var windowScale = window.WindowScale; var surfaceSize = window.SurfaceSize; if (windowSize != surfaceSize) { x = (int)Math.Round(windowScale * x); y = (int)Math.Round(windowScale * y); width = (int)Math.Round(windowScale * width); height = (int)Math.Round(windowScale * height); } OpenGL.glScissor(x, y, width, height); OpenGL.CheckGLError(); OpenGL.glEnable(OpenGL.GL_SCISSOR_TEST); OpenGL.CheckGLError(); }
public void EnableDepthBuffer() { VerifyThreadAffinity(); OpenGL.glClear(OpenGL.GL_DEPTH_BUFFER_BIT); OpenGL.CheckGLError(); OpenGL.glEnable(OpenGL.GL_DEPTH_TEST); 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 SetBlendMode(BlendMode mode) { VerifyThreadAffinity(); OpenGL.glBlendEquation(OpenGL.GL_FUNC_ADD); OpenGL.CheckGLError(); switch (mode) { case BlendMode.None: OpenGL.glDisable(OpenGL.GL_BLEND); break; case BlendMode.Alpha: OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.CheckGLError(); OpenGL.glBlendFunc(OpenGL.GL_ONE, OpenGL.GL_ONE_MINUS_SRC_ALPHA); break; case BlendMode.Additive: case BlendMode.Subtractive: OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.CheckGLError(); OpenGL.glBlendFunc(OpenGL.GL_ONE, OpenGL.GL_ONE); if (mode == BlendMode.Subtractive) { OpenGL.CheckGLError(); OpenGL.glBlendEquation(OpenGL.GL_FUNC_REVERSE_SUBTRACT); } break; case BlendMode.Multiply: OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.CheckGLError(); OpenGL.glBlendFunc(OpenGL.GL_DST_COLOR, OpenGL.GL_ONE_MINUS_SRC_ALPHA); OpenGL.CheckGLError(); break; case BlendMode.Multiplicative: OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.CheckGLError(); OpenGL.glBlendFunc(OpenGL.GL_ZERO, OpenGL.GL_SRC_COLOR); break; case BlendMode.DoubleMultiplicative: OpenGL.glEnable(OpenGL.GL_BLEND); OpenGL.CheckGLError(); OpenGL.glBlendFunc(OpenGL.GL_DST_COLOR, OpenGL.GL_SRC_COLOR); break; } OpenGL.CheckGLError(); }
public void EnableScissor(int left, int top, int width, int height) { VerifyThreadAffinity(); if (width < 0) { width = 0; } if (height < 0) { height = 0; } OpenGL.glScissor(left, WindowSize.Height - (top + height), width, height); OpenGL.CheckGLError(); OpenGL.glEnable(OpenGL.GL_SCISSOR_TEST); OpenGL.CheckGLError(); }