Exemplo n.º 1
0
        internal void Unbind()
        {
            if (!bound)
            {
                return;
            }

            if (OsuGlControl.CanUseFBO)
            {
                currentFrameBuffer = lastFrameBuffer;
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, lastFrameBuffer);
            }
            else
            {
                //Copy from backbuffer
                OsuGlControl.BindTexture(Texture.TextureId);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);

                GL.CopyTexSubImage2D(All.Texture2D, 0, (int)copyDstPosition.X, (int)copyDstPosition.Y, copySrcRectangle.X, copySrcRectangle.Y, copySrcRectangle.Width, copySrcRectangle.Height);
            }

            if (OsuGlControl.Viewport != prevViewport)
            {
                OsuGlControl.ResetViewport(prevViewport);
                OsuGlControl.ResetOrtho(prevOrtho);
            }

            bound = false;
        }
Exemplo n.º 2
0
        internal void Bind()
        {
            if (bound)
            {
                return;
            }

            prevViewport = OsuGlControl.Viewport;
            prevOrtho    = OsuGlControl.Ortho;

            if (OsuGlControl.CanUseFBO)
            {
                lastFrameBuffer    = currentFrameBuffer;
                currentFrameBuffer = frameBuffer;
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            }

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //For now we have this conditional here to reduce GL calls
            //This will be removed in peppy/more_gl_stuff (among a whole slew of other things)
            if (viewport != prevViewport)
            {
                OsuGlControl.ResetViewport(viewport);
                OsuGlControl.ResetOrtho(viewport);
            }

            bound = true;
        }