Click or drag to resize
Ab4d.SharpEngine logo

TextureLoader Class

TextureLoader is a static helper class that can be used to create a texture (as GpuImage) from a file. The file can be loaded by providing the file name or the file stream. The texture (GpuImage) can be created by calling CreateTexture method. The created texture can also be cached by the Scene or GpuDevice. Also, before loading the file, the Scene or GpuDevice cache can be checked if the file was already loaded. See remarks for more info.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.UtilitiesTextureLoader

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
public static class TextureLoader

The TextureLoader type exposes the following members.

Methods
 NameDescription
Public methodStatic memberCreateTexture(String, Scene, IBitmapIO, Boolean, Boolean) CreateTexture creates a GpuImage from the specified file. See remarks for TextureLoader for more info.
Public methodStatic memberCreateTexture(String, VulkanDevice, IBitmapIO, Boolean, Boolean) CreateTexture creates a GpuImage from the specified file.
Public methodStatic memberCreateTexture(Stream, String, Scene, IBitmapIO, Boolean, Boolean) CreateTexture creates a GpuImage from the specified file. See remarks for TextureLoader for more info.
Public methodStatic memberCreateTexture(Stream, String, VulkanDevice, IBitmapIO, Boolean, Boolean) CreateTexture creates a GpuImage from the specified file. See remarks for TextureLoader for more info.
Top
Remarks

TextureLoader is a static helper class that can be used to create a texture (as GpuImage) from a file. The file can be loaded by providing the file name or the file stream.

The texture (GpuImage) can be created by calling CreateTexture method.

When the CreateTexture methods are called by providing the Scene object and when useSceneCache is true, then before reading the file, the Scene's cache is checked if the GpuImage was already created from that file. Also, the created GpuImage in added to the Scene's cache.

When the CreateTexture methods are called by providing the VulkanDevice object and when useGpuDeviceCache is true, then before reading the file, the GpuDevice's cache is checked if the GpuImage was already created from that file. Also, the created GpuImage in added to the GpuDevice's cache.

Note that when GpuImage is cached by Scene or GpuDevice objects, then it cannot be disposed by calling the Dispose method. It can be disposed only when the Scene (if cached in Scene) is disposed, when GpuDevice (if cached in GpuDevice) is disposed or if GpuImage is removed from the cache and then disposed.

When the texture is loaded from stream and if you want to use caching, then also the streamFileName must be set. Otherwise no key is provided.

Note that by default useSceneCache is set to true, but useGpuDeviceCache is by default set to false.

To create StandardMaterial or SolidColorMaterial with texture, you can use the constructor that takes texture file name or texture file stream.

See Also