Package 

Class SwapChain


  • 
    public class SwapChain
    
                        

    A SwapChain represents an Operating System's native renderable surface.

    Typically it's a native window or a view. Because a SwapChain is initialized from a native object, it is given to filament as an Object, which must be of the proper type for each platform filament is running on.

    SwapChain swapChain = engine.createSwapChain(nativeWindow);

    The nativeWindow parameter above must be of type:

    ExamplesAndroid

    A Surface can be retrieved from a SurfaceView or SurfaceHolder easily using SurfaceHolder.getSurface() and/or SurfaceView.getHolder().

    To use a Textureview as a SwapChain, it is necessary to first get its SurfaceTexture, for instance using SurfaceTextureListener and then create a Surface:

     // using a TextureView.SurfaceTextureListener:
     public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
         mSurface = new Surface(surfaceTexture);
         // mSurface can now be used with Engine.createSwapChain()
     }
    
    • Method Detail

      • isSRGBSwapChainSupported

         static boolean isSRGBSwapChainSupported(@NonNull() Engine engine)

        Return whether createSwapChain supports the SWAP_CHAIN_CONFIG_SRGB_COLORSPACE flag.The default implementation returns false.

        Parameters:
        engine - A reference to the filament Engine
      • setFrameCompletedCallback

         void setFrameCompletedCallback(@NonNull() Object handler, @NonNull() Runnable callback)

        FrameCompletedCallback is a callback function that notifies an application when a frame'scontents have completed rendering on the GPU.

        Use setFrameCompletedCallback to set a callback on an individual SwapChain. Each time a framecompletes GPU rendering, the callback will be called.

        The FrameCompletedCallback is guaranteed to be called on the main Filament thread.

        Warning: Only Filament's Metal backend supports frame callbacks. Other backends ignore thecallback (which will never be called) and proceed normally.

        Parameters:
        handler - A Executor.
        callback - The Runnable callback to invoke.