public void SurfaceCreated(ISurfaceHolder holder) { if (holder is null) { throw new ArgumentNullException(nameof(holder)); } VeldridSwapchainSource = SwapchainSource.CreateAndroidSurface(holder.Surface.Handle, JNIEnv.Handle); Ready?.Invoke(this, EventArgs.Empty); }
public void SurfaceCreated(ISurfaceHolder holder) { bool deviceCreated = false; if (_backend == GraphicsBackend.Vulkan) { if (GraphicsDevice == null) { SwapchainSource ss = SwapchainSource.CreateAndroidSurface(holder.Surface.Handle, JNIEnv.Handle); SwapchainDescription sd = new SwapchainDescription( ss, (uint)Width, (uint)Height, DeviceOptions.SwapchainDepthFormat, DeviceOptions.SyncToVerticalBlank); GraphicsDevice = GraphicsDevice.CreateVulkan(DeviceOptions, sd); deviceCreated = true; } Debug.Assert(MainSwapchain == null); MainSwapchain = GraphicsDevice.MainSwapchain; } else { Debug.Assert(GraphicsDevice == null && MainSwapchain == null); SwapchainSource ss = SwapchainSource.CreateAndroidSurface(holder.Surface.Handle, JNIEnv.Handle); SwapchainDescription sd = new SwapchainDescription( ss, (uint)Width, (uint)Height, DeviceOptions.SwapchainDepthFormat, DeviceOptions.SyncToVerticalBlank); GraphicsDevice = GraphicsDevice.CreateOpenGLES(DeviceOptions, sd); MainSwapchain = GraphicsDevice.MainSwapchain; deviceCreated = true; } if (deviceCreated) { DeviceCreated?.Invoke(); } _surfaceCreated = true; }