private void drawChildren(Action <TexturedVertex2D> vertexAction, Vector2 frameBufferSize)
        {
            // Fill the frame buffer with drawn children
            using (bindFrameBuffer(currentFrameBuffer, frameBufferSize))
            {
                // We need to draw children as if they were zero-based to the top-left of the texture.
                // We can do this by adding a translation component to our (orthogonal) projection matrix.
                GLWrapper.PushOrtho(ScreenSpaceDrawRectangle);

                GLWrapper.ClearColour(BackgroundColour);
                base.Draw(vertexAction);

                GLWrapper.PopOrtho();
            }
        }
        protected override void PostDraw()
        {
            frameBuffer.Unbind();

            GLWrapper.PopOrtho();
            GLWrapper.PopViewport();

            GLWrapper.SetBlend(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);

            Rectangle textureRect = new Rectangle(0, frameBuffer.Texture.Height, frameBuffer.Texture.Width, -frameBuffer.Texture.Height);

            frameBuffer.Texture.Draw(ScreenSpaceDrawQuad, textureRect, DrawInfo.Colour, quadBatch);

            // In the case of nested framebuffer containerse we need to draw to
            // the last framebuffer container immediately, so let's force it
            ActiveBatch.Draw();
        }
        public sealed override void Draw(Action <TexturedVertex2D> vertexAction)
        {
            if (RequiresRedraw)
            {
                FrameStatistics.Increment(StatisticsCounterType.FBORedraw);

                SharedData.ResetCurrentEffectBuffer();

                using (establishFrameBufferViewport())
                {
                    // Fill the frame buffer with drawn children
                    using (BindFrameBuffer(SharedData.MainBuffer))
                    {
                        // We need to draw children as if they were zero-based to the top-left of the texture.
                        // We can do this by adding a translation component to our (orthogonal) projection matrix.
                        GLWrapper.PushOrtho(screenSpaceDrawRectangle);
                        GLWrapper.Clear(new ClearInfo(backgroundColour));

                        Child.Draw(vertexAction);

                        GLWrapper.PopOrtho();
                    }

                    PopulateContents();
                }

                SharedData.DrawVersion = GetDrawVersion();
            }

            Shader.Bind();

            base.Draw(vertexAction);
            DrawContents();

            Shader.Unbind();
        }