### Initialize Filament on Android Source: https://google.github.io/filament/index This example outlines the initial setup for Filament on Android. It requires calling Filament.init() and explains how rendering can be directed to a Surface, enabling output to SurfaceTexture, TextureView, or SurfaceView. It also highlights the use of the UiHelper class for simplified integration. ```java // You must always first initialize Filament by calling `Filament.init()`. // Rendering with Filament on Android is similar to rendering from native code... // You can render into a `Surface` by passing a `Surface` to the `createSwapChain` method. // To make things easier we provide an Android specific API called `UiHelper`... // All you need to do is set a render callback on the helper and attach your `SurfaceView` or `TextureView` to it. // You are still responsible for creating the swap chain in the `onNativeWindowChanged()` callback. ``` -------------------------------- ### Initialize Filament Engine and Swap Chain Source: https://google.github.io/filament/index This snippet demonstrates the fundamental setup for Filament, involving the creation of an Engine, Renderer, and SwapChain. The SwapChain is initialized using a native window pointer, which varies by operating system (e.g., NSView on macOS, HWND on Windows). ```cpp Engine* engine = Engine::create(); SwapChain* swapChain = engine->createSwapChain(nativeWindow); Renderer* renderer = engine->createRenderer(); ``` -------------------------------- ### Install Filament iOS with CocoaPods Source: https://google.github.io/filament/index This code snippet demonstrates how to install the Filament iOS library using CocoaPods. It specifies the Filament pod and a version constraint, ensuring compatibility with the specified release. ```ruby pod 'Filament', '~> 1.68.4' ``` -------------------------------- ### Add Renderable Entities to the Scene Source: https://google.github.io/filament/index This example shows how to create and add renderable objects to a Filament scene. It involves building a quad with specified bounding box, material, and geometry, then adding the resulting entity to the scene. ```cpp Entity renderable = EntityManager::get().create(); // build a quad RenderableManager::Builder(1) .boundingBox({{ -1, -1, -1 }, { 1, 1, 1 }}) .material(0, materialInstance) .geometry(0, RenderableManager::PrimitiveType::TRIANGLES, vertexBuffer, indexBuffer, 0, 6) .culling(false) .build(*engine, renderable); scene->addEntity(renderable); ``` -------------------------------- ### Set up View, Scene, and Camera for Rendering Source: https://google.github.io/filament/index This code illustrates how to prepare for rendering a frame by creating and configuring a Camera, View, and Scene. The Camera is associated with an entity, and the View is configured with both the Camera and the Scene. ```cpp Camera* camera = engine->createCamera(EntityManager::get().create()); View* view = engine->createView(); Scene* scene = engine->createScene(); view->setCamera(camera); view->setScene(scene); ``` -------------------------------- ### Create Material Instance from Baked Package Source: https://google.github.io/filament/index This snippet details the process of creating a MaterialInstance. It involves loading a material from a binary package, which is typically generated by the 'matc' tool, and then creating an instance of that material. ```cpp Material* material = Material::Builder() .package((void*) BAKED_MATERIAL_PACKAGE, sizeof(BAKED_MATERIAL_PACKAGE)) .build(*engine); MaterialInstance* materialInstance = material->createInstance(); ``` -------------------------------- ### Execute the Rendering Loop Source: https://google.github.io/filament/index This code demonstrates the core rendering loop in Filament. It begins a frame, renders the configured view, and ends the frame. The beginFrame() method returns false if the frame should be skipped, preventing unnecessary rendering. ```cpp // beginFrame() returns false if we need to skip a frame if (renderer->beginFrame(swapChain)) { // for each View renderer->render(view); renderer->endFrame(); } ``` -------------------------------- ### Filament Rendering on iOS Source: https://google.github.io/filament/index This section describes Filament's integration with iOS, supporting iOS 11.0 and above. It mentions that rendering is similar to native C++ code and that either a CAEAGLLayer or CAMetalLayer can be passed to createSwapChain. Filament for iOS supports both Metal and OpenGL ES. ```objectivec // Filament is supported on iOS 11.0 and above. // Filament on iOS is largely the same as native rendering with C++. // A `CAEAGLLayer` or `CAMetalLayer` is passed to the `createSwapChain` method. // Filament for iOS supports both Metal (preferred) and OpenGL ES. ``` -------------------------------- ### Add Filament Android Maven Dependency Source: https://google.github.io/filament/index This snippet shows how to add the Filament Android library as a Maven dependency in an Android project. It requires configuring the repositories to include mavenCentral() and then declaring the specific filament-android artifact. ```gradle repositories { // ... mavenCentral() } dependencies { implementation 'com.google.android.filament:filament-android:1.68.4' } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.