fix new API use for android example

This commit is contained in:
Chad Brokaw 2022-07-14 15:03:27 -04:00
parent 8de34f8728
commit 58721dc5c2

View file

@ -13,8 +13,8 @@ use ndk::native_window::NativeWindow;
use ndk_glue::Event; use ndk_glue::Event;
use piet_gpu_hal::{ use piet_gpu_hal::{
CmdBuf, Error, ImageLayout, Instance, QueryPool, Semaphore, Session, SubmittedCmdBuf, Surface, CmdBuf, Error, ImageLayout, Instance, InstanceFlags, QueryPool, Semaphore, Session,
Swapchain, SubmittedCmdBuf, Surface, Swapchain,
}; };
use piet::kurbo::Point; use piet::kurbo::Point;
@ -54,9 +54,9 @@ fn my_main() -> Result<(), Error> {
let width = window.width() as usize; let width = window.width() as usize;
let height = window.height() as usize; let height = window.height() as usize;
let handle = get_handle(window); let handle = get_handle(window);
let (instance, surface) = Instance::new(Some(&handle), Default::default())?; let instance = Instance::new(InstanceFlags::PRESENT)?;
gfx_state = let surface = instance.surface(&handle)?;
Some(GfxState::new(&instance, surface.as_ref(), width, height)?); gfx_state = Some(GfxState::new(&instance, Some(&surface), width, height)?);
} else { } else {
println!("native window is sadly none"); println!("native window is sadly none");
} }
@ -100,7 +100,7 @@ impl GfxState {
height: usize, height: usize,
) -> Result<GfxState, Error> { ) -> Result<GfxState, Error> {
unsafe { unsafe {
let device = instance.device(surface)?; let device = instance.device()?;
let swapchain = instance.swapchain(width, height, &device, surface.unwrap())?; let swapchain = instance.swapchain(width, height, &device, surface.unwrap())?;
let session = Session::new(device); let session = Session::new(device);
let current_frame = 0; let current_frame = 0;