Beispiel #1
0
        public void Use(int width, int height)
        {
#if nomsaa
            return;
#else
            if (width <= 0 || height <= 0)
            {
                return;
            }
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, Framebuffer);
            if (width != Width || height != Height)
            {
                Width  = width;
                Height = height;
                System.Diagnostics.Debug.WriteLine("width: " + width + " height: " + height);

                SafeFrameBuffer.BindRenderbuffer(RenderbufferTarget.Renderbuffer, _renderbuffer);
                SafeFrameBuffer.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, MSAA, RenderbufferStorage.Rgba8, width, height);
                SafeFrameBuffer.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, RenderbufferTarget.Renderbuffer, _renderbuffer);
                SafeFrameBuffer.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0);
                ErrorCheck();
            }
            ErrorCheck();
            GL.Clear(ClearBufferMask.ColorBufferBit);
#endif
        }
        public void Use(int width, int height)
        {
#if nomsaa
            return;
#else
            if (width <= 0 || height <= 0)
            {
                return;
            }
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, Framebuffer);
            if (width != Width || height != Height)
            {
                Width  = width;
                Height = height;

                SafeFrameBuffer.BindRenderbuffer(RenderbufferTarget.Renderbuffer, _renderbuffer);
                SafeFrameBuffer.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, MSAA, RenderbufferStorage.Rgba8, width, height);

                SafeFrameBuffer.BindRenderbuffer(RenderbufferTarget.Renderbuffer, _stencilbuffer);
                SafeFrameBuffer.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, MSAA, RenderbufferStorage.Depth24Stencil8, width, height);

                SafeFrameBuffer.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, RenderbufferTarget.Renderbuffer, _stencilbuffer);

                SafeFrameBuffer.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, RenderbufferTarget.Renderbuffer, _renderbuffer);
                SafeFrameBuffer.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0);
                ErrorCheck();
            }
            ErrorCheck();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
#endif
        }
Beispiel #3
0
        public MsaaFbo()
        {
            Framebuffer = SafeFrameBuffer.GenFramebuffer();
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, Framebuffer);
            _renderbuffer = SafeFrameBuffer.GenRenderbuffer();

            MSAA = Math.Min(8, GL.GetInteger(GetPName.MaxSamples));
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
Beispiel #4
0
        public void End()
        {
#if nomsaa
            return;
#else
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.DrawFramebuffer, 0);//default
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.ReadFramebuffer, Framebuffer);
            SafeFrameBuffer.BlitFramebuffer(0, 0, Width, Height,
                                            0, 0, Width, Height,
                                            ClearBufferMask.ColorBufferBit,
                                            BlitFramebufferFilter.Linear);
            ErrorCheck();
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
#endif
        }