sdl2 2.4.1.0 → 2.5.0.0
raw patch · 10 files changed
+253/−61 lines, 10 filesdep ~StateVarPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: StateVar
API changes (from Hackage documentation)
- SDL.Exception: instance GHC.Exception.Exception SDL.Exception.SDLException
- SDL.Internal.Vect: instance (Data.Data.Data (f a), Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f) => Data.Data.Data (SDL.Internal.Vect.Point f a)
- SDL.Raw.Error: instance GHC.Exception.Exception SDL.Raw.Error.SDLError
- SDL.Video: [windowOpenGL] :: WindowConfig -> Maybe OpenGLConfig
+ SDL.Exception: instance GHC.Exception.Type.Exception SDL.Exception.SDLException
+ SDL.Input.Keyboard.Codes: pattern KeycodeSleep :: () => () => Keycode
+ SDL.Input.Keyboard.Codes: pattern ScancodeApp2 :: () => () => Scancode
+ SDL.Internal.Vect: instance (Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable a, Data.Data.Data (f a)) => Data.Data.Data (SDL.Internal.Vect.Point f a)
+ SDL.Raw.Enum: pattern SDL_AUDIO_F32SYS :: () => () => AudioFormat
+ SDL.Raw.Enum: pattern SDL_AUDIO_PAUSED :: () => () => AudioStatus
+ SDL.Raw.Enum: pattern SDL_BLENDMODE_MOD :: () => () => BlendMode
+ SDL.Raw.Enum: pattern SDL_BIG_ENDIAN :: () => () => Endian
+ SDL.Raw.Enum: pattern SDL_GETEVENT :: () => () => EventAction
+ SDL.Raw.Enum: pattern SDL_GL_CONTEXT_RELEASE_BEHAVIOR :: () => () => GLattr
+ SDL.Raw.Enum: pattern SDL_CONTROLLER_AXIS_MAX :: () => () => GameControllerAxis
+ SDL.Raw.Enum: pattern SDL_CONTROLLER_BUTTON_MAX :: () => () => GameControllerButton
+ SDL.Raw.Enum: pattern SDL_HINT_OVERRIDE :: () => () => HintPriority
+ SDL.Raw.Enum: pattern SDL_INIT_EVERYTHING :: () => () => InitFlag
+ SDL.Raw.Enum: pattern SDL_JOYSTICK_POWER_MAX :: () => () => JoystickPowerLevel
+ SDL.Raw.Enum: pattern SDLK_SLEEP :: () => () => Keycode
+ SDL.Raw.Enum: pattern SDL_NUM_LOG_PRIORITIES :: () => () => LogPriority
+ SDL.Raw.Enum: pattern SDL_POWERSTATE_CHARGED :: () => () => PowerState
+ SDL.Raw.Enum: pattern SDL_FLIP_VERTICAL :: () => () => RendererFlip
+ SDL.Raw.Enum: pattern SDL_NUM_SCANCODES :: () => () => Scancode
+ SDL.Raw.Enum: pattern SDL_NUM_SYSTEM_CURSORS :: () => () => SystemCursor
+ SDL.Raw.Enum: pattern SDL_THREAD_PRIORITY_HIGH :: () => () => ThreadPriority
+ SDL.Raw.Enum: pattern SDL_HAPTIC_CONSTANT :: forall a. (Eq a, Num a) => () => a
+ SDL.Raw.Error: instance GHC.Exception.Type.Exception SDL.Raw.Error.SDLError
+ SDL.Raw.Types: type VkGetInstanceProcAddrFunc = VkInstance -> CString -> IO (FunPtr ())
+ SDL.Raw.Types: type VkInstance = Ptr ()
+ SDL.Raw.Types: type VkSurfaceKHR = Word64
+ SDL.Raw.Video: vkCreateSurface :: MonadIO m => Window -> VkInstance -> Ptr VkSurfaceKHR -> m Bool
+ SDL.Raw.Video: vkGetDrawableSize :: MonadIO m => Window -> Ptr CInt -> Ptr CInt -> m ()
+ SDL.Raw.Video: vkGetInstanceExtensions :: MonadIO m => Window -> Ptr CUInt -> Ptr CString -> m Bool
+ SDL.Raw.Video: vkGetVkGetInstanceProcAddr :: MonadIO m => m (FunPtr VkGetInstanceProcAddrFunc)
+ SDL.Raw.Video: vkLoadLibrary :: MonadIO m => CString -> m CInt
+ SDL.Raw.Video: vkUnloadLibrary :: MonadIO m => m ()
+ SDL.Video: NoGraphicsContext :: WindowGraphicsContext
+ SDL.Video: OpenGLContext :: OpenGLConfig -> WindowGraphicsContext
+ SDL.Video: VulkanContext :: WindowGraphicsContext
+ SDL.Video: [windowGraphicsContext] :: WindowConfig -> WindowGraphicsContext
+ SDL.Video: data WindowGraphicsContext
+ SDL.Video: instance GHC.Classes.Eq SDL.Video.WindowGraphicsContext
+ SDL.Video: instance GHC.Classes.Ord SDL.Video.WindowGraphicsContext
+ SDL.Video: instance GHC.Generics.Generic SDL.Video.WindowGraphicsContext
+ SDL.Video: instance GHC.Read.Read SDL.Video.WindowGraphicsContext
+ SDL.Video: instance GHC.Show.Show SDL.Video.WindowGraphicsContext
+ SDL.Video.Vulkan: type VkGetInstanceProcAddrFunc = VkInstance -> CString -> IO (FunPtr ())
+ SDL.Video.Vulkan: type VkInstance = Ptr ()
+ SDL.Video.Vulkan: type VkSurfaceKHR = Word64
+ SDL.Video.Vulkan: vkCreateSurface :: MonadIO m => Window -> VkInstance -> m VkSurfaceKHR
+ SDL.Video.Vulkan: vkGetDrawableSize :: MonadIO m => Window -> m (V2 CInt)
+ SDL.Video.Vulkan: vkGetInstanceExtensions :: MonadIO m => Window -> m [CString]
+ SDL.Video.Vulkan: vkGetVkGetInstanceProcAddr :: (Functor m, MonadIO m) => m VkGetInstanceProcAddrFunc
+ SDL.Video.Vulkan: vkLoadLibrary :: MonadIO m => Maybe FilePath -> m ()
+ SDL.Video.Vulkan: vkUnloadLibrary :: MonadIO m => m ()
- SDL: ($=) :: HasSetter t a => forall (m :: * -> *). MonadIO m => t -> a -> m ()
+ SDL: ($=) :: (HasSetter t a, MonadIO m) => t -> a -> m ()
- SDL: ($~!) :: HasUpdate t a b => forall (m :: * -> *). MonadIO m => t -> (a -> b) -> m ()
+ SDL: ($~!) :: (HasUpdate t a b, MonadIO m) => t -> (a -> b) -> m ()
- SDL: ($~) :: HasUpdate t a b => forall (m :: * -> *). MonadIO m => t -> (a -> b) -> m ()
+ SDL: ($~) :: (HasUpdate t a b, MonadIO m) => t -> (a -> b) -> m ()
- SDL: get :: HasGetter t a => forall (m :: * -> *). MonadIO m => t -> m a
+ SDL: get :: (HasGetter t a, MonadIO m) => t -> m a
- SDL.Audio: OpenDeviceSpec :: !(Changeable CInt) -> !(Changeable (AudioFormat sampleType)) -> !(Changeable Channels) -> !Word16 -> (forall actualSampleType. AudioFormat actualSampleType -> IOVector actualSampleType -> IO ()) -> !AudioDeviceUsage -> !(Maybe Text) -> OpenDeviceSpec
+ SDL.Audio: OpenDeviceSpec :: !Changeable CInt -> !Changeable (AudioFormat sampleType) -> !Changeable Channels -> !Word16 -> (forall actualSampleType. AudioFormat actualSampleType -> IOVector actualSampleType -> IO ()) -> !AudioDeviceUsage -> !Maybe Text -> OpenDeviceSpec
- SDL.Audio: [openDeviceChannels] :: OpenDeviceSpec -> !(Changeable Channels)
+ SDL.Audio: [openDeviceChannels] :: OpenDeviceSpec -> !Changeable Channels
- SDL.Audio: [openDeviceFormat] :: OpenDeviceSpec -> !(Changeable (AudioFormat sampleType))
+ SDL.Audio: [openDeviceFormat] :: OpenDeviceSpec -> !Changeable (AudioFormat sampleType)
- SDL.Audio: [openDeviceFreq] :: OpenDeviceSpec -> !(Changeable CInt)
+ SDL.Audio: [openDeviceFreq] :: OpenDeviceSpec -> !Changeable CInt
- SDL.Audio: [openDeviceName] :: OpenDeviceSpec -> !(Maybe Text)
+ SDL.Audio: [openDeviceName] :: OpenDeviceSpec -> !Maybe Text
- SDL.Audio: audioSpecFormat :: AudioSpec -> (AudioFormat sampleType)
+ SDL.Audio: audioSpecFormat :: AudioSpec -> AudioFormat sampleType
- SDL.Event: DollarGestureEventData :: !TouchID -> !GestureID -> !Word32 -> !CFloat -> !(Point V2 CFloat) -> DollarGestureEventData
+ SDL.Event: DollarGestureEventData :: !TouchID -> !GestureID -> !Word32 -> !CFloat -> !Point V2 CFloat -> DollarGestureEventData
- SDL.Event: JoyBallEventData :: !JoystickID -> !Word8 -> !(V2 Int16) -> JoyBallEventData
+ SDL.Event: JoyBallEventData :: !JoystickID -> !Word8 -> !V2 Int16 -> JoyBallEventData
- SDL.Event: KeyboardEventData :: !(Maybe Window) -> !InputMotion -> !Bool -> !Keysym -> KeyboardEventData
+ SDL.Event: KeyboardEventData :: !Maybe Window -> !InputMotion -> !Bool -> !Keysym -> KeyboardEventData
- SDL.Event: MouseButtonEventData :: !(Maybe Window) -> !InputMotion -> !MouseDevice -> !MouseButton -> !Word8 -> !(Point V2 Int32) -> MouseButtonEventData
+ SDL.Event: MouseButtonEventData :: !Maybe Window -> !InputMotion -> !MouseDevice -> !MouseButton -> !Word8 -> !Point V2 Int32 -> MouseButtonEventData
- SDL.Event: MouseMotionEventData :: !(Maybe Window) -> !MouseDevice -> ![MouseButton] -> !(Point V2 Int32) -> !(V2 Int32) -> MouseMotionEventData
+ SDL.Event: MouseMotionEventData :: !Maybe Window -> !MouseDevice -> ![MouseButton] -> !Point V2 Int32 -> !V2 Int32 -> MouseMotionEventData
- SDL.Event: MouseWheelEventData :: !(Maybe Window) -> !MouseDevice -> !(V2 Int32) -> !MouseScrollDirection -> MouseWheelEventData
+ SDL.Event: MouseWheelEventData :: !Maybe Window -> !MouseDevice -> !V2 Int32 -> !MouseScrollDirection -> MouseWheelEventData
- SDL.Event: MultiGestureEventData :: !TouchID -> !CFloat -> !CFloat -> !(Point V2 CFloat) -> !Word16 -> MultiGestureEventData
+ SDL.Event: MultiGestureEventData :: !TouchID -> !CFloat -> !CFloat -> !Point V2 CFloat -> !Word16 -> MultiGestureEventData
- SDL.Event: RegisteredEventData :: !(Maybe Window) -> !Int32 -> !(Ptr ()) -> !(Ptr ()) -> RegisteredEventData
+ SDL.Event: RegisteredEventData :: !Maybe Window -> !Int32 -> !Ptr () -> !Ptr () -> RegisteredEventData
- SDL.Event: TextEditingEventData :: !(Maybe Window) -> !Text -> !Int32 -> !Int32 -> TextEditingEventData
+ SDL.Event: TextEditingEventData :: !Maybe Window -> !Text -> !Int32 -> !Int32 -> TextEditingEventData
- SDL.Event: TextInputEventData :: !(Maybe Window) -> !Text -> TextInputEventData
+ SDL.Event: TextInputEventData :: !Maybe Window -> !Text -> TextInputEventData
- SDL.Event: TouchFingerEventData :: !TouchID -> !FingerID -> !InputMotion -> !(Point V2 CFloat) -> !CFloat -> TouchFingerEventData
+ SDL.Event: TouchFingerEventData :: !TouchID -> !FingerID -> !InputMotion -> !Point V2 CFloat -> !CFloat -> TouchFingerEventData
- SDL.Event: TouchFingerMotionEventData :: !TouchID -> !FingerID -> !(Point V2 CFloat) -> !(V2 CFloat) -> !CFloat -> TouchFingerMotionEventData
+ SDL.Event: TouchFingerMotionEventData :: !TouchID -> !FingerID -> !Point V2 CFloat -> !V2 CFloat -> !CFloat -> TouchFingerMotionEventData
- SDL.Event: UserEventData :: !Word32 -> !(Maybe Window) -> !Int32 -> !(Ptr ()) -> !(Ptr ()) -> UserEventData
+ SDL.Event: UserEventData :: !Word32 -> !Maybe Window -> !Int32 -> !Ptr () -> !Ptr () -> UserEventData
- SDL.Event: WindowMovedEventData :: !Window -> !(Point V2 Int32) -> WindowMovedEventData
+ SDL.Event: WindowMovedEventData :: !Window -> !Point V2 Int32 -> WindowMovedEventData
- SDL.Event: WindowResizedEventData :: !Window -> !(V2 Int32) -> WindowResizedEventData
+ SDL.Event: WindowResizedEventData :: !Window -> !V2 Int32 -> WindowResizedEventData
- SDL.Event: WindowSizeChangedEventData :: !Window -> !(V2 Int32) -> WindowSizeChangedEventData
+ SDL.Event: WindowSizeChangedEventData :: !Window -> !V2 Int32 -> WindowSizeChangedEventData
- SDL.Event: [dollarGestureEventPos] :: DollarGestureEventData -> !(Point V2 CFloat)
+ SDL.Event: [dollarGestureEventPos] :: DollarGestureEventData -> !Point V2 CFloat
- SDL.Event: [joyBallEventRelMotion] :: JoyBallEventData -> !(V2 Int16)
+ SDL.Event: [joyBallEventRelMotion] :: JoyBallEventData -> !V2 Int16
- SDL.Event: [keyboardEventWindow] :: KeyboardEventData -> !(Maybe Window)
+ SDL.Event: [keyboardEventWindow] :: KeyboardEventData -> !Maybe Window
- SDL.Event: [mouseButtonEventPos] :: MouseButtonEventData -> !(Point V2 Int32)
+ SDL.Event: [mouseButtonEventPos] :: MouseButtonEventData -> !Point V2 Int32
- SDL.Event: [mouseButtonEventWindow] :: MouseButtonEventData -> !(Maybe Window)
+ SDL.Event: [mouseButtonEventWindow] :: MouseButtonEventData -> !Maybe Window
- SDL.Event: [mouseMotionEventPos] :: MouseMotionEventData -> !(Point V2 Int32)
+ SDL.Event: [mouseMotionEventPos] :: MouseMotionEventData -> !Point V2 Int32
- SDL.Event: [mouseMotionEventRelMotion] :: MouseMotionEventData -> !(V2 Int32)
+ SDL.Event: [mouseMotionEventRelMotion] :: MouseMotionEventData -> !V2 Int32
- SDL.Event: [mouseMotionEventWindow] :: MouseMotionEventData -> !(Maybe Window)
+ SDL.Event: [mouseMotionEventWindow] :: MouseMotionEventData -> !Maybe Window
- SDL.Event: [mouseWheelEventPos] :: MouseWheelEventData -> !(V2 Int32)
+ SDL.Event: [mouseWheelEventPos] :: MouseWheelEventData -> !V2 Int32
- SDL.Event: [mouseWheelEventWindow] :: MouseWheelEventData -> !(Maybe Window)
+ SDL.Event: [mouseWheelEventWindow] :: MouseWheelEventData -> !Maybe Window
- SDL.Event: [multiGestureEventPos] :: MultiGestureEventData -> !(Point V2 CFloat)
+ SDL.Event: [multiGestureEventPos] :: MultiGestureEventData -> !Point V2 CFloat
- SDL.Event: [registeredEventData1] :: RegisteredEventData -> !(Ptr ())
+ SDL.Event: [registeredEventData1] :: RegisteredEventData -> !Ptr ()
- SDL.Event: [registeredEventData2] :: RegisteredEventData -> !(Ptr ())
+ SDL.Event: [registeredEventData2] :: RegisteredEventData -> !Ptr ()
- SDL.Event: [registeredEventWindow] :: RegisteredEventData -> !(Maybe Window)
+ SDL.Event: [registeredEventWindow] :: RegisteredEventData -> !Maybe Window
- SDL.Event: [textEditingEventWindow] :: TextEditingEventData -> !(Maybe Window)
+ SDL.Event: [textEditingEventWindow] :: TextEditingEventData -> !Maybe Window
- SDL.Event: [textInputEventWindow] :: TextInputEventData -> !(Maybe Window)
+ SDL.Event: [textInputEventWindow] :: TextInputEventData -> !Maybe Window
- SDL.Event: [touchFingerEventPos] :: TouchFingerEventData -> !(Point V2 CFloat)
+ SDL.Event: [touchFingerEventPos] :: TouchFingerEventData -> !Point V2 CFloat
- SDL.Event: [touchFingerMotionEventPos] :: TouchFingerMotionEventData -> !(Point V2 CFloat)
+ SDL.Event: [touchFingerMotionEventPos] :: TouchFingerMotionEventData -> !Point V2 CFloat
- SDL.Event: [touchFingerMotionEventRelMotion] :: TouchFingerMotionEventData -> !(V2 CFloat)
+ SDL.Event: [touchFingerMotionEventRelMotion] :: TouchFingerMotionEventData -> !V2 CFloat
- SDL.Event: [userEventData1] :: UserEventData -> !(Ptr ())
+ SDL.Event: [userEventData1] :: UserEventData -> !Ptr ()
- SDL.Event: [userEventData2] :: UserEventData -> !(Ptr ())
+ SDL.Event: [userEventData2] :: UserEventData -> !Ptr ()
- SDL.Event: [userEventWindow] :: UserEventData -> !(Maybe Window)
+ SDL.Event: [userEventWindow] :: UserEventData -> !Maybe Window
- SDL.Event: [windowMovedEventPosition] :: WindowMovedEventData -> !(Point V2 Int32)
+ SDL.Event: [windowMovedEventPosition] :: WindowMovedEventData -> !Point V2 Int32
- SDL.Event: [windowResizedEventSize] :: WindowResizedEventData -> !(V2 Int32)
+ SDL.Event: [windowResizedEventSize] :: WindowResizedEventData -> !V2 Int32
- SDL.Event: [windowSizeChangedEventSize] :: WindowSizeChangedEventData -> !(V2 Int32)
+ SDL.Event: [windowSizeChangedEventSize] :: WindowSizeChangedEventData -> !V2 Int32
- SDL.Input.Joystick: getJoystickID :: MonadIO m => Joystick -> m (Int32)
+ SDL.Input.Joystick: getJoystickID :: MonadIO m => Joystick -> m Int32
- SDL.Input.Joystick: numAxes :: (MonadIO m) => Joystick -> m CInt
+ SDL.Input.Joystick: numAxes :: MonadIO m => Joystick -> m CInt
- SDL.Input.Joystick: numBalls :: (MonadIO m) => Joystick -> m CInt
+ SDL.Input.Joystick: numBalls :: MonadIO m => Joystick -> m CInt
- SDL.Input.Joystick: numButtons :: (MonadIO m) => Joystick -> m CInt
+ SDL.Input.Joystick: numButtons :: MonadIO m => Joystick -> m CInt
- SDL.Input.Joystick: numHats :: (MonadIO m) => Joystick -> m CInt
+ SDL.Input.Joystick: numHats :: MonadIO m => Joystick -> m CInt
- SDL.Input.Joystick: numJoysticks :: MonadIO m => m (CInt)
+ SDL.Input.Joystick: numJoysticks :: MonadIO m => m CInt
- SDL.Internal.Exception: throwIfNull :: (MonadIO m) => Text -> Text -> m (Ptr a) -> m (Ptr a)
+ SDL.Internal.Exception: throwIfNull :: MonadIO m => Text -> Text -> m (Ptr a) -> m (Ptr a)
- SDL.Internal.Types: Window :: (Window) -> Window
+ SDL.Internal.Types: Window :: Window -> Window
- SDL.Internal.Vect: P :: (f a) -> Point f a
+ SDL.Internal.Vect: P :: f a -> Point f a
- SDL.Raw.Types: AudioCVT :: !CInt -> !AudioFormat -> !AudioFormat -> !CDouble -> !(Ptr Word8) -> !CInt -> !CInt -> !CInt -> !CDouble -> AudioCVT
+ SDL.Raw.Types: AudioCVT :: !CInt -> !AudioFormat -> !AudioFormat -> !CDouble -> !Ptr Word8 -> !CInt -> !CInt -> !CInt -> !CDouble -> AudioCVT
- SDL.Raw.Types: AudioSpec :: !CInt -> !AudioFormat -> !Word8 -> !Word8 -> !Word16 -> !Word32 -> !AudioCallback -> !(Ptr ()) -> AudioSpec
+ SDL.Raw.Types: AudioSpec :: !CInt -> !AudioFormat -> !Word8 -> !Word8 -> !Word16 -> !Word32 -> !AudioCallback -> !Ptr () -> AudioSpec
- SDL.Raw.Types: DisplayMode :: !Word32 -> !CInt -> !CInt -> !CInt -> !(Ptr ()) -> DisplayMode
+ SDL.Raw.Types: DisplayMode :: !Word32 -> !CInt -> !CInt -> !CInt -> !Ptr () -> DisplayMode
- SDL.Raw.Types: HapticCustom :: !Word16 -> !HapticDirection -> !Word32 -> !Word16 -> !Word16 -> !Word16 -> !Word8 -> !Word16 -> !Word16 -> !(Ptr Word16) -> !Word16 -> !Word16 -> !Word16 -> !Word16 -> HapticEffect
+ SDL.Raw.Types: HapticCustom :: !Word16 -> !HapticDirection -> !Word32 -> !Word16 -> !Word16 -> !Word16 -> !Word8 -> !Word16 -> !Word16 -> !Ptr Word16 -> !Word16 -> !Word16 -> !Word16 -> !Word16 -> HapticEffect
- SDL.Raw.Types: MessageBoxData :: !Word32 -> !Window -> !CString -> !CString -> !CInt -> !(Ptr MessageBoxButtonData) -> !(Ptr MessageBoxColorScheme) -> MessageBoxData
+ SDL.Raw.Types: MessageBoxData :: !Word32 -> !Window -> !CString -> !CString -> !CInt -> !Ptr MessageBoxButtonData -> !Ptr MessageBoxColorScheme -> MessageBoxData
- SDL.Raw.Types: Palette :: !CInt -> !(Ptr Color) -> Palette
+ SDL.Raw.Types: Palette :: !CInt -> !Ptr Color -> Palette
- SDL.Raw.Types: PixelFormat :: !Word32 -> !(Ptr Palette) -> !Word8 -> !Word8 -> !Word32 -> !Word32 -> !Word32 -> !Word32 -> PixelFormat
+ SDL.Raw.Types: PixelFormat :: !Word32 -> !Ptr Palette -> !Word8 -> !Word8 -> !Word32 -> !Word32 -> !Word32 -> !Word32 -> PixelFormat
- SDL.Raw.Types: RWops :: !(FunPtr (Ptr RWops -> IO Int64)) -> !(FunPtr (Ptr RWops -> Int64 -> CInt -> IO Int64)) -> !(FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize)) -> !(FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize)) -> !(FunPtr (Ptr RWops -> IO CInt)) -> !Word32 -> RWops
+ SDL.Raw.Types: RWops :: !FunPtr (Ptr RWops -> IO Int64) -> !FunPtr (Ptr RWops -> Int64 -> CInt -> IO Int64) -> !FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize) -> !FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize) -> !FunPtr (Ptr RWops -> IO CInt) -> !Word32 -> RWops
- SDL.Raw.Types: Surface :: !(Ptr PixelFormat) -> !CInt -> !CInt -> !(Ptr ()) -> !(Ptr ()) -> !Rect -> !CInt -> Surface
+ SDL.Raw.Types: Surface :: !Ptr PixelFormat -> !CInt -> !CInt -> !Ptr () -> !Ptr () -> !Rect -> !CInt -> Surface
- SDL.Raw.Types: UserEvent :: !Word32 -> !Word32 -> !Word32 -> !Int32 -> !(Ptr ()) -> !(Ptr ()) -> Event
+ SDL.Raw.Types: UserEvent :: !Word32 -> !Word32 -> !Word32 -> !Int32 -> !Ptr () -> !Ptr () -> Event
- SDL.Raw.Types: [audioCVTBuf] :: AudioCVT -> !(Ptr Word8)
+ SDL.Raw.Types: [audioCVTBuf] :: AudioCVT -> !Ptr Word8
- SDL.Raw.Types: [audioSpecUserdata] :: AudioSpec -> !(Ptr ())
+ SDL.Raw.Types: [audioSpecUserdata] :: AudioSpec -> !Ptr ()
- SDL.Raw.Types: [displayModeDriverData] :: DisplayMode -> !(Ptr ())
+ SDL.Raw.Types: [displayModeDriverData] :: DisplayMode -> !Ptr ()
- SDL.Raw.Types: [hapticCustomData] :: HapticEffect -> !(Ptr Word16)
+ SDL.Raw.Types: [hapticCustomData] :: HapticEffect -> !Ptr Word16
- SDL.Raw.Types: [messageBoxDataButtons] :: MessageBoxData -> !(Ptr MessageBoxButtonData)
+ SDL.Raw.Types: [messageBoxDataButtons] :: MessageBoxData -> !Ptr MessageBoxButtonData
- SDL.Raw.Types: [messageBoxDataColorScheme] :: MessageBoxData -> !(Ptr MessageBoxColorScheme)
+ SDL.Raw.Types: [messageBoxDataColorScheme] :: MessageBoxData -> !Ptr MessageBoxColorScheme
- SDL.Raw.Types: [paletteColors] :: Palette -> !(Ptr Color)
+ SDL.Raw.Types: [paletteColors] :: Palette -> !Ptr Color
- SDL.Raw.Types: [pixelFormatPalette] :: PixelFormat -> !(Ptr Palette)
+ SDL.Raw.Types: [pixelFormatPalette] :: PixelFormat -> !Ptr Palette
- SDL.Raw.Types: [rwopsClose] :: RWops -> !(FunPtr (Ptr RWops -> IO CInt))
+ SDL.Raw.Types: [rwopsClose] :: RWops -> !FunPtr (Ptr RWops -> IO CInt)
- SDL.Raw.Types: [rwopsRead] :: RWops -> !(FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize))
+ SDL.Raw.Types: [rwopsRead] :: RWops -> !FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize)
- SDL.Raw.Types: [rwopsSeek] :: RWops -> !(FunPtr (Ptr RWops -> Int64 -> CInt -> IO Int64))
+ SDL.Raw.Types: [rwopsSeek] :: RWops -> !FunPtr (Ptr RWops -> Int64 -> CInt -> IO Int64)
- SDL.Raw.Types: [rwopsSize] :: RWops -> !(FunPtr (Ptr RWops -> IO Int64))
+ SDL.Raw.Types: [rwopsSize] :: RWops -> !FunPtr (Ptr RWops -> IO Int64)
- SDL.Raw.Types: [rwopsWrite] :: RWops -> !(FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize))
+ SDL.Raw.Types: [rwopsWrite] :: RWops -> !FunPtr (Ptr RWops -> Ptr () -> CSize -> CSize -> IO CSize)
- SDL.Raw.Types: [surfaceFormat] :: Surface -> !(Ptr PixelFormat)
+ SDL.Raw.Types: [surfaceFormat] :: Surface -> !Ptr PixelFormat
- SDL.Raw.Types: [surfacePixels] :: Surface -> !(Ptr ())
+ SDL.Raw.Types: [surfacePixels] :: Surface -> !Ptr ()
- SDL.Raw.Types: [surfaceUserdata] :: Surface -> !(Ptr ())
+ SDL.Raw.Types: [surfaceUserdata] :: Surface -> !Ptr ()
- SDL.Raw.Types: [userEventData1] :: Event -> !(Ptr ())
+ SDL.Raw.Types: [userEventData1] :: Event -> !Ptr ()
- SDL.Raw.Types: [userEventData2] :: Event -> !(Ptr ())
+ SDL.Raw.Types: [userEventData2] :: Event -> !Ptr ()
- SDL.Vect: data V2 a :: * -> *
+ SDL.Vect: data V2 a
- SDL.Vect: data V3 a :: * -> *
+ SDL.Vect: data V3 a
- SDL.Vect: data V4 a :: * -> *
+ SDL.Vect: data V4 a
- SDL.Vect: newtype Point (f :: * -> *) a :: (* -> *) -> * -> *
+ SDL.Vect: newtype Point (f :: Type -> Type) a
- SDL.Video: Absolute :: (Point V2 CInt) -> WindowPosition
+ SDL.Video: Absolute :: Point V2 CInt -> WindowPosition
- SDL.Video: WindowConfig :: Bool -> Bool -> Bool -> WindowMode -> Maybe OpenGLConfig -> WindowPosition -> Bool -> V2 CInt -> Bool -> WindowConfig
+ SDL.Video: WindowConfig :: Bool -> Bool -> Bool -> WindowMode -> WindowGraphicsContext -> WindowPosition -> Bool -> V2 CInt -> Bool -> WindowConfig
- SDL.Video.Renderer: Rectangle :: (Point V2 a) -> (V2 a) -> Rectangle a
+ SDL.Video.Renderer: Rectangle :: Point V2 a -> V2 a -> Rectangle a
- SDL.Video.Renderer: Surface :: (Ptr Surface) -> (Maybe (IOVector Word8)) -> Surface
+ SDL.Video.Renderer: Surface :: Ptr Surface -> Maybe (IOVector Word8) -> Surface
- SDL.Video.Renderer: masksToPixelFormat :: (MonadIO m) => CInt -> V4 Word32 -> m PixelFormat
+ SDL.Video.Renderer: masksToPixelFormat :: MonadIO m => CInt -> V4 Word32 -> m PixelFormat
- SDL.Video.Renderer: pixelFormatToMasks :: (MonadIO m) => PixelFormat -> m (CInt, V4 Word32)
+ SDL.Video.Renderer: pixelFormatToMasks :: MonadIO m => PixelFormat -> m (CInt, V4 Word32)
- SDL.Video.Renderer: renderTargetSupported :: (MonadIO m) => Renderer -> m Bool
+ SDL.Video.Renderer: renderTargetSupported :: MonadIO m => Renderer -> m Bool
- SDL.Video.Renderer: setPaletteColors :: MonadIO m => Palette -> (Vector (V4 Word8)) -> CInt -> m ()
+ SDL.Video.Renderer: setPaletteColors :: MonadIO m => Palette -> Vector (V4 Word8) -> CInt -> m ()
Files
- ChangeLog.md +11/−1
- bench/Space.hs +2/−2
- examples/EventWatch.hs +9/−9
- examples/OpenGLExample.hs +1/−1
- sdl2.cabal +6/−4
- src/SDL/Raw/Enum.hsc +2/−0
- src/SDL/Raw/Types.hsc +8/−0
- src/SDL/Raw/Video.hs +40/−1
- src/SDL/Video.hs +64/−43
- src/SDL/Video/Vulkan.hs +110/−0
ChangeLog.md view
@@ -1,3 +1,13 @@+2.5.0.0+=======++* Version 2.0.6 of the SDL2 C library is now required.++* Added Vulkan support. See `SDL.Video.WindowGraphicsContext` data type and `SDL.Video.Vulkan` module.++* Support `StateVar` < 1.3++ 2.4.1.0 ======= @@ -11,7 +21,7 @@ https://github.com/haskell-game/sdl2/pull/177 for more information. Thanks to @Linearity for identifying and fixing this bug. - + 2.4.0.1 ======= * Raise upper bounds for `exceptions` to <0.11
bench/Space.hs view
@@ -44,9 +44,9 @@ (\weight -> if weightGCs weight > 0 then Just "Non-zero number of garbage collections!"- else if weightAllocatedBytes weight > 3000+ else if weightAllocatedBytes weight > 4000 then Just- "Allocated >3KB! Allocations should be constant."+ "Allocated >4KB! Allocations should be constant." else Nothing) | i <- [1, 10, 100, 1000, 10000] ])
examples/EventWatch.hs view
@@ -18,15 +18,15 @@ main = do initializeAll window <- createWindow "resize" WindowConfig {- windowBorder = True- , windowHighDPI = False- , windowInputGrabbed = False- , windowMode = Windowed- , windowOpenGL = Nothing- , windowPosition = Wherever- , windowResizable = True- , windowInitialSize = V2 800 600- , windowVisible = True+ windowBorder = True+ , windowHighDPI = False+ , windowInputGrabbed = False+ , windowMode = Windowed+ , windowGraphicsContext = NoGraphicsContext+ , windowPosition = Wherever+ , windowResizable = True+ , windowInitialSize = V2 800 600+ , windowVisible = True } renderer <- createRenderer window (-1) defaultRenderer addEventWatch $ \ev ->
examples/OpenGLExample.hs view
@@ -31,7 +31,7 @@ SDL.createWindow "SDL / OpenGL Example" SDL.defaultWindow {SDL.windowInitialSize = V2 screenWidth screenHeight,- SDL.windowOpenGL = Just SDL.defaultOpenGL}+ SDL.windowGraphicsContext = SDL.OpenGLContext SDL.defaultOpenGL} SDL.showWindow window _ <- SDL.glCreateContext window
sdl2.cabal view
@@ -1,6 +1,6 @@ name: sdl2-version: 2.4.1.0-synopsis: Both high- and low-level bindings to the SDL library (version 2.0.4+).+version: 2.5.0.0+synopsis: Both high- and low-level bindings to the SDL library (version 2.0.6+). description: This package contains bindings to the SDL 2 library, in both high- and low-level forms:@@ -78,6 +78,7 @@ SDL.Video SDL.Video.OpenGL SDL.Video.Renderer+ SDL.Video.Vulkan SDL.Internal.Exception SDL.Internal.Numbered@@ -113,19 +114,20 @@ includes: SDL.h+ SDL_vulkan.h sdlhelper.h extra-libraries: SDL2 pkgconfig-depends:- sdl2 >= 2.0.4+ sdl2 >= 2.0.6 build-depends: base >= 4.7 && < 5, bytestring >= 0.10.4.0 && < 0.11, exceptions >= 0.4 && < 0.11,- StateVar >= 1.1.0.0 && < 1.2,+ StateVar >= 1.1.0.0 && < 1.3, text >= 1.1.0.0 && < 1.3, transformers >= 0.2 && < 0.6, vector >= 0.10.9.0 && < 0.13
src/SDL/Raw/Enum.hsc view
@@ -898,6 +898,7 @@ pattern SDL_WINDOW_FOREIGN, pattern SDL_WINDOW_ALLOW_HIGHDPI, pattern SDL_WINDOW_MOUSE_CAPTURE,+ pattern SDL_WINDOW_VULKAN, -- ** Window Positioning pattern SDL_WINDOWPOS_UNDEFINED,@@ -1767,6 +1768,7 @@ pattern SDL_WINDOW_FOREIGN = (#const SDL_WINDOW_FOREIGN) pattern SDL_WINDOW_ALLOW_HIGHDPI = (#const SDL_WINDOW_ALLOW_HIGHDPI) pattern SDL_WINDOW_MOUSE_CAPTURE = (#const SDL_WINDOW_MOUSE_CAPTURE)+pattern SDL_WINDOW_VULKAN = (#const SDL_WINDOW_VULKAN) pattern SDL_WINDOWPOS_UNDEFINED = (#const SDL_WINDOWPOS_UNDEFINED) pattern SDL_WINDOWPOS_CENTERED = (#const SDL_WINDOWPOS_CENTERED)
src/SDL/Raw/Types.hsc view
@@ -2,6 +2,8 @@ module SDL.Raw.Types ( -- * Type Aliases -- ** Function Types+ VkGetInstanceProcAddrFunc,+ AudioCallback, EventFilter, HintCallback,@@ -40,6 +42,8 @@ TimerID, TLSID, TouchID,+ VkInstance,+ VkSurfaceKHR, Window, -- * Data Structures@@ -81,6 +85,8 @@ import Foreign.Storable import SDL.Raw.Enum +type VkGetInstanceProcAddrFunc = VkInstance -> CString -> IO (FunPtr ())+ type AudioCallback = FunPtr (Ptr () -> Ptr Word8 -> CInt -> IO ()) type EventFilter = FunPtr (Ptr () -> Ptr Event -> IO CInt) type HintCallback = FunPtr (Ptr () -> CString -> CString -> CString -> IO ())@@ -140,6 +146,8 @@ type TimerID = CInt type TLSID = CUInt type TouchID = Int64+type VkInstance = Ptr ()+type VkSurfaceKHR = Word64 type Window = Ptr () data Atomic = Atomic
src/SDL/Raw/Video.hs view
@@ -195,7 +195,15 @@ -- * Clipboard Handling getClipboardText, hasClipboardText,- setClipboardText+ setClipboardText,++ -- * Vulkan support functions+ vkLoadLibrary,+ vkGetVkGetInstanceProcAddr,+ vkUnloadLibrary,+ vkGetInstanceExtensions,+ vkCreateSurface,+ vkGetDrawableSize ) where import Control.Monad.IO.Class@@ -396,6 +404,13 @@ foreign import ccall "SDL.h SDL_HasClipboardText" hasClipboardTextFFI :: IO Bool foreign import ccall "SDL.h SDL_SetClipboardText" setClipboardTextFFI :: CString -> IO CInt +foreign import ccall "SDL_vulkan.h SDL_Vulkan_LoadLibrary" vkLoadLibraryFFI :: CString -> IO CInt+foreign import ccall "SDL_vulkan.h SDL_Vulkan_GetVkGetInstanceProcAddr" vkGetVkGetInstanceProcAddrFFI :: IO (FunPtr VkGetInstanceProcAddrFunc)+foreign import ccall "SDL_vulkan.h SDL_Vulkan_UnloadLibrary" vkUnloadLibraryFFI :: IO ()+foreign import ccall "SDL_vulkan.h SDL_Vulkan_GetInstanceExtensions" vkGetInstanceExtensionsFFI :: Window -> Ptr CUInt -> Ptr CString -> IO Bool+foreign import ccall "SDL_vulkan.h SDL_Vulkan_CreateSurface" vkCreateSurfaceFFI :: Window -> VkInstance -> Ptr VkSurfaceKHR -> IO Bool+foreign import ccall "SDL_vulkan.h SDL_Vulkan_GetDrawableSize" vkGetDrawableSizeFFI :: Window -> Ptr CInt -> Ptr CInt -> IO ()+ createWindow :: MonadIO m => CString -> CInt -> CInt -> CInt -> CInt -> Word32 -> m Window createWindow v1 v2 v3 v4 v5 v6 = liftIO $ createWindowFFI v1 v2 v3 v4 v5 v6 {-# INLINE createWindow #-}@@ -1135,3 +1150,27 @@ setClipboardText :: MonadIO m => CString -> m CInt setClipboardText v1 = liftIO $ setClipboardTextFFI v1 {-# INLINE setClipboardText #-}++vkLoadLibrary :: MonadIO m => CString -> m CInt+vkLoadLibrary v1 = liftIO $ setClipboardTextFFI v1+{-# INLINE vkLoadLibrary #-}++vkGetVkGetInstanceProcAddr :: MonadIO m => m (FunPtr VkGetInstanceProcAddrFunc)+vkGetVkGetInstanceProcAddr = liftIO vkGetVkGetInstanceProcAddrFFI+{-# INLINE vkGetVkGetInstanceProcAddr #-}++vkUnloadLibrary :: MonadIO m => m ()+vkUnloadLibrary = liftIO vkUnloadLibraryFFI+{-# INLINE vkUnloadLibrary #-}++vkGetInstanceExtensions :: MonadIO m => Window -> Ptr CUInt -> Ptr CString -> m Bool+vkGetInstanceExtensions v1 v2 v3 = liftIO $ vkGetInstanceExtensionsFFI v1 v2 v3+{-# INLINE vkGetInstanceExtensions #-}++vkCreateSurface :: MonadIO m => Window -> VkInstance -> Ptr VkSurfaceKHR -> m Bool+vkCreateSurface v1 v2 v3 = liftIO $ vkCreateSurfaceFFI v1 v2 v3+{-# INLINE vkCreateSurface #-}++vkGetDrawableSize :: MonadIO m => Window -> Ptr CInt -> Ptr CInt -> m ()+vkGetDrawableSize v1 v2 v3 = liftIO $ vkGetDrawableSizeFFI v1 v2 v3+{-# INLINE vkGetDrawableSize #-}
src/SDL/Video.hs view
@@ -12,6 +12,7 @@ , createWindow , defaultWindow , WindowConfig(..)+ , WindowGraphicsContext(..) , WindowMode(..) , WindowPosition(..) , destroyWindow@@ -103,9 +104,9 @@ -- Throws 'SDLException' on failure. createWindow :: MonadIO m => Text -> WindowConfig -> m Window createWindow title config = liftIO $ do- case windowOpenGL config of- Just glcfg -> setGLAttributes glcfg- Nothing -> return ()+ case windowGraphicsContext config of+ OpenGLContext glcfg -> setGLAttributes glcfg+ _ -> return () BS.useAsCString (Text.encodeUtf8 title) $ \title' -> do let create = Raw.createWindow title'@@ -120,9 +121,10 @@ , if windowHighDPI config then Raw.SDL_WINDOW_ALLOW_HIGHDPI else 0 , if windowInputGrabbed config then Raw.SDL_WINDOW_INPUT_GRABBED else 0 , toNumber $ windowMode config- , if isJust $ windowOpenGL config then Raw.SDL_WINDOW_OPENGL else 0+ , if ctxIsOpenGL (windowGraphicsContext config) then Raw.SDL_WINDOW_OPENGL else 0 , if windowResizable config then Raw.SDL_WINDOW_RESIZABLE else 0 , if windowVisible config then 0 else Raw.SDL_WINDOW_HIDDEN+ , if windowGraphicsContext config == VulkanContext then Raw.SDL_WINDOW_VULKAN else 0 ] setGLAttributes (OpenGLConfig (V4 r g b a) d s ms p) = do let (msk, v0, v1, flg) = case p of@@ -152,42 +154,59 @@ -- -- @ -- 'defaultWindow' = 'WindowConfig'--- { 'windowBorder' = True--- , 'windowHighDPI' = False--- , 'windowInputGrabbed' = False--- , 'windowMode' = 'Windowed'--- , 'windowOpenGL' = Nothing--- , 'windowPosition' = 'Wherever'--- , 'windowResizable' = False--- , 'windowInitialSize' = V2 800 600--- , 'windowVisible' = True+-- { 'windowBorder' = True+-- , 'windowHighDPI' = False+-- , 'windowInputGrabbed' = False+-- , 'windowMode' = 'Windowed'+-- , 'windowGraphicsContext' = NoGraphicsContext+-- , 'windowPosition' = 'Wherever'+-- , 'windowResizable' = False+-- , 'windowInitialSize' = V2 800 600+-- , 'windowVisible' = True -- } -- @ defaultWindow :: WindowConfig defaultWindow = WindowConfig- { windowBorder = True- , windowHighDPI = False- , windowInputGrabbed = False- , windowMode = Windowed- , windowOpenGL = Nothing- , windowPosition = Wherever- , windowResizable = False- , windowInitialSize = V2 800 600- , windowVisible = True+ { windowBorder = True+ , windowHighDPI = False+ , windowInputGrabbed = False+ , windowMode = Windowed+ , windowGraphicsContext = NoGraphicsContext+ , windowPosition = Wherever+ , windowResizable = False+ , windowInitialSize = V2 800 600+ , windowVisible = True } data WindowConfig = WindowConfig- { windowBorder :: Bool -- ^ Defaults to 'True'.- , windowHighDPI :: Bool -- ^ Defaults to 'False'. Can not be changed after window creation.- , windowInputGrabbed :: Bool -- ^ Defaults to 'False'. Whether the mouse shall be confined to the window.- , windowMode :: WindowMode -- ^ Defaults to 'Windowed'.- , windowOpenGL :: Maybe OpenGLConfig -- ^ Defaults to 'Nothing'. Can not be changed after window creation.- , windowPosition :: WindowPosition -- ^ Defaults to 'Wherever'.- , windowResizable :: Bool -- ^ Defaults to 'False'. Whether the window can be resized by the user. It is still possible to programatically change the size by changing 'windowSize'.- , windowInitialSize :: V2 CInt -- ^ Defaults to @(800, 600)@. If you set 'windowHighDPI' flag, window size in screen coordinates may differ from the size in pixels. Use 'glGetDrawableSize' to get size in pixels.- , windowVisible :: Bool -- ^ Defaults to 'True'.+ { windowBorder :: Bool -- ^ Defaults to 'True'.+ , windowHighDPI :: Bool -- ^ Defaults to 'False'. Can not be changed after window creation.+ , windowInputGrabbed :: Bool -- ^ Defaults to 'False'. Whether the mouse shall be confined to the window.+ , windowMode :: WindowMode -- ^ Defaults to 'Windowed'.+ , windowGraphicsContext :: WindowGraphicsContext -- ^ Defaults to 'NoGraphicsContext'. Can not be changed after window creation.+ , windowPosition :: WindowPosition -- ^ Defaults to 'Wherever'.+ , windowResizable :: Bool -- ^ Defaults to 'False'. Whether the window can be resized by the user. It is still possible to programatically change the size by changing 'windowSize'.+ , windowInitialSize :: V2 CInt -- ^ Defaults to @(800, 600)@. If you set 'windowHighDPI' flag, window size in screen coordinates may differ from the size in pixels. Use 'glGetDrawableSize' or 'SDL.Video.Vulkan.vkGetDrawableSize' to get size in pixels.+ , windowVisible :: Bool -- ^ Defaults to 'True'. } deriving (Eq, Generic, Ord, Read, Show, Typeable) +-- | Configuration of additional graphics context that will be created for window.+--+-- Can not be changed after window creation.+data WindowGraphicsContext+ = NoGraphicsContext -- ^ Window will be created without any additional graphics context.+ | OpenGLContext OpenGLConfig -- ^ Window will be created with OpenGL support with parameters from 'OpenGLConfig'.+ | VulkanContext -- ^ Window will be created with Vulkan support.+ -- The following functions will be implicitly called by SDL C library:+ --+ -- 1. analogue of 'SDL.Video.Vulkan.vkLoadLibrary' 'Nothing' will be called automatically before first window creation;+ -- 2. analogue of 'SDL.Video.Vulkan.vkUnloadLibrary' will be called after last window destruction.+ deriving (Eq, Generic, Ord, Read, Show, Typeable)++ctxIsOpenGL :: WindowGraphicsContext -> Bool+ctxIsOpenGL (OpenGLContext _) = True+ctxIsOpenGL _ = False+ data WindowMode = Fullscreen -- ^ Real fullscreen with a video mode change | FullscreenDesktop -- ^ Fake fullscreen that takes the size of the desktop@@ -294,7 +313,8 @@ -- | Get or set the size of a window's client area. Values beyond the maximum supported size are clamped. ----- If window was created with 'windowHighDPI' flag, this size may differ from the size in pixels. Use 'glGetDrawableSize' to get size in pixels.+-- If window was created with 'windowHighDPI' flag, this size may differ from the size in pixels.+-- Use 'glGetDrawableSize' or 'SDL.Video.Vulkan.vkGetDrawableSize' to get size in pixels. -- -- This 'StateVar' can be modified using '$=' and the current value retrieved with 'get'. --@@ -339,7 +359,7 @@ -- | Retrieve the configuration of the given window. ----- Note that 'Nothing' will be returned instead of potential OpenGL parameters+-- Note that 'NoGraphicsContext' will be returned instead of potential OpenGL parameters -- used during the creation of the window. getWindowConfig :: MonadIO m => Window -> m WindowConfig getWindowConfig (Window w) = do@@ -349,16 +369,17 @@ wPos <- getWindowAbsolutePosition (Window w) return WindowConfig {- windowBorder = wFlags .&. Raw.SDL_WINDOW_BORDERLESS == 0- , windowHighDPI = wFlags .&. Raw.SDL_WINDOW_ALLOW_HIGHDPI > 0- , windowInputGrabbed = wFlags .&. Raw.SDL_WINDOW_INPUT_GRABBED > 0- , windowMode = fromNumber wFlags- -- Should we store the openGL config that was used to create the window?- , windowOpenGL = Nothing- , windowPosition = Absolute (P wPos)- , windowResizable = wFlags .&. Raw.SDL_WINDOW_RESIZABLE > 0- , windowInitialSize = wSize- , windowVisible = wFlags .&. Raw.SDL_WINDOW_SHOWN > 0+ windowBorder = wFlags .&. Raw.SDL_WINDOW_BORDERLESS == 0+ , windowHighDPI = wFlags .&. Raw.SDL_WINDOW_ALLOW_HIGHDPI > 0+ , windowInputGrabbed = wFlags .&. Raw.SDL_WINDOW_INPUT_GRABBED > 0+ , windowMode = fromNumber wFlags+ -- Should we store the OpenGL config that was used to create the window?+ , windowGraphicsContext = if wFlags .&. Raw.SDL_WINDOW_VULKAN > 0+ then VulkanContext else NoGraphicsContext+ , windowPosition = Absolute (P wPos)+ , windowResizable = wFlags .&. Raw.SDL_WINDOW_RESIZABLE > 0+ , windowInitialSize = wSize+ , windowVisible = wFlags .&. Raw.SDL_WINDOW_SHOWN > 0 } -- | Get the pixel format that is used for the given window.
+ src/SDL/Video/Vulkan.hs view
@@ -0,0 +1,110 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE LambdaCase #-}++module SDL.Video.Vulkan (+ -- * Vulkan types+ VkInstance, VkSurfaceKHR, VkGetInstanceProcAddrFunc,+ -- * Vulkan loader+ vkLoadLibrary, vkUnloadLibrary, vkGetVkGetInstanceProcAddr,+ -- * Vulkan surface+ vkGetInstanceExtensions, vkCreateSurface,+ -- * Querying for the drawable size+ vkGetDrawableSize+) where++import Control.Monad.IO.Class (MonadIO, liftIO)+import Foreign hiding (throwIf_, throwIfNeg_)+import Foreign.C.Types (CInt)+import Foreign.C.String (CString, withCString)+import SDL.Vect (V2 (V2))+import SDL.Internal.Exception (throwIf_, throwIfNeg_)+import SDL.Internal.Types (Window (Window))+import SDL.Raw.Types (VkInstance, VkSurfaceKHR, VkGetInstanceProcAddrFunc)+import qualified SDL.Raw as Raw++#if !MIN_VERSION_base(4,8,0)+import Control.Applicative+#endif++-- | Dynamically load a Vulkan loader library.+--+-- If a filePath is 'Nothing', SDL will use the value of the environment variable+-- SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan+-- loader library.+--+-- This function should be called after initializing the video driver+-- (i.e. 'SDL.Init.initialize' ['SDL.Init.InitVideo']), but before+-- creating any windows with 'SDL.Video.windowGraphicsContext' = 'SDL.Video.VulkanContext'.+--+-- If no Vulkan loader library is loaded, analogue of 'vkLoadLibrary' 'Nothing'+-- will be automatically called by SDL C library upon creation of the first Vulkan window.+--+-- Throws 'SDL.Exception.SDLException' if there are no working Vulkan drivers installed.+vkLoadLibrary :: MonadIO m => Maybe FilePath -> m ()+vkLoadLibrary = \case+ Nothing -> liftIO . testNeg $ Raw.vkLoadLibrary nullPtr+ Just filePath -> liftIO . withCString filePath $ testNeg . Raw.vkLoadLibrary+ where+ testNeg = throwIfNeg_ "SDL.Video.Vulkan.vkLoadLibrary" "SDL_Vulkan_LoadLibrary"++-- | Unload the Vulkan loader library previously loaded by 'vkLoadLibrary'.+--+-- Analogue of this function will be automatically called by SDL C library+-- after destruction of the last window with+-- 'SDL.Video.windowGraphicsContext' = 'SDL.Video.VulkanContext'.+vkUnloadLibrary :: MonadIO m => m ()+vkUnloadLibrary = Raw.vkUnloadLibrary++foreign import ccall "dynamic" mkVkGetInstanceProcAddrFunc ::+ FunPtr VkGetInstanceProcAddrFunc -> VkGetInstanceProcAddrFunc++-- | Get the vkGetInstanceProcAddr function, which can be used to obtain another Vulkan functions+-- (see <https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkGetInstanceProcAddr.html>).+--+-- The 'vkGetVkGetInstanceProcAddr' function should be called after either calling 'vkLoadLibrary'+-- function or creating first Vulkan window.+vkGetVkGetInstanceProcAddr :: (Functor m, MonadIO m) => m VkGetInstanceProcAddrFunc+vkGetVkGetInstanceProcAddr = mkVkGetInstanceProcAddrFunc <$> Raw.vkGetVkGetInstanceProcAddr++-- | Get the names of the Vulkan instance extensions needed to create+-- a surface with 'vkCreateSurface'.+--+-- The extension names queried here must be enabled when calling vkCreateInstance+-- (see <https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkCreateInstance.html>),+-- otherwise 'vkCreateSurface' will fail.+--+-- Window should have been created with 'SDL.Video.windowGraphicsContext' = 'SDL.Video.VulkanContext'.+--+-- Throws 'SDL.Exception.SDLException' on failure.+vkGetInstanceExtensions :: MonadIO m => Window -> m [CString]+vkGetInstanceExtensions (Window w) = liftIO . alloca $ \countPtr -> do+ throwIf_ not "SDL.Video.Vulkan.vkGetInstanceExtensions (1)" "SDL_Vulkan_GetInstanceExtensions" $+ Raw.vkGetInstanceExtensions w countPtr nullPtr+ count <- fromIntegral <$> peek countPtr+ allocaArray count $ \sPtr ->+ throwIf_ not "SDL.Video.Vulkan.vkGetInstanceExtensions (2)" "SDL_Vulkan_GetInstanceExtensions"+ (Raw.vkGetInstanceExtensions w countPtr sPtr) >> peekArray count sPtr++-- | Create a Vulkan rendering surface for a window.+--+-- Window should have been created with 'SDL.Video.windowGraphicsContext' = 'SDL.Video.VulkanContext'.+--+-- Instance should have been created with the extensions returned+-- by 'vkGetInstanceExtensions' enabled.+--+-- Throws 'SDL.Exception.SDLException' on failure.+vkCreateSurface :: MonadIO m => Window -> VkInstance -> m VkSurfaceKHR+vkCreateSurface (Window w) vkInstance = liftIO . alloca $ \vkSurfacePtr ->+ throwIf_ not "SDL.Video.Vulkan.vkCreateSurface" "SDL_Vulkan_CreateSurface"+ (Raw.vkCreateSurface w vkInstance vkSurfacePtr) >> peek vkSurfacePtr++-- | Get the size of a window's underlying drawable area in pixels (for use+-- with setting viewport, scissor & etc).+--+-- It may differ from 'SDL.Video.windowSize' if window was created with 'SDL.Video.windowHighDPI' flag.+vkGetDrawableSize :: MonadIO m => Window -> m (V2 CInt)+vkGetDrawableSize (Window w) = liftIO . alloca $ \wptr ->+ alloca $ \hptr -> do+ Raw.vkGetDrawableSize w wptr hptr+ V2 <$> peek wptr <*> peek hptr