diff --git a/android/gltfio-android/src/main/cpp/KtxLoader.cpp b/android/gltfio-android/src/main/cpp/KtxLoader.cpp index 50eaa3bb6a..4e014036ac 100644 --- a/android/gltfio-android/src/main/cpp/KtxLoader.cpp +++ b/android/gltfio-android/src/main/cpp/KtxLoader.cpp @@ -34,7 +34,7 @@ Java_com_google_android_filament_gltfio_KtxLoader_nCreateTexture(JNIEnv* env, jc Engine* engine = (Engine*) nativeEngine; AutoBuffer buffer(env, javaBuffer, remaining); KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize()); - return (jlong) KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) { + return (jlong) ktx::createTexture(engine, *bundle, srgb, [](void* userdata) { KtxBundle* bundle = (KtxBundle*) userdata; delete bundle; }, bundle); @@ -46,7 +46,7 @@ Java_com_google_android_filament_gltfio_KtxLoader_nCreateIndirectLight(JNIEnv* e Engine* engine = (Engine*) nativeEngine; AutoBuffer buffer(env, javaBuffer, remaining); KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize()); - Texture* cubemap = KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) { + Texture* cubemap = ktx::createTexture(engine, *bundle, srgb, [](void* userdata) { KtxBundle* bundle = (KtxBundle*) userdata; delete bundle; }, bundle); @@ -69,7 +69,7 @@ Java_com_google_android_filament_gltfio_KtxLoader_nCreateSkybox(JNIEnv* env, jcl Engine* engine = (Engine*) nativeEngine; AutoBuffer buffer(env, javaBuffer, remaining); KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize()); - Texture* cubemap = KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) { + Texture* cubemap = ktx::createTexture(engine, *bundle, srgb, [](void* userdata) { KtxBundle* bundle = (KtxBundle*) userdata; delete bundle; }, bundle); diff --git a/ios/samples/hello-ar/hello-ar/FilamentArView/FilamentApp.cpp b/ios/samples/hello-ar/hello-ar/FilamentArView/FilamentApp.cpp index 97cd9fe3af..64850f23c9 100644 --- a/ios/samples/hello-ar/hello-ar/FilamentArView/FilamentApp.cpp +++ b/ios/samples/hello-ar/hello-ar/FilamentArView/FilamentApp.cpp @@ -200,7 +200,7 @@ void FilamentApp::setupIbl() { RESOURCES_VENETIAN_CROSSROADS_2K_IBL_SIZE); float3 harmonics[9]; iblBundle->getSphericalHarmonics(harmonics); - app.iblTexture = image::KtxUtility::createTexture(engine, iblBundle, false); + app.iblTexture = image::ktx::createTexture(engine, iblBundle, false); app.indirectLight = IndirectLight::Builder() .reflections(app.iblTexture) diff --git a/ios/samples/hello-gltf/hello-gltf/FilamentView/App.cpp b/ios/samples/hello-gltf/hello-gltf/FilamentView/App.cpp index cf10850fb3..8f04236043 100644 --- a/ios/samples/hello-gltf/hello-gltf/FilamentView/App.cpp +++ b/ios/samples/hello-gltf/hello-gltf/FilamentView/App.cpp @@ -88,11 +88,11 @@ void App::setupIbl() { RESOURCES_VENETIAN_CROSSROADS_2K_IBL_SIZE); float3 harmonics[9]; iblBundle->getSphericalHarmonics(harmonics); - app.iblTexture = image::KtxUtility::createTexture(engine, iblBundle, false); + app.iblTexture = image::ktx::createTexture(engine, iblBundle, false); image::KtxBundle* skyboxBundle = new image::KtxBundle(RESOURCES_VENETIAN_CROSSROADS_2K_SKYBOX_DATA, RESOURCES_VENETIAN_CROSSROADS_2K_SKYBOX_SIZE); - app.skyboxTexture = image::KtxUtility::createTexture(engine, skyboxBundle, false); + app.skyboxTexture = image::ktx::createTexture(engine, skyboxBundle, false); app.skybox = Skybox::Builder() .environment(app.skyboxTexture) diff --git a/ios/samples/hello-pbr/hello-pbr/FilamentApp.cpp b/ios/samples/hello-pbr/hello-pbr/FilamentApp.cpp index ae350a4872..6096144ff7 100644 --- a/ios/samples/hello-pbr/hello-pbr/FilamentApp.cpp +++ b/ios/samples/hello-pbr/hello-pbr/FilamentApp.cpp @@ -47,11 +47,11 @@ void FilamentApp::initialize() { RESOURCES_VENETIAN_CROSSROADS_2K_IBL_SIZE); filament::math::float3 harmonics[9]; iblBundle->getSphericalHarmonics(harmonics); - app.iblTexture = image::KtxUtility::createTexture(engine, iblBundle, false); + app.iblTexture = image::ktx::createTexture(engine, iblBundle, false); image::KtxBundle* skyboxBundle = new image::KtxBundle(RESOURCES_VENETIAN_CROSSROADS_2K_SKYBOX_DATA, RESOURCES_VENETIAN_CROSSROADS_2K_SKYBOX_SIZE); - app.skyboxTexture = image::KtxUtility::createTexture(engine, skyboxBundle, false); + app.skyboxTexture = image::ktx::createTexture(engine, skyboxBundle, false); app.skybox = Skybox::Builder() .environment(app.skyboxTexture) diff --git a/libs/image/include/image/KtxUtility.h b/libs/image/include/image/KtxUtility.h index ebd894293f..8ec2859d01 100644 --- a/libs/image/include/image/KtxUtility.h +++ b/libs/image/include/image/KtxUtility.h @@ -25,12 +25,12 @@ namespace image { /** - * KtxUtility allows clients to create Filament textures from KtxBundle objects. + * Allows clients to create Filament textures from KtxBundle objects. * * Note that libimage does not have a dependency on libfilament, so for simplicity this is a * header-only library with inlined functions. */ -namespace KtxUtility { +namespace ktx { using Texture = filament::Texture; using Engine = filament::Engine; @@ -300,7 +300,7 @@ namespace KtxUtility { return toCompressedFilamentEnum(info.glInternalFormat); } -} // namespace KtxUtility +} // namespace ktx } // namespace image diff --git a/samples/app/IBL.cpp b/samples/app/IBL.cpp index a811665495..520a06b6d2 100644 --- a/samples/app/IBL.cpp +++ b/samples/app/IBL.cpp @@ -70,8 +70,8 @@ bool IBL::loadFromKtx(const std::string& prefix) { KtxBundle* iblKtx = createKtx(iblPath); KtxBundle* skyKtx = createKtx(skyPath); - mSkyboxTexture = KtxUtility::createTexture(&mEngine, skyKtx, false); - mTexture = KtxUtility::createTexture(&mEngine, iblKtx, false); + mSkyboxTexture = ktx::createTexture(&mEngine, skyKtx, false); + mTexture = ktx::createTexture(&mEngine, iblKtx, false); if (!iblKtx->getSphericalHarmonics(mBands)) { return false; diff --git a/samples/suzanne.cpp b/samples/suzanne.cpp index 57ad5e1156..989b08910d 100644 --- a/samples/suzanne.cpp +++ b/samples/suzanne.cpp @@ -88,10 +88,10 @@ int main(int argc, char** argv) { auto ao = new image::KtxBundle(TEXTURES_AO_DATA, TEXTURES_AO_SIZE); auto metallic = new image::KtxBundle(TEXTURES_METALLIC_DATA, TEXTURES_METALLIC_SIZE); auto roughness = new image::KtxBundle(TEXTURES_ROUGHNESS_DATA, TEXTURES_ROUGHNESS_SIZE); - app.albedo = KtxUtility::createTexture(engine, albedo, true); - app.ao = KtxUtility::createTexture(engine, ao, false); - app.metallic = KtxUtility::createTexture(engine, metallic, false); - app.roughness = KtxUtility::createTexture(engine, roughness, false); + app.albedo = ktx::createTexture(engine, albedo, true); + app.ao = ktx::createTexture(engine, ao, false); + app.metallic = ktx::createTexture(engine, metallic, false); + app.roughness = ktx::createTexture(engine, roughness, false); app.normal = loadNormalMap(engine, TEXTURES_NORMAL_DATA, TEXTURES_NORMAL_SIZE); TextureSampler sampler(TextureSampler::MinFilter::LINEAR_MIPMAP_LINEAR, TextureSampler::MagFilter::LINEAR); diff --git a/web/filament-js/jsbindings.cpp b/web/filament-js/jsbindings.cpp index 33de1c6c39..d1daae7252 100644 --- a/web/filament-js/jsbindings.cpp +++ b/web/filament-js/jsbindings.cpp @@ -1108,7 +1108,7 @@ class_("KtxBundle") /// Returns "undefined" if no valid Filament enumerant exists. .function("getInternalFormat", EMBIND_LAMBDA(Texture::InternalFormat, (KtxBundle* self, bool srgb), { - auto result = KtxUtility::toTextureFormat(self->info()); + auto result = ktx::toTextureFormat(self->info()); if (srgb) { if (result == Texture::InternalFormat::RGB8) { result = Texture::InternalFormat::SRGB8; @@ -1125,7 +1125,7 @@ class_("KtxBundle") /// Returns "undefined" if no valid Filament enumerant exists. .function("getPixelDataFormat", EMBIND_LAMBDA(backend::PixelDataFormat, (KtxBundle* self), { - return KtxUtility::toPixelDataFormat(self->getInfo()); + return ktx::toPixelDataFormat(self->getInfo()); }), allow_raw_pointers()) /// getPixelDataType ::method:: @@ -1133,7 +1133,7 @@ class_("KtxBundle") /// Returns "undefined" if no valid Filament enumerant exists. .function("getPixelDataType", EMBIND_LAMBDA(backend::PixelDataType, (KtxBundle* self), { - return KtxUtility::toPixelDataType(self->getInfo()); + return ktx::toPixelDataType(self->getInfo()); }), allow_raw_pointers()) /// getCompressedPixelDataType ::method:: @@ -1141,14 +1141,14 @@ class_("KtxBundle") /// Returns "undefined" if no valid Filament enumerant exists. .function("getCompressedPixelDataType", EMBIND_LAMBDA(backend::CompressedPixelDataType, (KtxBundle* self), { - return KtxUtility::toCompressedPixelDataType(self->getInfo()); + return ktx::toCompressedPixelDataType(self->getInfo()); }), allow_raw_pointers()) /// isCompressed ::method:: /// Per spec, compressed textures in KTX always have their glFormat field set to 0. /// ::retval:: boolean .function("isCompressed", EMBIND_LAMBDA(bool, (KtxBundle* self), { - return KtxUtility::isCompressed(self->getInfo()); + return ktx::isCompressed(self->getInfo()); }), allow_raw_pointers()) .function("isCubemap", &KtxBundle::isCubemap) @@ -1177,9 +1177,9 @@ class_("KtxBundle") return std::string(self->getMetadata(key.c_str())); }), allow_raw_pointers()); -function("KtxUtility$createTexture", EMBIND_LAMBDA(Texture*, +function("ktx$createTexture", EMBIND_LAMBDA(Texture*, (Engine* engine, const KtxBundle& ktx, bool srgb), { - return KtxUtility::createTexture(engine, ktx, srgb, nullptr, nullptr); + return ktx::createTexture(engine, ktx, srgb, nullptr, nullptr); }), allow_raw_pointers()); /// KtxInfo ::class:: Property accessor for KTX header. diff --git a/web/filament-js/utilities.js b/web/filament-js/utilities.js index 6c4da0b7df..b447b6192c 100644 --- a/web/filament-js/utilities.js +++ b/web/filament-js/utilities.js @@ -254,7 +254,7 @@ Filament._createTextureFromKtx = function(ktxdata, engine, options) { options = options || {}; const ktx = options['ktx'] || new Filament.KtxBundle(ktxdata); const srgb = !!options['srgb']; - return Filament.KtxUtility$createTexture(engine, ktx, srgb); + return Filament.ktx$createTexture(engine, ktx, srgb); }; Filament._createIblFromKtx = function(ktxdata, engine, options) {