Exemplo n.º 1
0
        public byte[] GenerateMips(int SurfaceLevel = 0)
        {
            Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);

            List <byte[]> mipmaps = new List <byte[]>();

            mipmaps.Add(STGenericTexture.CompressBlock(DecompressedData[SurfaceLevel],
                                                       (int)TexWidth, (int)TexHeight, TextureData.ConvertFormat(Format), alphaRef));

            //while (Image.Width / 2 > 0 && Image.Height / 2 > 0)
            //      for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int width  = Image.Width / 2;
                int height = Image.Height / 2;
                if (width <= 0)
                {
                    width = 1;
                }
                if (height <= 0)
                {
                    height = 1;
                }

                Image = BitmapExtension.Resize(Image, width, height);
                mipmaps.Add(STGenericTexture.CompressBlock(BitmapExtension.ImageToByte(Image),
                                                           Image.Width, Image.Height, TextureData.ConvertFormat(Format), alphaRef));
            }
            Image.Dispose();

            return(Utils.CombineByteArray(mipmaps.ToArray()));
        }
Exemplo n.º 2
0
        public TextureView(string directory, STGenericTexture texture)
        {
            Name         = texture.Name;
            RedChannel   = texture.RedChannel;
            GreenChannel = texture.GreenChannel;
            BlueChannel  = texture.BlueChannel;
            AlphaChannel = texture.AlphaChannel;

            if (TextureCache.CacheTexturesToDisk)
            {
                if (!TextureCache.HasTextueCached(directory, texture.Name))
                {
                    TextureCache.SaveTextureToDisk(directory, texture);
                }
                RenderableTex = TextureCache.LoadTextureFromDisk(directory, texture.Name);
            }
            else
            {
                if (!IsPow2(texture.Width) || !IsPow2(texture.Height))
                {
                    RenderableTex = TextureCache.LoadTextureDecompressed(texture.GetBitmap(), texture.IsSRGB);
                }
                else
                {
                    texture.LoadRenderableTexture();
                    RenderableTex = (GLTexture)texture.RenderableTex;
                }
            }
        }
Exemplo n.º 3
0
        static void DrawImage(ShaderProgram shader, STGenericTexture texture, Vector2 scale, bool showAlpha)
        {
            ImageBlendState.RenderBlendState();

            //Draw main texture quad inside boundings (0, 1)
            shader.SetVector2("scale", scale);
            // shader.SetVector2("scale", new Vector2(1));
            shader.SetVector4("uColor", new Vector4(1));
            shader.SetBoolToInt("isSRGB", texture.IsSRGB);
            shader.SetBoolToInt("displayAlpha", showAlpha);
            shader.SetVector2("texCoordScale", new Vector2(1));
            shader.SetFloat("width", texture.Width);
            shader.SetFloat("height", texture.Height);
            shader.SetInt("currentMipLevel", 0);

            GL.ActiveTexture(TextureUnit.Texture1);
            BindTexture(texture);
            shader.SetInt("textureInput", 1);
            shader.SetInt("hasTexture", 1);

            //Draw background
            vao.Enable(shader);
            vao.Use();
            GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Length);
        }
Exemplo n.º 4
0
        public static void Draw(STGenericTexture texture, int width, int height, Viewport2D.Camera2D camera, bool showAlpha)
        {
            Vector3 scale = new Vector3(1, 1, 1);

            scale = UpdateAspectScale(scale, width, height, texture);

            Init();

            var shader = GlobalShaders.GetShader("IMAGE_EDITOR");

            shader.Enable();

            var cameraMtx = Matrix4.CreateScale(100) * camera.ProjectionMatrix;

            shader.SetMatrix4x4("mtxCam", ref cameraMtx);

            GL.Disable(EnableCap.Blend);

            DrawBackground(shader);

            cameraMtx = camera.ViewMatrix * camera.ProjectionMatrix;
            shader.SetMatrix4x4("mtxCam", ref cameraMtx);

            DrawImage(shader, texture, scale.Xy, showAlpha);
        }
        private void ReloadTexture(STGenericTexture tex, ListViewItem listItem)
        {
            Thread Thread = new Thread((ThreadStart)(() =>
            {
                Bitmap temp = tex.GetBitmap();
                if (temp == null)
                {
                    return;
                }

                temp = BitmapExtension.Resize(temp, ImageList.ImageSize);

                if (listViewCustom1.InvokeRequired)
                {
                    listViewCustom1.Invoke((MethodInvoker) delegate {
                        ImageList.Images[listItem.ImageIndex] = temp;
                        // Running on the UI thread
                        var dummy = ImageList.Handle;
                    });
                }
                else
                {
                    ListViewItem item = new ListViewItem(tex.Text, ImageList.Images.Count);
                    item.Tag = tex;

                    listViewCustom1.Items.Add(item);
                    ImageList.Images.Add(temp);
                    var dummy = ImageList.Handle;
                }

                temp.Dispose();
            }));

            Thread.Start();
        }
Exemplo n.º 6
0
        private void LoadTextureIcon(int index, STGenericTexture texture)
        {
            Bitmap temp = texture.GetBitmap();

            if (temp == null)
            {
                return;
            }

            temp = texture.GetComponentBitmap(temp, true);
            temp = BitmapExtension.CreateImageThumbnail(temp, 80, 80);

            if (listViewCustom1.InvokeRequired)
            {
                listViewCustom1.Invoke((MethodInvoker) delegate {
                    var item        = listViewCustom1.Items[index];
                    item.ImageIndex = imgListBig.Images.Count;
                    item.SubItems.Add(texture.Format.ToString());
                    item.SubItems.Add(texture.Width.ToString());
                    item.SubItems.Add(texture.Height.ToString());
                    item.SubItems.Add(texture.DataSize);

                    // Running on the UI thread
                    imgListBig.Images.Add(temp);
                    imgListSmall.Images.Add(temp);

                    var dummy  = imgListBig.Handle;
                    var dummy2 = imgListSmall.Handle;
                });
            }

            temp.Dispose();
        }
        private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewCustom1.SelectedItems.Count == 1)
            {
                SelectedIndex = listViewCustom1.SelectedIndices[0];

                SelectedTexSettings         = settings[listViewCustom1.SelectedIndices[0]];
                formatComboBox.SelectedItem = SelectedTexSettings.Format;
                ImgDimComb.SelectedItem     = SelectedTexSettings.SurfaceDim;


                SetupSettings(SelectedTexSettings);

                if (ForceMipCount)
                {
                    MipmapNum.Maximum = SelectedTexSettings.MipCount;
                }
                else
                {
                    MipmapNum.Maximum = STGenericTexture.GenerateTotalMipCount(
                        SelectedTexSettings.TexWidth, SelectedTexSettings.TexHeight) + 1;
                }

                MipmapNum.Value = SelectedTexSettings.MipCount;
            }
        }
Exemplo n.º 8
0
        public void LoadBitMap(string FileName, BntxFile bntxFile)
        {
            DecompressedData.Clear();

            TexName    = Path.GetFileNameWithoutExtension(FileName);
            bntx       = bntxFile;
            Format     = TEX_FORMAT.BC1;
            FormatType = TEX_FORMAT_TYPE.SRGB;

            GenerateMipmaps = true;

            Bitmap Image = new Bitmap(FileName);

            Image = STGenericTexture.SwapBlueRedChannels(Image);

            TexWidth  = (uint)Image.Width;
            TexHeight = (uint)Image.Height;
            MipCount  = (uint)GetTotalMipCount();

            DecompressedData.Add(BitmapExtension.ImageToByte(Image));

            Image.Dispose();
            if (DecompressedData.Count == 0)
            {
                throw new Exception("Failed to load " + Format);
            }
        }
Exemplo n.º 9
0
        public byte[] GenerateMips(int SurfaceLevel = 0)
        {
            Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);

            if (FlipY)
            {
                Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
            }

            List <byte[]> mipmaps = new List <byte[]>();

            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int MipWidth  = Math.Max(1, (int)TexWidth >> mipLevel);
                int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);

                if (mipLevel != 0)
                {
                    Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
                }

                mipmaps.Add(STGenericTexture.CompressBlock(BitmapExtension.ImageToByte(Image),
                                                           Image.Width, Image.Height, FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Format), alphaRef));
            }
            Image.Dispose();

            return(Utils.CombineByteArray(mipmaps.ToArray()));
        }
Exemplo n.º 10
0
        private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewCustom1.SelectedItems.Count == 1)
            {
                SelectedIndex = listViewCustom1.SelectedIndices[0];

                SelectedTexSettings         = settings[listViewCustom1.SelectedIndices[0]];
                formatComboBox.SelectedItem = SelectedTexSettings.Format;

                SetupSettings(SelectedTexSettings);

                MipmapNum.Maximum = STGenericTexture.GenerateTotalMipCount(
                    SelectedTexSettings.TexWidth, SelectedTexSettings.TexHeight) + 1;

                //Force the mip counter to be the selected mip counter
                //Some textures like bflim (used for UI) only have 1
                if (OverrideMipCounter)
                {
                    MipmapNum.Maximum = SelectedTexSettings.MipCount;
                    MipmapNum.Minimum = SelectedTexSettings.MipCount;
                }

                MipmapNum.Value  = SelectedTexSettings.MipCount;
                SwizzleNum.Value = SelectedTexSettings.SwizzlePattern;
            }
        }
Exemplo n.º 11
0
        public byte[] EncodeImage(STGenericTexture texture, byte[] data, uint width, uint height, int array, int mip)
        {
            var encoded = Decode_Gamecube.EncodeData(data, Format, PaletteFormat, (int)width, (int)height);

            PaletteData = encoded.Item2;
            return(encoded.Item1);
        }
Exemplo n.º 12
0
        private void UpdateImage(STGenericTexture texture, int arrayLevel = 0)
        {
            ResetChannelEditor();

            HasBeenEdited = false;

            if (texture.CanEdit)
            {
                imageToolStripMenuItem.Enabled       = true;
                adjustmentsToolStripMenuItem.Enabled = true;
            }

            ActiveTexture = texture;

            if (ActiveTexture.CanEdit)
            {
                editBtn.Enabled         = true;
                editBtn.BackgroundImage = Properties.Resources.Edit;
            }
            else
            {
                editBtn.BackgroundImage = BitmapExtension.GrayScale(Properties.Resources.Edit);
            }

            CurMipDisplayLevel   = 0;
            CurArrayDisplayLevel = arrayLevel;
            hasBeenEdited        = false;

            UpdateMipDisplay();
        }
        public void LoadDDS(string FileName, byte[] FileData = null)
        {
            TexName = STGenericTexture.SetNameFromPath(FileName);

            DDS dds = new DDS();

            if (FileData != null)
            {
                dds.Load(new FileReader(new MemoryStream(FileData)));
            }
            else
            {
                dds.Load(new FileReader(FileName));
            }
            MipCount  = dds.header.mipmapCount;
            TexWidth  = dds.header.width;
            TexHeight = dds.header.height;

            var surfaces = DDS.GetArrayFaces(dds, dds.ArrayCount);

            RedComp   = dds.RedChannel;
            GreenComp = dds.GreenChannel;
            BlueComp  = dds.BlueChannel;
            AlphaComp = dds.AlphaChannel;

            foreach (var surface in surfaces)
            {
                DataBlockOutput.Add(Utils.CombineByteArray(surface.mipmaps.ToArray()));
            }

            Format = dds.Format;
        }
Exemplo n.º 14
0
        public byte[] GenerateMips(STCompressionMode CompressionMode, int SurfaceLevel = 0)
        {
            Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);

            if (GammaFix)
            {
                Image = BitmapExtension.AdjustGamma(Image, 2.2f);
            }

            List <byte[]> mipmaps = new List <byte[]>();

            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int MipWidth  = Math.Max(1, (int)TexWidth >> mipLevel);
                int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);

                if (mipLevel != 0)
                {
                    Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
                }

                mipmaps.Add(STGenericTexture.CompressBlock(BitmapExtension.ImageToByte(Image),
                                                           Image.Width, Image.Height, TextureData.ConvertFormat(Format), alphaRef, CompressionMode));
            }
            Image.Dispose();

            return(Utils.CombineByteArray(mipmaps.ToArray()));
        }
Exemplo n.º 15
0
        public void LoadCameraFile(Course_MapCamera_bin camera, MK8MapCameraEditor editor)
        {
            MapCamera    = camera;
            ParentEditor = editor;

            CameraPoints.Add(new CameraPoint(camera.cameraData, true));
            CameraPoints.Add(new CameraPoint(camera.cameraData, false));

            //Try to load the mini map
            var folder = System.IO.Path.GetDirectoryName(camera.FilePath);

            if (System.IO.File.Exists($"{folder}/course_maptexture.bflim"))
            {
                var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bflim");
                if (fileFormat is BFLIM)
                {
                    MapCameraTexture = fileFormat as BFLIM;
                }
            }
            if (System.IO.File.Exists($"{folder}/course_maptexture.bntx"))
            {
                var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bntx");
                if (fileFormat is BNTX)
                {
                    MapCameraTexture = ((BNTX)fileFormat).Textures.Values.FirstOrDefault();
                }
            }
        }
        public void LoadDDS(string FileName, byte[] FileData = null)
        {
            TexName = STGenericTexture.SetNameFromPath(FileName);

            DDS dds = new DDS();

            if (FileData != null)
            {
                dds.Load(new FileReader(new MemoryStream(FileData)));
            }
            else
            {
                dds.Load(new FileReader(FileName));
            }
            MipCount    = dds.header.mipmapCount;
            TexWidth    = dds.header.width;
            TexHeight   = dds.header.height;
            arrayLength = 1;
            if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
            {
                arrayLength = 6;
            }
            DataBlockOutput.Add(dds.bdata);

            Format = (CTR_3DS.PICASurfaceFormat)CTR_3DS.ConvertToPICAFormat(dds.Format);
        }
Exemplo n.º 17
0
        public List <byte[]> GenerateMipList(STCompressionMode CompressionMode, bool multiThread, bool bc4Alpha, int SurfaceLevel = 0)
        {
            Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);

            if (GammaFix)
            {
                Image = BitmapExtension.AdjustGamma(Image, 2.2f);
            }
            if (bc4Alpha)
            {
                Image = BitmapExtension.SetChannel(Image, STChannelType.Alpha, STChannelType.Alpha, STChannelType.Alpha, STChannelType.Alpha);
            }

            List <byte[]> mipmaps = new List <byte[]>();

            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int MipWidth  = Math.Max(1, (int)TexWidth >> mipLevel);
                int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);

                if (mipLevel != 0)
                {
                    Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
                }

                mipmaps.Add(STGenericTexture.CompressBlock(BitmapExtension.ImageToByte(Image),
                                                           Image.Width, Image.Height, TextureData.ConvertFormat(Format), alphaRef, multiThread, CompressionMode));
            }
            Image.Dispose();

            return(mipmaps);
        }
Exemplo n.º 18
0
        public byte[] EncodeImage(STGenericTexture texture, byte[] data, uint width, uint height, int array, int mip)
        {
            List <byte[]> mipmaps = SwizzleSurfaceMipMaps(texture, data, texture.MipCount);

            //Combine mip map data
            return(ByteUtils.CombineArray(mipmaps.ToArray()));
        }
Exemplo n.º 19
0
        public override void RenderScene()
        {
            var shader = GlobalShaders.GetShader("UV_WINDOW");

            shader.Enable();

            STGenericTexture tex = null;

            foreach (var render in GLFrameworkEngine.DataCache.ModelCache.Values)
            {
                if (ActiveTextureMap != null)
                {
                    var brender = render;

                    if (brender.Textures.ContainsKey(ActiveTextureMap.Name))
                    {
                        tex = brender.Textures[ActiveTextureMap.Name];
                    }
                }
            }

            Vector2 aspectScale = UpdateAspectScale(Width, Height, tex);

            UVBackground.Draw(tex, ActiveTextureMap, Width, Height, aspectScale, Camera);
            DrawableUVMap.UpdateVertexBuffer(PolygonGroupIndex, UvChannelIndex, ActiveObjects, ActiveTextureMap);
            DrawableUVMap.Draw(Camera, aspectScale);
        }
Exemplo n.º 20
0
        private static void BindGLTexture(MatTexture tex, SF.Shader shader, STGenericTexture texture)
        {
            //If the texture is still not initialized then return
            if (!texture.RenderableTex.GLInitialized)
            {
                return;
            }

            if (tex.Type == STGenericMatTexture.TextureType.Diffuse)
            {
                shader.SetInt("RedChannel", (int)texture.RedChannel);
                shader.SetInt("GreenChannel", (int)texture.GreenChannel);
                shader.SetInt("BlueChannel", (int)texture.BlueChannel);
                shader.SetInt("AlphaChannel", (int)texture.AlphaChannel);
            }


            //     GL.ActiveTexture(TextureUnit.Texture0 + texid);
            GL.BindTexture(TextureTarget.Texture2D, texture.RenderableTex.TexID);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)MatTexture.wrapmode[tex.WrapModeS]);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)MatTexture.wrapmode[tex.WrapModeT]);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)MatTexture.minfilter[tex.MinFilter]);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)MatTexture.magfilter[tex.MagFilter]);
            GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, 0.0f);
        }
Exemplo n.º 21
0
        public List <byte[]> GenerateMipList(int SurfaceLevel = 0)
        {
            Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight);

            if (FlipY)
            {
                Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
            }
            if (UseBc4Alpha && (Format == GX2.GX2SurfaceFormat.T_BC4_UNORM || Format == GX2.GX2SurfaceFormat.T_BC4_SNORM))
            {
                Image = BitmapExtension.SetChannel(Image, STChannelType.Alpha, STChannelType.Alpha, STChannelType.Alpha, STChannelType.One);
            }

            Console.WriteLine($"FlipY {FlipY}");

            List <byte[]> mipmaps = new List <byte[]>();

            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int MipWidth  = Math.Max(1, (int)TexWidth >> mipLevel);
                int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);

                if (mipLevel != 0)
                {
                    Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
                }

                mipmaps.Add(STGenericTexture.CompressBlock(BitmapExtension.ImageToByte(Image),
                                                           Image.Width, Image.Height, FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Format), alphaRef));
            }
            Image.Dispose();

            return(mipmaps);
        }
Exemplo n.º 22
0
        public byte[] DecodeImage(STGenericTexture texture, byte[] data, uint width, uint height, int array, int mip)
        {
            uint bpp = TextureFormatHelper.GetBytesPerPixel(OutputFormat);

            GX2.GX2Surface surf = new GX2.GX2Surface();
            surf.bpp       = bpp;
            surf.height    = texture.Height;
            surf.width     = texture.Width;
            surf.depth     = texture.ArrayCount;
            surf.alignment = Alignment;
            surf.aa        = (uint)AAMode;
            surf.dim       = (uint)SurfaceDimension;
            surf.format    = (uint)Format;
            surf.use       = (uint)SurfaceUse;
            surf.pitch     = Pitch;
            surf.data      = data;
            surf.mipData   = MipData != null ? MipData : data;
            surf.mipOffset = MipOffsets != null ? MipOffsets : new uint[0];
            surf.numMips   = texture.MipCount;
            surf.numArray  = texture.ArrayCount;
            surf.tileMode  = (uint)TileMode;
            surf.swizzle   = Swizzle;

            Console.WriteLine("WII U DECODE");

            return(GX2.Decode(surf, array, mip));
        }
Exemplo n.º 23
0
        public static byte[] Decompress(byte[] Input, int Width, int Height, bool Alpha)
        {
            byte[] Output = new byte[Width * Height * 4];

            byte[] comp = new byte[4] {
                0xFF, 0xFF, 0xFF, 0xFF
            };

            int bpp = (int)STGenericTexture.GetBytesPerPixel(TEX_FORMAT.R4G4_UNORM);

            for (int Y = 0; Y < Height; Y++)
            {
                for (int X = 0; X < Width; X++)
                {
                    int InputOffset  = (Y * Width + X) * bpp;
                    int OutputOffset = (Y * Width + X) * 4;

                    int pixel = 0;
                    for (int i = 0; i < bpp; i++)
                    {
                        pixel |= Input[InputOffset + i] << (8 * i);
                    }

                    comp[0] = (byte)((pixel & 0xF) * 17);
                    comp[1] = (byte)(((pixel & 0xF0) >> 4) * 17);

                    Output[OutputOffset + 0] = comp[0];
                    Output[OutputOffset + 1] = comp[1];
                    Output[OutputOffset + 2] = comp[2];
                    Output[OutputOffset + 3] = comp[3];
                }
            }

            return(Output);
        }
        public void LoadDDS(string FileName, byte[] FileData = null)
        {
            TexName = STGenericTexture.SetNameFromPath(FileName);

            DDS dds = new DDS();

            if (FileData != null)
            {
                dds.Load(new FileReader(new MemoryStream(FileData)));
            }
            else
            {
                dds.Load(new FileReader(FileName));
            }
            MipCount    = dds.header.mipmapCount;
            TexWidth    = dds.header.width;
            TexHeight   = dds.header.height;
            arrayLength = 1;
            if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
            {
                arrayLength = 6;
            }
            DataBlockOutput.Add(dds.bdata);

            RedComp   = dds.RedChannel;
            GreenComp = dds.GreenChannel;
            BlueComp  = dds.BlueChannel;
            AlphaComp = dds.AlphaChannel;

            Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);;
        }
Exemplo n.º 25
0
        private static GLTexture BindGLTexture(STGenericTexture texture, STGenericTextureMap textureMap, ShaderProgram shader)
        {
            if (texture.RenderableTex == null)
            {
                texture.LoadRenderableTexture();
            }

            if (texture.RenderableTex == null)
            {
                return(null);
            }

            var target = ((GLTexture)texture.RenderableTex).Target;

            GL.BindTexture(target, texture.RenderableTex.ID);
            GL.TexParameter(target, TextureParameterName.TextureWrapS, (int)OpenGLHelper.WrapMode[textureMap.WrapU]);
            GL.TexParameter(target, TextureParameterName.TextureWrapT, (int)OpenGLHelper.WrapMode[textureMap.WrapV]);
            GL.TexParameter(target, TextureParameterName.TextureMinFilter, (int)OpenGLHelper.MinFilter[textureMap.MinFilter]);
            GL.TexParameter(target, TextureParameterName.TextureMagFilter, (int)OpenGLHelper.MagFilter[textureMap.MagFilter]);
            GL.TexParameter(target, TextureParameterName.TextureLodBias, textureMap.LODBias);
            GL.TexParameter(target, TextureParameterName.TextureMaxLod, textureMap.MaxLOD);
            GL.TexParameter(target, TextureParameterName.TextureMinLod, textureMap.MinLOD);

            int[] mask = new int[4]
            {
                OpenGLHelper.GetSwizzle(texture.RedChannel),
                OpenGLHelper.GetSwizzle(texture.GreenChannel),
                OpenGLHelper.GetSwizzle(texture.BlueChannel),
                OpenGLHelper.GetSwizzle(texture.AlphaChannel),
            };
            GL.TexParameter(target, TextureParameterName.TextureSwizzleRgba, mask);
            return((GLTexture)texture.RenderableTex);
        }
Exemplo n.º 26
0
 private void AddItem(STGenericTexture texture)
 {
     listViewCustom1.Items.Add(new ListViewItem(texture.Text)
     {
         Name = texture.Text, Tag = texture,
     });
 }
        static ObjectTreeNode LoadTextureFormat(STGenericTexture texture)
        {
            ObjectTreeNode node = new ObjectTreeNode(texture.Name);

            node.ImageKey = "Texture";
            node.Tag      = texture;
            return(node);
        }
Exemplo n.º 28
0
 public void Compress()
 {
     DataBlockOutput.Clear();
     foreach (var surface in DecompressedData)
     {
         DataBlockOutput.Add(STGenericTexture.CompressBlock(surface, (int)TexWidth, (int)TexHeight, Format, FormatType, alphaRef));
     }
 }
Exemplo n.º 29
0
        public void LoadTexture(STGenericTexture texture)
        {
            ActiveTexture = texture;

            skybox.ForceDisplay = true;
            skybox.LoadCustomTexture(ActiveTexture);
            glControl.MainDrawable = skybox;
        }
Exemplo n.º 30
0
        public void LoadTextures(LayoutEditor parentEditor, BxlytHeader header,
                                 Dictionary <string, STGenericTexture> textureList)
        {
            ParentEditor = parentEditor;
            TextureList  = textureList;
            ActiveLayout = header;
            listViewCustom1.Items.Clear();
            imgListSmall.Images.Clear();
            imgListSmall.Images.Add(FirstPlugin.Properties.Resources.MissingTexture);
            imgListBig.Images.Clear();
            imgListBig.Images.Add(FirstPlugin.Properties.Resources.MissingTexture);

            listViewCustom1.LargeImageList = imgListBig;
            listViewCustom1.SmallImageList = imgListSmall;

            listViewCustom1.BeginUpdate();
            foreach (var texture in header.Textures)
            {
                ListViewItem item = new ListViewItem();
                item.Text       = texture;
                item.ImageIndex = 0;
                listViewCustom1.Items.Add(item);
            }

            //Load textures after on a seperate thread

            if (Thread != null && Thread.IsAlive)
            {
                Thread.Abort();
            }

            Thread = new Thread((ThreadStart)(() =>
            {
                int index = 0;
                foreach (var texture in header.Textures)
                {
                    if (textureList.ContainsKey(texture))
                    {
                        if (header is BCLYT.Header)
                        {
                            //Skip certain formats like bcn ones
                            if (STGenericTexture.IsCompressed(textureList[texture].Format))
                            {
                                continue;
                            }
                        }

                        LoadTextureIcon(index, textureList[texture]);
                    }
                    index++;
                }
            }));
            Thread.Start();

            listViewCustom1.EndUpdate();

            isLoaded = true;
        }