.TH "ktx_glloader" 3 "Sun Jun 14 2026 18:00:57" "Version 0.0.0" "libktx Reference" \" -*- nroff -*- .ad l .nh .SH NAME ktx_glloader \- OpenGL Texture Image Loader .PP \- Create texture objects in current OpenGL context\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "\fBktx_error_code_e\fP \fBktxLoadOpenGL\fP (\fBPFNGLGETPROCADDRESS\fP pfnGLGetProcAddress)" .br .RI "Load pointers for the GL functions used by the ktxTexture*_GLUpload functions\&. " .ti -1c .RI "\fBKTX_error_code\fP \fBktxTexture1_GLUpload\fP (\fBktxTexture1\fP *This, GLuint *pTexture, GLenum *pTarget, GLenum *pGlerror)" .br .RI "Create a GL texture object from a \fBktxTexture1\fP object\&. " .ti -1c .RI "\fBKTX_error_code\fP \fBktxTexture2_GLUpload\fP (\fBktxTexture2\fP *This, GLuint *pTexture, GLenum *pTarget, GLenum *pGlerror)" .br .RI "Create a GL texture object from a \fBktxTexture2\fP object\&. " .ti -1c .RI "\fBKTX_error_code\fP \fBktxTexture_GLUpload\fP (\fBktxTexture\fP *This, GLuint *pTexture, GLenum *pTarget, GLenum *pGlerror)" .br .RI "Create a GL texture object from a \fBktxTexture\fP object\&. " .in -1c .SH "Detailed Description" .PP Create texture objects in current OpenGL context\&. .SH "Function Documentation" .PP .SS "\fBktx_error_code_e\fP ktxLoadOpenGL (\fBPFNGLGETPROCADDRESS\fP pfnGLGetProcAddress)" .PP Load pointers for the GL functions used by the ktxTexture*_GLUpload functions\&. Should be called by an application before its first call to a ktxTexture*_GLUpload function, passing a pointer to the GLGetProcAddress function provided by whatever OpenGL framework it is using\&. For backward compatibility, the ktxTexture*_GLUpload functions call this with a NULL pointer causing an attempt to load the pointers from the program module using \fRdlsym\fP (GNU/Linux, macOS), \fRwglGetProcAddr\fP and \fRGetProcAddr\fP (Windows) or \fRemscripten_GetProcAddress\fP (Web)\&. This works with the vast majority of OpenGL implementations but issues have been seen on Fedora systems particularly with NVIDIA hardware\&. For full robustness, applications should call this function\&. .PP \fBParameters\fP .RS 4 \fIpfnGLGetProcAddress\fP pointer to function for retrieving pointers to GL functions\&. If NULL, retrieval is attempted using system dependent generic functions\&. .RE .PP .SS "\fBKTX_error_code\fP ktxTexture1_GLUpload (\fBktxTexture1\fP * This, GLuint * pTexture, GLenum * pTarget, GLenum * pGlerror)" .PP Create a GL texture object from a \fBktxTexture1\fP object\&. Sets the texture object's GL_TEXTURE_MAX_LEVEL parameter according to the number of levels in the KTX data, provided the context supports this feature\&. .PP Unpacks compressed GL_ETC1_RGB8_OES and GL_ETC2_* format textures in software when the format is not supported by the GL context, provided the library has been compiled with \fRSUPPORT_SOFTWARE_ETC_UNPACK\fP defined as 1\&. .PP It will also convert textures with legacy formats to their modern equivalents when the format is not supported by the GL context, provided the library has been compiled with \fRSUPPORT_LEGACY_FORMAT_CONVERSION\fP defined as 1\&. .PP \fBParameters\fP .RS 4 \fIThis\fP handle of the \fBktxTexture\fP to upload\&. .br \fIpTexture\fP name of the GL texture object to load\&. If NULL or if \fR*pTexture == 0\fP the function will generate a texture name\&. The function binds either the generated name or the name given in \fR*pTexture\fP to the texture target returned in \fR*pTarget\fP, before loading the texture data\&. If \fRpTexture\fP is not NULL and a name was generated, the generated name will be returned in *pTexture\&. .br \fIpTarget\fP \fR*pTarget\fP is set to the texture target used\&. The target is chosen based on the file contents\&. .br \fIpGlerror\fP \fR*pGlerror\fP is set to the value returned by glGetError when this function returns the error KTX_GL_ERROR\&. pGlerror can be NULL\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_GL_ERROR\fP\fP A GL error was raised by glBindTexture, glGenTextures or gl*TexImage*\&. The GL error will be returned in \fR*glerror\fP, if glerror is not \fRNULL\fP\&. .br \fI\fBKTX_INVALID_VALUE\fP\fP \fRThis\fP or \fRtarget\fP is \fRNULL\fP or the size of a mip level is greater than the size of the preceding level\&. .br \fI\fBKTX_NOT_FOUND\fP\fP A dynamically loaded OpenGL {,ES} function required by the loader was not found\&. .br \fI\fBKTX_UNSUPPORTED_TEXTURE_TYPE\fP\fP The type of texture is not supported by the current OpenGL context\&. .RE .PP .SS "\fBKTX_error_code\fP ktxTexture2_GLUpload (\fBktxTexture2\fP * This, GLuint * pTexture, GLenum * pTarget, GLenum * pGlerror)" .PP Create a GL texture object from a \fBktxTexture2\fP object\&. Sets the texture object's GL_TEXTURE_MAX_LEVEL parameter according to the number of levels in the KTX data, provided the context supports this feature\&. .PP Unpacks compressed GL_ETC1_RGB8_OES and GL_ETC2_* format textures in software when the format is not supported by the GL context, provided the library has been compiled with \fRSUPPORT_SOFTWARE_ETC_UNPACK\fP defined as 1\&. .PP \fBParameters\fP .RS 4 \fIThis\fP handle of the \fBktxTexture\fP to upload\&. .br \fIpTexture\fP name of the GL texture object to load\&. If NULL or if \fR*pTexture == 0\fP the function will generate a texture name\&. The function binds either the generated name or the name given in \fR*pTexture\fP to the texture target returned in \fR*pTarget\fP, before loading the texture data\&. If \fRpTexture\fP is not NULL and a name was generated, the generated name will be returned in *pTexture\&. .br \fIpTarget\fP \fR*pTarget\fP is set to the texture target used\&. The target is chosen based on the file contents\&. .br \fIpGlerror\fP \fR*pGlerror\fP is set to the value returned by glGetError when this function returns the error KTX_GL_ERROR\&. pGlerror can be NULL\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_GL_ERROR\fP\fP A GL error was raised by glBindTexture, glGenTextures or gl*TexImage*\&. The GL error will be returned in \fR*glerror\fP, if glerror is not \fRNULL\fP\&. .br \fI\fBKTX_INVALID_VALUE\fP\fP \fRThis\fP or \fRtarget\fP is \fRNULL\fP or the size of a mip level is greater than the size of the preceding level\&. .br \fI\fBKTX_NOT_FOUND\fP\fP A dynamically loaded OpenGL {,ES} function required by the loader was not found\&. .br \fI\fBKTX_UNSUPPORTED_TEXTURE_TYPE\fP\fP The type of texture is not supported by the current OpenGL context\&. .RE .PP .SS "\fBKTX_error_code\fP ktxTexture_GLUpload (\fBktxTexture\fP * This, GLuint * pTexture, GLenum * pTarget, GLenum * pGlerror)" .PP Create a GL texture object from a \fBktxTexture\fP object\&. In order to ensure that the GL uploader is not linked into an application unless explicitly called, this is not a virtual function\&. It determines the texture type then dispatches to the correct function\&. .PP Sets the texture object's GL_TEXTURE_MAX_LEVEL parameter according to the number of levels in the KTX data, provided the context supports this feature\&. .PP Unpacks compressed GL_ETC1_RGB8_OES and GL_ETC2_* format textures in software when the format is not supported by the GL context, provided the library has been compiled with \fRSUPPORT_SOFTWARE_ETC_UNPACK\fP defined as 1\&. .PP It will also convert textures with legacy formats to their modern equivalents when the format is not supported by the GL context, provided the library has been compiled with \fRSUPPORT_LEGACY_FORMAT_CONVERSION\fP defined as 1\&. .PP \fBParameters\fP .RS 4 \fIThis\fP handle of the \fBktxTexture\fP to upload\&. .br \fIpTexture\fP name of the GL texture object to load\&. If NULL or if \fR*pTexture == 0\fP the function will generate a texture name\&. The function binds either the generated name or the name given in \fR*pTexture\fP to the texture target returned in \fR*pTarget\fP, before loading the texture data\&. If \fRpTexture\fP is not NULL and a name was generated, the generated name will be returned in *pTexture\&. .br \fIpTarget\fP \fR*pTarget\fP is set to the texture target used\&. The target is chosen based on the file contents\&. .br \fIpGlerror\fP \fR*pGlerror\fP is set to the value returned by glGetError when this function returns the error KTX_GL_ERROR\&. pGlerror can be NULL\&. .RE .PP \fBReturns\fP .RS 4 KTX_SUCCESS on success, other KTX_* enum values on error\&. .RE .PP \fBExceptions\fP .RS 4 \fI\fBKTX_GL_ERROR\fP\fP A GL error was raised by glBindTexture, glGenTextures or gl*TexImage*\&. The GL error will be returned in \fR*glerror\fP, if glerror is not \fRNULL\fP\&. .br \fI\fBKTX_INVALID_VALUE\fP\fP \fRThis\fP or \fRtarget\fP is \fRNULL\fP or the size of a mip level is greater than the size of the preceding level\&. .br \fI\fBKTX_NOT_FOUND\fP\fP A dynamically loaded OpenGL {,ES} function required by the loader was not found\&. .br \fI\fBKTX_UNSUPPORTED_TEXTURE_TYPE\fP\fP The type of texture is not supported by the current OpenGL context\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libktx Reference from the source code\&.