EntropyCanvas::TextureLoader
EntropyCanvas::TextureLoader
Section titled “EntropyCanvas::TextureLoader”Texture loading utility class. More…
#include <TextureLoader.h>
Public Classes
Section titled “Public Classes”| Name | |
|---|---|
| struct | Options Loading options. |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| TextureData | loadFromMemory(std::span< const uint8_t > data, const std::string & formatHint ="", const Options & options =defaultOptions()) =default Load texture from memory buffer. |
| TextureData | loadFromFile(const std::string & filePath, const Options & options =defaultOptions()) =default Load texture from file. |
| bool | isFormatSupported(const std::string & extension) Check if a file format is supported. |
| std::vector< std::string > | getSupportedExtensions() Get list of supported file extensions. |
| void | generateMipChain(TextureData & texture) Generate mip chain for existing texture. |
| const Options & | defaultOptions() Get default loading options. |
Detailed Description
Section titled “Detailed Description”class EntropyCanvas::TextureLoader;Texture loading utility class.
Loads textures from files or memory using OpenImageIO. Supports PNG, JPEG, TGA, BMP, PSD, GIF, HDR, PIC, EXR, TIFF, DPX, DDS, WebP formats.
Usage:
// Load with default optionsTextureData tex = TextureLoader::loadFromFile("diffuse.png");
// Load with custom optionsTextureLoader::Options opts;opts.generateMips = true;opts.maxDimension = 2048;TextureData tex = TextureLoader::loadFromFile("diffuse.png", opts);
// Load from memorystd::vector<uint8_t> pngData = readFileContents("texture.png");TextureData tex = TextureLoader::loadFromMemory(pngData, "png");Public Functions Documentation
Section titled “Public Functions Documentation”function loadFromMemory
Section titled “function loadFromMemory”static TextureData loadFromMemory( std::span< const uint8_t > data, const std::string & formatHint ="", const Options & options =defaultOptions()) =defaultLoad texture from memory buffer.
Parameters:
- data Raw image file data (not raw pixels)
- formatHint File extension hint (e.g., “png”, “jpg”) - may be empty
- options Loading options
Return: TextureData with loaded pixels, or invalid TextureData on failure
function loadFromFile
Section titled “function loadFromFile”static TextureData loadFromFile( const std::string & filePath, const Options & options =defaultOptions()) =defaultLoad texture from file.
Parameters:
- filePath Path to image file
- options Loading options
Return: TextureData with loaded pixels, or invalid TextureData on failure
Supports: PNG, JPEG, TGA, BMP, PSD (composited only), GIF (first frame), HDR (converted to LDR), PIC
function isFormatSupported
Section titled “function isFormatSupported”static bool isFormatSupported( const std::string & extension)Check if a file format is supported.
Parameters:
- extension File extension (e.g., “png”, “.jpg”)
Return: true if format is supported
function getSupportedExtensions
Section titled “function getSupportedExtensions”static std::vector< std::string > getSupportedExtensions()Get list of supported file extensions.
Return: Vector of supported extensions (e.g., {“png”, “jpg”, “tga”, …})
function generateMipChain
Section titled “function generateMipChain”static void generateMipChain( TextureData & texture)Generate mip chain for existing texture.
Parameters:
- texture Texture to generate mips for (must have mipData[0] populated)
Uses box filter downsampling to generate mip levels. Modifies the texture in place.
function defaultOptions
Section titled “function defaultOptions”static inline const Options & defaultOptions()Get default loading options.
Updated on 2026-01-26 at 16:50:32 -0500