Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I generate mip maps when creating KTX2 files using writer? #672

Closed
GasimGasimzada opened this issue Feb 5, 2023 · 1 comment
Closed

Comments

@GasimGasimzada
Copy link
Contributor

GasimGasimzada commented Feb 5, 2023

I am currently, manually setting data when creating KTX files from my application:

ktxTexture2 *texture = nullptr;
auto res = ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, &texture);

// Need to cast it to ktxTexture to be able to use the functions below
auto *baseTexture = reinterpret_cast<ktxTexture *>(texture);

ktxTexture_SetImageFromMemory(
    baseTexture, 0, 0, 0, static_cast<const ktx_uint8_t *>(asset.data.data),
    asset.size);
ktxTexture_WriteToNamedFile(baseTexture, assetPath.string().c_str());

How am I supposed to generate the mip levels for the texture when I am setting the image memory manually? Is this value only used when loading the KTX2 file?

@MarkCallow
Copy link
Collaborator

MarkCallow commented Feb 7, 2023

libktx does not contain code for resampling images. Open issue #464 is for adding this.

Currently you have to create the mip level images yourself and then set them into the ktxTexture by calling ktxTexture_SetImageFromMemory for each one using the level parameter to tell it which level you are providing.

Closing this as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants