From 0a313da48502fb66fa8b1223c6259e0f0a15d8ed Mon Sep 17 00:00:00 2001 From: Rua Date: Thu, 12 Jul 2018 16:54:42 +0200 Subject: [PATCH] Use plain integers for Vulkan handle types in auto-generated bindings --- sdl2-sys/sdl_bindings.rs | 6 ++++-- sdl2-sys/wrapper.h | 10 ++++++++++ src/sdl2/video.rs | 9 ++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sdl2-sys/sdl_bindings.rs b/sdl2-sys/sdl_bindings.rs index 576fb452..dd7ad950 100644 --- a/sdl2-sys/sdl_bindings.rs +++ b/sdl2-sys/sdl_bindings.rs @@ -29283,13 +29283,11 @@ extern "C" { pub struct VkInstance_T { _unused: [u8; 0], } -pub type VkInstance = *mut VkInstance_T; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct VkSurfaceKHR_T { _unused: [u8; 0], } -pub type VkSurfaceKHR = *mut VkSurfaceKHR_T; pub type SDL_vulkanInstance = VkInstance; pub type SDL_vulkanSurface = VkSurfaceKHR; extern "C" { @@ -29488,6 +29486,10 @@ extern "C" { h: *mut ::std::os::raw::c_int, ); } +///
+pub type VkInstance = usize; +///
+pub type VkSurfaceKHR = u64; pub type __builtin_va_list = [__va_list_tag; 1usize]; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/sdl2-sys/wrapper.h b/sdl2-sys/wrapper.h index 7ae5a3a3..8412a434 100644 --- a/sdl2-sys/wrapper.h +++ b/sdl2-sys/wrapper.h @@ -1,3 +1,13 @@ #include #include #include + +/** + *
+ */ +typedef uintptr_t VkInstance_int; + +/** + *
+ */ +typedef uint64_t VkSurfaceKHR_int; diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index c63b23b1..20cd7f5f 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -18,9 +18,8 @@ use get_error; use sys; +pub use sys::{VkInstance, VkSurfaceKHR}; -type VkInstance = usize; -type VkSurfaceKHR = u64; pub struct WindowSurfaceRef<'a>(&'a mut SurfaceRef, &'a Window); @@ -1147,11 +1146,11 @@ impl Window { /// [`vkCreateInstance`](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html) /// function in the Vulkan library. pub fn vulkan_create_surface(&self, instance: VkInstance) -> Result { - let mut surface: sys::VkSurfaceKHR = ptr::null_mut(); - if unsafe { sys::SDL_Vulkan_CreateSurface(self.context.raw, instance as *mut _, &mut surface) } == sys::SDL_bool::SDL_FALSE { + let mut surface: VkSurfaceKHR = 0; + if unsafe { sys::SDL_Vulkan_CreateSurface(self.context.raw, instance, &mut surface) } == sys::SDL_bool::SDL_FALSE { Err(get_error()) } else { - Ok(surface as VkSurfaceKHR) + Ok(surface) } }