示例#1
0
        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);
        }
 public void Clear()
 {
     VerifyThreadAffinity();
     OpenGL.glClearColor(0, 0, 0, 1);
     OpenGL.CheckGLError();
     OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
     OpenGL.CheckGLError();
 }
示例#3
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();
        }
示例#4
0
        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]);            //возвращем самую первую текстуру из коллекции
        }
示例#5
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();
        }