public GLShaderFilter SetSize(int Width, int Height)
        {
            if (Width != this.Width || Height != this.Height)
            {
                //Console.WriteLine("{0}x{1}", Width, Height);
                RenderTarget?.Dispose();
                RenderTarget = GLRenderTarget.Create(Width, Height, RenderTargetLayers.Color);
                //this.RenderTarget = GLRenderTarget.Create(Width, Height);
            }

            return(this);
        }
 public GLRenderTarget Bind()
 {
     if (Current != this)
     {
         Current?.Unbind();
     }
     Current = this;
     GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, FrameBufferId);
     {
         BindBuffers();
     }
     return(this);
 }
Esempio n. 3
0
        /// <summary>
        /// Copies a RenderTarget from one to another
        /// </summary>
        /// <param name="From"></param>
        /// <param name="To"></param>
        public static void CopyFromTo(GLRenderTarget From, GLRenderTarget To)
        {
            Contract.Assert(From != null);
            Contract.Assert(To != null);

            From.BindUnbind(() =>
            {
                To.TextureColor?.BindUnbind(() =>
                {
                    GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA4, 0, 0, From.Width, From.Height, 0);
                });

                To.TextureDepth?.BindUnbind(() =>
                {
                    GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT, 0, 0, From.Width,
                                        From.Height, 0);
                });
            });
        }
Esempio n. 4
0
            private void UpdateTextures(int ScaleViewport)
            {
                if (CurrentScaleViewport == ScaleViewport) return;
                CurrentScaleViewport = ScaleViewport;
                MustUpdateRenderTarget = false;

                if (RenderTarget != null) RenderTarget.Dispose();

                RenderTarget = GLRenderTarget.Create(
                    Width = 512 * ScaleViewport,
                    Height = 272 * ScaleViewport
                );
                //Console.WriteLine(OpenglContextFactory.Current);
                //Console.WriteLine(RenderTarget);
                //Console.ReadKey();
            }
Esempio n. 5
0
        public GLShaderFilter SetSize(int Width, int Height)
        {
            if (Width != this.Width || Height != this.Height)
            {
                //Console.WriteLine("{0}x{1}", Width, Height);
                if (this.RenderTarget != null) this.RenderTarget.Dispose();
                this.RenderTarget = GLRenderTarget.Create(Width, Height, RenderTargetLayers.Color);
                //this.RenderTarget = GLRenderTarget.Create(Width, Height);
            }

            return this;
        }
Esempio n. 6
0
        /// <summary>
        /// Copies a RenderTarget from one to another
        /// </summary>
        /// <param name="From"></param>
        /// <param name="To"></param>
        public static void CopyFromTo(GLRenderTarget From, GLRenderTarget To)
        {
            Contract.Assert(From != null);
            Contract.Assert(To != null);

            From.BindUnbind(() =>
            {
                if (To.TextureColor != null)
                {
                    To.TextureColor.BindUnbind(() =>
                    {
                        GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA4, 0, 0, From.Width, From.Height, 0);
                    });
                }

                if (To.TextureDepth != null)
                {
                    To.TextureDepth.BindUnbind(() =>
                    {
                        GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT, 0, 0, From.Width, From.Height, 0);
                    });
                }
            });
        }
Esempio n. 7
0
 public GLRenderTarget Bind()
 {
     if (Current != this && Current != null)
     {
         Current.Unbind();
     }
     Current = this;
     GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, FrameBufferId);
     {
         BindBuffers();
     }
     return this;
 }