diff --git a/libs/filamat/include/filamat/Package.h b/libs/filamat/include/filamat/Package.h index 981e9b4765..de16846e9c 100644 --- a/libs/filamat/include/filamat/Package.h +++ b/libs/filamat/include/filamat/Package.h @@ -34,7 +34,7 @@ public: Package() = default; // Regular constructor - Package(size_t size) : mSize(size) { + explicit Package(size_t size) : mSize(size) { mPayload = (uint8_t*) calloc(1, size); assert(mPayload != nullptr); } diff --git a/samples/app/FilamentApp.cpp b/samples/app/FilamentApp.cpp index efd2df9493..ac9ad10d83 100644 --- a/samples/app/FilamentApp.cpp +++ b/samples/app/FilamentApp.cpp @@ -69,7 +69,7 @@ FilamentApp::~FilamentApp() { } void FilamentApp::run(const Config& config,SetupCallback setupCallback, - CleanupCallback cleanupCallback, ImGuiCallback imguiCallback) { + CleanupCallback cleanupCallback, ImGuiCallback imguiCallback, size_t width, size_t height) { mEngine = Engine::create(config.backend); mDepthMaterial = Material::Builder() @@ -83,7 +83,7 @@ void FilamentApp::run(const Config& config,SetupCallback setupCallback, .build(*mEngine); std::unique_ptr window( - new FilamentApp::Window(this, config, config.title, 1024, 640)); + new FilamentApp::Window(this, config, config.title, width, height)); std::unique_ptr cameraCube(new Cube(*mEngine, mTransparentMaterial, {1,0,0})); // we can't cull the light-frustum because it's not applied a rigid transform diff --git a/samples/app/FilamentApp.h b/samples/app/FilamentApp.h index 47e8308303..00d9d53e6d 100644 --- a/samples/app/FilamentApp.h +++ b/samples/app/FilamentApp.h @@ -59,20 +59,21 @@ public: void animate(AnimCallback animation) { mAnimation = animation; } void run(const Config& config, SetupCallback setup, CleanupCallback cleanup, - ImGuiCallback imgui = ImGuiCallback()); + ImGuiCallback imgui = ImGuiCallback(), size_t width = 1024, size_t height = 640); filament::Material const* getTransparentMaterial() const noexcept { return mTransparentMaterial; } IBL* getIBL() const noexcept { return mIBL.get(); } void close() { mClosed = true; } -private: - FilamentApp(); FilamentApp(const FilamentApp& rhs) = delete; FilamentApp(FilamentApp&& rhs) = delete; FilamentApp& operator=(const FilamentApp& rhs) = delete; FilamentApp& operator=(FilamentApp&& rhs) = delete; +private: + FilamentApp(); + class CView { public: CView(filament::Renderer& renderer, std::string name); diff --git a/samples/app/MeshAssimp.cpp b/samples/app/MeshAssimp.cpp index a914fc4647..741b357338 100644 --- a/samples/app/MeshAssimp.cpp +++ b/samples/app/MeshAssimp.cpp @@ -48,8 +48,7 @@ static constexpr uint8_t DEFAULT_TRANSPARENT_PACKAGE[] = { #include "generated/material/aiDefaultTrans.inc" }; -MeshAssimp::MeshAssimp(Engine& engine, TargetApi targetApi, Platform platform) : mEngine(engine), - mTargetApi(targetApi), mPlatform(platform) { +MeshAssimp::MeshAssimp(Engine& engine) : mEngine(engine) { } MeshAssimp::~MeshAssimp() { diff --git a/samples/app/MeshAssimp.h b/samples/app/MeshAssimp.h index 147929db8b..7aeb64a595 100644 --- a/samples/app/MeshAssimp.h +++ b/samples/app/MeshAssimp.h @@ -46,9 +46,7 @@ public: using half4 = math::half4; using short4 = math::short4; using half2 = math::half2; - using TargetApi = filamat::MaterialBuilderBase::TargetApi; - using Platform = filamat::MaterialBuilderBase::Platform; - MeshAssimp(filament::Engine& engine, TargetApi targetApi, Platform platform); + explicit MeshAssimp(filament::Engine& engine); ~MeshAssimp(); void addFromFile(const utils::Path& path, @@ -95,8 +93,6 @@ private: filament::Material* mDefaultTransparentColorMaterial = nullptr; std::vector mRenderables; - TargetApi mTargetApi; - Platform mPlatform; }; #endif // TNT_FILAMENT_SAMPLE_MESH_ASSIMP_H diff --git a/samples/lightbulb.cpp b/samples/lightbulb.cpp index 87d9f96dfc..eef3a32bf7 100644 --- a/samples/lightbulb.cpp +++ b/samples/lightbulb.cpp @@ -200,8 +200,7 @@ static void cleanup(Engine* engine, View* view, Scene* scene) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" static void setup(Engine* engine, View* view, Scene* scene) { - g_meshSet.reset(new MeshAssimp(*engine, MeshAssimp::TargetApi::OPENGL, - MeshAssimp::Platform::DESKTOP)); + g_meshSet.reset(new MeshAssimp(*engine)); for (auto& filename : g_filenames) { g_meshSet->addFromFile(filename, g_materialLibrary); } diff --git a/samples/material_sandbox.cpp b/samples/material_sandbox.cpp index 091ac57653..db287afba3 100644 --- a/samples/material_sandbox.cpp +++ b/samples/material_sandbox.cpp @@ -137,7 +137,7 @@ static bool g_shadowPlane = false; static void printUsage(char* name) { std::string exec_name(Path(name).getName()); std::string usage( - "SAMPLE_MATERIAL is an example of clear coat materials\n" + "SAMPLE_MATERIAL showcases all material models\n" "Usage:\n" " SAMPLE_MATERIAL [options] \n" "Options:\n" @@ -164,13 +164,13 @@ static void printUsage(char* name) { static int handleCommandLineArgments(int argc, char* argv[], Config* config) { static constexpr const char* OPTSTR = "ha:vps:i:"; static const struct option OPTIONS[] = { - { "help", no_argument, 0, 'h' }, - { "api", required_argument, 0, 'a' }, - { "ibl", required_argument, 0, 'i' }, - { "split-view", no_argument, 0, 'v' }, - { "scale", required_argument, 0, 's' }, - { "shadow-plane", no_argument, 0, 'p' }, - { 0, 0, 0, 0 } // termination of the option list + { "help", no_argument, nullptr, 'h' }, + { "api", required_argument, nullptr, 'a' }, + { "ibl", required_argument, nullptr, 'i' }, + { "split-view", no_argument, nullptr, 'v' }, + { "scale", required_argument, nullptr, 's' }, + { "shadow-plane", no_argument, nullptr, 'p' }, + { nullptr, 0, nullptr, 0 } // termination of the option list }; int opt; int option_index = 0; @@ -219,12 +219,12 @@ static void cleanup(Engine* engine, View*, Scene*) { engine->destroy(material.second); } - for (size_t i = 0; i < MATERIAL_COUNT; i++) { - engine->destroy(g_materialInstance[i]); + for (auto& i : g_materialInstance) { + engine->destroy(i); } - for (size_t i = 0; i < MATERIAL_COUNT; i++) { - engine->destroy(g_material[i]); + for (auto& i : g_material) { + engine->destroy(i); } g_meshSet.reset(nullptr); @@ -237,10 +237,8 @@ static void cleanup(Engine* engine, View*, Scene*) { static void setup(Engine* engine, View*, Scene* scene) { g_scene = scene; - g_meshSet.reset(new MeshAssimp(*engine, MeshAssimp::TargetApi::OPENGL, - MeshAssimp::Platform::DESKTOP)); + g_meshSet = std::make_unique(*engine); - Package pkg; g_material[MATERIAL_UNLIT] = Material::Builder() .package((void*) MATERIAL_UNLIT_PACKAGE, sizeof(MATERIAL_UNLIT_PACKAGE)) .build(*engine); @@ -374,7 +372,7 @@ static void setup(Engine* engine, View*, Scene* scene) { } } -static void gui(filament::Engine* engine, filament::View* view) { +static void gui(filament::Engine* engine, filament::View*) { ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f)); ImGui::Begin("Parameters"); { diff --git a/samples/sample_full_pbr.cpp b/samples/sample_full_pbr.cpp index 213a39ce05..b0c94fe103 100644 --- a/samples/sample_full_pbr.cpp +++ b/samples/sample_full_pbr.cpp @@ -353,8 +353,7 @@ static void setup(Engine* engine, View* view, Scene* scene) { "normalMap", g_normalMap, sampler); } - g_meshSet = std::make_unique(*engine, - MeshAssimp::TargetApi::OPENGL, MeshAssimp::Platform::DESKTOP); + g_meshSet = std::make_unique(*engine); for (auto& filename : g_filenames) { g_meshSet->addFromFile(filename, g_materialInstances, true); } diff --git a/samples/sample_pbr.cpp b/samples/sample_pbr.cpp index d5a1c8a092..6c3db0e559 100644 --- a/samples/sample_pbr.cpp +++ b/samples/sample_pbr.cpp @@ -254,8 +254,7 @@ static void setup(Engine* engine, View* view, Scene* scene) { "metallicRoughnessMap", g_metallicRoughnessMap, sampler); } - g_meshSet = std::make_unique(*engine, - MeshAssimp::TargetApi::OPENGL, MeshAssimp::Platform::DESKTOP); + g_meshSet = std::make_unique(*engine); for (auto& filename : g_filenames) { g_meshSet->addFromFile(filename, g_materialInstances, true); } diff --git a/samples/sample_position_offset.cpp b/samples/sample_position_offset.cpp index 8627c6bf93..a158dfd85a 100644 --- a/samples/sample_position_offset.cpp +++ b/samples/sample_position_offset.cpp @@ -125,8 +125,7 @@ static void cleanup(Engine* engine, View* view, Scene* scene) { } static void setup(Engine* engine, View* view, Scene* scene) { - g_meshSet.reset(new MeshAssimp(*engine, MeshAssimp::TargetApi::OPENGL, - MeshAssimp::Platform::DESKTOP)); + g_meshSet.reset(new MeshAssimp(*engine)); Package pkg = MaterialBuilder() .name("PositionOffset") diff --git a/samples/vk_hellopbr.cpp b/samples/vk_hellopbr.cpp index 7a70543c07..5fa93b88f5 100644 --- a/samples/vk_hellopbr.cpp +++ b/samples/vk_hellopbr.cpp @@ -28,7 +28,6 @@ using namespace filament; using namespace math; using Backend = Engine::Backend; -using TargetApi = MeshAssimp::TargetApi; struct App { utils::Entity light; @@ -53,8 +52,7 @@ int main(int argc, char** argv) { auto& em = utils::EntityManager::get(); // Add geometry into the scene. - TargetApi api = config.backend == Backend::VULKAN ? TargetApi::VULKAN : TargetApi::OPENGL; - app.meshes = new MeshAssimp(*engine, api, MeshAssimp::Platform::DESKTOP); + app.meshes = new MeshAssimp(*engine); app.meshes->addFromFile(MODEL_FILE, app.materials); auto ti = tcm.getInstance(app.meshes->getRenderables()[0]); app.transform = mat4f{ mat3f(1), float3(0, 0, -4) } * tcm.getWorldTransform(ti); diff --git a/samples/vk_shadowtest.cpp b/samples/vk_shadowtest.cpp index 587be49655..dfeb3dd922 100644 --- a/samples/vk_shadowtest.cpp +++ b/samples/vk_shadowtest.cpp @@ -31,7 +31,6 @@ using namespace filament; using namespace math; using Backend = Engine::Backend; -using TargetApi = MeshAssimp::TargetApi; struct GroundPlane { VertexBuffer* vb; @@ -75,8 +74,7 @@ int main(int argc, char** argv) { auto& em = utils::EntityManager::get(); // Add geometry into the scene. - TargetApi api = config.backend == Backend::VULKAN ? TargetApi::VULKAN : TargetApi::OPENGL; - app.meshes = new MeshAssimp(*engine, api, MeshAssimp::Platform::DESKTOP); + app.meshes = new MeshAssimp(*engine); app.meshes->addFromFile(MODEL_FILE, app.materials); auto ti = tcm.getInstance(app.meshes->getRenderables()[0]); app.transform = mat4f{ mat3f(1), float3(0, 0, -4) } * tcm.getWorldTransform(ti);