示例#1
0
        public static SFTex.Texture2D CreateTexture2D(FTEX_Texture tex, int surfaceIndex = 0)
        {
            bool compressedFormatWithMipMaps = SFTex.TextureFormatTools.IsCompressed(tex.pixelInternalFormat);

            //Todo. Use mip maps from FTEX
            if (compressedFormatWithMipMaps)
            {
                if (tex.mipMapData.Count > 1)
                {
                    // Only load the first level and generate the rest.
                    SFTex.Texture2D texture = new SFTex.Texture2D();
                    texture.LoadImageData(tex.width, tex.height, tex.data, tex.mipMapData.Count,
                                          (InternalFormat)tex.pixelInternalFormat);
                    return(texture);
                }
                else
                {
                    // Only load the first level and generate the rest.
                    SFTex.Texture2D texture = new SFTex.Texture2D();
                    texture.LoadImageData(tex.width, tex.height, tex.data, tex.mipMapData.Count,
                                          (InternalFormat)tex.pixelInternalFormat);
                    return(texture);
                }
            }
            else
            {
                // Uncompressed.
                SFTex.Texture2D texture = new SFTex.Texture2D();
                texture.LoadImageData(tex.width, tex.height, tex.data, tex.mipMapCount,
                                      new SFTex.TextureFormatUncompressed(tex.pixelInternalFormat, tex.pixelFormat, tex.pixelType));
                return(texture);
            }
        }
示例#2
0
        public Dictionary <string, SFTex.Texture> glTexByName = new Dictionary <string, SFTex.Texture>(); //Rendering

        public void RefreshGlTexturesByName()
        {
            glTexByName.Clear();

            foreach (FTEX tex in FTEXtextures.Values)
            {
                SFTex.Texture2D texture2d = FTEX.CreateTexture2D(tex.texture);
                glTexByName.Add(tex.Text, texture2d);

                tex.texture.display = texture2d.Id;
                tex.display         = tex.texture.display;
            }
        }