Loads a texture from memory, resource pack or disk file.

HTEXTURE Texture_Load(
  const char *filename,
  DWORD size = 0,
  bool bMipmap = false


Texture file name.
If this parameter isn't 0, it is the size of memory block containing the texture in one of the known formats and the parameter filename is treated as a pointer to this block.
If true, a set of mipmap levels is automatically created and used for rendering.

Return value

If successful, returns the texture handle. Otherwise returns 0.


Supports BMP, DDS, DIB, JPG, PNG and TGA graphics file formats. DDS format allows usage of DXT1-DXT5 texture compression which results in better performance and lower video memory requirements.

Texture dimensions must be a power of 2. If this condition isn't met, the texture is automatically padded to the closest power of 2 dimensions, bigger than it's actual size.

If filename specifies relative path, texture file is first searched within all resource packs attached with Resource_AttachPack, then in the application disk folder. If filename specifies absolute disk path, texture file is loaded directly from disk.

If mipmapping requested, a set of consequent smaller versions of the texture is generated and used for rendering. This results in faster and higher quality rendering of sprites which are significantly reduced compared to their original size. Textures with this option require 1/3 more video memory.

If the function fails, you may obtain error message with System_GetErrorMessage function. Also if HGE_LOGFILE system state was set, the error message is written to log.

When the texture isn't needed longer, you must delete it with Texture_Free function.


Header: hge.h
Import library: hge.lib

See also

Texture_Create, Texture_Free