libktx Reference 4.3.2
Libraries and tools to create and read KTX image texture files.
Loading...
Searching...
No Matches
ktxTexture Class Reference

Base class representing a texture. More...

#include <ktx.h>

Public Types

enum  ktxTextureCreateStorageEnum
 Enum for requesting, or not, allocation of storage for images. More...
 
enum  ktxTextureCreateFlagBits
 Flags for requesting services during creation. More...
 
typedef KTX_error_code(* PFNKTXITERCB) (int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void *pixels, void *userdata)
 Signature of function called by the ktxTexture_Iterate* functions to receive image data.
 
typedef ktx_uint32_t ktxTextureCreateFlags
 Type for TextureCreateFlags parameters.
 

Public Member Functions

KTX_error_code ktxTexture_GLUpload (ktxTexture *This, GLuint *pTexture, GLenum *pTarget, GLenum *pGlerror)
 Create a GL texture object from a ktxTexture1 object.
 
KTX_error_code ktxTexture_CreateFromStream (ktxStream *pStream, ktxTextureCreateFlags createFlags, ktxTexture **newTex)
 Create a ktx1 or ktx2 texture according to the stream data.
 
KTX_error_code ktxTexture_CreateFromStdioStream (FILE *stdioStream, ktxTextureCreateFlags createFlags, ktxTexture **newTex)
 Create a ktxTexture1 or ktxTexture2 from a stdio stream according to the stream data.
 
KTX_error_code ktxTexture_CreateFromNamedFile (const char *const filename, ktxTextureCreateFlags createFlags, ktxTexture **newTex)
 Create a ktxTexture1 or ktxTexture2 from a named KTX file according to the file contents.
 
KTX_error_code ktxTexture_CreateFromMemory (const ktx_uint8_t *bytes, ktx_size_t size, ktxTextureCreateFlags createFlags, ktxTexture **newTex)
 Create a ktxTexture1 or ktxTexture2 from KTX-formatted data in memory according to the data contents.
 
ktx_uint8_t * ktxTexture_GetData (ktxTexture *This)
 Return a pointer to the texture image data.
 
ktx_size_t ktxTexture_GetDataSize (ktxTexture *This)
 Return the total size of the texture image data in bytes.
 
ktx_uint32_t ktxTexture_GetElementSize (ktxTexture *This)
 Return the size in bytes of an elements of a texture's images.
 
KTX_error_code ktxTexture_IterateLevelFaces (ktxTexture *This, PFNKTXITERCB iterCb, void *userdata)
 Iterate over the levels or faces in a ktxTexture object.
 
ktx_uint32_t ktxTexture_GetRowPitch (ktxTexture *This, ktx_uint32_t level)
 Return pitch betweeb rows of a texture image level in bytes.
 
KTX_error_code ktxTexture_VkUploadEx_WithSuballocator (ktxTexture *This, ktxVulkanDeviceInfo *vdi, ktxVulkanTexture *vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks *subAllocatorCallbacks)
 Create a Vulkan image object from a ktxTexture object.
 
KTX_error_code ktxTexture_VkUploadEx (ktxTexture *This, ktxVulkanDeviceInfo *vdi, ktxVulkanTexture *vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout)
 Create a Vulkan image object from a ktxTexture object.
 
KTX_error_code ktxTexture_VkUpload (ktxTexture *texture, ktxVulkanDeviceInfo *vdi, ktxVulkanTexture *vkTexture)
 Create a Vulkan image object from a ktxTexture object.
 
VkFormat ktxTexture_GetVkFormat (ktxTexture *This)
 Return the VkFormat enum of a ktxTexture object.
 

Static Public Member Functions

static ktxAstcParams astcDefaultOptions ()
 Creates default ASTC parameters.
 
static VkFormat astcVkFormat (ktx_uint32_t block_size, bool sRGB)
 Should be used to get VkFormat from ASTC block enum.
 
static astcenc_profile astcEncoderAction (const ktxAstcParams &params, const uint32_t *bdb)
 Creates valid ASTC encoder action from string.
 
static astcenc_swizzle astcSwizzle (const ktxAstcParams &params)
 Creates valid ASTC encoder swizzle from string.
 

Data Fields

class_id classId
 Identify the class type.
 
struct ktxTexture_vtblvtbl
 Pointer to the class's vtble.
 
struct ktxTexture_vvtbl * vvtbl
 Pointer to the class's vtble for Vulkan functions.
 
struct ktxTexture_protected * _protected
 Opaque pointer to the class's protected variables.
 
ktx_bool_t isArray
 
ktx_bool_t isCubemap
 
ktx_bool_t generateMipmaps
 
ktx_uint32_t baseWidth
 Width of the texture's base level.
 
ktx_uint32_t baseHeight
 Height of the texture's base level.
 
ktx_uint32_t baseDepth
 Depth of the texture's base level.
 
ktx_uint32_t numDimensions
 Number of dimensions in the texture: 1, 2 or 3.
 
ktx_uint32_t numLevels
 Number of mip levels in the texture.
 
ktx_uint32_t numFaces
 Number of faces: 6 for cube maps, 1 otherwise.
 
struct {
orientation
 Describes the logical orientation of the images in each dimension.
 
ktxHashList kvDataHead
 Head of the hash list of metadata.
 
ktx_uint32_t kvDataLen
 Length of the metadata, if it has been extracted in its raw form, otherwise 0.
 
ktx_uint8_t * kvData
 Pointer to the metadata, if it has been extracted in its raw form, otherwise NULL.
 
ktx_size_t dataSize
 Byte length of the texture's uncompressed image data.
 
ktx_uint8_t * pData
 Pointer to the start of the image data.
 

Detailed Description

Base class representing a texture.

ktxTextures should be created only by one of the provided functions and these fields should be considered read-only.

Examples
glloader.c, and vkload.cpp.

Member Typedef Documentation

◆ ktxTextureCreateFlags

typedef ktx_uint32_t ktxTextureCreateFlags

Type for TextureCreateFlags parameters.

See also
ktxTexture_CreateFrom*()

◆ PFNKTXITERCB

typedef KTX_error_code(* PFNKTXITERCB) (int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void *pixels, void *userdata)

Signature of function called by the ktxTexture_Iterate* functions to receive image data.

The function parameters are used to pass values which change for each image. Obtain values which are uniform across all images from the ktxTexture object.

Parameters
[in]miplevelMIP level from 0 to the max level which is dependent on the texture size.
[in]faceusually 0; for cube maps, one of the 6 cube faces in the order +X, -X, +Y, -Y, +Z, -Z, 0 to 5.
[in]widthwidth of the image.
[in]heightheight of the image or, for 1D textures textures, 1.
[in]depthdepth of the image or, for 1D & 2D textures, 1.
[in]faceLodSizenumber of bytes of data pointed at by pixels.
[in]pixelspointer to the image data.
[in,out]userdatapointer for the application to pass data to and from the callback function.

Member Enumeration Documentation

◆ ktxTextureCreateFlagBits

Flags for requesting services during creation.

See also
ktxTexture_CreateFrom*

◆ ktxTextureCreateStorageEnum

Enum for requesting, or not, allocation of storage for images.

See also
ktxTexture1_Create() and ktxTexture2_Create().

Member Function Documentation

◆ astcDefaultOptions()

static ktxAstcParams astcDefaultOptions ( )
static

Creates default ASTC parameters.

Returns
ktxAstcParams with default options for ASTC compressor

◆ astcEncoderAction()

static astcenc_profile astcEncoderAction ( const ktxAstcParams params,
const uint32_t *  bdb 
)
static

Creates valid ASTC encoder action from string.

Returns
Valid astc_profile from string

◆ astcSwizzle()

static astcenc_swizzle astcSwizzle ( const ktxAstcParams params)
static

Creates valid ASTC encoder swizzle from string.

Returns
Valid astcenc_swizzle from string

◆ astcVkFormat()

static VkFormat astcVkFormat ( ktx_uint32_t  block_size,
bool  sRGB 
)
static

Should be used to get VkFormat from ASTC block enum.

Returns
VKFormat for a specific ASTC block size

Field Documentation

◆ baseWidth

baseWidth

Width of the texture's base level.

n

◆ classId

classId

Identify the class type.

Since there are no public ktxTexture constructors, this can only have values of ktxTexture1_c or ktxTexture2_c.

Examples
glloader.c.

◆ generateMipmaps

generateMipmaps

KTX_TRUE if mipmaps should be generated for the texture by ktxTexture_GLUpload() or ktxTexture_VkUpload().

Examples
glloader.c.

◆ isArray

isArray

KTX_TRUE if the texture is an array texture, i.e, a GL_TEXTURE_*_ARRAY target is to be used.

Examples
glloader.c.

◆ isCubemap

isCubemap

KTX_TRUE if the texture is a cubemap or cubemap array.

KTX_TRUE if the texture's format is a block compressed format.

◆ numLevels

numLevels

Number of mip levels in the texture.

Number of array layers in the texture.

Must be 1, if generateMipmaps is KTX_TRUE. Can be less than a full pyramid but always starts at the base level.

Examples
glloader.c.

◆ orientation

orientation

Describes the logical orientation of the images in each dimension.

ktxOrientationX for X, ktxOrientationY for Y and ktxOrientationZ for Z.

◆ vvtbl

vvtbl

Pointer to the class's vtble for Vulkan functions.

A separate vtble is used so this header does not need to include vulkan.h.