Example #1
0
        private void RenderContent(CLYT Layout, int InfluenceAlpha, float Width, float Height)
        {
            SetupMaterial(Layout, Content.MaterialId);

            float[,] Vertex2 = SetupRect(Width, Height);
            float[][] VtxColor = SetupVtxColors(InfluenceAlpha);
            GL.Begin(PrimitiveType.Quads);

            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0 + o,
                                  Content.TexCoordEntries[o].TexCoordLT.X, Content.TexCoordEntries[o].TexCoordLT.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
            }
            GL.Color4(VtxColor[0][0], VtxColor[0][1], VtxColor[0][2], VtxColor[0][3]);
            GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0 + o,
                                  Content.TexCoordEntries[o].TexCoordRT.X, Content.TexCoordEntries[o].TexCoordRT.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
            }
            GL.Color4(VtxColor[1][0], VtxColor[1][1], VtxColor[1][2], VtxColor[1][3]);
            GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0 + o,
                                  Content.TexCoordEntries[o].TexCoordRB.X, Content.TexCoordEntries[o].TexCoordRB.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0, 1, 1);
            }
            GL.Color4(VtxColor[2][0], VtxColor[2][1], VtxColor[2][2], VtxColor[2][3]);
            GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0 + o,
                                  Content.TexCoordEntries[o].TexCoordLB.X, Content.TexCoordEntries[o].TexCoordLB.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
            }
            GL.Color4(VtxColor[3][0], VtxColor[3][1], VtxColor[3][2], VtxColor[3][3]);
            GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
            GL.End();
        }
        private void RenderContent(CLYT Layout, int InfluenceAlpha, float Width, float Height)
        {
            SetupMaterial(Layout, Content.MaterialId);

            float[,] Vertex2 = SetupRect(Width, Height);
            float[][] VtxColor = SetupVtxColors(InfluenceAlpha);
            Gl.glBegin(Gl.GL_QUADS);

            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                     Content.TexCoordEntries[o].TexCoordLT.X, Content.TexCoordEntries[o].TexCoordLT.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 0, 0);
            }
            Gl.glColor4f(VtxColor[0][0], VtxColor[0][1], VtxColor[0][2], VtxColor[0][3]);
            Gl.glVertex3f(Vertex2[0, 0], Vertex2[0, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                     Content.TexCoordEntries[o].TexCoordRT.X, Content.TexCoordEntries[o].TexCoordRT.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 1, 0);
            }
            Gl.glColor4f(VtxColor[1][0], VtxColor[1][1], VtxColor[1][2], VtxColor[1][3]);
            Gl.glVertex3f(Vertex2[1, 0], Vertex2[1, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                     Content.TexCoordEntries[o].TexCoordRB.X, Content.TexCoordEntries[o].TexCoordRB.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 1, 1);
            }
            Gl.glColor4f(VtxColor[2][0], VtxColor[2][1], VtxColor[2][2], VtxColor[2][3]);
            Gl.glVertex3f(Vertex2[2, 0], Vertex2[2, 1], 0);
            for (int o = 0; o < Content.TexCoordEntries.Length; o++)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                     Content.TexCoordEntries[o].TexCoordLB.X, Content.TexCoordEntries[o].TexCoordLB.Y);
            }
            if (Content.TexCoordEntries.Length == 0)
            {
                Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 0, 1);
            }
            Gl.glColor4f(VtxColor[3][0], VtxColor[3][1], VtxColor[3][2], VtxColor[3][3]);
            Gl.glVertex3f(Vertex2[3, 0], Vertex2[3, 1], 0);
            Gl.glEnd();
        }
Example #3
0
 public virtual void Render(CLYT Layout, CLIM[] Textures, int InfluenceAlpha)
 {
     Gl.glPushMatrix();
     {
         Gl.glTranslatef(Translation.X, Translation.Y, Translation.Z);
         Gl.glRotatef(Rotation.X, 1, 0, 0);
         Gl.glRotatef(Rotation.Y, 0, 1, 0);
         Gl.glRotatef(Rotation.Z, 0, 0, 1);
         Gl.glScalef(Scale.X, Scale.Y, 1);
         foreach (pan1 p in Children)
         {
             p.Render(Layout, Textures, InfluencedAlpha ? (int)((float)(Alpha * InfluenceAlpha) / 255f) : Alpha);
         }
     }
     Gl.glPopMatrix();
 }
Example #4
0
        protected static void SetupMaterial(CLYT Layout, int MatId)
        {
            var mat = Layout.Materials.Materials[MatId];

            mat.ApplyAlphaCompareBlendMode();

            for (int o = 0; o < mat.TexMaps.Length; o++)
            {
                Gl.glActiveTexture(Gl.GL_TEXTURE0 + o);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, MatId * 4 + o + 1);
                Gl.glEnable(Gl.GL_TEXTURE_2D);
            }
            if (mat.TexMaps.Length == 0)
            {
                Gl.glActiveTexture(Gl.GL_TEXTURE0);
                Gl.glColor4f(1, 1, 1, 1);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, MatId * 4 + 1);
                Gl.glEnable(Gl.GL_TEXTURE_2D);
            }

            Gl.glMatrixMode(Gl.GL_TEXTURE);
            for (int o = 0; o < mat.TexCoordGens.Length; o++)
            {
                Gl.glActiveTexture(Gl.GL_TEXTURE0 + o);
                Gl.glLoadIdentity();
                //if ((int)mat.TexCoordGens[o].Source < 4)
                //{
                mat1.MaterialEntry.TexMatrix srt = mat.TexMatrices[o];                //(int)mat.TexCoordGens[o].Source];
                Gl.glTranslatef(0.5f, 0.5f, 0.0f);
                Gl.glRotatef(srt.Rotation, 0.0f, 0.0f, 1.0f);
                Gl.glScalef(srt.Scale.X, srt.Scale.Y, 1.0f);
                Gl.glTranslatef(srt.Translation.X / srt.Scale.X - 0.5f, srt.Translation.Y / srt.Scale.Y - 0.5f, 0.0f);
                //}
                //else
                //{

                //}
            }
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            mat.GlShader.Enable();
        }
Example #5
0
        protected static void SetupMaterial(CLYT Layout, int MatId)
        {
            var mat = Layout.Materials.Materials[MatId];

            mat.ApplyAlphaCompareBlendMode();

            for (int o = 0; o < mat.TexMaps.Length; o++)
            {
                GL.ActiveTexture(TextureUnit.Texture0 + o);
                GL.BindTexture(TextureTarget.Texture2D, MatId * 4 + o + 1);
                GL.Enable(EnableCap.Texture2D);
            }
            if (mat.TexMaps.Length == 0)
            {
                GL.ActiveTexture(TextureUnit.Texture0);
                GL.Color4(1, 1, 1, 1);
                GL.BindTexture(TextureTarget.Texture2D, MatId * 4 + 1);
                GL.Enable(EnableCap.Texture2D);
            }

            GL.MatrixMode(MatrixMode.Texture);
            for (int o = 0; o < mat.TexCoordGens.Length; o++)
            {
                GL.ActiveTexture(TextureUnit.Texture0 + o);
                GL.LoadIdentity();
                //if ((int)mat.TexCoordGens[o].Source < 4)
                //{
                mat1.MaterialEntry.TexMatrix srt = mat.TexMatrices[o];                //(int)mat.TexCoordGens[o].Source];
                GL.Translate(0.5f, 0.5f, 0.0f);
                GL.Rotate(srt.Rotation, 0.0f, 0.0f, 1.0f);
                GL.Scale(srt.Scale.X, srt.Scale.Y, 1.0f);
                GL.Translate(srt.Translation.X / srt.Scale.X - 0.5f, srt.Translation.Y / srt.Scale.Y - 0.5f, 0.0f);
                //}
                //else
                //{

                //}
            }
            GL.MatrixMode(MatrixMode.Modelview);
            mat.GlShader.Enable();
        }
Example #6
0
        public override void Render(CLYT Layout, CLIM[] Textures, int InfluenceAlpha)
        {
            GL.PushMatrix();
            {
                SetupMaterial(Layout, MaterialId);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.Translate(Translation.X, Translation.Y, Translation.Z);
                GL.Rotate(Rotation.X, 1, 0, 0);
                GL.Rotate(Rotation.Y, 0, 1, 0);
                GL.Rotate(Rotation.Z, 0, 0, 1);
                GL.Scale(Scale.X, Scale.Y, 1);
                GL.PushMatrix();
                {
                    GL.Translate(-0.5f * Size.X * (float)HAlignment, -0.5f * Size.Y * (-(float)VAlignment), 0);
                    float[,] Vertex2 = SetupRect();
                    float[][] VtxColor = SetupVtxColors(InfluenceAlpha);
                    GL.Begin(PrimitiveType.Quads);

                    /*for (int o = 0; o < TexCoordEntries.Length; o++)
                     * {
                     *      GL.glMultiTexCoord2f(GL.GL_TEXTURE0 + o,
                     *              TexCoordEntries[o].TexCoordLT.X, TexCoordEntries[o].TexCoordLT.Y);
                     * }
                     * if (TexCoordEntries.Length == 0)*/GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                    GL.Color4(VtxColor[0][0], VtxColor[0][1], VtxColor[0][2], VtxColor[0][3]);
                    GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                    /*for (int o = 0; o < TexCoordEntries.Length; o++)
                     * {
                     *      GL.glMultiTexCoord2f(GL.GL_TEXTURE0 + o,
                     *              TexCoordEntries[o].TexCoordRT.X, TexCoordEntries[o].TexCoordRT.Y);
                     * }
                     * if (TexCoordEntries.Length == 0)*/GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
                    GL.Color4(VtxColor[1][0], VtxColor[1][1], VtxColor[1][2], VtxColor[1][3]);
                    GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                    /*for (int o = 0; o < TexCoordEntries.Length; o++)
                     * {
                     *      GL.glMultiTexCoord2f(GL.GL_TEXTURE0 + o,
                     *              TexCoordEntries[o].TexCoordRB.X, TexCoordEntries[o].TexCoordRB.Y);
                     * }
                     * if (TexCoordEntries.Length == 0)*/GL.MultiTexCoord2(TextureUnit.Texture0, 1, 1);
                    GL.Color4(VtxColor[2][0], VtxColor[2][1], VtxColor[2][2], VtxColor[2][3]);
                    GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                    /*for (int o = 0; o < TexCoordEntries.Length; o++)
                     * {
                     *      GL.glMultiTexCoord2f(GL.GL_TEXTURE0 + o,
                     *              TexCoordEntries[o].TexCoordLB.X, TexCoordEntries[o].TexCoordLB.Y);
                     * }
                     * if (TexCoordEntries.Length == 0)*/GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                    GL.Color4(VtxColor[3][0], VtxColor[3][1], VtxColor[3][2], VtxColor[3][3]);
                    GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                    GL.End();
                }
                GL.PopMatrix();
                foreach (pan1 p in Children)
                {
                    p.Render(Layout, Textures, InfluencedAlpha ? (int)((float)(Alpha * InfluenceAlpha) / 255f) : Alpha);
                }
            }
            GL.PopMatrix();
        }
Example #7
0
        public override void Render(CLYT Layout, CLIM[] Textures, int InfluenceAlpha)
        {
            Gl.glPushMatrix();
            {
                SetupMaterial(Layout, MaterialId);
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glTranslatef(Translation.X, Translation.Y, Translation.Z);
                Gl.glRotatef(Rotation.X, 1, 0, 0);
                Gl.glRotatef(Rotation.Y, 0, 1, 0);
                Gl.glRotatef(Rotation.Z, 0, 0, 1);
                Gl.glScalef(Scale.X, Scale.Y, 1);
                Gl.glPushMatrix();
                {
                    Gl.glTranslatef(-0.5f * Size.X * (float)HAlignment, -0.5f * Size.Y * (-(float)VAlignment), 0);
                    float[,] Vertex2 = SetupRect();
                    float[][] VtxColor = SetupVtxColors(InfluenceAlpha);
                    Gl.glBegin(Gl.GL_QUADS);

                    for (int o = 0; o < TexCoordEntries.Length; o++)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                             TexCoordEntries[o].TexCoordLT.X, TexCoordEntries[o].TexCoordLT.Y);
                    }
                    if (TexCoordEntries.Length == 0)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 0, 0);
                    }
                    Gl.glColor4f(VtxColor[0][0], VtxColor[0][1], VtxColor[0][2], VtxColor[0][3]);
                    Gl.glVertex3f(Vertex2[0, 0], Vertex2[0, 1], 0);
                    for (int o = 0; o < TexCoordEntries.Length; o++)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                             TexCoordEntries[o].TexCoordRT.X, TexCoordEntries[o].TexCoordRT.Y);
                    }
                    if (TexCoordEntries.Length == 0)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 1, 0);
                    }
                    Gl.glColor4f(VtxColor[1][0], VtxColor[1][1], VtxColor[1][2], VtxColor[1][3]);
                    Gl.glVertex3f(Vertex2[1, 0], Vertex2[1, 1], 0);
                    for (int o = 0; o < TexCoordEntries.Length; o++)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                             TexCoordEntries[o].TexCoordRB.X, TexCoordEntries[o].TexCoordRB.Y);
                    }
                    if (TexCoordEntries.Length == 0)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 1, 1);
                    }
                    Gl.glColor4f(VtxColor[2][0], VtxColor[2][1], VtxColor[2][2], VtxColor[2][3]);
                    Gl.glVertex3f(Vertex2[2, 0], Vertex2[2, 1], 0);
                    for (int o = 0; o < TexCoordEntries.Length; o++)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0 + o,
                                             TexCoordEntries[o].TexCoordLB.X, TexCoordEntries[o].TexCoordLB.Y);
                    }
                    if (TexCoordEntries.Length == 0)
                    {
                        Gl.glMultiTexCoord2f(Gl.GL_TEXTURE0, 0, 1);
                    }
                    Gl.glColor4f(VtxColor[3][0], VtxColor[3][1], VtxColor[3][2], VtxColor[3][3]);
                    Gl.glVertex3f(Vertex2[3, 0], Vertex2[3, 1], 0);
                    Gl.glEnd();
                }
                Gl.glPopMatrix();
                foreach (pan1 p in Children)
                {
                    p.Render(Layout, Textures, InfluencedAlpha ? (int)((float)(Alpha * InfluenceAlpha) / 255f) : Alpha);
                }
            }
            Gl.glPopMatrix();
        }
Example #8
0
        public override void Render(CLYT Layout, CLIM[] Textures, int InfluenceAlpha)
        {
            GL.PushMatrix();
            {
                GL.MatrixMode(MatrixMode.Modelview);
                GL.Translate(Translation.X, Translation.Y, Translation.Z);
                GL.Rotate(Rotation.X, 1, 0, 0);
                GL.Rotate(Rotation.Y, 0, 1, 0);
                GL.Rotate(Rotation.Z, 0, 0, 1);
                GL.Scale(Scale.X, Scale.Y, 1);
                GL.PushMatrix();
                {
                    //Translate to origin
                    GL.Translate(-0.5f * Size.X * (float)HAlignment, -0.5f * Size.Y * (-(float)VAlignment), 0);
                    switch (Kind)
                    {
                    case WindowKind.Around:
                        if (NrFrames == 1)                                //1 texture for all
                        {
                            mat1.MaterialEntry m = Layout.Materials.Materials[WindowFrames[0].MaterialId];
                            if (m.TexMaps.Length == 0)
                            {
                                RenderContent(Layout, InfluenceAlpha, Size.X, Size.Y);
                            }
                            else
                            {
                                var t = Textures[m.TexMaps[0].TexIndex];
                                if (t == null)
                                {
                                    break;
                                }
                                GL.PushMatrix();
                                {
                                    GL.Translate(t.Image.Width, -t.Image.Height, 0);
                                    RenderContent(Layout, InfluenceAlpha, Size.X - t.Image.Width * 2, Size.Y - t.Image.Height * 2);
                                }
                                GL.PopMatrix();
                                // _________
                                //|______|  |
                                //|  |   |  |
                                //|  |___|__|
                                //|__|______|
                                //Top Left
                                SetupMaterial(Layout, WindowFrames[0].MaterialId);
                                float[,] Vertex2 = SetupRect(Size.X - t.Image.Width, t.Image.Height);
                                GL.Begin(PrimitiveType.Quads);
                                GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t.Image.Width) / t.Image.Width, 0);
                                GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t.Image.Width) / t.Image.Width, 1);
                                GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                                GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                GL.End();
                                //Top Right
                                GL.PushMatrix();
                                {
                                    GL.Translate(Size.X - t.Image.Width, 0, 0);
                                    Vertex2 = SetupRect(t.Image.Width, Size.Y - t.Image.Height);
                                    GL.Begin(PrimitiveType.Quads);
                                    GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
                                    GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                    GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, (Size.Y - t.Image.Height) / t.Image.Height);
                                    GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 1, (Size.Y - t.Image.Height) / t.Image.Height);
                                    GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                    GL.End();
                                }
                                GL.PopMatrix();
                                //Bottom Right
                                GL.PushMatrix();
                                {
                                    GL.Translate(t.Image.Width, -(Size.Y - t.Image.Height), 0);
                                    Vertex2 = SetupRect(Size.X - t.Image.Width, t.Image.Height);
                                    GL.Begin(PrimitiveType.Quads);
                                    GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t.Image.Width) / t.Image.Width, 1);
                                    GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                                    GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                    GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t.Image.Width) / t.Image.Width, 0);
                                    GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                    GL.End();
                                }
                                GL.PopMatrix();
                                //Bottom Left
                                GL.PushMatrix();
                                {
                                    GL.Translate(0, -t.Image.Height, 0);
                                    Vertex2 = SetupRect(t.Image.Width, Size.Y - t.Image.Height);
                                    GL.Begin(PrimitiveType.Quads);
                                    GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, (Size.Y - t.Image.Height) / t.Image.Height);
                                    GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 1, (Size.Y - t.Image.Height) / t.Image.Height);
                                    GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
                                    GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                    GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                    GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                    GL.End();
                                }
                                GL.PopMatrix();
                            }
                        }
                        else if (NrFrames == 4)                                //Corners
                        {
                            var t1 = Textures[Layout.Materials.Materials[WindowFrames[0].MaterialId].TexMaps[0].TexIndex];
                            var t2 = Textures[Layout.Materials.Materials[WindowFrames[1].MaterialId].TexMaps[0].TexIndex];
                            var t3 = Textures[Layout.Materials.Materials[WindowFrames[2].MaterialId].TexMaps[0].TexIndex];
                            var t4 = Textures[Layout.Materials.Materials[WindowFrames[3].MaterialId].TexMaps[0].TexIndex];
                            if (t1 == null || t2 == null || t3 == null || t4 == null)
                            {
                                break;
                            }
                            GL.PushMatrix();
                            {
                                GL.Translate(t4.Image.Width, -t1.Image.Height, 0);
                                RenderContent(Layout, InfluenceAlpha, Size.X - (t4.Image.Width + t2.Image.Width), Size.Y - (t1.Image.Height + t3.Image.Height));
                            }
                            GL.PopMatrix();
                            // _________
                            //|______|  |
                            //|  |   |  |
                            //|  |___|__|
                            //|__|______|
                            //Top Left
                            SetupMaterial(Layout, WindowFrames[0].MaterialId);
                            float[,] Vertex2 = SetupRect(Size.X - t2.Image.Width, t1.Image.Height);
                            GL.Begin(PrimitiveType.Quads);
                            GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                            GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                            GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                            GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t2.Image.Width) / t1.Image.Width, 0);
                            GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                            GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t2.Image.Width) / t1.Image.Width, 1);
                            GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                            GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                            GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                            GL.End();
                            //Top Right
                            GL.PushMatrix();
                            {
                                GL.Translate(Size.X - t2.Image.Width, 0, 0);
                                SetupMaterial(Layout, WindowFrames[1].MaterialId);
                                Vertex2 = SetupRect(t2.Image.Width, Size.Y - t3.Image.Height);
                                GL.Begin(PrimitiveType.Quads);
                                GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
                                GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 1, (Size.Y - t3.Image.Height) / t2.Image.Height);
                                GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, (Size.Y - t3.Image.Height) / t2.Image.Height);
                                GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                GL.End();
                            }
                            GL.PopMatrix();
                            //Bottom Right
                            GL.PushMatrix();
                            {
                                GL.Translate(t4.Image.Width, -(Size.Y - t3.Image.Height), 0);
                                SetupMaterial(Layout, WindowFrames[2].MaterialId);
                                Vertex2 = SetupRect(Size.X - t4.Image.Width, t3.Image.Height);
                                GL.Begin(PrimitiveType.Quads);
                                GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t2.Image.Width) / t3.Image.Width, 0);
                                GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
                                GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                                GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, (Size.X - t2.Image.Width) / t3.Image.Width, 1);
                                GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                GL.End();
                            }
                            GL.PopMatrix();
                            //Bottom Left
                            GL.PushMatrix();
                            {
                                GL.Translate(0, -t1.Image.Height, 0);
                                SetupMaterial(Layout, WindowFrames[3].MaterialId);
                                Vertex2 = SetupRect(t4.Image.Width, Size.Y - t1.Image.Height);
                                GL.Begin(PrimitiveType.Quads);
                                GL.Color4(1, 1, 1, (InfluencedAlpha ? (byte)(((float)Alpha * (float)InfluenceAlpha) / 255f) : this.Alpha) / 255f);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 1, -(Size.Y - t1.Image.Height) / t4.Image.Height);
                                GL.Vertex3(Vertex2[0, 0], Vertex2[0, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, -(Size.Y - t1.Image.Height) / t4.Image.Height);
                                GL.Vertex3(Vertex2[1, 0], Vertex2[1, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
                                GL.Vertex3(Vertex2[2, 0], Vertex2[2, 1], 0);

                                GL.MultiTexCoord2(TextureUnit.Texture0, 1, 1);
                                GL.Vertex3(Vertex2[3, 0], Vertex2[3, 1], 0);
                                GL.End();
                            }
                            GL.PopMatrix();
                        }
                        else if (NrFrames == 8)                                //all
                        {
                            RenderContent(Layout, InfluenceAlpha, Size.X, Size.Y);
                        }
                        else
                        {
                            RenderContent(Layout, InfluenceAlpha, Size.X, Size.Y);
                            //not possible?
                        }
                        break;

                    default:
                        break;
                    }
                }
                GL.PopMatrix();
                foreach (pan1 p in Children)
                {
                    p.Render(Layout, Textures, InfluencedAlpha ? (int)((float)(Alpha * InfluenceAlpha) / 255f) : Alpha);
                }
            }
            GL.PopMatrix();
        }