EntropyCanvas::TextureData
EntropyCanvas::TextureData
Section titled “EntropyCanvas::TextureData”CPU-side texture pixel container. More…
#include <TextureData.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| size_t | totalBytes() const Get total size in bytes across all mip levels. |
| TextureMetadata | toMetadata() const Convert to TextureMetadata for network transfer. |
| bool | isValid() const Check if texture has valid data. |
| size_t | expectedMipBytes(uint32_t mipLevel) const Compute expected byte count for a mip level. |
| AssetId | computeAssetId() const Compute content-addressed AssetId for this texture. |
| uint32_t | calculateMipLevels(uint32_t w, uint32_t h) Calculate number of mip levels for given dimensions. |
| size_t | bytesPerPixel() const Get bytes per pixel for the current format. |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| uint32_t | width Width in pixels. |
| TextureType | type Texture dimension type. |
| std::string | rawFileFormat File format hint (e.g., “tga”, “png”) for decoding on the receiver side. |
| std::vector< uint8_t > | rawFileData Original file bytes (PNG, TGA, etc.) if loaded from file When present, this is preferred for network transfer so the receiver can decode with stb_image. |
| std::string | name Display name only (no file paths for privacy). |
| uint32_t | mipLevels Number of mip levels. |
| std::vector< std::vector< uint8_t > > | mipData Pixel data per mip level mipData[level] contains the bytes for that mip level. |
| uint32_t | height Height in pixels. |
| TextureFormat | format Pixel format. |
| uint32_t | depth Depth (for 3D textures, otherwise 1). |
| ColorSpace | colorSpace Color space interpretation. |
| uint32_t | arrayLayers Number of array layers (for texture arrays). |
Detailed Description
Section titled “Detailed Description”struct EntropyCanvas::TextureData;CPU-side texture pixel container.
Holds pixel data for a texture, ready for GPU upload. Supports multiple mip levels and various formats.
Usage:
// Load from file using TextureLoaderTextureData texture = TextureLoader::loadFromFile("diffuse.png");
// Build metadata for uploadAssetMetadataData metadata;metadata.type = AssetMetadataType::Texture;metadata.textureMetadata = texture.toMetadata();
// Upload via AssetClientauto handle = assetClient->upload( std::span<const uint8_t>(texture.mipData[0]), ContentType::Texture, true, metadata);Public Functions Documentation
Section titled “Public Functions Documentation”function totalBytes
Section titled “function totalBytes”size_t totalBytes() constGet total size in bytes across all mip levels.
Return: Total byte count
function toMetadata
Section titled “function toMetadata”TextureMetadata toMetadata() constConvert to TextureMetadata for network transfer.
Return: TextureMetadata for network transfer
Creates a TextureMetadata struct suitable for AssetClient upload. Does NOT include file paths (privacy protection).
function isValid
Section titled “function isValid”bool isValid() constCheck if texture has valid data.
Return: true if dimensions are non-zero and at least one mip level has data
function expectedMipBytes
Section titled “function expectedMipBytes”size_t expectedMipBytes( uint32_t mipLevel) constCompute expected byte count for a mip level.
Parameters:
- mipLevel Mip level (0 = base)
Return: Expected byte count for that mip level
function computeAssetId
Section titled “function computeAssetId”AssetId computeAssetId() constCompute content-addressed AssetId for this texture.
Return: Content-addressed AssetId for this texture
Computes a SHA-256 hash of the texture data to produce a deterministic, content-addressed identifier. Same texture always produces the same AssetId.
The hash includes:
- name, dimensions, format, type, colorSpace
- all mip level pixel data
function calculateMipLevels
Section titled “function calculateMipLevels”static uint32_t calculateMipLevels( uint32_t w, uint32_t h)Calculate number of mip levels for given dimensions.
Parameters:
- w Width
- h Height
Return: floor(log2(max(w,h))) + 1
function bytesPerPixel
Section titled “function bytesPerPixel”size_t bytesPerPixel() constGet bytes per pixel for the current format.
Return: Bytes per pixel (0 for compressed formats)
Public Attributes Documentation
Section titled “Public Attributes Documentation”variable width
Section titled “variable width”uint32_t width = 0;Width in pixels.
variable type
Section titled “variable type”TextureType type = TextureType::Texture2D;Texture dimension type.
variable rawFileFormat
Section titled “variable rawFileFormat”std::string rawFileFormat;File format hint (e.g., “tga”, “png”) for decoding on the receiver side.
variable rawFileData
Section titled “variable rawFileData”std::vector< uint8_t > rawFileData;Original file bytes (PNG, TGA, etc.) if loaded from file When present, this is preferred for network transfer so the receiver can decode with stb_image.
If empty, mipData is used instead.
variable name
Section titled “variable name”std::string name;Display name only (no file paths for privacy).
variable mipLevels
Section titled “variable mipLevels”uint32_t mipLevels = 1;Number of mip levels.
variable mipData
Section titled “variable mipData”std::vector< std::vector< uint8_t > > mipData;Pixel data per mip level mipData[level] contains the bytes for that mip level.
variable height
Section titled “variable height”uint32_t height = 0;Height in pixels.
variable format
Section titled “variable format”TextureFormat format = TextureFormat::RGBA8;Pixel format.
variable depth
Section titled “variable depth”uint32_t depth = 1;Depth (for 3D textures, otherwise 1).
variable colorSpace
Section titled “variable colorSpace”ColorSpace colorSpace = ColorSpace::sRGB;Color space interpretation.
variable arrayLayers
Section titled “variable arrayLayers”uint32_t arrayLayers = 1;Number of array layers (for texture arrays).
Updated on 2026-01-26 at 17:14:35 -0500