コード例 #1
0
        /// <summary>
        /// Copy the supplied image onto a newly-allocated OpenGL texture, returning the allocated texture name
        /// </summary>
        public virtual int AllocateAndSetupTexture(Bitmap par1Bitmap)
        {
            SingleIntBuffer.Clear();
            GLAllocation.GenerateTextureNames(SingleIntBuffer);
            int i = SingleIntBuffer.Get(0);

            SetupTexture(par1Bitmap, i);
            TextureNameToImageMap.AddKey(i, par1Bitmap);
            return(i);
        }
コード例 #2
0
        public virtual int GetTexture(string par1Str)
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;

            if (TextureMap.ContainsKey(par1Str))
            {
                return(TextureMap[par1Str]);
            }

            try
            {
                SingleIntBuffer.Clear();
                GLAllocation.GenerateTextureNames(SingleIntBuffer);
                int i = SingleIntBuffer.Get(0);

                if (par1Str.StartsWith("##"))
                {
                    SetupTexture(UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(2)))), i);
                }
                else if (par1Str.StartsWith("%clamp%"))
                {
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(7))), i);
                    ClampTexture = false;
                }
                else if (par1Str.StartsWith("%blur%"))
                {
                    BlurTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(6))), i);
                    BlurTexture = false;
                }
                else if (par1Str.StartsWith("%blurclamp%"))
                {
                    BlurTexture  = true;
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(11))), i);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                else
                {
                    Stream inputstream = texturepackbase.GetResourceAsStream(par1Str);

                    if (inputstream == null)
                    {
                        SetupTexture(MissingTextureImage, i);
                    }
                    else
                    {
                        SetupTexture(ReadTextureImage(inputstream), i);
                    }
                }

                TextureMap.Add(par1Str, i);
                return(i);
            }
            catch (Exception exception)
            {
                Utilities.LogException(exception);
            }

            GLAllocation.GenerateTextureNames(SingleIntBuffer);
            int j = SingleIntBuffer.Get(0);

            SetupTexture(MissingTextureImage, j);
            TextureMap.Add(par1Str, j);
            return(j);
        }