public BasePane AddNewPicturePane()
        {
            BasePane pane = null;

            if (ActiveLayout is BFLYT.Header)
            {
                pane = new BFLYT.PIC1((BFLYT.Header)ActiveLayout, RenamePane("P_pict"));
            }

            if (pane != null)
            {
                pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
                ((IPicturePane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((IPicturePane)pane).Material);
                ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
            }

            return(pane);
        }
        private void DrawPicturePane(BFLYT.PIC1 pane, byte effectiveAlpha)
        {
            Vector2[] TexCoords = new Vector2[] {
                new Vector2(1, 1),
                new Vector2(0, 1),
                new Vector2(0, 0),
                new Vector2(1, 0)
            };

            Color[] Colors = new Color[] {
                pane.ColorTopLeft.Color,
                pane.ColorTopRight.Color,
                pane.ColorBottomRight.Color,
                pane.ColorBottomLeft.Color,
            };

            var mat = pane.Material;

            bool defaultShading = Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.Default;

            SetBlending(mat.BlackColor.Color, mat.WhiteColor.Color);
            if (pane.TexCoords.Length > 0 && defaultShading)
            {
                string textureMap0 = "";
                if (mat.TextureMaps.Length > 0)
                {
                    textureMap0 = mat.GetTexture(0);
                }

                if (Textures.ContainsKey(textureMap0))
                {
                    BindGLTexture(mat.TextureMaps[0], Textures[textureMap0]);
                }
                else if (mat.TextureMaps.Length > 0)
                {
                }

                if (mat.TextureTransforms.Length > 0)
                {
                    GL.MatrixMode(MatrixMode.Texture);
                    GL.LoadIdentity();

                    var transform = mat.TextureTransforms[0];
                    GL.Scale(transform.Scale.X, transform.Scale.Y, 1);
                    GL.Rotate(transform.Rotate, 1, 0, 0);
                    GL.Translate(transform.Translate.X, transform.Translate.Y, 1);

                    GL.MatrixMode(MatrixMode.Modelview);
                }

                TexCoords = new Vector2[] {
                    pane.TexCoords[0].TopLeft.ToTKVector2(),
                    pane.TexCoords[0].TopRight.ToTKVector2(),
                    pane.TexCoords[0].BottomRight.ToTKVector2(),
                    pane.TexCoords[0].BottomLeft.ToTKVector2(),
                };
            }

            if (pane.TexCoords.Length > 0 && Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.UVTestPattern)
            {
                GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
                if (mat.TextureMaps.Length > 0)
                {
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, ConvertTextureWrap(mat.TextureMaps[0].WrapModeU));
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, ConvertTextureWrap(mat.TextureMaps[0].WrapModeV));
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, ConvertMagFilterMode(mat.TextureMaps[0].MaxFilterMode));
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, ConvertMinFilterMode(mat.TextureMaps[0].MinFilterMode));
                }
            }

            if (Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.BlackColor)
            {
                for (int i = 0; i < Colors.Length; i++)
                {
                    Colors[i] = pane.Material.BlackColor.Color;
                }
            }

            if (Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.WhiteColor)
            {
                for (int i = 0; i < Colors.Length; i++)
                {
                    Colors[i] = pane.Material.WhiteColor.Color;
                }
            }

            DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);

            GL.BindTexture(TextureTarget.Texture2D, 0);

            //   GL.PopAttrib();
            //    GL.PopAttrib();
        }