sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Init.Unsafe

Synopsis

Documentation

sDL_Init Source #

Arguments

:: SDL_InitFlags
flags
subsystem initialization flags.
-> IO CBool 

Initialize the SDL library.

SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the two may be used interchangeably. Though for readability of your code SDL_InitSubSystem() might be preferred.

The file I/O (for example: SDL_IOFromFile) and threading (SDL_CreateThread) subsystems are initialized by default. Message boxes (SDL_ShowSimpleMessageBox) also attempt to work without initializing the video subsystem, in hopes of being useful in showing an error dialog when SDL_Init fails. You must specifically initialize other subsystems if you use them in your application.

Logging (such as SDL_Log) works without initialization, too.

flags may be any of the following OR'd together:

  • sDL_INIT_AUDIO: audio subsystem; automatically initializes the events subsystem
  • sDL_INIT_VIDEO: video subsystem; automatically initializes the events subsystem, should be initialized on the main thread.
  • sDL_INIT_JOYSTICK: joystick subsystem; automatically initializes the events subsystem
  • sDL_INIT_HAPTIC: haptic (force feedback) subsystem
  • sDL_INIT_GAMEPAD: gamepad subsystem; automatically initializes the joystick subsystem
  • sDL_INIT_EVENTS: events subsystem
  • sDL_INIT_SENSOR: sensor subsystem; automatically initializes the events subsystem
  • sDL_INIT_CAMERA: camera subsystem; automatically initializes the events subsystem

Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or call SDL_Quit() to force shutdown). If a subsystem is already loaded then this call will increase the ref-count and return.

Consider reporting some basic metadata about your application before calling SDL_Init, using either SDL_SetAppMetadata() or SDL_SetAppMetadataProperty().

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
This function should only be called on the main thread.
See also
sDL_SetAppMetadata, sDL_SetAppMetadataProperty, sDL_InitSubSystem, sDL_Quit, SDL_SetMainReady, sDL_WasInit
C declaration
SDL_Init, defined at SDL3/SDL_init.h 238:34

Since: 3.2.0

sDL_InitSubSystem Source #

Arguments

:: SDL_InitFlags
flags
any of the flags used by SDL_Init(); see SDL_Init for details.
-> IO CBool 

Compatibility function to initialize the SDL library.

This function and SDL_Init() are interchangeable.

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
This function should only be called on the main thread.
See also
sDL_Init, sDL_Quit, sDL_QuitSubSystem
C declaration
SDL_InitSubSystem, defined at SDL3/SDL_init.h 257:34

Since: 3.2.0

sDL_QuitSubSystem Source #

Arguments

:: SDL_InitFlags
flags
any of the flags used by SDL_Init(); see SDL_Init for details.
-> IO () 

Shut down specific SDL subsystems.

You still need to call SDL_Quit() even if you close all open subsystems with SDL_QuitSubSystem().

Thread safety
This function is not thread safe.
See also
sDL_InitSubSystem, sDL_Quit
C declaration
SDL_QuitSubSystem, defined at SDL3/SDL_init.h 274:34

Since: 3.2.0

sDL_WasInit Source #

Arguments

:: SDL_InitFlags
flags
any of the flags used by SDL_Init(); see SDL_Init for details.
-> IO SDL_InitFlags 

Get a mask of the specified subsystems which are currently initialized.

Returns
a mask of all initialized subsystems if flags is 0, otherwise it returns the initialization status of the specified subsystems.
Thread safety
This function is not thread safe.
See also
sDL_Init, sDL_InitSubSystem
C declaration
SDL_WasInit, defined at SDL3/SDL_init.h 290:43

Since: 3.2.0

sDL_Quit :: IO () Source #

Clean up all initialized subsystems.

You should call this function even if you have already shutdown each initialized subsystem with SDL_QuitSubSystem(). It is safe to call this function even in the case of errors in initialization.

You can use this function with atexit() to ensure that it is run when your application is shutdown, but it is not wise to do this from a library or other dynamically loaded code.

Thread safety
This function should only be called on the main thread.
See also
sDL_Init, sDL_QuitSubSystem
C declaration
SDL_Quit, defined at SDL3/SDL_init.h 310:34

Since: 3.2.0

sDL_IsMainThread :: IO CBool Source #

Return whether this is the main thread.

On Apple platforms, the main thread is the thread that runs your program's main() entry point. On other platforms, the main thread is the one that calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs your program's main() entry point. If you are using the main callbacks, SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the main thread.

Returns
true if this thread is the main thread, or false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_RunOnMainThread
C declaration
SDL_IsMainThread, defined at SDL3/SDL_init.h 330:34

Since: 3.2.0

sDL_RunOnMainThread Source #

Arguments

:: SDL_MainThreadCallback
callback
the callback to call on the main thread.
-> Ptr Void
userdata
a pointer that is passed to callback.
-> CBool
wait_complete
true to wait for the callback to complete, false to return immediately.
-> IO CBool 

Call a function on the main thread during event processing.

If this is called on the main thread, the callback is executed immediately. If this is called on another thread, this callback is queued for execution on the main thread during event processing.

Be careful of deadlocks when using this functionality. You should not have the main thread wait for the current thread while this function is being called with wait_complete true.

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_IsMainThread
C declaration
SDL_RunOnMainThread, defined at SDL3/SDL_init.h 367:34

Since: 3.2.0

sDL_SetAppMetadata Source #

Arguments

:: PtrConst CChar
appname
The name of the application ("My Game 2: Bad Guy's Revenge!").
-> PtrConst CChar
appversion
The version of the application ("1.0.0beta5" or a git hash, or whatever makes sense).
-> PtrConst CChar
appidentifier
A unique string in reverse-domain format that identifies this app ("com.example.mygame2").
-> IO CBool 

Specify basic metadata about your app.

You can optionally provide metadata about your app to SDL. This is not required, but strongly encouraged.

There are several locations where SDL can make use of metadata (an "About" box in the macOS menu bar, the name of the app can be shown on some audio mixers, etc). Any piece of metadata can be left as NULL, if a specific detail doesn't make sense for the app.

This function should be called as early as possible, before SDL_Init. Multiple calls to this function are allowed, but various state might not change once it has been set up with a previous call to this function.

Passing a NULL removes any previous metadata.

This is a simplified interface for the most important information. You can supply significantly more detailed metadata with SDL_SetAppMetadataProperty().

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_SetAppMetadataProperty
C declaration
SDL_SetAppMetadata, defined at SDL3/SDL_init.h 405:34

Since: 3.2.0

sDL_SetAppMetadataProperty Source #

Arguments

:: PtrConst CChar
name
the name of the metadata property to set.
-> PtrConst CChar
value
the value of the property, or NULL to remove that property.
-> IO CBool 

Specify metadata about your app through a set of properties.

You can optionally provide metadata about your app to SDL. This is not required, but strongly encouraged.

There are several locations where SDL can make use of metadata (an "About" box in the macOS menu bar, the name of the app can be shown on some audio mixers, etc). Any piece of metadata can be left out, if a specific detail doesn't make sense for the app.

This function should be called as early as possible, before SDL_Init. Multiple calls to this function are allowed, but various state might not change once it has been set up with a previous call to this function.

Once set, this metadata can be read using SDL_GetAppMetadataProperty().

These are the supported properties:

  • sDL_PROP_APP_METADATA_NAME_STRING: The human-readable name of the application, like "My Game 2: Bad Guy's Revenge!". This will show up anywhere the OS shows the name of the application separately from window titles, such as volume control applets, etc. If not provided by the app, SDL will attempt to pick a reasonable default (the app's binary's name if the platform can provide it, or "SDL Application" if all else fails).
  • sDL_PROP_APP_METADATA_VERSION_STRING: The version of the app that is running; there are no rules on format, so "1.0.3beta2" and "April 22nd, 2024" and a git hash are all valid options. This has no default.
  • sDL_PROP_APP_METADATA_IDENTIFIER_STRING: A unique string that identifies this app. This must be in reverse-domain format, like "com.example.mygame2". This string is used by desktop compositors to identify and group windows together, as well as match applications with associated desktop settings and icons. If you plan to package your application in a container such as Flatpak, the app ID should match the name of your Flatpak container as well. This has no default.
  • sDL_PROP_APP_METADATA_CREATOR_STRING: The human-readable name of the creator/developer/maker of this app, like "MojoWorkshop, LLC"
  • sDL_PROP_APP_METADATA_COPYRIGHT_STRING: The human-readable copyright notice, like "Copyright (c) 2024 MojoWorkshop, LLC" or whatnot. Keep this to one line, don't paste a copy of a whole software license in here. This has no default.
  • sDL_PROP_APP_METADATA_URL_STRING: A URL to the app on the web. Maybe a product page, or a storefront, or even a GitHub repository, for user's further information This has no default.
  • sDL_PROP_APP_METADATA_TYPE_STRING: The type of application this is. Currently this string can be "game" for a video game, "mediaplayer" for a media player, or generically "application" if nothing else applies. Future versions of SDL might add new types. This defaults to "application".
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetAppMetadataProperty, sDL_SetAppMetadata
C declaration
SDL_SetAppMetadataProperty, defined at SDL3/SDL_init.h 469:34

Since: 3.2.0

sDL_GetAppMetadataProperty Source #

Arguments

:: PtrConst CChar
name
the name of the metadata property to get.
-> IO (PtrConst CChar) 

Get metadata about your app.

This returns metadata previously set using SDL_SetAppMetadata() or SDL_SetAppMetadataProperty(). See SDL_SetAppMetadataProperty() for the list of available properties and their meanings.

Returns
the current value of the metadata property, or the default if it is not set, NULL for properties with no default.
Thread safety
It is safe to call this function from any thread, although the string returned is not protected and could potentially be freed if you call SDL_SetAppMetadataProperty() to set that property from another thread.
See also
sDL_SetAppMetadata, sDL_SetAppMetadataProperty
C declaration
SDL_GetAppMetadataProperty, defined at SDL3/SDL_init.h 500:42

Since: 3.2.0