Пример #1
0
        private void textureListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (textureListBox.SelectedIndex >= 0)
            {
                selectedTexture = ((BRTI)textureListBox.SelectedItem);


                label1.Text = "Width: " + selectedTexture.texture.width;
                label2.Text = "Height: " + selectedTexture.texture.height;

                uint format   = selectedTexture.format >> 8;
                byte dataType = (byte)(selectedTexture.format & 0xFF);

                Formats.BNTXImageFormat f = (Formats.BNTXImageFormat)format;
                Formats.BNTXImageTypes  t = (Formats.BNTXImageTypes)dataType;

                label3.Text = f.ToString() + " " + t.ToString();

                // Render the selected texture.
                if (bntx.glTexByName.ContainsKey(selectedTexture.Text))
                {
                    textureToRender = bntx.glTexByName[selectedTexture.Text];
                }
            }
            else
            {
                label1.Text = "Width: " + "";
                label2.Text = "Height: " + "";
            }
            glControl1.Invalidate();
        }
Пример #2
0
        private void exportTextureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (textureListBox.SelectedItem == null)
            {
                return;
            }
            using (var sfd = new SaveFileDialog())
            {
                BRTI tex = (BRTI)(textureListBox.SelectedItem);
                sfd.Filter = "Direct Draw Surface (.png)|*.png|" +
                             "All files(*.*)|*.*";

                sfd.FileName = tex.Text;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    // use png instead
                    if (sfd.FileName.EndsWith(".png"))
                    {
                        tex.ExportAsImage(tex.texture, tex.display, sfd.FileName + ".png");
                    }
                    if (sfd.FileName.EndsWith(".dds"))
                    {
                    }
                }
            }
        }
Пример #3
0
        private void RenderTextureAlpha(BRTI tex)
        {
            if (!loadedA || glControl2 == null)
            {
                return;
            }

            if (Rendering.OpenTkSharedResources.SetupStatus != Rendering.OpenTkSharedResources.SharedResourceStatus.Initialized)
            {
                return;
            }

            glControl2.MakeCurrent();
            GL.Viewport(glControl2.ClientRectangle);

            if (listView1.SelectedItems == null)
            {
                glControl2.SwapBuffers();
                return;
            }

            int width  = tex.Width;
            int height = tex.Height;

            Rendering.ScreenDrawing.DrawTexturedQuad(tex.display, width, height, screenTriangle, false, false, false, true);

            glControl2.SwapBuffers();
        }
Пример #4
0
        public void RefreshGlTexturesByName()
        {
            glTexByName.Clear();

            foreach (BRTI tex in Nodes)
            {
                Texture2D tex2d = BRTI.CreateTexture2D(tex.texture);
                tex.texture.display = tex2d;
                tex.display         = tex.texture.display;

                glTexByName.Add(tex.Text, tex2d);
            }
        }
Пример #5
0
        public void Read(FileData f)
        {
            textures.Clear();

            BFRES b = new BFRES();

            temp = f.Pos();

            f.Skip(8); //Magic
            int Version        = f.ReadInt();
            int ByteOrderMark  = f.ReadShort();
            int FormatRevision = f.ReadShort();

            Text = f.ReadString(f.ReadInt() + temp, -1);
            f.Skip(2);
            int strOffset   = f.ReadShort();
            int relocOffset = f.ReadInt();
            int FileSize    = f.ReadInt();

            target = f.ReadString(f.Pos(), 4); //NX
            f.Skip(4);
            int TexturesCount   = f.ReadInt();
            int InfoPtrsOffset  = f.ReadInt();
            int DataBlockOffset = f.ReadInt();
            int DictOffset      = f.ReadInt();
            int strDictSize     = f.ReadInt();

            Text = Text + ".bntx";

            BNTXFile = f.GetSection(temp, FileSize);

            for (int i = 0; i < TexturesCount; i++)
            {
                f.Seek(InfoPtrsOffset + temp + i * 8);
                BRTIOffset = f.ReadInt();


                f.Seek(BRTIOffset + temp);

                //  textures.Add(new BRTI(f));
                BRTI texture = new BRTI();
                texture.Read(f, this);

                textures.Add(texture);
            }
            Nodes.AddRange(textures.ToArray());
        }
Пример #6
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;
                    newTexture.mipmaps.Add(t.texture.mipmaps[0]);

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

                    if (newTexture == null)
                    {
                        return;
                    }

                    FillForm();
                }
            }
        }