public CLYTShader(mat1.MaterialEntry Material, int[] Textures) { this.Textures = Textures; this.Material = Material; }
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(); }