Unit CastleTextureImages

Description

Handling of images for textures. This unit is not OpenGL-specific, it should be suitable for all 3D libraries. See CastleGLImage for OpenGL-specific handling of textures and other images.

Texture is any TEncodedImage instance. This includes not only a traditional 2D/3D matrix of pixels represented as TCastleImage, but also a texture compressed for GPU (TGPUCompressedImage). Moreover, a texture may have mipmaps defined — they are stored inside TCompositeImage instance (that contains a list of TEncodedImage).

Since not everything can really deal with such flexible definition of a texture, we decided to separate some routines specifically for textures. For example, you have LoadTextureImage to load full texture information — contrast this with LoadImage routine in CastleImages unit, that only returns TCastleImage (a "normal" way to deal with image data).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TTexturesVideosCache A cache of loaded images for textures.

Functions and Procedures

function LoadTextureImage(const URL: string; out Composite: TCompositeImage): TEncodedImage; overload;
function LoadTextureImage(const URL: string): TEncodedImage; overload;

Types

TAutoMinificationFilter = (...);
TMinificationFilter = minNearest..minLinearMipmapLinear;
TAutoMagnificationFilter = (...);
TMagnificationFilter = magNearest..magLinear;

Constants

TextureImageClasses: array [0..3] of TEncodedImageClass = ( TRGBImage, TRGBAlphaImage, TGrayscaleImage, TGrayscaleAlphaImage);
TextureImageClassesAll: array [0..5] of TEncodedImageClass = ( TRGBImage, TRGBAlphaImage, TGrayscaleImage, TGrayscaleAlphaImage, TGPUCompressedImage, TRGBFloatImage);

Variables

LogTextureCache: boolean = false;

Description

Functions and Procedures

function LoadTextureImage(const URL: string; out Composite: TCompositeImage): TEncodedImage; overload;

Load image suitable for a texture. This will load image to memory formats supported by common 3D libraries (like OpenGL), for example it will never return TRGBFloatImage (although OpenGL may support it, but we cannot be sure at this point). It may return texture compressed using one of the GPU compression algorithms (see TTextureCompression).

If the image comes from a TCompositeImage file (DDS, KTX...), it will also return it (if not, Composite returned will be Nil). This allows you to e.g. use texture mipmaps recorded there. Note that Composite.OwnsFirstImage is set to False, so you can always safely free everything by simple FreeAndNil(Image); FreeAndNil(Composite);.

Overloaded version without Composite parameter assumes you're not interested in this information (still it handles Composite files of course, it just doesn't return Composite object instance).

function LoadTextureImage(const URL: string): TEncodedImage; overload;
 

Types

TAutoMinificationFilter = (...);

Texture minification filter (what happens when many texture pixels are squeezed in one screen pixel).

Values
TMinificationFilter = minNearest..minLinearMipmapLinear;
 
TAutoMagnificationFilter = (...);

Texture magnification filter (what happens when a single texture pixel in stretched over many screen pixels).

Values
TMagnificationFilter = magNearest..magLinear;
 

Constants

TextureImageClasses: array [0..3] of TEncodedImageClass = ( TRGBImage, TRGBAlphaImage, TGrayscaleImage, TGrayscaleAlphaImage);

Image classes that are handled by absolutely all OpenGL versions.

TextureImageClassesAll: array [0..5] of TEncodedImageClass = ( TRGBImage, TRGBAlphaImage, TGrayscaleImage, TGrayscaleAlphaImage, TGPUCompressedImage, TRGBFloatImage);

All image classes that may be handled by OpenGL. Some of them may require specific OpenGL extensions or versions (like GPU-compressed or float textures).

Variables

LogTextureCache: boolean = false;

Log texture cache events. Allows to see how the cache performs, and also how alpha channel is detected. A lot of log messages.

Meaningful only if you initialized log (see CastleLog unit) by InitializeLog first.


Generated by PasDoc 0.15.0.