Example #1
0
        // --- unload texture ---

        /// <summary>Unloads the specified texture from OpenGL if loaded.</summary>
        /// <param name="handle">The handle to the registered texture.</param>
        public static void UnloadTexture(ref Texture handle)
        {
            //Null check the texture handle, as otherwise this can cause OpenGL to throw a fit
            if (handle == null)
            {
                return;
            }

            if (handle.MultipleFrames)
            {
                for (int i = 0; i < handle.TotalFrames; i++)
                {
                    handle.CurrentFrame = i;
                    foreach (OpenGlTexture t in handle.OpenGlTextures)
                    {
                        if (t.Valid)
                        {
                            GL.DeleteTextures(1, new[] { t.Name });
                            t.Valid = false;
                        }
                    }
                }

                /*
                 * Clone the ref for the search and then re-create the original in the texturemanager array
                 * This allows it to be re-loaded from disk
                 */
                var           texture = handle;
                TextureOrigin key     = animatedTextures.FirstOrDefault(x => x.Value == texture).Key;
                handle = new Texture(key);
            }


            handle.Ignore = false;
        }
Example #2
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="texture">The texture raw data.</param>
 internal Texture(OpenBveApi.Textures.Texture texture)
 {
     this.Origin         = new RawOrigin(texture);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #3
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 internal Texture(Bitmap bitmap, OpenBveApi.Textures.TextureParameters parameters)
 {
     this.Origin         = new BitmapOrigin(bitmap, parameters);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #4
0
 /// <summary>Creates a new texture.</summary>
 /// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
 internal Texture(Bitmap bitmap)
 {
     this.Origin         = new BitmapOrigin(bitmap);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #5
0
 // --- constructors ---
 /// <summary>Creates a new texture.</summary>
 /// <param name="path">The path to the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 internal Texture(string path, OpenBveApi.Textures.TextureParameters parameters)
 {
     this.Origin         = new PathOrigin(path, parameters);
     this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
 }
Example #6
0
			/// <summary>Creates a new texture.</summary>
			/// <param name="texture">The texture raw data.</param>
			internal Texture(OpenBveApi.Textures.Texture texture) {
				this.Origin = new RawOrigin(texture);
				this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
			}
Example #7
0
			/// <summary>Creates a new texture.</summary>
			/// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
			/// <param name="parameters">The parameters that specify how to process the texture.</param>
			internal Texture(Bitmap bitmap, OpenBveApi.Textures.TextureParameters parameters)
			{
				this.Origin = new BitmapOrigin(bitmap, parameters);
				this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
			}
Example #8
0
			/// <summary>Creates a new texture.</summary>
			/// <param name="bitmap">The System.Drawing.Bitmap that contains the texture.</param>
			internal Texture(Bitmap bitmap) {
				this.Origin = new BitmapOrigin(bitmap);
				this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
			}
Example #9
0
			// --- constructors ---
			/// <summary>Creates a new texture.</summary>
			/// <param name="path">The path to the texture.</param>
			/// <param name="parameters">The parameters that specify how to process the texture.</param>
			internal Texture(string path, OpenBveApi.Textures.TextureParameters parameters) {
				this.Origin = new PathOrigin(path, parameters);
				this.OpenGlTextures = new OpenGlTexture[] { new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture(), new OpenGlTexture() };
			}