Ejemplo n.º 1
0
        private void UploadTex(mat1.MaterialEntry.TexMap TexMap, CLIM Texture, int Id)
        {
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, Id);
            Gl.glColor3f(1, 1, 1);
            Bitmap b = Texture.ToBitmap();
            //b.RotateFlip(RotateFlipType.RotateNoneFlipY);
            BitmapData d = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, b.Width, b.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, d.Scan0);
            b.UnlockBits(d);

            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, (TexMap.MagFilter == mat1.MaterialEntry.TexMap.FilterMode.Linear) ? Gl.GL_LINEAR : Gl.GL_NEAREST);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, (TexMap.MinFilter == mat1.MaterialEntry.TexMap.FilterMode.Linear) ? Gl.GL_LINEAR : Gl.GL_NEAREST);

            switch (TexMap.WrapS)
            {
                case mat1.MaterialEntry.TexMap.WrapMode.Clamp:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
                    break;
                case mat1.MaterialEntry.TexMap.WrapMode.Repeat:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
                    break;
                case mat1.MaterialEntry.TexMap.WrapMode.Mirror:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_MIRRORED_REPEAT);
                    break;
                default:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT);
                    break;
            }

            switch (TexMap.WrapT)
            {
                case mat1.MaterialEntry.TexMap.WrapMode.Clamp:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);
                    break;
                case mat1.MaterialEntry.TexMap.WrapMode.Repeat:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);
                    break;
                case mat1.MaterialEntry.TexMap.WrapMode.Mirror:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_MIRRORED_REPEAT);
                    break;
                default:
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT);
                    break;
            }
        }
Ejemplo n.º 2
0
        public CLYT(byte[] Data)
        {
            EndianBinaryReader er = new EndianBinaryReader(new MemoryStream(Data), Endianness.LittleEndian);

            try
            {
                Header = new CLYTHeader(er);
                pan1 ParentPan = new pan1("FakeDummyTopPane");
                pan1 LastPan   = null;
                grp1 ParentGrp = new grp1("FakeDummyTopGroup");
                grp1 LastGrp   = null;
                int  blocknr   = 0;
                while (blocknr < Header.NrBlocks)
                {
                    String sig  = er.ReadString(Encoding.ASCII, 4);
                    UInt32 size = er.ReadUInt32();
                    er.BaseStream.Position -= 8;
                    switch (sig)
                    {
                    case "lyt1": Layout = new lyt1(er); break;

                    case "txl1": TextureList = new txl1(er); break;

                    case "fnl1": FontList = new fnl1(er); break;

                    case "mat1": Materials = new mat1(er); break;

                    case "pan1":
                        LastPan        = new pan1(er);
                        LastPan.Parent = ParentPan;
                        ParentPan.Children.Add(LastPan);
                        break;

                    case "pic1":
                        LastPan        = new pic1(er);
                        LastPan.Parent = ParentPan;
                        ParentPan.Children.Add(LastPan);
                        break;

                    case "txt1":
                        LastPan        = new txt1(er);
                        LastPan.Parent = ParentPan;
                        ParentPan.Children.Add(LastPan);
                        break;

                    case "bnd1":
                        LastPan        = new bnd1(er);
                        LastPan.Parent = ParentPan;
                        ParentPan.Children.Add(LastPan);
                        break;

                    case "wnd1":
                        LastPan        = new wnd1(er);
                        LastPan.Parent = ParentPan;
                        ParentPan.Children.Add(LastPan);
                        break;

                    case "pas1":
                        ParentPan = LastPan;
                        er.BaseStream.Position += 8;
                        break;

                    case "pae1":
                        ParentPan = ParentPan.Parent;
                        er.BaseStream.Position += 8;
                        break;

                    case "grp1":
                        LastGrp        = new grp1(er);
                        LastGrp.Parent = ParentGrp;
                        ParentGrp.Children.Add(LastGrp);
                        break;

                    case "grs1":
                        ParentGrp = LastGrp;
                        er.BaseStream.Position += 8;
                        break;

                    case "gre1":
                        ParentGrp = ParentGrp.Parent;
                        er.BaseStream.Position += 8;
                        break;

                    case "usd1":                            //userdata
                        er.BaseStream.Position += size;
                        break;

                    default:
                        er.BaseStream.Position += size;
                        break;
                    }
                    blocknr++;
                }
                RootPane         = ParentPan.Children[0];
                RootPane.Parent  = null;
                RootGroup        = ParentGrp.Children[0];
                RootGroup.Parent = null;
            }
            finally
            {
                er.Close();
            }
        }
Ejemplo n.º 3
0
 public CLYTShader(mat1.MaterialEntry Material, int[] Textures)
 {
     this.Textures = Textures;
     this.Material = Material;
 }