Beispiel #1
0
 public void SetTexture(Texture texture)
 {
     this.Texture = texture;
 }
Beispiel #2
0
        /// <summary>
        /// Either changes the name of an existing texture (and it's entry in the global
        /// texture array), or creates a new texture sharing the data of the existing one
        /// but with a different name. (Bitmap object and GL graphics memory is shared.)
        /// 
        /// This call is NOT necessary in ordinary usage! EVERY Texture gets put in the global
        /// texture array once created, even if the name assigned is just a Guid.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="texture"></param>
        /// <param name="makeCopy"></param>
        /// <remarks>ALL Textures already exist in the global texture array!
        /// This call is NOT necessary in ordinary Texture usage!
        /// Textures created using the new Texture(Bitmap) constructor have a GUID assigned.</remarks>
        public static void SetTexture(string name, Texture texture, bool makeCopy)
        {
            name = name.ToLower();

            lock (textures)
            {
                Texture t;

                if (makeCopy)
                {
                    // Copy the bastard, and change the name.
                    t = new Texture();
                    t.bitmap = texture.bitmap;
                    t.TexPointer = texture.TexPointer;
                    t.Filename = name;

                    if (textures.Keys.Contains(name))
                    {
                        Log.w("A texture with name '" + name + "' is already present - replacing.");
                        textures.Remove(name);
                    }
                }
                else
                {
                    textures.Remove(texture.Filename);
                    texture.Filename = name;
                    t = texture;
                }

                if (textures.ContainsKey(name))
                {
                    textures.Remove(name);
                    Log.v("Replacing texture '" + name + "' with new one. This is rarely"
                        + " a good thing.");
                }
                textures.Add(name, t);
            }
        }
Beispiel #3
0
 public Sprite(Texture texture)
 {
     Texture = texture;
 }