Skip to content

Instantly share code, notes, and snippets.

@RafaelOliveira
Created September 25, 2024 18:07
Show Gist options
  • Save RafaelOliveira/afaeb0ed650c7603f713882dfb5efb91 to your computer and use it in GitHub Desktop.
Save RafaelOliveira/afaeb0ed650c7603f713882dfb5efb91 to your computer and use it in GitHub Desktop.
Load a ktx texture in OpenGL with libktx
MYAPI void LoadKtxTexture(const char* fileName, int* width, int* height)
{
ktxTexture* kTexture;
GLenum target, glerror;
ktxTexture_CreateFromNamedFile(fileName, KTX_TEXTURE_CREATE_NO_FLAGS, &kTexture);
*width = kTexture->baseWidth;
*height = kTexture->baseHeight;
glGenTextures(1, &texDrawData.activeTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
ktxTexture_GLUpload(kTexture, &texDrawData.activeTextureId, &target, &glerror);
ktxTexture_Destroy(kTexture);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment