C4 Engine Terathon Software C4 Engine API Documentation

• Graphics Manager

API Links
Developer Links

Texture::Get

Defined in:  C4Textures.h
Returns a reference to a texture object.
Prototype

static Texture *Get(const char *name, long index = 0);

static Texture *Get(const TextureHeader *header, const void *image = nullptr);

Parameters
name The name of the texture resource.
index The index of the texture within the texture resource.
header A pointer to a TextureHeader structure describing the texture.
image A pointer to the pixel image for the texture. If this is nullptr, then the texture image should immediately follow the texture header in memory.
Description
The Get function returns a reference to a texture map object. A texture map may be stored in a resource or created in memory, and the location determines which version of the Get function should be called. If the texture is stored in a resource, then the version of the Get function taking the name of the resource in the name parameter should be called. If the texture image exists in memory, then the version of the Get function taking a TextureHeader structure should be called.

If a texture object already exists for the parameters passed to the Get function, then its reference count is incremented, and a pointer to the existing object is returned. Otherwise, a new texture object is created with a reference count of 1, and a pointer to the new object is returned. If an attempt is made to create a texture object for a resource that does not exist, then the return value is nullptr.

For each successful call to the Get function, there should be a balancing call to the Shared::Release function that releases the texture object.
See Also

TextureHeader

Shared::Release