Ejemplo n.º 1
0
 protected override void Dispose()
 {
     if (framebuffers.Count > 0)
     {
         foreach (var kv in framebuffers)
         {
             graphics.GetContextMeta(kv.Key).FrameBuffersToDelete.Add(kv.Value);
         }
         framebuffers.Clear();
     }
 }
Ejemplo n.º 2
0
            static void Clear(GL_Graphics graphics, ISystemOpenGL.Context context, RenderTarget target, Clear flags, Color color, float depth, int stencil, RectInt viewport)
            {
                // update the viewport
                var meta = graphics.GetContextMeta(context);

                {
                    viewport.Y = target.RenderHeight - viewport.Y - viewport.Height;

                    if (meta.Viewport != viewport)
                    {
                        GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
                        meta.Viewport = viewport;
                    }
                }

                // we disable the scissor for clearing
                meta.ForceScissorUpdate = true;
                GL.Disable(GLEnum.SCISSOR_TEST);

                // clear
                var mask = GLEnum.ZERO;

                if (flags.HasFlag(Framework.Clear.Color))
                {
                    GL.ClearColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                    mask |= GLEnum.COLOR_BUFFER_BIT;
                }

                if (flags.HasFlag(Framework.Clear.Depth))
                {
                    GL.ClearDepth(depth);
                    mask |= GLEnum.DEPTH_BUFFER_BIT;
                }

                if (flags.HasFlag(Framework.Clear.Stencil))
                {
                    GL.ClearStencil(stencil);
                    mask |= GLEnum.STENCIL_BUFFER_BIT;
                }

                GL.Clear(mask);
                GL.BindFramebuffer(GLEnum.FRAMEBUFFER, 0);
            }