Skip to main content.

Safe Texture Loading Functions

These functions attempt to load the requested texture into memory, returning a ImagePtr object which holds a pointer to the Image class which has the details of the texture loaded.

LoadTextureSafe

Function Prototypes

  • ImagePtr LoadTextureSafe(std::string const &filename)
    Loads a texture from the given filename. The GTL will use the file extension (everything after the final . (dot) in the file name) to select the loader.
  • ImagePtr LoadTextureSafe(std::string const &filename, FileTypes val)
    Loads a texture from the given filename. The GTL will use the given FileType value to select the loader to use.
  • ImagePtr LoadTextureSafe(ReadFunc_t reader, SeekFunc_t seeker, FileTypes val)
    Uses the given reading and seeking functions to load in a texture of a given type. The reading and seeking functions must work as specified on the key concepts page. As it copies function pointers this might not be safe for DLL useage.
  • ImagePtr LoadTextureSafe(PHYSFS_File* file, FileTypes val)
    Loads a texture from the given PhysFS file handle using the specified type to select the loader to use.
  • ImagePtr LoadTextureSafe(PHYSFS_File* file, std::string const &filename )
    Loads a texture from the given PhysFS file handle using the filename provided to work out what type the image is to select the loader to use.

Return Value

  • A smart pointer to a class which contains read online formation about the image, a pointer to the image data and functions to manipulate it

Possible Known Exceptions

Other Details / Notes

  • If the image can not be loaded for any reason then the Image class pointed to will have a FORMAT_NONE image type
  • If the requested image is already open else where loading can fail and a pointer to a nulled Image object is return
  • When the FileType is specified the loader doesnt try to to second guess the user, it assumes you know what you are doing.
  • When using the PhysFS support it is upto the end user to link the correct PhysFS lib files into the project. Without doing to the linking of the final exe will fail.

Copyright © 2004, Rob Jones