-
Notifications
You must be signed in to change notification settings - Fork 29
API SDL
Core SDL3 wrapper functions and nested helper surfaces.
- Functions: 1405
- Functions with XML docs: 1396
public static IntPtr AcquireCameraFrame(IntPtr camera, out ulong timestampNS);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS);
Acquire a frame.
The frame is a memory pointer to the image data, whose size and format are given by the spec requested when opening the device.
This is a non blocking API. If there is a frame available, a non-null surface is returned, and timestampNS will be filled with a non-zero value.
Note that an error case can also return null, but a null by itself is normal and just signifies that a new frame is not yet available. Note that even if a camera device fails outright (a USB camera is unplugged while in use, etc), SDL will send an event separately to notify the app, but continue to provide blank frames at ongoing intervals until SDL.CloseCamera is called, so real failure here is almost always an out of memory condition.
After use, the frame should be released with SDL.ReleaseCameraFrame. If you don't do this, the system may stop providing more video!
Do not call SDL.DestroySurface on the returned surface! It must be given back to the camera subsystem with SDL.ReleaseCameraFrame!
If the system is waiting for the user to approve access to the camera, as some platforms require, this will return null (no frames available); you should either wait for an SDL.EventType.CameraDeviceApproved (or SDL.EventType.CameraDeviceDenied) event, or poll SDL.GetCameraPermissionState occasionally until it returns non-zero.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
opened camera device. |
timestampNS |
out ulong |
a pointer filled in with the frame's timestamp, or 0 on error. Can be null. |
Returns
a new frame of video on success, null if none is currently available.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AcquireCameraFrame(System.IntPtr,System.UInt64@)
public static IntPtr AcquireGPUCommandBuffer(IntPtr device);SDL declaration
extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer(SDL_GPUDevice *device);
Acquire a command buffer.
This command buffer is managed by the implementation and should not be freed by the user. The command buffer may only be used on the thread it was acquired on. The command buffer should be submitted on the thread it was acquired on.
It is valid to acquire multiple command buffers on the same thread at once. In fact a common design pattern is to acquire two command buffers per frame where one is dedicated to render and compute passes and the other is dedicated to copy passes and other preparatory work such as generating mipmaps. Interleaving commands between the two command buffers reduces the total amount of passes overall which improves rendering performance.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context. |
Returns
a command buffer, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AcquireGPUCommandBuffer(System.IntPtr)
public static bool AcquireGPUSwapchainTexture(IntPtr commandBuffer, IntPtr window, out IntPtr swapchainTexture, out uint swapchainTextureWidth, out uint swapchainTextureHeight);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, SDL_GPUTexture **swapchain_texture, Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height);
Acquire a texture to use in presentation.
When a swapchain texture is acquired on a command buffer, it will automatically be submitted for presentation when the command buffer is submitted. The swapchain texture should only be referenced by the command buffer used to acquire it.
If too many frames are in flight, this function will fill the swapchain texture handle with null and return true. This is not an error. This null pointer should not be passed back into SDL. Instead, it should be considered as an indication to wait.
In VSYNC present mode (which is the default) this function may block on vblank.
If you use this function, it is possible to create a situation where many command buffers are allocated while the rendering context waits for the GPU to catch up, which will cause memory usage to grow. You should use SDL.WaitAndAcquireGPUSwapchainTexture unless you know what you are doing with timing.
The swapchain texture is managed by the implementation and must not be freed by the user. You MUST NOT call this function from any thread other than the one that created the window.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
window |
IntPtr |
a window that has been claimed. |
swapchainTexture |
out IntPtr |
a pointer filled in with a swapchain texture handle. |
swapchainTextureWidth |
out uint |
a pointer filled in with the swapchain texture width, may be null. |
swapchainTextureHeight |
out uint |
a pointer filled in with the swapchain texture height, may be null. |
Returns
true on success, false on error; call SDL.GetError for more information.
Thread safety
This function should only be called from the thread that created the window.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AcquireGPUSwapchainTexture(System.IntPtr,System.IntPtr,System.IntPtr@,System.UInt32@,System.UInt32@)
public static int AddAtomicInt(ref SDL.AtomicInt a, int v);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_AddAtomicInt(SDL_AtomicInt *a, int v);
Add to an atomic variable.
This function also acts as a full memory barrier.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicInt |
a pointer to an SDL_AtomicInt variable to be modified. |
v |
int |
the desired value to add. |
Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddAtomicInt(SDL3.SDL.AtomicInt@,System.Int32)
public static uint AddAtomicU32(ref SDL.AtomicU32 a, int v);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL SDL_AddAtomicU32(SDL_AtomicU32 *a, int v);
Add to an atomic variable.
This function also acts as a full memory barrier.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicU32 |
a pointer to an SDL.AtomicU32 variable to be modified. |
v |
int |
the desired value to add or subtract. |
Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.AddAtomicU32(SDL3.SDL.AtomicU32@,System.Int32)
public static bool AddEventWatch(SDL.EventFilter filter, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata);
Add a callback to be triggered when an event is added to the event queue.
filter will be called when an event happens, and its return value is ignored.
WARNING: Be very careful of what you do in the event filter function, as it may run in a different thread!
If the quit event is generated by a signal (e.g. SIGINT), it will bypass the internal queue and be delivered to the watch callback immediately, and arrive at the next event poll.
Note: the callback is called for events posted by the user through SDL.PushEvent, but not for disabled events, nor for events by a filter callback set with SDL.SetEventFilter, nor for events posted by the user through SDL.PeepEvents.
Parameters
| Name | Type | Description |
|---|---|---|
filter |
SDL.EventFilter |
an SDL.EventFilter function to call when an event happens. |
userdata |
IntPtr |
a pointer that is passed to filter. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddEventWatch(SDL3.SDL.EventFilter,System.IntPtr)
public static int AddGamepadMapping(string mapping);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
Add support for gamepads that SDL is unaware of or change the binding of an existing gamepad.
The mapping string has the format "GUID,name,mapping", where GUID is the string value from SDL.GUIDToString, name is the human readable string for the device and mappings are gamepad mappings to joystick ones. Under Windows there is a reserved GUID of "xinput" that covers all XInput devices. The mapping format for joystick is:
-
bX: a joystick button, index X -
hX.Y: hat X with value Y -
aX: axis X of the joystick Buttons can be used as a gamepad axes and vice versa.
If a device with this GUID is already plugged in, SDL will generate an SDL.EventType.GamepadAdded event.
This string shows an example of a valid mapping for a gamepad:
c "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
Parameters
| Name | Type | Description |
|---|---|---|
mapping |
string |
the mapping string. |
Returns
1 if a new mapping is added, 0 if an existing mapping is updated, -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddGamepadMapping(System.String)
public static int AddGamepadMappingsFromFile(string file);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
Load a set of gamepad mappings from a file.
You can call this function several times, if needed, to load different database files.
If a new mapping is loaded for an already known gamepad GUID, the later version will overwrite the one currently loaded.
Any new mappings for already plugged in controllers will generate SDL.EventType.GamepadAdded events.
Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).
Parameters
| Name | Type | Description |
|---|---|---|
file |
string |
the mappings file to load. |
Returns
the number of mappings added or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddGamepadMappingsFromFile(System.String)
public static int AddGamepadMappingsFromIO(IntPtr src, bool closeio);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio);
Load a set of gamepad mappings from an SDL_IOStream.
You can call this function several times, if needed, to load different database files.
If a new mapping is loaded for an already known gamepad GUID, the later version will overwrite the one currently loaded.
Any new mappings for already plugged in controllers will generate SDL.EventType.GamepadAdded events.
Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).
This function will load the text database entirely in memory before processing it, so take this into consideration if you are in a memory constrained environment.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the data stream for the mappings to be added. |
closeio |
bool |
if true, calls SDL.CloseIO on src before returning, even in the case of an error. |
Returns
the number of mappings added or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddGamepadMappingsFromIO(System.IntPtr,System.Boolean)
public static int AddHintCallback(string name, SDL.HintCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata);
Add a function to watch a particular hint.
The callback function is called during this function, to provide it an initial value, and again each time the hint's value changes.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
the hint to watch. |
callback |
SDL.HintCallback |
An SDL.HintCallback function that will be called when the hint value changes. |
userdata |
IntPtr |
a pointer to pass to the callback function. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddHintCallback(System.String,SDL3.SDL.HintCallback,System.IntPtr)
public static bool AddSurfaceAlternateImage(IntPtr surface, IntPtr image);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image);
Add an alternate version of a surface.
This function adds an alternate version of this surface, usually used for content with high DPI representations like cursors or icons. The size, format, and content do not need to match the original surface, and these alternate versions will not be updated when the original surface changes.
This function adds a reference to the alternate version, so you should call SDL.DestroySurface on the image after this call.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the SDL.Surface structure to update. |
image |
IntPtr |
a pointer to an alternate SDL.Surface to associate with this surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddSurfaceAlternateImage(System.IntPtr,System.IntPtr)
public static uint AddTimer(uint interval, SDL.TimerCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *userdata);
Call a callback function at a future time.
The callback function is passed the current timer interval and the user supplied parameter from the SDL.AddTimer call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed.
The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns.
Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ms to execute and returned 1000 (ms), the timer would only wait another 750 ms before its next iteration.
Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL.GetTicksNS or SDL.GetPerformanceCounter in case your callback needs to adjust for variances.
Parameters
| Name | Type | Description |
|---|---|---|
interval |
uint |
the timer delay, in milliseconds, passed to callback. |
callback |
SDL.TimerCallback |
the SDL.TimerCallback function to call when the specified interval elapses. |
userdata |
IntPtr |
a pointer that is passed to callback. |
Returns
a timer ID or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddTimer(System.UInt32,SDL3.SDL.TimerCallback,System.IntPtr)
public static uint AddTimerNS(ulong interval, SDL.NSTimerCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimerNS(Uint64 interval, SDL_NSTimerCallback callback, void *userdata);
Call a callback function at a future time.
The callback function is passed the current timer interval and the user supplied parameter from the SDL.AddTimerNS call and should return the next timer interval. If the value returned from the callback is 0, the timer is canceled and will be removed.
The callback is run on a separate thread, and for short timeouts can potentially be called before this function returns.
Timers take into account the amount of time it took to execute the callback. For example, if the callback took 250 ns to execute and returned 1000 (ns), the timer would only wait another 750 ns before its next iteration.
Timing may be inexact due to OS scheduling. Be sure to note the current time with SDL.GetTicksNS or SDL.GetPerformanceCounter in case your callback needs to adjust for variances.
Parameters
| Name | Type | Description |
|---|---|---|
interval |
ulong |
the timer delay, in nanoseconds, passed to callback. |
callback |
SDL.NSTimerCallback |
the SDL.TimerCallback function to call when the specified interval elapses. |
userdata |
IntPtr |
a pointer that is passed to callback. |
Returns
a timer ID or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddTimerNS(System.UInt64,SDL3.SDL.NSTimerCallback,System.IntPtr)
public static bool AddVulkanRenderSemaphores(IntPtr renderer, uint waitStageMasl, long waitSemaphore, long signalSemaphore);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
Add a set of synchronization semaphores for the current frame.
The Vulkan renderer will wait for waitSemaphore before submitting rendering commands and signal signalSemaphore after rendering commands are complete for this frame.
This should be called each frame that you want semaphore synchronization. The Vulkan renderer may have multiple frames in flight on the GPU, so you should have multiple semaphores that are used for synchronization. Querying SDL.Props.RendererVulkanSwapchainImageCountNumber will give you the maximum number of semaphores you'll need.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
waitStageMasl |
uint |
the VkPipelineStageFlags for the wait. |
waitSemaphore |
long |
a VkSempahore to wait on before rendering the current frame, or 0 if not needed. |
signalSemaphore |
long |
a VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
It is NOT safe to call this function from two threads at once.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AddVulkanRenderSemaphores(System.IntPtr,System.UInt32,System.Int64,System.Int64)
public static IntPtr AlignedAlloc(UIntPtr alignment, UIntPtr size);SDL declaration
extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_aligned_alloc(size_t alignment, size_t size);
Allocate memory aligned to a specific alignment.
The memory returned by this function must be freed with SDL.AlignedFree, not SDL.Free.
If alignment is less than the size of void *, it will be increased to match that.
The returned memory address will be a multiple of the alignment value, and the size of the memory allocated will be a multiple of the alignment value.
Parameters
| Name | Type | Description |
|---|---|---|
alignment |
UIntPtr |
the alignment of the memory. |
size |
UIntPtr |
the size to allocate. |
Returns
a pointer to the aligned memory, or null if allocation failed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AlignedAlloc(System.UIntPtr,System.UIntPtr)
public static void AlignedFree(IntPtr mem);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_aligned_free(void *mem);
Free memory allocated by SDL.AlignedAlloc.
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is null, this function does nothing.
Parameters
| Name | Type | Description |
|---|---|---|
mem |
IntPtr |
a pointer previously returned by SDL.AlignedAlloc, or null. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AlignedFree(System.IntPtr)
public static SDL.AppResult AppEvent(IntPtr appstate, ref SDL.Event event);XML documentation is not available for this function.
XML member id: M:SDL3.SDL.AppEvent(System.IntPtr,SDL3.SDL.Event@)
public static SDL.AppResult AppInit(IntPtr appstate, int argc, string[] argv);SDL declaration
extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]);
App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps.
Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a standard "main" function, you should not supply this.
This function is called by SDL once, at startup. The function should initialize whatever is necessary, possibly create windows and open audio devices, etc. The argc and argv parameters work like they would with a standard "main" function.
This function should not go into an infinite mainloop; it should do any one-time setup it requires and then return.
The app may optionally assign a pointer to appstate. This pointer will be provided on every future call to the other entry points, to allow application state to be preserved between functions without the app needing to use a global variable. If this isn't set, the pointer will be null in future entry points.
If this function returns SDL.AppResult.Continue, the app will proceed to normal operation, and will begin receiving repeated calls to SDL.AppIterate and SDL.AppEvent for the life of the program. If this function returns SDL.AppResult.Failure, SDL will call SDL.AppQuit and terminate the process with an exit code that reports an error to the platform. If it returns SDL.AppResult.Success, SDL calls SDL.AppQuit and terminates with an exit code that reports success to the platform.
This function is called by SDL on the main thread.
Parameters
| Name | Type | Description |
|---|---|---|
appstate |
IntPtr |
a place where the app can optionally store a pointer for future use. |
argc |
int |
the standard ANSI C main's argc; number of elements in argv. |
argv |
string[] |
the standard ANSI C main's argv; array of command line arguments. |
Returns
SDL.AppResult.Failure to terminate with an error, SDL.AppResult.Success to terminate with success, SDL.AppResult.Continue to continue.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AppInit(System.IntPtr,System.Int32,System.String[])
public static SDL.AppResult AppIterate(IntPtr appstate);SDL declaration
extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate);
App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps.
Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a standard "main" function, you should not supply this.
This function is called repeatedly by SDL after SDL.AppInit returns 0. The function should operate as a single iteration the program's primary loop; it should update whatever state it needs and draw a new frame of video, usually.
On some platforms, this function will be called at the refresh rate of the display (which might change during the life of your app!). There are no promises made about what frequency this function might run at. You should use SDL's timer functions if you need to see how much time has passed since the last iteration.
There is no need to process the SDL event queue during this function; SDL will send events as they arrive in SDL.AppEvent, and in most cases the event queue will be empty when this function runs anyhow.
This function should not go into an infinite mainloop; it should do one iteration of whatever the program does and return.
The appstate parameter is an optional pointer provided by the app during SDL.AppInit. If the app never provided a pointer, this will be null.
If this function returns SDL.AppResult.Continue, the app will continue normal operation, receiving repeated calls to SDL.AppIterate and SDL_AppEvent for the life of the program. If this function returns SDL.AppResult.Failure, SDL will call SDL.AppQuit and terminate the process with an exit code that reports an error to the platform. If it returns SDL.AppResult.Success, SDL calls SDL.AppQuit and terminates with an exit code that reports success to the platform.
This function is called by SDL on the main thread.
Parameters
| Name | Type | Description |
|---|---|---|
appstate |
IntPtr |
an optional pointer, provided by the app in SDL.AppInit. |
Returns
SDL.AppResult.Failure to terminate with an error, SDL.AppResult.Success to terminate with success, SDL.AppResult.Continue to continue.
Thread safety
This function may get called concurrently with SDL.AppEvent for events not pushed on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AppIterate(System.IntPtr)
public static void AppQuit(IntPtr appstate, SDL.AppResult result);SDL declaration
extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate, SDL_AppResult result);
App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps.
Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a standard "main" function, you should not supply this.
This function is called once by SDL before terminating the program.
This function will be called in all cases, even if SDL.AppInit requests termination at startup.
This function should not go into an infinite mainloop; it should deinitialize any resources necessary, perform whatever shutdown activities, and return.
You do not need to call SDL.Quit in this function, as SDL will call it after this function returns and before the process terminates, but it is safe to do so.
The appstate parameter is an optional pointer provided by the app during SDL.AppInit. If the app never provided a pointer, this will be null. This function call is the last time this pointer will be provided, so any resources to it should be cleaned up here.
This function is called by SDL on the main thread.
Parameters
| Name | Type | Description |
|---|---|---|
appstate |
IntPtr |
an optional pointer, provided by the app in SDL.AppInit. |
result |
SDL.AppResult |
the result code that terminated the app (success or failure). |
Thread safety
SDL.AppEvent may get called concurrently with this function if other threads that push events are still active.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AppQuit(System.IntPtr,SDL3.SDL.AppResult)
public static System.IO.Stream AsStream(IntPtr io, bool leaveOpen);Wraps an existing SDL_IOStream as a managed System.IO.Stream. This is useful when SDL returns an SDL_IOStream and you want to consume it using standard .NET stream APIs.
Parameters
| Name | Type | Description |
|---|---|---|
io |
IntPtr |
A pointer to an existing SDL_IOStream. |
leaveOpen |
bool |
If true, the underlying SDL_IOStream will not be closed when the returned managed stream is disposed. |
Returns
A managed stream wrapper over the provided SDL_IOStream.
XML member id: M:SDL3.SDL.AsStream(System.IntPtr,System.Boolean)
public static IntPtr AsyncIOFromFile(string file, string mode);SDL declaration
extern SDL_DECLSPEC SDL_AsyncIO * SDLCALL SDL_AsyncIOFromFile(const char *file, const char *mode);
Use this function to create a new SDL_AsyncIO object for reading from and/or writing to a named file.
The mode string understands the following values:
- "r": Open a file for reading only. It must exist.
- "w": Open a file for writing only. It will create missing files or truncate existing ones.
- "r+": Open a file for update both reading and writing. The file must exist.
- "w+": Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file. There is no "b" mode, as there is only "binary" style I/O, and no "a" mode for appending, since you specify the position when starting a task.
This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.
This call is not asynchronous; it will open the file before returning, under the assumption that doing so is generally a fast operation. Future reads and writes to the opened file will be async, however.
Parameters
| Name | Type | Description |
|---|---|---|
file |
string |
a UTF-8 string representing the filename to open. |
mode |
string |
an ASCII string representing the mode to be used for opening the file. |
Returns
a pointer to the SDL_AsyncIO structure that is created or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0.
XML member id: M:SDL3.SDL.AsyncIOFromFile(System.String,System.String)
public static bool AtomicDecRef(ref SDL.AtomicInt a);SDL declaration
#define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1)
Decrement an atomic variable used as a reference count.
Note: If you don't know what this macro is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicInt |
a pointer to an SDL.AtomicInt to increment. |
Returns
true if the variable reached zero after decrementing, false otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AtomicDecRef(SDL3.SDL.AtomicInt@)
public static int AtomicIncRef(ref SDL.AtomicInt a);SDL declaration
#define SDL_AtomicIncRef(a) SDL_AddAtomicInt(a, 1)
Increment an atomic variable used as a reference count.
Note: If you don't know what this macro is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicInt |
a pointer to an SDL_AtomicInt to increment. |
Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AtomicIncRef(SDL3.SDL.AtomicInt@)
public static uint AttachVirtualJoystick(in SDL.VirtualJoystickDesc desc);SDL declaration
extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc);
Attach a new virtual joystick. Apps can create virtual joysticks, that exist without hardware directly backing them, and have program-supplied inputs. Once attached, a virtual joystick looks like any other joystick that SDL can access. These can be used to make other things look like joysticks, or provide pre-recorded input, etc.
Once attached, the app can send joystick inputs to the new virtual joystick using SDL.SetJoystickVirtualAxis, etc.
When no longer needed, the virtual joystick can be removed by calling SDL.DetachVirtualJoystick.
Parameters
| Name | Type | Description |
|---|---|---|
desc |
in SDL.VirtualJoystickDesc |
joystick description, initialized using SDL.InitInterface. |
Returns
the joystick instance ID, or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AttachVirtualJoystick(SDL3.SDL.VirtualJoystickDesc@)
public static uint AudioBitSize(uint x);Retrieve the size, in bits, from an SDL.AudioFormat.
For example, AudioBitSize(AudioFormat.AudioS16) returns 16.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
data size in bits.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioBitSize(System.UInt32)
public static uint AudioByteSize(uint x);Retrieve the size, in bytes, from an SDL.AudioFormat.
For example, AudioByteSize(AudioFormat.AudioS16) returns 2.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
data size in bytes.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioByteSize(System.UInt32)
public static bool AudioDevicePaused(uint devid);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AudioDevicePaused(SDL_AudioDeviceID dev);
Use this function to query if an audio device is paused.
Unlike in SDL2, audio devices start in an unpaused state, since an app has to bind a stream before any audio will flow.
Physical devices can not be paused or unpaused, only logical devices created through SDL.OpenAudioDevice can be. Physical and invalid device IDs will report themselves as unpaused here.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
a device opened by SDL.OpenAudioDevice. |
Returns
true if device is valid and paused, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioDevicePaused(System.UInt32)
public static uint AudioFrameSize(SDL.AudioSpec x);Calculate the size of each audio frame (in bytes) from an SDL.AudioSpec.
This reports on the size of an audio sample frame: stereo Sint16 data (2 channels of 2 bytes each) would be 4 bytes per frame, for example.
Parameters
| Name | Type | Description |
|---|---|---|
x |
SDL.AudioSpec |
an SDL.AudioSpec to query. |
Returns
the number of bytes used per sample frame.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioFrameSize(SDL3.SDL.AudioSpec)
public static bool AudioIsBigEndian(uint x);Determine if an SDL.AudioFormat represents bigendian data.
For example, AudioIsBitEndian(AudioFormat.AudioS16LE) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is bigendian, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsBigEndian(System.UInt32)
public static bool AudioIsFloat(uint x);Determine if an SDL.AudioFormat represents floating point data.
For example, AudioIsFloat(AudioFormat.AudioS16) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is floating point, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsFloat(System.UInt32)
public static bool AudioIsInt(uint x);Determine if an SDL.AudioFormat represents integer data.
For example, AudioIsInt(AudioFormat.AudioF32) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is integer, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsInt(System.UInt32)
public static bool AudioIsLittleEndian(uint x);Determine if an SDL.AudioFormat represents littleendian data.
For example, AudioIsLittleEndian(AudioFormat.AudioS16BE) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is littleendian, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsLittleEndian(System.UInt32)
public static bool AudioIsSigned(uint x);Determine if an SDL.AudioFormat represents signed data.
For example, AudioIsSigned(AudioFormat.AudioU8) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is signed, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsSigned(System.UInt32)
public static bool AudioIsUnsigned(uint x);Determine if an SDL.AudioFormat represents unsigned data.
For example, AudioIsUnsigned(AudioFormat.AudioS16) returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
x |
uint |
an SDL.AudioFormat value. |
Returns
non-zero if format is unsigned, zero otherwise.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.AudioIsUnsigned(System.UInt32)
public static bool AudioStreamDevicePaused(IntPtr stream);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_AudioStreamDevicePaused(SDL_AudioStream *stream);
Use this function to query if an audio device associated with a stream is paused.
Unlike in SDL2, audio devices start in an unpaused state, since an app has to bind a stream before any audio will flow.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream associated with the audio device to query. |
Returns
true if device is valid and paused, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.10.
XML member id: M:SDL3.SDL.AudioStreamDevicePaused(System.IntPtr)
public static IntPtr BeginGPUComputePass(IntPtr commandBuffer, IntPtr storageTextureBindings, uint numStorageTextureBindings, IntPtr storageBufferBindings, uint numStorageBufferBindings);XML documentation is not available for this function.
XML member id: M:SDL3.SDL.BeginGPUComputePass(System.IntPtr,System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static IntPtr BeginGPUComputePass(IntPtr commandBuffer, ReadOnlySpan<SDL.GPUStorageTextureReadWriteBinding> storageTextureBindings, uint numStorageTextureBindings, ReadOnlySpan<SDL.GPUStorageBufferReadWriteBinding> storageBufferBindings, uint numStorageBufferBindings);Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
|
storageTextureBindings |
ReadOnlySpan<SDL.GPUStorageTextureReadWriteBinding> |
|
numStorageTextureBindings |
uint |
|
storageBufferBindings |
ReadOnlySpan<SDL.GPUStorageBufferReadWriteBinding> |
|
numStorageBufferBindings |
uint |
XML member id: M:SDL3.SDL.BeginGPUComputePass(System.IntPtr,System.ReadOnlySpan{SDL3.SDL.GPUStorageTextureReadWriteBinding},System.UInt32,System.ReadOnlySpan{SDL3.SDL.GPUStorageBufferReadWriteBinding},System.UInt32)
public static IntPtr BeginGPUComputePass(IntPtr commandBuffer, SDL.GPUStorageTextureReadWriteBinding[] storageTextureBindings, uint numStorageTextureBindings, SDL.GPUStorageBufferReadWriteBinding[] storageBufferBindings, uint numStorageBufferBindings);SDL declaration
extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings, Uint32 num_storage_texture_bindings, const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings, Uint32 num_storage_buffer_bindings);
Begins a compute pass on a command buffer.
A compute pass is defined by a set of texture subresources and buffers that may be written to by compute pipelines. These textures and buffers must have been created with the SDL.GPUTextureUsageFlags.ComputeStorageWrite bit or the SDL.GPUTextureUsageFlags.ComputeStorageSimultaneousReadWrite bit. If you do not create a texture with SDL.GPUTextureUsageFlags.ComputeStorageSimultaneousReadWrite, you must not read from the texture in the compute pass. All operations related to compute pipelines must take place inside of a compute pass. You must not begin another compute pass, or a render pass or copy pass before ending the compute pass.
A VERY IMPORTANT NOTE - Reads and writes in compute passes are NOT implicitly synchronized. This means you may cause data races by both reading and writing a resource region in a compute pass, or by writing multiple times to a resource region. If your compute work depends on reading the completed output from a previous dispatch, you MUST end the current compute pass and begin a new one before you can safely access the data. Otherwise you will receive unexpected results. Reading and writing a texture in the same compute pass is only supported by specific texture formats. Make sure you check the format support!
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
storageTextureBindings |
SDL.GPUStorageTextureReadWriteBinding[] |
an array of writeable storage texture binding structs. |
numStorageTextureBindings |
uint |
the number of storage textures to bind from the array. |
storageBufferBindings |
SDL.GPUStorageBufferReadWriteBinding[] |
an array of writeable storage buffer binding structs. |
numStorageBufferBindings |
uint |
the number of storage buffers to bind from the array. |
Returns
a compute pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPUComputePass(System.IntPtr,SDL3.SDL.GPUStorageTextureReadWriteBinding[],System.UInt32,SDL3.SDL.GPUStorageBufferReadWriteBinding[],System.UInt32)
public static IntPtr BeginGPUCopyPass(IntPtr commandBuffer);SDL declaration
extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass(SDL_GPUCommandBuffer *command_buffer);
Begins a copy pass on a command buffer.
All operations related to copying to or from buffers or textures take place inside a copy pass. You must not begin another copy pass, or a render pass or compute pass before ending the copy pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
Returns
a copy pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPUCopyPass(System.IntPtr)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, in SDL.GPUColorTargetInfo[] colorTargetInfos, uint numColorTargets, in SDL.GPUDepthStencilTargetInfo depthStencilTargetInfo);SDL declaration
extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
Begins a render pass on a command buffer.
A render pass consists of a set of texture subresources (or depth slices in the 3D texture case) which will be rendered to during the render pass, along with corresponding clear values and load/store operations. All operations related to graphics pipelines must take place inside of a render pass. A default viewport and scissor state are automatically set when this is called. You cannot begin another render pass, or begin a compute pass or copy pass until you have ended the render pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
colorTargetInfos |
in SDL.GPUColorTargetInfo[] |
an array of texture subresources with corresponding clear values and load/store ops. |
numColorTargets |
uint |
the number of color targets in the colorTargetInfos array. |
depthStencilTargetInfo |
in SDL.GPUDepthStencilTargetInfo |
a texture subresource with corresponding clear value and load/store ops, may be null. |
Returns
a render pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,SDL3.SDL.GPUColorTargetInfo[]@,System.UInt32,SDL3.SDL.GPUDepthStencilTargetInfo@)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, in SDL.GPUColorTargetInfo[] colorTargetInfos, uint numColorTargets, IntPtr depthStencilTargetInfo);SDL declaration
extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
Begins a render pass on a command buffer.
A render pass consists of a set of texture subresources (or depth slices in the 3D texture case) which will be rendered to during the render pass, along with corresponding clear values and load/store operations. All operations related to graphics pipelines must take place inside of a render pass. A default viewport and scissor state are automatically set when this is called. You cannot begin another render pass, or begin a compute pass or copy pass until you have ended the render pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
colorTargetInfos |
in SDL.GPUColorTargetInfo[] |
an array of texture subresources with corresponding clear values and load/store ops. |
numColorTargets |
uint |
the number of color targets in the colorTargetInfos array. |
depthStencilTargetInfo |
IntPtr |
a texture subresource with corresponding clear value and load/store ops, may be null. |
Returns
a render pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,SDL3.SDL.GPUColorTargetInfo[]@,System.UInt32,System.IntPtr)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, IntPtr colorTargetInfos, uint numColorTargets, in SDL.GPUDepthStencilTargetInfo depthStencilTargetInfo);SDL declaration
extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
Begins a render pass on a command buffer.
A render pass consists of a set of texture subresources (or depth slices in the 3D texture case) which will be rendered to during the render pass, along with corresponding clear values and load/store operations. All operations related to graphics pipelines must take place inside of a render pass. A default viewport and scissor state are automatically set when this is called. You cannot begin another render pass, or begin a compute pass or copy pass until you have ended the render pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
colorTargetInfos |
IntPtr |
an array of texture subresources with corresponding clear values and load/store ops. |
numColorTargets |
uint |
the number of color targets in the colorTargetInfos array. |
depthStencilTargetInfo |
in SDL.GPUDepthStencilTargetInfo |
a texture subresource with corresponding clear value and load/store ops, may be null. |
Returns
a render pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,System.IntPtr,System.UInt32,SDL3.SDL.GPUDepthStencilTargetInfo@)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, IntPtr colorTargetInfos, uint numColorTargets, IntPtr depthStencilTargetInfo);SDL declaration
extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
Begins a render pass on a command buffer.
A render pass consists of a set of texture subresources (or depth slices in the 3D texture case) which will be rendered to during the render pass, along with corresponding clear values and load/store operations. All operations related to graphics pipelines must take place inside of a render pass. A default viewport and scissor state are automatically set when this is called. You cannot begin another render pass, or begin a compute pass or copy pass until you have ended the render pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
colorTargetInfos |
IntPtr |
an array of texture subresources with corresponding clear values and load/store ops. |
numColorTargets |
uint |
the number of color targets in the colorTargetInfos array. |
depthStencilTargetInfo |
IntPtr |
a texture subresource with corresponding clear value and load/store ops, may be null. |
Returns
a render pass handle.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,System.IntPtr,System.UInt32,System.IntPtr)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, ReadOnlySpan<SDL.GPUColorTargetInfo> colorTargetInfos, uint numColorTargets, in SDL.GPUDepthStencilTargetInfo depthStencilTargetInfo);Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
|
colorTargetInfos |
ReadOnlySpan<SDL.GPUColorTargetInfo> |
|
numColorTargets |
uint |
|
depthStencilTargetInfo |
in SDL.GPUDepthStencilTargetInfo |
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,System.ReadOnlySpan{SDL3.SDL.GPUColorTargetInfo},System.UInt32,SDL3.SDL.GPUDepthStencilTargetInfo@)
public static IntPtr BeginGPURenderPass(IntPtr commandBuffer, ReadOnlySpan<SDL.GPUColorTargetInfo> colorTargetInfos, uint numColorTargets, IntPtr depthStencilTargetInfo);Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
|
colorTargetInfos |
ReadOnlySpan<SDL.GPUColorTargetInfo> |
|
numColorTargets |
uint |
|
depthStencilTargetInfo |
IntPtr |
XML member id: M:SDL3.SDL.BeginGPURenderPass(System.IntPtr,System.ReadOnlySpan{SDL3.SDL.GPUColorTargetInfo},System.UInt32,System.IntPtr)
public static bool BindAudioStream(uint devid, IntPtr stream);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream);
Bind a single audio stream to an audio device.
This is a convenience function, equivalent to calling BindAudioStreams(devid, stream, 1).
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
an audio device to bind a stream to. |
stream |
IntPtr |
an audio stream to bind to a device. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindAudioStream(System.UInt32,System.IntPtr)
public static bool BindAudioStreams(uint devid, IntPtr[] streams, int numStream);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *streams, int num_streams);
Bind a list of audio streams to an audio device.
Audio data will flow through any bound streams. For a playback device, data for all bound streams will be mixed together and fed to the device. For a recording device, a copy of recorded data will be provided to each bound stream.
Audio streams can only be bound to an open device. This operation is atomic--all streams bound in the same call will start processing at the same time, so they can stay in sync. Also: either all streams will be bound or none of them will be.
It is an error to bind an already-bound stream; it must be explicitly unbound first.
Binding a stream to a device will set its output format for playback devices, and its input format for recording devices, so they match the device's settings. The caller is welcome to change the other end of the stream's format at any time with SDL.SetAudioStreamFormat. If the other end of the stream's format has never been set (the audio stream was created with a null audio spec), this function will set it to match the device end's format.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
an audio device to bind a stream to. |
streams |
IntPtr[] |
an array of audio streams to bind. |
numStream |
int |
number streams listed in the streams array. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindAudioStreams(System.UInt32,System.IntPtr[],System.Int32)
public static bool BindAudioStreams(uint devid, ReadOnlySpan<IntPtr> streams, int numStream);Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
|
streams |
ReadOnlySpan<IntPtr> |
|
numStream |
int |
XML member id: M:SDL3.SDL.BindAudioStreams(System.UInt32,System.ReadOnlySpan{System.IntPtr},System.Int32)
public static void BindGPUComputePipeline(IntPtr computePass, IntPtr computePipeline);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(SDL_GPUComputePass *compute_pass, SDL_GPUComputePipeline *compute_pipeline);
Binds a compute pipeline on a command buffer for use in compute dispatch.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
computePipeline |
IntPtr |
a compute pipeline to bind. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputePipeline(System.IntPtr,System.IntPtr)
public static void BindGPUComputeSamplers(IntPtr computePass, uint firstSlot, IntPtr textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the compute shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute sampler slot to begin binding from. |
textureSamplerBindings |
IntPtr |
an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler bindings to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeSamplers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUComputeSamplers(IntPtr computePass, uint firstSlot, ReadOnlySpan<SDL.GPUTextureSamplerBinding> textureSamplerBindings, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
|
firstSlot |
uint |
|
textureSamplerBindings |
ReadOnlySpan<SDL.GPUTextureSamplerBinding> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUComputeSamplers(System.IntPtr,System.UInt32,System.ReadOnlySpan{SDL3.SDL.GPUTextureSamplerBinding},System.UInt32)
public static void BindGPUComputeSamplers(IntPtr computePass, uint firstSlot, SDL.GPUTextureSamplerBinding[] textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the compute shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute sampler slot to begin binding from. |
textureSamplerBindings |
SDL.GPUTextureSamplerBinding[] |
an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler bindings to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeSamplers(System.IntPtr,System.UInt32,SDL3.SDL.GPUTextureSamplerBinding[],System.UInt32)
public static void BindGPUComputeStorageBuffers(IntPtr computePass, uint firstSlot, IntPtr storageBuffers, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings);
Binds storage buffers as readonly for use on the compute pipeline.
These buffers must have been created with SDL.GPUBufferUsageFlags.ComputeStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute storage buffer slot to begin binding from. |
storageBuffers |
IntPtr |
an array of storage buffer binding structs. |
numBindings |
uint |
the number of storage buffers to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeStorageBuffers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUComputeStorageBuffers(IntPtr computePass, uint firstSlot, IntPtr[] storageBuffers, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings);
Binds storage buffers as readonly for use on the compute pipeline.
These buffers must have been created with SDL.GPUBufferUsageFlags.ComputeStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute storage buffer slot to begin binding from. |
storageBuffers |
IntPtr[] |
an array of storage buffer binding structs. |
numBindings |
uint |
the number of storage buffers to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeStorageBuffers(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUComputeStorageBuffers(IntPtr computePass, uint firstSlot, ReadOnlySpan<IntPtr> storageBuffers, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
|
firstSlot |
uint |
|
storageBuffers |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUComputeStorageBuffers(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static void BindGPUComputeStorageTextures(IntPtr computePass, uint firstSlot, IntPtr storageTextures, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings);
Binds storage textures as readonly for use on the compute pipeline.
These textures must have been created with SDL.GPUTextureUsageFlags.ComputeStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute storage texture slot to begin binding from. |
storageTextures |
IntPtr |
an array of storage textures. |
numBindings |
uint |
the number of storage textures to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeStorageTextures(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUComputeStorageTextures(IntPtr computePass, uint firstSlot, IntPtr[] storageTextures, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings);
Binds storage textures as readonly for use on the compute pipeline.
These textures must have been created with SDL.GPUTextureUsageFlags.ComputeStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUComputePipeline.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
firstSlot |
uint |
the compute storage texture slot to begin binding from. |
storageTextures |
IntPtr[] |
an array of storage textures. |
numBindings |
uint |
the number of storage textures to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUComputeStorageTextures(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUComputeStorageTextures(IntPtr computePass, uint firstSlot, ReadOnlySpan<IntPtr> storageTextures, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
|
firstSlot |
uint |
|
storageTextures |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUComputeStorageTextures(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static void BindGPUFragmentSamplers(IntPtr renderPass, uint firstSlot, IntPtr textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the fragment shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment sampler slot to begin binding from. |
textureSamplerBindings |
IntPtr |
an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler pairs to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentSamplers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUFragmentSamplers(IntPtr renderPass, uint firstSlot, ReadOnlySpan<SDL.GPUTextureSamplerBinding> textureSamplerBindings, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
textureSamplerBindings |
ReadOnlySpan<SDL.GPUTextureSamplerBinding> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUFragmentSamplers(System.IntPtr,System.UInt32,System.ReadOnlySpan{SDL3.SDL.GPUTextureSamplerBinding},System.UInt32)
public static void BindGPUFragmentSamplers(IntPtr renderPass, uint firstSlot, SDL.GPUTextureSamplerBinding[] textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the fragment shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment sampler slot to begin binding from. |
textureSamplerBindings |
SDL.GPUTextureSamplerBinding[] |
an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler pairs to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentSamplers(System.IntPtr,System.UInt32,SDL3.SDL.GPUTextureSamplerBinding[],System.UInt32)
public static void BindGPUFragmentStorageBuffers(IntPtr renderPass, uint firstSlot, IntPtr storageBuffers, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings);
Binds storage buffers for use on the fragment shader.
These buffers must have been created with SDL.GPUBufferUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment storage buffer slot to begin binding from. |
storageBuffers |
IntPtr |
an array of storage buffers. |
numBindings |
uint |
the number of storage buffers to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentStorageBuffers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUFragmentStorageBuffers(IntPtr renderPass, uint firstSlot, IntPtr[] storageBuffers, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings);
Binds storage buffers for use on the fragment shader.
These buffers must have been created with SDL.GPUBufferUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment storage buffer slot to begin binding from. |
storageBuffers |
IntPtr[] |
an array of storage buffers. |
numBindings |
uint |
the number of storage buffers to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentStorageBuffers(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUFragmentStorageBuffers(IntPtr renderPass, uint firstSlot, ReadOnlySpan<IntPtr> storageBuffers, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
storageBuffers |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUFragmentStorageBuffers(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static void BindGPUFragmentStorageTextures(IntPtr renderPass, uint firstSlot, IntPtr storageTextures, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings);
Binds storage textures for use on the fragment shader.
These textures must have been created with SDL.GPUTextureUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment storage texture slot to begin binding from. |
storageTextures |
IntPtr |
an array of storage textures. |
numBindings |
uint |
the number of storage textures to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentStorageTextures(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUFragmentStorageTextures(IntPtr renderPass, uint firstSlot, IntPtr[] storageTextures, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings);
Binds storage textures for use on the fragment shader.
These textures must have been created with SDL.GPUTextureUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the fragment storage texture slot to begin binding from. |
storageTextures |
IntPtr[] |
an array of storage textures. |
numBindings |
uint |
the number of storage textures to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUFragmentStorageTextures(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUFragmentStorageTextures(IntPtr renderPass, uint firstSlot, ReadOnlySpan<IntPtr> storageTextures, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
storageTextures |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUFragmentStorageTextures(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static void BindGPUGraphicsPipeline(IntPtr renderPass, IntPtr graphicsPipeline);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(SDL_GPURenderPass *render_pass, SDL_GPUGraphicsPipeline *graphics_pipeline);
Binds a graphics pipeline on a render pass to be used in rendering.
A graphics pipeline must be bound before making any draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
graphicsPipeline |
IntPtr |
the graphics pipeline to bind. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUGraphicsPipeline(System.IntPtr,System.IntPtr)
public static void BindGPUIndexBuffer(IntPtr renderPass, in SDL.GPUBufferBinding binding, SDL.GPUIndexElementSize indexElementSize);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(SDL_GPURenderPass *render_pass, const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize index_element_size);
Binds an index buffer on a command buffer for use with subsequent draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
binding |
in SDL.GPUBufferBinding |
a pointer to a struct containing an index buffer and offset. |
indexElementSize |
SDL.GPUIndexElementSize |
whether the index values in the buffer are 16- or 32-bit. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUIndexBuffer(System.IntPtr,SDL3.SDL.GPUBufferBinding@,SDL3.SDL.GPUIndexElementSize)
public static void BindGPUVertexBuffers(IntPtr renderPass, uint firstSlot, IntPtr bindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUBufferBinding *bindings, Uint32 num_bindings);
Binds vertex buffers on a command buffer for use with subsequent draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex buffer slot to begin binding from. |
bindings |
IntPtr |
a pointer to an array of SDL.GPUBufferBinding structs containing vertex buffers and offset values. |
numBindings |
uint |
the number of bindings in the bindings array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexBuffers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUVertexBuffers(IntPtr renderPass, uint firstSlot, ReadOnlySpan<SDL.GPUBufferBinding> bindings, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
bindings |
ReadOnlySpan<SDL.GPUBufferBinding> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUVertexBuffers(System.IntPtr,System.UInt32,System.ReadOnlySpan{SDL3.SDL.GPUBufferBinding},System.UInt32)
public static void BindGPUVertexBuffers(IntPtr renderPass, uint firstSlot, SDL.GPUBufferBinding[] bindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUBufferBinding *bindings, Uint32 num_bindings);
Binds vertex buffers on a command buffer for use with subsequent draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex buffer slot to begin binding from. |
bindings |
SDL.GPUBufferBinding[] |
an array of SDL.GPUBufferBinding structs containing vertex buffers and offset values. |
numBindings |
uint |
the number of bindings in the bindings array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexBuffers(System.IntPtr,System.UInt32,SDL3.SDL.GPUBufferBinding[],System.UInt32)
public static void BindGPUVertexSamplers(IntPtr renderPass, uint firstSlot, IntPtr textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the vertex shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex sampler slot to begin binding from. |
textureSamplerBindings |
IntPtr |
a pointer an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler pairs to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexSamplers(System.IntPtr,System.UInt32,System.IntPtr,System.UInt32)
public static void BindGPUVertexSamplers(IntPtr renderPass, uint firstSlot, ReadOnlySpan<SDL.GPUTextureSamplerBinding> textureSamplerBindings, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
textureSamplerBindings |
ReadOnlySpan<SDL.GPUTextureSamplerBinding> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUVertexSamplers(System.IntPtr,System.UInt32,System.ReadOnlySpan{SDL3.SDL.GPUTextureSamplerBinding},System.UInt32)
public static void BindGPUVertexSamplers(IntPtr renderPass, uint firstSlot, SDL.GPUTextureSamplerBinding[] textureSamplerBindings, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings);
Binds texture-sampler pairs for use on the vertex shader.
The textures must have been created with SDL.GPUTextureUsageFlags.Sampler.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex sampler slot to begin binding from. |
textureSamplerBindings |
SDL.GPUTextureSamplerBinding[] |
an array of texture-sampler binding structs. |
numBindings |
uint |
the number of texture-sampler pairs to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexSamplers(System.IntPtr,System.UInt32,SDL3.SDL.GPUTextureSamplerBinding[],System.UInt32)
public static void BindGPUVertexStorageBuffers(IntPtr renderPass, uint firstSlot, IntPtr[] storageBuffers, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings);
Binds storage buffers for use on the vertex shader.
These buffers must have been created with SDL.GPUBufferUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex storage buffer slot to begin binding from. |
storageBuffers |
IntPtr[] |
an array of buffers. |
numBindings |
uint |
the number of buffers to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexStorageBuffers(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUVertexStorageBuffers(IntPtr renderPass, uint firstSlot, ReadOnlySpan<IntPtr> storageBuffers, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
storageBuffers |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUVertexStorageBuffers(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static void BindGPUVertexStorageTextures(IntPtr renderPass, uint firstSlot, IntPtr[] storageTextures, uint numBindings);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings);
Binds storage textures for use on the vertex shader.
These textures must have been created with SDL.GPUTextureUsageFlags.GraphicsStorageRead.
Be sure your shader is set up according to the requirements documented in SDL.CreateGPUShader.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
firstSlot |
uint |
the vertex storage texture slot to begin binding from. |
storageTextures |
IntPtr[] |
an array of storage textures. |
numBindings |
uint |
the number of storage texture to bind from the array. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BindGPUVertexStorageTextures(System.IntPtr,System.UInt32,System.IntPtr[],System.UInt32)
public static void BindGPUVertexStorageTextures(IntPtr renderPass, uint firstSlot, ReadOnlySpan<IntPtr> storageTextures, uint numBindings);Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
|
firstSlot |
uint |
|
storageTextures |
ReadOnlySpan<IntPtr> |
|
numBindings |
uint |
XML member id: M:SDL3.SDL.BindGPUVertexStorageTextures(System.IntPtr,System.UInt32,System.ReadOnlySpan{System.IntPtr},System.UInt32)
public static uint BitsPerPixel(SDL.PixelFormat x);A macro to determine an SDL.PixelFormat's bits per pixel.
Note that this macro double-evaluates its parameter, so do not use expressions with side-effects here.
FourCC formats will report zero here, as it rarely makes sense to measure them per-pixel.
Parameters
| Name | Type | Description |
|---|---|---|
x |
SDL.PixelFormat |
an SDL.PixelFormat to check. |
Returns
the bits-per-pixel of format.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BitsPerPixel(SDL3.SDL.PixelFormat)
public static void BlitGPUTexture(IntPtr commandBuffer, in SDL.GPUBlitInfo info);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitInfo *info);
Blits from a source texture region to a destination texture region.
This function must not be called inside of any pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
info |
in SDL.GPUBlitInfo |
the blit info struct containing the blit parameters. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitGPUTexture(System.IntPtr,SDL3.SDL.GPUBlitInfo@)
public static bool BlitSurface(IntPtr src, in SDL.Rect srcrect, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Performs a fast blit from the source surface to the destination surface.
This assumes that the source and destination rectangles are the same size. If either srcrect or dstrect are null, the entire surface (src or dst) is copied. The final blit rectangles are saved in srcrect and dstrect after all clipping is performed.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
`c RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key.
RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key. `
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or nullto copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the x and y position in the destination surface, or null for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SDL.BlitSurfaceScaled. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurface(IntPtr src, in SDL.Rect srcrect, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Performs a fast blit from the source surface to the destination surface.
This assumes that the source and destination rectangles are the same size. If either srcrect or dstrect are null, the entire surface (src or dst) is copied. The final blit rectangles are saved in srcrect and dstrect after all clipping is performed.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
`c RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key.
RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key. `
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or nullto copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the x and y position in the destination surface, or null for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SDL.BlitSurfaceScaled. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,System.IntPtr)
public static bool BlitSurface(IntPtr src, IntPtr srcrect, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Performs a fast blit from the source surface to the destination surface.
This assumes that the source and destination rectangles are the same size. If either srcrect or dstrect are null, the entire surface (src or dst) is copied. The final blit rectangles are saved in srcrect and dstrect after all clipping is performed.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
`c RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key.
RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key. `
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or nullto copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the x and y position in the destination surface, or null for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SDL.BlitSurfaceScaled. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurface(IntPtr src, IntPtr srcrect, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Performs a fast blit from the source surface to the destination surface with clipping.
If either srcrect or dstrect are null, the entire surface (src or dst) is copied while ensuring clipping to dst.clip_rect.
The blit function should not be called on a locked surface.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
`c RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key.
RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels that do not match the source color key. `
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or nullto copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the x and y position in the destination surface, or null for (0,0). The width and height are ignored, and are copied from srcrect. If you want a specific width and height, you should use SDL.BlitSurfaceScaled. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)
public static bool BlitSurface9Grid(IntPtr src, in SDL.Rect srcrect, int leftWidth, int rightWidth, int topHeight, int bottomHeight, float scale, SDL.ScaleMode scaleMode, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be used for the 9-grid, or null to use the entire surface. |
leftWidth |
int |
the width, in pixels, of the left corners in srcrect. |
rightWidth |
int |
the width, in pixels, of the right corners in srcrect. |
topHeight |
int |
the height, in pixels, of the top corners in srcrect. |
bottomHeight |
int |
the height, in pixels, of the bottom corners in srcrect. |
scale |
float |
the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled blit. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface9Grid(System.IntPtr,SDL3.SDL.Rect@,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurface9Grid(IntPtr src, in SDL.Rect srcrect, int leftWidth, int rightWidth, int topHeight, int bottomHeight, float scale, SDL.ScaleMode scaleMode, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be used for the 9-grid, or null to use the entire surface. |
leftWidth |
int |
the width, in pixels, of the left corners in srcrect. |
rightWidth |
int |
the width, in pixels, of the right corners in srcrect. |
topHeight |
int |
the height, in pixels, of the top corners in srcrect. |
bottomHeight |
int |
the height, in pixels, of the bottom corners in srcrect. |
scale |
float |
the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled blit. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface9Grid(System.IntPtr,SDL3.SDL.Rect@,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,System.IntPtr)
public static bool BlitSurface9Grid(IntPtr src, IntPtr srcrect, int leftWidth, int rightWidth, int topHeight, int bottomHeight, float scale, SDL.ScaleMode scaleMode, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be used for the 9-grid, or null to use the entire surface. |
leftWidth |
int |
the width, in pixels, of the left corners in srcrect. |
rightWidth |
int |
the width, in pixels, of the right corners in srcrect. |
topHeight |
int |
the height, in pixels, of the top corners in srcrect. |
bottomHeight |
int |
the height, in pixels, of the bottom corners in srcrect. |
scale |
float |
the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled blit. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface9Grid(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurface9Grid(IntPtr src, IntPtr srcrect, int leftWidth, int rightWidth, int topHeight, int bottomHeight, float scale, SDL.ScaleMode scaleMode, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be used for the 9-grid, or null to use the entire surface. |
leftWidth |
int |
the width, in pixels, of the left corners in srcrect. |
rightWidth |
int |
the width, in pixels, of the right corners in srcrect. |
topHeight |
int |
the height, in pixels, of the top corners in srcrect. |
bottomHeight |
int |
the height, in pixels, of the bottom corners in srcrect. |
scale |
float |
the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled blit. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurface9Grid(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,System.IntPtr)
public static bool BlitSurfaceScaled(IntPtr src, in SDL.Rect srcrect, IntPtr dst, in SDL.Rect dstrect, SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
Perform a scaled blit to a destination surface, which may be of a different format.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire destination surface. |
scaleMode |
SDL.ScaleMode |
the SDL.ScaleMode to be used. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceScaled(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,SDL3.SDL.Rect@,SDL3.SDL.ScaleMode)
public static bool BlitSurfaceScaled(IntPtr src, in SDL.Rect srcrect, IntPtr dst, IntPtr dstrect, SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
Perform a scaled blit to a destination surface, which may be of a different format.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire destination surface. |
scaleMode |
SDL.ScaleMode |
the SDL.ScaleMode to be used. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceScaled(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,System.IntPtr,SDL3.SDL.ScaleMode)
public static bool BlitSurfaceScaled(IntPtr src, IntPtr srcrect, IntPtr dst, in SDL.Rect dstrect, SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
Perform a scaled blit to a destination surface, which may be of a different format.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire destination surface. |
scaleMode |
SDL.ScaleMode |
the SDL.ScaleMode to be used. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceScaled(System.IntPtr,System.IntPtr,System.IntPtr,SDL3.SDL.Rect@,SDL3.SDL.ScaleMode)
public static bool BlitSurfaceScaled(IntPtr src, IntPtr srcrect, IntPtr dst, IntPtr dstrect, SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
Perform a scaled blit to a destination surface, which may be of a different format.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire destination surface. |
scaleMode |
SDL.ScaleMode |
the SDL.ScaleMode to be used. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceScaled(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,SDL3.SDL.ScaleMode)
public static bool BlitSurfaceTiled(IntPtr src, in SDL.Rect srcrect, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiled(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurfaceTiled(IntPtr src, in SDL.Rect srcrect, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiled(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,System.IntPtr)
public static bool BlitSurfaceTiled(IntPtr src, IntPtr srcrect, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiled(System.IntPtr,System.IntPtr,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurfaceTiled(IntPtr src, IntPtr srcrect, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiled(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)
public static bool BlitSurfaceTiledWithScale(IntPtr src, in SDL.Rect srcrect, float scale, SDL.ScaleMode scaleMode, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be scaled and repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
scale |
float |
the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiledWithScale(System.IntPtr,SDL3.SDL.Rect@,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurfaceTiledWithScale(IntPtr src, in SDL.Rect srcrect, float scale, SDL.ScaleMode scaleMode, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be scaled and repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
scale |
float |
the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiledWithScale(System.IntPtr,SDL3.SDL.Rect@,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,System.IntPtr)
public static bool BlitSurfaceTiledWithScale(IntPtr src, IntPtr srcrect, float scale, SDL.ScaleMode scaleMode, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be scaled and repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
scale |
float |
the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiledWithScale(System.IntPtr,System.IntPtr,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurfaceTiledWithScale(IntPtr src, IntPtr srcrect, float scale, SDL.ScaleMode scaleMode, IntPtr dst, IntPtr dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
The pixels in srcrect will be scaled and repeated as many times as needed to completely fill dstrect.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
IntPtr |
the SDL.Rect structure representing the rectangle to be copied, or null to copy the entire surface. |
scale |
float |
the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles. |
scaleMode |
SDL.ScaleMode |
scale algorithm to be used. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
IntPtr |
the SDL.Rect structure representing the target rectangle in the destination surface, or null to fill the entire surface. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceTiledWithScale(System.IntPtr,System.IntPtr,System.Single,SDL3.SDL.ScaleMode,System.IntPtr,System.IntPtr)
public static bool BlitSurfaceUnchecked(IntPtr src, in SDL.Rect srcrect, IntPtr dst, in SDL.Rect dstrect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
Perform low-level surface blitting only.
This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, may not be null. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, may not be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceUnchecked(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,SDL3.SDL.Rect@)
public static bool BlitSurfaceUncheckedScaled(IntPtr src, in SDL.Rect srcrect, IntPtr dst, in SDL.Rect dstrect, SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
Perform low-level surface scaled blitting only.
This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
the SDL.Surface structure to be copied from. |
srcrect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to be copied, may not be null. |
dst |
IntPtr |
the SDL.Surface structure that is the blit target. |
dstrect |
in SDL.Rect |
the SDL.Rect structure representing the target rectangle in the destination surface, may not be null. |
scaleMode |
SDL.ScaleMode |
the SDL.ScaleMode to be used. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Only one thread should be using the src and dst surfaces at any given time.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BlitSurfaceUncheckedScaled(System.IntPtr,SDL3.SDL.Rect@,System.IntPtr,SDL3.SDL.Rect@,SDL3.SDL.ScaleMode)
public static void BroadcastCondition(IntPtr cond);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
Restart all threads that are waiting on the condition variable.
Parameters
| Name | Type | Description |
|---|---|---|
cond |
IntPtr |
the condition variable to signal. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BroadcastCondition(System.IntPtr)
public static uint ButtonMask(int x);XML documentation is not available for this function.
XML member id: M:SDL3.SDL.ButtonMask(System.Int32)
public static uint BytesPerPixel(SDL.PixelFormat x);A macro to determine an SDL.PixelFormat's bytes per pixel.
Note that this macro double-evaluates its parameter, so do not use expressions with side-effects here.
FourCC formats do their best here, but many of them don't have a meaningful measurement of bytes per pixel.
Parameters
| Name | Type | Description |
|---|---|---|
x |
SDL.PixelFormat |
an SDL.PixelFormat to check. |
Returns
the bytes-per-pixel of format.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.BytesPerPixel(SDL3.SDL.PixelFormat)
public static uint CalculateGPUTextureFormatSize(SDL.GPUTextureFormat format, uint width, uint height, uint depthOrLayerCount);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize(SDL_GPUTextureFormat format, Uint32 width, Uint32 height, Uint32 depth_or_layer_count);
Calculate the size in bytes of a texture format with dimensions.
Parameters
| Name | Type | Description |
|---|---|---|
format |
SDL.GPUTextureFormat |
a texture format. |
width |
uint |
width in pixels. |
height |
uint |
height in pixels. |
depthOrLayerCount |
uint |
depth for 3D textures or layer count otherwise. |
Returns
the size of a texture with this format and dimensions.
Since: This function is available since SDL 3.1.6.
XML member id: M:SDL3.SDL.CalculateGPUTextureFormatSize(SDL3.SDL.GPUTextureFormat,System.UInt32,System.UInt32,System.UInt32)
public static IntPtr Calloc(UIntPtr nmemb, UIntPtr size);SDL declaration
extern SDL_DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
Allocate a zero-initialized array.
The memory returned by this function must be freed with SDL.Free.
If either of nmemb or size is 0, they will both be set to 1.
If the allocation is successful, the returned pointer is guaranteed to be aligned to either the fundamental alignment (alignof(max_align_t) in C11 and later) or 2 * sizeof(void *), whichever is smaller. Use SDL.AlignedAlloc if you need to allocate memory aligned to an alignment greater than this guarantee.
Parameters
| Name | Type | Description |
|---|---|---|
nmemb |
UIntPtr |
the number of elements in the array. |
size |
UIntPtr |
the size of each element of the array. |
Returns
a pointer to the allocated array, or null if allocation failed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.Calloc(System.UIntPtr,System.UIntPtr)
public static bool CancelGPUCommandBuffer(IntPtr commandBuffer);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CancelGPUCommandBuffer(SDL_GPUCommandBuffer *command_buffer);
Cancels a command buffer.
None of the enqueued commands are executed.
It is an error to call this function after a swapchain texture has been acquired.
This must be called from the thread the command buffer was acquired on.
You must not reference the command buffer after calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command buffer. |
Returns
true on success, false on error; call SDL.GetError for more information.
Since: This function is available since SDL 3.1.6.
XML member id: M:SDL3.SDL.CancelGPUCommandBuffer(System.IntPtr)
public static bool CaptureMouse(bool enabled);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled);
Capture the mouse and to track input outside an SDL window.
Capturing enables your app to obtain mouse events globally, instead of just within your window. Not all video targets support this function. When capturing is enabled, the current window will get all mouse events, but unlike relative mode, no change is made to the cursor and it is not restrained to your window.
This function may also deny mouse input to other windows--both those in your application and others on the system--so you should use this function sparingly, and in small bursts. For example, you might want to track the mouse while the user is dragging something, until the user releases a mouse button. It is not recommended that you capture the mouse for long periods of time, such as the entire time your app is running. For that, you should probably use SDL.SetWindowRelativeMouseMode or SDL.SetWindowMouseGrab, depending on your goals.
While captured, mouse events still report coordinates relative to the current (foreground) window, but those coordinates may be outside the bounds of the window (including negative values). Capturing is only allowed for the foreground window. If the window loses focus while capturing, the capture will be disabled automatically.
While capturing is enabled, the current window will have the SDL.WindowFlags.MouseCapture flag set.
Please note that SDL will attempt to "auto capture" the mouse while the user is pressing a button; this is to try and make mouse behavior more consistent between platforms, and deal with the common case of a user dragging the mouse outside of the window. This means that if you are calling SDL.CaptureMouse only to deal with this situation, you do not have to (although it is safe to do so). If this causes problems for your app, you can disable auto capture by setting the SDL.Hints.MouseAutoCapture hint to zero.
Parameters
| Name | Type | Description |
|---|---|---|
enabled |
bool |
true to enable capturing, false to disable. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CaptureMouse(System.Boolean)
public static bool ClaimWindowForGPUDevice(IntPtr device, IntPtr window);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClaimWindowForGPUDevice(SDL_GPUDevice *device, SDL_Window *window);
Claims a window, creating a swapchain structure for it.
This must be called before SDL.AcquireGPUSwapchainTexture is called using the window. You should only call this function from the thread that created the window.
The swapchain will be created with SDL.GPUSwapchainComposition.SDR and SDL.GPUPresentMode.VSync. If you want to have different swapchain parameters, you must call SDL.SetGPUSwapchainParameters after claiming the window.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context. |
window |
IntPtr |
an SDL_Window. |
Returns
true on success, or false on failure; call SDL.GetError for more information.
Thread safety
This function should only be called from the thread that created the window.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClaimWindowForGPUDevice(System.IntPtr,System.IntPtr)
public static void CleanupTLS();SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CleanupTLS(void);
Cleanup all TLS data for this thread.
If you are creating your threads outside of SDL and then calling SDL functions, you should call this function before your thread exits, to properly clean up SDL memory.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CleanupTLS
public static bool ClearAudioStream(IntPtr stream);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
Clear any pending data in the stream.
This drops any queued data, so there will be nothing to read from the stream until more is added.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to clear. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearAudioStream(System.IntPtr)
public static bool ClearClipboardData();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void);
Clear the clipboard data.
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearClipboardData
public static bool ClearComposition(IntPtr window);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearComposition(SDL_Window *window);
Dismiss the composition window/IME without disabling the subsystem.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to affect. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearComposition(System.IntPtr)
public static bool ClearError();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearError(void);
Clear any previous error message for this thread.
Returns
true.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearError
public static bool ClearProperty(uint props, string name);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name);
Clear a property from a group of properties.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to modify. |
name |
string |
the name of the property to clear. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearProperty(System.UInt32,System.String)
public static bool ClearSurface(IntPtr surface, float r, float g, float b, float a);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);
Clear a surface with a specific color, with floating point precision.
This function handles all surface formats, and ignores any clip rectangle.
If the surface is YUV, the color is assumed to be in the sRGB colorspace, otherwise the color is assumed to be in the colorspace of the surface.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the SDL.Surface to clear. |
r |
float |
the red component of the pixel, normally in the range 0-1. |
g |
float |
the green component of the pixel, normally in the range 0-1. |
b |
float |
the blue component of the pixel, normally in the range 0-1. |
a |
float |
the alpha component of the pixel, normally in the range 0-1. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ClearSurface(System.IntPtr,System.Single,System.Single,System.Single,System.Single)
public static void ClickTrayEntry(IntPtr entry);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_ClickTrayEntry(SDL_TrayEntry *entry);
Simulate a click on a tray entry.
Parameters
| Name | Type | Description |
|---|---|---|
entry |
IntPtr |
The entry to activate. |
Thread safety
This function should be called on the thread that created the tray.
Since: This function is available since SDL 3.1.10.
XML member id: M:SDL3.SDL.ClickTrayEntry(System.IntPtr)
public static bool CloseAsyncIO(IntPtr asyncio, bool flush, IntPtr queue, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CloseAsyncIO(SDL_AsyncIO *asyncio, bool flush, SDL_AsyncIOQueue *queue, void *userdata);
Close and free any allocated resources for an async I/O object.
Closing a file is also an asynchronous task! If a write failure were to happen during the closing process, for example, the task results will report it as usual.
Closing a file that has been written to does not guarantee the data has made it to physical media; it may remain in the operating system's file cache, for later writing to disk. This means that a successfully-closed file can be lost if the system crashes or loses power in this small window. To prevent this, call this function with the flush parameter set to true. This will make the operation take longer, and perhaps increase system load in general, but a successful result guarantees that the data has made it to physical storage. Don't use this for temporary files, caches, and unimportant data, and definitely use it for crucial irreplaceable files, like game saves.
This function guarantees that the close will happen after any other pending tasks to asyncio, so it's safe to open a file, start several operations, close the file immediately, then check for all results later. This function will not block until the tasks have completed.
Once this function returns true, asyncio is no longer valid, regardless of any future outcomes. Any completed tasks might still contain this pointer in their SDL_AsyncIOOutcome data, in case the app was using this value to track information, but it should not be used again.
If this function returns false, the close wasn't started at all, and it's safe to attempt to close again later.
An SDL_AsyncIOQueue must be specified. The newly-created task will be added to it when it completes its work.
Parameters
| Name | Type | Description |
|---|---|---|
asyncio |
IntPtr |
a pointer to an SDL_AsyncIO structure to close. |
flush |
bool |
true if data should sync to disk before the task completes. |
queue |
IntPtr |
a queue to add the new SDL_AsyncIO to. |
userdata |
IntPtr |
an app-defined pointer that will be provided with the task results. |
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, but two threads should not attempt to close the same object.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.CloseAsyncIO(System.IntPtr,System.Boolean,System.IntPtr,System.IntPtr)
public static void CloseAudioDevice(uint devid);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
Close a previously-opened audio device.
The application should close open audio devices once they are no longer needed.
This function may block briefly while pending audio data is played by the hardware, so that applications don't drop the last buffer of data they supplied if terminating immediately afterwards.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
an audio device id previously returned by SDL.OpenAudioDevice. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseAudioDevice(System.UInt32)
public static void CloseCamera(IntPtr camera);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseCamera(SDL_Camera *camera);
Use this function to shut down camera processing and close the camera device.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
opened camera device. |
Thread safety
It is safe to call this function from any thread, but no thread may reference device once this function is called.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseCamera(System.IntPtr)
public static void CloseGamepad(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
Close a gamepad previously opened with SDL.OpenGamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseGamepad(System.IntPtr)
public static void CloseHaptic(IntPtr haptic);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseHaptic(SDL_Haptic *haptic);
Close a haptic device previously opened with SDL.OpenHaptic.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic device to close. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseHaptic(System.IntPtr)
public static bool CloseIO(IntPtr context);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context);
Close and free an allocated SDL_IOStream structure.
SDL.CloseIO closes and cleans up the SDL_IOStream stream. It releases any resources used by the stream and frees the SDL_IOStream itself. This returns true on success, or false if the stream failed to flush to its output (e.g. to disk).
Note that if this fails to flush the stream for any reason, this function reports an error, but the SDL_IOStream is still invalid once this function returns.
This call flushes any buffered writes to the operating system, but there are no guarantees that those writes have gone to physical media; they might be in the OS's file cache, waiting to go to disk later. If it's absolutely crucial that writes go to disk immediately, so they are definitely stored even if the power fails before the file cache would have caught up, one should call SDL.FlushIO before closing. Note that flushing takes time and makes the system and your app operate less efficiently, so do so sparingly.
Parameters
| Name | Type | Description |
|---|---|---|
context |
IntPtr |
SDL_IOStream structure to close. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Do not use the same SDL_IOStream from two threads at once.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseIO(System.IntPtr)
public static void CloseJoystick(IntPtr joystick);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
Close a joystick previously opened with SDL.OpenJoystick.
Parameters
| Name | Type | Description |
|---|---|---|
joystick |
IntPtr |
the joystick device to close. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseJoystick(System.IntPtr)
public static void CloseSensor(IntPtr sensor);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CloseSensor(SDL_Sensor *sensor);
Close a sensor previously opened with SDL.OpenSensor.
Parameters
| Name | Type | Description |
|---|---|---|
sensor |
IntPtr |
the SDL_Sensor object to close. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseSensor(System.IntPtr)
public static bool CloseStorage(IntPtr storage);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CloseStorage(SDL_Storage *storage);
Closes and frees a storage container.
Parameters
| Name | Type | Description |
|---|---|---|
storage |
IntPtr |
a storage container to close. |
Returns
true if the container was freed with no errors, false otherwise; call SDL.GetError for more information. Even if the function returns an error, the container data will be freed; the error is only for informational purposes.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CloseStorage(System.IntPtr)
public static SDL.ChromaLocation ColorspaceChroma(SDL.Colorspace cspace);A macro to retrieve the chroma sample location of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL.Colorspace to check. |
Returns
the SDL.ChromaLocation of cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspaceChroma(SDL3.SDL.Colorspace)
public static SDL.MatrixCoefficients ColorspaceMatrix(SDL.Colorspace cspace);A macro to retrieve the matrix coefficients of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL.Colorspace to check. |
Returns
the SDL.MatrixCoefficients of cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspaceMatrix(SDL3.SDL.Colorspace)
public static SDL.ColorPrimaries ColorspacePrimaries(SDL.Colorspace cspace);A macro to retrieve the primaries of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL_Colorspace to check. |
Returns
the SDL.ColorPrimaries of cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspacePrimaries(SDL3.SDL.Colorspace)
public static SDL.ColorRange ColorspaceRange(SDL.Colorspace cspace);A macro to retrieve the range of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL.Colorspace to check. |
Returns
the SDL.ColorRange of cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspaceRange(SDL3.SDL.Colorspace)
public static SDL.TransferCharacteristics ColorspaceTransfer(SDL.Colorspace cspace);A macro to retrieve the transfer characteristics of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL.Colorspace to check. |
Returns
the SDL.TransferCharacteristics of cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspaceTransfer(SDL3.SDL.Colorspace)
public static SDL.ColorType ColorspaceType(SDL.Colorspace cspace);A macro to retrieve the type of an SDL.Colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
cspace |
SDL.Colorspace |
an SDL.Colorspace to check. |
Returns
the SDL.ColorType for cspace.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ColorspaceType(SDL3.SDL.Colorspace)
public static bool CompareAndSwapAtomicInt(ref SDL.AtomicInt a, int oldval, int newval);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval);
Set an atomic variable to a new value if it is currently an old value.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicInt |
a pointer to an SDL.AtomicInt variable to be modified. |
oldval |
int |
the old value. |
newval |
int |
the new value. |
Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CompareAndSwapAtomicInt(SDL3.SDL.AtomicInt@,System.Int32,System.Int32)
public static bool CompareAndSwapAtomicPointer(ref IntPtr a, IntPtr oldval, IntPtr newval);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval);
Set a pointer to a new value if it is currently an old value.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref IntPtr |
a pointer to a pointer. |
oldval |
IntPtr |
the old pointer value. |
newval |
IntPtr |
the new pointer value. |
Returns
true if the pointer was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CompareAndSwapAtomicPointer(System.IntPtr@,System.IntPtr,System.IntPtr)
public static bool CompareAndSwapAtomicU32(ref SDL.AtomicU32 a, uint oldval, uint newval);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval);
Set an atomic variable to a new value if it is currently an old value.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicU32 |
a pointer to an SDL.AtomicU32 variable to be modified. |
oldval |
uint |
the old value. |
newval |
uint |
the new value. |
Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CompareAndSwapAtomicU32(SDL3.SDL.AtomicU32@,System.UInt32,System.UInt32)
public static SDL.BlendMode ComposeCustomBlendMode(SDL.BlendFactor srcColorFactor, SDL.BlendFactor dstColorFactor, SDL.BlendOperation colorOperation, SDL.BlendFactor srcAlphaFactor, SDL.BlendFactor dstAlphaFactor, SDL.BlendOperation alphaOperation);SDL declaration
extern SDL_DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation);
Compose a custom blend mode for renderers.
The functions SDL.SetRenderDrawBlendMode and SDL.SetTextureBlendMode accept the SDL.BlendMode returned by this function if the renderer supports it.
A blend mode controls how the pixels from a drawing operation (source) get combined with the pixels from the render target (destination). First, the components of the source and destination pixels get multiplied with their blend factors. Then, the blend operation takes the two products and calculates the result that will get stored in the render target.
Expressed in pseudocode, it would look like this:
c dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor); dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor);
Where the functions colorOperation(src, dst) and alphaOperation(src, dst) can return one of the following:
src + dstsrc - dstdst - srcmin(src, dst)-
max(src, dst)The red, green, and blue components are always multiplied with the first, second, and third components of theSDL.BlendFactor, respectively. The fourth component is not used.
The alpha component is always multiplied with the fourth component of the SDL.BlendFactor. The other components are not used in the alpha calculation.
Support for these blend modes varies for each renderer. To check if a specific SDL.BlendMode is supported, create a renderer and pass it to either SDL.SetRenderDrawBlendMode or SDL.SetTextureBlendMode. They will return with an error if the blend mode is not supported.
This list describes the support of custom blend modes for each renderer. All renderers support the four blend modes listed in the SDL_BlendMode enumeration.
- direct3d: Supports all operations with all factors. However, some factors produce unexpected results with
SDL.BlendOperation.MinimumandSDL.BlendOperation.Maximum. - direct3d11: Same as Direct3D 9.
- opengl: Supports the
SDL.BlendOperation.Addoperation with all factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly here. - opengles2: Supports the
SDL.BlendOperation.Add,SDL.BlendOperation.Subtract,SDL.BlendOperation.RevSubtractoperations with all factors. - psp: No custom blend mode support.
- software: No custom blend mode support.
Some renderers do not provide an alpha component for the default render target. The
SDL.BlendFactor.DstAlphaandSDL.BlendFactor.OneMinusDstAlphafactors do not have an effect in this case.
Parameters
| Name | Type | Description |
|---|---|---|
srcColorFactor |
SDL.BlendFactor |
the SDL.BlendFactor applied to the red, green, and blue components of the source pixels. |
dstColorFactor |
SDL.BlendFactor |
the SDL.BlendFactor applied to the red, green, and blue components of the destination pixels. |
colorOperation |
SDL.BlendOperation |
the SDL.BlendOperation used to combine the red, green, and blue components of the source and destination pixels. |
srcAlphaFactor |
SDL.BlendFactor |
the SDL.BlendFactor applied to the alpha component of the source pixels. |
dstAlphaFactor |
SDL.BlendFactor |
the SDL.BlendFactor applied to the alpha component of the destination pixels. |
alphaOperation |
SDL.BlendOperation |
the SDL.BlendOperation used to combine the alpha component of the source and destination pixels. |
Returns
an SDL.BlendMode that represents the chosen factors and operations.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ComposeCustomBlendMode(SDL3.SDL.BlendFactor,SDL3.SDL.BlendFactor,SDL3.SDL.BlendOperation,SDL3.SDL.BlendFactor,SDL3.SDL.BlendFactor,SDL3.SDL.BlendOperation)
public static bool ConvertAudioSamples(in SDL.AudioSpec srcSpec, IntPtr srcData, int srcLen, in SDL.AudioSpec dstSpec, out IntPtr dstData, out int dstLen);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len);
Convert some audio data of one format to another format.
Please note that this function is for convenience, but should not be used to resample audio in blocks, as it will introduce audio artifacts on the boundaries. You should only use this function if you are converting audio data in its entirety in one call. If you want to convert audio in smaller chunks, use an SDL_AudioStream, which is designed for this situation.
Internally, this function creates and destroys an SDL_AudioStream on each use, so it's also less efficient than using one directly, if you need to convert multiple times.
Parameters
| Name | Type | Description |
|---|---|---|
srcSpec |
in SDL.AudioSpec |
the format details of the input audio. |
srcData |
IntPtr |
the audio data to be converted. |
srcLen |
int |
the length of srcData. |
dstSpec |
in SDL.AudioSpec |
the format details of the output audio. |
dstData |
out IntPtr |
will be filled with a pointer to converted audio data, which should be freed with SDL.Free. On error, it will be null. |
dstLen |
out int |
will be filled with the len of dstData. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertAudioSamples(SDL3.SDL.AudioSpec@,System.IntPtr,System.Int32,SDL3.SDL.AudioSpec@,System.IntPtr@,System.Int32@)
public static bool ConvertEventToRenderCoordinates(IntPtr renderer, ref SDL.Event event);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
Convert the coordinates in an event to render coordinates.
This takes into account several states:
- The window dimensions.
- The logical presentation settings (
SDL.SetRenderLogicalPresentation) - The scale (
SDL.SetRenderScale) - The viewport (
SDL.SetRenderViewport) Various event types are converted with this function: mouse, touch, pen, etc.
Touch coordinates are converted from normalized coordinates in the window to non-normalized rendering coordinates.
Relative mouse coordinates (xrel and yrel event fields) are also converted. Applications that do not want these fields converted should use SDL.RenderCoordinatesFromWindow on the specific event fields instead of converting the entire event structure.
Once converted, coordinates may be outside the rendering area.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
event |
ref SDL.Event |
the event to modify. |
Returns
true if the event is converted or doesn't need conversion, or false on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertEventToRenderCoordinates(System.IntPtr,SDL3.SDL.Event@)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, byte[] src, int srcPitch, SDL.PixelFormat dstFormat, out byte[] dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
Copy a block of pixels of one format to another format.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
src |
byte[] |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dst |
out byte[] |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.Byte[],System.Int32,SDL3.SDL.PixelFormat,System.Byte[]@,System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, byte[] src, int srcPitch, SDL.PixelFormat dstFormat, out IntPtr dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
Copy a block of pixels of one format to another format.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
src |
byte[] |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dst |
out IntPtr |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.Byte[],System.Int32,SDL3.SDL.PixelFormat,System.IntPtr@,System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, out byte[] dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
Copy a block of pixels of one format to another format.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
src |
IntPtr |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dst |
out byte[] |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,System.Byte[]@,System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, out IntPtr dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
Copy a block of pixels of one format to another format.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
src |
IntPtr |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dst |
out IntPtr |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,System.IntPtr@,System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, Span<byte> dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
src |
IntPtr |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dst |
Span<byte> |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,System.Span{System.Byte},System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, ReadOnlySpan<byte> src, int srcPitch, SDL.PixelFormat dstFormat, IntPtr dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
src |
ReadOnlySpan<byte> |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dst |
IntPtr |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.ReadOnlySpan{System.Byte},System.Int32,SDL3.SDL.PixelFormat,System.IntPtr,System.Int32)
public static bool ConvertPixels(int width, int height, SDL.PixelFormat srcFormat, ReadOnlySpan<byte> src, int srcPitch, SDL.PixelFormat dstFormat, Span<byte> dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
src |
ReadOnlySpan<byte> |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dst |
Span<byte> |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixels(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.ReadOnlySpan{System.Byte},System.Int32,SDL3.SDL.PixelFormat,System.Span{System.Byte},System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, byte[] src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, out byte[] dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
Copy a block of pixels of one format and colorspace to another format and colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
srcColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the src pixels. |
srcProperties |
uint |
an SDL_PropertiesID with additional source color properties, or 0. |
src |
byte[] |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dstColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the dst pixels. |
dstProperties |
uint |
an SDL_PropertiesID with additional destination color properties, or 0. |
dst |
out byte[] |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Byte[],System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Byte[]@,System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, byte[] src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, out IntPtr dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
Copy a block of pixels of one format and colorspace to another format and colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
srcColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the src pixels. |
srcProperties |
uint |
an SDL_PropertiesID with additional source color properties, or 0. |
src |
byte[] |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dstColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the dst pixels. |
dstProperties |
uint |
an SDL_PropertiesID with additional destination color properties, or 0. |
dst |
out IntPtr |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Byte[],System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr@,System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, out byte[] dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
Copy a block of pixels of one format and colorspace to another format and colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
srcColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the src pixels. |
srcProperties |
uint |
an SDL_PropertiesID with additional source color properties, or 0. |
src |
IntPtr |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dstColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the dst pixels. |
dstProperties |
uint |
an SDL_PropertiesID with additional destination color properties, or 0. |
dst |
out byte[] |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Byte[]@,System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, out IntPtr dst, int dstPitch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
Copy a block of pixels of one format and colorspace to another format and colorspace.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the block to copy, in pixels. |
height |
int |
the height of the block to copy, in pixels. |
srcFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the src pixels format. |
srcColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the src pixels. |
srcProperties |
uint |
an SDL_PropertiesID with additional source color properties, or 0. |
src |
IntPtr |
a pointer to the source pixels. |
srcPitch |
int |
the pitch of the source pixels, in bytes. |
dstFormat |
SDL.PixelFormat |
an SDL.PixelFormat value of the dst pixels format. |
dstColorspace |
SDL.Colorspace |
an SDL.Colorspace value describing the colorspace of the dst pixels. |
dstProperties |
uint |
an SDL_PropertiesID with additional destination color properties, or 0. |
dst |
out IntPtr |
a pointer to be filled in with new pixel data. |
dstPitch |
int |
the pitch of the destination pixels, in bytes. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
The same destination pixels should not be used from two threads at once. It is safe to use the same source pixels from multiple threads.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr@,System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, IntPtr src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, Span<byte> dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
srcColorspace |
SDL.Colorspace |
|
srcProperties |
uint |
|
src |
IntPtr |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dstColorspace |
SDL.Colorspace |
|
dstProperties |
uint |
|
dst |
Span<byte> |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Span{System.Byte},System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, ReadOnlySpan<byte> src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, IntPtr dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
srcColorspace |
SDL.Colorspace |
|
srcProperties |
uint |
|
src |
ReadOnlySpan<byte> |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dstColorspace |
SDL.Colorspace |
|
dstProperties |
uint |
|
dst |
IntPtr |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.ReadOnlySpan{System.Byte},System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.IntPtr,System.Int32)
public static bool ConvertPixelsAndColorspace(int width, int height, SDL.PixelFormat srcFormat, SDL.Colorspace srcColorspace, uint srcProperties, ReadOnlySpan<byte> src, int srcPitch, SDL.PixelFormat dstFormat, SDL.Colorspace dstColorspace, uint dstProperties, Span<byte> dst, int dstPitch);Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
|
height |
int |
|
srcFormat |
SDL.PixelFormat |
|
srcColorspace |
SDL.Colorspace |
|
srcProperties |
uint |
|
src |
ReadOnlySpan<byte> |
|
srcPitch |
int |
|
dstFormat |
SDL.PixelFormat |
|
dstColorspace |
SDL.Colorspace |
|
dstProperties |
uint |
|
dst |
Span<byte> |
|
dstPitch |
int |
XML member id: M:SDL3.SDL.ConvertPixelsAndColorspace(System.Int32,System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.ReadOnlySpan{System.Byte},System.Int32,SDL3.SDL.PixelFormat,SDL3.SDL.Colorspace,System.UInt32,System.Span{System.Byte},System.Int32)
public static IntPtr ConvertSurface(IntPtr surface, SDL.PixelFormat format);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format);
Copy an existing surface to a new surface of the specified format.
This function is used to optimize images for faster repeat blitting. This is accomplished by converting the original and storing the result as a new surface. The new, optimized surface can then be used as the source for future blits, making them faster.
If you are converting to an indexed surface and want to map colors to a palette, you can use SDL.ConvertSurfaceAndColorspace instead.
If the original surface has alternate images, the new surface will have a reference to them as well.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the existing SDL.Surface structure to convert. |
format |
SDL.PixelFormat |
the new pixel format. |
Returns
the new SDL.Surface structure that is created or null on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertSurface(System.IntPtr,SDL3.SDL.PixelFormat)
public static IntPtr ConvertSurfaceAndColorspace(IntPtr surface, SDL.PixelFormat format, IntPtr palette, SDL.Colorspace colorspace, uint props);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props);
Copy an existing surface to a new surface of the specified format and colorspace.
This function converts an existing surface to a new format and colorspace and returns the new surface. This will perform any pixel format and colorspace conversion needed.
If the original surface has alternate images, the new surface will have a reference to them as well.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the existing SDL.Surface structure to convert. |
format |
SDL.PixelFormat |
the new pixel format. |
palette |
IntPtr |
an optional palette to use for indexed formats, may be null. |
colorspace |
SDL.Colorspace |
the new colorspace. |
props |
uint |
an SDL_PropertiesID with additional color properties, or 0. |
Returns
the new SDL.Surface structure that is created or null on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.ConvertSurfaceAndColorspace(System.IntPtr,SDL3.SDL.PixelFormat,System.IntPtr,SDL3.SDL.Colorspace,System.UInt32)
public static bool CopyFile(string oldpath, string newpath);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath);
Copy a file.
If the file at newpath already exists, it will be overwritten with the contents of the file at oldpath.
This function will block until the copy is complete, which might be a significant time for large files on slow disks. On some platforms, the copy can be handed off to the OS itself, but on others SDL might just open both paths, and read from one and write to the other.
Note that this is not an atomic operation! If something tries to read from newpath while the copy is in progress, it will see an incomplete copy of the data, and if the calling thread terminates (or the power goes out) during the copy, newpath's previous contents will be gone, replaced with an incomplete copy of the data. To avoid this risk, it is recommended that the app copy to a temporary file in the same directory as newpath, and if the copy is successful, use SDL.RenamePath to replace newpath with the temporary file. This will ensure that reads of newpath will either see a complete copy of the data, or it will see the pre-copy state of newpath.
This function attempts to synchronize the newly-copied data to disk before returning, if the platform allows it, so that the renaming trick will not have a problem in a system crash or power failure, where the file could be renamed but the contents never made it from the system file cache to the physical disk.
If the copy fails for any reason, the state of newpath is undefined. It might be half a copy, it might be the untouched data of what was already there, or it might be a zero-byte file, etc.
Parameters
| Name | Type | Description |
|---|---|---|
oldpath |
string |
the old path. |
newpath |
string |
the new path. |
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, but this operation is not atomic, so the app might need to protect access to specific paths from other threads if appropriate.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CopyFile(System.String,System.String)
public static void CopyGPUBufferToBuffer(IntPtr copyPass, in SDL.GPUBufferLocation source, in SDL.GPUBufferLocation destination, uint size, bool cycle);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferLocation *source, const SDL_GPUBufferLocation *destination, Uint32 size, bool cycle);
Performs a buffer-to-buffer copy.
This copy occurs on the GPU timeline. You may assume the copy has finished in subsequent commands.
This function does not support copying between depth and color textures. For those, copy the texture to a buffer and then to the destination texture.
Parameters
| Name | Type | Description |
|---|---|---|
copyPass |
IntPtr |
a copy pass handle. |
source |
in SDL.GPUBufferLocation |
the buffer and offset to copy from. |
destination |
in SDL.GPUBufferLocation |
the buffer and offset to copy to. |
size |
uint |
the length of the buffer to copy. |
cycle |
bool |
if true, cycles the destination buffer if it is already bound, otherwise overwrites the data. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CopyGPUBufferToBuffer(System.IntPtr,SDL3.SDL.GPUBufferLocation@,SDL3.SDL.GPUBufferLocation@,System.UInt32,System.Boolean)
public static void CopyGPUTextureToTexture(IntPtr copyPass, in SDL.GPUTextureLocation source, in SDL.GPUTextureLocation destination, uint w, uint h, uint d, bool cycle);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureLocation *source, const SDL_GPUTextureLocation *destination, Uint32 w, Uint32 h, Uint32 d, bool cycle);
Performs a texture-to-texture copy.
This copy occurs on the GPU timeline. You may assume the copy has finished in subsequent commands.
Parameters
| Name | Type | Description |
|---|---|---|
copyPass |
IntPtr |
a copy pass handle. |
source |
in SDL.GPUTextureLocation |
a source texture region. |
destination |
in SDL.GPUTextureLocation |
a destination texture region. |
w |
uint |
the width of the region to copy. |
h |
uint |
the height of the region to copy. |
d |
uint |
the depth of the region to copy. |
cycle |
bool |
if true, cycles the destination texture if the destination texture is bound, otherwise overwrites the data. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CopyGPUTextureToTexture(System.IntPtr,SDL3.SDL.GPUTextureLocation@,SDL3.SDL.GPUTextureLocation@,System.UInt32,System.UInt32,System.UInt32,System.Boolean)
public static bool CopyProperties(uint src, uint dst);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst);
Copy a group of properties.
Copy all the properties from one group of properties to another, with the exception of properties requiring cleanup (set using SDL.SetPointerPropertyWithCleanup), which will not be copied. Any property that already exists on dst will be overwritten.
Parameters
| Name | Type | Description |
|---|---|---|
src |
uint |
the properties to copy. |
dst |
uint |
the destination properties. |
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. This function acquires simultaneous mutex locks on both the source and destination property sets.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CopyProperties(System.UInt32,System.UInt32)
public static bool CopyStorageFile(IntPtr storage, string oldpath, string newpath);SDL declaration
c extern SDL_DECLSPEC bool SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath);
Copy a file in a writable storage container.
Parameters
| Name | Type | Description |
|---|---|---|
storage |
IntPtr |
a storage container. |
oldpath |
string |
the old path. |
newpath |
string |
the new path. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CopyStorageFile(System.IntPtr,System.String,System.String)
public static IntPtr CreateAnimatedCursor(ReadOnlySpan<SDL.CursorFrameInfo> frames, int frameCount, int hotX, int hotY);Parameters
| Name | Type | Description |
|---|---|---|
frames |
ReadOnlySpan<SDL.CursorFrameInfo> |
|
frameCount |
int |
|
hotX |
int |
|
hotY |
int |
XML member id: M:SDL3.SDL.CreateAnimatedCursor(System.ReadOnlySpan{SDL3.SDL.CursorFrameInfo},System.Int32,System.Int32,System.Int32)
public static IntPtr CreateAnimatedCursor(SDL.CursorFrameInfo[] frames, int frameCount, int hotX, int hotY);SDL declaration
extern SDL_DECLSPEC SDL_Cursor *SDLCALL SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames,int frame_count, int hot_x, int hot_y);
Create an animated color cursor. Animated cursors are composed of a sequential array of frames, specified as surfaces and durations in an array of SDL.CursorFrameInfo structs. The hot spot coordinates are universal to all frames, and all frames must have the same dimensions.
Frame durations are specified in milliseconds. A duration of 0 implies an infinite frame time, and the animation will stop on that frame. To create a one-shot animation, set the duration of the last frame in the sequence to 0.
If this function is passed surfaces with alternate representations added with SDL.AddSurfaceAlternateImage, the surfaces will be interpreted as the content to be used for 100% display scale, and the alternate representations will be used for high DPI situations. For example, if the original surfaces are 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. If a matching version of the image isn't available, the closest larger size image will be downscaled to the appropriate size and be used instead, if available. Otherwise, the closest smaller image will be upscaled and be used instead.
If the underlying platform does not support animated cursors, this function will fall back to creating a static color cursor using the first frame in the sequence.
Parameters
| Name | Type | Description |
|---|---|---|
frames |
SDL.CursorFrameInfo[] |
an array of cursor images composing the animation. |
frameCount |
int |
the number of frames in the sequence. |
hotX |
int |
the x position of the cursor hot spot. |
hotY |
int |
the y position of the cursor hot spot. |
Returns
the new cursor on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.CreateAnimatedCursor(SDL3.SDL.CursorFrameInfo[],System.Int32,System.Int32,System.Int32)
public static IntPtr CreateAsyncIOQueue();SDL declaration
extern SDL_DECLSPEC SDL_AsyncIOQueue * SDLCALL SDL_CreateAsyncIOQueue(void);
Create a task queue for tracking multiple I/O operations.
Async I/O operations are assigned to a queue when started. The queue can be checked for completed tasks thereafter.
Returns
a new task queue object or null if there was an error; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.CreateAsyncIOQueue
public static IntPtr CreateAudioStream(in SDL.AudioSpec srcSpec, in SDL.AudioSpec dstSpec);SDL declaration
extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);
Create a new audio stream.
SDL_AudioStream is an audio conversion interface. You push data as you have it, and pull it when you need it; the stream will buffer data as needed.
Note that srcSpec or dstSpec may be null, but any attempts to put or get data from an audio stream will fail until it has valid specs assigned to both ends of the stream. Specs can be assigned later through SDL.SetAudioStreamFormat, or binding the stream to an audio device (which will set the format of only the input or output, depending on what kind of device the stream was bound to).
Use SDL.CreateAudioStream when either audio spec should be null.
Parameters
| Name | Type | Description |
|---|---|---|
srcSpec |
in SDL.AudioSpec |
the format details of the input audio. |
dstSpec |
in SDL.AudioSpec |
the format details of the output audio. |
Returns
a new audio stream on success or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0.
XML member id: M:SDL3.SDL.CreateAudioStream(SDL3.SDL.AudioSpec@,SDL3.SDL.AudioSpec@)
public static IntPtr CreateAudioStream(IntPtr srcSpec, IntPtr dstSpec);SDL declaration
extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);
Create a new audio stream.
SDL_AudioStream is an audio conversion interface. You push data as you have it, and pull it when you need it; the stream will buffer data as needed.
Note that srcSpec or dstSpec may be null, but any attempts to put or get data from an audio stream will fail until it has valid specs assigned to both ends of the stream. Specs can be assigned later through SDL.SetAudioStreamFormat, or binding the stream to an audio device (which will set the format of only the input or output, depending on what kind of device the stream was bound to).
Parameters
| Name | Type | Description |
|---|---|---|
srcSpec |
IntPtr |
the format details of the input audio. May be null. |
dstSpec |
IntPtr |
the format details of the output audio. May be null. |
Returns
a new audio stream on success or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0.
XML member id: M:SDL3.SDL.CreateAudioStream(System.IntPtr,System.IntPtr)
public static IntPtr CreateColorCursor(IntPtr surface, int hotX, int hotY);SDL declaration
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y);
Create a color cursor.
If this function is passed a surface with alternate representations added with SDL.AddSurfaceAlternateImage, the surface will be interpreted as the content to be used for 100% display scale, and the alternate representations will be used for high DPI situations if SDL.Hints.MouseDPIScaleCursors is enabled. For example, if the original surface is 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. If a matching version of the image isn't available, the closest larger size image will be downscaled to the appropriate size and be used instead, if available. Otherwise, the closest smaller image will be upscaled and be used instead.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
an SDL.Surface structure representing the cursor image. |
hotX |
int |
the x position of the cursor hot spot. |
hotY |
int |
the y position of the cursor hot spot. |
Returns
the new cursor on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateColorCursor(System.IntPtr,System.Int32,System.Int32)
public static IntPtr CreateCondition();SDL declaration
extern SDL_DECLSPEC SDL_Condition * SDLCALL SDL_CreateCondition(void);
Create a condition variable.
Returns
a new condition variable or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateCondition
public static IntPtr CreateCursor(byte[] data, byte[] mask, int w, int h, int hotX, int hotY);SDL declaration
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y);
Create a cursor using the specified bitmap data and mask (in MSB format).
mask has to be in MSB (Most Significant Bit) format.
The cursor width (w) must be a multiple of 8 bits.
The cursor is created in black and white according to the following:
- data=0, mask=1: white
- data=1, mask=1: black
- data=0, mask=0: transparent
- data=1, mask=0: inverted color if possible, black if not.
Cursors created with this function must be freed with
SDL.DestroyCursor.
If you want to have a color cursor, or create your cursor from an SDL_Surface, you should use SDL.CreateColorCursor. Alternately, you can hide the cursor and draw your own as part of your game's rendering, but it will be bound to the framerate.
Also, SDL.CreateSystemCursor is available, which provides several readily-available system cursors to pick from.
Parameters
| Name | Type | Description |
|---|---|---|
data |
byte[] |
the color value for each pixel of the cursor. |
mask |
byte[] |
the mask value for each pixel of the cursor. |
w |
int |
the width of the cursor. |
h |
int |
the height of the cursor. |
hotX |
int |
the x-axis offset from the left of the cursor image to the mouse x position, in the range of 0 to w - 1. |
hotY |
int |
the y-axis offset from the top of the cursor image to the mouse y position, in the range of 0 to h - 1. |
Returns
a new cursor with the specified parameters on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateCursor(System.Byte[],System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32)
public static IntPtr CreateCursor(ReadOnlySpan<byte> data, ReadOnlySpan<byte> mask, int w, int h, int hotX, int hotY);Parameters
| Name | Type | Description |
|---|---|---|
data |
ReadOnlySpan<byte> |
|
mask |
ReadOnlySpan<byte> |
|
w |
int |
|
h |
int |
|
hotX |
int |
|
hotY |
int |
XML member id: M:SDL3.SDL.CreateCursor(System.ReadOnlySpan{System.Byte},System.ReadOnlySpan{System.Byte},System.Int32,System.Int32,System.Int32,System.Int32)
public static bool CreateDirectory(string path);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path);
Create a directory, and any missing parent directories.
This reports success if path already exists as a directory.
If parent directories are missing, it will also create them. Note that if this fails, it will not remove any parent directories it already made.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
the path of the directory to create. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateDirectory(System.String)
public static IntPtr CreateEnvironment(bool populated);SDL declaration
extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(bool populated);
Create a set of environment variables
Parameters
| Name | Type | Description |
|---|---|---|
populated |
bool |
true to initialize it from the C runtime environment, false to create an empty environment. |
Returns
a pointer to the new environment or null on failure; call SDL.GetError for more information.
Thread safety
If populated is false, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateEnvironment(System.Boolean)
public static IntPtr CreateGPUBuffer(IntPtr device, in SDL.GPUBufferCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer(SDL_GPUDevice *device, const SDL_GPUBufferCreateInfo *createinfo);
Creates a buffer object to be used in graphics or compute workflows.
The contents of this buffer are undefined until data is written to the buffer.
Note that certain combinations of usage flags are invalid. For example, a buffer cannot have both the SDL.GPUBufferUsageFlags.Vertex and SDL.GPUBufferUsageFlags.Index flags.
If you use a STORAGE flag, the data in the buffer must respect std140 layout conventions. In practical terms this means you must ensure that vec3 and vec4 fields are 16-byte aligned.
For better understanding of underlying concepts and memory management with SDL GPU API, you may refer this blog post.
There are optional properties that can be provided through props. These are the supported properties:
-
SDL.Props.GPUBufferCreateNameString: a name that can be displayed in debugging tools.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUBufferCreateInfo |
a struct describing the state of the buffer to create. |
Returns
a buffer object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUBuffer(System.IntPtr,SDL3.SDL.GPUBufferCreateInfo@)
public static IntPtr CreateGPUComputePipeline(IntPtr device, in SDL.GPUComputePipelineCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline(SDL_GPUDevice *device, const SDL_GPUComputePipelineCreateInfo *createinfo);
Creates a pipeline object to be used in a compute workflow.
Shader resource bindings must be authored to follow a particular order depending on the shader format.
For SPIR-V shaders, use the following resource sets:
-
0: Sampled textures, followed by read-only storage textures, followed by read-only storage buffers
-
1: Read-write storage textures, followed by read-write storage buffers
-
2: Uniform buffers For DXBC and DXIL shaders, use the following register order:
-
(t[n], space0): Sampled textures, followed by read-only storage textures, followed by read-only storage buffers
-
(u[n], space1): Read-write storage textures, followed by read-write storage buffers
-
(b[n], space2): Uniform buffers For MSL/metallib, use the following order:
-
buffer: Uniform buffers, followed by read-only storage buffers, followed by read-write storage buffers
-
texture: Sampled textures, followed by read-only storage textures, followed by read-write storage textures
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUComputePipelineCreateInfo |
a struct describing the state of the compute pipeline to create. |
Returns
a compute pipeline object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUComputePipeline(System.IntPtr,SDL3.SDL.GPUComputePipelineCreateInfo@)
public static IntPtr CreateGPUDevice(SDL.GPUShaderFormat formatFlags, bool debugMode, string name);SDL declaration
extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice(SDL_GPUShaderFormat format_flags, bool debug_mode, const char *name);
Creates a GPU context. The GPU driver name can be one of the following:
Parameters
| Name | Type | Description |
|---|---|---|
formatFlags |
SDL.GPUShaderFormat |
a bitflag indicating which shader formats the app is able to provide. |
debugMode |
bool |
enable debug mode properties and validations. |
name |
string |
the preferred GPU driver, or null to let SDL pick the optimal driver. |
Returns
a GPU context on success or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUDevice(SDL3.SDL.GPUShaderFormat,System.Boolean,System.String)
public static IntPtr CreateGPUDeviceWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props);
Creates a GPU context.
These are the supported properties:
-
SDL.Props.GPUDeviceCreateDebugModeBoolean: enable debug mode properties and validations, defaults totrue. -
SDL.Props.GPUDeviceCreatePreferLowPowerBoolean: enable to prefer energy efficiency over maximum GPU performance, defaults tofalse. -
SDL.Props.GPUDeviceCreateVerboseBoolean: enable to automatically log useful debug information on device creation, defaults totrue. -
SDL.Props.GPUDeviceCreateNameString: the name of the GPU driver to use, if a specific one is desired. -
SDL.Props.GPUDeviceCreateFeatureClipDistanceBoolean: Enable Vulkan device feature shaderClipDistance. If disabled, clip distances are not supported in shader code: gl_ClipDistance[] built-ins of GLSL, SV_ClipDistance0/1 semantics of HLSL and clip_distance attribute of Metal. Disabling optional features allows the application to run on some older Android devices. Defaults totrue. -
SDL.Props.GPUDeviceCreateFeatureDepthClampingBoolean: Enable Vulkan device feature depthClamp. If disabled, there is no depth clamp support and enable_depth_clip inSDL.GPURasterizerStatemust always be set totrue. Disabling optional features allows the application to run on some older Android devices. Defaults totrue. -
SDL.Props.GPUDeviceCreateFeatureIndirectDrawFirstInstanceBoolean: Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the argument first_instance ofSDL.GPUIndirectDrawCommandmust be set to zero. Disabling optional features allows the application to run on some older Android devices. Defaults totrue. -
SDL.Props.GPUDeviceCreateFeatureAnisotropyBoolean: Enable Vulkan device feature samplerAnisotropy. If disabled, enable_anisotropy ofSDL.GPUSamplerCreateInfomust be set tofalse. Disabling optional features allows the application to run on some older Android devices. Defaults totrue. These are the current shader format properties: -
SDL.Props.GPUDeviceCreateShadersPrivateBoolean: The app is able to provide shaders for an NDA platform. -
SDL.Props.GPUDeviceCreateShadersSPIRVBoolean: The app is able to provide SPIR-V shaders if applicable. -
SDL.Props.GPUDeviceCreateShadersDXBCBoolean: The app is able to provide DXBC shaders if applicableSDL.Props.GPUDeviceCreateShadersDXILBoolean: The app is able to provide DXIL shaders if applicable. -
SDL.Props.GPUDeviceCreateShadersMSLBoolean: The app is able to provide MSL shaders if applicable. -
SDL.Props.GPUDeviceCreateShadersMetalLibBoolean: The app is able to provide Metal shader libraries if applicable. With the D3D12 backend: -
SDL.Props.GPUDeviceCreateD3D12SemanticNameString: the prefix to use for all vertex semantics, default is "TEXCOORD". -
SDL.Props.GPUDeviceCreateD3D12AllowFewerResourceSlotsBoolean: By default, Resourcing Binding Tier 2 is required for D3D12 support. However, an application can set this property totrueto enable Tier 1 support, if (and only if) the application uses 8 or fewer storage resources across all shader stages. As of writing, this property is useful for targeting Intel Haswell and Broadwell GPUs; other hardware either supports Tier 2 Resource Binding or does not support D3D12 in any capacity. Defaults tofalse. -
SDL.Props.GPUDeviceCreateD3D12AgilitySDKVersionNumber: Certain feature checks are only possible on Windows 11 by default. By setting this alongsideSDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRINGand vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make those feature checks possible on older platforms. The version you provide must match the one given in the DLL. -
SDL.Props.GPUDeviceCreateD3D12AgilitySDKPathString: Certain feature checks are only possible on Windows 11 by default. By setting this alongsideSDL.Props.GPUDeviceCreateD3D12AgilitySDKVersionNumberand vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make those feature checks possible on older platforms. The path you provide must be relative to the executable path of your app. Be sure not to put the DLL in the same directory as the exe; Microsoft strongly advises against this! With the Vulkan backend: -
SDL.Props.GPUDeviceCreateVulkanRequireHardwareAccelerationBoolean: By default, Vulkan device enumeration includes drivers of all types, including software renderers (for example, the Lavapipe Mesa driver). This can be useful if your application requires SDL_GPU, but if you can provide your own fallback renderer (for example, an OpenGL renderer) this property can be set totrue. Defaults tofalse. -
SDL.Props.GPUDeviceCreateVulkanOptionsPointer: a pointer to anSDL.GPUVulkanOptionsstructure to be processed during device creation. This allows configuring a variety of Vulkan-specific options such as increasing the API version and opting into extensions aside from the minimal set SDL requires. With the Metal backend: -
SDL.Props.GPUDeviceCreateMetalAllowMacFamily1Boolean: By default, macOS support requires what Apple calls"MTLGPUFamilyMac2"hardware or newer. However, an application can set this property totrueto enable support for"MTLGPUFamilyMac1"hardware, if (and only if) the application does not write to sRGB textures. (For history's sake: MacFamily1 also does not support indirect command buffers, MSAA depth resolve, and stencil resolve/feedback, but these are not exposed features in SDL_GPU.)
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
a GPU context on success or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUDeviceWithProperties(System.UInt32)
public static IntPtr CreateGPUGraphicsPipeline(IntPtr device, in SDL.GPUGraphicsPipelineCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeline(SDL_GPUDevice *device, const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
Creates a pipeline object to be used in a graphics workflow.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUGraphicsPipelineCreateInfo |
a struct describing the state of the graphics pipeline to create. |
Returns
a graphics pipeline object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUGraphicsPipeline(System.IntPtr,SDL3.SDL.GPUGraphicsPipelineCreateInfo@)
public static IntPtr CreateGPURenderer(IntPtr device, IntPtr window);SDL declaration
extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_Window *window, SDL_GPUShaderFormat format_flags, SDL_GPUDevice **device);
Create a 2D GPU rendering context.
The GPU device to use is passed in as a parameter. If this is null, then a device will be created normally and can be retrieved using SDL.GetGPURendererDevice.
The window to use is passed in as a parameter. If this is null, then this will become an offscreen renderer. In that case, you should call SDL.SetRenderTarget to setup rendering to a texture, and then call SDL.RenderPresent normally to complete drawing a frame.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
the window where rendering is displayed, or null to create an offscreen renderer. |
window |
IntPtr |
a bitflag indicating which shader formats the app is able to provide. |
Returns
a valid rendering context or null if there was an error; call SDL.GetError for more information.
Thread safety
If this function is called with a valid GPU device, it should be called on the thread that created the device. If this function is called with a valid window, it should be called on the thread that created the window.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.CreateGPURenderer(System.IntPtr,System.IntPtr)
public static IntPtr CreateGPURenderState(IntPtr renderer, IntPtr createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, const SDL_GPURenderStateCreateInfo *createinfo);
Create custom GPU render state.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the renderer to use. |
createinfo |
IntPtr |
a struct describing the GPU render state to create. |
Returns
a custom GPU render state or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the renderer.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.CreateGPURenderState(System.IntPtr,System.IntPtr)
public static IntPtr CreateGPUSampler(IntPtr device, in SDL.GPUSamplerCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(SDL_GPUDevice *device, const SDL_GPUSamplerCreateInfo *createinfo);
Creates a sampler object to be used when binding textures in a graphics workflow. There are optional properties that can be provided through props. These are the supported properties:
-
SDL.Props.GPUGraphicsPipelineCreateNameString: a name that can be displayed in debugging tools.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUSamplerCreateInfo |
a struct describing the state of the sampler to create. |
Returns
a sampler object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUSampler(System.IntPtr,SDL3.SDL.GPUSamplerCreateInfo@)
public static IntPtr CreateGPUShader(IntPtr device, in SDL.GPUShaderCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(SDL_GPUDevice *device, const SDL_GPUShaderCreateInfo *createinfo);
Creates a shader to be used when creating a graphics pipeline.
Shader resource bindings must be authored to follow a particular order depending on the shader format.
For SPIR-V shaders, use the following resource sets:
For vertex shaders:
-
0: Sampled textures, followed by storage textures, followed by storage buffers
-
1: Uniform buffers For fragment shaders:
-
2: Sampled textures, followed by storage textures, followed by storage buffers
-
3: Uniform buffers For DXBC and DXIL shaders, use the following register order:
For vertex shaders:
-
(t[n], space0): Sampled textures, followed by storage textures, followed by storage buffers
-
(s[n], space0): Samplers with indices corresponding to the sampled textures
-
(b[n], space1): Uniform buffers For pixel shaders:
-
(t[n], space2): Sampled textures, followed by storage textures, followed by storage buffers
-
(s[n], space2): Samplers with indices corresponding to the sampled textures
-
(b[n], space3): Uniform buffers For MSL/metallib, use the following order:
-
texture: Sampled textures, followed by storage textures
-
sampler: Samplers with indices corresponding to the sampled textures
-
buffer: Uniform buffers, followed by storage buffers. Vertex buffer 0 is bound at buffer(14), vertex buffer 1 at buffer(15), and so on. Rather than manually authoring vertex buffer indices, use the stage_in attribute which will automatically use the vertex input information from the SDL_GPUGraphicsPipeline. Shader semantics other than system-value semantics do not matter in D3D12 and for ease of use the SDL implementation assumes that non system-value semantics will all be TEXCOORD. If you are using HLSL as the shader source language, your vertex semantics should start at TEXCOORD0 and increment like so: TEXCOORD1, TEXCOORD2, etc. If you wish to change the semantic prefix to something other than TEXCOORD you can use
SDL.Props.GPUDeviceCreateD3D12SemanticNameStringwithSDL.CreateGPUDeviceWithProperties.
There are optional properties that can be provided through props. These are the supported properties:
-
SDL.Props.GPUSamplerCreateNameString: a name that can be displayed in debugging tools.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUShaderCreateInfo |
a struct describing the state of the shader to create. |
Returns
a shader object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUShader(System.IntPtr,SDL3.SDL.GPUShaderCreateInfo@)
public static IntPtr CreateGPUTexture(IntPtr device, in SDL.GPUTextureCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(SDL_GPUDevice *device, const SDL_GPUTextureCreateInfo *createinfo);
Creates a texture object to be used in graphics or compute workflows.
The contents of this texture are undefined until data is written to the texture, either via SDL.UploadToGPUTexture or by performing a render or compute pass with this texture as a target.
Note that certain combinations of usage flags are invalid. For example, a texture cannot have both the SDL.GPUTextureUsageFlags.Sampler and SDL.GPUTextureUsageFlags.GraphicsStorageRead flags.
If you request a sample count higher than the hardware supports, the implementation will automatically fall back to the highest available sample count.
There are optional properties that can be provided through SDL.GPUTextureCreateInfo's props. These are the supported properties:
-
SDL.Props.GPUTextureCreateD3D12ClearRFloat: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.ColorTarget, clear the texture to a color with this red intensity. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearGFloat: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.ColorTarget, clear the texture to a color with this green intensity. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearBFloat: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.ColorTarget, clear the texture to a color with this blue intensity. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearAFloat: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.ColorTarget, clear the texture to a color with this alpha intensity. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearDepthFloat: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.DepthStencilTarget, clear the texture to a depth of this value. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearStencilUint8: (Direct3D 12 only) if the texture usage isSDL.GPUTextureUsageFlags.DepthStencilTarget, clear the texture to a stencil of this value. Defaults to zero. -
SDL.Props.GPUTextureCreateD3D12ClearStencilNumber: (Direct3D 12 only) if the texture usageSDL.GPUTextureUsageFlags.DepthStencilTarget, clear the texture to a stencil of this Uint8 value. Defaults to zero. -
SDL.Props.GPUShaderCreateNameString: a name that can be displayed in debugging tools.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUTextureCreateInfo |
a struct describing the state of the texture to create. |
Returns
a texture object on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUTexture(System.IntPtr,SDL3.SDL.GPUTextureCreateInfo@)
public static IntPtr CreateGPUTransferBuffer(IntPtr device, in SDL.GPUTransferBufferCreateInfo createinfo);SDL declaration
extern SDL_DECLSPEC SDL_GPUTransferBuffer *SDLCALL SDL_CreateGPUTransferBuffer(SDL_GPUDevice *device, const SDL_GPUTransferBufferCreateInfo *createinfo);
Creates a transfer buffer to be used when uploading to or downloading from graphics resources.
Download buffers can be particularly expensive to create, so it is good practice to reuse them if data will be downloaded regularly.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context. |
createinfo |
in SDL.GPUTransferBufferCreateInfo |
a struct describing the state of the transfer buffer to create. |
Returns
a transfer buffer on success, or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateGPUTransferBuffer(System.IntPtr,SDL3.SDL.GPUTransferBufferCreateInfo@)
public static int CreateHapticEffect(IntPtr haptic, in SDL.HapticEffect effect);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect);
Create a new haptic effect on a specified device.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
an SDL_Haptic device to create the effect on. |
effect |
in SDL.HapticEffect |
an SDL.HapticEffect structure containing the properties of the effect to create. |
Returns
the ID of the effect on success or -1 on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateHapticEffect(System.IntPtr,SDL3.SDL.HapticEffect@)
public static IntPtr CreateMutex();SDL declaration
extern SDL_DECLSPEC SDL_Mutex * SDLCALL SDL_CreateMutex(void);
Create a new mutex.
All newly-created mutexes begin in the unlocked state.
Calls to SDL.LockMutex will not return while the mutex is locked by another thread. See SDL.TryLockMutex to attempt to lock without blocking.
SDL mutexes are reentrant.
Returns
the initialized and unlocked mutex or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateMutex
public static IntPtr CreatePalette(int ncolors);SDL declaration
extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors);
Create a palette structure with the specified number of color entries.
The palette entries are initialized to white.
Parameters
| Name | Type | Description |
|---|---|---|
ncolors |
int |
represents the number of color entries in the color palette. |
Returns
a new SDL.Palette structure on success or null on failure (e.g. if there wasn't enough memory); call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreatePalette(System.Int32)
public static IntPtr CreatePopupWindow(IntPtr parent, int offsetX, int offsetY, int w, int h, SDL.WindowFlags flags);SDL declaration
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags);
Create a child popup window of the specified parent window.
The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.
The flags parameter must contain at least one of the following:
-
SDL.WindowFlags.Tooltip: The popup window is a tooltip and will not pass any input events. -
SDL.WindowFlags.PopupMenu: The popup window is a popup menu. The topmost popup menu will implicitly gain the keyboard focus. The following flags are not relevant to popup window creation and will be ignored: -
SDL.WindowFlags.Minimized -
SDL.WindowFlags.Maximized -
SDL.WindowFlags.Fullscreen -
SDL.WindowFlags.BorderlessThe following flags are incompatible with popup window creation and will cause it to fail: -
SDL.WindowFlags.Utility -
SDL.WindowFlags.ModalThe parent parameter must be non-nulland a valid window. The parent of a popup window can be either a regular, toplevel window, or another popup window.
Popup windows cannot be minimized, maximized, made fullscreen, raised, flash, be made a modal window, be the parent of a toplevel window, or grab the mouse and/or keyboard. Attempts to do so will fail.
Popup windows implicitly do not have a border/decorations and do not appear on the taskbar/dock or in lists of windows such as alt-tab menus.
By default, popup window positions will automatically be constrained to keep the entire window within display bounds. This can be overridden with the SDL.Props.WindowCreateConstrainPopupBoolean property.
By default, popup menus will automatically grab keyboard focus from the parent when shown. This behavior can be overridden by setting the SDL.WindowFlags.NotFocusable flag, setting the SDL.Props.WindowCreateFocusableBoolean property to false, or toggling it after creation via the SDL.SetWindowFocusable function.
If a parent window is hidden or destroyed, any child popup windows will be recursively hidden or destroyed as well. Child popup windows not explicitly hidden will be restored when the parent is shown.
Parameters
| Name | Type | Description |
|---|---|---|
parent |
IntPtr |
the parent of the window, must not be null. |
offsetX |
int |
the x position of the popup window relative to the origin of the parent. |
offsetY |
int |
the y position of the popup window relative to the origin of the parent window. |
w |
int |
the width of the window. |
h |
int |
the height of the window. |
flags |
SDL.WindowFlags |
SDL.WindowFlags.Tooltip or SDL.WindowFlags.PopupMenu, and zero or more additional SDL.WindowFlags OR'd together. |
Returns
the window that was created or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreatePopupWindow(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,SDL3.SDL.WindowFlags)
public static IntPtr CreateProcess(string[] args, bool pipeStdio);SDL declaration
extern SDL_DECLSPEC SDL_Process *SDLCALL SDL_CreateProcess(const char * const *args, bool pipe_stdio);
Create a new process.
The path to the executable is supplied in args[0]. args[1..N] are additional arguments passed on the command line of the new process, and the argument list should be terminated with a null, e.g.:
c const char *args[] = { "myprogram", "argument", null};
Setting pipeStdio to true is equivalent to setting SDL.Props.ProcessCreateSTDInNumber and SDL.Props.ProcessCreateSTDOutNumber to SDL.ProcessIO.App, and will allow the use of SDL.ReadProcess or SDL.GetProcessInput and SDL.GetProcessOutput.
See SDL.CreateProcessWithProperties for more details.
Parameters
| Name | Type | Description |
|---|---|---|
args |
string[] |
the path and arguments for the new process. |
pipeStdio |
bool |
true to create pipes to the process's standard input and from the process's standard output, false for the process to have no input and inherit the application's standard output. |
Returns
the newly created and running process, or null if the process couldn't be created.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateProcess(System.String[],System.Boolean)
public static IntPtr CreateProcessWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC SDL_Process *SDLCALL SDL_CreateProcessWithProperties(SDL_PropertiesID props);
Create a new process with the specified properties.
These are the supported properties:
-
SDL.Props.ProcessCreateArgsPointer: an array of strings containing the program to run, any arguments, and anullpointer, e.g. const char *args[] = { "myprogram", "argument",null}. This is a required property. -
SDL.Props.ProcessCreateEnvironmentPointer: an SDL_Environment pointer. If this property is set, it will be the entire environment for the process, otherwise the current environment is used. -
SDL.Props.ProcessCreateWorkingDirectoryString: a UTF-8 encoded string representing the working directory for the process, defaults to the current working directory. -
SDL.Props.ProcessCreateSTDInNumber: an SDL_ProcessIO value describing where standard input for the process comes from, defaults toSDL.ProcessIO.Null. -
SDL.Props.ProcessCreateSTDInPointer: an SDL_IOStream pointer used for standard input whenSDL.Props.ProcessCreateSTDInNumberis set toSDL.ProcessIO.Redirect. -
SDL.Props.ProcessCreateSTDOutNumber: an SDL_ProcessIO value describing where standard output for the process goes to, defaults toSDL.ProcessIO.Inherited. -
SDL.Props.ProcessCreateSTDOutPointer: an SDL_IOStream pointer used for standard output whenSDL.Props.ProcessCreateSTDOutNumberis set toSDL.ProcessIO.Redirect.. -
SDL.Props.ProcessCreateSTDErrNumber: an SDL_ProcessIO value describing where standard error for the process goes to, defaults toSDL.ProcessIO.Inherited. -
SDL.Props.ProcessCreateSTDErrPointer: an SDL_IOStream pointer used for standard error whenSDL.Props.ProcessCreateSTDErrNumberis set toSDL.ProcessIO.Redirect. -
SDL.Props.ProcessCreateSTDErrToSTDOutBoolean:trueif the error output of the process should be redirected into the standard output of the process. This property has no effect ifSDL.Props.ProcessCreateSTDErrNumberis set. -
SDL.Props.ProcessCreateBackgroundBoolean:trueif the process should run in the background. In this case the default input and output isSDL.ProcessIO.Nulland the exitcode of the process is not available, and will always be 0. -
SDL.Props.ProcessCreateCMDLineString: a string containing the program to run and any parameters. This string is passed directly toCreateProcesson Windows, and does nothing on other platforms. This property is only important if you want to start programs that does non-standard command-line processing, and in most cases usingSDL.Props.ProcessCreateArgsPointeris sufficient. On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and SIGCHLD should not be ignored or handled because those would prevent SDL from properly tracking the lifetime of the underlying process. You should useSDL.WaitProcessinstead.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
the newly created and running process, or null if the process couldn't be created.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateProcessWithProperties(System.UInt32)
public static uint CreateProperties();SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void);
Create a group of properties.
All properties are automatically destroyed when SDL.Quit is called.
Returns
an ID for a new group of properties, or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateProperties
public static IntPtr CreateRenderer(IntPtr window, string name);SDL declaration
extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);
Create a 2D rendering context for a window.
If you want a specific renderer, you can specify its name here. A list of available renderers can be obtained by calling SDL.GetRenderDriver multiple times, with indices from 0 to SDL.GetNumRenderDrivers-1. If you don't need a specific renderer, specify null and SDL will attempt to choose the best option for you, based on what is available on the user's system.
If name is a comma-separated list, SDL will try each name, in the order listed, until one succeeds or all of them fail.
By default the rendering size matches the window size in pixels, but you can call SDL.SetRenderLogicalPresentation to change the content size and scaling options.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window where rendering is displayed. |
name |
string |
the name of the rendering driver to initialize, or null to let SDL choose one. |
Returns
a valid rendering context or null if there was an error; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateRenderer(System.IntPtr,System.String)
public static IntPtr CreateRendererWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
Create a 2D rendering context for a window, with the specified properties.
These are the supported properties:
-
SDL.Props.RendererCreateNameString: the name of the rendering driver to use, if a specific one is desired -
SDL.Props.RendererCreateWindowPointer: the window where rendering is displayed, required if this isn't a software renderer using a surface -
SDL.Props.RendererCreateSurfacePointer: the surface where rendering is displayed, if you want a software renderer without a window -
SDL.Props.RendererCreateOutputColorspaceNumber: an SDL_Colorspace value describing the colorspace for output to the display, defaults toSDL.Colorspace.SRGB. The direct3d11, direct3d12, and metal renderers supportSDL.Colorspace.SRGBLinear, which is a linear color space and supports HDR output. If you selectSDL.Colorspace.SRGBLinear, drawing still uses the sRGB colorspace, but values can go beyond 1.0 and float (linear) format textures can be used for HDR content. -
SDL.Props.RendererCreatePresentVSyncNumber: non-zero if you want present synchronized with the refresh rate. This property can take any value that is supported bySDL.SetRenderVSyncfor the renderer. With the SDL GPU renderer (since SDL 3.4.0): -
SDL.Props.RendererCreateGPUShadersSPIRVBoolean: the app is able to provide SPIR-V shaders to SDL_GPURenderState, optional. -
SDL.Props.RendererCreateGPUShadersDXILBoolean: the app is able to provide DXIL shaders to SDL_GPURenderState, optional. -
SDL.Props.RendererCreateGPUShadersMSLBoolean: the app is able to provide MSL shaders to SDL_GPURenderState, optional. With the vulkan renderer: -
SDL.Props.RendererCreateVulkanInstancePointer: the VkInstance to use with the renderer, optional. -
SDL.Props.RendererCreateVulkanSurfaceNumber: the VkSurfaceKHR to use with the renderer, optional. -
SDL.Props.RendererCreateVulkanPhysicalDevicePointer: the VkPhysicalDevice to use with the renderer, optional. -
SDL.Props.RendererCreateVulkanDevicePointer: the VkDevice to use with the renderer, optional. -
SDL.Props.RendererCreateVulkanGraphicsQueueFamilyIndexNumber: the queue family index used for rendering. -
SDL.Props.RendererCreateVulkanPresentQueueFamilyIndexNumber: the queue family index used for presentation.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
a valid rendering context or null if there was an error; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateRendererWithProperties(System.UInt32)
public static IntPtr CreateRWLock();SDL declaration
extern SDL_DECLSPEC SDL_RWLock * SDLCALL SDL_CreateRWLock(void);
Create a new read/write lock.
A read/write lock is useful for situations where you have multiple threads trying to access a resource that is rarely updated. All threads requesting a read-only lock will be allowed to run in parallel; if a thread requests a write lock, it will be provided exclusive access. This makes it safe for multiple threads to use a resource at the same time if they promise not to change it, and when it has to be changed, the rwlock will serve as a gateway to make sure those changes can be made safely.
In the right situation, a rwlock can be more efficient than a mutex, which only lets a single thread proceed at a time, even if it won't be modifying the data.
All newly-created read/write locks begin in the unlocked state.
Calls to SDL.LockRWLockForReading and SDL.LockRWLockForWriting will not return while the rwlock is locked for writing by another thread. See SDL.TryLockRWLockForReading and SDL.TryLockRWLockForWriting to attempt to lock without blocking.
SDL read/write locks are only recursive for read-only locks! They are not guaranteed to be fair, or provide access in a FIFO manner! They are not guaranteed to favor writers. You may not lock a rwlock for both read-only and write access at the same time from the same thread (so you can't promote your read-only lock to a write lock without unlocking first).
Returns
the initialized and unlocked read/write lock or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateRWLock
public static IntPtr CreateSemaphore(uint initialValue);SDL declaration
extern SDL_DECLSPEC SDL_Semaphore * SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
Create a semaphore.
This function creates a new semaphore and initializes it with the value initialValue. Each wait operation on the semaphore will atomically decrement the semaphore value and potentially block if the semaphore value is 0. Each post operation will atomically increment the semaphore value and wake waiting threads and allow them to retry the wait operation.
Parameters
| Name | Type | Description |
|---|---|---|
initialValue |
uint |
the starting value of the semaphore. |
Returns
a new semaphore or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSemaphore(System.UInt32)
public static IntPtr CreateSoftwareRenderer(IntPtr surface);SDL declaration
extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);
Create a 2D software rendering context for a surface.
Two other API which can be used to create SDL_Renderer: SDL.CreateRenderer and SDL.CreateWindowAndRenderer. These can also create a software renderer, but they are intended to be used with an SDL_Window as the final destination and not an SDL.Surface.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the SDL.Surface structure representing the surface where rendering is done. |
Returns
a valid rendering context or null if there was an error; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSoftwareRenderer(System.IntPtr)
public static bool CreateStorageDirectory(IntPtr storage, string path);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path);
Create a directory in a writable storage container.
Parameters
| Name | Type | Description |
|---|---|---|
storage |
IntPtr |
a storage container. |
path |
string |
the path of the directory to create. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateStorageDirectory(System.IntPtr,System.String)
public static IntPtr CreateSurface(int width, int height, SDL.PixelFormat format);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormat format);
Allocate a new surface with a specific pixel format.
The pixels of the new surface are initialized to zero.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the surface. |
height |
int |
the height of the surface. |
format |
SDL.PixelFormat |
the SDL.PixelFormat for the new surface's pixel format. |
Returns
the new SDL.Surface structure that is created or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSurface(System.Int32,System.Int32,SDL3.SDL.PixelFormat)
public static IntPtr CreateSurfaceFrom(int width, int height, SDL.PixelFormat format, IntPtr pixels, int pitch);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch);
Allocate a new surface with a specific pixel format and existing pixel data.
No copy is made of the pixel data. Pixel data is not managed automatically; you must free the surface before you free the pixel data.
Pitch is the offset in bytes from one row of pixels to the next, e.g. width*4 for SDL.PixelFormat.RGBA8888.
You may pass null for pixels and 0 for pitch to create a surface that you will fill in with valid values later.
Parameters
| Name | Type | Description |
|---|---|---|
width |
int |
the width of the surface. |
height |
int |
the height of the surface. |
format |
SDL.PixelFormat |
the SDL.PixelFormat for the new surface's pixel format. |
pixels |
IntPtr |
a pointer to existing pixel data. |
pitch |
int |
the number of bytes between each row, including padding. |
Returns
the new SDL.Surface structure that is created or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSurfaceFrom(System.Int32,System.Int32,SDL3.SDL.PixelFormat,System.IntPtr,System.Int32)
public static IntPtr CreateSurfacePalette(IntPtr surface);SDL declaration
extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *surface);
Create a palette and associate it with a surface.
This function creates a palette compatible with the provided surface. The palette is then returned for you to modify, and the surface will automatically use the new palette in future operations. You do not need to destroy the returned palette, it will be freed when the reference count reaches 0, usually when the surface is destroyed.
Bitmap surfaces (with format SDL.PixelFormat.Index1LSB or SDL.PixelFormat.Index1MSB) will have the palette initialized with 0 as white and 1 as black. Other surfaces will get a palette initialized with white in every entry.
If this function is called for a surface that already has a palette, a new palette will be created to replace it.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the SDL.Surface structure to update. |
Returns
a new SDL.Palette structure on success or null on failure (e.g. if the surface didn't have an index format); call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSurfacePalette(System.IntPtr)
public static IntPtr CreateSystemCursor(SDL.SystemCursor id);SDL declaration
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
Create a system cursor.
Parameters
| Name | Type | Description |
|---|---|---|
id |
SDL.SystemCursor |
an SDL.SystemCursor enum value. |
Returns
a cursor on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateSystemCursor(SDL3.SDL.SystemCursor)
public static IntPtr CreateTexture(IntPtr renderer, SDL.PixelFormat format, SDL.TextureAccess access, int w, int h);SDL declaration
extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h);
Create a texture for a rendering context.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
format |
SDL.PixelFormat |
one of the enumerated values in SDL.PixelFormat. |
access |
SDL.TextureAccess |
one of the enumerated values in SDL.TextureAccess
|
w |
int |
the width of the texture in pixels. |
h |
int |
the height of the texture in pixels. |
Returns
the created texture or null on failure; call SDL.GetError for more information.
Remarks
The contents of a texture when first created are not defined.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateTexture(System.IntPtr,SDL3.SDL.PixelFormat,SDL3.SDL.TextureAccess,System.Int32,System.Int32)
public static IntPtr CreateTextureFromSurface(IntPtr renderer, IntPtr surface);SDL declaration
extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
Create a texture from an existing surface.
The surface is not modified or freed by this function.
The SDL.TextureAccess hint for the created texture is SDL.TextureAccess.Static.
The pixel format of the created texture may be different from the pixel format of the surface, and can be queried using the SDL.Props.TextureFormatNumber property.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
surface |
IntPtr |
the SDL.Surface structure containing pixel data used to fill the texture. |
Returns
the created texture or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateTextureFromSurface(System.IntPtr,System.IntPtr)
public static IntPtr CreateTextureWithProperties(IntPtr renderer, uint props);SDL declaration
extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
Create a texture for a rendering context with the specified properties.
These are the supported properties:
-
SDL.Props.TextureCreateColorspaceNumber: anSDL.Colorspacevalue describing the texture colorspace, defaults toSDL.Colorspace.SRGBLinearfor floating point textures,SDL.Colorspace.HDR10for 10-bit textures,SDL.Colorspace.SRGBfor other RGB textures andSDL.Colorspace.JPEGfor YUV textures. -
SDL.Props.TextureCreateFormatNumber: one of the enumerated values inSDL.PixelFormat, defaults to the best RGBA format for the renderer -
SDL.Props.TextureCreateAccessNumber: one of the enumerated values inSDL.TextureAccess, defaults toSDL.TextureAccess.Static -
SDL.Props.TextureCreateWidthNumber: the width of the texture in pixels, required -
SDL.Props.TextureCreateHeightNumber: the height of the texture in pixels, required -
SDL.Props.TextureCreatePalettePointer: an SDL_Palette to use with palettized texture formats. This can be set later withSDL.SetTexturePalette -
SDL.Props.TextureCreateSDRWhitePointFloat: for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 textures and 1.0 for floating point textures. -
SDL.Props.TextureCreateHDRHeadroomFloat: for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This would be equivalent to maxCLL /SDL.Props.TextureCreateSDRWhitePointFloatfor HDR10 content. If this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped. With the direct3d11 renderer: -
SDL.Props.TextureCreateD3D11TexturePointer: the ID3D11Texture2D associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateD3D11TextureUPointer: the ID3D11Texture2D associated with the U plane of a YUV texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateD3D11TextureVPointer: the ID3D11Texture2D associated with the V plane of a YUV texture, if you want to wrap an existing texture. With the direct3d12 renderer: -
SDL.Props.TextureCreateD3D12TexturePointer: the ID3D12Resource associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateD3D12TextureUPointer: the ID3D12Resource associated with the U plane of a YUV texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateD3D12TextureVPointer: the ID3D12Resource associated with the V plane of a YUV texture, if you want to wrap an existing texture. With the metal renderer: -
SDL.Props.TextureCreateMetalPixelbufferPointer: the CVPixelBufferRef associated with the texture, if you want to create a texture from an existing pixel buffer. With the opengl renderer: -
SDL.Props.TextureCreateOpenGLTextureNumberthe GLuint texture associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLTextureUVNumber: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGlTextureUNumber: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLTextureVNumber: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture. With the opengles2 renderer: -
SDL.Props.TextureCreateOpenGLES2TextureNumber: the GLuint texture associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLES2TextureNumber: the GLuint texture associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLES2TextureUVNumber: the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLES2TextureUNumber: the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateOpenGLES2TextureVNumber: the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture. With the vulkan renderer: -
SDL.Props.TextureCreateVulkanTextureNumber: the VkImage with layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if you want to wrap an existing texture. With the GPU renderer: -
SDL.Props.TextureCreateGPUTexturePointer: the SDL_GPUTexture associated with the texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateGPUTextureUVNumber: the SDL_GPUTexture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateGPUTextureUNumber: the SDL_GPUTexture associated with the U plane of a YUV texture, if you want to wrap an existing texture. -
SDL.Props.TextureCreateGPUTextureVNumber: the SDL_GPUTexture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
props |
uint |
the properties to use. |
Returns
the created texture or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateTextureWithProperties(System.IntPtr,System.UInt32)
public static IntPtr CreateThread(SDL.ThreadFunction fn, string name, IntPtr data);SDL declaration
extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
Create a new thread with a default stack size.
This is a convenience function, equivalent to calling SDL.CreateThreadWithProperties with the following properties set:
-
SDL.Props.ThreadCreateEntryFunctionPointer:fn -
SDL.Props.ThreadCreateNameString:name -
SDL.Props.ThreadCreateUserdataPointer:dataNote that this "function" is actually a macro that calls an internal function with two extra parameters not listed here; they are hidden through preprocessor macros and are needed to support various C runtimes at the point of the function call. Language bindings that aren't using the C headers will need to deal with this.
Usually, apps should just call this function the same way on every platform and let the macros hide the details.
Parameters
| Name | Type | Description |
|---|---|---|
fn |
SDL.ThreadFunction |
the SDL.ThreadFunction function to call in the new thread. |
name |
string |
the name of the thread. |
data |
IntPtr |
a pointer that is passed to fn. |
Returns
an opaque pointer to the new thread object on success, null if the new thread could not be created; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateThread(SDL3.SDL.ThreadFunction,System.String,System.IntPtr)
public static IntPtr CreateThreadRuntime(SDL.ThreadFunction fn, string name, IntPtr data, IntPtr pfnBeginThread, IntPtr pfnEndThread);SDL declaration
extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadRuntime(SDL_ThreadFunction fn, const char *name, void *data, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread);
The actual entry point for SDL_CreateThread.
Parameters
| Name | Type | Description |
|---|---|---|
fn |
SDL.ThreadFunction |
the SDL.ThreadFunction function to call in the new thread |
name |
string |
the name of the thread |
data |
IntPtr |
a pointer that is passed to fn
|
pfnBeginThread |
IntPtr |
the C runtime's _beginthreadex (or whatnot). Can be null. |
pfnEndThread |
IntPtr |
the C runtime's _endthreadex (or whatnot). Can be null. |
Returns
an opaque pointer to the new thread object on success, null if the new thread could not be created; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateThreadRuntime(SDL3.SDL.ThreadFunction,System.String,System.IntPtr,System.IntPtr,System.IntPtr)
public static IntPtr CreateThreadWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithProperties(SDL_PropertiesID props);
Create a new thread with with the specified properties.
These are the supported properties:
-
SDL.Props.ThreadCreateEntryFunctionPointer: an SDL_ThreadFunction value that will be called at the start of the new thread's life. Required. -
SDL.Props.ThreadCreateNameString: the name of the new thread, which might be available to debuggers. Optional, defaults tonull. -
SDL.Props.ThreadCreateUserdataPointer: an arbitrary app-defined pointer, which is passed to the entry function on the new thread, as its only parameter. Optional, defaults tonull. -
SDL.Props.ThreadCreateStacksizeNumber: the size, in bytes, of the new thread's stack. Optional, defaults to 0 (system-defined default). SDL makes an attempt to reportSDL.Props.ThreadCreateNameStringto the system, so that debuggers can display it. Not all platforms support this.
Thread naming is a little complicated: Most systems have very small limits for the string length (Haiku has 32 bytes, Linux currently has 16, Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll have to see what happens with your system's debugger. The name should be UTF-8 (but using the naming limits of C identifiers is a better bet). There are no requirements for thread naming conventions, so long as the string is null-terminated UTF-8, but these guidelines are helpful in choosing a name:
https://stackoverflow.com/questions/149932/naming-conventions-for-threads
If a system imposes requirements, SDL will try to munge the string for it (truncate, etc), but the original string contents will be available from SDL.GetThreadName.
The size (in bytes) of the new stack can be specified with SDL.Props.ThreadCreateStacksizeNumber. Zero means "use the system default" which might be wildly different between platforms. x86 Linux generally defaults to eight megabytes, an embedded device might be a few kilobytes instead. You generally need to specify a stack that is a multiple of the system's page size (in many cases, this is 4 kilobytes, but check your system documentation).
Note that this "function" is actually a macro that calls an internal function with two extra parameters not listed here; they are hidden through preprocessor macros and are needed to support various C runtimes at the point of the function call. Language bindings that aren't using the C headers will need to deal with this.
The actual symbol in SDL is SDL.CreateThreadWithPropertiesRuntime, so there is no symbol clash, but trying to load an SDL shared library and look for SDL.CreateThreadWithProperties will fail.
Usually, apps should just call this function the same way on every platform and let the macros hide the details.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
an opaque pointer to the new thread object on success, null if the new thread could not be created; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateThreadWithProperties(System.UInt32)
public static IntPtr CreateThreadWithPropertiesRuntime(uint props, IntPtr pfnBeginThread, IntPtr pfnEndThread);SDL declaration
extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithPropertiesRuntime(SDL_PropertiesID props, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread);
The actual entry point for SDL.CreateThreadWithProperties.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use |
pfnBeginThread |
IntPtr |
the C runtime's _beginthreadex (or whatnot). Can be null. |
pfnEndThread |
IntPtr |
the C runtime's _endthreadex (or whatnot). Can be null. |
Returns
an opaque pointer to the new thread object on success, null if the new thread could not be created; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateThreadWithPropertiesRuntime(System.UInt32,System.IntPtr,System.IntPtr)
public static IntPtr CreateTray(IntPtr icon, string tooltip);SDL declaration
extern SDL_DECLSPEC SDL_Tray *SDLCALL SDL_CreateTray(SDL_Surface *icon, const char *tooltip);
Create an icon to be placed in the operating system's tray, or equivalent.
Many platforms advise not using a system tray unless persistence is a necessary feature. Avoid needlessly creating a tray icon, as the user may feel like it clutters their interface.
Using tray icons require the video subsystem.
Parameters
| Name | Type | Description |
|---|---|---|
icon |
IntPtr |
a surface to be used as icon. May be null. |
tooltip |
string |
a tooltip to be displayed when the mouse hovers the icon in UTF-8 encoding. Not supported on all platforms. May be null. |
Returns
The newly created system tray icon.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.CreateTray(System.IntPtr,System.String)
public static IntPtr CreateTrayMenu(IntPtr tray);SDL declaration
extern SDL_DECLSPEC SDL_TrayMenu *SDLCALL SDL_CreateTrayMenu(SDL_Tray *tray);
Create a menu for a system tray.
This should be called at most once per tray icon.
This function does the same thing as SDL.CreateTraySubmenu, except that it takes a SDL_Tray instead of a SDL_TrayEntry.
A menu does not need to be destroyed; it will be destroyed with the tray.
Parameters
| Name | Type | Description |
|---|---|---|
tray |
IntPtr |
the tray to bind the menu to. |
Returns
the newly created menu.
Thread safety
This function should be called on the thread that created the tray.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.CreateTrayMenu(System.IntPtr)
public static IntPtr CreateTraySubmenu(IntPtr entry);SDL declaration
extern SDL_DECLSPEC SDL_TrayMenu *SDLCALL SDL_CreateTraySubmenu(SDL_TrayEntry *entry);
Create a submenu for a system tray entry.
This should be called at most once per tray entry.
This function does the same thing as SDL.CreateTrayMenu, except that it takes a SDL_TrayEntry instead of a SDL_Tray.
A menu does not need to be destroyed; it will be destroyed with the tray.
Parameters
| Name | Type | Description |
|---|---|---|
entry |
IntPtr |
the tray entry to bind the menu to. |
Returns
the newly created menu.
Thread safety
This function should be called on the thread that created the tray.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.CreateTraySubmenu(System.IntPtr)
public static IntPtr CreateWindow(string title, int w, int h, SDL.WindowFlags flags);SDL declaration
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags);
Create a window with the specified dimensions and flags.
The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.
flags may be any of the following OR'd together:
-
SDL.WindowFlags.Fullscreen: fullscreen window at desktop resolution -
SDL.WindowFlags.OpenGL: window usable with an OpenGL context -
SDL.WindowFlags.Hidden: window is not visible -
SDL.WindowFlags.Borderless: no window decoration -
SDL.WindowFlags.Resizable: window can be resized -
SDL.WindowFlags.Minimized: window is minimized -
SDL.WindowFlags.Maximized: window is maximized -
SDL.WindowFlags.MouseGrabbed: window has grabbed mouse focus -
SDL.WindowFlags.InputFocus: window has input focus -
SDL.WindowFlags.MouseFocus: window has mouse focus -
SDL.WindowFlags.External: window not created by SDL -
SDL.WindowFlags.Modal: window is modal -
SDL.WindowFlags.HighPixelDensity: window uses high pixel density back buffer if possible -
SDL.WindowFlags.MouseCapture: window has mouse captured (unrelated toSDL.WindowFlags.MouseGrabbed) -
SDL.WindowFlags.AlwaysOnTop: window should always be above others -
SDL.WindowFlags.Utility: window should be treated as a utility window, not showing in the task bar and window list -
SDL.WindowFlags.Tooltip: window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window -
SDL.WindowFlags.PopupMenu: window should be treated as a popup menu, requires a parent window -
SDL.WindowFlags.KeyboardGrabbed: window has grabbed keyboard input -
SDL.WindowFlags.Vulkan: window usable with a Vulkan instance -
SDL.WindowFlags.Metal: window usable with a Metal instance -
SDL.WindowFlags.Transparent: window with transparent buffer -
SDL.WindowFlags.NotFocusable: window should not be focusable The SDL_Window will be shown ifSDL.WindowFlags.Hiddenis not set. If hidden at creation time,SDL.ShowWindowcan be used to show it later.
On Apple's macOS, you must set the NSHighResolutionCapable Info.plist property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
The window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use SDL.GetWindowSize to query the client area's size in window coordinates, and SDL.GetWindowSizeInPixels or SDL.GetRenderOutputSize to query the drawable size in pixels. Note that the drawable size can vary after the window is created and should be queried again if you get an SDL.EventType.WindowPixelSizeChanged event.
If the window is created with any of the SDL.WindowFlags.OpenGL or SDL.WindowFlags.Vulkan flags, then the corresponding LoadLibrary function (SDL.GLLoadLibrary or SDL.VulkanLoadLibrary) is called and the corresponding UnloadLibrary function is called by SDL.DestroyWindow.
If SDL.WindowFlags.Vulkan is specified and there isn't a working Vulkan driver, SDL.CreateWindow will fail, because SDL.VulkanLoadLibrary will fail.
If SDL.WindowFlags.Metal is specified on an OS that does not support Metal, SDL.CreateWindow will fail.
If you intend to use this window with an SDL_Renderer, you should use SDL.CreateWindowAndRenderer instead of this function, to avoid window flicker.
On non-Apple devices, SDL requires you to either not link to the Vulkan loader or link to a dynamic library version. This limitation may be removed in a future version of SDL.
Parameters
| Name | Type | Description |
|---|---|---|
title |
string |
the title of the window, in UTF-8 encoding. |
w |
int |
the width of the window. |
h |
int |
the height of the window. |
flags |
SDL.WindowFlags |
0, or one or more SDL.WindowFlags OR'd together. |
Returns
the window that was created or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateWindow(System.String,System.Int32,System.Int32,SDL3.SDL.WindowFlags)
public static bool CreateWindowAndRenderer(string title, int width, int height, SDL.WindowFlags windowFlags, out IntPtr window, out IntPtr renderer);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer);
Create a window and default renderer.
Parameters
| Name | Type | Description |
|---|---|---|
title |
string |
the title of the window, in UTF-8 encoding. |
width |
int |
the width of the window. |
height |
int |
the height of the window. |
windowFlags |
SDL.WindowFlags |
the flags used to create the window (see SDL.CreateWindow). |
window |
out IntPtr |
a pointer filled with the window, or null on error. |
renderer |
out IntPtr |
a pointer filled with the renderer, or null on error. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateWindowAndRenderer(System.String,System.Int32,System.Int32,SDL3.SDL.WindowFlags,System.IntPtr@,System.IntPtr@)
public static IntPtr CreateWindowWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_PropertiesID props);
Create a window with the specified properties.
These are the supported properties:
-
SDL.Props.WindowCreateAlwaysOnTopBoolean:trueif the window should be always on top -
SDL.Props.WindowCreateBorderlessBoolean:trueif the window has no window decoration -
SDL.Props.WindowCreateExternalGraphicsContextBoolean:trueif the window will be used with an externally managed graphics context. -
SDL.Props.WindowCreateFocusableBoolean:trueif the window should accept keyboard input (defaultstrue) -
SDL.Props.WindowCreateFullscreenBoolean:trueif the window should start in fullscreen mode at desktop resolution -
SDL.Props.WindowCreateHeightNumber: the height of the window -
SDL.Props.WindowCreateHiddenBoolean:trueif the window should start hidden -
SDL.Props.WindowCreateHighPixelDensityBoolean:trueif the window uses a high pixel density buffer if possible -
SDL.Props.WindowCreateMaximizedBoolean:trueif the window should start maximized -
SDL.Props.WindowCreateMenuBoolean:trueif the window is a popup menu -
SDL.Props.WindowCreateMetalBoolean:trueif the window will be used with Metal rendering -
SDL.Props.WindowCreateMinimizedBoolean:trueif the window should start minimized -
SDL.Props.WindowCreateModalBoolean:trueif the window is modal to its parent -
SDL.Props.WindowCreateMouseGrabbedBoolean:trueif the window starts with grabbed mouse focus -
SDL.Props.WindowCreateOpenGLBoolean:trueif the window will be used with OpenGL rendering -
SDL.Props.WindowCreateParentPointer: an SDL_Window that will be the parent of this window, required for windows with the"tooltip,"``"menu", and"modal"properties -
SDL.Props.WindowCreateResizableBoolean:trueif the window should be resizable -
SDL.Props.WindowCreateTitleString: the title of the window, in UTF-8 encoding -
SDL.Props.WindowCreateTransparentBoolean:trueif the window show transparent in the areas with alpha of 0 -
SDL.Props.WindowCreateTooltipBoolean:trueif the window is a tooltip -
SDL.Props.WindowCreateUtilityBoolean:trueif the window is a utility window, not showing in the task bar and window list -
SDL.Props.WindowCreateVulkanBoolean:trueif the window will be used with Vulkan rendering -
SDL.Props.WindowCreateWidthNumber: the width of the window -
SDL.Props.WindowCreateXNumber: the x position of the window, orSDL.WindowPosCentered, defaults toSDL.WindowPosUndefined. This is relative to the parent for windows with the"tooltip"or"menu"property set. -
SDL.Props.WindowCreateYNumber: the y position of the window, orSDL.WindowPosCentered, defaults toSDL.WindowPosUndefined. This is relative to the parent for windows with the"tooltip"or"menu"property set. These are additional supported properties on macOS: -
SDL.Props.WindowCreateCocoaWindowPointer: the(__unsafe_unretained)NSWindow associated with the window, if you want to wrap an existing window. -
SDL.Props.WindowCreateCocoaViewPointer: the(__unsafe_unretained)NSView associated with the window, defaults to[window contentView]These are additional supported properties on iOS, tvOS, and visionOS: -
SDL.Props.WindowCreateWindowScenePointer: the(__unsafe_unretained)UIWindowScene associated with the window, defaults to the active window scene. These are additional supported properties with visionOS: -
SDL.Props.WindowCreateVisionOSSettingsString: the settings of the window in JSON format. If this isn't set, the window will have standard UIKit behavior. If this is set to""or a valid setting string then the window is created with enhanced features allowing curved display. The curvature in the settings is defined as a radius in millimeters. A common value for a gaming monitor is 1000 and a setting string for that would be"{\"curvatureRadius\":1000}". These are additional supported properties on Wayland: -
SDL.Props.WindowCreateWaylandSurfaceRoleCustomBoolean-trueif the application wants to use the Wayland surface for a custom role and does not want it attached to an XDG toplevel window. See README-wayland for more information on using custom surfaces. -
SDL.Props.WindowCreateWaylandCreateEGLWindowBoolean-trueif the application wants an associatedwl_egl_windowobject to be created and attached to the window, even if the window does not have the OpenGL property orSDL.WindowFlags.OpenGLflag set. -
SDL.Props.WindowCreateWaylandWLSurfacePointer- the wl_surface associated with the window, if you want to wrap an existing window. See README-wayland for more information. These are additional supported properties on Windows: -
SDL.Props.WindowCreateWin32HWNDPointer: the HWND associated with the window, if you want to wrap an existing window. -
`SDL.Props.WindowCreateWin32PixelFormatHWNDPointer``: optional, another window to share pixel format with, useful for OpenGL windows These are additional supported properties with X11:
-
SDL.Props.WindowCreateX11WindowNumber: the X11 Window associated with the window, if you want to wrap an existing window. The window is implicitly shown if the"hidden"property is not set.
These are additional supported properties with Emscripten:
-
SDL.Props.WindowCreateEmscriptennCanvasIdString: the id given to the canvas element. This should start with a#sign -
SDL.Props.WindowCreateEmscriptenKeyboardElementString: override the binding element for keyboard inputs for this canvas. The variable can be one of: -
"#window": the javascript window object (default) -
"#document": the javascript document object -
"#screen": the javascript window.screen object -
"#canvas": the WebGL canvas element -
"#none": Don't bind anything at all - any other string without a leading # sign applies to the element on the page with that ID. Windows with the "tooltip" and "menu" properties are popup windows and have the behaviors and guidelines outlined in
SDL.CreatePopupWindow. Windows with the"tooltip"and"menu"properties are popup windows and have the behaviors and guidelines outlined inSDL.CreatePopupWindow.
If this window is being created to be used with an SDL_Renderer, you should not add a graphics API specific property (SDL.Props.WindowCreateOpenGLBoolean, etc), as SDL will handle that internally when it chooses a renderer. However, SDL might need to recreate your window at that point, which may cause the window to appear briefly, and then flicker as it is recreated. The correct approach to this is to create the window with the SDL.Props.WindowCreateHiddenBoolean property set to true, then create the renderer, then show the window with SDL.ShowWindow.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
the window that was created or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CreateWindowWithProperties(System.UInt32)
public static bool CursorVisible();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void);
Return whether the cursor is currently being shown.
Returns
true if the cursor is being shown, or false if the cursor is hidden.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.CursorVisible
public static bool DateTimeToTime(in SDL.DateTime dt, out long ticks);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks);
Converts a calendar time to an SDL_Time in nanoseconds since the epoch.
This function ignores the day_of_week member of the SDL.DateTime struct, so it may remain unset.
Parameters
| Name | Type | Description |
|---|---|---|
dt |
in SDL.DateTime |
the source SDL.DateTime. |
ticks |
out long |
the resulting SDL_Time. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DateTimeToTime(SDL3.SDL.DateTime@,System.Int64@)
public static ushort DefineAudioFormat(bool signed, bool bigendian, bool flt, int size);Define an SDL.AudioFormat value.
SDL does not support custom audio formats, so this macro is not of much use externally, but it can be illustrative as to what the various bits of an SDL.AudioFormat mean.
For example, SDL.AudioFormat.AudioS32LE looks like this:
c DefineAudioFormat(1, 0, 0, 32)
Parameters
| Name | Type | Description |
|---|---|---|
signed |
bool |
1 for signed data, 0 for unsigned data. |
bigendian |
bool |
1 for bigendian data, 0 for littleendian data. |
flt |
bool |
1 for floating point data, 0 for integer data. |
size |
int |
number of bits per sample. |
Returns
a format value in the style of SDL.AudioFormat.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DefineAudioFormat(System.Boolean,System.Boolean,System.Boolean,System.Int32)
public static SDL.Colorspace DefineColorspace(SDL.ColorType type, SDL.ColorRange range, SDL.ColorPrimaries primaries, SDL.TransferCharacteristics transfer, SDL.MatrixCoefficients matrix, SDL.ChromaLocation chroma);A macro for defining custom SDL.Colorspace formats.
For example, defining SDL.Colorspace.SRGB looks like this:
c DefineColorspace(ColorType.RGB, ColorRange.Full, ColorPrimaries.BT709, TransferCharacteristics.SRGB, MatrixCoefficients.Identity, ChromaLocation.None)
Parameters
| Name | Type | Description |
|---|---|---|
type |
SDL.ColorType |
the type of the new format, probably an SDL.ColorType value. |
range |
SDL.ColorRange |
the range of the new format, probably a SDL.ColorRange value. |
primaries |
SDL.ColorPrimaries |
the primaries of the new format, probably an SDL.ColorPrimaries value. |
transfer |
SDL.TransferCharacteristics |
the transfer characteristics of the new format, probably an SDL.TransferCharacteristics value. |
matrix |
SDL.MatrixCoefficients |
the matrix coefficients of the new format, probably an SDL.MatrixCoefficients value. |
chroma |
SDL.ChromaLocation |
the chroma sample location of the new format, probably an SDL.ChromaLocation value. |
Returns
a format value in the style of SDL.ColorRange.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DefineColorspace(SDL3.SDL.ColorType,SDL3.SDL.ColorRange,SDL3.SDL.ColorPrimaries,SDL3.SDL.TransferCharacteristics,SDL3.SDL.MatrixCoefficients,SDL3.SDL.ChromaLocation)
public static SDL.PixelFormat DefinePixelFormat(SDL.PixelType type, byte order, SDL.PackedLayout layout, byte bits, byte bytes);A macro for defining custom non-FourCC pixel formats.
For example, defining SDL.PixelFormat.RGBA8888 looks like this:
c DefinePixelFormat(PixelType.Packed32, PackedOrder.RGBA, PackedLayout.Layout8888, 32, 4)
Parameters
| Name | Type | Description |
|---|---|---|
type |
SDL.PixelType |
the type of the new format, probably a SDL.PixelType value. |
order |
byte |
the order of the new format, probably a SDL.BitmapOrder, SDL.PackedOrder, or SDL.ArrayOrder value. |
layout |
SDL.PackedLayout |
the layout of the new format, probably an SDL.PackedLayout value or zero. |
bits |
byte |
the number of bits per pixel of the new format. |
bytes |
byte |
the number of bytes per pixel of the new format. |
Returns
a format value in the style of SDL.PixelFormat
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DefinePixelFormat(SDL3.SDL.PixelType,System.Byte,SDL3.SDL.PackedLayout,System.Byte,System.Byte)
public static SDL.PixelFormat DefinePixelFourCC(char a, char b, char c, char d);A macro for defining custom FourCC pixel formats.
For example, defining SDL.PixelFormat.YV12 looks like this:
c DefinePixelFourCC('Y', 'V', '1', '2')
Parameters
| Name | Type | Description |
|---|---|---|
a |
char |
the first character of the FourCC code. |
b |
char |
the second character of the FourCC code. |
c |
char |
the third character of the FourCC code. |
d |
char |
the fourth character of the FourCC code. |
Returns
a format value in the style of SDL.PixelFormat.
Thread safety
It is safe to call this macro from any thread.
Since: This macro is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DefinePixelFourCC(System.Char,System.Char,System.Char,System.Char)
public static void Delay(uint ms);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
Wait a specified number of milliseconds before returning.
This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling.
Parameters
| Name | Type | Description |
|---|---|---|
ms |
uint |
the number of milliseconds to delay. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.Delay(System.UInt32)
public static void DelayNS(ulong ns);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DelayNS(Uint64 ns);
Wait a specified number of nanoseconds before returning.
This function waits a specified number of nanoseconds before returning. It waits at least the specified time, but possibly longer due to OS scheduling.
Parameters
| Name | Type | Description |
|---|---|---|
ns |
ulong |
the number of nanoseconds to delay. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DelayNS(System.UInt64)
public static void DelayPrecise(ulong ns);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DelayPrecise(Uint64 ns);
Wait a specified number of nanoseconds before returning.
This function waits a specified number of nanoseconds before returning. It will attempt to wait as close to the requested time as possible, busy waiting if necessary, but could return later due to OS scheduling.
Parameters
| Name | Type | Description |
|---|---|---|
ns |
ulong |
the number of nanoseconds to delay. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.6.
XML member id: M:SDL3.SDL.DelayPrecise(System.UInt64)
public static void DestroyAsyncIOQueue(IntPtr queue);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyAsyncIOQueue(SDL_AsyncIOQueue *queue);
Destroy a previously-created async I/O task queue.
If there are still tasks pending for this queue, this call will block until those tasks are finished. All those tasks will be deallocated. Their results will be lost to the app.
Any pending reads from SDL.LoadFileAsync that are still in this queue will have their buffers deallocated by this function, to prevent a memory leak.
Once this function is called, the queue is no longer valid and should not be used, including by other threads that might access it while destruction is blocking on pending tasks.
Do not destroy a queue that still has threads waiting on it through SDL.WaitAsyncIOResult. You can call SDL.SignalAsyncIOQueue first to unblock those threads, and take measures (such as SDL.WaitThread) to make sure they have finished their wait and won't wait on the queue again.
Parameters
| Name | Type | Description |
|---|---|---|
queue |
IntPtr |
the task queue to destroy. |
Thread safety
It is safe to call this function from any thread, so long as no other thread is waiting on the queue with SDL.WaitAsyncIOResult.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.DestroyAsyncIOQueue(System.IntPtr)
public static void DestroyAudioStream(IntPtr stream);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
Free an audio stream.
This will release all allocated data, including any audio that is still queued. You do not need to manually clear the stream first.
If this stream was bound to an audio device, it is unbound during this call. If this stream was created with SDL.OpenAudioDeviceStream, the audio device that was opened alongside this stream's creation will be closed, too.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to destroy. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyAudioStream(System.IntPtr)
public static void DestroyCondition(IntPtr cond);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_Condition *cond);
Destroy a condition variable.
Parameters
| Name | Type | Description |
|---|---|---|
cond |
IntPtr |
the condition variable to destroy. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyCondition(System.IntPtr)
public static void DestroyCursor(IntPtr cursor);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor);
Free a previously-created cursor.
Use this function to free cursor resources created with SDL.CreateCursor, SDL.CreateColorCursor or SDL.CreateSystemCursor.
Parameters
| Name | Type | Description |
|---|---|---|
cursor |
IntPtr |
the cursor to free. |
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyCursor(System.IntPtr)
public static void DestroyEnvironment(IntPtr env);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyEnvironment(SDL_Environment *env);
Destroy a set of environment variables.
Parameters
| Name | Type | Description |
|---|---|---|
env |
IntPtr |
the environment to destroy. |
Thread safety
It is safe to call this function from any thread, as long as the environment is no longer in use.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyEnvironment(System.IntPtr)
public static void DestroyGPUDevice(IntPtr device);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
Destroys a GPU context previously returned by SDL_CreateGPUDevice.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU Context to destroy. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyGPUDevice(System.IntPtr)
public static void DestroyGPURenderState(IntPtr state);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state);
Destroy custom GPU render state.
Parameters
| Name | Type | Description |
|---|---|---|
state |
IntPtr |
state the state to destroy. |
Thread safety
This function should be called on the thread that created the renderer.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.DestroyGPURenderState(System.IntPtr)
public static void DestroyHapticEffect(IntPtr haptic, int effect);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int effect);
Destroy a haptic effect on the device.
This will stop the effect if it's running. Effects are automatically destroyed when the device is closed.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic device to destroy the effect on. |
effect |
int |
the ID of the haptic effect to destroy. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyHapticEffect(System.IntPtr,System.Int32)
public static void DestroyMutex(IntPtr mutex);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_Mutex *mutex);
Destroy a mutex created with SDL.CreateMutex.
This function must be called on any mutex that is no longer needed. Failure to destroy a mutex will result in a system memory or resource leak. While it is safe to destroy a mutex that is unlocked, it is not safe to attempt to destroy a locked mutex, and may result in undefined behavior depending on the platform.
Parameters
| Name | Type | Description |
|---|---|---|
mutex |
IntPtr |
the mutex to destroy. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyMutex(System.IntPtr)
public static void DestroyPalette(IntPtr palette);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette);
Free a palette created with SDL.CreatePalette.
Parameters
| Name | Type | Description |
|---|---|---|
palette |
IntPtr |
the SDL.Palette structure to be freed. |
Thread safety
It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyPalette(System.IntPtr)
public static void DestroyProcess(IntPtr process);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyProcess(SDL_Process *process);
Destroy a previously created process object.
Note that this does not stop the process, just destroys the SDL object used to track it. If you want to stop the process you should use SDL.KillProcess.
Parameters
| Name | Type | Description |
|---|---|---|
process |
IntPtr |
The process object to destroy. |
Thread safety
This function is not thread safe.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyProcess(System.IntPtr)
public static void DestroyProperties(uint props);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyProperties(SDL_PropertiesID props);
Destroy a group of properties.
All properties are deleted and their cleanup functions will be called, if any.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to destroy. |
Thread safety
This function should not be called while these properties are locked or other threads might be setting or getting values from these properties.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyProperties(System.UInt32)
public static void DestroyRenderer(IntPtr renderer);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
Destroy the rendering context for a window and free all associated textures.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyRenderer(System.IntPtr)
public static void DestroyRWLock(IntPtr rwlock);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyRWLock(SDL_RWLock *rwlock);
Destroy a read/write lock created with SDL.CreateRWLock.
This function must be called on any read/write lock that is no longer needed. Failure to destroy a rwlock will result in a system memory or resource leak. While it is safe to destroy a rwlock that is unlocked, it is not safe to attempt to destroy a locked rwlock, and may result in undefined behavior depending on the platform.
Parameters
| Name | Type | Description |
|---|---|---|
rwlock |
IntPtr |
the rwlock to destroy. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyRWLock(System.IntPtr)
public static void DestroySemaphore(IntPtr sem);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
Destroy a semaphore.
It is not safe to destroy a semaphore if there are threads currently waiting on it.
Parameters
| Name | Type | Description |
|---|---|---|
sem |
IntPtr |
the semaphore to destroy. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroySemaphore(System.IntPtr)
public static void DestroySurface(IntPtr surface);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
Free a surface.
It is safe to pass null to this function.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the SDL.Surface to free. |
Thread safety
No other thread should be using the surface when it is freed.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroySurface(System.IntPtr)
public static void DestroyTexture(IntPtr texture);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
Destroy the specified texture.
Passing null or an otherwise invalid texture will set the SDL error message to "Invalid texture".
Parameters
| Name | Type | Description |
|---|---|---|
texture |
IntPtr |
the texture to destroy. |
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyTexture(System.IntPtr)
public static void DestroyTray(IntPtr tray);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyTray(SDL_Tray *tray);
Destroys a tray object.
This also destroys all associated menus and entries.
Parameters
| Name | Type | Description |
|---|---|---|
tray |
IntPtr |
the tray icon to be destroyed. |
Thread safety
This function should be called on the thread that created the tray.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.DestroyTray(System.IntPtr)
public static void DestroyWindow(IntPtr window);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
Destroy a window.
Any child windows owned by the window will be recursively destroyed as well.
Note that on some platforms, the visible window may not actually be removed from the screen until the SDL event loop is pumped again, even though the SDL_Window is no longer valid after this call.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to destroy. |
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyWindow(System.IntPtr)
public static bool DestroyWindowSurface(IntPtr window);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
Destroy the surface associated with the window.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to update. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DestroyWindowSurface(System.IntPtr)
public static void DetachThread(IntPtr thread);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread *thread);
Let a thread clean up on exit without intervention.
A thread may be "detached" to signify that it should not remain until another thread has called SDL.WaitThread on it. Detaching a thread is useful for long-running threads that nothing needs to synchronize with or further manage. When a detached thread is done, it simply goes away.
There is no way to recover the return code of a detached thread. If you need this, don't detach the thread and instead use SDL.WaitThread.
Once a thread is detached, you should usually assume the SDL_Thread isn't safe to reference again, as it will become invalid immediately upon the detached thread's exit, instead of remaining until someone has called SDL.WaitThread to finally clean it up. As such, don't detach the same thread more than once.
If a thread has already exited when passed to SDL.DetachThread, it will stop waiting for a call to SDL.WaitThread and clean up immediately. It is not safe to detach a thread that might be used with SDL.WaitThread.
You may not call SDL.WaitThread on a thread that has been detached. Use either that function or this one, but not both, or behavior is undefined.
It is safe to pass null to this function; it is a no-op.
Parameters
| Name | Type | Description |
|---|---|---|
thread |
IntPtr |
the SDL_Thread pointer that was returned from the SDL.CreateThread call that started this thread. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DetachThread(System.IntPtr)
public static bool DetachVirtualJoystick(uint instanceId);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
Detach a virtual joystick.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the joystick instance ID, previously returned from SDL.AttachVirtualJoystick. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DetachVirtualJoystick(System.UInt32)
public static bool DisableScreenSaver();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_DisableScreenSaver(void);
Prevent the screen from being blanked by a screen saver.
If you disable the screensaver, it is automatically re-enabled when SDL quits.
Returns
true on success or false on failure; call SDL.GetError for more information.
Remarks
The screensaver is disabled by default, but this may by changed by SDL.Hints.VideoAllowScreensaver.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DisableScreenSaver
public static void DispatchGPUCompute(IntPtr computePass, uint groupcountX, uint groupcountY, uint groupcountZ);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(SDL_GPUComputePass *compute_pass, Uint32 groupcount_x, Uint32 groupcount_y, Uint32 groupcount_z);
Dispatches compute work.
You must not call this function before binding a compute pipeline.
A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and the dispatches write to the same resource region as each other, there is no guarantee of which order the writes will occur. If the write order matters, you MUST end the compute pass and begin another one.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
groupcountX |
uint |
number of local workgroups to dispatch in the X dimension. |
groupcountY |
uint |
number of local workgroups to dispatch in the Y dimension. |
groupcountZ |
uint |
number of local workgroups to dispatch in the Z dimension. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DispatchGPUCompute(System.IntPtr,System.UInt32,System.UInt32,System.UInt32)
public static void DispatchGPUComputeIndirect(IntPtr computePass, IntPtr buffer, uint offset);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(SDL_GPUComputePass *compute_pass, SDL_GPUBuffer *buffer, Uint32 offset);
Dispatches compute work with parameters set from a buffer.
The buffer layout should match the layout of SDL.GPUIndirectDispatchCommand. You must not call this function before binding a compute pipeline.
A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and the dispatches write to the same resource region as each other, there is no guarantee of which order the writes will occur. If the write order matters, you MUST end the compute pass and begin another one.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
buffer |
IntPtr |
a buffer containing dispatch parameters. |
offset |
uint |
the offset to start reading from the dispatch buffer. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DispatchGPUComputeIndirect(System.IntPtr,System.IntPtr,System.UInt32)
public static void DownloadFromGPUBuffer(IntPtr copyPass, in SDL.GPUTextureRegion source, in SDL.GPUTransferBufferLocation destination);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferRegion *source, const SDL_GPUTransferBufferLocation *destination);
Copies data from a buffer to a transfer buffer on the GPU timeline.
This data is not guaranteed to be copied until the command buffer fence is signaled.
Parameters
| Name | Type | Description |
|---|---|---|
copyPass |
IntPtr |
a copy pass handle. |
source |
in SDL.GPUTextureRegion |
the source buffer with offset and size. |
destination |
in SDL.GPUTransferBufferLocation |
the destination transfer buffer with offset. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DownloadFromGPUBuffer(System.IntPtr,SDL3.SDL.GPUTextureRegion@,SDL3.SDL.GPUTransferBufferLocation@)
public static void DownloadFromGPUTexture(IntPtr copyPass, in SDL.GPUTextureRegion source, in SDL.GPUTextureTransferInfo destination);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureRegion *source, const SDL_GPUTextureTransferInfo *destination);
Copies data from a texture to a transfer buffer on the GPU timeline.
This data is not guaranteed to be copied until the command buffer fence is signaled.
Parameters
| Name | Type | Description |
|---|---|---|
copyPass |
IntPtr |
a copy pass handle. |
source |
in SDL.GPUTextureRegion |
the source texture region. |
destination |
in SDL.GPUTextureTransferInfo |
the destination transfer buffer with image layout information. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DownloadFromGPUTexture(System.IntPtr,SDL3.SDL.GPUTextureRegion@,SDL3.SDL.GPUTextureTransferInfo@)
public static void DrawGPUIndexedPrimitives(IntPtr renderPass, uint numIndices, uint numInstances, uint firstIndex, int vertexOffset, uint firstInstance);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(SDL_GPURenderPass *render_pass, Uint32 num_indices, Uint32 num_instances, Uint32 first_index, Sint32 vertex_offset, Uint32 first_instance);
Draws data using bound graphics state with an index buffer and instancing enabled.
You must not call this function before binding a graphics pipeline.
Note that the firstIndex and firstInstance parameters are NOT compatible with built-in vertex/instance ID variables in shaders (for example, SV_VertexID); GPU APIs and shader languages do not define these built-in variables consistently, so if your shader depends on them, the only way to keep behavior consistent and portable is to always pass 0 for the correlating parameter in the draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
numIndices |
uint |
the number of indices to draw per instance. |
numInstances |
uint |
the number of instances to draw. |
firstIndex |
uint |
the starting index within the index buffer. |
vertexOffset |
int |
value added to vertex index before indexing into the vertex buffer. |
firstInstance |
uint |
the ID of the first instance to draw. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DrawGPUIndexedPrimitives(System.IntPtr,System.UInt32,System.UInt32,System.UInt32,System.Int32,System.UInt32)
public static void DrawGPUIndexedPrimitivesIndirect(IntPtr renderPass, IntPtr buffer, uint offset, uint drawCount);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count);
Draws data using bound graphics state with an index buffer enabled and with draw parameters set from a buffer.
The buffer must consist of tightly-packed draw parameter sets that each match the layout of SDL.GPUIndexedIndirectDrawCommand. You must not call this function before binding a graphics pipeline.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
buffer |
IntPtr |
a buffer containing draw parameters. |
offset |
uint |
the offset to start reading from the draw buffer. |
drawCount |
uint |
the number of draw parameter sets that should be read from the draw buffer. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DrawGPUIndexedPrimitivesIndirect(System.IntPtr,System.IntPtr,System.UInt32,System.UInt32)
public static void DrawGPUPrimitives(IntPtr renderPass, uint numVertices, uint numInstances, uint firstVertex, uint firstInstance);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(SDL_GPURenderPass *render_pass, Uint32 num_vertices, Uint32 num_instances, Uint32 first_vertex, Uint32 first_instance);
Draws data using bound graphics state.
You must not call this function before binding a graphics pipeline.
Note that the firstVertex and firstInstance parameters are NOT compatible with built-in vertex/instance ID variables in shaders (for example, SV_VertexID); GPU APIs and shader languages do not define these built-in variables consistently, so if your shader depends on them, the only way to keep behavior consistent and portable is to always pass 0 for the correlating parameter in the draw calls.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
numVertices |
uint |
the number of vertices to draw. |
numInstances |
uint |
the number of instances that will be drawn. |
firstVertex |
uint |
the index of the first vertex to draw. |
firstInstance |
uint |
the ID of the first instance to draw. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DrawGPUPrimitives(System.IntPtr,System.UInt32,System.UInt32,System.UInt32,System.UInt32)
public static void DrawGPUPrimitivesIndirect(IntPtr renderPass, IntPtr buffer, uint offset, uint drawCount);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count);
Draws data using bound graphics state and with draw parameters set from a buffer.
The buffer must consist of tightly-packed draw parameter sets that each match the layout of SDL.GPUIndirectDrawCommand. You must not call this function before binding a graphics pipeline.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
buffer |
IntPtr |
a buffer containing draw parameters. |
offset |
uint |
the offset to start reading from the draw buffer. |
drawCount |
uint |
the number of draw parameter sets that should be read from the draw buffer. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DrawGPUPrimitivesIndirect(System.IntPtr,System.IntPtr,System.UInt32,System.UInt32)
public static IntPtr DuplicateSurface(IntPtr surface);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
Creates a new surface identical to the existing surface.
If the original surface has alternate images, the new surface will have a reference to them as well.
The returned surface should be freed with SDL.DestroySurface.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the surface to duplicate. |
Returns
a copy of the surface or null on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.DuplicateSurface(System.IntPtr)
public static IntPtr EGLGetCurrentConfig();SDL declaration
extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void);
Get the currently active EGL config.
Returns
the currently active EGL config or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EGLGetCurrentConfig
public static IntPtr EGLGetCurrentDisplay();SDL declaration
extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void);
Get the currently active EGL display.
Returns
the currently active EGL display or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EGLGetCurrentDisplay
public static IntPtr EGLGetProcAddress(string proc);SDL declaration
extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
Get an EGL library function by name.
If an EGL library is loaded, this function allows applications to get entry points for EGL functions. This is useful to provide to an EGL API and extension loader.
Parameters
| Name | Type | Description |
|---|---|---|
proc |
string |
the name of an EGL function. |
Returns
a pointer to the named EGL function. The returned pointer should be cast to the appropriate function signature.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EGLGetProcAddress(System.String)
public static IntPtr EGLGetWindowSurface(IntPtr window);SDL declaration
extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window);
Get the EGL surface associated with the window.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to query. |
Returns
the EGLSurface pointer associated with the window, or null on failure.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EGLGetWindowSurface(System.IntPtr)
public static void EGLSetAttributeCallbacks(SDL.EGLAttribArrayCallback platformAttribCallback, SDL.EGLIntArrayCallback surfaceAttribCallback, SDL.EGLIntArrayCallback contextAttribCallback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, SDL_EGLIntArrayCallback surfaceAttribCallback, SDL_EGLIntArrayCallback contextAttribCallback, void *userdata);
Sets the callbacks for defining custom EGLAttrib arrays for EGL initialization.
Callbacks that aren't needed can be set to null.
NOTE: These callback pointers will be reset after SDL.GLResetAttributes.
Parameters
| Name | Type | Description |
|---|---|---|
platformAttribCallback |
SDL.EGLAttribArrayCallback |
callback for attributes to pass to eglGetPlatformDisplay. May be null. |
surfaceAttribCallback |
SDL.EGLIntArrayCallback |
callback for attributes to pass to eglCreateSurface. May be null. |
contextAttribCallback |
SDL.EGLIntArrayCallback |
callback for attributes to pass to eglCreateContext. May be null. |
userdata |
IntPtr |
a pointer that is passed to the callbacks. |
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EGLSetAttributeCallbacks(SDL3.SDL.EGLAttribArrayCallback,SDL3.SDL.EGLIntArrayCallback,SDL3.SDL.EGLIntArrayCallback,System.IntPtr)
public static bool EnableScreenSaver();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_EnableScreenSaver(void);
Allow the screen to be blanked by a screen saver.
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EnableScreenSaver
public static void EndGPUComputePass(IntPtr computePass);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(SDL_GPUComputePass *compute_pass);
Ends the current compute pass.
All bound compute state on the command buffer is unset. The compute pass handle is now invalid.
Parameters
| Name | Type | Description |
|---|---|---|
computePass |
IntPtr |
a compute pass handle. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EndGPUComputePass(System.IntPtr)
public static void EndGPUCopyPass(IntPtr copyPass);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(SDL_GPUCopyPass *copy_pass);
Ends the current copy pass.
Parameters
| Name | Type | Description |
|---|---|---|
copyPass |
IntPtr |
a copy pass handle. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EndGPUCopyPass(System.IntPtr)
public static void EndGPURenderPass(IntPtr renderPass);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(SDL_GPURenderPass *render_pass);
Ends the given render pass.
All bound graphics state on the render pass command buffer is unset. The render pass handle is now invalid.
Parameters
| Name | Type | Description |
|---|---|---|
renderPass |
IntPtr |
a render pass handle. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EndGPURenderPass(System.IntPtr)
public static int EnterAppMainCallbacks(int argc, string[] argv, SDL.AppInitFunc appinit, SDL.AppIterateFunc appiter, SDL.AppEventFunc appevent, SDL.AppQuitFunc appquit);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit);
An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
Generally, you should not call this function directly. This only exists to hand off work into SDL as soon as possible, where it has a lot more control and functionality available, and make the inline code in SDL_main.h as small as possible.
Not all platforms use this, it's actual use is hidden in a magic header-only library, and you should not call this directly unless you really know what you're doing.
Parameters
| Name | Type | Description |
|---|---|---|
argc |
int |
standard Unix main argc. |
argv |
string[] |
standard Unix main argv. |
appinit |
SDL.AppInitFunc |
the application's SDL.AppInit function. |
appiter |
SDL.AppIterateFunc |
the application's SDL.AppIterate function. |
appevent |
SDL.AppEventFunc |
the application's SDL.AppEvent function. |
appquit |
SDL.AppQuitFunc |
the application's SDL.AppQuit function. |
Returns
standard Unix main return value.
Thread safety
It is not safe to call this anywhere except as the only function call in SDL_main.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EnterAppMainCallbacks(System.Int32,System.String[],SDL3.SDL.AppInitFunc,SDL3.SDL.AppIterateFunc,SDL3.SDL.AppEventFunc,SDL3.SDL.AppQuitFunc)
public static bool EnumerateDirectory(string path, SDL.EnumerateDirectoryCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
Enumerate a directory through a callback function.
This function provides every directory entry through an app-provided callback, called once for each directory entry, until all results have been provided or the callback returns either SDL.EnumerationResult.Success or SDL.EnumerationResult.Failure.
This will return false if there was a system problem in general, or if a callback returns SDL.EnumerationResult.Failure. A successful return means a callback returned SDL.EnumerationResult.Success to halt enumeration, or all directory entries were enumerated.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
the path of the directory to enumerate. |
callback |
SDL.EnumerateDirectoryCallback |
a function that is called for each entry in the directory. |
userdata |
IntPtr |
a pointer that is passed to callback. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EnumerateDirectory(System.String,SDL3.SDL.EnumerateDirectoryCallback,System.IntPtr)
public static bool EnumerateProperties(uint props, SDL.EnumeratePropertiesCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata);
Enumerate the properties contained in a group of properties.
The callback function is called for each property in the group of properties. The properties are locked during enumeration.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to query. |
callback |
SDL.EnumeratePropertiesCallback |
the function to call for each property. |
userdata |
IntPtr |
a pointer that is passed to callback. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EnumerateProperties(System.UInt32,SDL3.SDL.EnumeratePropertiesCallback,System.IntPtr)
public static bool EnumerateStorageDirectory(IntPtr storage, string path, SDL.EnumerateDirectoryCallback callback, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
Enumerate a directory in a storage container through a callback function.
This function provides every directory entry through an app-provided callback, called once for each directory entry, until all results have been provided or the callback returns either SDL.EnumerationResult.Success or SDL.EnumerationResult.Failure.
This will return false if there was a system problem in general, or if a callback returns SDL.EnumerationResult.Failure. A successful return means a callback returned SDL.EnumerationResult.Success to halt enumeration, or all directory entries were enumerated.
If path is null, this is treated as a request to enumerate the root of the storage container's tree. An empty string also works for this.
Parameters
| Name | Type | Description |
|---|---|---|
storage |
IntPtr |
a storage container. |
path |
string |
the path of the directory to enumerate, or null for the root |
callback |
SDL.EnumerateDirectoryCallback |
a function that is called for each entry in the directory. |
userdata |
IntPtr |
a pointer that is passed to callback. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EnumerateStorageDirectory(System.IntPtr,System.String,SDL3.SDL.EnumerateDirectoryCallback,System.IntPtr)
public static bool EventEnabled(uint type);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_EventEnabled(Uint32 type);
Query the state of processing events by type.
Parameters
| Name | Type | Description |
|---|---|---|
type |
uint |
the type of event; see SDL.EventType for details. |
Returns
true if the event is being processed, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.EventEnabled(System.UInt32)
public static bool FillSurfaceRect(IntPtr dst, in SDL.Rect rect, uint color);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
Perform a fast fill of a rectangle with a specific color.
color should be a pixel of the format used by the surface, and can be generated by SDL.MapRGB or SDL.MapRGBA. If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.
If there is a clip rectangle set on the destination (set via SDL.SetSurfaceClipRect), then this function will fill based on the intersection of the clip rectangle and rect.
Parameters
| Name | Type | Description |
|---|---|---|
dst |
IntPtr |
the SDL.Surface structure that is the drawing target. |
rect |
in SDL.Rect |
the SDL.Rect structure representing the rectangle to fill, or null to fill the entire surface. |
color |
uint |
the color to fill with. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function is not thread safe.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FillSurfaceRect(System.IntPtr,SDL3.SDL.Rect@,System.UInt32)
public static bool FillSurfaceRect(IntPtr dst, IntPtr rect, uint color);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
Perform a fast fill of a rectangle with a specific color.
color should be a pixel of the format used by the surface, and can be generated by SDL.MapRGB or SDL.MapRGBA. If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.
If there is a clip rectangle set on the destination (set via SDL.SetSurfaceClipRect), then this function will fill based on the intersection of the clip rectangle and rect.
Parameters
| Name | Type | Description |
|---|---|---|
dst |
IntPtr |
the SDL.Surface structure that is the drawing target. |
rect |
IntPtr |
the SDL.Rect structure representing the rectangle to fill, or null to fill the entire surface. |
color |
uint |
the color to fill with. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FillSurfaceRect(System.IntPtr,System.IntPtr,System.UInt32)
public static bool FillSurfaceRects(IntPtr dst, ReadOnlySpan<SDL.Rect> rects, int count, uint color);Parameters
| Name | Type | Description |
|---|---|---|
dst |
IntPtr |
|
rects |
ReadOnlySpan<SDL.Rect> |
|
count |
int |
|
color |
uint |
XML member id: M:SDL3.SDL.FillSurfaceRects(System.IntPtr,System.ReadOnlySpan{SDL3.SDL.Rect},System.Int32,System.UInt32)
public static bool FillSurfaceRects(IntPtr dst, SDL.Rect[] rects, int count, uint color);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
Perform a fast fill of a set of rectangles with a specific color.
color should be a pixel of the format used by the surface, and can be generated by SDL.MapRGB or SDL.MapRGBA. If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.
If there is a clip rectangle set on the destination (set via SDL.SetSurfaceClipRect), then this function will fill based on the intersection of the clip rectangle and rect.
Parameters
| Name | Type | Description |
|---|---|---|
dst |
IntPtr |
the SDL.Surface structure that is the drawing target. |
rects |
SDL.Rect[] |
an array of SDL.Rect representing the rectangles to fill. |
count |
int |
the number of rectangles in the array. |
color |
uint |
the color to fill with. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function is not thread safe.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FillSurfaceRects(System.IntPtr,SDL3.SDL.Rect[],System.Int32,System.UInt32)
public static void FilterEvents(SDL.EventFilter filter, IntPtr userdata);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata);
Run a specific filter function on the current event queue, removing any events for which the filter returns false.
See SDL.SetEventFilter for more information. Unlike SDL.SetEventFilter, this function does not change the filter permanently, it only uses the supplied filter until this function returns.
Parameters
| Name | Type | Description |
|---|---|---|
filter |
SDL.EventFilter |
the SDL.EventFilter function to call when an event happens. |
userdata |
IntPtr |
a pointer that is passed to filter. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FilterEvents(SDL3.SDL.EventFilter,System.IntPtr)
public static bool FlashWindow(IntPtr window, SDL.FlashOperation operation);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
Request a window to demand attention from the user.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to be flashed. |
operation |
SDL.FlashOperation |
the operation to perform. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlashWindow(System.IntPtr,SDL3.SDL.FlashOperation)
public static bool FlipSurface(IntPtr surface, SDL.FlipMode flip);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
Flip a surface vertically or horizontally.
Parameters
| Name | Type | Description |
|---|---|---|
surface |
IntPtr |
the surface to flip. |
flip |
SDL.FlipMode |
the direction to flip. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function can be called on different threads with different surfaces.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlipSurface(System.IntPtr,SDL3.SDL.FlipMode)
public static bool FlushAudioStream(IntPtr stream);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
Tell the stream that you're done sending data, and anything being buffered should be converted/resampled and made available immediately.
It is legal to add more data to a stream after flushing, but there may be audio gaps in the output. Generally this is intended to signal the end of input, so the complete output becomes available.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to flush. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlushAudioStream(System.IntPtr)
public static void FlushEvent(uint type);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
Clear events of a specific type from the event queue.
This will unconditionally remove any events from the queue that match type. If you need to remove a range of event types, use SDL.FlushEvents instead.
It's also normal to just ignore events you don't care about in your event loop without calling this function.
This function only affects currently queued events. If you want to make sure that all pending OS events are flushed, you can call SDL.PumpEvents on the main thread immediately before the flush call.
If you have user events with custom data that needs to be freed, you should use SDL.PeepEvents to remove and clean up those events before calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
type |
uint |
the type of event to be cleared; see SDL.EventType for details. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlushEvent(System.UInt32)
public static void FlushEvents(uint minType, uint maxType);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
Clear events of a range of types from the event queue.
This will unconditionally remove any events from the queue that are in the range of minType to maxType, inclusive. If you need to remove a single event type, use SDL.FlushEvent instead.
It's also normal to just ignore events you don't care about in your event loop without calling this function.
This function only affects currently queued events. If you want to make sure that all pending OS events are flushed, you can call SDL.PumpEvents on the main thread immediately before the flush call.
Parameters
| Name | Type | Description |
|---|---|---|
minType |
uint |
the low end of event type to be cleared, inclusive; see SDL.EventType for details. |
maxType |
uint |
the high end of event type to be cleared, inclusive; see SDL.EventType for details. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlushEvents(System.UInt32,System.UInt32)
public static bool FlushIO(IntPtr context);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context);
Flush any buffered data in the stream.
This function makes sure that any buffered data is written to the stream. Normally this isn't necessary but if the stream is a pipe or socket it guarantees that any pending data is sent.
Parameters
| Name | Type | Description |
|---|---|---|
context |
IntPtr |
SDL_IOStream structure to flush. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
Do not use the same SDL_IOStream from two threads at once.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlushIO(System.IntPtr)
public static bool FlushRenderer(IntPtr renderer);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
Force the rendering context to flush any pending commands and state.
You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly, in addition to using an SDL_Renderer.
This is for a very-specific case: if you are using SDL's render API, and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If this applies, you should call this function between calls to SDL's render API and the low-level API you're using in cooperation.
In all other cases, you can ignore this function.
This call makes SDL flush any pending rendering work it was queueing up to do later in a single batch, and marks any internal cached state as invalid, so it'll prepare all its state again later, from scratch.
This means you do not need to save state in your rendering code to protect the SDL renderer. However, there lots of arbitrary pieces of Direct3D and OpenGL state that can confuse things; you should use your best judgment and be prepared to make changes if specific state needs to be protected.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.FlushRenderer(System.IntPtr)
public static uint FourCC(char a, char b, char c, char d);XML documentation is not available for this function.
XML member id: M:SDL3.SDL.FourCC(System.Char,System.Char,System.Char,System.Char)
public static void Free(IntPtr mem);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_free(void *mem);
Free allocated memory.
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem is null, this function does nothing.
Parameters
| Name | Type | Description |
|---|---|---|
mem |
IntPtr |
a pointer to allocated memory, or null. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.Free(System.IntPtr)
public static bool GamepadConnected(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
Check if a gamepad has been opened and is currently connected.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Returns
true if the gamepad has been opened and is currently connected, or It is safe to call this function from any thread.false if not.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadConnected(System.IntPtr)
public static bool GamepadEventsEnabled();SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
Query the state of gamepad event processing.
If gamepad events are disabled, you must call SDL.UpdateGamepads yourself and check the state of the gamepad when you want gamepad information.
Returns
true if gamepad events are being processed, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadEventsEnabled
public static bool GamepadHasAxis(IntPtr gamepad, SDL.GamepadAxis axis);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
Query whether a gamepad has a given axis.
This merely reports whether the gamepad's mapping defined this axis, as that is all the information SDL has about the physical device.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
axis |
SDL.GamepadAxis |
an axis enum value (an SDL.GamepadAxis value). |
Returns
true if the gamepad has this axis, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadHasAxis(System.IntPtr,SDL3.SDL.GamepadAxis)
public static bool GamepadHasButton(IntPtr gamepad, SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
Query whether a gamepad has a given button.
This merely reports whether the gamepad's mapping defined this button, as that is all the information SDL has about the physical device.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
button |
SDL.GamepadButton |
a button enum value (an SDL.GamepadButton value). |
Returns
true if the gamepad has this button, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadHasButton(System.IntPtr,SDL3.SDL.GamepadButton)
public static bool GamepadHasSensor(IntPtr gamepad, SDL.SensorType type);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
Return whether a gamepad has a particular sensor.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad to query. |
type |
SDL.SensorType |
the type of sensor to query. |
Returns
true if the sensor exists, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadHasSensor(System.IntPtr,SDL3.SDL.SensorType)
public static bool GamepadSensorEnabled(IntPtr gamepd, SDL.SensorType type);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
Query whether sensor data reporting is enabled for a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepd |
IntPtr |
the gamepad to query. |
type |
SDL.SensorType |
the type of sensor to query. |
Returns
true if the sensor is enabled, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GamepadSensorEnabled(System.IntPtr,SDL3.SDL.SensorType)
public static void GDKResumeGPU(IntPtr device);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
Call this to resume GPU operation on Xbox after receiving the SDL.EventType.WillEnterForeground event.
When resuming, this function MUST be called before calling any other SDL_GPU functions.
This function MUST be called from the application's render thread.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
device a GPU context. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GDKResumeGPU(System.IntPtr)
public static void GDKSuspendComplete();SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
Callback from the application to let the suspend continue.
This function is only needed for Xbox GDK support; all other platforms will do nothing and set an "unsupported" error message.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GDKSuspendComplete
public static void GDKSuspendGPU(IntPtr device);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
Call this to suspend GPU operation on Xbox after receiving the SDL.EventType.DidEnterBackground event.
Do NOT call any SDL_GPU functions after calling this function! This must also be called before calling SDL.GDKSuspendComplete.
This function MUST be called from the application's render thread.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
device a GPU context. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GDKSuspendGPU(System.IntPtr)
public static void GenerateMipmapsForGPUTexture(IntPtr commandBuffer, IntPtr texture);SDL declaration
extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(SDL_GPUCommandBuffer *command_buffer, SDL_GPUTexture *texture);
Generates mipmaps for the given texture.
This function must not be called inside of any pass.
Parameters
| Name | Type | Description |
|---|---|---|
commandBuffer |
IntPtr |
a command_buffer. |
texture |
IntPtr |
a texture with more than 1 mip level. |
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GenerateMipmapsForGPUTexture(System.IntPtr,System.IntPtr)
public static IntPtr GetAndroidActivity();SDL declaration
extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void);
Retrieve the Java instance of the Android activity class.
The prototype of the function in SDL's code actually declares a void* return type, even if the implementation returns a jobject. The rationale being that the SDL headers can avoid including jni.h.
The jobject returned by the function is a local reference and must be released by the caller. See the PushLocalFrame() and PopLocalFrame() or DeleteLocalRef() functions of the Java native interface:
https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
Returns
the jobject representing the instance of the Activity class of the Android application, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidActivity
public static string GetAndroidCachePath();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
Get the path used for caching data for this Android application.
This path is unique to your application, but is public and can be written to by other applications.
Your cache path is typically: /data/data/your.app.package/cache/.
This is a C wrapper over android.content.Context.getCacheDir():
https://developer.android.com/reference/android/content/Context#getCacheDir()
Returns
the path used for caches for this application on success or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidCachePath
public static string GetAndroidExternalStoragePath();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void);
Get the path used for external storage for this Android application.
This path is unique to your application, but is public and can be written to by other applications.
Your external storage path is typically: /storage/sdcard0/Android/data/your.app.package/files.
This is a C wrapper over android.content.Context.getExternalFilesDir():
https://developer.android.com/reference/android/content/Context#getExternalFilesDir()
Returns
the path used for external storage for this application on success or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidExternalStoragePath
public static uint GetAndroidExternalStorageState();SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void);
Get the current state of external storage for this Android application.
The current state of external storage, a bitmask of these values: SDL.AndroidExternalStorageRead, SDL.AndroidExternalStorageWrite.
If external storage is currently unavailable, this will return 0.
Returns
the current state of external storage, or 0 if external storage is currently unavailable.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidExternalStorageState
public static string GetAndroidInternalStoragePath();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidInternalStoragePath(void);
Get the path used for internal storage for this Android application.
This path is unique to your application and cannot be written to by other applications.
Your internal storage path is typically: /data/data/your.app.package/files.
This is a C wrapper over android.content.Context.getFilesDir():
https://developer.android.com/reference/android/content/Context#getFilesDir()
Returns
the path used for internal storage or null on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidInternalStoragePath
public static IntPtr GetAndroidJNIEnv();SDL declaration
extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void);
Get the Android Java Native Interface Environment of the current thread.
This is the JNIEnv one needs to access the Java virtual machine from native code, and is needed for many Android APIs to be usable from C.
The prototype of the function in SDL's code actually declare a void* return type, even if the implementation returns a pointer to a JNIEnv. The rationale being that the SDL headers can avoid including jni.h.
Returns
a pointer to Java native interface object (JNIEnv) to which the current thread is attached, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidJNIEnv
public static int GetAndroidSDKVersion();SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
Query Android API level of the current device.
- API level 35: Android 15 (VANILLA_ICE_CREAM)
- API level 34: Android 14 (UPSIDE_DOWN_CAKE)
- API level 33: Android 13 (TIRAMISU)
- API level 32: Android 12L (S_V2)
- API level 31: Android 12 (S)
- API level 30: Android 11 (R)
- API level 29: Android 10 (Q)
- API level 28: Android 9 (P)
- API level 27: Android 8.1 (O_MR1)
- API level 26: Android 8.0 (O)
- API level 25: Android 7.1 (N_MR1)
- API level 24: Android 7.0 (N)
- API level 23: Android 6.0 (M)
- API level 22: Android 5.1 (LOLLIPOP_MR1)
- API level 21: Android 5.0 (LOLLIPOP, L)
- API level 20: Android 4.4W (KITKAT_WATCH)
- API level 19: Android 4.4 (KITKAT)
- API level 18: Android 4.3 (JELLY_BEAN_MR2)
- API level 17: Android 4.2 (JELLY_BEAN_MR1)
- API level 16: Android 4.1 (JELLY_BEAN)
- API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
- API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
- API level 13: Android 3.2 (HONEYCOMB_MR2)
- API level 12: Android 3.1 (HONEYCOMB_MR1)
- API level 11: Android 3.0 (HONEYCOMB)
- API level 10: Android 2.3.3 (GINGERBREAD_MR1)
Returns
the Android API level.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAndroidSDKVersion
public static string GetAppMetadataProperty(string name);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAppMetadataProperty(const char *name);
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.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
the name of the metadata property to get. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAppMetadataProperty(System.String)
public static SDL.AssertionHandler GetAssertionHandler(IntPtr puserdata);SDL declaration
extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
Get the current assertion handler.
This returns the function pointer that is called when an assertion is triggered. This is either the value last passed to SDL.SetAssertionHandler, or if no application-specified function is set, is equivalent to calling SDL.GetDefaultAssertionHandler.
The parameter puserdata is a pointer to a void*, which will store the "userdata" pointer that was passed to SDL.SetAssertionHandler. This value will always be null for the default handler. If you don't care about this data, it is safe to pass a null pointer to this function to ignore it.
Parameters
| Name | Type | Description |
|---|---|---|
puserdata |
IntPtr |
pointer which is filled with the "userdata" pointer that was passed to SDL.SetAssertionHandler. |
Returns
the SDL.AssertionHandler that is called when an assert triggers.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAssertionHandler(System.IntPtr)
public static IntPtr GetAssertionReport();SDL declaration
extern SDL_DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
Get a list of all assertion failures.
This function gets all assertions triggered since the last call to SDL.ResetAssertionReport, or the start of the program.
The proper way to examine this data looks something like this:
c const SDL_AssertData *item = SDL_GetAssertionReport(); while (item) { printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? "yes" : "no"); item = item->next;
Returns
a list of all failed assertions or null if the list is empty. This memory should not be modified or freed by the application. This pointer remains valid until the next call to SDL.Quit or SDL.ResetAssertionReport.
Thread safety
This function is not thread safe. Other threads calling SDL.ResetAssertionReport simultaneously, may render the returned pointer invalid.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAssertionReport
public static bool GetAsyncIOResult(IntPtr queue, out SDL.AsyncIOOutcome outcome);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome);
Query an async I/O task queue for completed tasks.
If a task assigned to this queue has finished, this will return true and fill in outcome with the details of the task. If no task in the queue has finished, this function will return false. This function does not block.
If a task has completed, this function will free its resources and the task pointer will no longer be valid. The task will be removed from the queue.
It is safe for multiple threads to call this function on the same queue at once; a completed task will only go to one of the threads.
Parameters
| Name | Type | Description |
|---|---|---|
queue |
IntPtr |
the async I/O task queue to query. |
outcome |
out SDL.AsyncIOOutcome |
details of a finished task will be written here. May not be null. |
Returns
true if a task has completed, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.GetAsyncIOResult(System.IntPtr,SDL3.SDL.AsyncIOOutcome@)
public static long GetAsyncIOSize(IntPtr asyncio);SDL declaration
extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetAsyncIOSize(SDL_AsyncIO *asyncio);
Use this function to get the size of the data stream in an SDL_AsyncIO.
This call is not asynchronous; it assumes that obtaining this info is a non-blocking operation in most reasonable cases.
Parameters
| Name | Type | Description |
|---|---|---|
asyncio |
IntPtr |
the SDL_AsyncIO to get the size of the data stream from. |
Returns
the size of the data stream in the SDL_IOStream on success or a negative error code on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.GetAsyncIOSize(System.IntPtr)
public static int GetAtomicInt(ref SDL.AtomicInt a);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAtomicInt(SDL_AtomicInt *a);
Get the value of an atomic variable.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicInt |
a pointer to an SDL.AtomicInt variable. |
Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAtomicInt(SDL3.SDL.AtomicInt@)
public static IntPtr GetAtomicPointer(ref IntPtr a);SDL declaration
extern SDL_DECLSPEC void * SDLCALL SDL_GetAtomicPointer(void **a);
Get the value of a pointer atomically.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref IntPtr |
a pointer to a pointer. |
Returns
the current value of a pointer.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAtomicPointer(System.IntPtr@)
public static uint GetAtomicU32(ref SDL.AtomicU32 a);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a);
Get the value of an atomic variable.
Note: If you don't know what this function is for, you shouldn't use it!
Parameters
| Name | Type | Description |
|---|---|---|
a |
ref SDL.AtomicU32 |
a pointer to an SDL.AtomicU32 variable. |
Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAtomicU32(SDL3.SDL.AtomicU32@)
public static int[] GetAudioDeviceChannelMap(uint devid, out int count);Get the current channel map of an audio device.
Channel maps are optional; most things do not need them, instead passing data in the order that SDL expects.
Audio devices usually have no remapping applied. This is represented by returning null, and does not signify an error.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
the instance ID of the device to query. |
count |
out int |
On output, set to number of channels in the map. Can be null. |
Returns
an array of the current channel mapping, with as many elements as the current output spec's channels, or null if default. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioDeviceChannelMap(System.UInt32,System.Int32@)
public static bool GetAudioDeviceFormat(uint devid, out SDL.AudioSpec spec, out int sampleFrames);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames);
Get the current audio format of a specific audio device.
For an opened device, this will report the format the device is currently using. If the device isn't yet opened, this will report the device's preferred format (or a reasonable default if this can't be determined).
You may also specify SDL.AudioDeviceDefaultPlayback or SDL.AudioDeviceDefaultRecording here, which is useful for getting a reasonable recommendation before opening the system-recommended default device.
You can also use this to request the current device buffer size. This is specified in sample frames and represents the amount of data SDL will feed to the physical hardware in each chunk. This can be converted to milliseconds of audio with the following equation:
ms = (int) ((((Sint64) frames) * 1000) / spec.freq);
Buffer size is only important if you need low-level control over the audio playback timing. Most apps do not need this.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
the instance ID of the device to query. |
spec |
out SDL.AudioSpec |
on return, will be filled with device details. |
sampleFrames |
out int |
pointer to store device buffer size, in sample frames. Can be null. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioDeviceFormat(System.UInt32,SDL3.SDL.AudioSpec@,System.Int32@)
public static float GetAudioDeviceGain(uint devid);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid);
Get the gain of an audio device.
The gain of a device is its volume; a larger gain means a louder output, with a gain of zero being silence.
Audio devices default to a gain of 1.0f (no change in output).
Physical devices may not have their gain changed, only logical devices, and this function will always return -1.0f when used on physical devices.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
the audio device to query. |
Returns
the gain of the device or -1.0f on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioDeviceGain(System.UInt32)
public static string GetAudioDeviceName(uint devid);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDeviceName(SDL_AudioDeviceID devid);
Get the human-readable name of a specific audio device. WARNING: this function will work with SDL.AudioDeviceDefaultPlayback and SDL.AudioDeviceDefaultRecording, returning the current default physical devices' names. However, as the default device may change at any time, it is likely better to show a generic name to the user, like "System default audio device" or perhaps "default [currently %s]". Do not store this name to disk to reidentify the device in a later run of the program, as the default might change in general, and the string will be the name of a specific device and not the abstract system default.
Parameters
| Name | Type | Description |
|---|---|---|
devid |
uint |
the instance ID of the device to query. |
Returns
the name of the audio device, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioDeviceName(System.UInt32)
public static string GetAudioDriver(int index);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index);
Use this function to get the name of a built in audio driver.
The list of audio drivers is given in the order that they are normally initialized by default; the drivers that seem more reasonable to choose first (as far as the SDL developers believe) are earlier in the list.
The names of drivers are all simple, low-ASCII identifiers, like "alsa", "coreaudio" or "wasapi". These never have Unicode characters, and are not meant to be proper names.
Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
the index of the audio driver; the value ranges from 0 to SDL.GetNumAudioDrivers - 1. |
Returns
the name of the audio driver at the requested index, or null if an invalid index was specified.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioDriver(System.Int32)
public static string GetAudioFormatName(SDL.AudioFormat format);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioFormatName(SDL_AudioFormat format);
Get the human readable name of an audio format.
Parameters
| Name | Type | Description |
|---|---|---|
format |
SDL.AudioFormat |
the audio format to query. |
Returns
the human readable name of the specified audio format or SDL.AudioFormat.Unknown if the format isn't recognized.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioFormatName(SDL3.SDL.AudioFormat)
public static uint[] GetAudioPlaybackDevices(out int count);SDL declaration
extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevices(int *count);
Get a list of currently-connected audio playback devices.
This returns of list of available devices that play sound, perhaps to speakers or headphones ("playback" devices). If you want devices that record audio, like a microphone ("recording" devices), use SDL.GetAudioRecordingDevices instead.
This only returns a list of physical devices; it will not have any device IDs returned by SDL.OpenAudioDevice.
If this function returns null, to signify an error, count will be set to zero.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of devices returned, may be null. |
Returns
a 0 terminated array of device instance IDs or null on error; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioPlaybackDevices(System.Int32@)
public static uint[] GetAudioRecordingDevices(out int count);SDL declaration
extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int *count);
Get a list of currently-connected audio recording devices.
This returns of list of available devices that record audio, like a microphone ("recording" devices). If you want devices that play sound, perhaps to speakers or headphones ("playback" devices), use SDL.GetAudioPlaybackDevices instead.
This only returns a list of physical devices; it will not have any device IDs returned by SDL.OpenAudioDevice.
If this function returns null, to signify an error, count will be set to zero.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of devices returned, may be null. |
Returns
a 0 terminated array of device instance IDs, or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioRecordingDevices(System.Int32@)
public static int GetAudioStreamAvailable(IntPtr stream);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *stream);
Get the number of converted/resampled bytes available.
The stream may be buffering data behind the scenes until it has enough to resample correctly, so this number might be lower than what you expect, or even be zero. Add more data or flush the stream if you need the data now.
If the stream has so much data that it would overflow an int, the return value is clamped to a maximum value, but no queued data is lost; if there are gigabytes of data queued, the app might need to read some of it with SDL.GetAudioStreamData before this function's return value is no longer clamped.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to query. |
Returns
the number of converted/resampled bytes available or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamAvailable(System.IntPtr)
public static int GetAudioStreamData(IntPtr stream, byte[] buf, int len);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
Get converted/resampled data from the stream.
The input/output data format/channels/samplerate is specified when creating the stream, and can be changed after creation by calling SDL.SetAudioStreamFormat.
Note that any conversion and resampling necessary is done during this call, and SDL_PutAudioStreamData simply queues unconverted data for later. This is different than SDL2, where that work was done while inputting new data to the stream and requesting the output just copied the converted data.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the stream the audio is being requested from. |
buf |
byte[] |
a buffer to fill with audio data. |
len |
int |
the maximum number of bytes to fill. |
Returns
the number of bytes read from the stream or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread, but if the stream has a callback set, the caller might need to manage extra locking.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamData(System.IntPtr,System.Byte[],System.Int32)
public static int GetAudioStreamData(IntPtr stream, IntPtr buf, int len);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
Get converted/resampled data from the stream.
The input/output data format/channels/samplerate is specified when creating the stream, and can be changed after creation by calling SDL.SetAudioStreamFormat.
Note that any conversion and resampling necessary is done during this call, and SDL_PutAudioStreamData simply queues unconverted data for later. This is different than SDL2, where that work was done while inputting new data to the stream and requesting the output just copied the converted data.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the stream the audio is being requested from. |
buf |
IntPtr |
a buffer to fill with audio data. |
len |
int |
the maximum number of bytes to fill. |
Returns
the number of bytes read from the stream or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread, but if the stream has a callback set, the caller might need to manage extra locking.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamData(System.IntPtr,System.IntPtr,System.Int32)
public static int GetAudioStreamData(IntPtr stream, Span<byte> buf, int len);Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
|
buf |
Span<byte> |
|
len |
int |
XML member id: M:SDL3.SDL.GetAudioStreamData(System.IntPtr,System.Span{System.Byte},System.Int32)
public static uint GetAudioStreamDevice(IntPtr stream);SDL declaration
extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamDevice(SDL_AudioStream *stream);
Query an audio stream for its currently-bound device.
This reports the logical audio device that an audio stream is currently bound to.
If not bound, or invalid, this returns zero, which is not a valid device ID.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to query. |
Returns
the bound audio device, or 0 if not bound or invalid.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamDevice(System.IntPtr)
public static bool GetAudioStreamFormat(IntPtr stream, out SDL.AudioSpec srcSpec, out SDL.AudioSpec dstSpec);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec);
Query the current format of an audio stream.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
srcSpec |
out SDL.AudioSpec |
where to store the input audio format; ignored if null. |
dstSpec |
out SDL.AudioSpec |
where to store the output audio format; ignored if null. |
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, as it holds a stream-specific mutex while running.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamFormat(System.IntPtr,SDL3.SDL.AudioSpec@,SDL3.SDL.AudioSpec@)
public static float GetAudioStreamFrequencyRatio(IntPtr stream);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStream *stream);
Get the frequency ratio of an audio stream.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
Returns
the frequency ratio of the stream or 0.0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamFrequencyRatio(System.IntPtr)
public static float GetAudioStreamGain(IntPtr stream);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamGain(SDL_AudioStream *stream);
Get the gain of an audio stream.
The gain of a stream is its volume; a larger gain means a louder output, with a gain of zero being silence.
Audio streams default to a gain of 1.0f (no change in output).
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
Returns
the gain of the stream or -1.0f on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamGain(System.IntPtr)
public static int[] GetAudioStreamInputChannelMap(IntPtr stream, out int count);SDL declaration
extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count);
Get the current input channel map of an audio stream.
Channel maps are optional; most things do not need them, instead passing data in the order that SDL expects.
Audio streams default to no remapping applied. This is represented by returning null, and does not signify an error.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
count |
out int |
On output, set to number of channels in the map. Can be null. |
Returns
an array of the current channel mapping, with as many elements as the current output spec's channels, or null if default. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamInputChannelMap(System.IntPtr,System.Int32@)
public static int[] GetAudioStreamOutputChannelMap(IntPtr stream, out int count);SDL declaration
extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count);
Get the current output channel map of an audio stream.
Channel maps are optional; most things do not need them, instead passing data in the order that SDL expects.
Audio streams default to no remapping applied. This is represented by returning null, and does not signify an error.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
count |
out int |
On output, set to number of channels in the map. Can be null. |
Returns
an array of the current channel mapping, with as many elements as the current output spec's channels, or null if default. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamOutputChannelMap(System.IntPtr,System.Int32@)
public static uint GetAudioStreamProperties(IntPtr stream);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream);
Get the properties associated with an audio stream.
The application can hang any data it wants here, but the following properties are understood by SDL:
-
SDL.Props.AudioStreamAutoCleanupBoolean: iftrue(the default), the stream be automatically cleaned up when the audio subsystem quits. If set tofalse, the streams will persist beyond that. This property is ignored for streams created throughSDL.OpenAudioDeviceStream, and will always be cleaned up. Streams that are not cleaned up will still be unbound from devices when the audio subsystem quits. This property was added in SDL 3.4.0.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the SDL_AudioStream to query. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamProperties(System.IntPtr)
public static int GetAudioStreamQueued(IntPtr stream);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamQueued(SDL_AudioStream *stream);
Get the number of bytes currently queued.
This is the number of bytes put into a stream as input, not the number that can be retrieved as output. Because of several details, it's not possible to calculate one number directly from the other. If you need to know how much usable data can be retrieved right now, you should use SDL.GetAudioStreamAvailable and not this function.
Note that audio streams can change their input format at any time, even if there is still data queued in a different format, so the returned byte count will not necessarily match the number of sample frames available. Users of this API should be aware of format changes they make when feeding a stream and plan accordingly.
Queued data is not converted until it is consumed by SDL.GetAudioStreamData, so this value should be representative of the exact data that was put into the stream.
If the stream has so much data that it would overflow an int, the return value is clamped to a maximum value, but no queued data is lost; if there are gigabytes of data queued, the app might need to read some of it with SDL.GetAudioStreamData before this function's return value is no longer clamped.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IntPtr |
the audio stream to query. |
Returns
the number of bytes queued or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetAudioStreamQueued(System.IntPtr)
public static string GetBasePath();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void);
Get the directory where the application was run from.
SDL caches the result of this call internally, but the first call to this function is not necessarily fast, so plan accordingly.
macOS and iOS Specific Functionality: If the application is in a ".app" bundle, this function returns the Resource directory (e.g. MyApp.app/Contents/Resources/). This behaviour can be overridden by adding a property to the Info.plist file. Adding a string key with the name SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the behaviour.
Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an application in /Applications/SDLApp/MyApp.app):
-
resource: bundle resource directory (the default). For example:/Applications/SDLApp/MyApp.app/Contents/Resources -
bundle: the Bundle directory. For example:/Applications/SDLApp/MyApp.app/ -
parent: the containing directory of the bundle. For example:/Applications/SDLApp/Android Specific Functionality: This function returns"./", which allows filesystem operations to use internal storage and the asset system.
Nintendo 3DS Specific Functionality: This function returns "romfs" directory of the application as it is uncommon to store resources outside the executable. As such it is not a writable directory.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
Returns
an absolute path in UTF-8 encoding to the application data directory. null will be returned on error or when the platform doesn't implement this functionality, call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetBasePath
public static bool GetBooleanProperty(uint props, string name, bool defaultValue);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, bool default_value);
Get a boolean property from a group of properties.
You can use SDL.GetPropertyType to query whether the property exists and is a boolean property.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to query. |
name |
string |
the name of the property to query. |
defaultValue |
bool |
the default value of the property. |
Returns
the value of the property, or defaultValue if it is not set or not a boolean property.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetBooleanProperty(System.UInt32,System.String,System.Boolean)
public static string GetCameraDriver(int index);SDL declaration
extern SDL_DECLSPEC const char *SDLCALL SDL_GetCameraDriver(int index);
Use this function to get the name of a built in camera driver.
The list of camera drivers is given in the order that they are normally initialized by default; the drivers that seem more reasonable to choose first (as far as the SDL developers believe) are earlier in the list.
The names of drivers are all simple, low-ASCII identifiers, like "v4l2", "coremedia" or "android". These never have Unicode characters, and are not meant to be proper names.
Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
the index of the camera driver; the value ranges from 0 to SDL.GetNumCameraDrivers - 1. |
Returns
the name of the camera driver at the requested index, or null if an invalid index was specified.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraDriver(System.Int32)
public static int GetCameraFormat(IntPtr camera, out SDL.CameraSpec spec);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec);
Get the spec that a camera is using when generating images.
Note that this might not be the native format of the hardware, as SDL might be converting to this format behind the scenes.
If the system is waiting for the user to approve access to the camera, as some platforms require, this will return false, but this isn't necessarily a fatal error; you should either wait for an SDL.EventType.CameraDeviceApproved (or SDL.EventType.CameraDeviceDenied) event, or poll SDL.GetCameraPermissionState occasionally until it returns non-zero.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
opened camera device. |
spec |
out SDL.CameraSpec |
the SDL.CameraSpec to be initialized by this function. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraFormat(System.IntPtr,SDL3.SDL.CameraSpec@)
public static uint GetCameraID(IntPtr camera);SDL declaration
extern SDL_DECLSPEC SDL_CameraID SDLCALL SDL_GetCameraID(SDL_Camera *camera);
Get the instance ID of an opened camera.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
an SDL_Camera to query. |
Returns
the instance ID of the specified camera on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraID(System.IntPtr)
public static string GetCameraName(uint instanceId);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id);
Get the human-readable device name for a camera.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the camera device instance ID. |
Returns
a human-readable device name or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraName(System.UInt32)
public static SDL.CameraPermissionState GetCameraPermissionState(IntPtr camera);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera);
Query if camera access has been approved by the user.
Cameras will not function between when the device is opened by the app and when the user permits access to the hardware. On some platforms, this presents as a popup dialog where the user has to explicitly approve access; on others the approval might be implicit and not alert the user at all.
This function can be used to check the status of that approval. It will return SDL.CameraPermissionState.Pending if waiting for user response, SDL.CameraPermissionState.Approved if the camera is approved for use, and SDL.CameraPermissionState.Denied if the user denied access.
Instead of polling with this function, you can wait for a SDL.EventType.CameraDeviceApproved (or SDL.EventType.CameraDeviceDenied) event in the standard SDL event loop, which is guaranteed to be sent once when permission to use the camera is decided.
If a camera is declined, there's nothing to be done but call SDL.CloseCamera to dispose of it.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
the opened camera device to query. |
Returns
a SDL.CameraPermissionState value indicating if access is granted, or SDL.CameraPermissionState.Pending if the decision is still pending.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraPermissionState(System.IntPtr)
public static SDL.CameraPosition GetCameraPosition(uint instanceId);SDL declaration
extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraPosition(SDL_CameraID instance_id);
Get the position of the camera in relation to the system.
Most platforms will report SDL.CameraPosition.Unknown, but mobile devices, like phones, can often make a distinction between cameras on the front of the device (that points towards the user, for taking "selfies") and cameras on the back (for filming in the direction the user is facing).
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the camera device instance ID. |
Returns
the position of the camera on the system hardware.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraPosition(System.UInt32)
public static uint GetCameraProperties(IntPtr camera);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera *camera);
Get the properties associated with an opened camera.
Parameters
| Name | Type | Description |
|---|---|---|
camera |
IntPtr |
the SDL_Camera obtained from SDL.OpenCamera. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraProperties(System.IntPtr)
public static uint[] GetCameras(out int count);SDL declaration
extern SDL_DECLSPEC SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
Get a list of currently connected camera devices.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of cameras returned, may be null. |
Returns
a 0 terminated array of camera instance IDs or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameras(System.Int32@)
public static SDL.CameraSpec[] GetCameraSupportedFormats(uint instanceId, out int count);SDL declaration
extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count);
Get the list of native formats/sizes a camera supports.
This returns a list of all formats and frame sizes that a specific camera can offer. This is useful if your app can accept a variety of image formats and sizes and so want to find the optimal spec that doesn't require conversion.
This function isn't strictly required; if you call SDL.OpenCamera with a null spec, SDL will choose a native format for you, and if you instead specify a desired format, it will transparently convert to the requested format on your behalf.
If count is not null, it will be filled with the number of elements in the returned array.
Note that it's legal for a camera to supply an empty list. This is what will happen on Emscripten builds, since that platform won't tell anything about available cameras until you've opened one, and won't even tell if there is a camera until the user has given you permission to check through a scary warning popup.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the camera device instance ID. |
count |
out int |
a pointer filled in with the number of elements in the list, may be null. |
Returns
a null terminated array of pointers to SDL.CameraSpec or null on failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCameraSupportedFormats(System.UInt32,System.Int32@)
public static IntPtr GetClipboardData(string mimeType, out UIntPtr size);SDL declaration
extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size);
Get the data from the clipboard for a given mime type.
The size of text data does not include the terminator, but the text is guaranteed to be null-terminated.
Parameters
| Name | Type | Description |
|---|---|---|
mimeType |
string |
the mime type to read from the clipboard. |
size |
out UIntPtr |
a pointer filled in with the length of the returned data. |
Returns
the retrieved data buffer or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetClipboardData(System.String,System.UIntPtr@)
public static string[] GetClipboardMimeTypes(out UIntPtr numMimeTypes);SDL declaration
extern SDL_DECLSPEC char ** SDLCALL SDL_GetClipboardMimeTypes(size_t *num_mime_types);
Retrieve the list of mime types available in the clipboard.
Parameters
| Name | Type | Description |
|---|---|---|
numMimeTypes |
out UIntPtr |
a pointer filled with the number of mime types, may be null. |
Returns
a null-terminated array of strings with mime types, or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetClipboardMimeTypes(System.UIntPtr@)
public static string GetClipboardText();SDL declaration
extern SDL_DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
Get UTF-8 text from the clipboard.
This function returns an empty string if there is not enough memory left for a copy of the clipboard's content.
Returns
the clipboard text on success or an empty string on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetClipboardText
public static bool GetClosestFullscreenDisplayMode(uint displayID, int w, int h, float refreshRate, bool includeHighDensityModes, out SDL.DisplayMode closest);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest);
Get the closest match to the requested display mode.
The available display modes are scanned and closest is filled in with the closest mode matching the requested mode and returned. The mode format and refresh rate default to the desktop mode if they are set to 0. The modes are scanned with size being first priority, format being second priority, and finally checking the refresh rate. If all the available modes are too small, then false is returned.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
w |
int |
the width in pixels of the desired display mode. |
h |
int |
the height in pixels of the desired display mode. |
refreshRate |
float |
the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate. |
includeHighDensityModes |
bool |
boolean to include high density modes in the search. |
closest |
out SDL.DisplayMode |
a pointer filled in with the closest display mode equal to or larger than the desired mode. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetClosestFullscreenDisplayMode(System.UInt32,System.Int32,System.Int32,System.Single,System.Boolean,SDL3.SDL.DisplayMode@)
public static int GetCPUCacheLineSize();SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
Determine the L1 cache line size of the CPU.
This is useful for determining multi-threaded structure padding or SIMD prefetch sizes.
Returns
the L1 cache line size of the CPU, in bytes.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCPUCacheLineSize
public static string GetCurrentAudioDriver();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void);
Get the name of the current audio driver.
The names of drivers are all simple, low-ASCII identifiers, like "alsa", "coreaudio" or "wasapi". These never have Unicode characters, and are not meant to be proper names.
Returns
the name of the current audio driver or null if no driver has been initialized.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentAudioDriver
public static string GetCurrentCameraDriver();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void);
Get the name of the current camera driver.
The names of drivers are all simple, low-ASCII identifiers, like "v4l2", "coremedia" or "android". These never have Unicode characters, and are not meant to be proper names.
Returns
the name of the current camera driver or null if no driver has been initialized.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentCameraDriver
public static string GetCurrentDirectory();SDL declaration
extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void);
Get what the system believes is the "current working directory."
For systems without a concept of a current working directory, this will still attempt to provide something reasonable.
SDL does not provide a means to change the current working directory; for platforms without this concept, this would cause surprises with file access outside of SDL.
The returned path is guaranteed to end with a path separator (\\ on Windows, / on most other platforms).
Returns
a UTF-8 string of the current working directory in platform-dependent notation. null if there's a problem. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.8.
XML member id: M:SDL3.SDL.GetCurrentDirectory
public static SDL.DisplayMode? GetCurrentDisplayMode(uint displayID);SDL declaration
extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
Get information about the current display mode.
There's a difference between this function and SDL.GetDesktopDisplayMode when SDL runs fullscreen and has changed the resolution. In that case this function will return the current display mode, and not the previous native display mode.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
Returns
a pointer to the desktop display mode or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentDisplayMode(System.UInt32)
public static SDL.DisplayOrientation GetCurrentDisplayOrientation(uint displayID);SDL declaration
extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID);
Get the orientation of a display.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
Returns
the SDL.DisplayOrientation enum value of the display, or SDL.DisplayOrientation.Unknown if it isn't available.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentDisplayOrientation(System.UInt32)
public static bool GetCurrentRenderOutputSize(IntPtr renderer, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
Get the current output size in pixels of a rendering context.
If a rendering target is active, this will return the size of the rendering target in pixels, otherwise return the value of SDL.GetRenderOutputSize.
Rendering target or not, the output will be adjusted by the current logical presentation state, dictated by SDL.SetRenderLogicalPresentation.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
w |
out int |
a pointer filled in with the current width. |
h |
out int |
a pointer filled in with the current height. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentRenderOutputSize(System.IntPtr,System.Int32@,System.Int32@)
public static ulong GetCurrentThreadID();SDL declaration
extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetCurrentThreadID(void);
Get the thread identifier for the current thread.
This thread identifier is as reported by the underlying operating system. If SDL is running on a platform that does not support threads the return value will always be zero.
This function also returns a valid thread ID when called from the main thread.
Returns
the ID of the current thread.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentThreadID
public static bool GetCurrentTime(out long ticks);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentTime(SDL_Time *ticks);
Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coordinated Time (UTC).
Parameters
| Name | Type | Description |
|---|---|---|
ticks |
out long |
the SDL_Time to hold the returned tick count. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentTime(System.Int64@)
public static string GetCurrentVideoDriver();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void);
Get the name of the currently initialized video driver.
The names of drivers are all simple, low-ASCII identifiers, like "cocoa", "x11" or "windows". These never have Unicode characters, and are not meant to be proper names.
Returns
the name of the current video driver or null if no driver has been initialized.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCurrentVideoDriver
public static IntPtr GetCursor();SDL declaration
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
Get the active cursor.
This function returns a pointer to the current cursor which is owned by the library. It is not necessary to free the cursor with SDL.DestroyCursor.
Returns
the active cursor or null if there is no mouse.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetCursor
public static bool GetDateTimeLocalePreferences(out SDL.DateFormat dateFormat, out SDL.TimeFormat timeFormat);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat);
Gets the current preferred date and time format for the system locale.
This might be a "slow" call that has to query the operating system. It's best to ask for this once and save the results. However, the preferred formats can change, usually because the user has changed a system preference outside of your program.
Parameters
| Name | Type | Description |
|---|---|---|
dateFormat |
out SDL.DateFormat |
a pointer to the SDL.DateFormat to hold the returned date format, may be null. |
timeFormat |
out SDL.TimeFormat |
a pointer to the SDL.TimeFormat to hold the returned time format, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function is not thread safe.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDateTimeLocalePreferences(SDL3.SDL.DateFormat@,SDL3.SDL.TimeFormat@)
public static int GetDayOfWeek(int year, int month, int day);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfWeek(int year, int month, int day);
Get the day of week for a calendar date.
Parameters
| Name | Type | Description |
|---|---|---|
year |
int |
the year component of the date. |
month |
int |
the month component of the date. |
day |
int |
the day component of the date. |
Returns
a value between 0 and 6 (0 being Sunday) if the date is valid or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDayOfWeek(System.Int32,System.Int32,System.Int32)
public static int GetDayOfYear(int year, int month, int day);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfYear(int year, int month, int day);
Get the day of year for a calendar date.
Parameters
| Name | Type | Description |
|---|---|---|
year |
int |
the year component of the date. |
month |
int |
the month component of the date. |
day |
int |
the day component of the date. |
Returns
the day of year [0-365] if the date is valid or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDayOfYear(System.Int32,System.Int32,System.Int32)
public static int GetDaysInMonth(int year, int month);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetDaysInMonth(int year, int month);
Get the number of days in a month for a given year.
Parameters
| Name | Type | Description |
|---|---|---|
year |
int |
the year. |
month |
int |
the month [1-12]. |
Returns
the number of days in the requested month or -1 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDaysInMonth(System.Int32,System.Int32)
public static SDL.AssertionHandler GetDefaultAssertionHandler();SDL declaration
extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
Get the default assertion handler.
This returns the function pointer that is called by default when an assertion is triggered. This is an internal function provided by SDL, that is used for assertions when SDL.SetAssertionHandler hasn't been used to provide a different function.
Returns
the default SDL.AssertionHandler that is called when an assert triggers.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDefaultAssertionHandler
public static IntPtr GetDefaultCursor();SDL declaration
extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void);
Get the default cursor.
You do not have to call SDL.DestroyCursor on the return value, but it is safe to do so.
Returns
the default cursor on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDefaultCursor
public static SDL.LogOutputFunction GetDefaultLogOutputFunction();SDL declaration
extern SDL_DECLSPEC SDL_LogOutputFunction SDLCALL SDL_GetDefaultLogOutputFunction(void);
Get the default log output function.
Returns
the default log output callback. It should be called with null for the userdata argument.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.1.6.
XML member id: M:SDL3.SDL.GetDefaultLogOutputFunction
public static bool GetDefaultTextureScaleMode(IntPtr renderer, out SDL.ScaleMode scaleMode);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode);
Get default texture scale mode of the given renderer.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the renderer to get data from. |
scaleMode |
out SDL.ScaleMode |
a SDL.ScaleMode filled with current default scale mode. See SDL.SetDefaultTextureScaleMode for the meaning of the value. |
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.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.GetDefaultTextureScaleMode(System.IntPtr,SDL3.SDL.ScaleMode@)
public static SDL.DisplayMode? GetDesktopDisplayMode(uint displayID);SDL declaration
extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID);
Get information about the desktop's display mode.
There's a difference between this function and SDL.GetCurrentDisplayMode when SDL runs fullscreen and has changed the resolution. In that case this function will return the previous native display mode, and not the current display mode.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
Returns
a pointer to the desktop display mode or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDesktopDisplayMode(System.UInt32)
public static int GetDirect3D9AdapterIndex(uint displayID);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID);
Get the D3D9 adapter index that matches the specified display.
The returned adapter index can be passed to IDirect3D9::CreateDevice and controls on which monitor a full screen application will appear.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance of the display to query. |
Returns
the D3D9 adapter index on success or -1 on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDirect3D9AdapterIndex(System.UInt32)
public static bool GetDisplayBounds(uint displayID, out SDL.Rect rect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
Get the desktop area represented by a display.
The primary display is often located at (0,0), but may be placed at a different location depending on monitor layout.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
rect |
out SDL.Rect |
the SDL.Rect structure filled in with the display bounds. |
Returns
success on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayBounds(System.UInt32,SDL3.SDL.Rect@)
public static float GetDisplayContentScale(uint displayID);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID);
Get the content scale of a display.
The content scale is the expected scale for content based on the DPI settings of the display. For example, a 4K display might have a 2.0 (200%) display scale, which means that the user expects UI elements to be twice as big on this display, to aid in readability.
After window creation, SDL.GetWindowDisplayScale should be used to query the content scale factor for individual windows instead of querying the display for a window and calling this function, as the per-window content scale factor may differ from the base value of the display it is on, particularly on high-DPI and/or multi-monitor desktop configurations.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
Returns
the content scale of the display, or 0.0f on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayContentScale(System.UInt32)
public static uint GetDisplayForPoint(SDL.Point point);SDL declaration
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
Get the display containing a point.
Parameters
| Name | Type | Description |
|---|---|---|
point |
SDL.Point |
the point to query. |
Returns
the instance ID of the display containing the point or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayForPoint(SDL3.SDL.Point)
public static uint GetDisplayForRect(SDL.Rect rect);SDL declaration
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
Get the display primarily containing a rect.
Parameters
| Name | Type | Description |
|---|---|---|
rect |
SDL.Rect |
the rect to query. |
Returns
the instance ID of the display entirely containing the rect or closest to the center of the rect on success or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayForRect(SDL3.SDL.Rect)
public static uint GetDisplayForWindow(IntPtr window);SDL declaration
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
Get the display associated with a window.
Parameters
| Name | Type | Description |
|---|---|---|
window |
IntPtr |
the window to query. |
Returns
the instance ID of the display containing the center of the window on success or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayForWindow(System.IntPtr)
public static string GetDisplayName(uint displayID);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
Get the name of a display in UTF-8 encoding.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
Returns
the name of a display or null on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayName(System.UInt32)
public static uint GetDisplayProperties(uint displayID);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
Get the properties associated with a display.
The following read-only properties are provided by SDL:
-
SDL.Props.DisplayHDREnabledBoolean:trueif the display has HDR headroom above the SDR white point. This is for informational and diagnostic purposes only, as not all platforms provide this information at the display level. On KMS/DRM: -
SDL.Props.DisplayKMSDRMPanelOrientationNumber: the "panel orientation" property for the display in degrees of clockwise rotation. Note that this is provided only as a hint, and the application is responsible for any coordinate transformations needed to conform to the requested display orientation. On Wayland: -
SDL.Props.DisplayWaylandWLOutputPointer: the wl_output associated with the display On Windows: -
SDL.Props.DisplayWindowsHMonitorPointer: the monitor handle (HMONITOR) associated with the display
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
displayID the instance ID of the display to query. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayProperties(System.UInt32)
public static uint[] GetDisplays(out int count);SDL declaration
extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count);
Get a list of currently connected displays.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of displays returned, may be null. |
Returns
a 0 terminated array of display instance IDs or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplays(System.Int32@)
public static bool GetDisplayUsableBounds(uint displayID, out SDL.Rect rect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
Get the usable desktop area represented by a display, in screen coordinates.
This is the same area as SDL.GetDisplayBounds reports, but with portions reserved by the system removed. For example, on Apple's macOS, this subtracts the area occupied by the menu bar and dock.
Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
rect |
out SDL.Rect |
the SDL.Rect structure filled in with the display bounds. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDisplayUsableBounds(System.UInt32,SDL3.SDL.Rect@)
public static bool GetDXGIOutputInfo(uint displayID, out int adapterIndex, out int outputIndex);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
Get the DXGI Adapter and Output indices for the specified display.
The DXGI Adapter and Output indices can be passed to EnumAdapters and EnumOutputs respectively to get the objects required to create a DX10 or DX11 device and swap chain.
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance of the display to query. |
adapterIndex |
out int |
a pointer to be filled in with the adapter index. |
outputIndex |
out int |
a pointer to be filled in with the output index. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetDXGIOutputInfo(System.UInt32,System.Int32@,System.Int32@)
public static IntPtr GetEnvironment();SDL declaration
extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_GetEnvironment(void);
Get the process environment.
This is initialized at application start and is not affected by setenv() and unsetenv() calls after that point. Use SDL.SetEnvironmentVariable and SDL.UnsetEnvironmentVariable if you want to modify this environment, or SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist in the C runtime environment after SDL.Quit.
Returns
a pointer to the environment for the process or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetEnvironment
public static string GetEnvironmentVariable(IntPtr env, string name);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name);
Get the value of a variable in the environment.
The name of the variable is case sensitive on all platforms.
This function uses SDL's cached copy of the environment and is thread-safe.
Parameters
| Name | Type | Description |
|---|---|---|
env |
IntPtr |
the environment to query. |
name |
string |
the name of the variable to get. |
Returns
a pointer to the value of the variable or null if it can't be found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0.
XML member id: M:SDL3.SDL.GetEnvironmentVariable(System.IntPtr,System.String)
public static string[] GetEnvironmentVariables(IntPtr env);SDL declaration
extern SDL_DECLSPEC char ** SDLCALL SDL_GetEnvironmentVariables(SDL_Environment *env);
Get all variables in the environment.
Parameters
| Name | Type | Description |
|---|---|---|
env |
IntPtr |
the environment to query. |
Returns
a null terminated array of pointers to environment variables in the form "variable=value" or null on failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetEnvironmentVariables(System.IntPtr)
public static string GetError();SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetError(void);
Retrieve a message about the last error that occurred on the current thread.
It is possible for multiple errors to occur before calling SDL.GetError. Only the last error is returned.
The message is only applicable when an SDL function has signaled an error. You must check the return values of SDL function calls to determine when to appropriately call SDL.GetError. You should not use the results of SDL.GetError to decide if an error has occurred! Sometimes SDL will set an error string even when reporting success.
SDL will not clear the error string for successful API calls. You must check return values for failure cases before you can assume the error string applies.
Error strings are set per-thread, so an error set in a different thread will not interfere with the current thread's operation.
The returned value is a thread-local string which will remain valid until the current thread's error string is changed. The caller should make a copy if the value is needed after the next SDL API call.
Returns
a message with information about the specific error that occurred, or an empty string if there hasn't been an error message set since the last call to SDL.ClearError.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetError
public static int GetEventDescription(in IntPtr event, byte[] buf, int buflen);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen);
Generate a human-readable description of an event.
This will fill buf with a null-terminated string that might look something like this:
c EventMouseMotion(timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
The exact format of the string is not guaranteed; it is intended for logging purposes, to be read by a human, and not parsed by a computer.
The returned value follows the same rules as SDL_snprintf(): buf will always be null-terminated (unless buflen is zero), and will be truncated if buflen is too small. The return code is the number of bytes needed for the complete string, not counting the null-terminator, whether the string was truncated or not. Unlike SDL_snprintf(), though, this function never returns -1.
Parameters
| Name | Type | Description |
|---|---|---|
event |
in IntPtr |
an event to describe. May be null. |
buf |
byte[] |
the buffer to fill with the description string. May be null. |
buflen |
int |
the maximum bytes that can be written to buf. |
Returns
number of bytes needed for the full string, not counting the null-terminator byte.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.GetEventDescription(System.IntPtr@,System.Byte[],System.Int32)
public static int GetEventDescription(in IntPtr event, Span<byte> buf, int buflen);Parameters
| Name | Type | Description |
|---|---|---|
event |
in IntPtr |
|
buf |
Span<byte> |
|
buflen |
int |
XML member id: M:SDL3.SDL.GetEventDescription(System.IntPtr@,System.Span{System.Byte},System.Int32)
public static int GetEventDescription(in SDL.Event event, byte[] buf, int buflen);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen);
Generate a human-readable description of an event.
This will fill buf with a null-terminated string that might look something like this:
c EventMouseMotion(timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
The exact format of the string is not guaranteed; it is intended for logging purposes, to be read by a human, and not parsed by a computer.
The returned value follows the same rules as SDL_snprintf(): buf will always be null-terminated (unless buflen is zero), and will be truncated if buflen is too small. The return code is the number of bytes needed for the complete string, not counting the null-terminator, whether the string was truncated or not. Unlike SDL_snprintf(), though, this function never returns -1.
Parameters
| Name | Type | Description |
|---|---|---|
event |
in SDL.Event |
an event to describe. May be null. |
buf |
byte[] |
the buffer to fill with the description string. May be null. |
buflen |
int |
the maximum bytes that can be written to buf. |
Returns
number of bytes needed for the full string, not counting the null-terminator byte.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.GetEventDescription(SDL3.SDL.Event@,System.Byte[],System.Int32)
public static int GetEventDescription(in SDL.Event event, Span<byte> buf, int buflen);Parameters
| Name | Type | Description |
|---|---|---|
event |
in SDL.Event |
|
buf |
Span<byte> |
|
buflen |
int |
XML member id: M:SDL3.SDL.GetEventDescription(SDL3.SDL.Event@,System.Span{System.Byte},System.Int32)
public static bool GetEventFilter(out SDL.EventFilter filter, out IntPtr userdata);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata);
Query the current event filter.
This function can be used to "chain" filters, by saving the existing filter before replacing it with a function that will call that saved filter.
Parameters
| Name | Type | Description |
|---|---|---|
filter |
out SDL.EventFilter |
the current callback function will be stored here. |
userdata |
out IntPtr |
the pointer that is passed to the current event filter will be stored here. |
Returns
true on success or false if there is no event filter set.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetEventFilter(SDL3.SDL.EventFilter@,System.IntPtr@)
public static float GetFloatProperty(uint props, string name, float defaultValue);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float default_value);
Get a floating point property from a group of properties.
You can use SDL.GetPropertyType to query whether the property exists and is a floating point property.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to query. |
name |
string |
the name of the property to query. |
defaultValue |
float |
the default value of the property. |
Returns
the value of the property, or defaultValue if it is not set or not a float property.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetFloatProperty(System.UInt32,System.String,System.Single)
public static SDL.DisplayMode[] GetFullscreenDisplayModes(uint displayID, out int count);SDL declaration
extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
Get a list of fullscreen display modes available on a display.
The display modes are sorted in this priority:
- w -> largest to smallest
- h -> largest to smallest
- bits per pixel -> more colors to fewer colors
- packed pixel layout -> largest to smallest
- refresh rate -> highest to lowest
- pixel density -> lowest to highest
Parameters
| Name | Type | Description |
|---|---|---|
displayID |
uint |
the instance ID of the display to query. |
count |
out int |
a pointer filled in with the number of display modes returned, may be null. |
Returns
a null terminated array of display mode pointers or null on failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetFullscreenDisplayModes(System.UInt32,System.Int32@)
public static string GetGamepadAppleSFSymbolsNameForAxis(IntPtr gamepad, SDL.GamepadAxis axis);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad to query. |
axis |
SDL.GamepadAxis |
an axis on the gamepad. |
Returns
the sfSymbolsName or null if the name can't be found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadAppleSFSymbolsNameForAxis(System.IntPtr,SDL3.SDL.GamepadAxis)
public static string GetGamepadAppleSFSymbolsNameForButton(IntPtr gamepad, SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
Return the sfSymbolsName for a given button on a gamepad on Apple platforms.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad to query. |
button |
SDL.GamepadButton |
a button on the gamepad. |
Returns
the sfSymbolsName or null if the name can't be found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadAppleSFSymbolsNameForButton(System.IntPtr,SDL3.SDL.GamepadButton)
public static short GetGamepadAxis(IntPtr gamepad, SDL.GamepadAxis axis);SDL declaration
extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
Get the current state of an axis control on a gamepad.
The axis indices start at index 0.
For thumbsticks, the state is a value ranging from -32768 (up/left) to 32767 (down/right).
Triggers range from 0 when released to 32767 when fully pressed, and never return a negative value. Note that this differs from the value reported by the lower-level SDL.GetJoystickAxis, which normally uses the full range.
Note that for invalid gamepads or axes, this will return 0. Zero is also a valid value in normal operation; usually it means a centered axis.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
axis |
SDL.GamepadAxis |
an axis index (one of the SDL.GamepadAxis values). |
Returns
axis state.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadAxis(System.IntPtr,SDL3.SDL.GamepadAxis)
public static SDL.GamepadAxis GetGamepadAxisFromString(string str);SDL declaration
extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
Convert a string into SDL.GamepadAxis enum.
This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.
Note specially that "righttrigger" and "lefttrigger" map to SDL.GamepadAxis.RightTrigger and SDL.GamepadAxis.LeftTrigger, respectively.
Parameters
| Name | Type | Description |
|---|---|---|
str |
string |
string representing a SDL_Gamepad axis. |
Returns
the SDL.GamepadAxis enum corresponding to the input string, or SDL.GamepadAxis.Invalid if no match was found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadAxisFromString(System.String)
public static SDL.GamepadBinding[] GetGamepadBindings(IntPtr gamepad, out int count);SDL declaration
extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
Get the SDL joystick layer bindings for a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
count |
out int |
a pointer filled in with the number of bindings returned. |
Returns
a null terminated array of pointers to bindings or nullon failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadBindings(System.IntPtr,System.Int32@)
public static bool GetGamepadButton(IntPtr gamepad, SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
Get the current state of a button on a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
button |
SDL.GamepadButton |
a button index (one of the SDL_GamepadButton values). |
Returns
true if the button is pressed, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadButton(System.IntPtr,SDL3.SDL.GamepadButton)
public static SDL.GamepadButton GetGamepadButtonFromString(string str);SDL declaration
extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
Convert a string into an SDL_GamepadButton enum.
This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.
Parameters
| Name | Type | Description |
|---|---|---|
str |
string |
string representing a SDL_Gamepad button. |
Returns
the SDL.GamepadButton enum corresponding to the input string, or SDL.GamepadButton.Invalid if no match was found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadButtonFromString(System.String)
public static SDL.GamepadButtonLabel GetGamepadButtonLabel(IntPtr gamepad, SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);
Get the label of a button on a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
button |
SDL.GamepadButton |
a button index (one of the SDL.GamepadButton values). |
Returns
the SDL.GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadButtonLabel(System.IntPtr,SDL3.SDL.GamepadButton)
public static SDL.GamepadButtonLabel GetGamepadButtonLabelForType(SDL.GamepadType type, SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
Get the label of a button on a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
type |
SDL.GamepadType |
the type of gamepad to check. |
button |
SDL.GamepadButton |
a button index (one of the SDL.GamepadButton values). |
Returns
the SDL.GamepadButtonLabel enum corresponding to the button label.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadButtonLabelForType(SDL3.SDL.GamepadType,SDL3.SDL.GamepadButton)
public static SDL.JoystickConnectionState GetGamepadConnectionState(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);
Get the connection state of a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the connection state on success or SDL.JoystickConnectionState.Invalid on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadConnectionState(System.IntPtr)
public static ushort GetGamepadFirmwareVersion(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
Get the firmware version of an opened gamepad, if available.
If the firmware version isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the gamepad firmware version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadFirmwareVersion(System.IntPtr)
public static IntPtr GetGamepadFromID(uint instanceID);SDL declaration
extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);
Get the SDL_Gamepad associated with a joystick instance ID, if it has been opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID of the gamepad. |
Returns
an SDL_Gamepad on success or null on failure or if it hasn't been opened yet; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadFromID(System.UInt32)
public static IntPtr GetGamepadFromPlayerIndex(int playerIndex);SDL declaration
extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
Get the SDL_Gamepad associated with a player index.
Parameters
| Name | Type | Description |
|---|---|---|
playerIndex |
int |
the player index, which different from the instance ID. |
Returns
the SDL_Gamepad associated with a player index.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadFromPlayerIndex(System.Int32)
public static SDL.GUID GetGamepadGUIDForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
Get the implementation-dependent GUID of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the GUID of the selected gamepad. If called on an invalid index, this function returns a zero GUID.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadGUIDForID(System.UInt32)
public static uint GetGamepadID(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
Get the instance ID of an opened gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Returns
the instance ID of the specified gamepad on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadID(System.IntPtr)
public static IntPtr GetGamepadJoystick(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
Get the underlying joystick from a gamepad.
This function will give you a SDL_Joystick object, which allows you to use the SDL_Joystick functions with a SDL_Gamepad object. This would be useful for getting a joystick's position at any given time, even if it hasn't moved (moving it would produce an event, which would have the axis' value).
The pointer returned is owned by the SDL_Gamepad. You should not call SDL.CloseJoystick on it, for example, since doing so will likely cause SDL to crash.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object that you want to get a joystick from. |
Returns
an SDL_Joystick object, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadJoystick(System.IntPtr)
public static string GetGamepadMapping(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
Get the current mapping of a gamepad.
Details about mappings are discussed with SDL.AddGamepadMapping.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad you want to get the current mapping for. |
Returns
a string that has the gamepad's mapping or null if no mapping is available; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadMapping(System.IntPtr)
public static string GetGamepadMappingForGUID(SDL.GUID guid);SDL declaration
extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
Get the gamepad mapping string for a given GUID.
Parameters
| Name | Type | Description |
|---|---|---|
guid |
SDL.GUID |
a structure containing the GUID for which a mapping is desired. |
Returns
a mapping string or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadMappingForGUID(SDL3.SDL.GUID)
public static string GetGamepadMappingForID(uint instanceId);SDL declaration
extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
Get the mapping of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the joystick instance ID. |
Returns
the mapping string. Returns null if no mapping is available. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadMappingForID(System.UInt32)
public static string[] GetGamepadMappings(out int count);SDL declaration
extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
Get the current gamepad mappings.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of mappings returned, can be null. |
Returns
an array of the mapping strings, null-terminated, or null on failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadMappings(System.Int32@)
public static string GetGamepadName(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
Get the implementation-dependent name for an opened gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Returns
the implementation dependent name for the gamepad, or null if there is no name or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadName(System.IntPtr)
public static string GetGamepadNameForID(uint instanceId);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id);
Get the implementation dependent name of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the joystick instance ID. |
Returns
the name of the selected gamepad. If no name can be found, this function returns null; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadNameForID(System.UInt32)
public static string GetGamepadPath(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
Get the implementation-dependent path for an opened gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Returns
the implementation dependent path for the gamepad, or null if there is no path or the identifier passed is invalid.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadPath(System.IntPtr)
public static string GetGamepadPathForID(uint instanceId);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id);
Get the implementation dependent path of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
uint |
the joystick instance ID. |
Returns
the path of the selected gamepad. If no path can be found, this function returns null; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadPathForID(System.UInt32)
public static int GetGamepadPlayerIndex(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
Get the player index of an opened gamepad.
For XInput gamepads this returns the XInput user index.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the player index for gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadPlayerIndex(System.IntPtr)
public static int GetGamepadPlayerIndexForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);
Get the player index of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the player index of a gamepad, or -1 if it's not available.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadPlayerIndexForID(System.UInt32)
public static SDL.PowerState GetGamepadPowerInfo(IntPtr gamepad, out int percent);SDL declaration
extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
Get the battery state of a gamepad.
You should never take a battery status as absolute truth. Batteries (especially failing batteries) are delicate hardware, and the values reported here are best estimates based on what that hardware reports. It's not uncommon for older batteries to lose stored power much faster than it reports, or completely drain when reporting it has 20 percent left, etc.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
percent |
out int |
a pointer filled in with the percentage of battery life left, between 0 and 100, or null to ignore. This will be filled in with -1 we can't determine a value or there is no battery. |
Returns
the current battery state.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadPowerInfo(System.IntPtr,System.Int32@)
public static ushort GetGamepadProduct(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
Get the USB product ID of an opened gamepad, if available.
If the product ID isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the USB product ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadProduct(System.IntPtr)
public static ushort GetGamepadProductForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id);
Get the USB product ID of a gamepad, if available.
This can be called before any gamepads are opened. If the product ID isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the USB product ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadProductForID(System.UInt32)
public static ushort GetGamepadProductVersion(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
Get the product version of an opened gamepad, if available.
If the product version isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the USB product version, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadProductVersion(System.IntPtr)
public static ushort GetGamepadProductVersionForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);
Get the product version of a gamepad, if available.
This can be called before any gamepads are opened. If the product version isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the product version of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadProductVersionForID(System.UInt32)
public static uint GetGamepadProperties(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
Get the properties associated with an opened gamepad.
These properties are shared with the underlying joystick object.
The following read-only properties are provided by SDL:
-
SDL.Props.GamepadCapMonoLedBoolean:trueif this gamepad has an LED that has adjustable brightness -
SDL.Props.GamepadCapRGBLedBoolean:trueif this gamepad has an LED that has adjustable color -
SDL.Props.GamepadCapPlayerLedBoolean:trueif this gamepad has a player LED -
SDL.Props.GamepadCapRumbleBoolean:trueif this gamepad has left/right rumble -
SDL.Props.GamepadCapTriggerRumbleBoolean:trueif this gamepad has simple trigger rumble
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad identifier previously returned by SDL.OpenGamepad. |
Returns
a valid property ID on success or 0 on failure; call It is safe to call this function from any thread.SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadProperties(System.IntPtr)
public static uint[] GetGamepads(out int count);SDL declaration
extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
Get a list of currently connected gamepads.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of gamepads returned, may be null. |
Returns
a 0 terminated array of joystick instance IDs or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepads(System.Int32@)
public static bool GetGamepadSensorData(IntPtr gamepad, SDL.SensorType type, out float[] data, int numValues);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
Get the current state of a gamepad sensor.
The number of values and interpretation of the data is sensor dependent. See the remarks in SDL.SensorType for details for each type of sensor.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad to query. |
type |
SDL.SensorType |
the type of sensor to query. |
data |
out float[] |
a pointer filled with the current sensor state. |
numValues |
int |
the number of values to write to data. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadSensorData(System.IntPtr,SDL3.SDL.SensorType,System.Single[]@,System.Int32)
public static bool GetGamepadSensorData(IntPtr gamepad, SDL.SensorType type, Span<float> data, int numValues);Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
|
type |
SDL.SensorType |
|
data |
Span<float> |
|
numValues |
int |
XML member id: M:SDL3.SDL.GetGamepadSensorData(System.IntPtr,SDL3.SDL.SensorType,System.Span{System.Single},System.Int32)
public static float GetGamepadSensorDataRate(IntPtr gamepad, SDL.SensorType type);SDL declaration
extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
Get the data rate (number of events per second) of a gamepad sensor.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad to query. |
type |
SDL.SensorType |
the type of sensor to query. |
Returns
the data rate, or 0.0f if the data rate is not available.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadSensorDataRate(System.IntPtr,SDL3.SDL.SensorType)
public static string GetGamepadSerial(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
Get the serial number of an opened gamepad, if available.
Returns the serial number of the gamepad, or null if it is not available.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the serial number, or null if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadSerial(System.IntPtr)
public static ulong GetGamepadSteamHandle(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
Get the Steam Input handle of an opened gamepad, if available.
Returns an InputHandle_t for the gamepad that can be used with Steam Input API: https://partner.steamgames.com/doc/api/ISteamInput
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the gamepad handle, or 0 if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadSteamHandle(System.IntPtr)
public static string GetGamepadStringForAxis(SDL.GamepadAxis axis);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
Convert from an SDL_GamepadAxis enum to a string.
Parameters
| Name | Type | Description |
|---|---|---|
axis |
SDL.GamepadAxis |
an enum value for a given SDL.GamepadAxis. |
Returns
a string for the given axis, or null if an invalid axis is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadStringForAxis(SDL3.SDL.GamepadAxis)
public static string GetGamepadStringForButton(SDL.GamepadButton button);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
Convert from an SDL.GamepadButton enum to a string.
Parameters
| Name | Type | Description |
|---|---|---|
button |
SDL.GamepadButton |
an enum value for a given SDL.GamepadButton. |
Returns
a string for the given button, or null if an invalid button is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadStringForButton(SDL3.SDL.GamepadButton)
public static string GetGamepadStringForType(SDL.GamepadType type);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
Convert from an SDL.GamepadType enum to a string.
Parameters
| Name | Type | Description |
|---|---|---|
type |
SDL.GamepadType |
an enum value for a given SDL.GamepadType. |
Returns
a string for the given type, or null if an invalid type is specified. The string returned is of the format used by SDL_Gamepad mapping strings.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadStringForType(SDL3.SDL.GamepadType)
public static bool GetGamepadTouchpadFinger(IntPtr gamepad, int touchpad, int finger, out bool down, out float x, out float y, out float pressure);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);
Get the current state of a finger on a touchpad on a gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
a gamepad. |
touchpad |
int |
a touchpad. |
finger |
int |
a finger. |
down |
out bool |
a pointer filled with true if the finger is down, false otherwise, may be null. |
x |
out float |
a pointer filled with the x position, normalized 0 to 1, with the origin in the upper left, may be null. |
y |
out float |
a pointer filled with the y position, normalized 0 to 1, with the origin in the upper left, may be null. |
pressure |
out float |
a pointer filled with pressure value, may be null. |
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.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadTouchpadFinger(System.IntPtr,System.Int32,System.Int32,System.Boolean@,System.Single@,System.Single@,System.Single@)
public static SDL.GamepadType GetGamepadType(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
Get the type of an opened gamepad.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the gamepad type, or SDL.GamepadType.Unknown if it's not available.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadType(System.IntPtr)
public static SDL.GamepadType GetGamepadTypeForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);
Get the type of a gamepad.
This can be called before any gamepads are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the gamepad type.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadTypeForID(System.UInt32)
public static SDL.GamepadType GetGamepadTypeFromString(string str);SDL declaration
extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
Convert a string into SDL.GamepadType enum.
This function is called internally to translate SDL_Gamepad mapping strings for the underlying joystick device into the consistent SDL_Gamepad mapping. You do not normally need to call this function unless you are parsing SDL_Gamepad mappings in your own code.
Parameters
| Name | Type | Description |
|---|---|---|
str |
string |
string representing a SDL.GamepadType type. |
Returns
the SDL.GamepadType enum corresponding to the input string, or SDL.GamepadType.Unknown if no match was found.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadTypeFromString(System.String)
public static ushort GetGamepadVendor(IntPtr gamepad);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
Get the USB vendor ID of an opened gamepad, if available.
If the vendor ID isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
gamepad |
IntPtr |
the gamepad object to query. |
Returns
the USB vendor ID, or zero if unavailable.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadVendor(System.IntPtr)
public static ushort GetGamepadVendorForID(uint instanceID);SDL declaration
extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);
Get the USB vendor ID of a gamepad, if available.
This can be called before any gamepads are opened. If the vendor ID isn't available this function returns 0.
Parameters
| Name | Type | Description |
|---|---|---|
instanceID |
uint |
the joystick instance ID. |
Returns
the USB vendor ID of the selected gamepad. If called on an invalid index, this function returns zero.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGamepadVendorForID(System.UInt32)
public static bool GetGDKDefaultUser(out IntPtr outUserHandle);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle);
Gets a reference to the default user handle for GDK.
This is effectively a synchronous version of XUserAddAsync, which always prefers the default user and allows a sign-in UI.
Parameters
| Name | Type | Description |
|---|---|---|
outUserHandle |
out IntPtr |
a pointer to be filled in with the default user handle. |
Returns
true if success or false on failure; call SDL_GetError() for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGDKDefaultUser(System.IntPtr@)
public static bool GetGDKTaskQueue(out IntPtr outTaskQueue);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue);
Gets a reference to the global async task queue handle for GDK, initializing if needed.
Once you are done with the task queue, you should call XTaskQueueCloseHandle to reduce the reference count to avoid a resource leak.
Parameters
| Name | Type | Description |
|---|---|---|
outTaskQueue |
out IntPtr |
a pointer to be filled in with task queue handle. |
Returns
true on success or false on failure; call SDL_GetError() for more information.
XML member id: M:SDL3.SDL.GetGDKTaskQueue(System.IntPtr@)
public static SDL.MouseButtonFlags GetGlobalMouseState(out float x, out float y);SDL declaration
extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
Query the platform for the asynchronous mouse button state and the desktop-relative platform-cursor position.
This function immediately queries the platform for the most recent asynchronous state, more costly than retrieving SDL's cached state in SDL.GetMouseState.
Passing non-null pointers to x or y will write the destination with respective x or y coordinates relative to the desktop.
In Relative Mode, the platform-cursor's position usually contradicts the SDL-cursor's position as manually calculated from SDL.GetMouseState and SDL.GetWindowPosition.
This function can be useful if you need to track the mouse outside of a specific window and SDL.CaptureMouse doesn't fit your needs. For example, it could be useful if you need to track the mouse while dragging a window, where coordinates relative to a window might not be in sync at all times.
Parameters
| Name | Type | Description |
|---|---|---|
x |
out float |
a pointer to receive the platform-cursor's x-position from the desktop's top left corner, can be null if unused. |
y |
out float |
a pointer to receive the platform-cursor's y-position from the desktop's top left corner, can be null if unused. |
Returns
a 32-bit bitmask of the button state that can be bitwise-compared against the SDL.ButtonMask macro.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGlobalMouseState(System.Single@,System.Single@)
public static uint GetGlobalProperties();SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGlobalProperties(void);
Get the global SDL properties.
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGlobalProperties
public static string GetGPUDeviceDriver(IntPtr device);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device);
Returns the name of the backend used to create this GPU context.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context to query. |
Returns
the name of the device's driver, or null on error.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGPUDeviceDriver(System.IntPtr)
public static uint GetGPUDeviceProperties(IntPtr device);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device);
Get the properties associated with a GPU device.
All properties are optional and may differ between GPU backends and SDL versions.
The following properties are provided by SDL:
SDL.Props.GPUDeviceNameString: Contains the name of the underlying device as reported by the system driver. This string has no standardized format, is highly inconsistent between hardware devices and drivers, and is able to change at any time. Do not attempt to parse this string as it is bound to fail at some point in the future when system drivers are updated, new hardware devices are introduced, or when SDL adds new GPU backends or modifies existing ones.
Strings that have been found in the wild include:
- GTX 970
- GeForce GTX 970
- NVIDIA GeForce GTX 970
- Microsoft Direct3D12 (NVIDIA GeForce GTX 970)
- NVIDIA Graphics Device
- GeForce GPU
- P106-100
- AMD 15D8:C9
- AMD Custom GPU 0405
- AMD Radeon (TM) Graphics
- ASUS Radeon RX 470 Series
- Intel(R) Arc(tm) A380 Graphics (DG2)
- Virtio-GPU Venus (NVIDIA TITAN V)
- SwiftShader Device (LLVM 16.0.0)
- llvmpipe (LLVM 15.0.4, 256 bits)
- Microsoft Basic Render Driver
- unknown device The above list shows that the same device can have different formats, the vendor name may or may not appear in the string, the included vendor name may not be the vendor of the chipset on the device, some manufacturers include pseudo-legal marks while others don't, some devices may not use a marketing name in the string, the device string may be wrapped by the name of a translation interface, the device may be emulated in software, or the string may contain generic text that does not identify the device at all.
SDL.Props.GPUDeviceDriverNameString: Contains the self-reported name of the underlying system driver.
Strings that have been found in the wild include:
- Intel Corporation
- Intel open-source Mesa driver
- Qualcomm Technologies Inc. Adreno Vulkan Driver
- MoltenVK
- Mali-G715
- venus
SDL.Props.GPUDeviceDriverVersionString: Contains the self-reported version of the underlying system driver. This is a relatively short version string in an unspecified format. IfSDL.Props.GPUDeviceDriverInfoStringis available then that property should be preferred over this one as it may contain additional information that is useful for identifying the exact driver version used.
Strings that have been found in the wild include:
- 53.0.0
- 0.405.2463
- 32.0.15.6614
SDL.Props.GPUDeviceDriverInfoString: Contains the detailed version information of the underlying system driver as reported by the driver. This is an arbitrary string with no standardized format and it may contain newlines. This property should be preferred overSDL.Props.GPUDeviceDriverVersionStringif it is available as it usually contains the same information but in a format that is easier to read.
Strings that have been found in the wild include:
- 101.6559
- 1.2.11
- Mesa 21.2.2 (LLVM 12.0.1)
- Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa)
- v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129 This string has also been observed to be a multiline string (which has a trailing newline):
c Driver Build: 85da404, I46ff5fc46f, 1606794520 Date: 11/30/20 Compiler Version: EV031.31.04.01 Driver Branch: promo490_3_Google
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context to query. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.GetGPUDeviceProperties(System.IntPtr)
public static string GetGPUDriver(int index);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index);
Get the name of a built in GPU driver.
The GPU drivers are presented in the order in which they are normally checked during initialization.
The names of drivers are all simple, low-ASCII identifiers, like "vulkan", "metal" or "direct3d12". These never have Unicode characters, and are not meant to be proper names.
Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
the index of a GPU driver. |
Returns
the name of the GPU driver with the given index.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGPUDriver(System.Int32)
public static IntPtr GetGPURendererDevice(IntPtr renderer);SDL declaration
extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_GetGPURendererDevice(SDL_Renderer *renderer);
Return the GPU device used by a renderer.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the rendering context. |
Returns
the GPU device used by the renderer, or null if the renderer is not a GPU renderer; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.4.0.
XML member id: M:SDL3.SDL.GetGPURendererDevice(System.IntPtr)
public static SDL.GPUShaderFormat GetGPUShaderFormats(IntPtr device);SDL declaration
extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device);
Returns the supported shader formats for this GPU context.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context to query. |
Returns
a bitflag indicating which shader formats the driver is able to consume.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGPUShaderFormats(System.IntPtr)
public static SDL.GPUTextureFormat GetGPUSwapchainTextureFormat(IntPtr device, IntPtr window);SDL declaration
extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat(SDL_GPUDevice *device, SDL_Window *window);
Obtains the texture format of the swapchain for the given window.
Note that this format can change if the swapchain parameters change.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
a GPU context. |
window |
IntPtr |
an SDL_Window that has been claimed. |
Returns
the texture format of the swapchain.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGPUSwapchainTextureFormat(System.IntPtr,System.IntPtr)
public static IntPtr GetGrabbedWindow();SDL declaration
extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
Get the window that currently has an input grab enabled.
Returns
the window if input is grabbed or null otherwise.
Thread safety
This function should only be called on the main thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetGrabbedWindow
public static bool GetHapticEffectStatus(IntPtr haptic, int effect);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect);
Get the status of the current effect on the specified haptic device.
Device must support the SDL.HAPTIC_STATUS feature.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic device to query for the effect status on. |
effect |
int |
the ID of the haptic effect to query its status. |
Returns
true if it is playing, false if it isn't playing or haptic status isn't supported.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticEffectStatus(System.IntPtr,System.Int32)
public static uint GetHapticFeatures(IntPtr haptic);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic);
Get the haptic device's supported features in bitwise manner.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic device to query. |
Returns
a list of supported haptic features in bitwise manner (OR'd), or 0 on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticFeatures(System.IntPtr)
public static IntPtr GetHapticFromID(int instanceId);SDL declaration
extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_GetHapticFromID(SDL_HapticID instance_id);
Get the SDL_Haptic associated with an instance ID, if it has been opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
int |
the instance ID to get the SDL_Haptic for. |
Returns
an SDL_Haptic on success or null on failure or if it hasn't been opened yet; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticFromID(System.Int32)
public static int GetHapticID(IntPtr haptic);SDL declaration
extern SDL_DECLSPEC SDL_HapticID SDLCALL SDL_GetHapticID(SDL_Haptic *haptic);
Get the instance ID of an opened haptic device.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic device to query. |
Returns
the instance ID of the specified haptic device on success or 0 on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticID(System.IntPtr)
public static string GetHapticName(IntPtr haptic);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticName(SDL_Haptic *haptic);
Get the implementation dependent name of a haptic device.
Parameters
| Name | Type | Description |
|---|---|---|
haptic |
IntPtr |
the SDL_Haptic obtained from SDL.OpenJoystick. |
Returns
the name of the selected haptic device. If no name can be found, this function returns null; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticName(System.IntPtr)
public static string GetHapticNameForID(int instanceId);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticNameForID(SDL_HapticID instance_id);
Get the implementation dependent name of a haptic device.
This can be called before any haptic devices are opened.
Parameters
| Name | Type | Description |
|---|---|---|
instanceId |
int |
the haptic device instance ID. |
Returns
the name of the selected haptic device. If no name can be found, this function returns null; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHapticNameForID(System.Int32)
public static int[] GetHaptics(out int count);SDL declaration
extern SDL_DECLSPEC SDL_HapticID * SDLCALL SDL_GetHaptics(int *count);
Get a list of currently connected haptic devices.
Parameters
| Name | Type | Description |
|---|---|---|
count |
out int |
a pointer filled in with the number of haptic devices returned, may be null. |
Returns
a 0 terminated array of haptic device instance IDs or null on failure; call SDL.GetError for more information. This should be freed with SDL.Free when it is no longer needed.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHaptics(System.Int32@)
public static string GetHint(string name);SDL declaration
extern SDL_DECLSPEC const char *SDLCALL SDL_GetHint(const char *name);
Get the value of a hint.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
name the hint to query. |
Returns
the string value of a hint or null if the hint isn't set.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHint(System.String)
public static bool GetHintBoolean(string name, bool defaultValue);SDL declaration
extern SDL_DECLSPEC bool SDLCALL SDL_GetHintBoolean(const char *name, bool default_value);
Get the boolean value of a hint variable.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
the name of the hint to get the boolean value from. |
defaultValue |
bool |
the value to return if the hint does not exist. |
Returns
the boolean value of a hint or the provided default value if the hint does not exist.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetHintBoolean(System.String,System.Boolean)
public static uint GetIOProperties(IntPtr context);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *context);
Get the properties associated with an SDL_IOStream.
Parameters
| Name | Type | Description |
|---|---|---|
context |
IntPtr |
a pointer to an SDL_IOStream structure. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetIOProperties(System.IntPtr)
public static long GetIOSize(IntPtr context);SDL declaration
extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
Use this function to get the size of the data stream in an SDL_IOStream.
Parameters
| Name | Type | Description |
|---|---|---|
context |
IntPtr |
the SDL_IOStream to get the size of the data stream from. |
Returns
the size of the data stream in the SDL_IOStream on success or a negative error code on failure; call SDL.GetError for more information.
Thread safety
Do not use the same SDL_IOStream from two threads at once.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetIOSize(System.IntPtr)
public static SDL.IOStatus GetIOStatus(IntPtr context);SDL declaration
extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context);
Query the stream status of an SDL_IOStream.
This information can be useful to decide if a short read or write was due to an error, an EOF, or a non-blocking operation that isn't yet ready to complete.
An SDL_IOStream's status is only expected to change after a SDL.ReadIO or SDL.WriteIO call; don't expect it to change if you just call this query function in a tight loop.
Parameters
| Name | Type | Description |
|---|---|---|
context |
IntPtr |
the SDL_IOStream to query. |
Returns
an SDL.IOStatus enum with the current state.
Thread safety
Do not use the same SDL_IOStream from two threads at once.
Since: This function is available since SDL 3.2.0
XML member id: M:SDL3.SDL.GetIOStatus(System.IntPtr)
public static short GetJoystickAxis(IntPtr joystick, int axis);SDL declaration
extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
Get the current state of an axis control on a joystick.
SDL makes no promises about what part of the joystick any given axis refers to. Your game should have some sort of configuration UI to let users specify what each axis should be bound to. Alternately, SDL's higher-level Game Controller API makes a great effort to apply order to this lower-level interface, so you know that a specific axis is the "left thumb stick," etc.
The value returned by SDL.GetJoystickAxis is a signed integer (-32768 to 32767) representing the current position of the axis. It may be necessary to impose certain tolerances on these values to account for jitter.
Parameters
| Name | Type | Description |
|---|---|---|
joystick |
IntPtr |
an SDL_Joystick structure containing joystick information. |
axis |
int |
the axis to query; the axis indices start at index |