コード例 #1
0
        public void SetRenderBuffer(TargetBuffer Target, RenderbufferStorage Format, int Width, int Height, int Number = 0)
        {
            RenderBuffer buffer = new RenderBuffer(Format, Width, Height);

            switch (Target)
            {
            case TargetBuffer.Color:
                if (colorBuffers.ContainsKey(Number))
                {
                    UnBind();
                    colorBuffers[Number].Dispose();
                    Bind();
                }
                colorBuffers[Number] = buffer;
                GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, (FramebufferAttachment)((int)FramebufferAttachment.ColorAttachment0 + Number), RenderbufferTarget.Renderbuffer, buffer.handle);
                break;

            case TargetBuffer.Depth:
                if (depthBuffer != null)
                {
                    UnBind();
                    depthBuffer.Dispose();
                    Bind();
                }
                depthBuffer = buffer;
                GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, buffer.handle);
                break;

            case TargetBuffer.Stencil:
                if (stencilBuffer != null)
                {
                    UnBind();
                    stencilBuffer.Dispose();
                    Bind();
                }
                stencilBuffer = buffer;
                GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, RenderbufferTarget.Renderbuffer, buffer.handle);
                break;
            }
        }
コード例 #2
0
        public void SetTextureBuffer(TargetBuffer Target, PixelInternalFormat InternalFormat, PixelFormat Format, PixelType Type, int Width, int Height, int Number = 0)
        {
            TextureBuffer buffer = new TextureBuffer(InternalFormat, Format, Type, Width, Height);

            switch (Target)
            {
            case TargetBuffer.Color:
                if (colorBuffers.ContainsKey(Number))
                {
                    UnBind();
                    colorBuffers[Number].Dispose();
                    Bind();
                }
                colorBuffers[Number] = buffer;
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, (FramebufferAttachment)((int)FramebufferAttachment.ColorAttachment0 + Number), TextureTarget.Texture2D, buffer.handle, 0);
                break;

            case TargetBuffer.Depth:
                if (depthBuffer != null)
                {
                    UnBind();
                    depthBuffer.Dispose();
                    Bind();
                }
                depthBuffer = buffer;
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, buffer.handle, 0);
                break;

            case TargetBuffer.Stencil:
                if (stencilBuffer != null)
                {
                    UnBind();
                    stencilBuffer.Dispose();
                    Bind();
                }
                stencilBuffer = buffer;
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, TextureTarget.Texture2D, buffer.handle, 0);
                break;
            }
        }