public ITexture Bind(bool CreateNewTexture, Size size)
        {
            VerifyThreadAffinity();

            // Cache viewport rect to restore when unbinding
            cv = ViewportRectangle();

            OpenGL.glFlush();
            OpenGL.CheckGLError();
            OpenGL.glBindFramebuffer(OpenGL.FRAMEBUFFER_EXT, framebuffer);
            OpenGL.CheckGLError();
            ITextureInternal tex = null;

            if (CreateNewTexture)
            {
                tex = new Texture();
            }

            this.texture.Add(tex);
            tex.SetEmpty(size.Width, size.Height);

            OpenGL.glFramebufferTexture2D(OpenGL.FRAMEBUFFER_EXT, OpenGL.COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, tex.ID, 0);
            OpenGL.CheckGLError();

            OpenGL.glViewport(0, 0, size.Width, size.Height);
            OpenGL.CheckGLError();
            OpenGL.glClearColor(0, 0, 0, 0);
            OpenGL.CheckGLError();
            OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            OpenGL.CheckGLError();
            return(tex);
        }
Exemple #2
0
 public void Unbind()
 {
     VerifyThreadAffinity();
     OpenGL.glFlush();
     OpenGL.CheckGLError();
     OpenGL.glBindFramebuffer(OpenGL.FRAMEBUFFER_EXT, 0);
     OpenGL.CheckGLError();
     OpenGL.glViewport(cv[0], cv[1], cv[2], cv[3]);
     OpenGL.CheckGLError();
 }
Exemple #3
0
        public void Unbind()
        {
            if (scissored)
            {
                throw new InvalidOperationException("Attempting to unbind FrameBuffer with an active scissor region.");
            }

            VerifyThreadAffinity();
            OpenGL.glFlush();
            OpenGL.CheckGLError();
            OpenGL.glBindFramebuffer(OpenGL.GL_FRAMEBUFFER, 0);
            OpenGL.CheckGLError();
            OpenGL.glViewport(cv[0], cv[1], cv[2], cv[3]);
            OpenGL.CheckGLError();
        }
Exemple #4
0
        public void Bind()
        {
            VerifyThreadAffinity();

            // Cache viewport rect to restore when unbinding
            cv = ViewportRectangle();

            OpenGL.glFlush();
            OpenGL.CheckGLError();
            OpenGL.glBindFramebuffer(OpenGL.GL_FRAMEBUFFER, framebuffer);
            OpenGL.CheckGLError();
            OpenGL.glViewport(0, 0, size.Width, size.Height);
            OpenGL.CheckGLError();
            OpenGL.glClearColor(clearColor.R, clearColor.G, clearColor.B, clearColor.A);
            OpenGL.CheckGLError();
            OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            OpenGL.CheckGLError();
        }
        public ITexture Bind(bool returnTexture)
        {
            VerifyThreadAffinity();

            // Cache viewport rect to restore when unbinding
            cv = ViewportRectangle();

            OpenGL.glFlush();
            OpenGL.CheckGLError();
            OpenGL.glBindFramebuffer(OpenGL.FRAMEBUFFER_EXT, framebuffer);
            OpenGL.CheckGLError();
            OpenGL.glViewport(0, 0, size.Width, size.Height);
            OpenGL.CheckGLError();
            OpenGL.glClearColor(0, 0, 0, 0);
            OpenGL.CheckGLError();
            OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            OpenGL.CheckGLError();
            return(this.Texture[0]);            //возвращем самую первую текстуру из коллекции
        }
        public void ReBind(ITextureInternal t)
        {
            VerifyThreadAffinity();

            // Cache viewport rect to restore when unbinding
            cv = ViewportRectangle();

            OpenGL.glFlush();
            OpenGL.CheckGLError();
            OpenGL.glBindFramebuffer(OpenGL.FRAMEBUFFER_EXT, framebuffer);
            OpenGL.CheckGLError();


            OpenGL.glFramebufferTexture2D(OpenGL.FRAMEBUFFER_EXT, OpenGL.COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, t.ID, 0);
            OpenGL.CheckGLError();

            OpenGL.glViewport(0, 0, size.Width, size.Height);
            OpenGL.CheckGLError();
            OpenGL.glClearColor(0, 0, 0, 0);
            OpenGL.CheckGLError();
            OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            OpenGL.CheckGLError();
        }