Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTarget" /> class.
        /// </summary>
        /// <param name="buffers">The render target buffers.</param>
        /// <param name="colorSpace">The render target color space.</param>
        /// <param name="sampling">The render target buffer sampling options.</param>
        public RenderTarget(TargetBuffers buffers = TargetBuffers.Color0, ColorSpace colorSpace = ColorSpace.Linear, Sampling sampling = Sampling.None)
        {
            if (buffers == TargetBuffers.None)
            {
                throw new ArgumentException("Render target must have at least one buffer.", nameof(buffers));
            }

            if ((buffers & TargetBuffers.Color0) == TargetBuffers.Color0)
            {
                this.Color0 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color1) == TargetBuffers.Color1)
            {
                this.Color1 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color2) == TargetBuffers.Color2)
            {
                this.Color2 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.Color3) == TargetBuffers.Color3)
            {
                this.Color3 = new Texture2D(null, colorSpace, sampling);
            }

            if ((buffers & TargetBuffers.DepthStencil) == TargetBuffers.DepthStencil)
            {
                this.DepthStencil = new Texture2D(null, ColorSpace.sRGB, sampling & ~Sampling.Mipmap);
            }
        }
Exemple #2
0
        /// <summary>
        /// Configures the render target.
        /// </summary>
        /// <param name="width">The render target width in pixels.</param>
        /// <param name="height">The render target height in pixels.</param>
        /// <param name="renderTarget">The render target. Null selects the default render target.</param>
        public static void Target(int width, int height, RenderTarget renderTarget = null)
        {
            Width = width;
            Height = height;

            if (renderTarget != null)
            {
                currentTargetBuffers = renderTarget.Initialize(width, height);
            }
            else if (RenderTarget != null)
            {
                gl.BindFramebuffer(GL.FRAMEBUFFER, 0);
                gl.BindRenderbuffer(GL.RENDERBUFFER, 0);
                currentTargetBuffers = TargetBuffers.Color0 | TargetBuffers.DepthStencil;
            }

            RenderTarget = renderTarget;

            gl.Viewport(0, 0, width, height);
        }