// --- 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; }
/// <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() }; }
/// <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() }; }
/// <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() }; }
// --- 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() }; }