Skip to content

Commit

Permalink
update sdl3-sys to 0.1.1 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
maia-s authored Nov 3, 2024
1 parent f5de311 commit fd6ae0c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ libc = "0.2.92"
lazy_static = "1.4.0"

[dependencies.sdl3-sys]
# path = "sdl3-sys"
version = "0.0.10+SDL-preview-3.1.3"
version = "0.1.1"

[dependencies.c_vec]
# allow both 1.* and 2.0 versions
Expand Down
2 changes: 1 addition & 1 deletion src/sdl3/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl AudioSubsystem {
}
}

#[repr(i32)]
#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
pub enum AudioFormat {
/// Unsigned 8-bit samples
Expand Down
6 changes: 3 additions & 3 deletions src/sdl3/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl Gamepad {
let props = sys::gamepad::SDL_GetGamepadProperties(self.raw);
sys::properties::SDL_GetBooleanProperty(
props,
sys::gamepad::SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN.as_ptr(),
sys::gamepad::SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN,
false,
)
}
Expand All @@ -548,7 +548,7 @@ impl Gamepad {
let props = sys::gamepad::SDL_GetGamepadProperties(self.raw);
sys::properties::SDL_GetBooleanProperty(
props,
sys::gamepad::SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN.as_ptr(),
sys::gamepad::SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN,
false,
)
}
Expand All @@ -559,7 +559,7 @@ impl Gamepad {
let props = sys::gamepad::SDL_GetGamepadProperties(self.raw);
sys::properties::SDL_GetBooleanProperty(
props,
sys::gamepad::SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN.as_ptr(),
sys::gamepad::SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN,
false,
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/sdl3/joystick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl Joystick {
let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) };
sys::properties::SDL_GetBooleanProperty(
props,
sys::joystick::SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN.as_ptr(),
sys::joystick::SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN,
false,
)
}
Expand All @@ -412,7 +412,7 @@ impl Joystick {
let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) };
sys::properties::SDL_GetBooleanProperty(
props,
sys::joystick::SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN.as_ptr(),
sys::joystick::SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN,
false,
)
}
Expand All @@ -423,7 +423,7 @@ impl Joystick {
let props = unsafe { sys::joystick::SDL_GetJoystickProperties(self.raw) };
sys::properties::SDL_GetBooleanProperty(
props,
sys::joystick::SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN.as_ptr(),
sys::joystick::SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN,
false,
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/sdl3/raw_window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ unsafe impl HasRawWindowHandle for Window {

handle.ns_window = SDL_GetPointerProperty(
window_properties,
sys::video::SDL_PROP_WINDOW_COCOA_WINDOW_POINTER.as_ptr(),
sys::video::SDL_PROP_WINDOW_COCOA_WINDOW_POINTER,
std::ptr::null_mut(),
);

Expand Down
10 changes: 5 additions & 5 deletions src/sdl3/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ impl InternalTexture {
let format = unsafe {
sys::properties::SDL_GetNumberProperty(
self.get_properties(),
sys::render::SDL_PROP_TEXTURE_FORMAT_NUMBER.as_ptr(),
sys::render::SDL_PROP_TEXTURE_FORMAT_NUMBER,
0,
)
};
Expand All @@ -1871,7 +1871,7 @@ impl InternalTexture {
let access = unsafe {
sys::properties::SDL_GetNumberProperty(
self.get_properties(),
sys::render::SDL_PROP_TEXTURE_ACCESS_NUMBER.as_ptr(),
sys::render::SDL_PROP_TEXTURE_ACCESS_NUMBER,
0,
)
};
Expand All @@ -1882,7 +1882,7 @@ impl InternalTexture {
unsafe {
sys::properties::SDL_GetNumberProperty(
self.get_properties(),
sys::render::SDL_PROP_TEXTURE_WIDTH_NUMBER.as_ptr(),
sys::render::SDL_PROP_TEXTURE_WIDTH_NUMBER,
0,
) as u32
}
Expand All @@ -1892,7 +1892,7 @@ impl InternalTexture {
unsafe {
sys::properties::SDL_GetNumberProperty(
self.get_properties(),
sys::render::SDL_PROP_TEXTURE_HEIGHT_NUMBER.as_ptr(),
sys::render::SDL_PROP_TEXTURE_HEIGHT_NUMBER,
0,
) as u32
}
Expand Down Expand Up @@ -2210,7 +2210,7 @@ impl InternalTexture {
unsafe {
sys::properties::SDL_GetNumberProperty(
props_id,
sys::render::SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER.as_ptr(),
sys::render::SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER,
0,
)
}
Expand Down
26 changes: 11 additions & 15 deletions src/sdl3/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pub mod gl_attr {
macro_rules! gl_set_attribute {
($attr:ident, $value:expr) => {{
let result =
unsafe { sys::video::SDL_GL_SetAttribute(sys::video::SDL_GLattr::$attr, $value) };
unsafe { sys::video::SDL_GL_SetAttribute(sys::video::SDL_GLAttr::$attr, $value) };

if result == false {
// Panic and print the attribute that failed.
Expand All @@ -240,7 +240,7 @@ pub mod gl_attr {
($attr:ident) => {{
let mut value = 0;
let result = unsafe {
sys::video::SDL_GL_GetAttribute(sys::video::SDL_GLattr::$attr, &mut value)
sys::video::SDL_GL_GetAttribute(sys::video::SDL_GLAttr::$attr, &mut value)
};
if result == false {
// Panic and print the attribute that failed.
Expand Down Expand Up @@ -814,8 +814,7 @@ impl VideoSubsystem {
let mut result = Vec::with_capacity(num_modes as usize);
for i in 0..num_modes {
let mode = *modes.offset(i as isize);
let mode = *mode;
result.push(DisplayMode::from_ll(&mode));
result.push(DisplayMode::from_ll(&*mode));
}
SDL_free(modes as *mut c_void);
Ok(result)
Expand All @@ -830,8 +829,7 @@ impl VideoSubsystem {
if raw_mode.is_null() {
return Err(get_error());
}
let mode = *raw_mode;
Ok(DisplayMode::from_ll(&mode))
Ok(DisplayMode::from_ll(&*raw_mode))
}
}

Expand All @@ -848,8 +846,7 @@ impl VideoSubsystem {
if raw_mode.is_null() {
return Err(get_error());
}
let mode = *raw_mode;
Ok(DisplayMode::from_ll(&mode))
Ok(DisplayMode::from_ll(&*raw_mode))
}
}

Expand Down Expand Up @@ -1165,33 +1162,33 @@ impl WindowBuilder {
let props = SDL_CreateProperties();
SDL_SetStringProperty(
props,
sys::video::SDL_PROP_WINDOW_CREATE_TITLE_STRING.as_ptr(),
sys::video::SDL_PROP_WINDOW_CREATE_TITLE_STRING,
title.as_ptr(),
);

if self.x != WindowPos::Undefined {
SDL_SetNumberProperty(
props,
sys::video::SDL_PROP_WINDOW_CREATE_X_NUMBER.as_ptr(),
sys::video::SDL_PROP_WINDOW_CREATE_X_NUMBER,
to_ll_windowpos(self.x).into(),
);
}
if self.y != WindowPos::Undefined {
SDL_SetNumberProperty(
props,
sys::video::SDL_PROP_WINDOW_CREATE_Y_NUMBER.as_ptr(),
sys::video::SDL_PROP_WINDOW_CREATE_Y_NUMBER,
to_ll_windowpos(self.y).into(),
);
}

SDL_SetNumberProperty(
props,
sys::video::SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER.as_ptr(),
sys::video::SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER,
raw_width.into(),
);
SDL_SetNumberProperty(
props,
sys::video::SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER.as_ptr(),
sys::video::SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER,
raw_height.into(),
);
let flags_cstr = CString::new("flags").unwrap();
Expand Down Expand Up @@ -1664,8 +1661,7 @@ impl Window {
if mode_raw.is_null() {
return None;
}
let mode_raw = *mode_raw;
Some(DisplayMode::from_ll(&mode_raw))
Some(DisplayMode::from_ll(&*mode_raw))
}
}

Expand Down

0 comments on commit fd6ae0c

Please sign in to comment.