You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
640B

  1. use crate::render::Instance;
  2. use ash::vk;
  3. use std::rc::Rc;
  4. pub struct Surface {
  5. handle: vk::SurfaceKHR,
  6. pub instance: Rc<Instance>,
  7. }
  8. impl Surface {
  9. pub fn create(
  10. instance: Rc<Instance>,
  11. window: &crate::hal::Window,
  12. ) -> Result<Rc<Self>, crate::hal::ErrSdl> {
  13. let handle = window.vulkan_create_surface(&instance)?;
  14. Ok(Rc::new(Self { handle, instance }))
  15. }
  16. }
  17. impl Drop for Surface {
  18. fn drop(&mut self) {
  19. unsafe {
  20. self.instance.surface_ext.destroy_surface(self.handle, None);
  21. }
  22. }
  23. }
  24. impl std::ops::Deref for Surface {
  25. type Target = vk::SurfaceKHR;
  26. fn deref(&self) -> &Self::Target {
  27. &self.handle
  28. }
  29. }
  30. // EOF