예제 #1
0
        private void replaceTextureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                BRTI t = (BRTI)(textureListBox.SelectedItem);

                ofd.Filter = "Portable Network Graphic (.png)|*.png;|" +
                             "All files(*.*)|*.*";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    Edited = true;
                    BRTI.BRTI_Texture newTexture = null;
                    if (Path.GetExtension(ofd.FileName).ToLower().Equals(".png"))
                    {
                        newTexture = fromPNG(ofd.FileName, 1);
                    }
                    if (Path.GetExtension(ofd.FileName).ToLower().Equals(".dds"))
                    {
                        DDS dds = new DDS(new FileData(ofd.FileName));
                        newTexture = dds.toBRTITexture();
                    }

                    t.texture.height = newTexture.height;
                    t.texture.width  = newTexture.width;
                    t.texture.pixelInternalFormat = newTexture.pixelInternalFormat;
                    t.texture.mipmaps             = newTexture.mipmaps;
                    t.texture.pixelFormat         = newTexture.pixelFormat;
                    t.texture.data = newTexture.data;

                    GL.DeleteTexture(t.texture.display);

                    BNTX.glTexByName.Add(ofd.FileName, BRTI.CreateTexture2D(t.texture));

                    if (newTexture == null)
                    {
                        return;
                    }

                    FillForm();
                }
            }
        }