Exemple #1
0
        public void Clear(ClearOptions options, Color color, float depth, byte stencil)
        {
            if (depth < 0 || depth > 1)
            {
                throw new ArgumentOutOfRangeException("Depth must be between 0 and 1", "depth");
            }

            if (options.HasFlag(ClearOptions.Color))
            {
                SetClearColor(ref color);
                currentClearBufferMask |= ClearBufferMask.ColorBufferBit;
            }

            if (options.HasFlag(ClearOptions.Depth))
            {
                SetClearDepth(ref depth);
                currentClearBufferMask |= ClearBufferMask.DepthBufferBit;
            }

            if (options.HasFlag(ClearOptions.Stencil))
            {
                SetClearStencil(ref stencil);
                currentClearBufferMask |= ClearBufferMask.StencilBufferBit;
            }
        }
Exemple #2
0
 private ShaderWindow(ShaderWindowSettings configuration, DisplayDevice display)
     : base(configuration.Width, configuration.Height,
            configuration.GraphicsMode == null ? GraphicsMode.Default : configuration.GraphicsMode.CreateGraphicsMode(),
            DefaultTitle, GameWindowFlags.Default, display)
 {
     settings              = configuration;
     VSync                 = configuration.VSync;
     swapSync              = configuration.SwapSync;
     clearColor            = configuration.ClearColor;
     clearMask             = configuration.ClearMask;
     Title                 = configuration.Title ?? DefaultTitle;
     CursorVisible         = configuration.CursorVisible;
     Location              = configuration.Location.GetValueOrDefault(Location);
     WindowBorder          = configuration.WindowBorder;
     WindowState           = configuration.WindowState;
     Viewport              = DefaultViewport;
     Scissor               = DefaultViewport;
     TargetRenderFrequency = configuration.TargetRenderFrequency;
     TargetUpdateFrequency = configuration.TargetUpdateFrequency.GetValueOrDefault(
         VSync != VSyncMode.Off && configuration.TargetRenderFrequency == 0
         ? display.RefreshRate
         : configuration.TargetRenderFrequency);
     updateFrame     = new Subject <FrameEvent>();
     renderFrame     = new Subject <FrameEvent>();
     resourceManager = new ResourceManager();
     shaders         = new List <Shader>();
 }
Exemple #3
0
        public void ClearBuffers(int RtIndex, GalClearBufferFlags Flags)
        {
            ClearBufferMask Mask = 0;

            //OpenGL doesn't support clearing just a single color channel,
            //so we can't just clear all channels...
            if (Flags.HasFlag(GalClearBufferFlags.ColorRed) &&
                Flags.HasFlag(GalClearBufferFlags.ColorGreen) &&
                Flags.HasFlag(GalClearBufferFlags.ColorBlue) &&
                Flags.HasFlag(GalClearBufferFlags.ColorAlpha))
            {
                Mask = ClearBufferMask.ColorBufferBit;
            }

            if (Flags.HasFlag(GalClearBufferFlags.Depth))
            {
                Mask |= ClearBufferMask.DepthBufferBit;
            }

            if (Flags.HasFlag(GalClearBufferFlags.Stencil))
            {
                Mask |= ClearBufferMask.StencilBufferBit;
            }

            GL.Clear(Mask);
        }
        public void ClearBuffers(
            GalClearBufferFlags Flags,
            float Red, float Green, float Blue, float Alpha,
            float Depth,
            int Stencil)
        {
            ClearBufferMask Mask = ClearBufferMask.ColorBufferBit;

            GL.ColorMask(
                Flags.HasFlag(GalClearBufferFlags.ColorRed),
                Flags.HasFlag(GalClearBufferFlags.ColorGreen),
                Flags.HasFlag(GalClearBufferFlags.ColorBlue),
                Flags.HasFlag(GalClearBufferFlags.ColorAlpha));

            if (Flags.HasFlag(GalClearBufferFlags.Depth))
            {
                Mask |= ClearBufferMask.DepthBufferBit;
            }

            if (Flags.HasFlag(GalClearBufferFlags.Stencil))
            {
                Mask |= ClearBufferMask.StencilBufferBit;
            }

            GL.ClearColor(Red, Green, Blue, Alpha);

            GL.ClearDepth(Depth);

            GL.ClearStencil(Stencil);

            GL.Clear(Mask);

            GL.ColorMask(true, true, true, true);
        }
Exemple #5
0
 public static void Clear(ClearBufferMask mask)
 {
     Debug.Assert(Delegates.pglClear != null, "pglClear not implemented");
     Delegates.pglClear((UInt32)mask);
     LogCommand("glClear", null, mask);
     DebugCheckErrors(null);
 }
Exemple #6
0
        /// <summary>
        /// Copies content to the specified Framebuffer.
        /// </summary>
        public void CopyTo(Framebuffer target, ClearBufferMask clear = ClearBufferMask.ColorBufferBit, BlitFramebufferFilter filter = BlitFramebufferFilter.Linear)
        {
            Activate(FramebufferTarget.ReadFramebuffer, false);
            target.Activate(FramebufferTarget.DrawFramebuffer, false);

            GL.BlitFramebuffer(0, 0, (int)Size.X, (int)Size.Y, 0, 0, (int)Size.X, (int)Size.Y, clear, filter);
        }
        /// <summary>
        /// Clear surface buffers.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for clearing buffers.
        /// </param>
        /// <param name="bufferMask">
        /// A <see cref="ClearBufferMask"/> indicating which buffers to clear.
        /// </param>
        public void Clear(GraphicsContext ctx, ClearBufferMask bufferMask)
        {
            // Update clear values (only what is necessary)
            if ((bufferMask & ClearBufferMask.ColorBufferBit) != 0)
            {
                Gl.ClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
            }
#if !MONODROID
            if ((bufferMask & ClearBufferMask.DepthBufferBit) != 0)
            {
                Gl.ClearDepth(mClearDepth);
            }
#else
            if ((bufferMask & ClearBufferMask.DepthBufferBit) != 0)
            {
                Gl.ClearDepth((float)mClearDepth);
            }
#endif
            if ((bufferMask & ClearBufferMask.StencilBufferBit) != 0)
            {
                Gl.ClearStencil(mClearStencil);
            }

            // Clear
            Gl.Clear(bufferMask);
        }
Exemple #8
0
        public Camera(float a_fov, int a_width, int a_height, float a_near, float a_far, ClearBufferMask a_clearFlags = ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit, RenderTexture a_renderTexture = null, IPost a_post = null) : base()
        {
            SetProjectionViewport(a_fov, a_width, a_height, a_near, a_far);

            m_clearFlags = a_clearFlags;

            m_renderTexture = a_renderTexture;
            m_post          = a_post;

            m_clearColor = Color.Gray;

            if (Cameras == null)
            {
                Cameras = new List <Camera>();
            }

            lock (CameraList)
            {
                Cameras.Add(this);

                if (m_mainCamera == null)
                {
                    m_mainCamera = this;
                }
            }
        }
Exemple #9
0
        public static void Clear(Vector4d?color = null, double?depth = null, int?stencil = null)
        {
            ClearBufferMask mask = (ClearBufferMask)0;

            if (color.HasValue)
            {
                Vector4d vcolor = color.Value;
                mask |= ClearBufferMask.ColorBufferBit;
                GL.ClearColor((float)vcolor.X, (float)vcolor.Y, (float)vcolor.Z, (float)vcolor.W);
            }

            if (depth.HasValue)
            {
                mask |= ClearBufferMask.DepthBufferBit;
                GL.ClearDepth(depth.Value);
            }

            if (stencil != null)
            {
                mask |= ClearBufferMask.StencilBufferBit;
                GL.ClearStencil(stencil.Value);
            }

            GL.Clear(mask);
            CheckError();
        }
Exemple #10
0
        public void Copy(
            TextureView src,
            TextureView dst,
            Extents2D srcRegion,
            Extents2D dstRegion,
            bool linearFilter)
        {
            TextureView srcConverted = src.Format.IsBgra8() != dst.Format.IsBgra8() ? BgraSwap(src) : src;

            (int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();

            GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, GetSrcFramebufferLazy());
            GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, GetDstFramebufferLazy());

            Attach(FramebufferTarget.ReadFramebuffer, src.Format, srcConverted.Handle);
            Attach(FramebufferTarget.DrawFramebuffer, dst.Format, dst.Handle);

            ClearBufferMask mask = GetMask(src.Format);

            if ((mask & (ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit)) != 0 || src.Format.IsInteger())
            {
                linearFilter = false;
            }

            BlitFramebufferFilter filter = linearFilter
                ? BlitFramebufferFilter.Linear
                : BlitFramebufferFilter.Nearest;

            GL.ReadBuffer(ReadBufferMode.ColorAttachment0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);

            GL.Disable(EnableCap.RasterizerDiscard);
            GL.Disable(IndexedEnableCap.ScissorTest, 0);

            GL.BlitFramebuffer(
                srcRegion.X1,
                srcRegion.Y1,
                srcRegion.X2,
                srcRegion.Y2,
                dstRegion.X1,
                dstRegion.Y1,
                dstRegion.X2,
                dstRegion.Y2,
                mask,
                filter);

            Attach(FramebufferTarget.ReadFramebuffer, src.Format, 0);
            Attach(FramebufferTarget.DrawFramebuffer, dst.Format, 0);

            GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
            GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);

            ((Pipeline)_renderer.Pipeline).RestoreScissor0Enable();
            ((Pipeline)_renderer.Pipeline).RestoreRasterizerDiscard();

            if (srcConverted != src)
            {
                srcConverted.Dispose();
            }
        }
 public void Clear(ClearBufferMask mask)
 {
     ThreadingHelper.BlockOnUIThread(() =>
     {
         GL.Clear((OpenTK.Graphics.OpenGL4.ClearBufferMask)mask);
     });
 }
Exemple #12
0
        public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
        {
            Rectangle         scissorRectangle  = this.ScissorRectangle;
            DepthStencilState depthStencilState = this.DepthStencilState;
            BlendState        blendState        = this.BlendState;

            this.ScissorRectangle  = this._viewport.Bounds;
            this.DepthStencilState = DepthStencilState.Default;
            this.BlendState        = BlendState.Opaque;
            this.ApplyState(false);
            ClearBufferMask mask = (ClearBufferMask)0;

            if ((options & ClearOptions.Target) == ClearOptions.Target)
            {
                GL.ClearColor(color.X, color.Y, color.Z, color.W);
                mask |= ClearBufferMask.ColorBufferBit;
            }
            if ((options & ClearOptions.Stencil) == ClearOptions.Stencil)
            {
                GL.ClearStencil(stencil);
                mask |= ClearBufferMask.StencilBufferBit;
            }
            if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer)
            {
                GL.ClearDepth((double)depth);
                mask |= ClearBufferMask.DepthBufferBit;
            }
            GL.Clear(mask);
            this.ScissorRectangle  = scissorRectangle;
            this.DepthStencilState = depthStencilState;
            this.BlendState        = blendState;
        }
        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="options"></param>
        /// <param name="color"></param>
        /// <param name="depth"></param>
        /// <param name="stencil"></param>
        public void PlatformClear(ClearOptions options, Vector4 color, float depth, int stencil)
        {
            var prevScissorRect       = ScissorRectangle;
            var prevDepthStencilState = DepthStencilState;
            var prevBlendState        = BlendState;

            ScissorRectangle = _viewport.Bounds;

            DepthStencilState = this.clearDepthStencilState;
            BlendState        = BlendState.Opaque;

            ApplyState(false);

            ClearBufferMask bufferMask = 0;

            //颜色缓冲
            if ((options & ClearOptions.Target) == ClearOptions.Target)
            {
                if (color != _lastClearColor)
                {
                    GL.ClearColor(color.X, color.Y, color.Z, color.W);//状态设置
                    GraphicsExtensions.CheckGLError();
                    _lastClearColor = color;
                }
                bufferMask = bufferMask | ClearBufferMask.ColorBufferBit;
            }
            //模板缓冲
            if ((options & ClearOptions.Stencil) == ClearOptions.Stencil)
            {
                if (stencil != _lastClearStencil)
                {
                    GL.ClearStencil(stencil);
                    GraphicsExtensions.CheckGLError();
                    _lastClearStencil = stencil;
                }
                bufferMask = bufferMask | ClearBufferMask.StencilBufferBit;
            }

            //深度缓冲
            if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer)
            {
                if (depth != _lastClearDepth)
                {
                    GL.ClearDepth(depth);
                    GraphicsExtensions.CheckGLError();
                    _lastClearDepth = depth;
                }
                bufferMask = bufferMask | ClearBufferMask.DepthBufferBit;
            }



            GL.Clear(bufferMask);//状态应用
            GraphicsExtensions.CheckGLError();

            //
            ScissorRectangle  = prevScissorRect;
            DepthStencilState = prevDepthStencilState;
            BlendState        = prevBlendState;
        }
Exemple #14
0
        public void BeginRendering(ClearFlag clearFlags, ColorRgba clearColor, float clearDepth)
        {
            RenderTarget.Bind(this.renderTarget);

            // Setup viewport
            Vector2 refSize     = this.TargetSize;
            Rect    viewportAbs = new Rect(refSize);

            GL.Viewport((int)viewportAbs.X, (int)refSize.Y - (int)viewportAbs.H - (int)viewportAbs.Y, (int)viewportAbs.W, (int)viewportAbs.H);
            GL.Scissor((int)viewportAbs.X, (int)refSize.Y - (int)viewportAbs.H - (int)viewportAbs.Y, (int)viewportAbs.W, (int)viewportAbs.H);

            // Clear buffers
            ClearBufferMask glClearMask = 0;

            if ((clearFlags & ClearFlag.Color) != ClearFlag.None)
            {
                glClearMask |= ClearBufferMask.ColorBufferBit;
            }
            if ((clearFlags & ClearFlag.Depth) != ClearFlag.None)
            {
                glClearMask |= ClearBufferMask.DepthBufferBit;
            }
            GL.ClearColor((OpenTK.Graphics.Color4)clearColor);
            GL.ClearDepth((double)clearDepth);             // The "float version" is from OpenGL 4.1..
            GL.Clear(glClearMask);

            // Configure Rendering params
            if (this.renderMode == RenderMatrix.OrthoScreen)
            {
                GL.Enable(EnableCap.ScissorTest);
                GL.Enable(EnableCap.DepthTest);
                GL.DepthFunc(DepthFunction.Always);
            }
            else
            {
                GL.Enable(EnableCap.ScissorTest);
                GL.Enable(EnableCap.DepthTest);
                GL.DepthFunc(DepthFunction.Lequal);
            }

            // Upload and adjust matrices
            this.UpdateMatrices();
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref this.matModelView);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref this.matProjection);
            if (this.renderTarget.IsAvailable)
            {
                if (this.renderMode == RenderMatrix.OrthoScreen)
                {
                    GL.Translate(0.0f, RenderTarget.BoundRT.Res.Height * 0.5f, 0.0f);
                }
                GL.Scale(1.0f, -1.0f, 1.0f);
                if (this.renderMode == RenderMatrix.OrthoScreen)
                {
                    GL.Translate(0.0f, -RenderTarget.BoundRT.Res.Height * 0.5f, 0.0f);
                }
            }
        }
Exemple #15
0
 public static Reaction <T> Clear <T> (Vec4 clearColor, ClearBufferMask mask)
 {
     return(React.By <T> (input =>
     {
         GL.ClearColor(clearColor.X, clearColor.Y, clearColor.Z, clearColor.W);
         GL.Clear(mask);
     }));
 }
Exemple #16
0
        public void ClearBuffers(GLQueueClearBufferMask combinedMask)
        {
            ClearBufferMask bitmask = ((combinedMask & GLQueueClearBufferMask.Color) == GLQueueClearBufferMask.Color) ? ClearBufferMask.ColorBufferBit: 0;

            bitmask |= ((combinedMask & GLQueueClearBufferMask.Depth) == GLQueueClearBufferMask.Depth) ? ClearBufferMask.DepthBufferBit: 0;
            bitmask |= ((combinedMask & GLQueueClearBufferMask.Stencil) == GLQueueClearBufferMask.Stencil) ? ClearBufferMask.StencilBufferBit: 0;
            GL.Clear(bitmask);
        }
        public void Blit(IFramebuffer target, ClearBufferMask mask, BlitFramebufferFilter filter)
        {
            FramebufferGL3 targetGL3 = (FramebufferGL3)target;

            GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, framebufferObject);
            GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, targetGL3.framebufferObject);
            GL.BlitFramebuffer(0, 0, viewport.Width, viewport.Height, 0, 0, target.Viewport.Width, target.Viewport.Height, mask, filter);
        }
Exemple #18
0
        public static void Clear(ClearBufferMask mask)
        {
#if USE_OPENGL
            OpenTK.Graphics.OpenGL.GL.Clear((OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
#else
            OpenTK.Graphics.ES11.GL.Clear((OpenTK.Graphics.ES11.ClearBufferMask)mask);
#endif
        }
Exemple #19
0
 public void CopyToScreen(ClearBufferMask what, BlitFramebufferFilter how)
 {
     //create();
     GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, _frameBuffer);
     GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, 0);
     GL.BlitFramebuffer(0, 0, _width, _height, 0, 0, SharpCraft.Instance.Width, SharpCraft.Instance.Height, what, how);
     GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
 }
 public void Clear(ClearBufferMask mask, System.Drawing.Color color)
 {
     ThreadingHelper.BlockOnUIThread(() =>
     {
         GL.Clear((OpenTK.Graphics.OpenGL4.ClearBufferMask)mask);
         GL.ClearColor(color);
     });
 }
Exemple #21
0
        public void Clear(ClearBufferMask mask)
        {
            var g = GetCurrentGraphics();

            if ((mask & ClearBufferMask.ColorBufferBit) != 0)
            {
                g.Clear(_currentClearColor);
            }
        }
Exemple #22
0
        public static void Clear(ClearBufferMask clearBufferMask)
        {
            GL.Clear(clearBufferMask);

            if (enableErrorCheck)
            {
                LogErrors();
            }
        }
Exemple #23
0
        public void Copy(
            long SrcKey,
            long DstKey,
            int SrcX0,
            int SrcY0,
            int SrcX1,
            int SrcY1,
            int DstX0,
            int DstY0,
            int DstX1,
            int DstY1)
        {
            if (Texture.TryGetImageHandler(SrcKey, out ImageHandler SrcTex) &&
                Texture.TryGetImageHandler(DstKey, out ImageHandler DstTex))
            {
                if (SrcTex.HasColor != DstTex.HasColor ||
                    SrcTex.HasDepth != DstTex.HasDepth ||
                    SrcTex.HasStencil != DstTex.HasStencil)
                {
                    throw new NotImplementedException();
                }

                if (SrcFb == 0)
                {
                    SrcFb = GL.GenFramebuffer();
                }

                if (DstFb == 0)
                {
                    DstFb = GL.GenFramebuffer();
                }

                GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, SrcFb);
                GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, DstFb);

                FramebufferAttachment Attachment = GetAttachment(SrcTex);

                GL.FramebufferTexture(FramebufferTarget.ReadFramebuffer, Attachment, SrcTex.Handle, 0);
                GL.FramebufferTexture(FramebufferTarget.DrawFramebuffer, Attachment, DstTex.Handle, 0);

                BlitFramebufferFilter Filter = BlitFramebufferFilter.Nearest;

                if (SrcTex.HasColor)
                {
                    GL.DrawBuffer(DrawBufferMode.ColorAttachment0);

                    Filter = BlitFramebufferFilter.Linear;
                }

                ClearBufferMask Mask = GetClearMask(SrcTex);

                GL.Clear(Mask);

                GL.BlitFramebuffer(SrcX0, SrcY0, SrcX1, SrcY1, DstX0, DstY0, DstX1, DstY1, Mask, Filter);
            }
        }
Exemple #24
0
        public void Clear()
        {
            ClearBufferMask ClearMask = ClearBufferMask.ColorBufferBit;

            if (HasDepth)
            {
                ClearMask |= ClearBufferMask.DepthBufferBit;
            }
            GL.Clear(ClearMask);
        }
Exemple #25
0
        private void ApplyRenderTarget()
        {
            graphicsDevice.BindManager.Fbo = graphicsDevice.GetFBO(currentDepthRenderTarget, currentRenderTargets);

            if (currentClearBufferMask != 0)
            {
                GL.Clear(currentClearBufferMask);
                currentClearBufferMask = 0;
            }
        }
Exemple #26
0
        private void CopyTextures(
            int SrcX0,
            int SrcY0,
            int SrcX1,
            int SrcY1,
            int DstX0,
            int DstY0,
            int DstX1,
            int DstY1,
            int SrcTexture,
            int DstTexture,
            FramebufferAttachment Attachment,
            ClearBufferMask Mask,
            bool Color)
        {
            if (SrcFb == 0)
            {
                SrcFb = GL.GenFramebuffer();
            }
            if (DstFb == 0)
            {
                DstFb = GL.GenFramebuffer();
            }

            GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, SrcFb);
            GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, DstFb);

            GL.FramebufferTexture(
                FramebufferTarget.ReadFramebuffer,
                Attachment,
                SrcTexture,
                0);

            GL.FramebufferTexture(
                FramebufferTarget.DrawFramebuffer,
                Attachment,
                DstTexture,
                0);

            if (Color)
            {
                GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            }

            GL.Clear(Mask);

            GL.BlitFramebuffer(
                SrcX0, SrcY0, SrcX1, SrcY1,
                DstX0, DstY0, DstX1, DstY1,
                Mask,
                Color ? BlitFramebufferFilter.Linear : BlitFramebufferFilter.Nearest);

            EnsureFrameBuffer();
        }
Exemple #27
0
        public void Clear(params string[] mask)
        {
            ClearBufferMask clearBufferMask = ClearBufferMask.None;

            foreach (string m in mask)
            {
                clearBufferMask |= m.ToEnum <ClearBufferMask>();
            }

            GL.Clear(clearBufferMask);
        }
Exemple #28
0
        public static void Clear(ClearBufferMask mask)
        {
#if USE_OPENGL
            if (HardwareAvailable)
            {
                OpenTK.Graphics.OpenGL.GL.Clear((OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
            }
#else
            OpenTK.Graphics.ES11.GL.Clear((OpenTK.Graphics.ES11.ClearBufferMask)mask);
#endif
        }
Exemple #29
0
        public void Clear(ClearOptions options, Color4 color, float depth, byte stencil)
        {
            if (options == ClearOptions.None)
            {
                return;
            }
            EnsureRenderTarget();
            BindClearValues(false, options, color, depth, stencil);
            ClearBufferMask glClearBufferMask = 0;

            if ((options & ClearOptions.ColorBuffer) != 0)
            {
                glClearBufferMask |= ClearBufferMask.ColorBufferBit;
                if (boundColorWriteMask != ColorWriteMask.All)
                {
                    GL.ColorMask(true, true, true, true);
                    GLHelper.CheckGLErrors();
                    boundColorWriteMask = ColorWriteMask.All;
                }
            }
            if ((options & ClearOptions.DepthBuffer) != 0)
            {
                glClearBufferMask |= ClearBufferMask.DepthBufferBit;
                if (!boundDepthState.WriteEnable)
                {
                    GL.DepthMask(true);
                    GLHelper.CheckGLErrors();
                    boundDepthState.WriteEnable = true;
                    depthStateDirty             = true;
                }
            }
            if ((options & ClearOptions.StencilBuffer) != 0)
            {
                glClearBufferMask |= ClearBufferMask.StencilBufferBit;
                if (boundStencilState.WriteMask != 0xff)
                {
                    GL.StencilMask(0xff);
                    GLHelper.CheckGLErrors();
                    boundStencilState.WriteMask = 0xff;
                    stencilStateDirty           = true;
                }
            }
            if (boundScissorState.Enable)
            {
                GL.Disable(EnableCap.ScissorTest);
                GLHelper.CheckGLErrors();
                boundScissorState.Enable = false;
                scissorStateDirty        = true;
            }
            GL.Clear(glClearBufferMask);
            GLHelper.CheckGLErrors();
        }
            public FramebufferAttachment(ShaderWindow window, FramebufferAttachmentConfiguration attachmentConfiguration)
            {
                textureName    = attachmentConfiguration.TextureName;
                textureWidth   = attachmentConfiguration.Width.GetValueOrDefault(window.Width);
                textureHeight  = attachmentConfiguration.Height.GetValueOrDefault(window.Height);
                attachment     = attachmentConfiguration.Attachment;
                internalFormat = attachmentConfiguration.InternalFormat;
                format         = attachmentConfiguration.Format;
                type           = attachmentConfiguration.Type;
                clearColor     = attachmentConfiguration.ClearColor;
                clearMask      = attachmentConfiguration.ClearMask;

                texture = window.ResourceManager.Load <Texture>(attachmentConfiguration.TextureName);
                ClearTexture(texture.Id, textureWidth, textureHeight);
            }
Exemple #31
0
 public static void Clear(ClearBufferMask flags)
 {
     gl.glClear((int)flags);
 }
		public static void BlitFramebuffer(Int32 srcX0, Int32 srcY0, Int32 srcX1, Int32 srcY1, Int32 dstX0, Int32 dstY0, Int32 dstX1, Int32 dstY1, ClearBufferMask mask, Int32 filter)
		{
			Debug.Assert(Delegates.pglBlitFramebuffer != null, "pglBlitFramebuffer not implemented");
			Delegates.pglBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, (UInt32)mask, filter);
			LogFunction("glBlitFramebuffer({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, LogEnumName(filter));
			DebugCheckErrors(null);
		}
Exemple #33
0
		public static void Clear(ClearBufferMask mask)
		{
#if USE_OPENGL
			if (openGlHardwareAvailable)
			{
				OpenTK.Graphics.OpenGL.GL.Clear((OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
			}
#else
			OpenTK.Graphics.ES11.GL.Clear((OpenTK.Graphics.ES11.ClearBufferMask)mask);
#endif
		}
 /// <summary>
 /// Generally called before Spritebatch.Begin()
 /// </summary>
 public static void Clear(ClearBufferMask mask)
 {
     GL.Clear(mask);
 }
 internal void GLBlitFramebufferApple(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, ClearBufferMask mask, TextureMagFilter filter)
 {
     GLResolveMultisampleFramebufferApple();
 }
Exemple #36
0
		public static void Clear(ClearBufferMask mask)
		{
			glClear deleg = BaseGraphicsContext.Current.Loader.Get<glClear>();
			if (deleg != null)
				deleg(mask);
		}
Exemple #37
0
		public static void Clear(ClearBufferMask mask)
		{
			Debug.Assert(Delegates.pglClear != null, "pglClear not implemented");
			Delegates.pglClear((UInt32)mask);
			CallLog("glClear({0})", mask);
			DebugCheckErrors();
		}
Exemple #38
0
		public void Clear(ClearBufferMask mask)
		{
			GL.Clear((global::OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
		}
 public static void BlitFramebufferEXT( int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, ClearBufferMask mask, uint filter )
 {
     if (_BlitFramebufferEXT == null) throw new Exception( "Extension method BlitFramebufferEXT not found" );
      _BlitFramebufferEXT( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
 }
Exemple #40
0
		internal static extern void glClear(ClearBufferMask mask);
 public extern void Clear(ClearBufferMask mask);
Exemple #42
0
        /// <summary>
        /// luo fbo. jos width ja height on 0, käytetään arvoja jotka on jo Width ja Height:ssä 
        /// (ladattu settings.xml tiedostosta)
        /// </summary>
        public FBO(int width, int height, int createColorBuffers, bool createDepthBuffer)
        {
            if (IsSupported == false) return;

            if (fboHandle != 0) return;
            if (width != 0 && height != 0)
            {
                Width = width;
                Height = height;
            }
            else
            {
                Width = WidthS; // aseta settings.xml tiedostossa annetut arvot
                Height = HeightS;
            }

            GL.Ext.GenFramebuffers(1, out fboHandle);
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, fboHandle);

            if (createColorBuffers > 0) // Create Color Tex
            {
                clearFlags = ClearBufferMask.ColorBufferBit;
                colorTexture = new uint[createColorBuffers];
                PixelInternalFormat[] modes = { PixelInternalFormat.Rgba32f, PixelInternalFormat.Rgba16f, PixelInternalFormat.Rgba8 };

                for (int q = 0; q < createColorBuffers; q++)
                {
                    int c;
                    if (Texture.IsFloatTextureSupported) c = 0;
                    else c = 2;

                    // koitetaan luoda texture
                    for (; c < modes.Length; c++)
                    {
                        GL.GenTextures(1, out colorTexture[q]);
                        GL.BindTexture(TextureTarget.Texture2D, colorTexture[q]);
                        if (c < 2)
                            GL.TexImage2D(TextureTarget.Texture2D, 0, modes[c], Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
                        else
                            GL.TexImage2D(TextureTarget.Texture2D, 0, modes[c], Width, Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
                        if (colorTexture[q] > 0 && GL.GetError() == ErrorCode.NoError)
                        {
                            if (c < 2) Log.WriteLine("FBO: float color texture created " + modes[c]);
                            else Log.WriteLine("FBO: color texture created " + modes[c]);
                            break;
                        }
                    }
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
                    GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                    GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext + q, TextureTarget.Texture2D, colorTexture[q], 0);
                }
            }
            else
            {
                GL.DrawBuffer(DrawBufferMode.None);
                GL.ReadBuffer(ReadBufferMode.None);
            }

            if (createDepthBuffer) // Create Depth Tex
            {
                clearFlags |= ClearBufferMask.DepthBufferBit;
                PixelInternalFormat[] modes ={PixelInternalFormat.DepthComponent32f,
                        PixelInternalFormat.DepthComponent32, PixelInternalFormat.DepthComponent24,
                        PixelInternalFormat.DepthComponent16, PixelInternalFormat.DepthComponent };

                int c;
                if (Texture.IsFloatTextureSupported) c = 0;
                else c = 1;

                // koitetaan luoda texture
                for (; c < modes.Length; c++)
                {
                    GL.GenTextures(1, out depthTexture);
                    GL.BindTexture(TextureTarget.Texture2D, depthTexture);
                    if (c == 0)
                        GL.TexImage2D(TextureTarget.Texture2D, 0, modes[c], Width, Height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
                    else
                        GL.TexImage2D(TextureTarget.Texture2D, 0, modes[c], Width, Height, 0, PixelFormat.DepthComponent, PixelType.UnsignedInt, IntPtr.Zero);
                    if (depthTexture > 0 && GL.GetError() == ErrorCode.NoError)
                    {
                        if (c == 0) Log.WriteLine("FBO: float depth texture created " + modes[c]);
                        else Log.WriteLine("FBO: depth texture created " + modes[c]);
                        break;
                    }
                }
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
                GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.DepthAttachmentExt, TextureTarget.Texture2D, depthTexture, 0);

                // This is to allow usage of shadow2DProj function in the shader
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareMode, (int)TextureCompareMode.CompareRToTexture);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareFunc, (int)All.Lequal);

                if (Settings.UseGL3 == false) GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.DepthTextureMode, (int)All.Intensity);
            }

            bool ok = CheckFBOError();

            // using FBO might have changed states, e.g. the FBO might not support stereoscopic views or double buffering
            if (Settings.UseGL3 == false)
            {
                int[] queryinfo = new int[6];
                GL.GetInteger(GetPName.MaxColorAttachmentsExt, out queryinfo[0]);
                GL.GetInteger(GetPName.AuxBuffers, out queryinfo[1]);
                GL.GetInteger(GetPName.MaxDrawBuffers, out queryinfo[2]);
                GL.GetInteger(GetPName.Stereo, out queryinfo[3]);
                GL.GetInteger(GetPName.Samples, out queryinfo[4]);
                GL.GetInteger(GetPName.Doublebuffer, out queryinfo[5]);
                Log.WriteLine("Max ColorBuffers: " + queryinfo[0] + " / Max AuxBuffers: " + queryinfo[1] + " / Max DrawBuffers: " + queryinfo[2] +
                    " / Stereo: " + (queryinfo[3] > 0 ? "true" : "false") + " / Samples: " + queryinfo[4] + " / DoubleBuffer: " + queryinfo[5]);
            }

            if (ok == false)
            {
                IsSupported = false;
                Log.WriteLine("Error: " + GL.GetError());
                return;
            }
            else IsSupported = true;

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // disable rendering into the FBO
            GL.BindTexture(TextureTarget.Texture2D, 0);

            CreateTextures();
        }
 /// <summary>
 /// This function clears the buffers specified by mask.
 /// </summary>
 /// <param name="mask">Which buffers to clear.</param>
 public static void Clear(ClearBufferMask mask)
 {
     OpenGL.Clear((uint)mask);
 }
Exemple #44
0
		public static void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, ClearBufferMask mask, BlitFramebufferFilter filter)
		{
			glBlitFramebuffer deleg = BaseGraphicsContext.Current.Loader.Get<glBlitFramebuffer>();
			if (deleg != null)
				deleg(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
		}
Exemple #45
0
 internal void Clear(ClearBufferMask flags)
 {
     gl.glClear((int)flags);
     CheckException();
 }