Use plain integers for Vulkan handle types in auto-generated bindings

This commit is contained in:
Rua
2018-07-12 16:54:42 +02:00
parent 22c896e360
commit 0a313da485
3 changed files with 18 additions and 7 deletions
+4 -2
View File
@@ -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,
);
}
/// <div rustbindgen replaces="VkInstance"></div>
pub type VkInstance = usize;
/// <div rustbindgen replaces="VkSurfaceKHR"></div>
pub type VkSurfaceKHR = u64;
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
+10
View File
@@ -1,3 +1,13 @@
#include <SDL.h>
#include <SDL_syswm.h>
#include <SDL_vulkan.h>
/**
* <div rustbindgen replaces="VkInstance"></div>
*/
typedef uintptr_t VkInstance_int;
/**
* <div rustbindgen replaces="VkSurfaceKHR"></div>
*/
typedef uint64_t VkSurfaceKHR_int;
+4 -5
View File
@@ -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<VkSurfaceKHR, String> {
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)
}
}