diff --git a/sdl2-sys/src/audio.rs b/sdl2-sys/src/audio.rs index eb5cb899..3f6a582d 100644 --- a/sdl2-sys/src/audio.rs +++ b/sdl2-sys/src/audio.rs @@ -38,10 +38,10 @@ pub struct SDL_AudioSpec { pub padding: uint16_t, pub size: uint32_t, pub callback: SDL_AudioCallback, - pub userdata: *const c_void, + pub userdata: *mut c_void, } pub type SDL_AudioFilter = - Option; + Option; #[allow(dead_code, missing_copy_implementations, raw_pointer_derive)] #[derive(Copy, Clone)] #[repr(C)] @@ -70,7 +70,7 @@ extern "C" { pub fn SDL_AudioQuit(); pub fn SDL_GetCurrentAudioDriver() -> *const c_char; pub fn SDL_OpenAudio(desired: *const SDL_AudioSpec, - obtained: *const SDL_AudioSpec) -> c_int; + obtained: *mut SDL_AudioSpec) -> c_int; pub fn SDL_GetNumAudioDevices(iscapture: c_int) -> c_int; pub fn SDL_GetAudioDeviceName(index: c_int, iscapture: c_int) -> *const c_char; pub fn SDL_OpenAudioDevice(device: *const c_char, iscapture: c_int, @@ -82,7 +82,7 @@ extern "C" { SDL_AudioStatus; pub fn SDL_PauseAudio(pause_on: c_int); pub fn SDL_PauseAudioDevice(dev: SDL_AudioDeviceID, pause_on: c_int); - pub fn SDL_LoadWAV_RW(src: *const SDL_RWops, freesrc: c_int, + pub fn SDL_LoadWAV_RW(src: *mut SDL_RWops, freesrc: c_int, spec: *mut SDL_AudioSpec, audio_buf: *mut *mut uint8_t, audio_len: *mut uint32_t) -> *mut SDL_AudioSpec; pub fn SDL_FreeWAV(audio_buf: *mut uint8_t); @@ -91,9 +91,9 @@ extern "C" { src_rate: c_int, dst_format: SDL_AudioFormat, dst_channels: uint8_t, dst_rate: c_int) -> c_int; pub fn SDL_ConvertAudio(cvt: *mut SDL_AudioCVT) -> c_int; - pub fn SDL_MixAudio(dst: *const uint8_t, src: *const uint8_t, len: uint32_t, + pub fn SDL_MixAudio(dst: *mut uint8_t, src: *const uint8_t, len: uint32_t, volume: c_int); - pub fn SDL_MixAudioFormat(dst: *const uint8_t, src: *const uint8_t, + pub fn SDL_MixAudioFormat(dst: *mut uint8_t, src: *const uint8_t, format: SDL_AudioFormat, len: uint32_t, volume: c_int); pub fn SDL_LockAudio(); diff --git a/sdl2-sys/src/controller.rs b/sdl2-sys/src/controller.rs index cf512051..c793af28 100644 --- a/sdl2-sys/src/controller.rs +++ b/sdl2-sys/src/controller.rs @@ -36,14 +36,14 @@ pub struct SDL_GameControllerButtonBindDataHat { } impl SDL_GameControllerButtonBindData { - pub fn button(&self) -> *const c_int { - self.data.as_ptr() as *const _ + pub fn button(&mut self) -> *mut c_int { + self.data.as_mut_ptr() as *mut _ } - pub fn axis(&self) -> *const c_int { - self.data.as_ptr() as *const _ + pub fn axis(&mut self) -> *mut c_int { + self.data.as_mut_ptr() as *mut _ } - pub fn hat(&self) -> *const SDL_GameControllerButtonBindDataHat { - self.data.as_ptr() as *const _ + pub fn hat(&mut self) -> *mut SDL_GameControllerButtonBindDataHat { + self.data.as_mut_ptr() as *mut _ } } @@ -80,21 +80,21 @@ extern "C" { pub fn SDL_GameControllerAddMapping(mappingString: *const c_char) -> c_int; pub fn SDL_GameControllerMappingForGUID(guid: SDL_JoystickGUID) -> *const c_char; - pub fn SDL_GameControllerMapping(gamecontroller: *const SDL_GameController) + pub fn SDL_GameControllerMapping(gamecontroller: *mut SDL_GameController) -> *const c_char; pub fn SDL_IsGameController(joystick_index: c_int) -> SDL_bool; pub fn SDL_GameControllerNameForIndex(joystick_index: c_int) -> *const c_char; pub fn SDL_GameControllerOpen(joystick_index: c_int) -> - *const SDL_GameController; - pub fn SDL_GameControllerName(gamecontroller: *const SDL_GameController) -> + *mut SDL_GameController; + pub fn SDL_GameControllerName(gamecontroller: *mut SDL_GameController) -> *const c_char; pub fn SDL_GameControllerGetAttached(gamecontroller: - *const SDL_GameController) -> + *mut SDL_GameController) -> SDL_bool; pub fn SDL_GameControllerGetJoystick(gamecontroller: - *const SDL_GameController) -> - *const SDL_Joystick; + *mut SDL_GameController) -> + *mut SDL_Joystick; pub fn SDL_GameControllerEventState(state: c_int) -> c_int; pub fn SDL_GameControllerUpdate(); pub fn SDL_GameControllerGetAxisFromString(pchString: *const c_char) -> @@ -103,10 +103,10 @@ extern "C" { SDL_GameControllerAxis) -> *const c_char; pub fn SDL_GameControllerGetBindForAxis(gamecontroller: - *const SDL_GameController, + *mut SDL_GameController, axis: SDL_GameControllerAxis) -> SDL_GameControllerButtonBind; - pub fn SDL_GameControllerGetAxis(gamecontroller: *const SDL_GameController, + pub fn SDL_GameControllerGetAxis(gamecontroller: *mut SDL_GameController, axis: SDL_GameControllerAxis) -> int16_t; pub fn SDL_GameControllerGetButtonFromString(pchString: *const c_char) -> @@ -115,13 +115,13 @@ extern "C" { SDL_GameControllerButton) -> *const c_char; pub fn SDL_GameControllerGetBindForButton(gamecontroller: - *const SDL_GameController, + *mut SDL_GameController, button: SDL_GameControllerButton) -> SDL_GameControllerButtonBind; pub fn SDL_GameControllerGetButton(gamecontroller: - *const SDL_GameController, + *mut SDL_GameController, button: SDL_GameControllerButton) -> uint8_t; - pub fn SDL_GameControllerClose(gamecontroller: *const SDL_GameController); + pub fn SDL_GameControllerClose(gamecontroller: *mut SDL_GameController); } diff --git a/sdl2-sys/src/event.rs b/sdl2-sys/src/event.rs index d7e0cc22..76f3921a 100644 --- a/sdl2-sys/src/event.rs +++ b/sdl2-sys/src/event.rs @@ -320,8 +320,8 @@ pub struct SDL_UserEvent { pub timestamp: uint32_t, pub windowID: uint32_t, pub code: int32_t, - pub data1: *const c_void, - pub data2: *const c_void, + pub data1: *mut c_void, + pub data2: *mut c_void, } #[allow(missing_copy_implementations)] @@ -329,7 +329,7 @@ pub struct SDL_UserEvent { pub struct SDL_SysWMEvent { pub type_: uint32_t, pub timestamp: uint32_t, - pub msg: *const SDL_SysWMmsg, + pub msg: *mut SDL_SysWMmsg, } #[allow(missing_copy_implementations)] @@ -339,100 +339,100 @@ pub struct SDL_Event { } impl SDL_Event { - pub fn type_(&self) -> *const uint32_t { - self.data.as_ptr() as *const _ + pub fn type_(&mut self) -> *mut uint32_t { + self.data.as_mut_ptr() as *mut _ } - pub fn common(&self) -> *const SDL_CommonEvent { - self.data.as_ptr() as *const _ + pub fn common(&mut self) -> *mut SDL_CommonEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn window(&self) -> *const SDL_WindowEvent { - self.data.as_ptr() as *const _ + pub fn window(&mut self) -> *mut SDL_WindowEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn key(&self) -> *const SDL_KeyboardEvent { - self.data.as_ptr() as *const _ + pub fn key(&mut self) -> *mut SDL_KeyboardEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn edit(&self) -> *const SDL_TextEditingEvent { - self.data.as_ptr() as *const _ + pub fn edit(&mut self) -> *mut SDL_TextEditingEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn text(&self) -> *const SDL_TextInputEvent { - self.data.as_ptr() as *const _ + pub fn text(&mut self) -> *mut SDL_TextInputEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn motion(&self) -> *const SDL_MouseMotionEvent { - self.data.as_ptr() as *const _ + pub fn motion(&mut self) -> *mut SDL_MouseMotionEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn button(&self) -> *const SDL_MouseButtonEvent { - self.data.as_ptr() as *const _ + pub fn button(&mut self) -> *mut SDL_MouseButtonEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn wheel(&self) -> *const SDL_MouseWheelEvent { - self.data.as_ptr() as *const _ + pub fn wheel(&mut self) -> *mut SDL_MouseWheelEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn jaxis(&self) -> *const SDL_JoyAxisEvent { - self.data.as_ptr() as *const _ + pub fn jaxis(&mut self) -> *mut SDL_JoyAxisEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn jball(&self) -> *const SDL_JoyBallEvent { - self.data.as_ptr() as *const _ + pub fn jball(&mut self) -> *mut SDL_JoyBallEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn jhat(&self) -> *const SDL_JoyHatEvent { - self.data.as_ptr() as *const _ + pub fn jhat(&mut self) -> *mut SDL_JoyHatEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn jbutton(&self) -> *const SDL_JoyButtonEvent { - self.data.as_ptr() as *const _ + pub fn jbutton(&mut self) -> *mut SDL_JoyButtonEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn jdevice(&self) -> *const SDL_JoyDeviceEvent { - self.data.as_ptr() as *const _ + pub fn jdevice(&mut self) -> *mut SDL_JoyDeviceEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn caxis(&self) -> *const SDL_ControllerAxisEvent { - self.data.as_ptr() as *const _ + pub fn caxis(&mut self) -> *mut SDL_ControllerAxisEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn cbutton(&self) -> *const SDL_ControllerButtonEvent { - self.data.as_ptr() as *const _ + pub fn cbutton(&mut self) -> *mut SDL_ControllerButtonEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn cdevice(&self) -> *const SDL_ControllerDeviceEvent { - self.data.as_ptr() as *const _ + pub fn cdevice(&mut self) -> *mut SDL_ControllerDeviceEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn quit(&self) -> *const SDL_QuitEvent { - self.data.as_ptr() as *const _ + pub fn quit(&mut self) -> *mut SDL_QuitEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn user(&self) -> *const SDL_UserEvent { - self.data.as_ptr() as *const _ + pub fn user(&mut self) -> *mut SDL_UserEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn syswm(&self) -> *const SDL_SysWMEvent { - self.data.as_ptr() as *const _ + pub fn syswm(&mut self) -> *mut SDL_SysWMEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn tfinger(&self) -> *const SDL_TouchFingerEvent { - self.data.as_ptr() as *const _ + pub fn tfinger(&mut self) -> *mut SDL_TouchFingerEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn mgesture(&self) -> *const SDL_MultiGestureEvent { - self.data.as_ptr() as *const _ + pub fn mgesture(&mut self) -> *mut SDL_MultiGestureEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn dgesture(&self) -> *const SDL_DollarGestureEvent { - self.data.as_ptr() as *const _ + pub fn dgesture(&mut self) -> *mut SDL_DollarGestureEvent { + self.data.as_mut_ptr() as *mut _ } - pub fn drop(&self) -> *const SDL_DropEvent { - self.data.as_ptr() as *const _ + pub fn drop(&mut self) -> *mut SDL_DropEvent { + self.data.as_mut_ptr() as *mut _ } } @@ -441,10 +441,10 @@ pub const SDL_ADDEVENT: SDL_eventaction = 0; pub const SDL_PEEKEVENT: SDL_eventaction = 1; pub const SDL_GETEVENT: SDL_eventaction = 2; pub type SDL_EventFilter = - extern "C" fn(userdata: *const c_void, event: *const SDL_Event) -> c_int; + extern "C" fn(userdata: *mut c_void, event: *mut SDL_Event) -> c_int; extern "C" { - pub fn SDL_free(mem: *const c_void); + pub fn SDL_free(mem: *mut c_void); pub fn SDL_PumpEvents(); pub fn SDL_PeepEvents(events: *mut SDL_Event, numevents: c_int, action: SDL_eventaction, @@ -460,12 +460,12 @@ extern "C" { c_int; pub fn SDL_PushEvent(event: *mut SDL_Event) -> c_int; pub fn SDL_SetEventFilter(filter: SDL_EventFilter, - userdata: *const c_void); + userdata: *mut c_void); /*pub fn SDL_GetEventFilter(filter: *SDL_EventFilter, userdata: **c_void) -> SDL_bool;*/ - pub fn SDL_AddEventWatch(filter: SDL_EventFilter, userdata: *const c_void); - pub fn SDL_DelEventWatch(filter: SDL_EventFilter, userdata: *const c_void); - pub fn SDL_FilterEvents(filter: SDL_EventFilter, userdata: *const c_void); + pub fn SDL_AddEventWatch(filter: SDL_EventFilter, userdata: *mut c_void); + pub fn SDL_DelEventWatch(filter: SDL_EventFilter, userdata: *mut c_void); + pub fn SDL_FilterEvents(filter: SDL_EventFilter, userdata: *mut c_void); pub fn SDL_EventState(type_: uint32_t, state: SDL_EventState) -> SDL_EventState; pub fn SDL_RegisterEvents(numevents: c_int) -> uint32_t; } diff --git a/sdl2-sys/src/gesture.rs b/sdl2-sys/src/gesture.rs index ff916bd0..01951a81 100644 --- a/sdl2-sys/src/gesture.rs +++ b/sdl2-sys/src/gesture.rs @@ -6,7 +6,7 @@ pub type SDL_GestureID = int64_t; extern "C" { pub fn SDL_RecordGesture(touchId: SDL_TouchID) -> c_int; - pub fn SDL_SaveAllDollarTemplates(src: *const SDL_RWops) -> c_int; - pub fn SDL_SaveDollarTemplate(gestureId: SDL_GestureID, src: *const SDL_RWops) -> c_int; - pub fn SDL_LoadDollarTemplates(touchId: SDL_TouchID, src: *const SDL_RWops) -> c_int; + pub fn SDL_SaveAllDollarTemplates(src: *mut SDL_RWops) -> c_int; + pub fn SDL_SaveDollarTemplate(gestureId: SDL_GestureID, src: *mut SDL_RWops) -> c_int; + pub fn SDL_LoadDollarTemplates(touchId: SDL_TouchID, src: *mut SDL_RWops) -> c_int; } diff --git a/sdl2-sys/src/haptic.rs b/sdl2-sys/src/haptic.rs index 9b4742ce..48d5dcc1 100644 --- a/sdl2-sys/src/haptic.rs +++ b/sdl2-sys/src/haptic.rs @@ -132,64 +132,64 @@ pub struct SDL_HapticEffect { } impl SDL_HapticEffect { - pub fn type_(&self) -> *const uint16_t { - self.data.as_ptr() as *const _ + pub fn type_(&mut self) -> *mut uint16_t { + self.data.as_mut_ptr() as *mut _ } - pub fn constant(&self) -> *const SDL_HapticConstant { - self.data.as_ptr() as *const _ + pub fn constant(&mut self) -> *mut SDL_HapticConstant { + self.data.as_mut_ptr() as *mut _ } - pub fn periodic(&self) -> *const SDL_HapticPeriodic { - self.data.as_ptr() as *const _ + pub fn periodic(&mut self) -> *mut SDL_HapticPeriodic { + self.data.as_mut_ptr() as *mut _ } - pub fn condition(&self) -> *const SDL_HapticCondition { - self.data.as_ptr() as *const _ + pub fn condition(&mut self) -> *mut SDL_HapticCondition { + self.data.as_mut_ptr() as *mut _ } - pub fn ramp(&self) -> *const SDL_HapticRamp { - self.data.as_ptr() as *const _ + pub fn ramp(&mut self) -> *mut SDL_HapticRamp { + self.data.as_mut_ptr() as *mut _ } - pub fn left_right(&self) -> *const SDL_HapticLeftRight { - self.data.as_ptr() as *const _ + pub fn left_right(&mut self) -> *mut SDL_HapticLeftRight { + self.data.as_mut_ptr() as *mut _ } - pub fn custom(&self) -> *const SDL_HapticCustom { - self.data.as_ptr() as *const _ + pub fn custom(&mut self) -> *mut SDL_HapticCustom { + self.data.as_mut_ptr() as *mut _ } } extern "C" { pub fn SDL_NumHaptics() -> c_int; pub fn SDL_HapticName(device_index: c_int) -> *const c_char; - pub fn SDL_HapticOpen(device_index: c_int) -> *const SDL_Haptic; + pub fn SDL_HapticOpen(device_index: c_int) -> *mut SDL_Haptic; pub fn SDL_HapticOpened(device_index: c_int) -> c_int; - pub fn SDL_HapticIndex(haptic: *const SDL_Haptic) -> c_int; + pub fn SDL_HapticIndex(haptic: *mut SDL_Haptic) -> c_int; pub fn SDL_MouseIsHaptic() -> c_int; - pub fn SDL_HapticOpenFromMouse() -> *const SDL_Haptic; - pub fn SDL_JoystickIsHaptic(joystick: *const SDL_Joystick) -> c_int; - pub fn SDL_HapticOpenFromJoystick(joystick: *const SDL_Joystick) -> *const SDL_Haptic; - pub fn SDL_HapticClose(haptic: *const SDL_Haptic); - pub fn SDL_HapticNumEffects(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticNumEffectsPlaying(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticQuery(haptic: *const SDL_Haptic) -> c_uint; - pub fn SDL_HapticNumAxes(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticEffectSupported(haptic: *const SDL_Haptic, effect: *const SDL_HapticEffect) -> c_int; - pub fn SDL_HapticNewEffect(haptic: *const SDL_Haptic, effect: *const SDL_HapticEffect) -> c_int; - pub fn SDL_HapticUpdateEffect(haptic: *const SDL_Haptic, effect: *const SDL_HapticEffect) -> c_int; - pub fn SDL_HapticRunEffect(haptic: *const SDL_Haptic, effect: c_int, iterations: uint32_t) -> c_int; - pub fn SDL_HapticStopEffect(haptic: *const SDL_Haptic, effect: c_int) -> c_int; - pub fn SDL_HapticDestroyEffect(haptic: *const SDL_Haptic, effect: c_int); - pub fn SDL_HapticGetEffectStatus(haptic: *const SDL_Haptic, effect: c_int) -> c_int; - pub fn SDL_HapticSetGain(haptic: *const SDL_Haptic, gain: c_int) -> c_int; - pub fn SDL_HapticSetAutocenter(haptic: *const SDL_Haptic, autocenter: c_int) -> c_int; - pub fn SDL_HapticPause(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticUnpause(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticStopAll(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticRumbleSupported(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticRumbleInit(haptic: *const SDL_Haptic) -> c_int; - pub fn SDL_HapticRumblePlay(haptic: *const SDL_Haptic, strength: c_float, length: uint32_t) -> c_int; - pub fn SDL_HapticRumbleStop(haptic: *const SDL_Haptic) -> c_int; + pub fn SDL_HapticOpenFromMouse() -> *mut SDL_Haptic; + pub fn SDL_JoystickIsHaptic(joystick: *mut SDL_Joystick) -> c_int; + pub fn SDL_HapticOpenFromJoystick(joystick: *mut SDL_Joystick) -> *mut SDL_Haptic; + pub fn SDL_HapticClose(haptic: *mut SDL_Haptic); + pub fn SDL_HapticNumEffects(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticNumEffectsPlaying(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticQuery(haptic: *mut SDL_Haptic) -> c_uint; + pub fn SDL_HapticNumAxes(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticEffectSupported(haptic: *mut SDL_Haptic, effect: *mut SDL_HapticEffect) -> c_int; + pub fn SDL_HapticNewEffect(haptic: *mut SDL_Haptic, effect: *mut SDL_HapticEffect) -> c_int; + pub fn SDL_HapticUpdateEffect(haptic: *mut SDL_Haptic, effect: *mut SDL_HapticEffect) -> c_int; + pub fn SDL_HapticRunEffect(haptic: *mut SDL_Haptic, effect: c_int, iterations: uint32_t) -> c_int; + pub fn SDL_HapticStopEffect(haptic: *mut SDL_Haptic, effect: c_int) -> c_int; + pub fn SDL_HapticDestroyEffect(haptic: *mut SDL_Haptic, effect: c_int); + pub fn SDL_HapticGetEffectStatus(haptic: *mut SDL_Haptic, effect: c_int) -> c_int; + pub fn SDL_HapticSetGain(haptic: *mut SDL_Haptic, gain: c_int) -> c_int; + pub fn SDL_HapticSetAutocenter(haptic: *mut SDL_Haptic, autocenter: c_int) -> c_int; + pub fn SDL_HapticPause(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticUnpause(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticStopAll(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticRumbleSupported(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticRumbleInit(haptic: *mut SDL_Haptic) -> c_int; + pub fn SDL_HapticRumblePlay(haptic: *mut SDL_Haptic, strength: c_float, length: uint32_t) -> c_int; + pub fn SDL_HapticRumbleStop(haptic: *mut SDL_Haptic) -> c_int; } diff --git a/sdl2-sys/src/joystick.rs b/sdl2-sys/src/joystick.rs index 9eefbfa6..4b5eee23 100644 --- a/sdl2-sys/src/joystick.rs +++ b/sdl2-sys/src/joystick.rs @@ -14,31 +14,31 @@ pub struct SDL_JoystickGUID { extern "C" { pub fn SDL_NumJoysticks() -> c_int; pub fn SDL_JoystickNameForIndex(device_index: c_int) -> *const c_char; - pub fn SDL_JoystickOpen(device_index: c_int) -> *const SDL_Joystick; - pub fn SDL_JoystickName(joystick: *const SDL_Joystick) -> *const c_char; + pub fn SDL_JoystickOpen(device_index: c_int) -> *mut SDL_Joystick; + pub fn SDL_JoystickName(joystick: *mut SDL_Joystick) -> *const c_char; pub fn SDL_JoystickGetDeviceGUID(device_index: c_int) -> SDL_JoystickGUID; - pub fn SDL_JoystickGetGUID(joystick: *const SDL_Joystick) -> + pub fn SDL_JoystickGetGUID(joystick: *mut SDL_Joystick) -> SDL_JoystickGUID; pub fn SDL_JoystickGetGUIDString(guid: SDL_JoystickGUID, pszGUID: *const c_char, cbGUID: c_int); pub fn SDL_JoystickGetGUIDFromString(pchGUID: *const c_char) -> SDL_JoystickGUID; - pub fn SDL_JoystickGetAttached(joystick: *const SDL_Joystick) -> SDL_bool; - pub fn SDL_JoystickInstanceID(joystick: *const SDL_Joystick) -> int32_t; - pub fn SDL_JoystickNumAxes(joystick: *const SDL_Joystick) -> c_int; - pub fn SDL_JoystickNumBalls(joystick: *const SDL_Joystick) -> c_int; - pub fn SDL_JoystickNumHats(joystick: *const SDL_Joystick) -> c_int; - pub fn SDL_JoystickNumButtons(joystick: *const SDL_Joystick) -> c_int; + pub fn SDL_JoystickGetAttached(joystick: *mut SDL_Joystick) -> SDL_bool; + pub fn SDL_JoystickInstanceID(joystick: *mut SDL_Joystick) -> int32_t; + pub fn SDL_JoystickNumAxes(joystick: *mut SDL_Joystick) -> c_int; + pub fn SDL_JoystickNumBalls(joystick: *mut SDL_Joystick) -> c_int; + pub fn SDL_JoystickNumHats(joystick: *mut SDL_Joystick) -> c_int; + pub fn SDL_JoystickNumButtons(joystick: *mut SDL_Joystick) -> c_int; pub fn SDL_JoystickUpdate(); pub fn SDL_JoystickEventState(state: c_int) -> c_int; - pub fn SDL_JoystickGetAxis(joystick: *const SDL_Joystick, axis: c_int) -> + pub fn SDL_JoystickGetAxis(joystick: *mut SDL_Joystick, axis: c_int) -> int16_t; - pub fn SDL_JoystickGetHat(joystick: *const SDL_Joystick, hat: c_int) -> + pub fn SDL_JoystickGetHat(joystick: *mut SDL_Joystick, hat: c_int) -> int8_t; - pub fn SDL_JoystickGetBall(joystick: *const SDL_Joystick, ball: c_int, + pub fn SDL_JoystickGetBall(joystick: *mut SDL_Joystick, ball: c_int, dx: *const c_int, dy: *const c_int) -> c_int; - pub fn SDL_JoystickGetButton(joystick: *const SDL_Joystick, button: c_int) + pub fn SDL_JoystickGetButton(joystick: *mut SDL_Joystick, button: c_int) -> uint8_t; - pub fn SDL_JoystickClose(joystick: *const SDL_Joystick); + pub fn SDL_JoystickClose(joystick: *mut SDL_Joystick); } diff --git a/sdl2-sys/src/keyboard.rs b/sdl2-sys/src/keyboard.rs index f8ccd4ba..64094e9f 100644 --- a/sdl2-sys/src/keyboard.rs +++ b/sdl2-sys/src/keyboard.rs @@ -18,8 +18,8 @@ pub struct SDL_Keysym { } extern "C" { - pub fn SDL_GetKeyboardFocus() -> *const SDL_Window; - pub fn SDL_GetKeyboardState(numkeys: *const c_int) -> *const uint8_t; + pub fn SDL_GetKeyboardFocus() -> *mut SDL_Window; + pub fn SDL_GetKeyboardState(numkeys: *mut c_int) -> *const uint8_t; pub fn SDL_GetModState() -> SDL_Keymod; pub fn SDL_SetModState(modstate: SDL_Keymod); pub fn SDL_GetKeyFromScancode(scancode: SDL_Scancode) -> SDL_Keycode; @@ -33,5 +33,5 @@ extern "C" { pub fn SDL_StopTextInput(); pub fn SDL_SetTextInputRect(rect: *const SDL_Rect); pub fn SDL_HasScreenKeyboardSupport() -> SDL_bool; - pub fn SDL_IsScreenKeyboardShown(window: *const SDL_Window) -> SDL_bool; + pub fn SDL_IsScreenKeyboardShown(window: *mut SDL_Window) -> SDL_bool; } diff --git a/sdl2-sys/src/messagebox.rs b/sdl2-sys/src/messagebox.rs index bedac5c1..7c08c30b 100644 --- a/sdl2-sys/src/messagebox.rs +++ b/sdl2-sys/src/messagebox.rs @@ -7,5 +7,5 @@ pub const SDL_MESSAGEBOX_WARNING : SDL_MessageBoxFlags = 0x00000020; pub const SDL_MESSAGEBOX_INFORMATION : SDL_MessageBoxFlags = 0x00000040; extern "C" { - pub fn SDL_ShowSimpleMessageBox(flags: uint32_t, title: *const c_char, message: *const c_char, window: *const SDL_Window) -> c_int; + pub fn SDL_ShowSimpleMessageBox(flags: uint32_t, title: *const c_char, message: *const c_char, window: *mut SDL_Window) -> c_int; } diff --git a/sdl2-sys/src/mouse.rs b/sdl2-sys/src/mouse.rs index 27b9fb4a..130ca22f 100644 --- a/sdl2-sys/src/mouse.rs +++ b/sdl2-sys/src/mouse.rs @@ -38,21 +38,21 @@ pub const SDL_BUTTON_X2MASK: u32 = 0x10; extern "C" { - pub fn SDL_GetMouseFocus() -> *const SDL_Window; - pub fn SDL_GetMouseState(x: *const c_int, y: *const c_int) -> uint32_t; - pub fn SDL_GetRelativeMouseState(x: *const c_int, y: *const c_int) -> uint32_t; - pub fn SDL_WarpMouseInWindow(window: *const SDL_Window, x: c_int, y: c_int); + pub fn SDL_GetMouseFocus() -> *mut SDL_Window; + pub fn SDL_GetMouseState(x: *mut c_int, y: *mut c_int) -> uint32_t; + pub fn SDL_GetRelativeMouseState(x: *mut c_int, y: *mut c_int) -> uint32_t; + pub fn SDL_WarpMouseInWindow(window: *mut SDL_Window, x: c_int, y: c_int); pub fn SDL_SetRelativeMouseMode(enabled: SDL_bool) -> c_int; pub fn SDL_GetRelativeMouseMode() -> SDL_bool; pub fn SDL_CreateCursor(data: *const uint8_t, mask: *const uint8_t, w: c_int, h: c_int, hot_x: c_int, hot_y: c_int) -> - *const SDL_Cursor; - pub fn SDL_CreateColorCursor(surface: *const SDL_Surface, hot_x: c_int, - hot_y: c_int) -> *const SDL_Cursor; - pub fn SDL_CreateSystemCursor(id: SDL_SystemCursor) -> *const SDL_Cursor; - pub fn SDL_SetCursor(cursor: *const SDL_Cursor); - pub fn SDL_GetCursor() -> *const SDL_Cursor; - pub fn SDL_GetDefaultCursor() -> *const SDL_Cursor; - pub fn SDL_FreeCursor(cursor: *const SDL_Cursor); + *mut SDL_Cursor; + pub fn SDL_CreateColorCursor(surface: *mut SDL_Surface, hot_x: c_int, + hot_y: c_int) -> *mut SDL_Cursor; + pub fn SDL_CreateSystemCursor(id: SDL_SystemCursor) -> *mut SDL_Cursor; + pub fn SDL_SetCursor(cursor: *mut SDL_Cursor); + pub fn SDL_GetCursor() -> *mut SDL_Cursor; + pub fn SDL_GetDefaultCursor() -> *mut SDL_Cursor; + pub fn SDL_FreeCursor(cursor: *mut SDL_Cursor); pub fn SDL_ShowCursor(toggle: SDL_MouseState) -> SDL_MouseState; } diff --git a/sdl2-sys/src/pixels.rs b/sdl2-sys/src/pixels.rs index cb8c0441..3b5cded7 100644 --- a/sdl2-sys/src/pixels.rs +++ b/sdl2-sys/src/pixels.rs @@ -14,7 +14,7 @@ pub struct SDL_Color { #[repr(C)] pub struct SDL_Palette { pub ncolors: c_int, - pub colors: *const SDL_Color, + pub colors: *mut SDL_Color, pub version: uint32_t, pub refcount: c_int } @@ -23,7 +23,7 @@ pub struct SDL_Palette { #[repr(C)] pub struct SDL_PixelFormat { pub format: SDL_PixelFormatEnum, - pub palette: *const SDL_Palette, + pub palette: *mut SDL_Palette, pub BitsPerPixel: uint8_t, pub BytesPerPixel: uint8_t, pub padding: [uint8_t; 2], @@ -40,7 +40,7 @@ pub struct SDL_PixelFormat { pub Bshift: uint8_t, pub Ashift: uint8_t, pub refcount: c_int, - pub next: *const SDL_PixelFormat + pub next: *mut SDL_PixelFormat } pub type SDL_PixelFormatEnum = uint32_t; @@ -82,8 +82,8 @@ pub const SDL_PIXELFORMAT_UYVY: SDL_PixelFormatEnum = 0x59565955; pub const SDL_PIXELFORMAT_YVYU: SDL_PixelFormatEnum = 0x55595659; extern "C" { - pub fn SDL_GetRGB(pixel: uint32_t, format: *const SDL_PixelFormat, r: *const uint8_t, g: *const uint8_t, b: *const uint8_t); - pub fn SDL_GetRGBA(pixel: uint32_t, format: *const SDL_PixelFormat, r: *const uint8_t, g: *const uint8_t, b: *const uint8_t, a: *const uint8_t); - pub fn SDL_MapRGB(format: *const SDL_PixelFormat, r: uint8_t, g: uint8_t, b: uint8_t) -> uint32_t; - pub fn SDL_MapRGBA(format: *const SDL_PixelFormat, r: uint8_t, g: uint8_t, b: uint8_t, a: uint8_t) -> uint32_t; + pub fn SDL_GetRGB(pixel: uint32_t, format: *mut SDL_PixelFormat, r: *mut uint8_t, g: *mut uint8_t, b: *mut uint8_t); + pub fn SDL_GetRGBA(pixel: uint32_t, format: *mut SDL_PixelFormat, r: *mut uint8_t, g: *mut uint8_t, b: *mut uint8_t, a: *mut uint8_t); + pub fn SDL_MapRGB(format: *mut SDL_PixelFormat, r: uint8_t, g: uint8_t, b: uint8_t) -> uint32_t; + pub fn SDL_MapRGBA(format: *mut SDL_PixelFormat, r: uint8_t, g: uint8_t, b: uint8_t, a: uint8_t) -> uint32_t; } diff --git a/sdl2-sys/src/rect.rs b/sdl2-sys/src/rect.rs index 5e617a31..f8472048 100644 --- a/sdl2-sys/src/rect.rs +++ b/sdl2-sys/src/rect.rs @@ -42,10 +42,10 @@ pub mod ll { extern "C" { pub fn SDL_HasIntersection(A: *const SDL_Rect, B: *const SDL_Rect) -> SDL_bool; - pub fn SDL_IntersectRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *const SDL_Rect) -> SDL_bool; - pub fn SDL_UnionRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *const SDL_Rect); - pub fn SDL_EnclosePoints(points: *const SDL_Point, count: c_int, clip: *const SDL_Rect, result: *const SDL_Rect) -> SDL_bool; - pub fn SDL_IntersectRectAndLine(rect: *const SDL_Rect, X1: *const c_int, Y1: *const c_int, X2: *const c_int, Y2: *const c_int) -> SDL_bool; + pub fn SDL_IntersectRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect) -> SDL_bool; + pub fn SDL_UnionRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect); + pub fn SDL_EnclosePoints(points: *const SDL_Point, count: c_int, clip: *const SDL_Rect, result: *mut SDL_Rect) -> SDL_bool; + pub fn SDL_IntersectRectAndLine(rect: *const SDL_Rect, X1: *mut c_int, Y1: *mut c_int, X2: *mut c_int, Y2: *mut c_int) -> SDL_bool; } } @@ -70,14 +70,14 @@ impl Rect { /// Calculate a minimal rectangle enclosing a set of points. pub fn from_enclose_points(points: &[Point], clip: Option) -> Option { - let out: Rect = Rect::new(0, 0, 0, 0); + let mut out: Rect = Rect::new(0, 0, 0, 0); let result = unsafe { ll::SDL_EnclosePoints( points.as_ptr(), points.len() as c_int, transmute(clip.as_ref()), - &out + &mut out ) != 0 }; @@ -102,10 +102,10 @@ impl Rect { /// Calculate the intersection of two rectangles. pub fn intersection(&self, other: &Rect) -> Option { - let out: Rect = Rect::new(0, 0, 0, 0); + let mut out: Rect = Rect::new(0, 0, 0, 0); let result = unsafe { - ll::SDL_IntersectRect(self, other, &out) != 0 + ll::SDL_IntersectRect(self, other, &mut out) != 0 }; if result { @@ -117,10 +117,10 @@ impl Rect { /// Calculate the union of two rectangles. pub fn union(&self, other: &Rect) -> Rect { - let out: Rect = Rect::new(0, 0, 0, 0); + let mut out: Rect = Rect::new(0, 0, 0, 0); unsafe { - ll::SDL_UnionRect(self, other, &out) + ll::SDL_UnionRect(self, other, &mut out) }; out @@ -128,11 +128,11 @@ impl Rect { /// Calculate the intersection of a rectangle and line segment. return points of intersection. pub fn intersect_line(&self, start: &Point, end: &Point) -> Option<(Point, Point)> { - let out_start: Point = start.clone(); - let out_end: Point = end.clone(); + let mut out_start: Point = start.clone(); + let mut out_end: Point = end.clone(); let result = unsafe { - ll::SDL_IntersectRectAndLine(self, &out_start.x, &out_start.y, &out_end.x, &out_end.y) != 0 + ll::SDL_IntersectRectAndLine(self, &mut out_start.x, &mut out_start.y, &mut out_end.x, &mut out_end.y) != 0 }; if result { @@ -142,4 +142,3 @@ impl Rect { } } } - diff --git a/sdl2-sys/src/rect_2.rs b/sdl2-sys/src/rect_2.rs index 1baa83e5..2dd4e34a 100644 --- a/sdl2-sys/src/rect_2.rs +++ b/sdl2-sys/src/rect_2.rs @@ -22,8 +22,8 @@ pub type SDL_bool = c_int; extern "C" { pub fn SDL_HasIntersection(A: *const SDL_Rect, B: *const SDL_Rect) -> SDL_bool; - pub fn SDL_IntersectRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *const SDL_Rect) -> SDL_bool; - pub fn SDL_UnionRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *const SDL_Rect); - pub fn SDL_EnclosePoints(points: *const SDL_Point, count: c_int, clip: *const SDL_Rect, result: *const SDL_Rect) -> SDL_bool; - pub fn SDL_IntersectRectAndLine(rect: *const SDL_Rect, X1: *const c_int, Y1: *const c_int, X2: *const c_int, Y2: *const c_int) -> SDL_bool; + pub fn SDL_IntersectRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect) -> SDL_bool; + pub fn SDL_UnionRect(A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect); + pub fn SDL_EnclosePoints(points: *const SDL_Point, count: c_int, clip: *const SDL_Rect, result: *mut SDL_Rect) -> SDL_bool; + pub fn SDL_IntersectRectAndLine(rect: *const SDL_Rect, X1: *mut c_int, Y1: *mut c_int, X2: *mut c_int, Y2: *mut c_int) -> SDL_bool; } diff --git a/sdl2-sys/src/render.rs b/sdl2-sys/src/render.rs index db1a434f..a55292b0 100644 --- a/sdl2-sys/src/render.rs +++ b/sdl2-sys/src/render.rs @@ -60,56 +60,56 @@ pub const SDL_BLENDMODE_MOD : SDL_BlendMode = 0x00000004; extern "C" { pub fn SDL_GetNumRenderDrivers() -> c_int; - pub fn SDL_GetRenderDriverInfo(index: c_int, info: *const SDL_RendererInfo) -> c_int; - pub fn SDL_CreateWindowAndRenderer(width: c_int, height: c_int, window_flags: uint32_t, window: *const *const SDL_Window, renderer: *const *const SDL_Renderer) -> c_int; - pub fn SDL_CreateRenderer(window: *const SDL_Window, index: c_int, flags: uint32_t) -> *const SDL_Renderer; - pub fn SDL_CreateSoftwareRenderer(surface: *const SDL_Surface) -> *const SDL_Renderer; - pub fn SDL_GetRenderer(window: *const SDL_Window) -> *const SDL_Renderer; - pub fn SDL_GetRendererInfo(renderer: *const SDL_Renderer, info: *const SDL_RendererInfo) -> c_int; - pub fn SDL_GetRendererOutputSize(renderer: *const SDL_Renderer, w: *const c_int, h: *const c_int) -> c_int; - pub fn SDL_CreateTexture(renderer: *const SDL_Renderer, format: uint32_t, access: c_int, w: c_int, h: c_int) -> *const SDL_Texture; - pub fn SDL_CreateTextureFromSurface(renderer: *const SDL_Renderer, surface: *const SDL_Surface) -> *const SDL_Texture; - pub fn SDL_QueryTexture(texture: *const SDL_Texture, format: *const uint32_t, access: *const c_int, w: *const c_int, h: *const c_int) -> c_int; - pub fn SDL_SetTextureColorMod(texture: *const SDL_Texture, r: uint8_t, g: uint8_t, b: uint8_t) -> c_int; - pub fn SDL_GetTextureColorMod(texture: *const SDL_Texture, r: *const uint8_t, g: *const uint8_t, b: *const uint8_t) -> c_int; - pub fn SDL_SetTextureAlphaMod(texture: *const SDL_Texture, alpha: uint8_t) -> c_int; - pub fn SDL_GetTextureAlphaMod(texture: *const SDL_Texture, alpha: *const uint8_t) -> c_int; - pub fn SDL_SetTextureBlendMode(texture: *const SDL_Texture, blendMode: SDL_BlendMode) -> c_int; - pub fn SDL_GetTextureBlendMode(texture: *const SDL_Texture, blendMode: *const SDL_BlendMode) -> c_int; - pub fn SDL_UpdateTexture(texture: *const SDL_Texture, rect: *const SDL_Rect, pixels: *const c_void, pitch: c_int) -> c_int; - pub fn SDL_UpdateYUVTexture(texture: *const SDL_Texture, rect: *const SDL_Rect, Yplane: *const uint8_t, Ypitch: c_int, Uplane: *const uint8_t, Upitch: c_int, Vplane: *const uint8_t, Vpitch: c_int) -> c_int; - pub fn SDL_LockTexture(texture: *const SDL_Texture, rect: *const SDL_Rect, pixels: *mut *mut c_void, pitch: *mut c_int) -> c_int; - pub fn SDL_UnlockTexture(texture: *const SDL_Texture); - pub fn SDL_RenderTargetSupported(renderer: *const SDL_Renderer) -> SDL_bool; - pub fn SDL_SetRenderTarget(renderer: *const SDL_Renderer, texture: *const SDL_Texture) -> c_int; - pub fn SDL_GetRenderTarget(renderer: *const SDL_Renderer) -> *const SDL_Texture; - pub fn SDL_RenderSetLogicalSize(renderer: *const SDL_Renderer, w: c_int, h: c_int) -> c_int; - pub fn SDL_RenderGetLogicalSize(renderer: *const SDL_Renderer, w: *const c_int, h: *const c_int); - pub fn SDL_RenderSetViewport(renderer: *const SDL_Renderer, rect: *const SDL_Rect) -> c_int; - pub fn SDL_RenderGetViewport(renderer: *const SDL_Renderer, rect: *const SDL_Rect); - pub fn SDL_RenderSetClipRect(renderer: *const SDL_Renderer, rect: *const SDL_Rect) -> c_int; - pub fn SDL_RenderGetClipRect(renderer: *const SDL_Renderer, rect: *const SDL_Rect); - pub fn SDL_RenderSetScale(renderer: *const SDL_Renderer, scaleX: c_float, scaleY: c_float) -> c_int; - pub fn SDL_RenderGetScale(renderer: *const SDL_Renderer, scaleX: *const c_float, scaleY: *const c_float); - pub fn SDL_SetRenderDrawColor(renderer: *const SDL_Renderer, r: uint8_t, g: uint8_t, b: uint8_t, a: uint8_t) -> c_int; - pub fn SDL_GetRenderDrawColor(renderer: *const SDL_Renderer, r: *const uint8_t, g: *const uint8_t, b: *const uint8_t, a: *const uint8_t) -> c_int; - pub fn SDL_SetRenderDrawBlendMode(renderer: *const SDL_Renderer, blendMode: SDL_BlendMode) -> c_int; - pub fn SDL_GetRenderDrawBlendMode(renderer: *const SDL_Renderer, blendMode: *const SDL_BlendMode) -> c_int; - pub fn SDL_RenderClear(renderer: *const SDL_Renderer) -> c_int; - pub fn SDL_RenderDrawPoint(renderer: *const SDL_Renderer, x: c_int, y: c_int) -> c_int; - pub fn SDL_RenderDrawPoints(renderer: *const SDL_Renderer, Points: *const SDL_Point, count: c_int) -> c_int; - pub fn SDL_RenderDrawLine(renderer: *const SDL_Renderer, x1: c_int, y1: c_int, x2: c_int, y2: c_int) -> c_int; - pub fn SDL_RenderDrawLines(renderer: *const SDL_Renderer, Points: *const SDL_Point, count: c_int) -> c_int; - pub fn SDL_RenderDrawRect(renderer: *const SDL_Renderer, rect: *const SDL_Rect) -> c_int; - pub fn SDL_RenderDrawRects(renderer: *const SDL_Renderer, rects: *const SDL_Rect, count: c_int) -> c_int; - pub fn SDL_RenderFillRect(renderer: *const SDL_Renderer, rect: *const SDL_Rect) -> c_int; - pub fn SDL_RenderFillRects(renderer: *const SDL_Renderer, rects: *const SDL_Rect, count: c_int) -> c_int; - pub fn SDL_RenderCopy(renderer: *const SDL_Renderer, texture: *const SDL_Texture, srcrect: *const SDL_Rect, dstrect: *const SDL_Rect) -> c_int; - pub fn SDL_RenderCopyEx(renderer: *const SDL_Renderer, texture: *const SDL_Texture, srcrect: *const SDL_Rect, dstrect: *const SDL_Rect, angle: c_double, center: *const SDL_Point, flip: SDL_RendererFlip) -> c_int; - pub fn SDL_RenderReadPixels(renderer: *const SDL_Renderer, rect: *const SDL_Rect, format: uint32_t, pixels: *mut c_void, pitch: c_int) -> c_int; - pub fn SDL_RenderPresent(renderer: *const SDL_Renderer); - pub fn SDL_DestroyTexture(texture: *const SDL_Texture); - pub fn SDL_DestroyRenderer(renderer: *const SDL_Renderer); - pub fn SDL_GL_BindTexture(texture: *const SDL_Texture, texw: *const c_float, texh: *const c_float) -> c_int; - pub fn SDL_GL_UnbindTexture(texture: *const SDL_Texture) -> c_int; + pub fn SDL_GetRenderDriverInfo(index: c_int, info: *mut SDL_RendererInfo) -> c_int; + pub fn SDL_CreateWindowAndRenderer(width: c_int, height: c_int, window_flags: uint32_t, window: *mut *mut SDL_Window, renderer: *mut *mut SDL_Renderer) -> c_int; + pub fn SDL_CreateRenderer(window: *mut SDL_Window, index: c_int, flags: uint32_t) -> *mut SDL_Renderer; + pub fn SDL_CreateSoftwareRenderer(surface: *mut SDL_Surface) -> *mut SDL_Renderer; + pub fn SDL_GetRenderer(window: *mut SDL_Window) -> *mut SDL_Renderer; + pub fn SDL_GetRendererInfo(renderer: *mut SDL_Renderer, info: *mut SDL_RendererInfo) -> c_int; + pub fn SDL_GetRendererOutputSize(renderer: *mut SDL_Renderer, w: *mut c_int, h: *mut c_int) -> c_int; + pub fn SDL_CreateTexture(renderer: *mut SDL_Renderer, format: uint32_t, access: c_int, w: c_int, h: c_int) -> *mut SDL_Texture; + pub fn SDL_CreateTextureFromSurface(renderer: *mut SDL_Renderer, surface: *mut SDL_Surface) -> *mut SDL_Texture; + pub fn SDL_QueryTexture(texture: *mut SDL_Texture, format: *mut uint32_t, access: *mut c_int, w: *mut c_int, h: *mut c_int) -> c_int; + pub fn SDL_SetTextureColorMod(texture: *mut SDL_Texture, r: uint8_t, g: uint8_t, b: uint8_t) -> c_int; + pub fn SDL_GetTextureColorMod(texture: *mut SDL_Texture, r: *mut uint8_t, g: *mut uint8_t, b: *mut uint8_t) -> c_int; + pub fn SDL_SetTextureAlphaMod(texture: *mut SDL_Texture, alpha: uint8_t) -> c_int; + pub fn SDL_GetTextureAlphaMod(texture: *mut SDL_Texture, alpha: *mut uint8_t) -> c_int; + pub fn SDL_SetTextureBlendMode(texture: *mut SDL_Texture, blendMode: SDL_BlendMode) -> c_int; + pub fn SDL_GetTextureBlendMode(texture: *mut SDL_Texture, blendMode: *mut SDL_BlendMode) -> c_int; + pub fn SDL_UpdateTexture(texture: *mut SDL_Texture, rect: *const SDL_Rect, pixels: *const c_void, pitch: c_int) -> c_int; + pub fn SDL_UpdateYUVTexture(texture: *mut SDL_Texture, rect: *const SDL_Rect, Yplane: *const uint8_t, Ypitch: c_int, Uplane: *const uint8_t, Upitch: c_int, Vplane: *const uint8_t, Vpitch: c_int) -> c_int; + pub fn SDL_LockTexture(texture: *mut SDL_Texture, rect: *const SDL_Rect, pixels: *mut *mut c_void, pitch: *mut c_int) -> c_int; + pub fn SDL_UnlockTexture(texture: *mut SDL_Texture); + pub fn SDL_RenderTargetSupported(renderer: *mut SDL_Renderer) -> SDL_bool; + pub fn SDL_SetRenderTarget(renderer: *mut SDL_Renderer, texture: *mut SDL_Texture) -> c_int; + pub fn SDL_GetRenderTarget(renderer: *mut SDL_Renderer) -> *mut SDL_Texture; + pub fn SDL_RenderSetLogicalSize(renderer: *mut SDL_Renderer, w: c_int, h: c_int) -> c_int; + pub fn SDL_RenderGetLogicalSize(renderer: *mut SDL_Renderer, w: *mut c_int, h: *mut c_int); + pub fn SDL_RenderSetViewport(renderer: *mut SDL_Renderer, rect: *const SDL_Rect) -> c_int; + pub fn SDL_RenderGetViewport(renderer: *mut SDL_Renderer, rect: *mut SDL_Rect); + pub fn SDL_RenderSetClipRect(renderer: *mut SDL_Renderer, rect: *const SDL_Rect) -> c_int; + pub fn SDL_RenderGetClipRect(renderer: *mut SDL_Renderer, rect: *mut SDL_Rect); + pub fn SDL_RenderSetScale(renderer: *mut SDL_Renderer, scaleX: c_float, scaleY: c_float) -> c_int; + pub fn SDL_RenderGetScale(renderer: *mut SDL_Renderer, scaleX: *mut c_float, scaleY: *mut c_float); + pub fn SDL_SetRenderDrawColor(renderer: *mut SDL_Renderer, r: uint8_t, g: uint8_t, b: uint8_t, a: uint8_t) -> c_int; + pub fn SDL_GetRenderDrawColor(renderer: *mut SDL_Renderer, r: *mut uint8_t, g: *mut uint8_t, b: *mut uint8_t, a: *mut uint8_t) -> c_int; + pub fn SDL_SetRenderDrawBlendMode(renderer: *mut SDL_Renderer, blendMode: SDL_BlendMode) -> c_int; + pub fn SDL_GetRenderDrawBlendMode(renderer: *mut SDL_Renderer, blendMode: *mut SDL_BlendMode) -> c_int; + pub fn SDL_RenderClear(renderer: *mut SDL_Renderer) -> c_int; + pub fn SDL_RenderDrawPoint(renderer: *mut SDL_Renderer, x: c_int, y: c_int) -> c_int; + pub fn SDL_RenderDrawPoints(renderer: *mut SDL_Renderer, Points: *const SDL_Point, count: c_int) -> c_int; + pub fn SDL_RenderDrawLine(renderer: *mut SDL_Renderer, x1: c_int, y1: c_int, x2: c_int, y2: c_int) -> c_int; + pub fn SDL_RenderDrawLines(renderer: *mut SDL_Renderer, Points: *const SDL_Point, count: c_int) -> c_int; + pub fn SDL_RenderDrawRect(renderer: *mut SDL_Renderer, rect: *const SDL_Rect) -> c_int; + pub fn SDL_RenderDrawRects(renderer: *mut SDL_Renderer, rects: *const SDL_Rect, count: c_int) -> c_int; + pub fn SDL_RenderFillRect(renderer: *mut SDL_Renderer, rect: *const SDL_Rect) -> c_int; + pub fn SDL_RenderFillRects(renderer: *mut SDL_Renderer, rects: *const SDL_Rect, count: c_int) -> c_int; + pub fn SDL_RenderCopy(renderer: *mut SDL_Renderer, texture: *mut SDL_Texture, srcrect: *const SDL_Rect, dstrect: *const SDL_Rect) -> c_int; + pub fn SDL_RenderCopyEx(renderer: *mut SDL_Renderer, texture: *mut SDL_Texture, srcrect: *const SDL_Rect, dstrect: *const SDL_Rect, angle: c_double, center: *const SDL_Point, flip: SDL_RendererFlip) -> c_int; + pub fn SDL_RenderReadPixels(renderer: *mut SDL_Renderer, rect: *const SDL_Rect, format: uint32_t, pixels: *mut c_void, pitch: c_int) -> c_int; + pub fn SDL_RenderPresent(renderer: *mut SDL_Renderer); + pub fn SDL_DestroyTexture(texture: *mut SDL_Texture); + pub fn SDL_DestroyRenderer(renderer: *mut SDL_Renderer); + pub fn SDL_GL_BindTexture(texture: *mut SDL_Texture, texw: *mut c_float, texh: *mut c_float) -> c_int; + pub fn SDL_GL_UnbindTexture(texture: *mut SDL_Texture) -> c_int; } diff --git a/sdl2-sys/src/rwops.rs b/sdl2-sys/src/rwops.rs index 1e3d2555..ec2f0d0c 100644 --- a/sdl2-sys/src/rwops.rs +++ b/sdl2-sys/src/rwops.rs @@ -16,23 +16,23 @@ pub static RW_SEEK_END: c_int = 2; #[allow(dead_code)] #[repr(C)] pub struct SDL_RWops { - pub size: extern "C" fn(context: *const SDL_RWops) -> int64_t, - pub seek: extern "C" fn(context: *const SDL_RWops, offset: int64_t, whence: c_int) -> int64_t, - pub read: extern "C" fn(context: *const SDL_RWops, ptr: *const c_void, + pub size: extern "C" fn(context: *mut SDL_RWops) -> int64_t, + pub seek: extern "C" fn(context: *mut SDL_RWops, offset: int64_t, whence: c_int) -> int64_t, + pub read: extern "C" fn(context: *mut SDL_RWops, ptr: *mut c_void, size: size_t, maxnum: size_t) -> size_t, - pub write: extern "C" fn(context: *const SDL_RWops, ptr: *const c_void, + pub write: extern "C" fn(context: *mut SDL_RWops, ptr: *const c_void, size: size_t, maxnum: size_t) -> size_t, - pub close: extern "C" fn(context: *const SDL_RWops) -> c_int, + pub close: extern "C" fn(context: *mut SDL_RWops) -> c_int, pub type_: uint32_t, hidden: SDL_RWops_Anon } extern "C" { - pub fn SDL_RWFromFile(file: *const c_char, mode: *const c_char) -> *const SDL_RWops; - pub fn SDL_RWFromFP(fp: *const FILE, autoclose: SDL_bool) -> *const SDL_RWops; - pub fn SDL_RWFromMem(mem: *const c_void, size: c_int) -> *const SDL_RWops; - pub fn SDL_RWFromConstMem(mem: *const c_void, size: c_int) -> *const SDL_RWops; + pub fn SDL_RWFromFile(file: *const c_char, mode: *const c_char) -> *mut SDL_RWops; + pub fn SDL_RWFromFP(fp: *mut FILE, autoclose: SDL_bool) -> *mut SDL_RWops; + pub fn SDL_RWFromMem(mem: *mut c_void, size: c_int) -> *mut SDL_RWops; + pub fn SDL_RWFromConstMem(mem: *const c_void, size: c_int) -> *mut SDL_RWops; - pub fn SDL_AllocRW() -> *const SDL_RWops; - pub fn SDL_FreeRW(area: *const SDL_RWops); + pub fn SDL_AllocRW() -> *mut SDL_RWops; + pub fn SDL_FreeRW(area: *mut SDL_RWops); } diff --git a/sdl2-sys/src/surface.rs b/sdl2-sys/src/surface.rs index c9ef6e5a..236c23b9 100644 --- a/sdl2-sys/src/surface.rs +++ b/sdl2-sys/src/surface.rs @@ -24,47 +24,47 @@ pub struct SDL_BlitMap; #[repr(C)] pub struct SDL_Surface { pub flags: uint32_t, - pub format: *const SDL_PixelFormat, + pub format: *mut SDL_PixelFormat, pub w: c_int, pub h: c_int, pub pitch: c_int, - pub pixels: *const c_void, - pub userdata: *const c_void, + pub pixels: *mut c_void, + pub userdata: *mut c_void, pub locked: c_int, - pub lock_data: *const c_void, + pub lock_data: *mut c_void, pub clip_rect: SDL_Rect, - pub map: *const SDL_BlitMap, + pub map: *mut SDL_BlitMap, pub refcount: c_int } extern "C" { - pub fn SDL_CreateRGBSurface(flags: uint32_t, width: c_int, height: c_int, depth: c_int, Rmask: uint32_t, Gmask: uint32_t, Bmask: uint32_t, Amask: uint32_t) -> *const SDL_Surface; - pub fn SDL_CreateRGBSurfaceFrom(pixels: *const c_void, width: c_int, height: c_int, depth: c_int, pitch: c_int, Rmask: uint32_t, Gmask: uint32_t, Bmask: uint32_t, Amask: uint32_t) -> *const SDL_Surface; - pub fn SDL_FreeSurface(surface: *const SDL_Surface); - pub fn SDL_SetSurfacePalette(surface: *const SDL_Surface, palette: *const SDL_Palette) -> c_int; - pub fn SDL_LockSurface(surface: *const SDL_Surface) -> c_int; - pub fn SDL_UnlockSurface(surface: *const SDL_Surface); - pub fn SDL_LoadBMP_RW(src: *const SDL_RWops, freesrc: c_int) -> *const SDL_Surface; - pub fn SDL_SaveBMP_RW(surface: *const SDL_Surface, dst: *const SDL_RWops, freedst: c_int) -> c_int; - pub fn SDL_SetSurfaceRLE(surface: *const SDL_Surface, flag: c_int) -> c_int; - pub fn SDL_SetColorKey(surface: *const SDL_Surface, flag: c_int, key: uint32_t) -> c_int; - pub fn SDL_GetColorKey(surface: *const SDL_Surface, key: *const uint32_t) -> c_int; - pub fn SDL_SetSurfaceColorMod(surface: *const SDL_Surface, r: uint8_t, g: uint8_t, b: uint8_t) -> c_int; - pub fn SDL_GetSurfaceColorMod(surface: *const SDL_Surface, r: *const uint8_t, g: *const uint8_t, b: *const uint8_t ) -> c_int; - pub fn SDL_SetSurfaceAlphaMod(surface: *const SDL_Surface, alpha: uint8_t) -> c_int; - pub fn SDL_GetSurfaceAlphaMod(surface: *const SDL_Surface, alpha: *const uint8_t ) -> c_int; - pub fn SDL_SetSurfaceBlendMode(surface: *const SDL_Surface, blendMode: SDL_BlendMode) -> c_int; - pub fn SDL_GetSurfaceBlendMode(surface: *const SDL_Surface, blendMode: *const SDL_BlendMode) -> c_int; - pub fn SDL_SetClipRect(surface: *const SDL_Surface, rect: *const SDL_Rect) -> SDL_bool; - pub fn SDL_GetClipRect(surface: *const SDL_Surface, rect: *const SDL_Rect); - pub fn SDL_ConvertSurface(src: *const SDL_Surface, fmt: *const SDL_PixelFormat, flags: uint32_t) -> *const SDL_Surface; - pub fn SDL_ConvertSurfaceFormat(src: *const SDL_Surface, pixel_format: uint32_t, flags: uint32_t) -> *const SDL_Surface; - pub fn SDL_ConvertPixels(width: c_int, height: c_int, src_format: uint32_t, src: *const c_void, src_pitch: c_int, dst_format: uint32_t, dst: *const c_void, dst_pitch: c_int) -> c_int; - pub fn SDL_FillRect(dst: *const SDL_Surface, rect: *const SDL_Rect, color: uint32_t) -> c_int; - pub fn SDL_FillRects(dst: *const SDL_Surface, rects: *const SDL_Rect, count: c_int, color: uint32_t) -> c_int; - pub fn SDL_UpperBlit(src: *const SDL_Surface, srcrect: *const SDL_Rect, dst: *const SDL_Surface, dstrect: *const SDL_Rect) -> c_int; - pub fn SDL_LowerBlit(src: *const SDL_Surface, srcrect: *const SDL_Rect, dst: *const SDL_Surface, dstrect: *const SDL_Rect) -> c_int; - pub fn SDL_SoftStretch(src: *const SDL_Surface, srcrect: *const SDL_Rect, dst: *const SDL_Surface, dstrect: *const SDL_Rect) -> c_int; - pub fn SDL_UpperBlitScaled(src: *const SDL_Surface, srcrect: *const SDL_Rect, dst: *const SDL_Surface, dstrect: *const SDL_Rect) -> c_int; - pub fn SDL_LowerBlitScaled(src: *const SDL_Surface, srcrect: *const SDL_Rect, dst: *const SDL_Surface, dstrect: *const SDL_Rect) -> c_int; + pub fn SDL_CreateRGBSurface(flags: uint32_t, width: c_int, height: c_int, depth: c_int, Rmask: uint32_t, Gmask: uint32_t, Bmask: uint32_t, Amask: uint32_t) -> *mut SDL_Surface; + pub fn SDL_CreateRGBSurfaceFrom(pixels: *mut c_void, width: c_int, height: c_int, depth: c_int, pitch: c_int, Rmask: uint32_t, Gmask: uint32_t, Bmask: uint32_t, Amask: uint32_t) -> *mut SDL_Surface; + pub fn SDL_FreeSurface(surface: *mut SDL_Surface); + pub fn SDL_SetSurfacePalette(surface: *mut SDL_Surface, palette: *mut SDL_Palette) -> c_int; + pub fn SDL_LockSurface(surface: *mut SDL_Surface) -> c_int; + pub fn SDL_UnlockSurface(surface: *mut SDL_Surface); + pub fn SDL_LoadBMP_RW(src: *mut SDL_RWops, freesrc: c_int) -> *mut SDL_Surface; + pub fn SDL_SaveBMP_RW(surface: *mut SDL_Surface, dst: *mut SDL_RWops, freedst: c_int) -> c_int; + pub fn SDL_SetSurfaceRLE(surface: *mut SDL_Surface, flag: c_int) -> c_int; + pub fn SDL_SetColorKey(surface: *mut SDL_Surface, flag: c_int, key: uint32_t) -> c_int; + pub fn SDL_GetColorKey(surface: *mut SDL_Surface, key: *mut uint32_t) -> c_int; + pub fn SDL_SetSurfaceColorMod(surface: *mut SDL_Surface, r: uint8_t, g: uint8_t, b: uint8_t) -> c_int; + pub fn SDL_GetSurfaceColorMod(surface: *mut SDL_Surface, r: *mut uint8_t, g: *mut uint8_t, b: *mut uint8_t ) -> c_int; + pub fn SDL_SetSurfaceAlphaMod(surface: *mut SDL_Surface, alpha: uint8_t) -> c_int; + pub fn SDL_GetSurfaceAlphaMod(surface: *mut SDL_Surface, alpha: *mut uint8_t ) -> c_int; + pub fn SDL_SetSurfaceBlendMode(surface: *mut SDL_Surface, blendMode: SDL_BlendMode) -> c_int; + pub fn SDL_GetSurfaceBlendMode(surface: *mut SDL_Surface, blendMode: *mut SDL_BlendMode) -> c_int; + pub fn SDL_SetClipRect(surface: *mut SDL_Surface, rect: *const SDL_Rect) -> SDL_bool; + pub fn SDL_GetClipRect(surface: *mut SDL_Surface, rect: *mut SDL_Rect); + pub fn SDL_ConvertSurface(src: *mut SDL_Surface, fmt: *mut SDL_PixelFormat, flags: uint32_t) -> *mut SDL_Surface; + pub fn SDL_ConvertSurfaceFormat(src: *mut SDL_Surface, pixel_format: uint32_t, flags: uint32_t) -> *mut SDL_Surface; + pub fn SDL_ConvertPixels(width: c_int, height: c_int, src_format: uint32_t, src: *const c_void, src_pitch: c_int, dst_format: uint32_t, dst: *mut c_void, dst_pitch: c_int) -> c_int; + pub fn SDL_FillRect(dst: *mut SDL_Surface, rect: *const SDL_Rect, color: uint32_t) -> c_int; + pub fn SDL_FillRects(dst: *mut SDL_Surface, rects: *const SDL_Rect, count: c_int, color: uint32_t) -> c_int; + pub fn SDL_UpperBlit(src: *mut SDL_Surface, srcrect: *mut SDL_Rect, dst: *mut SDL_Surface, dstrect: *mut SDL_Rect) -> c_int; + pub fn SDL_LowerBlit(src: *mut SDL_Surface, srcrect: *mut SDL_Rect, dst: *mut SDL_Surface, dstrect: *mut SDL_Rect) -> c_int; + pub fn SDL_SoftStretch(src: *mut SDL_Surface, srcrect: *mut SDL_Rect, dst: *mut SDL_Surface, dstrect: *mut SDL_Rect) -> c_int; + pub fn SDL_UpperBlitScaled(src: *mut SDL_Surface, srcrect: *mut SDL_Rect, dst: *mut SDL_Surface, dstrect: *mut SDL_Rect) -> c_int; + pub fn SDL_LowerBlitScaled(src: *mut SDL_Surface, srcrect: *mut SDL_Rect, dst: *mut SDL_Surface, dstrect: *mut SDL_Rect) -> c_int; } diff --git a/sdl2-sys/src/timer.rs b/sdl2-sys/src/timer.rs index 8dac9e5b..03c7dffb 100644 --- a/sdl2-sys/src/timer.rs +++ b/sdl2-sys/src/timer.rs @@ -4,7 +4,7 @@ use libc::{uint32_t, uint64_t, c_void, c_int}; //SDL_timer.h pub type SDL_TimerCallback = - Option uint32_t>; + Option uint32_t>; pub type SDL_TimerID = c_int; extern "C" { pub fn SDL_GetTicks() -> uint32_t; @@ -13,6 +13,6 @@ extern "C" { pub fn SDL_Delay(ms: uint32_t); pub fn SDL_AddTimer(interval: uint32_t, callback: SDL_TimerCallback, - param: *const c_void) -> SDL_TimerID; + param: *mut c_void) -> SDL_TimerID; pub fn SDL_RemoveTimer(id: SDL_TimerID) -> c_int; } diff --git a/sdl2-sys/src/touch.rs b/sdl2-sys/src/touch.rs index 8db0eded..935d88f7 100644 --- a/sdl2-sys/src/touch.rs +++ b/sdl2-sys/src/touch.rs @@ -19,5 +19,5 @@ extern "C" { pub fn SDL_GetTouchDevice(index: c_int) -> SDL_TouchID; pub fn SDL_GetNumTouchFingers(touchID: SDL_TouchID) -> c_int; pub fn SDL_GetTouchFinger(touchID: SDL_TouchID, index: c_int) -> - *const SDL_Finger; + *mut SDL_Finger; } diff --git a/sdl2-sys/src/video.rs b/sdl2-sys/src/video.rs index 98f81ff3..bb0b6931 100644 --- a/sdl2-sys/src/video.rs +++ b/sdl2-sys/src/video.rs @@ -21,7 +21,7 @@ pub struct SDL_DisplayMode { pub w: c_int, pub h: c_int, pub refresh_rate: c_int, - pub driverdata: *const c_void + pub driverdata: *mut c_void } pub type SDL_WindowPos = c_int; @@ -148,68 +148,68 @@ extern "C" { pub fn SDL_GetCurrentVideoDriver() -> *const c_char; pub fn SDL_GetNumVideoDisplays() -> c_int; pub fn SDL_GetDisplayName(displayIndex: c_int) -> *const c_char; - pub fn SDL_GetDisplayBounds(displayIndex: c_int, rect: *const SDL_Rect) -> c_int; + pub fn SDL_GetDisplayBounds(displayIndex: c_int, rect: *mut SDL_Rect) -> c_int; pub fn SDL_GetNumDisplayModes(displayIndex: c_int) -> c_int; - pub fn SDL_GetDisplayMode(displayIndex: c_int, modeIndex: c_int, mode: *const SDL_DisplayMode) -> c_int; - pub fn SDL_GetDesktopDisplayMode(displayIndex: c_int, mode: *const SDL_DisplayMode) -> c_int; - pub fn SDL_GetCurrentDisplayMode(displayIndex: c_int, mode: *const SDL_DisplayMode) -> c_int; - pub fn SDL_GetClosestDisplayMode(displayIndex: c_int, mode: *const SDL_DisplayMode, closest: *const SDL_DisplayMode) -> *const SDL_DisplayMode; - pub fn SDL_GetWindowDisplayIndex(window: *const SDL_Window) -> c_int; - pub fn SDL_SetWindowDisplayMode(window: *const SDL_Window, mode: *const SDL_DisplayMode) -> c_int; - pub fn SDL_GetWindowDisplayMode(window: *const SDL_Window, mode: *const SDL_DisplayMode) -> c_int; - pub fn SDL_GetWindowPixelFormat(window: *const SDL_Window) -> uint32_t; - pub fn SDL_CreateWindow(title: *const c_char, x: c_int, y: c_int, w: c_int, h: c_int, flags: uint32_t) -> *const SDL_Window; - pub fn SDL_CreateWindowFrom(data: *const c_void) -> *const SDL_Window; - pub fn SDL_GetWindowID(window: *const SDL_Window) -> uint32_t; - pub fn SDL_GetWindowFromID(id: uint32_t) -> *const SDL_Window; - pub fn SDL_GetWindowFlags(window: *const SDL_Window) -> uint32_t; - pub fn SDL_SetWindowTitle(window: *const SDL_Window, title: *const c_char); - pub fn SDL_GetWindowTitle(window: *const SDL_Window) -> *const c_char; - pub fn SDL_SetWindowIcon(window: *const SDL_Window, icon: *const SDL_Surface); - pub fn SDL_SetWindowData(window: *const SDL_Window, name: *const c_char, userdata: *const c_void) -> *const c_void; - pub fn SDL_GetWindowData(window: *const SDL_Window, name: *const c_char) -> *const c_void; - pub fn SDL_SetWindowPosition(window: *const SDL_Window, x: c_int, y: c_int); - pub fn SDL_GetWindowPosition(window: *const SDL_Window, x: *const c_int, y: *const c_int); - pub fn SDL_SetWindowSize(window: *const SDL_Window, w: c_int, h: c_int); - pub fn SDL_GetWindowSize(window: *const SDL_Window, w: *const c_int, h: *const c_int); - pub fn SDL_SetWindowMinimumSize(window: *const SDL_Window, min_w: c_int, min_h: c_int); - pub fn SDL_GetWindowMinimumSize(window: *const SDL_Window, w: *const c_int, h: *const c_int); - pub fn SDL_SetWindowMaximumSize(window: *const SDL_Window, max_w: c_int, max_h: c_int); - pub fn SDL_GetWindowMaximumSize(window: *const SDL_Window, w: *const c_int, h: *const c_int); - pub fn SDL_SetWindowBordered(window: *const SDL_Window, bordered: SDL_bool); - pub fn SDL_ShowWindow(window: *const SDL_Window); - pub fn SDL_HideWindow(window: *const SDL_Window); - pub fn SDL_RaiseWindow(window: *const SDL_Window); - pub fn SDL_MaximizeWindow(window: *const SDL_Window); - pub fn SDL_MinimizeWindow(window: *const SDL_Window); - pub fn SDL_RestoreWindow(window: *const SDL_Window); - pub fn SDL_SetWindowFullscreen(window: *const SDL_Window, flags: uint32_t) -> c_int; - pub fn SDL_GetWindowSurface(window: *const SDL_Window) -> *const SDL_Surface; - pub fn SDL_UpdateWindowSurface(window: *const SDL_Window) -> c_int; - pub fn SDL_UpdateWindowSurfaceRects(window: *const SDL_Window, rects: *const SDL_Rect, numrects: c_int) -> c_int; - pub fn SDL_SetWindowGrab(window: *const SDL_Window, grabbed: SDL_bool); - pub fn SDL_GetWindowGrab(window: *const SDL_Window) -> SDL_bool; - pub fn SDL_SetWindowBrightness(window: *const SDL_Window, brightness: c_float) -> c_int; - pub fn SDL_GetWindowBrightness(window: *const SDL_Window) -> c_float; - pub fn SDL_SetWindowGammaRamp(window: *const SDL_Window, red: *const uint16_t, green: *const uint16_t, blue: *const uint16_t) -> c_int; - pub fn SDL_GetWindowGammaRamp(window: *const SDL_Window, red: *const uint16_t, green: *const uint16_t, blue: *const uint16_t) -> c_int; - pub fn SDL_DestroyWindow(window: *const SDL_Window); + pub fn SDL_GetDisplayMode(displayIndex: c_int, modeIndex: c_int, mode: *mut SDL_DisplayMode) -> c_int; + pub fn SDL_GetDesktopDisplayMode(displayIndex: c_int, mode: *mut SDL_DisplayMode) -> c_int; + pub fn SDL_GetCurrentDisplayMode(displayIndex: c_int, mode: *mut SDL_DisplayMode) -> c_int; + pub fn SDL_GetClosestDisplayMode(displayIndex: c_int, mode: *const SDL_DisplayMode, closest: *mut SDL_DisplayMode) -> *mut SDL_DisplayMode; + pub fn SDL_GetWindowDisplayIndex(window: *mut SDL_Window) -> c_int; + pub fn SDL_SetWindowDisplayMode(window: *mut SDL_Window, mode: *const SDL_DisplayMode) -> c_int; + pub fn SDL_GetWindowDisplayMode(window: *mut SDL_Window, mode: *mut SDL_DisplayMode) -> c_int; + pub fn SDL_GetWindowPixelFormat(window: *mut SDL_Window) -> uint32_t; + pub fn SDL_CreateWindow(title: *const c_char, x: c_int, y: c_int, w: c_int, h: c_int, flags: uint32_t) -> *mut SDL_Window; + pub fn SDL_CreateWindowFrom(data: *const c_void) -> *mut SDL_Window; + pub fn SDL_GetWindowID(window: *mut SDL_Window) -> uint32_t; + pub fn SDL_GetWindowFromID(id: uint32_t) -> *mut SDL_Window; + pub fn SDL_GetWindowFlags(window: *mut SDL_Window) -> uint32_t; + pub fn SDL_SetWindowTitle(window: *mut SDL_Window, title: *const c_char); + pub fn SDL_GetWindowTitle(window: *mut SDL_Window) -> *const c_char; + pub fn SDL_SetWindowIcon(window: *mut SDL_Window, icon: *mut SDL_Surface); + pub fn SDL_SetWindowData(window: *mut SDL_Window, name: *const c_char, userdata: *const c_void) -> *const c_void; + pub fn SDL_GetWindowData(window: *mut SDL_Window, name: *const c_char) -> *mut c_void; + pub fn SDL_SetWindowPosition(window: *mut SDL_Window, x: c_int, y: c_int); + pub fn SDL_GetWindowPosition(window: *mut SDL_Window, x: *const c_int, y: *const c_int); + pub fn SDL_SetWindowSize(window: *mut SDL_Window, w: c_int, h: c_int); + pub fn SDL_GetWindowSize(window: *mut SDL_Window, w: *mut c_int, h: *mut c_int); + pub fn SDL_SetWindowMinimumSize(window: *mut SDL_Window, min_w: c_int, min_h: c_int); + pub fn SDL_GetWindowMinimumSize(window: *mut SDL_Window, w: *mut c_int, h: *mut c_int); + pub fn SDL_SetWindowMaximumSize(window: *mut SDL_Window, max_w: c_int, max_h: c_int); + pub fn SDL_GetWindowMaximumSize(window: *mut SDL_Window, w: *mut c_int, h: *mut c_int); + pub fn SDL_SetWindowBordered(window: *mut SDL_Window, bordered: SDL_bool); + pub fn SDL_ShowWindow(window: *mut SDL_Window); + pub fn SDL_HideWindow(window: *mut SDL_Window); + pub fn SDL_RaiseWindow(window: *mut SDL_Window); + pub fn SDL_MaximizeWindow(window: *mut SDL_Window); + pub fn SDL_MinimizeWindow(window: *mut SDL_Window); + pub fn SDL_RestoreWindow(window: *mut SDL_Window); + pub fn SDL_SetWindowFullscreen(window: *mut SDL_Window, flags: uint32_t) -> c_int; + pub fn SDL_GetWindowSurface(window: *mut SDL_Window) -> *mut SDL_Surface; + pub fn SDL_UpdateWindowSurface(window: *mut SDL_Window) -> c_int; + pub fn SDL_UpdateWindowSurfaceRects(window: *mut SDL_Window, rects: *const SDL_Rect, numrects: c_int) -> c_int; + pub fn SDL_SetWindowGrab(window: *mut SDL_Window, grabbed: SDL_bool); + pub fn SDL_GetWindowGrab(window: *mut SDL_Window) -> SDL_bool; + pub fn SDL_SetWindowBrightness(window: *mut SDL_Window, brightness: c_float) -> c_int; + pub fn SDL_GetWindowBrightness(window: *mut SDL_Window) -> c_float; + pub fn SDL_SetWindowGammaRamp(window: *mut SDL_Window, red: *const uint16_t, green: *const uint16_t, blue: *const uint16_t) -> c_int; + pub fn SDL_GetWindowGammaRamp(window: *mut SDL_Window, red: *mut uint16_t, green: *mut uint16_t, blue: *mut uint16_t) -> c_int; + pub fn SDL_DestroyWindow(window: *mut SDL_Window); pub fn SDL_IsScreenSaverEnabled() -> SDL_bool; pub fn SDL_EnableScreenSaver(); pub fn SDL_DisableScreenSaver(); - pub fn SDL_GL_GetDrawableSize(window: *const SDL_Window, w: *const c_int, h: *const c_int); + pub fn SDL_GL_GetDrawableSize(window: *mut SDL_Window, w: *mut c_int, h: *mut c_int); pub fn SDL_GL_LoadLibrary(path: *const c_char) -> c_int; pub fn SDL_GL_GetProcAddress(procname: *const c_char) -> Option; pub fn SDL_GL_UnloadLibrary(); pub fn SDL_GL_ExtensionSupported(extension: *const c_char) -> SDL_bool; pub fn SDL_GL_SetAttribute(attr: SDL_GLattr, value: c_int) -> c_int; - pub fn SDL_GL_GetAttribute(attr: SDL_GLattr, value: *const c_int) -> c_int; - pub fn SDL_GL_CreateContext(window: *const SDL_Window) -> SDL_GLContext; - pub fn SDL_GL_MakeCurrent(window: *const SDL_Window, context: SDL_GLContext) -> c_int; - pub fn SDL_GL_GetCurrentWindow() -> *const SDL_Window; + pub fn SDL_GL_GetAttribute(attr: SDL_GLattr, value: *mut c_int) -> c_int; + pub fn SDL_GL_CreateContext(window: *mut SDL_Window) -> SDL_GLContext; + pub fn SDL_GL_MakeCurrent(window: *mut SDL_Window, context: SDL_GLContext) -> c_int; + pub fn SDL_GL_GetCurrentWindow() -> *mut SDL_Window; pub fn SDL_GL_GetCurrentContext() -> SDL_GLContext; pub fn SDL_GL_SetSwapInterval(interval: c_int) -> c_int; pub fn SDL_GL_GetSwapInterval() -> c_int; - pub fn SDL_GL_SwapWindow(window: *const SDL_Window); + pub fn SDL_GL_SwapWindow(window: *mut SDL_Window); pub fn SDL_GL_DeleteContext(context: SDL_GLContext); } diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index e1b09f73..74659e9c 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -183,7 +183,7 @@ pub fn mapping_for_guid(guid: joystick::Guid) -> SdlResult { /// Wrapper around the SDL_GameController object pub struct GameController { - raw: *const ll::SDL_GameController, + raw: *mut ll::SDL_GameController, } impl GameController { diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 1a9af30c..ce706abf 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -486,8 +486,8 @@ impl Event { timestamp: 0, windowID: window_id, code: code as i32, - data1: ptr::null(), - data2: ptr::null(), + data1: ptr::null_mut(), + data2: ptr::null_mut(), }; unsafe { ptr::copy(&event, &mut ret as *mut ll::SDL_Event as *mut ll::SDL_UserEvent, 1); @@ -501,7 +501,7 @@ impl Event { } } - fn from_ll(raw: &ll::SDL_Event) -> Event { + fn from_ll(mut raw: ll::SDL_Event) -> Event { let raw_type = raw.type_(); let raw_type = if raw_type.is_null() { panic!("Event payload is null") @@ -864,7 +864,7 @@ impl Event { let buf = CStr::from_ptr(event.file).to_bytes(); let text = String::from_utf8_lossy(buf).to_string(); - ll::SDL_free(event.file as *const c_void); + ll::SDL_free(event.file as *mut c_void); Event::DropFile { timestamp: event.timestamp, @@ -918,7 +918,7 @@ impl<'sdl> EventPump<'sdl> { let mut raw = unsafe { mem::uninitialized() }; let has_pending = unsafe { ll::SDL_PollEvent(&mut raw) == 1 as c_int }; - if has_pending { Some(Event::from_ll(&raw)) } + if has_pending { Some(Event::from_ll(raw)) } else { None } } @@ -955,7 +955,7 @@ impl<'sdl> EventPump<'sdl> { let mut raw = mem::uninitialized(); let success = ll::SDL_WaitEvent(&mut raw) == 1; - if success { Event::from_ll(&raw) } + if success { Event::from_ll(raw) } else { panic!(get_error()) } } } @@ -966,7 +966,7 @@ impl<'sdl> EventPump<'sdl> { let mut raw = mem::uninitialized(); let success = ll::SDL_WaitEventTimeout(&mut raw, timeout as c_int) == 1; - if success { Some(Event::from_ll(&raw)) } + if success { Some(Event::from_ll(raw)) } else { None } } } @@ -1089,7 +1089,7 @@ where B: FromIterator } else { events.set_len(max_amount as usize); - events.iter().map(|event_raw| { + events.into_iter().map(|event_raw| { Event::from_ll(event_raw) }).collect() } diff --git a/src/sdl2/joystick.rs b/src/sdl2/joystick.rs index b0e15f3f..74374e2b 100644 --- a/src/sdl2/joystick.rs +++ b/src/sdl2/joystick.rs @@ -59,7 +59,7 @@ pub fn update() { /// Wrapper around the SDL_Joystick object pub struct Joystick { - raw: *const ll::SDL_Joystick, + raw: *mut ll::SDL_Joystick, } impl Joystick { diff --git a/src/sdl2/keyboard.rs b/src/sdl2/keyboard.rs index 58fdfc4f..55514ef8 100644 --- a/src/sdl2/keyboard.rs +++ b/src/sdl2/keyboard.rs @@ -30,7 +30,7 @@ bitflags! { pub fn get_keyboard_focus() -> Option { let raw = unsafe { ll::SDL_GetKeyboardFocus() }; - if raw == ptr::null() { + if raw == ptr::null_mut() { None } else { unsafe { Some(Window::from_ll(raw, false)) } @@ -39,9 +39,9 @@ pub fn get_keyboard_focus() -> Option { pub fn get_keyboard_state() -> HashMap { let mut state: HashMap = HashMap::new(); - let count = 0; + let mut count = 0; - let state_ptr = unsafe { ll::SDL_GetKeyboardState(&count) }; + let state_ptr = unsafe { ll::SDL_GetKeyboardState(&mut count) }; let raw = unsafe { ::std::slice::from_raw_parts(state_ptr, count as usize) }; diff --git a/src/sdl2/messagebox.rs b/src/sdl2/messagebox.rs index c0bda1ee..0f26c957 100644 --- a/src/sdl2/messagebox.rs +++ b/src/sdl2/messagebox.rs @@ -19,10 +19,10 @@ pub fn show_simple_message_box(flags: MessageBoxFlag, title: &str, message: &str let result = unsafe { let title_cstr = CString::new(title).unwrap().as_ptr(); let message_cstr = CString::new(message).unwrap().as_ptr(); - ll::SDL_ShowSimpleMessageBox(flags.bits(), - title_cstr, - message_cstr, - window.map_or(ptr::null(), |win| win.raw())) + ll::SDL_ShowSimpleMessageBox(flags.bits(), + title_cstr, + message_cstr, + window.map_or(ptr::null_mut(), |win| win.raw())) } == 0; if result { diff --git a/src/sdl2/mouse.rs b/src/sdl2/mouse.rs index 1da40a30..b9c9f660 100644 --- a/src/sdl2/mouse.rs +++ b/src/sdl2/mouse.rs @@ -26,7 +26,7 @@ pub enum SystemCursor { #[derive(PartialEq)] #[allow(raw_pointer_derive)] pub struct Cursor { - raw: *const ll::SDL_Cursor, + raw: *mut ll::SDL_Cursor, owned: bool } @@ -48,7 +48,7 @@ impl Cursor { width as i32, height as i32, hot_x as i32, hot_y as i32); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Cursor{ raw: raw, owned: true }) @@ -61,7 +61,7 @@ impl Cursor { unsafe { let raw = ll::SDL_CreateColorCursor(surface.raw(), hot_x, hot_y); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Cursor{ raw: raw, owned: true }) @@ -73,7 +73,7 @@ impl Cursor { unsafe { let raw = ll::SDL_CreateSystemCursor(cursor as u32); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Cursor{ raw: raw, owned: true }) @@ -119,7 +119,7 @@ pub fn wrap_mouse(bitflags: u8) -> Mouse { pub fn get_mouse_focus() -> Option { let raw = unsafe { ll::SDL_GetMouseFocus() }; - if raw == ptr::null() { + if raw == ptr::null_mut() { None } else { unsafe { Some(video::Window::from_ll(raw, false)) } @@ -127,19 +127,19 @@ pub fn get_mouse_focus() -> Option { } pub fn get_mouse_state() -> (MouseState, i32, i32) { - let x = 0; - let y = 0; + let mut x = 0; + let mut y = 0; unsafe { - let raw = ll::SDL_GetMouseState(&x, &y); + let raw = ll::SDL_GetMouseState(&mut x, &mut y); return (MouseState::from_bits_truncate(raw), x as i32, y as i32); } } pub fn get_relative_mouse_state() -> (MouseState, i32, i32) { - let x = 0; - let y = 0; + let mut x = 0; + let mut y = 0; unsafe { - let raw = ll::SDL_GetRelativeMouseState(&x, &y); + let raw = ll::SDL_GetRelativeMouseState(&mut x, &mut y); return (MouseState::from_bits_truncate(raw), x as i32, y as i32); } } @@ -159,7 +159,7 @@ pub fn get_relative_mouse_mode() -> bool { pub fn get_cursor() -> Option { let raw = unsafe { ll::SDL_GetCursor() }; - if raw == ptr::null() { + if raw == ptr::null_mut() { None } else { Some(Cursor { raw: raw, owned: false }) @@ -169,7 +169,7 @@ pub fn get_cursor() -> Option { pub fn get_default_cursor() -> Option { let raw = unsafe { ll::SDL_GetDefaultCursor() }; - if raw == ptr::null() { + if raw == ptr::null_mut() { None } else { Some(Cursor { raw: raw, owned: false }) diff --git a/src/sdl2/pixels.rs b/src/sdl2/pixels.rs index 92ff3006..cb8f4481 100644 --- a/src/sdl2/pixels.rs +++ b/src/sdl2/pixels.rs @@ -6,10 +6,10 @@ use sys::pixels as ll; #[derive(PartialEq)] #[allow(raw_pointer_derive, missing_copy_implementations)] pub struct Palette { - raw: *const ll::SDL_Palette + raw: *mut ll::SDL_Palette } -impl_raw_accessors!((Palette, *const ll::SDL_Palette)); +impl_raw_accessors!((Palette, *mut ll::SDL_Palette)); #[derive(PartialEq, Clone, Copy)] pub enum Color { @@ -30,13 +30,10 @@ impl Color { } pub fn from_u32(format: &PixelFormat, pixel: u32) -> Color { - let r: u8 = 0; - let g: u8 = 0; - let b: u8 = 0; - let a: u8 = 0; + let (mut r, mut g, mut b, mut a) = (0, 0, 0, 0); unsafe { - ll::SDL_GetRGBA(pixel, format.raw, &r, &g, &b, &a) + ll::SDL_GetRGBA(pixel, format.raw, &mut r, &mut g, &mut b, &mut a) }; Color::RGBA(r, g, b, a) } @@ -58,11 +55,11 @@ impl rand::Rand for Color { #[derive(PartialEq)] #[allow(raw_pointer_derive, missing_copy_implementations)] pub struct PixelFormat { - raw: *const ll::SDL_PixelFormat + raw: *mut ll::SDL_PixelFormat } -impl_raw_accessors!((PixelFormat, *const ll::SDL_PixelFormat)); -impl_raw_constructor!((PixelFormat, PixelFormat (raw: *const ll::SDL_PixelFormat))); +impl_raw_accessors!((PixelFormat, *mut ll::SDL_PixelFormat)); +impl_raw_constructor!((PixelFormat, PixelFormat (raw: *mut ll::SDL_PixelFormat))); #[derive(Copy, Clone, PartialEq, Debug)] pub enum PixelFormatEnum { diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index b6b2bf9f..58517ee2 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -148,7 +148,7 @@ pub enum RendererParent<'a> { /// 2D rendering context pub struct Renderer<'a> { - raw: *const ll::SDL_Renderer, + raw: *mut ll::SDL_Renderer, parent: Option>, is_alive: Rc> } @@ -174,7 +174,7 @@ impl<'a> Renderer<'a> { ll::SDL_CreateRenderer(window.raw(), index as c_int, renderer_flags.bits()) }; - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { unsafe { @@ -187,9 +187,9 @@ impl<'a> Renderer<'a> { pub fn new_with_window(_sdl: &Sdl, width: i32, height: i32, window_flags: video::WindowFlags) -> SdlResult> { use sys::video::SDL_Window; - let raw_window: *const SDL_Window = ptr::null(); - let raw_renderer: *const ll::SDL_Renderer = ptr::null(); - let result = unsafe { ll::SDL_CreateWindowAndRenderer(width as c_int, height as c_int, window_flags.bits(), &raw_window, &raw_renderer) == 0}; + let mut raw_window: *mut SDL_Window = ptr::null_mut(); + let mut raw_renderer: *mut ll::SDL_Renderer = ptr::null_mut(); + let result = unsafe { ll::SDL_CreateWindowAndRenderer(width as c_int, height as c_int, window_flags.bits(), &mut raw_window, &mut raw_renderer) == 0}; if result { let window = unsafe { Window::from_ll(raw_window, true) }; unsafe { @@ -203,7 +203,7 @@ impl<'a> Renderer<'a> { /// Creates a 2D software rendering context for a surface. pub fn from_surface(surface: surface::Surface<'a>) -> SdlResult> { let raw_renderer = unsafe { ll::SDL_CreateSoftwareRenderer(surface.raw()) }; - if raw_renderer != ptr::null() { + if raw_renderer != ptr::null_mut() { unsafe { Ok(Renderer::from_ll(raw_renderer, RendererParent::Surface(surface))) } @@ -215,8 +215,8 @@ impl<'a> Renderer<'a> { /// Gets information about the rendering context. pub fn get_info(&self) -> RendererInfo { unsafe { - let renderer_info_raw: ll::SDL_RendererInfo = mem::uninitialized(); - if ll::SDL_GetRendererInfo(self.raw, &renderer_info_raw) != 0 { + let mut renderer_info_raw = mem::uninitialized(); + if ll::SDL_GetRendererInfo(self.raw, &mut renderer_info_raw) != 0 { // Should only fail on an invalid renderer panic!(); } else { @@ -306,9 +306,9 @@ impl<'a> Renderer<'a> { } /// Unwraps the window or surface the rendering context was created from. - pub unsafe fn raw(&self) -> *const ll::SDL_Renderer { self.raw } + pub unsafe fn raw(&self) -> *mut ll::SDL_Renderer { self.raw } - pub unsafe fn from_ll(raw: *const ll::SDL_Renderer, parent: RendererParent) + pub unsafe fn from_ll(raw: *mut ll::SDL_Renderer, parent: RendererParent) -> Renderer { Renderer { @@ -339,7 +339,7 @@ impl<'a> Renderer<'a> { } let result = unsafe { ll::SDL_CreateTexture(self.raw, format as uint32_t, access as c_int, width as c_int, height as c_int) }; - if result == ptr::null() { + if result == ptr::null_mut() { Err(get_error()) } else { unsafe { Ok(Texture::from_ll(self, result)) } @@ -366,7 +366,7 @@ impl<'a> Renderer<'a> { /// The access hint for the created texture is `TextureAccess::Static`. pub fn create_texture_from_surface(&self, surface: &surface::Surface) -> SdlResult { let result = unsafe { ll::SDL_CreateTextureFromSurface(self.raw, surface.raw()) }; - if result == ptr::null() { + if result == ptr::null_mut() { Err(get_error()) } else { unsafe { Ok(Texture::from_ll(self, result)) } @@ -376,13 +376,13 @@ impl<'a> Renderer<'a> { /// Drawing functionality for the render context. pub struct RenderDrawer<'renderer> { - raw: *const ll::SDL_Renderer, + raw: *mut ll::SDL_Renderer, is_renderer_alive: &'renderer Rc> } /// Render target methods for the drawer impl<'renderer> RenderDrawer<'renderer> { - fn new<'l>(raw: *const ll::SDL_Renderer, is_renderer_alive: &'l Rc>) -> RenderDrawer<'l> { + fn new<'l>(raw: *mut ll::SDL_Renderer, is_renderer_alive: &'l Rc>) -> RenderDrawer<'l> { RenderDrawer { raw: raw, is_renderer_alive: is_renderer_alive @@ -427,11 +427,8 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the color used for drawing operations (Rect, Line and Clear). pub fn get_draw_color(&self) -> pixels::Color { - let r: u8 = 0; - let g: u8 = 0; - let b: u8 = 0; - let a: u8 = 0; - let ret = unsafe { ll::SDL_GetRenderDrawColor(self.raw, &r, &g, &b, &a) }; + let (mut r, mut g, mut b, mut a) = (0, 0, 0, 0); + let ret = unsafe { ll::SDL_GetRenderDrawColor(self.raw, &mut r, &mut g, &mut b, &mut a) }; // Should only fail on an invalid renderer if ret != 0 { panic!(get_error()) } else { pixels::Color::RGBA(r, g, b, a) } @@ -446,8 +443,8 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the blend mode used for drawing operations. pub fn get_blend_mode(&self) -> BlendMode { - let blend = 0; - let ret = unsafe { ll::SDL_GetRenderDrawBlendMode(self.raw, &blend) }; + let mut blend = 0; + let ret = unsafe { ll::SDL_GetRenderDrawBlendMode(self.raw, &mut blend) }; // Should only fail on an invalid renderer if ret != 0 { panic!(get_error()) } else { FromPrimitive::from_i64(blend as i64).unwrap() } @@ -472,10 +469,10 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the output size of a rendering context. pub fn get_output_size(&self) -> SdlResult<(i32, i32)> { - let width: c_int = 0; - let height: c_int = 0; + let mut width = 0; + let mut height = 0; - let result = unsafe { ll::SDL_GetRendererOutputSize(self.raw, &width, &height) == 0 }; + let result = unsafe { ll::SDL_GetRendererOutputSize(self.raw, &mut width, &mut height) == 0 }; if result { Ok((width as i32, height as i32)) @@ -492,11 +489,10 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets device independent resolution for rendering. pub fn get_logical_size(&self) -> (i32, i32) { + let mut width = 0; + let mut height = 0; - let width: c_int = 0; - let height: c_int = 0; - - unsafe { ll::SDL_RenderGetLogicalSize(self.raw, &width, &height) }; + unsafe { ll::SDL_RenderGetLogicalSize(self.raw, &mut width, &mut height) }; (width as i32, height as i32) } @@ -513,13 +509,8 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the drawing area for the current target. pub fn get_viewport(&self) -> Rect { - let rect = Rect{ - x: 0, - y: 0, - w: 0, - h: 0 - }; - unsafe { ll::SDL_RenderGetViewport(self.raw, &rect) }; + let mut rect = unsafe { mem::uninitialized() }; + unsafe { ll::SDL_RenderGetViewport(self.raw, &mut rect) }; rect } @@ -539,13 +530,8 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the clip rectangle for the current target. pub fn get_clip_rect(&self) -> Rect { - let rect = Rect{ - x: 0, - y: 0, - w: 0, - h: 0 - }; - unsafe { ll::SDL_RenderGetClipRect(self.raw, &rect) }; + let mut rect = unsafe { mem::uninitialized() }; + unsafe { ll::SDL_RenderGetClipRect(self.raw, &mut rect) }; rect } @@ -558,9 +544,9 @@ impl<'renderer> RenderDrawer<'renderer> { /// Gets the drawing scale for the current target. pub fn get_scale(&self) -> (f32, f32) { - let scale_x = 0.0; - let scale_y = 0.0; - unsafe { ll::SDL_RenderGetScale(self.raw, &scale_x, &scale_y) }; + let mut scale_x = 0.0; + let mut scale_y = 0.0; + unsafe { ll::SDL_RenderGetScale(self.raw, &mut scale_x, &mut scale_y) }; (scale_x, scale_y) } @@ -792,7 +778,7 @@ impl<'renderer> RenderDrawer<'renderer> { /// } /// ``` pub struct RenderTarget<'renderer> { - raw: *const ll::SDL_Renderer, + raw: *mut ll::SDL_Renderer, is_renderer_alive: &'renderer Rc> } @@ -804,7 +790,7 @@ impl<'renderer> RenderTarget<'renderer> { unsafe { let old_texture_raw = ll::SDL_GetRenderTarget(self.raw); - if ll::SDL_SetRenderTarget(self.raw, ptr::null()) == 0 { + if ll::SDL_SetRenderTarget(self.raw, ptr::null_mut()) == 0 { Ok(match old_texture_raw.is_null() { true => None, false => Some(Texture { @@ -852,7 +838,7 @@ impl<'renderer> RenderTarget<'renderer> { ll::SDL_CreateTexture(self.raw, format as uint32_t, access as c_int, width as c_int, height as c_int) }; - if new_texture_raw == ptr::null() { + if new_texture_raw == ptr::null_mut() { Err(get_error()) } else { unsafe { @@ -890,7 +876,7 @@ pub struct TextureQuery { /// /// A Texture can be safely dropped before or after the Renderer is dropped. pub struct Texture { - raw: *const ll::SDL_Texture, + raw: *mut ll::SDL_Texture, is_renderer_alive: Rc> } @@ -927,12 +913,12 @@ impl Texture { pub fn query(&self) -> TextureQuery { self.check_renderer(); - let format: uint32_t = 0; - let access: c_int = 0; - let width: c_int = 0; - let height: c_int = 0; + let mut format = 0; + let mut access = 0; + let mut width = 0; + let mut height = 0; - let ret = unsafe { ll::SDL_QueryTexture(self.raw, &format, &access, &width, &height) }; + let ret = unsafe { ll::SDL_QueryTexture(self.raw, &mut format, &mut access, &mut width, &mut height) }; // Should only fail on an invalid texture if ret != 0 { panic!(get_error()) @@ -961,10 +947,8 @@ impl Texture { pub fn get_color_mod(&self) -> (u8, u8, u8) { self.check_renderer(); - let r = 0; - let g = 0; - let b = 0; - let ret = unsafe { ll::SDL_GetTextureColorMod(self.raw, &r, &g, &b) }; + let (mut r, mut g, mut b) = (0, 0, 0); + let ret = unsafe { ll::SDL_GetTextureColorMod(self.raw, &mut r, &mut g, &mut b) }; // Should only fail on an invalid texture if ret != 0 { panic!(get_error()) } @@ -986,8 +970,8 @@ impl Texture { pub fn get_alpha_mod(&self) -> u8 { self.check_renderer(); - let alpha = 0; - let ret = unsafe { ll::SDL_GetTextureAlphaMod(self.raw, &alpha) }; + let mut alpha = 0; + let ret = unsafe { ll::SDL_GetTextureAlphaMod(self.raw, &mut alpha) }; // Should only fail on an invalid texture if ret != 0 { panic!(get_error()) } @@ -1009,8 +993,8 @@ impl Texture { pub fn get_blend_mode(&self) -> BlendMode { self.check_renderer(); - let blend = 0; - let ret = unsafe { ll::SDL_GetTextureBlendMode(self.raw, &blend) }; + let mut blend = 0; + let ret = unsafe { ll::SDL_GetTextureBlendMode(self.raw, &mut blend) }; // Should only fail on an invalid texture if ret != 0 { panic!(get_error()) } @@ -1163,10 +1147,10 @@ impl Texture { pub unsafe fn gl_bind_texture(&mut self) -> (f32, f32) { self.check_renderer(); - let texw = 0.0; - let texh = 0.0; + let mut texw = 0.0; + let mut texh = 0.0; - if ll::SDL_GL_BindTexture(self.raw, &texw, &texh) == 0 { + if ll::SDL_GL_BindTexture(self.raw, &mut texw, &mut texh) == 0 { (texw, texh) } else { panic!("OpenGL texture binding not supported"); @@ -1187,10 +1171,10 @@ impl Texture { self.check_renderer(); unsafe { - let texw = 0.0; - let texh = 0.0; + let mut texw = 0.0; + let mut texh = 0.0; - if ll::SDL_GL_BindTexture(self.raw, &texw, &texh) == 0 { + if ll::SDL_GL_BindTexture(self.raw, &mut texw, &mut texh) == 0 { let return_value = f(texw, texh); if ll::SDL_GL_UnbindTexture(self.raw) == 0 { @@ -1205,14 +1189,14 @@ impl Texture { } } - pub unsafe fn from_ll(renderer: &Renderer, raw: *const ll::SDL_Texture) -> Texture { + pub unsafe fn from_ll(renderer: &Renderer, raw: *mut ll::SDL_Texture) -> Texture { Texture { raw: raw, is_renderer_alive: renderer.is_alive.clone() } } - pub unsafe fn raw(&self) -> *const ll::SDL_Texture { self.raw } + pub unsafe fn raw(&self) -> *mut ll::SDL_Texture { self.raw } } @@ -1226,15 +1210,8 @@ pub fn get_num_render_drivers() -> SdlResult { } pub fn get_render_driver_info(index: i32) -> SdlResult { - let out = ll::SDL_RendererInfo { - name: ptr::null(), - flags: 0, - num_texture_formats: 0, - texture_formats: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], - max_texture_width: 0, - max_texture_height: 0, - }; - let result = unsafe { ll::SDL_GetRenderDriverInfo(index as c_int, &out) == 0 }; + let mut out = unsafe { mem::uninitialized() }; + let result = unsafe { ll::SDL_GetRenderDriverInfo(index as c_int, &mut out) == 0 }; if result { unsafe { Ok(RendererInfo::from_ll(&out)) } } else { diff --git a/src/sdl2/rwops.rs b/src/sdl2/rwops.rs index 704b170e..ba74e19c 100644 --- a/src/sdl2/rwops.rs +++ b/src/sdl2/rwops.rs @@ -9,11 +9,11 @@ use sys::rwops as ll; #[derive(PartialEq)] #[allow(raw_pointer_derive)] pub struct RWops { - raw: *const ll::SDL_RWops, + raw: *mut ll::SDL_RWops, close_on_drop: bool } -impl_raw_accessors!((RWops, *const ll::SDL_RWops)); +impl_raw_accessors!((RWops, *mut ll::SDL_RWops)); impl_owned_accessors!((RWops, close_on_drop)); /// A structure that provides an abstract interface to stream I/O. @@ -62,7 +62,7 @@ impl io::Read for RWops { // FIXME: it's better to use as_mut_ptr(). // number of objects read, or 0 at error or end of file. let ret = unsafe { - ((*self.raw).read)(self.raw, buf.as_ptr() as *const c_void, 1, out_len) + ((*self.raw).read)(self.raw, buf.as_ptr() as *mut c_void, 1, out_len) }; Ok(ret as usize) } diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index da96ab6d..e8c3a9a5 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -23,7 +23,7 @@ bitflags! { } pub struct Surface<'a> { - raw: *const ll::SDL_Surface, + raw: *mut ll::SDL_Surface, owned: bool, _marker: PhantomData<&'a ()> } @@ -39,11 +39,11 @@ impl<'a> Drop for Surface<'a> { } impl<'a> Surface<'a> { - pub unsafe fn raw(&self) -> *const ll::SDL_Surface { self.raw } + pub unsafe fn raw(&self) -> *mut ll::SDL_Surface { self.raw } pub unsafe fn owned(&self) -> bool { self.owned } - pub unsafe fn from_ll<'b>(raw: *const ll::SDL_Surface, owned: bool) -> Surface<'b> { + pub unsafe fn from_ll<'b>(raw: *mut ll::SDL_Surface, owned: bool) -> Surface<'b> { Surface { raw: raw, owned: owned, @@ -57,7 +57,7 @@ impl<'a> Surface<'a> { let raw = ll::SDL_CreateRGBSurface(surface_flags.bits(), width as c_int, height as c_int, bpp as c_int, rmask, gmask, bmask, amask); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Surface { @@ -74,10 +74,10 @@ impl<'a> Surface<'a> { unsafe { let raw = ll::SDL_CreateRGBSurfaceFrom( - data.as_ptr() as *const _, width as c_int, height as c_int, + data.as_mut_ptr() as *mut _, width as c_int, height as c_int, bpp as c_int, pitch as c_int, rmask, gmask, bmask, amask); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Surface { @@ -199,9 +199,9 @@ impl<'a> Surface<'a> { } pub fn get_color_key(&self) -> SdlResult { - let key: u32 = 0; + let mut key = 0; let result = unsafe { - ll::SDL_GetColorKey(self.raw, &key) + ll::SDL_GetColorKey(self.raw, &mut key) }; if result == 0 { @@ -223,12 +223,12 @@ impl<'a> Surface<'a> { } pub fn get_color_mod(&self) -> SdlResult { - let r: u8 = 0; - let g: u8 = 0; - let b: u8 = 0; + let mut r = 0; + let mut g = 0; + let mut b = 0; let result = unsafe { - ll::SDL_GetSurfaceColorMod(self.raw, &r, &g, &b) == 0 + ll::SDL_GetSurfaceColorMod(self.raw, &mut r, &mut g, &mut b) == 0 }; if result { @@ -282,9 +282,9 @@ impl<'a> Surface<'a> { } pub fn get_alpha_mod(&self) -> SdlResult { - let alpha = 0u8; + let mut alpha = 0; let result = unsafe { - ll::SDL_GetSurfaceAlphaMod(self.raw, &alpha) + ll::SDL_GetSurfaceAlphaMod(self.raw, &mut alpha) }; match result { @@ -305,9 +305,9 @@ impl<'a> Surface<'a> { } pub fn get_blend_mode(&self) -> SdlResult { - let mode: ll::SDL_BlendMode = 0; + let mut mode: ll::SDL_BlendMode = 0; let result = unsafe { - ll::SDL_GetSurfaceBlendMode(self.raw, &mode) + ll::SDL_GetSurfaceBlendMode(self.raw, &mut mode) }; match result { @@ -323,9 +323,9 @@ impl<'a> Surface<'a> { } pub fn get_clip_rect(&self) -> Rect { - let rect = Rect::new(0, 0, 0, 0); + let mut rect = Rect::new(0, 0, 0, 0); unsafe { - ll::SDL_GetClipRect(self.raw, &rect) + ll::SDL_GetClipRect(self.raw, &mut rect) }; rect } @@ -334,7 +334,7 @@ impl<'a> Surface<'a> { // SDL_ConvertSurface takes a flag as the last parameter, which should be 0 by the docs. let surface_ptr = unsafe { ll::SDL_ConvertSurface(self.raw, format.raw(), 0u32) }; - if surface_ptr == ptr::null() { + if surface_ptr== ptr::null_mut() { Err(get_error()) } else { unsafe { Ok(Surface::from_ll(surface_ptr, true)) } @@ -344,7 +344,7 @@ impl<'a> Surface<'a> { pub fn convert_format(&self, format: pixels::PixelFormatEnum) -> SdlResult> { let surface_ptr = unsafe { ll::SDL_ConvertSurfaceFormat(self.raw, format as uint32_t, 0u32) }; - if surface_ptr == ptr::null() { + if surface_ptr== ptr::null_mut() { Err(get_error()) } else { unsafe { Ok(Surface::from_ll(surface_ptr, true)) } diff --git a/src/sdl2/timer.rs b/src/sdl2/timer.rs index 3b9f5ffd..40bd6a3a 100644 --- a/src/sdl2/timer.rs +++ b/src/sdl2/timer.rs @@ -63,9 +63,9 @@ impl<'a> Drop for Timer<'a> { } } -extern "C" fn c_timer_callback(_interval: u32, param: *const c_void) -> uint32_t { +extern "C" fn c_timer_callback(_interval: u32, param: *mut c_void) -> uint32_t { unsafe { - let f: *const Box u32> = mem::transmute(param); + let f: *mut Box u32> = mem::transmute(param); (*f)() as uint32_t } } diff --git a/src/sdl2/touch.rs b/src/sdl2/touch.rs index db445bff..5b7116a7 100644 --- a/src/sdl2/touch.rs +++ b/src/sdl2/touch.rs @@ -20,7 +20,7 @@ pub fn get_num_touch_fingers(touch: TouchDevice) -> i32 { pub fn get_touch_finger(touch: TouchDevice, index: i32) -> Option { let raw = unsafe { ll::SDL_GetTouchFinger(touch, index) }; - if raw == ptr::null() { + if raw == ptr::null_mut() { None } else { unsafe { Some(*raw) } diff --git a/src/sdl2/version.rs b/src/sdl2/version.rs index 5a5a1858..eb8b911c 100644 --- a/src/sdl2/version.rs +++ b/src/sdl2/version.rs @@ -20,11 +20,8 @@ pub struct Version { impl Version { /// Convert a raw *SDL_version to Version. - pub fn from_ll(sv: *const ll::SDL_version) -> Version { - unsafe { - let ref v = *sv; - Version{ major: v.major, minor: v.minor, patch: v.patch } - } + pub fn from_ll(v: ll::SDL_version) -> Version { + Version { major: v.major, minor: v.minor, patch: v.patch } } } @@ -39,7 +36,7 @@ pub fn get_version() -> Version { unsafe { let mut cver = ll::SDL_version { major: 0, minor: 0, patch: 0}; ll::SDL_GetVersion(&mut cver); - Version::from_ll(&cver) + Version::from_ll(cver) } } diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index 6d20b60f..8d1cec5e 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -96,7 +96,7 @@ impl DisplayMode { w: self.w as c_int, h: self.h as c_int, refresh_rate: self.refresh_rate as c_int, - driverdata: ptr::null() + driverdata: ptr::null_mut() } } } @@ -159,13 +159,13 @@ impl Drop for GLContext { } pub struct Window { - raw: *const ll::SDL_Window, + raw: *mut ll::SDL_Window, owned: bool } impl_raw_accessors!( (GLContext, ll::SDL_GLContext), - (Window, *const ll::SDL_Window) + (Window, *mut ll::SDL_Window) ); impl_owned_accessors!( @@ -174,7 +174,7 @@ impl_owned_accessors!( ); impl_raw_constructor!( - (Window, Window (raw: *const ll::SDL_Window, owned: bool)) + (Window, Window (raw: *mut ll::SDL_Window, owned: bool)) ); impl Drop for Window { @@ -189,7 +189,7 @@ impl Drop for Window { /// Contains accessors to a `Window`'s properties. pub struct WindowProperties<'a> { - raw: *const ll::SDL_Window, + raw: *mut ll::SDL_Window, _marker: PhantomData<&'a ()> } @@ -242,7 +242,7 @@ impl Window { window_flags.bits() ); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { try!(init(WindowProperties { @@ -311,7 +311,7 @@ impl Window { /// already being used as a variable in the application. pub unsafe fn from_id(id: u32) -> SdlResult { let raw = ll::SDL_GetWindowFromID(id); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Window{ raw: raw, owned: false}) @@ -324,7 +324,7 @@ impl Window { pub fn gl_create_context(&self) -> SdlResult { let result = unsafe { ll::SDL_GL_CreateContext(self.raw) }; - if result == ptr::null() { + if result == ptr::null_mut() { Err(get_error()) } else { Ok(GLContext{raw: result, owned: true}) @@ -361,7 +361,7 @@ impl<'a> WindowProperties<'a> { let result = ll::SDL_SetWindowDisplayMode( self.raw, match display_mode { - Some(ref mode) => &mode.to_ll() as *const _, + Some(ref mode) => &mode.to_ll(), None => ptr::null() } ); @@ -374,12 +374,12 @@ impl<'a> WindowProperties<'a> { } pub fn get_display_mode(&self) -> SdlResult { - let dm = unsafe { mem::uninitialized() }; + let mut dm = unsafe { mem::uninitialized() }; let result = unsafe { ll::SDL_GetWindowDisplayMode( self.raw, - &dm + &mut dm ) == 0 }; @@ -431,9 +431,9 @@ impl<'a> WindowProperties<'a> { } pub fn get_position(&self) -> (i32, i32) { - let x: c_int = 0; - let y: c_int = 0; - unsafe { ll::SDL_GetWindowPosition(self.raw, &x, &y) }; + let mut x: c_int = 0; + let mut y: c_int = 0; + unsafe { ll::SDL_GetWindowPosition(self.raw, &mut x, &mut y) }; (x as i32, y as i32) } @@ -442,16 +442,16 @@ impl<'a> WindowProperties<'a> { } pub fn get_size(&self) -> (i32, i32) { - let w: c_int = 0; - let h: c_int = 0; - unsafe { ll::SDL_GetWindowSize(self.raw, &w, &h) }; + let mut w: c_int = 0; + let mut h: c_int = 0; + unsafe { ll::SDL_GetWindowSize(self.raw, &mut w, &mut h) }; (w as i32, h as i32) } pub fn get_drawable_size(&self) -> (i32, i32) { - let w: c_int = 0; - let h: c_int = 0; - unsafe { ll::SDL_GL_GetDrawableSize(self.raw, &w, &h) }; + let mut w: c_int = 0; + let mut h: c_int = 0; + unsafe { ll::SDL_GL_GetDrawableSize(self.raw, &mut w, &mut h) }; (w as i32, h as i32) } @@ -460,9 +460,9 @@ impl<'a> WindowProperties<'a> { } pub fn get_minimum_size(&self) -> (i32, i32) { - let w: c_int = 0; - let h: c_int = 0; - unsafe { ll::SDL_GetWindowMinimumSize(self.raw, &w, &h) }; + let mut w: c_int = 0; + let mut h: c_int = 0; + unsafe { ll::SDL_GetWindowMinimumSize(self.raw, &mut w, &mut h) }; (w as i32, h as i32) } @@ -471,9 +471,9 @@ impl<'a> WindowProperties<'a> { } pub fn get_maximum_size(&self) -> (i32, i32) { - let w: c_int = 0; - let h: c_int = 0; - unsafe { ll::SDL_GetWindowMaximumSize(self.raw, &w, &h) }; + let mut w: c_int = 0; + let mut h: c_int = 0; + unsafe { ll::SDL_GetWindowMaximumSize(self.raw, &mut w, &mut h) }; (w as i32, h as i32) } @@ -518,7 +518,7 @@ impl<'a> WindowProperties<'a> { pub fn get_surface(&mut self) -> SdlResult { let raw = unsafe { ll::SDL_GetWindowSurface(self.raw) }; - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { unsafe { Ok(Surface::from_ll(raw, false)) } //Docs say that it releases with the window @@ -591,10 +591,10 @@ impl<'a> WindowProperties<'a> { } pub fn get_gamma_ramp(&self) -> SdlResult<(Vec, Vec, Vec)> { - let red: Vec = Vec::with_capacity(256); - let green: Vec = Vec::with_capacity(256); - let blue: Vec = Vec::with_capacity(256); - let result = unsafe {ll::SDL_GetWindowGammaRamp(self.raw, red.as_ptr(), green.as_ptr(), blue.as_ptr()) == 0}; + let mut red: Vec = Vec::with_capacity(256); + let mut green: Vec = Vec::with_capacity(256); + let mut blue: Vec = Vec::with_capacity(256); + let result = unsafe {ll::SDL_GetWindowGammaRamp(self.raw, red.as_mut_ptr(), green.as_mut_ptr(), blue.as_mut_ptr()) == 0}; if result { Ok((red, green, blue)) } else { @@ -656,8 +656,8 @@ pub fn get_display_name(display_index: i32) -> String { } pub fn get_display_bounds(display_index: i32) -> SdlResult { - let out: Rect = Rect::new(0, 0, 0, 0); - let result = unsafe { ll::SDL_GetDisplayBounds(display_index as c_int, &out) == 0 }; + let mut out: Rect = Rect::new(0, 0, 0, 0); + let result = unsafe { ll::SDL_GetDisplayBounds(display_index as c_int, &mut out) == 0 }; if result { Ok(out) @@ -676,8 +676,8 @@ pub fn get_num_display_modes(display_index: i32) -> SdlResult { } pub fn get_display_mode(display_index: i32, mode_index: i32) -> SdlResult { - let dm = unsafe { mem::uninitialized() }; - let result = unsafe { ll::SDL_GetDisplayMode(display_index as c_int, mode_index as c_int, &dm) == 0}; + let mut dm = unsafe { mem::uninitialized() }; + let result = unsafe { ll::SDL_GetDisplayMode(display_index as c_int, mode_index as c_int, &mut dm) == 0}; if result { Ok(DisplayMode::from_ll(&dm)) @@ -687,8 +687,8 @@ pub fn get_display_mode(display_index: i32, mode_index: i32) -> SdlResult SdlResult { - let dm = unsafe { mem::uninitialized() }; - let result = unsafe { ll::SDL_GetDesktopDisplayMode(display_index as c_int, &dm) == 0}; + let mut dm = unsafe { mem::uninitialized() }; + let result = unsafe { ll::SDL_GetDesktopDisplayMode(display_index as c_int, &mut dm) == 0}; if result { Ok(DisplayMode::from_ll(&dm)) @@ -698,8 +698,8 @@ pub fn get_desktop_display_mode(display_index: i32) -> SdlResult { } pub fn get_current_display_mode(display_index: i32) -> SdlResult { - let dm = unsafe { mem::uninitialized() }; - let result = unsafe { ll::SDL_GetCurrentDisplayMode(display_index as c_int, &dm) == 0}; + let mut dm = unsafe { mem::uninitialized() }; + let result = unsafe { ll::SDL_GetCurrentDisplayMode(display_index as c_int, &mut dm) == 0}; if result { Ok(DisplayMode::from_ll(&dm)) @@ -710,11 +710,11 @@ pub fn get_current_display_mode(display_index: i32) -> SdlResult { pub fn get_closest_display_mode(display_index: i32, mode: &DisplayMode) -> SdlResult { let input = mode.to_ll(); - let dm = unsafe { mem::uninitialized() }; + let mut dm = unsafe { mem::uninitialized() }; - let result = unsafe { ll::SDL_GetClosestDisplayMode(display_index as c_int, &input, &dm) }; + let result = unsafe { ll::SDL_GetClosestDisplayMode(display_index as c_int, &input, &mut dm) }; - if result == ptr::null() { + if result == ptr::null_mut() { Err(get_error()) } else { Ok(DisplayMode::from_ll(&dm)) @@ -773,9 +773,9 @@ pub fn gl_set_attribute(attr: GLAttr, value: i32) -> bool { } pub fn gl_get_attribute(attr: GLAttr) -> SdlResult { - let out: c_int = 0; + let mut out = 0; - let result = unsafe { ll::SDL_GL_GetAttribute(FromPrimitive::from_u64(attr as u64).unwrap(), &out) } == 0; + let result = unsafe { ll::SDL_GL_GetAttribute(FromPrimitive::from_u64(attr as u64).unwrap(), &mut out) } == 0; if result { Ok(out as i32) } else { @@ -785,7 +785,7 @@ pub fn gl_get_attribute(attr: GLAttr) -> SdlResult { pub unsafe fn gl_get_current_window() -> SdlResult { let raw = ll::SDL_GL_GetCurrentWindow(); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(Window{ raw: raw, owned: false }) @@ -794,7 +794,7 @@ pub unsafe fn gl_get_current_window() -> SdlResult { pub unsafe fn gl_get_current_context() -> SdlResult { let raw = ll::SDL_GL_GetCurrentContext(); - if raw == ptr::null() { + if raw == ptr::null_mut() { Err(get_error()) } else { Ok(GLContext{ raw: raw, owned: false })