sdl3_sys/generated/render.rs
1//! Header file for SDL 2D rendering functions.
2//!
3//! This API supports the following features:
4//!
5//! - single pixel points
6//! - single pixel lines
7//! - filled rectangles
8//! - texture images
9//! - 2D polygons
10//!
11//! The primitives may be drawn in opaque, blended, or additive modes.
12//!
13//! The texture images may be drawn in opaque, blended, or additive modes. They
14//! can have an additional color tint or alpha modulation applied to them, and
15//! may also be stretched with linear interpolation.
16//!
17//! This API is designed to accelerate simple 2D operations. You may want more
18//! functionality such as 3D polygons and particle effects, and in that case
19//! you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of
20//! the many good 3D engines.
21//!
22//! These functions must be called from the main thread. See this bug for
23//! details: <https://github.com/libsdl-org/SDL/issues/986>
24
25use super::stdinc::*;
26
27use super::blendmode::*;
28
29use super::error::*;
30
31use super::events::*;
32
33use super::pixels::*;
34
35use super::properties::*;
36
37use super::rect::*;
38
39use super::surface::*;
40
41use super::video::*;
42
43use super::gpu::*;
44
45/// The name of the software renderer.
46///
47/// ## Availability
48/// This macro is available since SDL 3.2.0.
49pub const SDL_SOFTWARE_RENDERER: *const ::core::ffi::c_char = c"software".as_ptr();
50
51/// The name of the GPU renderer.
52///
53/// ## Availability
54/// This macro is available since SDL 3.4.0.
55pub const SDL_GPU_RENDERER: *const ::core::ffi::c_char = c"gpu".as_ptr();
56
57/// Vertex structure.
58///
59/// ## Availability
60/// This struct is available since SDL 3.2.0.
61#[repr(C)]
62#[derive(Clone, Copy, Default, PartialEq)]
63#[cfg_attr(feature = "debug-impls", derive(Debug))]
64pub struct SDL_Vertex {
65 /// Vertex position, in [`SDL_Renderer`] coordinates
66 pub position: SDL_FPoint,
67 /// Vertex color
68 pub color: SDL_FColor,
69 /// Normalized texture coordinates, if needed
70 pub tex_coord: SDL_FPoint,
71}
72
73/// The access pattern allowed for a texture.
74///
75/// ## Availability
76/// This enum is available since SDL 3.2.0.
77///
78/// ## Known values (`sdl3-sys`)
79/// | Associated constant | Global constant | Description |
80/// | ------------------- | --------------- | ----------- |
81/// | [`STATIC`](SDL_TextureAccess::STATIC) | [`SDL_TEXTUREACCESS_STATIC`] | Changes rarely, not lockable |
82/// | [`STREAMING`](SDL_TextureAccess::STREAMING) | [`SDL_TEXTUREACCESS_STREAMING`] | Changes frequently, lockable |
83/// | [`TARGET`](SDL_TextureAccess::TARGET) | [`SDL_TEXTUREACCESS_TARGET`] | Texture can be used as a render target |
84#[repr(transparent)]
85#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
86pub struct SDL_TextureAccess(pub ::core::ffi::c_int);
87
88impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_TextureAccess {
89 #[inline(always)]
90 fn eq(&self, other: &::core::ffi::c_int) -> bool {
91 &self.0 == other
92 }
93}
94
95impl ::core::cmp::PartialEq<SDL_TextureAccess> for ::core::ffi::c_int {
96 #[inline(always)]
97 fn eq(&self, other: &SDL_TextureAccess) -> bool {
98 self == &other.0
99 }
100}
101
102impl From<SDL_TextureAccess> for ::core::ffi::c_int {
103 #[inline(always)]
104 fn from(value: SDL_TextureAccess) -> Self {
105 value.0
106 }
107}
108
109#[cfg(feature = "debug-impls")]
110impl ::core::fmt::Debug for SDL_TextureAccess {
111 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
112 #[allow(unreachable_patterns)]
113 f.write_str(match *self {
114 Self::STATIC => "SDL_TEXTUREACCESS_STATIC",
115 Self::STREAMING => "SDL_TEXTUREACCESS_STREAMING",
116 Self::TARGET => "SDL_TEXTUREACCESS_TARGET",
117
118 _ => return write!(f, "SDL_TextureAccess({})", self.0),
119 })
120 }
121}
122
123impl SDL_TextureAccess {
124 /// Changes rarely, not lockable
125 pub const STATIC: Self = Self((0 as ::core::ffi::c_int));
126 /// Changes frequently, lockable
127 pub const STREAMING: Self = Self((1 as ::core::ffi::c_int));
128 /// Texture can be used as a render target
129 pub const TARGET: Self = Self((2 as ::core::ffi::c_int));
130}
131
132/// Changes rarely, not lockable
133pub const SDL_TEXTUREACCESS_STATIC: SDL_TextureAccess = SDL_TextureAccess::STATIC;
134/// Changes frequently, lockable
135pub const SDL_TEXTUREACCESS_STREAMING: SDL_TextureAccess = SDL_TextureAccess::STREAMING;
136/// Texture can be used as a render target
137pub const SDL_TEXTUREACCESS_TARGET: SDL_TextureAccess = SDL_TextureAccess::TARGET;
138
139#[cfg(feature = "metadata")]
140impl sdl3_sys::metadata::GroupMetadata for SDL_TextureAccess {
141 const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
142 &crate::metadata::render::METADATA_SDL_TextureAccess;
143}
144
145/// The addressing mode for a texture when used in [`SDL_RenderGeometry()`].
146///
147/// This affects how texture coordinates are interpreted outside of \[0, 1\]
148///
149/// Texture wrapping is always supported for power of two texture sizes, and is
150/// supported for other texture sizes if
151/// [`SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`] is set to true.
152///
153/// ## Availability
154/// This enum is available since SDL 3.4.0.
155///
156/// ## Known values (`sdl3-sys`)
157/// | Associated constant | Global constant | Description |
158/// | ------------------- | --------------- | ----------- |
159/// | [`INVALID`](SDL_TextureAddressMode::INVALID) | [`SDL_TEXTURE_ADDRESS_INVALID`] | |
160/// | [`AUTO`](SDL_TextureAddressMode::AUTO) | [`SDL_TEXTURE_ADDRESS_AUTO`] | Wrapping is enabled if texture coordinates are outside \[0, 1\], this is the default |
161/// | [`CLAMP`](SDL_TextureAddressMode::CLAMP) | [`SDL_TEXTURE_ADDRESS_CLAMP`] | Texture coordinates are clamped to the \[0, 1\] range |
162/// | [`WRAP`](SDL_TextureAddressMode::WRAP) | [`SDL_TEXTURE_ADDRESS_WRAP`] | The texture is repeated (tiled) |
163#[repr(transparent)]
164#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
165pub struct SDL_TextureAddressMode(pub ::core::ffi::c_int);
166
167impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_TextureAddressMode {
168 #[inline(always)]
169 fn eq(&self, other: &::core::ffi::c_int) -> bool {
170 &self.0 == other
171 }
172}
173
174impl ::core::cmp::PartialEq<SDL_TextureAddressMode> for ::core::ffi::c_int {
175 #[inline(always)]
176 fn eq(&self, other: &SDL_TextureAddressMode) -> bool {
177 self == &other.0
178 }
179}
180
181impl From<SDL_TextureAddressMode> for ::core::ffi::c_int {
182 #[inline(always)]
183 fn from(value: SDL_TextureAddressMode) -> Self {
184 value.0
185 }
186}
187
188#[cfg(feature = "debug-impls")]
189impl ::core::fmt::Debug for SDL_TextureAddressMode {
190 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
191 #[allow(unreachable_patterns)]
192 f.write_str(match *self {
193 Self::INVALID => "SDL_TEXTURE_ADDRESS_INVALID",
194 Self::AUTO => "SDL_TEXTURE_ADDRESS_AUTO",
195 Self::CLAMP => "SDL_TEXTURE_ADDRESS_CLAMP",
196 Self::WRAP => "SDL_TEXTURE_ADDRESS_WRAP",
197
198 _ => return write!(f, "SDL_TextureAddressMode({})", self.0),
199 })
200 }
201}
202
203impl SDL_TextureAddressMode {
204 pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
205 /// Wrapping is enabled if texture coordinates are outside \[0, 1\], this is the default
206 pub const AUTO: Self = Self((0_i32 as ::core::ffi::c_int));
207 /// Texture coordinates are clamped to the \[0, 1\] range
208 pub const CLAMP: Self = Self((1_i32 as ::core::ffi::c_int));
209 /// The texture is repeated (tiled)
210 pub const WRAP: Self = Self((2_i32 as ::core::ffi::c_int));
211}
212
213pub const SDL_TEXTURE_ADDRESS_INVALID: SDL_TextureAddressMode = SDL_TextureAddressMode::INVALID;
214/// Wrapping is enabled if texture coordinates are outside \[0, 1\], this is the default
215pub const SDL_TEXTURE_ADDRESS_AUTO: SDL_TextureAddressMode = SDL_TextureAddressMode::AUTO;
216/// Texture coordinates are clamped to the \[0, 1\] range
217pub const SDL_TEXTURE_ADDRESS_CLAMP: SDL_TextureAddressMode = SDL_TextureAddressMode::CLAMP;
218/// The texture is repeated (tiled)
219pub const SDL_TEXTURE_ADDRESS_WRAP: SDL_TextureAddressMode = SDL_TextureAddressMode::WRAP;
220
221#[cfg(feature = "metadata")]
222impl sdl3_sys::metadata::GroupMetadata for SDL_TextureAddressMode {
223 const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
224 &crate::metadata::render::METADATA_SDL_TextureAddressMode;
225}
226
227/// How the logical size is mapped to the output.
228///
229/// ## Availability
230/// This enum is available since SDL 3.2.0.
231///
232/// ## Known values (`sdl3-sys`)
233/// | Associated constant | Global constant | Description |
234/// | ------------------- | --------------- | ----------- |
235/// | [`DISABLED`](SDL_RendererLogicalPresentation::DISABLED) | [`SDL_LOGICAL_PRESENTATION_DISABLED`] | There is no logical size in effect |
236/// | [`STRETCH`](SDL_RendererLogicalPresentation::STRETCH) | [`SDL_LOGICAL_PRESENTATION_STRETCH`] | The rendered content is stretched to the output resolution |
237/// | [`LETTERBOX`](SDL_RendererLogicalPresentation::LETTERBOX) | [`SDL_LOGICAL_PRESENTATION_LETTERBOX`] | The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color |
238/// | [`OVERSCAN`](SDL_RendererLogicalPresentation::OVERSCAN) | [`SDL_LOGICAL_PRESENTATION_OVERSCAN`] | The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds |
239/// | [`INTEGER_SCALE`](SDL_RendererLogicalPresentation::INTEGER_SCALE) | [`SDL_LOGICAL_PRESENTATION_INTEGER_SCALE`] | The rendered content is scaled up by integer multiples to fit the output resolution |
240#[repr(transparent)]
241#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
242pub struct SDL_RendererLogicalPresentation(pub ::core::ffi::c_int);
243
244impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_RendererLogicalPresentation {
245 #[inline(always)]
246 fn eq(&self, other: &::core::ffi::c_int) -> bool {
247 &self.0 == other
248 }
249}
250
251impl ::core::cmp::PartialEq<SDL_RendererLogicalPresentation> for ::core::ffi::c_int {
252 #[inline(always)]
253 fn eq(&self, other: &SDL_RendererLogicalPresentation) -> bool {
254 self == &other.0
255 }
256}
257
258impl From<SDL_RendererLogicalPresentation> for ::core::ffi::c_int {
259 #[inline(always)]
260 fn from(value: SDL_RendererLogicalPresentation) -> Self {
261 value.0
262 }
263}
264
265#[cfg(feature = "debug-impls")]
266impl ::core::fmt::Debug for SDL_RendererLogicalPresentation {
267 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
268 #[allow(unreachable_patterns)]
269 f.write_str(match *self {
270 Self::DISABLED => "SDL_LOGICAL_PRESENTATION_DISABLED",
271 Self::STRETCH => "SDL_LOGICAL_PRESENTATION_STRETCH",
272 Self::LETTERBOX => "SDL_LOGICAL_PRESENTATION_LETTERBOX",
273 Self::OVERSCAN => "SDL_LOGICAL_PRESENTATION_OVERSCAN",
274 Self::INTEGER_SCALE => "SDL_LOGICAL_PRESENTATION_INTEGER_SCALE",
275
276 _ => return write!(f, "SDL_RendererLogicalPresentation({})", self.0),
277 })
278 }
279}
280
281impl SDL_RendererLogicalPresentation {
282 /// There is no logical size in effect
283 pub const DISABLED: Self = Self((0 as ::core::ffi::c_int));
284 /// The rendered content is stretched to the output resolution
285 pub const STRETCH: Self = Self((1 as ::core::ffi::c_int));
286 /// The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color
287 pub const LETTERBOX: Self = Self((2 as ::core::ffi::c_int));
288 /// The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds
289 pub const OVERSCAN: Self = Self((3 as ::core::ffi::c_int));
290 /// The rendered content is scaled up by integer multiples to fit the output resolution
291 pub const INTEGER_SCALE: Self = Self((4 as ::core::ffi::c_int));
292}
293
294/// There is no logical size in effect
295pub const SDL_LOGICAL_PRESENTATION_DISABLED: SDL_RendererLogicalPresentation =
296 SDL_RendererLogicalPresentation::DISABLED;
297/// The rendered content is stretched to the output resolution
298pub const SDL_LOGICAL_PRESENTATION_STRETCH: SDL_RendererLogicalPresentation =
299 SDL_RendererLogicalPresentation::STRETCH;
300/// The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color
301pub const SDL_LOGICAL_PRESENTATION_LETTERBOX: SDL_RendererLogicalPresentation =
302 SDL_RendererLogicalPresentation::LETTERBOX;
303/// The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds
304pub const SDL_LOGICAL_PRESENTATION_OVERSCAN: SDL_RendererLogicalPresentation =
305 SDL_RendererLogicalPresentation::OVERSCAN;
306/// The rendered content is scaled up by integer multiples to fit the output resolution
307pub const SDL_LOGICAL_PRESENTATION_INTEGER_SCALE: SDL_RendererLogicalPresentation =
308 SDL_RendererLogicalPresentation::INTEGER_SCALE;
309
310#[cfg(feature = "metadata")]
311impl sdl3_sys::metadata::GroupMetadata for SDL_RendererLogicalPresentation {
312 const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
313 &crate::metadata::render::METADATA_SDL_RendererLogicalPresentation;
314}
315
316/// An efficient driver-specific representation of pixel data
317///
318/// ## Availability
319/// This struct is available since SDL 3.2.0.
320///
321/// ## See also
322/// - [`SDL_CreateTexture`]
323/// - [`SDL_CreateTextureFromSurface`]
324/// - [`SDL_CreateTextureWithProperties`]
325/// - [`SDL_DestroyTexture`]
326#[repr(C)]
327#[cfg_attr(feature = "debug-impls", derive(Debug))]
328pub struct SDL_Texture {
329 /// The format of the texture, read-only
330 pub format: SDL_PixelFormat,
331 /// The width of the texture, read-only.
332 pub w: ::core::ffi::c_int,
333 /// The height of the texture, read-only.
334 pub h: ::core::ffi::c_int,
335 /// Application reference count, used when freeing texture
336 pub refcount: ::core::ffi::c_int,
337 #[doc(hidden)]
338 __non_exhaustive: ::sdl3_sys::NonExhaustive,
339}
340
341unsafe extern "C" {
342 /// Get the number of 2D rendering drivers available for the current display.
343 ///
344 /// A render driver is a set of code that handles rendering and texture
345 /// management on a particular display. Normally there is only one, but some
346 /// drivers may have several available with different capabilities.
347 ///
348 /// There may be none if SDL was compiled without render support.
349 ///
350 /// ## Return value
351 /// Returns the number of built in render drivers.
352 ///
353 /// ## Thread safety
354 /// It is safe to call this function from any thread.
355 ///
356 /// ## Availability
357 /// This function is available since SDL 3.2.0.
358 ///
359 /// ## See also
360 /// - [`SDL_CreateRenderer`]
361 /// - [`SDL_GetRenderDriver`]
362 pub fn SDL_GetNumRenderDrivers() -> ::core::ffi::c_int;
363}
364
365unsafe extern "C" {
366 /// Use this function to get the name of a built in 2D rendering driver.
367 ///
368 /// The list of rendering drivers is given in the order that they are normally
369 /// initialized by default; the drivers that seem more reasonable to choose
370 /// first (as far as the SDL developers believe) are earlier in the list.
371 ///
372 /// The names of drivers are all simple, low-ASCII identifiers, like "opengl",
373 /// "direct3d12" or "metal". These never have Unicode characters, and are not
374 /// meant to be proper names.
375 ///
376 /// ## Parameters
377 /// - `index`: the index of the rendering driver; the value ranges from 0 to
378 /// [`SDL_GetNumRenderDrivers()`] - 1.
379 ///
380 /// ## Return value
381 /// Returns the name of the rendering driver at the requested index, or NULL
382 /// if an invalid index was specified.
383 ///
384 /// ## Thread safety
385 /// It is safe to call this function from any thread.
386 ///
387 /// ## Availability
388 /// This function is available since SDL 3.2.0.
389 ///
390 /// ## See also
391 /// - [`SDL_GetNumRenderDrivers`]
392 pub fn SDL_GetRenderDriver(index: ::core::ffi::c_int) -> *const ::core::ffi::c_char;
393}
394
395unsafe extern "C" {
396 /// Create a window and default renderer.
397 ///
398 /// ## Parameters
399 /// - `title`: the title of the window, in UTF-8 encoding.
400 /// - `width`: the width of the window.
401 /// - `height`: the height of the window.
402 /// - `window_flags`: the flags used to create the window (see
403 /// [`SDL_CreateWindow()`]).
404 /// - `window`: a pointer filled with the window, or NULL on error.
405 /// - `renderer`: a pointer filled with the renderer, or NULL on error.
406 ///
407 /// ## Return value
408 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
409 /// information.
410 ///
411 /// ## Thread safety
412 /// This function should only be called on the main thread.
413 ///
414 /// ## Availability
415 /// This function is available since SDL 3.2.0.
416 ///
417 /// ## See also
418 /// - [`SDL_CreateRenderer`]
419 /// - [`SDL_CreateWindow`]
420 pub fn SDL_CreateWindowAndRenderer(
421 title: *const ::core::ffi::c_char,
422 width: ::core::ffi::c_int,
423 height: ::core::ffi::c_int,
424 window_flags: SDL_WindowFlags,
425 window: *mut *mut SDL_Window,
426 renderer: *mut *mut SDL_Renderer,
427 ) -> ::core::primitive::bool;
428}
429
430unsafe extern "C" {
431 /// Create a 2D rendering context for a window.
432 ///
433 /// If you want a specific renderer, you can specify its name here. A list of
434 /// available renderers can be obtained by calling [`SDL_GetRenderDriver()`]
435 /// multiple times, with indices from 0 to [`SDL_GetNumRenderDrivers()`]-1. If you
436 /// don't need a specific renderer, specify NULL and SDL will attempt to choose
437 /// the best option for you, based on what is available on the user's system.
438 ///
439 /// If `name` is a comma-separated list, SDL will try each name, in the order
440 /// listed, until one succeeds or all of them fail.
441 ///
442 /// By default the rendering size matches the window size in pixels, but you
443 /// can call [`SDL_SetRenderLogicalPresentation()`] to change the content size and
444 /// scaling options.
445 ///
446 /// ## Parameters
447 /// - `window`: the window where rendering is displayed.
448 /// - `name`: the name of the rendering driver to initialize, or NULL to let
449 /// SDL choose one.
450 ///
451 /// ## Return value
452 /// Returns a valid rendering context or NULL if there was an error; call
453 /// [`SDL_GetError()`] for more information.
454 ///
455 /// ## Thread safety
456 /// This function should only be called on the main thread.
457 ///
458 /// ## Availability
459 /// This function is available since SDL 3.2.0.
460 ///
461 /// ## See also
462 /// - [`SDL_CreateRendererWithProperties`]
463 /// - [`SDL_CreateSoftwareRenderer`]
464 /// - [`SDL_DestroyRenderer`]
465 /// - [`SDL_GetNumRenderDrivers`]
466 /// - [`SDL_GetRenderDriver`]
467 /// - [`SDL_GetRendererName`]
468 pub fn SDL_CreateRenderer(
469 window: *mut SDL_Window,
470 name: *const ::core::ffi::c_char,
471 ) -> *mut SDL_Renderer;
472}
473
474unsafe extern "C" {
475 /// Create a 2D rendering context for a window, with the specified properties.
476 ///
477 /// These are the supported properties:
478 ///
479 /// - [`SDL_PROP_RENDERER_CREATE_NAME_STRING`]\: the name of the rendering driver
480 /// to use, if a specific one is desired
481 /// - [`SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`]\: the window where rendering is
482 /// displayed, required if this isn't a software renderer using a surface
483 /// - [`SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`]\: the surface where rendering
484 /// is displayed, if you want a software renderer without a window
485 /// - [`SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`]\: an [`SDL_Colorspace`]
486 /// value describing the colorspace for output to the display, defaults to
487 /// [`SDL_COLORSPACE_SRGB`]. The direct3d11, direct3d12, and metal renderers
488 /// support [`SDL_COLORSPACE_SRGB_LINEAR`], which is a linear color space and
489 /// supports HDR output. If you select [`SDL_COLORSPACE_SRGB_LINEAR`], drawing
490 /// still uses the sRGB colorspace, but values can go beyond 1.0 and float
491 /// (linear) format textures can be used for HDR content.
492 /// - [`SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`]\: non-zero if you want
493 /// present synchronized with the refresh rate. This property can take any
494 /// value that is supported by [`SDL_SetRenderVSync()`] for the renderer.
495 ///
496 /// With the SDL GPU renderer (since SDL 3.4.0):
497 ///
498 /// - [`SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER`]\: the device to use with the
499 /// renderer, optional.
500 /// - [`SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN`]\: the app is able to
501 /// provide SPIR-V shaders to [`SDL_GPURenderState`], optional.
502 /// - [`SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN`]\: the app is able to
503 /// provide DXIL shaders to [`SDL_GPURenderState`], optional.
504 /// - [`SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN`]\: the app is able to
505 /// provide MSL shaders to [`SDL_GPURenderState`], optional.
506 ///
507 /// With the vulkan renderer:
508 ///
509 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`]\: the VkInstance to use
510 /// with the renderer, optional.
511 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`]\: the VkSurfaceKHR to use
512 /// with the renderer, optional.
513 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`]\: the
514 /// VkPhysicalDevice to use with the renderer, optional.
515 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`]\: the VkDevice to use
516 /// with the renderer, optional.
517 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`]\: the
518 /// queue family index used for rendering.
519 /// - [`SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`]\: the
520 /// queue family index used for presentation.
521 ///
522 /// ## Parameters
523 /// - `props`: the properties to use.
524 ///
525 /// ## Return value
526 /// Returns a valid rendering context or NULL if there was an error; call
527 /// [`SDL_GetError()`] for more information.
528 ///
529 /// ## Thread safety
530 /// This function should only be called on the main thread.
531 ///
532 /// ## Availability
533 /// This function is available since SDL 3.2.0.
534 ///
535 /// ## See also
536 /// - [`SDL_CreateProperties`]
537 /// - [`SDL_CreateRenderer`]
538 /// - [`SDL_CreateSoftwareRenderer`]
539 /// - [`SDL_DestroyRenderer`]
540 /// - [`SDL_GetRendererName`]
541 pub fn SDL_CreateRendererWithProperties(props: SDL_PropertiesID) -> *mut SDL_Renderer;
542}
543
544pub const SDL_PROP_RENDERER_CREATE_NAME_STRING: *const ::core::ffi::c_char =
545 c"SDL.renderer.create.name".as_ptr();
546
547pub const SDL_PROP_RENDERER_CREATE_WINDOW_POINTER: *const ::core::ffi::c_char =
548 c"SDL.renderer.create.window".as_ptr();
549
550pub const SDL_PROP_RENDERER_CREATE_SURFACE_POINTER: *const ::core::ffi::c_char =
551 c"SDL.renderer.create.surface".as_ptr();
552
553pub const SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER: *const ::core::ffi::c_char =
554 c"SDL.renderer.create.output_colorspace".as_ptr();
555
556pub const SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER: *const ::core::ffi::c_char =
557 c"SDL.renderer.create.present_vsync".as_ptr();
558
559pub const SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER: *const ::core::ffi::c_char =
560 c"SDL.renderer.create.gpu.device".as_ptr();
561
562pub const SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN: *const ::core::ffi::c_char =
563 c"SDL.renderer.create.gpu.shaders_spirv".as_ptr();
564
565pub const SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN: *const ::core::ffi::c_char =
566 c"SDL.renderer.create.gpu.shaders_dxil".as_ptr();
567
568pub const SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN: *const ::core::ffi::c_char =
569 c"SDL.renderer.create.gpu.shaders_msl".as_ptr();
570
571pub const SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER: *const ::core::ffi::c_char =
572 c"SDL.renderer.create.vulkan.instance".as_ptr();
573
574pub const SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER: *const ::core::ffi::c_char =
575 c"SDL.renderer.create.vulkan.surface".as_ptr();
576
577pub const SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER: *const ::core::ffi::c_char =
578 c"SDL.renderer.create.vulkan.physical_device".as_ptr();
579
580pub const SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER: *const ::core::ffi::c_char =
581 c"SDL.renderer.create.vulkan.device".as_ptr();
582
583pub const SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER:
584 *const ::core::ffi::c_char = c"SDL.renderer.create.vulkan.graphics_queue_family_index".as_ptr();
585
586pub const SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER:
587 *const ::core::ffi::c_char = c"SDL.renderer.create.vulkan.present_queue_family_index".as_ptr();
588
589unsafe extern "C" {
590 /// Create a 2D GPU rendering context.
591 ///
592 /// The GPU device to use is passed in as a parameter. If this is NULL, then a
593 /// device will be created normally and can be retrieved using
594 /// [`SDL_GetGPURendererDevice()`].
595 ///
596 /// The window to use is passed in as a parameter. If this is NULL, then this
597 /// will become an offscreen renderer. In that case, you should call
598 /// [`SDL_SetRenderTarget()`] to setup rendering to a texture, and then call
599 /// [`SDL_RenderPresent()`] normally to complete drawing a frame.
600 ///
601 /// ## Parameters
602 /// - `device`: the GPU device to use with the renderer, or NULL to create a
603 /// device.
604 /// - `window`: the window where rendering is displayed, or NULL to create an
605 /// offscreen renderer.
606 ///
607 /// ## Return value
608 /// Returns a valid rendering context or NULL if there was an error; call
609 /// [`SDL_GetError()`] for more information.
610 ///
611 /// ## Thread safety
612 /// If this function is called with a valid GPU device, it should
613 /// be called on the thread that created the device. If this
614 /// function is called with a valid window, it should be called
615 /// on the thread that created the window.
616 ///
617 /// ## Availability
618 /// This function is available since SDL 3.4.0.
619 ///
620 /// ## See also
621 /// - [`SDL_CreateRendererWithProperties`]
622 /// - [`SDL_GetGPURendererDevice`]
623 /// - [`SDL_CreateGPUShader`]
624 /// - [`SDL_CreateGPURenderState`]
625 /// - [`SDL_SetGPURenderState`]
626 pub fn SDL_CreateGPURenderer(
627 device: *mut SDL_GPUDevice,
628 window: *mut SDL_Window,
629 ) -> *mut SDL_Renderer;
630}
631
632unsafe extern "C" {
633 /// Return the GPU device used by a renderer.
634 ///
635 /// ## Parameters
636 /// - `renderer`: the rendering context.
637 ///
638 /// ## Return value
639 /// Returns the GPU device used by the renderer, or NULL if the renderer is
640 /// not a GPU renderer; call [`SDL_GetError()`] for more information.
641 ///
642 /// ## Thread safety
643 /// It is safe to call this function from any thread.
644 ///
645 /// ## Availability
646 /// This function is available since SDL 3.4.0.
647 pub fn SDL_GetGPURendererDevice(renderer: *mut SDL_Renderer) -> *mut SDL_GPUDevice;
648}
649
650unsafe extern "C" {
651 /// Create a 2D software rendering context for a surface.
652 ///
653 /// Two other API which can be used to create [`SDL_Renderer`]\:
654 /// [`SDL_CreateRenderer()`] and [`SDL_CreateWindowAndRenderer()`]. These can _also_
655 /// create a software renderer, but they are intended to be used with an
656 /// [`SDL_Window`] as the final destination and not an [`SDL_Surface`].
657 ///
658 /// ## Parameters
659 /// - `surface`: the [`SDL_Surface`] structure representing the surface where
660 /// rendering is done.
661 ///
662 /// ## Return value
663 /// Returns a valid rendering context or NULL if there was an error; call
664 /// [`SDL_GetError()`] for more information.
665 ///
666 /// ## Thread safety
667 /// It is safe to call this function from any thread.
668 ///
669 /// ## Availability
670 /// This function is available since SDL 3.2.0.
671 ///
672 /// ## See also
673 /// - [`SDL_DestroyRenderer`]
674 pub fn SDL_CreateSoftwareRenderer(surface: *mut SDL_Surface) -> *mut SDL_Renderer;
675}
676
677unsafe extern "C" {
678 /// Get the renderer associated with a window.
679 ///
680 /// ## Parameters
681 /// - `window`: the window to query.
682 ///
683 /// ## Return value
684 /// Returns the rendering context on success or NULL on failure; call
685 /// [`SDL_GetError()`] for more information.
686 ///
687 /// ## Thread safety
688 /// It is safe to call this function from any thread.
689 ///
690 /// ## Availability
691 /// This function is available since SDL 3.2.0.
692 pub fn SDL_GetRenderer(window: *mut SDL_Window) -> *mut SDL_Renderer;
693}
694
695unsafe extern "C" {
696 /// Get the window associated with a renderer.
697 ///
698 /// ## Parameters
699 /// - `renderer`: the renderer to query.
700 ///
701 /// ## Return value
702 /// Returns the window on success or NULL on failure; call [`SDL_GetError()`] for
703 /// more information.
704 ///
705 /// ## Thread safety
706 /// It is safe to call this function from any thread.
707 ///
708 /// ## Availability
709 /// This function is available since SDL 3.2.0.
710 pub fn SDL_GetRenderWindow(renderer: *mut SDL_Renderer) -> *mut SDL_Window;
711}
712
713unsafe extern "C" {
714 /// Get the name of a renderer.
715 ///
716 /// ## Parameters
717 /// - `renderer`: the rendering context.
718 ///
719 /// ## Return value
720 /// Returns the name of the selected renderer, or NULL on failure; call
721 /// [`SDL_GetError()`] for more information.
722 ///
723 /// ## Thread safety
724 /// It is safe to call this function from any thread.
725 ///
726 /// ## Availability
727 /// This function is available since SDL 3.2.0.
728 ///
729 /// ## See also
730 /// - [`SDL_CreateRenderer`]
731 /// - [`SDL_CreateRendererWithProperties`]
732 pub fn SDL_GetRendererName(renderer: *mut SDL_Renderer) -> *const ::core::ffi::c_char;
733}
734
735unsafe extern "C" {
736 /// Get the properties associated with a renderer.
737 ///
738 /// The following read-only properties are provided by SDL:
739 ///
740 /// - [`SDL_PROP_RENDERER_NAME_STRING`]\: the name of the rendering driver
741 /// - [`SDL_PROP_RENDERER_WINDOW_POINTER`]\: the window where rendering is
742 /// displayed, if any
743 /// - [`SDL_PROP_RENDERER_SURFACE_POINTER`]\: the surface where rendering is
744 /// displayed, if this is a software renderer without a window
745 /// - [`SDL_PROP_RENDERER_VSYNC_NUMBER`]\: the current vsync setting
746 /// - [`SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`]\: the maximum texture width
747 /// and height
748 /// - [`SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`]\: a (const [`SDL_PixelFormat`] *)
749 /// array of pixel formats, terminated with [`SDL_PIXELFORMAT_UNKNOWN`],
750 /// representing the available texture formats for this renderer.
751 /// - [`SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`]\: true if the renderer
752 /// supports [`SDL_TEXTURE_ADDRESS_WRAP`] on non-power-of-two textures.
753 /// - [`SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`]\: an [`SDL_Colorspace`] value
754 /// describing the colorspace for output to the display, defaults to
755 /// [`SDL_COLORSPACE_SRGB`].
756 /// - [`SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`]\: true if the output colorspace is
757 /// [`SDL_COLORSPACE_SRGB_LINEAR`] and the renderer is showing on a display with
758 /// HDR enabled. This property can change dynamically when
759 /// [`SDL_EVENT_WINDOW_HDR_STATE_CHANGED`] is sent.
760 /// - [`SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`]\: the value of SDR white in the
761 /// [`SDL_COLORSPACE_SRGB_LINEAR`] colorspace. When HDR is enabled, this value is
762 /// automatically multiplied into the color scale. This property can change
763 /// dynamically when [`SDL_EVENT_WINDOW_HDR_STATE_CHANGED`] is sent.
764 /// - [`SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`]\: the additional high dynamic range
765 /// that can be displayed, in terms of the SDR white point. When HDR is not
766 /// enabled, this will be 1.0. This property can change dynamically when
767 /// [`SDL_EVENT_WINDOW_HDR_STATE_CHANGED`] is sent.
768 ///
769 /// With the direct3d renderer:
770 ///
771 /// - [`SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`]\: the IDirect3DDevice9 associated
772 /// with the renderer
773 ///
774 /// With the direct3d11 renderer:
775 ///
776 /// - [`SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`]\: the ID3D11Device associated
777 /// with the renderer
778 /// - [`SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`]\: the IDXGISwapChain1
779 /// associated with the renderer. This may change when the window is resized.
780 ///
781 /// With the direct3d12 renderer:
782 ///
783 /// - [`SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`]\: the ID3D12Device associated
784 /// with the renderer
785 /// - [`SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`]\: the IDXGISwapChain4
786 /// associated with the renderer.
787 /// - [`SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`]\: the ID3D12CommandQueue
788 /// associated with the renderer
789 ///
790 /// With the vulkan renderer:
791 ///
792 /// - [`SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`]\: the VkInstance associated
793 /// with the renderer
794 /// - [`SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`]\: the VkSurfaceKHR associated
795 /// with the renderer
796 /// - [`SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`]\: the VkPhysicalDevice
797 /// associated with the renderer
798 /// - [`SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`]\: the VkDevice associated with
799 /// the renderer
800 /// - [`SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`]\: the queue
801 /// family index used for rendering
802 /// - [`SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`]\: the queue
803 /// family index used for presentation
804 /// - [`SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`]\: the number of
805 /// swapchain images, or potential frames in flight, used by the Vulkan
806 /// renderer
807 ///
808 /// With the gpu renderer:
809 ///
810 /// - [`SDL_PROP_RENDERER_GPU_DEVICE_POINTER`]\: the [`SDL_GPUDevice`] associated with
811 /// the renderer
812 ///
813 /// ## Parameters
814 /// - `renderer`: the rendering context.
815 ///
816 /// ## Return value
817 /// Returns a valid property ID on success or 0 on failure; call
818 /// [`SDL_GetError()`] for more information.
819 ///
820 /// ## Thread safety
821 /// It is safe to call this function from any thread.
822 ///
823 /// ## Availability
824 /// This function is available since SDL 3.2.0.
825 pub fn SDL_GetRendererProperties(renderer: *mut SDL_Renderer) -> SDL_PropertiesID;
826}
827
828pub const SDL_PROP_RENDERER_NAME_STRING: *const ::core::ffi::c_char = c"SDL.renderer.name".as_ptr();
829
830pub const SDL_PROP_RENDERER_WINDOW_POINTER: *const ::core::ffi::c_char =
831 c"SDL.renderer.window".as_ptr();
832
833pub const SDL_PROP_RENDERER_SURFACE_POINTER: *const ::core::ffi::c_char =
834 c"SDL.renderer.surface".as_ptr();
835
836pub const SDL_PROP_RENDERER_VSYNC_NUMBER: *const ::core::ffi::c_char =
837 c"SDL.renderer.vsync".as_ptr();
838
839pub const SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER: *const ::core::ffi::c_char =
840 c"SDL.renderer.max_texture_size".as_ptr();
841
842pub const SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER: *const ::core::ffi::c_char =
843 c"SDL.renderer.texture_formats".as_ptr();
844
845pub const SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN: *const ::core::ffi::c_char =
846 c"SDL.renderer.texture_wrapping".as_ptr();
847
848pub const SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER: *const ::core::ffi::c_char =
849 c"SDL.renderer.output_colorspace".as_ptr();
850
851pub const SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN: *const ::core::ffi::c_char =
852 c"SDL.renderer.HDR_enabled".as_ptr();
853
854pub const SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT: *const ::core::ffi::c_char =
855 c"SDL.renderer.SDR_white_point".as_ptr();
856
857pub const SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT: *const ::core::ffi::c_char =
858 c"SDL.renderer.HDR_headroom".as_ptr();
859
860pub const SDL_PROP_RENDERER_D3D9_DEVICE_POINTER: *const ::core::ffi::c_char =
861 c"SDL.renderer.d3d9.device".as_ptr();
862
863pub const SDL_PROP_RENDERER_D3D11_DEVICE_POINTER: *const ::core::ffi::c_char =
864 c"SDL.renderer.d3d11.device".as_ptr();
865
866pub const SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER: *const ::core::ffi::c_char =
867 c"SDL.renderer.d3d11.swap_chain".as_ptr();
868
869pub const SDL_PROP_RENDERER_D3D12_DEVICE_POINTER: *const ::core::ffi::c_char =
870 c"SDL.renderer.d3d12.device".as_ptr();
871
872pub const SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER: *const ::core::ffi::c_char =
873 c"SDL.renderer.d3d12.swap_chain".as_ptr();
874
875pub const SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER: *const ::core::ffi::c_char =
876 c"SDL.renderer.d3d12.command_queue".as_ptr();
877
878pub const SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER: *const ::core::ffi::c_char =
879 c"SDL.renderer.vulkan.instance".as_ptr();
880
881pub const SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER: *const ::core::ffi::c_char =
882 c"SDL.renderer.vulkan.surface".as_ptr();
883
884pub const SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER: *const ::core::ffi::c_char =
885 c"SDL.renderer.vulkan.physical_device".as_ptr();
886
887pub const SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER: *const ::core::ffi::c_char =
888 c"SDL.renderer.vulkan.device".as_ptr();
889
890pub const SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER: *const ::core::ffi::c_char =
891 c"SDL.renderer.vulkan.graphics_queue_family_index".as_ptr();
892
893pub const SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER: *const ::core::ffi::c_char =
894 c"SDL.renderer.vulkan.present_queue_family_index".as_ptr();
895
896pub const SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER: *const ::core::ffi::c_char =
897 c"SDL.renderer.vulkan.swapchain_image_count".as_ptr();
898
899pub const SDL_PROP_RENDERER_GPU_DEVICE_POINTER: *const ::core::ffi::c_char =
900 c"SDL.renderer.gpu.device".as_ptr();
901
902unsafe extern "C" {
903 /// Get the output size in pixels of a rendering context.
904 ///
905 /// This returns the true output size in pixels, ignoring any render targets or
906 /// logical size and presentation.
907 ///
908 /// For the output size of the current rendering target, with logical size
909 /// adjustments, use [`SDL_GetCurrentRenderOutputSize()`] instead.
910 ///
911 /// ## Parameters
912 /// - `renderer`: the rendering context.
913 /// - `w`: a pointer filled in with the width in pixels.
914 /// - `h`: a pointer filled in with the height in pixels.
915 ///
916 /// ## Return value
917 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
918 /// information.
919 ///
920 /// ## Thread safety
921 /// This function should only be called on the main thread.
922 ///
923 /// ## Availability
924 /// This function is available since SDL 3.2.0.
925 ///
926 /// ## See also
927 /// - [`SDL_GetCurrentRenderOutputSize`]
928 pub fn SDL_GetRenderOutputSize(
929 renderer: *mut SDL_Renderer,
930 w: *mut ::core::ffi::c_int,
931 h: *mut ::core::ffi::c_int,
932 ) -> ::core::primitive::bool;
933}
934
935unsafe extern "C" {
936 /// Get the current output size in pixels of a rendering context.
937 ///
938 /// If a rendering target is active, this will return the size of the rendering
939 /// target in pixels, otherwise return the value of [`SDL_GetRenderOutputSize()`].
940 ///
941 /// Rendering target or not, the output will be adjusted by the current logical
942 /// presentation state, dictated by [`SDL_SetRenderLogicalPresentation()`].
943 ///
944 /// ## Parameters
945 /// - `renderer`: the rendering context.
946 /// - `w`: a pointer filled in with the current width.
947 /// - `h`: a pointer filled in with the current height.
948 ///
949 /// ## Return value
950 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
951 /// information.
952 ///
953 /// ## Thread safety
954 /// This function should only be called on the main thread.
955 ///
956 /// ## Availability
957 /// This function is available since SDL 3.2.0.
958 ///
959 /// ## See also
960 /// - [`SDL_GetRenderOutputSize`]
961 pub fn SDL_GetCurrentRenderOutputSize(
962 renderer: *mut SDL_Renderer,
963 w: *mut ::core::ffi::c_int,
964 h: *mut ::core::ffi::c_int,
965 ) -> ::core::primitive::bool;
966}
967
968unsafe extern "C" {
969 /// Create a texture for a rendering context.
970 ///
971 /// The contents of a texture when first created are not defined.
972 ///
973 /// ## Parameters
974 /// - `renderer`: the rendering context.
975 /// - `format`: one of the enumerated values in [`SDL_PixelFormat`].
976 /// - `access`: one of the enumerated values in [`SDL_TextureAccess`].
977 /// - `w`: the width of the texture in pixels.
978 /// - `h`: the height of the texture in pixels.
979 ///
980 /// ## Return value
981 /// Returns the created texture or NULL on failure; call [`SDL_GetError()`] for
982 /// more information.
983 ///
984 /// ## Thread safety
985 /// This function should only be called on the main thread.
986 ///
987 /// ## Availability
988 /// This function is available since SDL 3.2.0.
989 ///
990 /// ## See also
991 /// - [`SDL_CreateTextureFromSurface`]
992 /// - [`SDL_CreateTextureWithProperties`]
993 /// - [`SDL_DestroyTexture`]
994 /// - [`SDL_GetTextureSize`]
995 /// - [`SDL_UpdateTexture`]
996 pub fn SDL_CreateTexture(
997 renderer: *mut SDL_Renderer,
998 format: SDL_PixelFormat,
999 access: SDL_TextureAccess,
1000 w: ::core::ffi::c_int,
1001 h: ::core::ffi::c_int,
1002 ) -> *mut SDL_Texture;
1003}
1004
1005unsafe extern "C" {
1006 /// Create a texture from an existing surface.
1007 ///
1008 /// The surface is not modified or freed by this function.
1009 ///
1010 /// The [`SDL_TextureAccess`] hint for the created texture is
1011 /// [`SDL_TEXTUREACCESS_STATIC`].
1012 ///
1013 /// The pixel format of the created texture may be different from the pixel
1014 /// format of the surface, and can be queried using the
1015 /// [`SDL_PROP_TEXTURE_FORMAT_NUMBER`] property.
1016 ///
1017 /// ## Parameters
1018 /// - `renderer`: the rendering context.
1019 /// - `surface`: the [`SDL_Surface`] structure containing pixel data used to fill
1020 /// the texture.
1021 ///
1022 /// ## Return value
1023 /// Returns the created texture or NULL on failure; call [`SDL_GetError()`] for
1024 /// more information.
1025 ///
1026 /// ## Thread safety
1027 /// This function should only be called on the main thread.
1028 ///
1029 /// ## Availability
1030 /// This function is available since SDL 3.2.0.
1031 ///
1032 /// ## See also
1033 /// - [`SDL_CreateTexture`]
1034 /// - [`SDL_CreateTextureWithProperties`]
1035 /// - [`SDL_DestroyTexture`]
1036 pub fn SDL_CreateTextureFromSurface(
1037 renderer: *mut SDL_Renderer,
1038 surface: *mut SDL_Surface,
1039 ) -> *mut SDL_Texture;
1040}
1041
1042unsafe extern "C" {
1043 /// Create a texture for a rendering context with the specified properties.
1044 ///
1045 /// These are the supported properties:
1046 ///
1047 /// - [`SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`]\: an [`SDL_Colorspace`] value
1048 /// describing the texture colorspace, defaults to [`SDL_COLORSPACE_SRGB_LINEAR`]
1049 /// for floating point textures, [`SDL_COLORSPACE_HDR10`] for 10-bit textures,
1050 /// [`SDL_COLORSPACE_SRGB`] for other RGB textures and [`SDL_COLORSPACE_JPEG`] for
1051 /// YUV textures.
1052 /// - [`SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`]\: one of the enumerated values in
1053 /// [`SDL_PixelFormat`], defaults to the best RGBA format for the renderer
1054 /// - [`SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`]\: one of the enumerated values in
1055 /// [`SDL_TextureAccess`], defaults to [`SDL_TEXTUREACCESS_STATIC`]
1056 /// - [`SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`]\: the width of the texture in
1057 /// pixels, required
1058 /// - [`SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`]\: the height of the texture in
1059 /// pixels, required
1060 /// - [`SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER`]\: an [`SDL_Palette`] to use with
1061 /// palettized texture formats. This can be set later with
1062 /// [`SDL_SetTexturePalette()`]
1063 /// - [`SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`]\: for HDR10 and floating
1064 /// point textures, this defines the value of 100% diffuse white, with higher
1065 /// values being displayed in the High Dynamic Range headroom. This defaults
1066 /// to 100 for HDR10 textures and 1.0 for floating point textures.
1067 /// - [`SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`]\: for HDR10 and floating
1068 /// point textures, this defines the maximum dynamic range used by the
1069 /// content, in terms of the SDR white point. This would be equivalent to
1070 /// maxCLL / [`SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`] for HDR10 content.
1071 /// If this is defined, any values outside the range supported by the display
1072 /// will be scaled into the available HDR headroom, otherwise they are
1073 /// clipped.
1074 ///
1075 /// With the direct3d11 renderer:
1076 ///
1077 /// - [`SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`]\: the ID3D11Texture2D
1078 /// associated with the texture, if you want to wrap an existing texture.
1079 /// - [`SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`]\: the ID3D11Texture2D
1080 /// associated with the U plane of a YUV texture, if you want to wrap an
1081 /// existing texture.
1082 /// - [`SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`]\: the ID3D11Texture2D
1083 /// associated with the V plane of a YUV texture, if you want to wrap an
1084 /// existing texture.
1085 ///
1086 /// With the direct3d12 renderer:
1087 ///
1088 /// - [`SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`]\: the ID3D12Resource
1089 /// associated with the texture, if you want to wrap an existing texture.
1090 /// - [`SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`]\: the ID3D12Resource
1091 /// associated with the U plane of a YUV texture, if you want to wrap an
1092 /// existing texture.
1093 /// - [`SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`]\: the ID3D12Resource
1094 /// associated with the V plane of a YUV texture, if you want to wrap an
1095 /// existing texture.
1096 ///
1097 /// With the metal renderer:
1098 ///
1099 /// - [`SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`]\: the CVPixelBufferRef
1100 /// associated with the texture, if you want to create a texture from an
1101 /// existing pixel buffer.
1102 ///
1103 /// With the opengl renderer:
1104 ///
1105 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`]\: the GLuint texture
1106 /// associated with the texture, if you want to wrap an existing texture.
1107 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`]\: the GLuint texture
1108 /// associated with the UV plane of an NV12 texture, if you want to wrap an
1109 /// existing texture.
1110 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`]\: the GLuint texture
1111 /// associated with the U plane of a YUV texture, if you want to wrap an
1112 /// existing texture.
1113 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`]\: the GLuint texture
1114 /// associated with the V plane of a YUV texture, if you want to wrap an
1115 /// existing texture.
1116 ///
1117 /// With the opengles2 renderer:
1118 ///
1119 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`]\: the GLuint texture
1120 /// associated with the texture, if you want to wrap an existing texture.
1121 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`]\: the GLuint texture
1122 /// associated with the texture, if you want to wrap an existing texture.
1123 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`]\: the GLuint texture
1124 /// associated with the UV plane of an NV12 texture, if you want to wrap an
1125 /// existing texture.
1126 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`]\: the GLuint texture
1127 /// associated with the U plane of a YUV texture, if you want to wrap an
1128 /// existing texture.
1129 /// - [`SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`]\: the GLuint texture
1130 /// associated with the V plane of a YUV texture, if you want to wrap an
1131 /// existing texture.
1132 ///
1133 /// With the vulkan renderer:
1134 ///
1135 /// - [`SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`]\: the VkImage associated
1136 /// with the texture, if you want to wrap an existing texture.
1137 /// - [`SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER`]\: the VkImageLayout for the
1138 /// VkImage, defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
1139 ///
1140 /// With the GPU renderer:
1141 ///
1142 /// - [`SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`]\: the [`SDL_GPUTexture`]
1143 /// associated with the texture, if you want to wrap an existing texture.
1144 /// - [`SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`]\: the [`SDL_GPUTexture`]
1145 /// associated with the UV plane of an NV12 texture, if you want to wrap an
1146 /// existing texture.
1147 /// - [`SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`]\: the [`SDL_GPUTexture`]
1148 /// associated with the U plane of a YUV texture, if you want to wrap an
1149 /// existing texture.
1150 /// - [`SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`]\: the [`SDL_GPUTexture`]
1151 /// associated with the V plane of a YUV texture, if you want to wrap an
1152 /// existing texture.
1153 ///
1154 /// ## Parameters
1155 /// - `renderer`: the rendering context.
1156 /// - `props`: the properties to use.
1157 ///
1158 /// ## Return value
1159 /// Returns the created texture or NULL on failure; call [`SDL_GetError()`] for
1160 /// more information.
1161 ///
1162 /// ## Thread safety
1163 /// This function should only be called on the main thread.
1164 ///
1165 /// ## Availability
1166 /// This function is available since SDL 3.2.0.
1167 ///
1168 /// ## See also
1169 /// - [`SDL_CreateProperties`]
1170 /// - [`SDL_CreateTexture`]
1171 /// - [`SDL_CreateTextureFromSurface`]
1172 /// - [`SDL_DestroyTexture`]
1173 /// - [`SDL_GetTextureSize`]
1174 /// - [`SDL_UpdateTexture`]
1175 pub fn SDL_CreateTextureWithProperties(
1176 renderer: *mut SDL_Renderer,
1177 props: SDL_PropertiesID,
1178 ) -> *mut SDL_Texture;
1179}
1180
1181pub const SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER: *const ::core::ffi::c_char =
1182 c"SDL.texture.create.colorspace".as_ptr();
1183
1184pub const SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER: *const ::core::ffi::c_char =
1185 c"SDL.texture.create.format".as_ptr();
1186
1187pub const SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER: *const ::core::ffi::c_char =
1188 c"SDL.texture.create.access".as_ptr();
1189
1190pub const SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER: *const ::core::ffi::c_char =
1191 c"SDL.texture.create.width".as_ptr();
1192
1193pub const SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER: *const ::core::ffi::c_char =
1194 c"SDL.texture.create.height".as_ptr();
1195
1196pub const SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER: *const ::core::ffi::c_char =
1197 c"SDL.texture.create.palette".as_ptr();
1198
1199pub const SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT: *const ::core::ffi::c_char =
1200 c"SDL.texture.create.SDR_white_point".as_ptr();
1201
1202pub const SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT: *const ::core::ffi::c_char =
1203 c"SDL.texture.create.HDR_headroom".as_ptr();
1204
1205pub const SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER: *const ::core::ffi::c_char =
1206 c"SDL.texture.create.d3d11.texture".as_ptr();
1207
1208pub const SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1209 c"SDL.texture.create.d3d11.texture_u".as_ptr();
1210
1211pub const SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1212 c"SDL.texture.create.d3d11.texture_v".as_ptr();
1213
1214pub const SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER: *const ::core::ffi::c_char =
1215 c"SDL.texture.create.d3d12.texture".as_ptr();
1216
1217pub const SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1218 c"SDL.texture.create.d3d12.texture_u".as_ptr();
1219
1220pub const SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1221 c"SDL.texture.create.d3d12.texture_v".as_ptr();
1222
1223pub const SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER: *const ::core::ffi::c_char =
1224 c"SDL.texture.create.metal.pixelbuffer".as_ptr();
1225
1226pub const SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1227 c"SDL.texture.create.opengl.texture".as_ptr();
1228
1229pub const SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER: *const ::core::ffi::c_char =
1230 c"SDL.texture.create.opengl.texture_uv".as_ptr();
1231
1232pub const SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER: *const ::core::ffi::c_char =
1233 c"SDL.texture.create.opengl.texture_u".as_ptr();
1234
1235pub const SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER: *const ::core::ffi::c_char =
1236 c"SDL.texture.create.opengl.texture_v".as_ptr();
1237
1238pub const SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1239 c"SDL.texture.create.opengles2.texture".as_ptr();
1240
1241pub const SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER: *const ::core::ffi::c_char =
1242 c"SDL.texture.create.opengles2.texture_uv".as_ptr();
1243
1244pub const SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER: *const ::core::ffi::c_char =
1245 c"SDL.texture.create.opengles2.texture_u".as_ptr();
1246
1247pub const SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER: *const ::core::ffi::c_char =
1248 c"SDL.texture.create.opengles2.texture_v".as_ptr();
1249
1250pub const SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1251 c"SDL.texture.create.vulkan.texture".as_ptr();
1252
1253pub const SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER: *const ::core::ffi::c_char =
1254 c"SDL.texture.create.vulkan.layout".as_ptr();
1255
1256pub const SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER: *const ::core::ffi::c_char =
1257 c"SDL.texture.create.gpu.texture".as_ptr();
1258
1259pub const SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER: *const ::core::ffi::c_char =
1260 c"SDL.texture.create.gpu.texture_uv".as_ptr();
1261
1262pub const SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1263 c"SDL.texture.create.gpu.texture_u".as_ptr();
1264
1265pub const SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1266 c"SDL.texture.create.gpu.texture_v".as_ptr();
1267
1268unsafe extern "C" {
1269 /// Get the properties associated with a texture.
1270 ///
1271 /// The following read-only properties are provided by SDL:
1272 ///
1273 /// - [`SDL_PROP_TEXTURE_COLORSPACE_NUMBER`]\: an [`SDL_Colorspace`] value describing
1274 /// the texture colorspace.
1275 /// - [`SDL_PROP_TEXTURE_FORMAT_NUMBER`]\: one of the enumerated values in
1276 /// [`SDL_PixelFormat`].
1277 /// - [`SDL_PROP_TEXTURE_ACCESS_NUMBER`]\: one of the enumerated values in
1278 /// [`SDL_TextureAccess`].
1279 /// - [`SDL_PROP_TEXTURE_WIDTH_NUMBER`]\: the width of the texture in pixels.
1280 /// - [`SDL_PROP_TEXTURE_HEIGHT_NUMBER`]\: the height of the texture in pixels.
1281 /// - [`SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`]\: for HDR10 and floating point
1282 /// textures, this defines the value of 100% diffuse white, with higher
1283 /// values being displayed in the High Dynamic Range headroom. This defaults
1284 /// to 100 for HDR10 textures and 1.0 for other textures.
1285 /// - [`SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`]\: for HDR10 and floating point
1286 /// textures, this defines the maximum dynamic range used by the content, in
1287 /// terms of the SDR white point. If this is defined, any values outside the
1288 /// range supported by the display will be scaled into the available HDR
1289 /// headroom, otherwise they are clipped. This defaults to 1.0 for SDR
1290 /// textures, 4.0 for HDR10 textures, and no default for floating point
1291 /// textures.
1292 ///
1293 /// With the direct3d11 renderer:
1294 ///
1295 /// - [`SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`]\: the ID3D11Texture2D associated
1296 /// with the texture
1297 /// - [`SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`]\: the ID3D11Texture2D
1298 /// associated with the U plane of a YUV texture
1299 /// - [`SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`]\: the ID3D11Texture2D
1300 /// associated with the V plane of a YUV texture
1301 ///
1302 /// With the direct3d12 renderer:
1303 ///
1304 /// - [`SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`]\: the ID3D12Resource associated
1305 /// with the texture
1306 /// - [`SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`]\: the ID3D12Resource associated
1307 /// with the U plane of a YUV texture
1308 /// - [`SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`]\: the ID3D12Resource associated
1309 /// with the V plane of a YUV texture
1310 ///
1311 /// With the vulkan renderer:
1312 ///
1313 /// - [`SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`]\: the VkImage associated with the
1314 /// texture
1315 ///
1316 /// With the opengl renderer:
1317 ///
1318 /// - [`SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`]\: the GLuint texture associated
1319 /// with the texture
1320 /// - [`SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`]\: the GLuint texture
1321 /// associated with the UV plane of an NV12 texture
1322 /// - [`SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`]\: the GLuint texture associated
1323 /// with the U plane of a YUV texture
1324 /// - [`SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`]\: the GLuint texture associated
1325 /// with the V plane of a YUV texture
1326 /// - [`SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`]\: the GLenum for the
1327 /// texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
1328 /// - [`SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`]\: the texture coordinate width of
1329 /// the texture (0.0 - 1.0)
1330 /// - [`SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`]\: the texture coordinate height of
1331 /// the texture (0.0 - 1.0)
1332 ///
1333 /// With the opengles2 renderer:
1334 ///
1335 /// - [`SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`]\: the GLuint texture
1336 /// associated with the texture
1337 /// - [`SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`]\: the GLuint texture
1338 /// associated with the UV plane of an NV12 texture
1339 /// - [`SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`]\: the GLuint texture
1340 /// associated with the U plane of a YUV texture
1341 /// - [`SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`]\: the GLuint texture
1342 /// associated with the V plane of a YUV texture
1343 /// - [`SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`]\: the GLenum for the
1344 /// texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
1345 ///
1346 /// With the gpu renderer:
1347 ///
1348 /// - [`SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`]\: the [`SDL_GPUTexture`] associated
1349 /// with the texture
1350 /// - [`SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`]\: the [`SDL_GPUTexture`] associated
1351 /// with the UV plane of an NV12 texture
1352 /// - [`SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`]\: the [`SDL_GPUTexture`] associated
1353 /// with the U plane of a YUV texture
1354 /// - [`SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`]\: the [`SDL_GPUTexture`] associated
1355 /// with the V plane of a YUV texture
1356 ///
1357 /// ## Parameters
1358 /// - `texture`: the texture to query.
1359 ///
1360 /// ## Return value
1361 /// Returns a valid property ID on success or 0 on failure; call
1362 /// [`SDL_GetError()`] for more information.
1363 ///
1364 /// ## Thread safety
1365 /// It is safe to call this function from any thread.
1366 ///
1367 /// ## Availability
1368 /// This function is available since SDL 3.2.0.
1369 pub fn SDL_GetTextureProperties(texture: *mut SDL_Texture) -> SDL_PropertiesID;
1370}
1371
1372pub const SDL_PROP_TEXTURE_COLORSPACE_NUMBER: *const ::core::ffi::c_char =
1373 c"SDL.texture.colorspace".as_ptr();
1374
1375pub const SDL_PROP_TEXTURE_FORMAT_NUMBER: *const ::core::ffi::c_char =
1376 c"SDL.texture.format".as_ptr();
1377
1378pub const SDL_PROP_TEXTURE_ACCESS_NUMBER: *const ::core::ffi::c_char =
1379 c"SDL.texture.access".as_ptr();
1380
1381pub const SDL_PROP_TEXTURE_WIDTH_NUMBER: *const ::core::ffi::c_char = c"SDL.texture.width".as_ptr();
1382
1383pub const SDL_PROP_TEXTURE_HEIGHT_NUMBER: *const ::core::ffi::c_char =
1384 c"SDL.texture.height".as_ptr();
1385
1386pub const SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT: *const ::core::ffi::c_char =
1387 c"SDL.texture.SDR_white_point".as_ptr();
1388
1389pub const SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT: *const ::core::ffi::c_char =
1390 c"SDL.texture.HDR_headroom".as_ptr();
1391
1392pub const SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER: *const ::core::ffi::c_char =
1393 c"SDL.texture.d3d11.texture".as_ptr();
1394
1395pub const SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1396 c"SDL.texture.d3d11.texture_u".as_ptr();
1397
1398pub const SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1399 c"SDL.texture.d3d11.texture_v".as_ptr();
1400
1401pub const SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER: *const ::core::ffi::c_char =
1402 c"SDL.texture.d3d12.texture".as_ptr();
1403
1404pub const SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1405 c"SDL.texture.d3d12.texture_u".as_ptr();
1406
1407pub const SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1408 c"SDL.texture.d3d12.texture_v".as_ptr();
1409
1410pub const SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1411 c"SDL.texture.opengl.texture".as_ptr();
1412
1413pub const SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER: *const ::core::ffi::c_char =
1414 c"SDL.texture.opengl.texture_uv".as_ptr();
1415
1416pub const SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER: *const ::core::ffi::c_char =
1417 c"SDL.texture.opengl.texture_u".as_ptr();
1418
1419pub const SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER: *const ::core::ffi::c_char =
1420 c"SDL.texture.opengl.texture_v".as_ptr();
1421
1422pub const SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER: *const ::core::ffi::c_char =
1423 c"SDL.texture.opengl.target".as_ptr();
1424
1425pub const SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT: *const ::core::ffi::c_char =
1426 c"SDL.texture.opengl.tex_w".as_ptr();
1427
1428pub const SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT: *const ::core::ffi::c_char =
1429 c"SDL.texture.opengl.tex_h".as_ptr();
1430
1431pub const SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1432 c"SDL.texture.opengles2.texture".as_ptr();
1433
1434pub const SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER: *const ::core::ffi::c_char =
1435 c"SDL.texture.opengles2.texture_uv".as_ptr();
1436
1437pub const SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER: *const ::core::ffi::c_char =
1438 c"SDL.texture.opengles2.texture_u".as_ptr();
1439
1440pub const SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER: *const ::core::ffi::c_char =
1441 c"SDL.texture.opengles2.texture_v".as_ptr();
1442
1443pub const SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER: *const ::core::ffi::c_char =
1444 c"SDL.texture.opengles2.target".as_ptr();
1445
1446pub const SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER: *const ::core::ffi::c_char =
1447 c"SDL.texture.vulkan.texture".as_ptr();
1448
1449pub const SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER: *const ::core::ffi::c_char =
1450 c"SDL.texture.gpu.texture".as_ptr();
1451
1452pub const SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER: *const ::core::ffi::c_char =
1453 c"SDL.texture.gpu.texture_uv".as_ptr();
1454
1455pub const SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER: *const ::core::ffi::c_char =
1456 c"SDL.texture.gpu.texture_u".as_ptr();
1457
1458pub const SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER: *const ::core::ffi::c_char =
1459 c"SDL.texture.gpu.texture_v".as_ptr();
1460
1461unsafe extern "C" {
1462 /// Get the renderer that created an [`SDL_Texture`].
1463 ///
1464 /// ## Parameters
1465 /// - `texture`: the texture to query.
1466 ///
1467 /// ## Return value
1468 /// Returns a pointer to the [`SDL_Renderer`] that created the texture, or NULL on
1469 /// failure; call [`SDL_GetError()`] for more information.
1470 ///
1471 /// ## Thread safety
1472 /// It is safe to call this function from any thread.
1473 ///
1474 /// ## Availability
1475 /// This function is available since SDL 3.2.0.
1476 pub fn SDL_GetRendererFromTexture(texture: *mut SDL_Texture) -> *mut SDL_Renderer;
1477}
1478
1479unsafe extern "C" {
1480 /// Get the size of a texture, as floating point values.
1481 ///
1482 /// ## Parameters
1483 /// - `texture`: the texture to query.
1484 /// - `w`: a pointer filled in with the width of the texture in pixels. This
1485 /// argument can be NULL if you don't need this information.
1486 /// - `h`: a pointer filled in with the height of the texture in pixels. This
1487 /// argument can be NULL if you don't need this information.
1488 ///
1489 /// ## Return value
1490 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1491 /// information.
1492 ///
1493 /// ## Thread safety
1494 /// This function should only be called on the main thread.
1495 ///
1496 /// ## Availability
1497 /// This function is available since SDL 3.2.0.
1498 pub fn SDL_GetTextureSize(
1499 texture: *mut SDL_Texture,
1500 w: *mut ::core::ffi::c_float,
1501 h: *mut ::core::ffi::c_float,
1502 ) -> ::core::primitive::bool;
1503}
1504
1505unsafe extern "C" {
1506 /// Set the palette used by a texture.
1507 ///
1508 /// Setting the palette keeps an internal reference to the palette, which can
1509 /// be safely destroyed afterwards.
1510 ///
1511 /// A single palette can be shared with many textures.
1512 ///
1513 /// ## Parameters
1514 /// - `texture`: the texture to update.
1515 /// - `palette`: the [`SDL_Palette`] structure to use.
1516 ///
1517 /// ## Return value
1518 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1519 /// information.
1520 ///
1521 /// ## Thread safety
1522 /// This function should only be called on the main thread.
1523 ///
1524 /// ## Availability
1525 /// This function is available since SDL 3.4.0.
1526 ///
1527 /// ## See also
1528 /// - [`SDL_CreatePalette`]
1529 /// - [`SDL_GetTexturePalette`]
1530 pub fn SDL_SetTexturePalette(
1531 texture: *mut SDL_Texture,
1532 palette: *mut SDL_Palette,
1533 ) -> ::core::primitive::bool;
1534}
1535
1536unsafe extern "C" {
1537 /// Get the palette used by a texture.
1538 ///
1539 /// ## Parameters
1540 /// - `texture`: the texture to query.
1541 ///
1542 /// ## Return value
1543 /// Returns a pointer to the palette used by the texture, or NULL if there is
1544 /// no palette used.
1545 ///
1546 /// ## Thread safety
1547 /// This function should only be called on the main thread.
1548 ///
1549 /// ## Availability
1550 /// This function is available since SDL 3.4.0.
1551 ///
1552 /// ## See also
1553 /// - [`SDL_SetTexturePalette`]
1554 pub fn SDL_GetTexturePalette(texture: *mut SDL_Texture) -> *mut SDL_Palette;
1555}
1556
1557unsafe extern "C" {
1558 /// Set an additional color value multiplied into render copy operations.
1559 ///
1560 /// When this texture is rendered, during the copy operation each source color
1561 /// channel is modulated by the appropriate color value according to the
1562 /// following formula:
1563 ///
1564 /// `srcC = srcC * (color / 255)`
1565 ///
1566 /// Color modulation is not always supported by the renderer; it will return
1567 /// false if color modulation is not supported.
1568 ///
1569 /// ## Parameters
1570 /// - `texture`: the texture to update.
1571 /// - `r`: the red color value multiplied into copy operations.
1572 /// - `g`: the green color value multiplied into copy operations.
1573 /// - `b`: the blue color value multiplied into copy operations.
1574 ///
1575 /// ## Return value
1576 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1577 /// information.
1578 ///
1579 /// ## Thread safety
1580 /// This function should only be called on the main thread.
1581 ///
1582 /// ## Availability
1583 /// This function is available since SDL 3.2.0.
1584 ///
1585 /// ## See also
1586 /// - [`SDL_GetTextureColorMod`]
1587 /// - [`SDL_SetTextureAlphaMod`]
1588 /// - [`SDL_SetTextureColorModFloat`]
1589 pub fn SDL_SetTextureColorMod(
1590 texture: *mut SDL_Texture,
1591 r: Uint8,
1592 g: Uint8,
1593 b: Uint8,
1594 ) -> ::core::primitive::bool;
1595}
1596
1597unsafe extern "C" {
1598 /// Set an additional color value multiplied into render copy operations.
1599 ///
1600 /// When this texture is rendered, during the copy operation each source color
1601 /// channel is modulated by the appropriate color value according to the
1602 /// following formula:
1603 ///
1604 /// `srcC = srcC * color`
1605 ///
1606 /// Color modulation is not always supported by the renderer; it will return
1607 /// false if color modulation is not supported.
1608 ///
1609 /// ## Parameters
1610 /// - `texture`: the texture to update.
1611 /// - `r`: the red color value multiplied into copy operations.
1612 /// - `g`: the green color value multiplied into copy operations.
1613 /// - `b`: the blue color value multiplied into copy operations.
1614 ///
1615 /// ## Return value
1616 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1617 /// information.
1618 ///
1619 /// ## Thread safety
1620 /// This function should only be called on the main thread.
1621 ///
1622 /// ## Availability
1623 /// This function is available since SDL 3.2.0.
1624 ///
1625 /// ## See also
1626 /// - [`SDL_GetTextureColorModFloat`]
1627 /// - [`SDL_SetTextureAlphaModFloat`]
1628 /// - [`SDL_SetTextureColorMod`]
1629 pub fn SDL_SetTextureColorModFloat(
1630 texture: *mut SDL_Texture,
1631 r: ::core::ffi::c_float,
1632 g: ::core::ffi::c_float,
1633 b: ::core::ffi::c_float,
1634 ) -> ::core::primitive::bool;
1635}
1636
1637unsafe extern "C" {
1638 /// Get the additional color value multiplied into render copy operations.
1639 ///
1640 /// ## Parameters
1641 /// - `texture`: the texture to query.
1642 /// - `r`: a pointer filled in with the current red color value.
1643 /// - `g`: a pointer filled in with the current green color value.
1644 /// - `b`: a pointer filled in with the current blue color value.
1645 ///
1646 /// ## Return value
1647 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1648 /// information.
1649 ///
1650 /// ## Thread safety
1651 /// This function should only be called on the main thread.
1652 ///
1653 /// ## Availability
1654 /// This function is available since SDL 3.2.0.
1655 ///
1656 /// ## See also
1657 /// - [`SDL_GetTextureAlphaMod`]
1658 /// - [`SDL_GetTextureColorModFloat`]
1659 /// - [`SDL_SetTextureColorMod`]
1660 pub fn SDL_GetTextureColorMod(
1661 texture: *mut SDL_Texture,
1662 r: *mut Uint8,
1663 g: *mut Uint8,
1664 b: *mut Uint8,
1665 ) -> ::core::primitive::bool;
1666}
1667
1668unsafe extern "C" {
1669 /// Get the additional color value multiplied into render copy operations.
1670 ///
1671 /// ## Parameters
1672 /// - `texture`: the texture to query.
1673 /// - `r`: a pointer filled in with the current red color value.
1674 /// - `g`: a pointer filled in with the current green color value.
1675 /// - `b`: a pointer filled in with the current blue color value.
1676 ///
1677 /// ## Return value
1678 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1679 /// information.
1680 ///
1681 /// ## Thread safety
1682 /// This function should only be called on the main thread.
1683 ///
1684 /// ## Availability
1685 /// This function is available since SDL 3.2.0.
1686 ///
1687 /// ## See also
1688 /// - [`SDL_GetTextureAlphaModFloat`]
1689 /// - [`SDL_GetTextureColorMod`]
1690 /// - [`SDL_SetTextureColorModFloat`]
1691 pub fn SDL_GetTextureColorModFloat(
1692 texture: *mut SDL_Texture,
1693 r: *mut ::core::ffi::c_float,
1694 g: *mut ::core::ffi::c_float,
1695 b: *mut ::core::ffi::c_float,
1696 ) -> ::core::primitive::bool;
1697}
1698
1699unsafe extern "C" {
1700 /// Set an additional alpha value multiplied into render copy operations.
1701 ///
1702 /// When this texture is rendered, during the copy operation the source alpha
1703 /// value is modulated by this alpha value according to the following formula:
1704 ///
1705 /// `srcA = srcA * (alpha / 255)`
1706 ///
1707 /// Alpha modulation is not always supported by the renderer; it will return
1708 /// false if alpha modulation is not supported.
1709 ///
1710 /// ## Parameters
1711 /// - `texture`: the texture to update.
1712 /// - `alpha`: the source alpha value multiplied into copy operations.
1713 ///
1714 /// ## Return value
1715 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1716 /// information.
1717 ///
1718 /// ## Thread safety
1719 /// This function should only be called on the main thread.
1720 ///
1721 /// ## Availability
1722 /// This function is available since SDL 3.2.0.
1723 ///
1724 /// ## See also
1725 /// - [`SDL_GetTextureAlphaMod`]
1726 /// - [`SDL_SetTextureAlphaModFloat`]
1727 /// - [`SDL_SetTextureColorMod`]
1728 pub fn SDL_SetTextureAlphaMod(
1729 texture: *mut SDL_Texture,
1730 alpha: Uint8,
1731 ) -> ::core::primitive::bool;
1732}
1733
1734unsafe extern "C" {
1735 /// Set an additional alpha value multiplied into render copy operations.
1736 ///
1737 /// When this texture is rendered, during the copy operation the source alpha
1738 /// value is modulated by this alpha value according to the following formula:
1739 ///
1740 /// `srcA = srcA * alpha`
1741 ///
1742 /// Alpha modulation is not always supported by the renderer; it will return
1743 /// false if alpha modulation is not supported.
1744 ///
1745 /// ## Parameters
1746 /// - `texture`: the texture to update.
1747 /// - `alpha`: the source alpha value multiplied into copy operations.
1748 ///
1749 /// ## Return value
1750 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1751 /// information.
1752 ///
1753 /// ## Thread safety
1754 /// This function should only be called on the main thread.
1755 ///
1756 /// ## Availability
1757 /// This function is available since SDL 3.2.0.
1758 ///
1759 /// ## See also
1760 /// - [`SDL_GetTextureAlphaModFloat`]
1761 /// - [`SDL_SetTextureAlphaMod`]
1762 /// - [`SDL_SetTextureColorModFloat`]
1763 pub fn SDL_SetTextureAlphaModFloat(
1764 texture: *mut SDL_Texture,
1765 alpha: ::core::ffi::c_float,
1766 ) -> ::core::primitive::bool;
1767}
1768
1769unsafe extern "C" {
1770 /// Get the additional alpha value multiplied into render copy operations.
1771 ///
1772 /// ## Parameters
1773 /// - `texture`: the texture to query.
1774 /// - `alpha`: a pointer filled in with the current alpha value.
1775 ///
1776 /// ## Return value
1777 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1778 /// information.
1779 ///
1780 /// ## Thread safety
1781 /// This function should only be called on the main thread.
1782 ///
1783 /// ## Availability
1784 /// This function is available since SDL 3.2.0.
1785 ///
1786 /// ## See also
1787 /// - [`SDL_GetTextureAlphaModFloat`]
1788 /// - [`SDL_GetTextureColorMod`]
1789 /// - [`SDL_SetTextureAlphaMod`]
1790 pub fn SDL_GetTextureAlphaMod(
1791 texture: *mut SDL_Texture,
1792 alpha: *mut Uint8,
1793 ) -> ::core::primitive::bool;
1794}
1795
1796unsafe extern "C" {
1797 /// Get the additional alpha value multiplied into render copy operations.
1798 ///
1799 /// ## Parameters
1800 /// - `texture`: the texture to query.
1801 /// - `alpha`: a pointer filled in with the current alpha value.
1802 ///
1803 /// ## Return value
1804 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1805 /// information.
1806 ///
1807 /// ## Thread safety
1808 /// This function should only be called on the main thread.
1809 ///
1810 /// ## Availability
1811 /// This function is available since SDL 3.2.0.
1812 ///
1813 /// ## See also
1814 /// - [`SDL_GetTextureAlphaMod`]
1815 /// - [`SDL_GetTextureColorModFloat`]
1816 /// - [`SDL_SetTextureAlphaModFloat`]
1817 pub fn SDL_GetTextureAlphaModFloat(
1818 texture: *mut SDL_Texture,
1819 alpha: *mut ::core::ffi::c_float,
1820 ) -> ::core::primitive::bool;
1821}
1822
1823unsafe extern "C" {
1824 /// Set the blend mode for a texture, used by [`SDL_RenderTexture()`].
1825 ///
1826 /// If the blend mode is not supported, the closest supported mode is chosen
1827 /// and this function returns false.
1828 ///
1829 /// ## Parameters
1830 /// - `texture`: the texture to update.
1831 /// - `blendMode`: the [`SDL_BlendMode`] to use for texture blending.
1832 ///
1833 /// ## Return value
1834 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1835 /// information.
1836 ///
1837 /// ## Thread safety
1838 /// This function should only be called on the main thread.
1839 ///
1840 /// ## Availability
1841 /// This function is available since SDL 3.2.0.
1842 ///
1843 /// ## See also
1844 /// - [`SDL_GetTextureBlendMode`]
1845 pub fn SDL_SetTextureBlendMode(
1846 texture: *mut SDL_Texture,
1847 blendMode: SDL_BlendMode,
1848 ) -> ::core::primitive::bool;
1849}
1850
1851unsafe extern "C" {
1852 /// Get the blend mode used for texture copy operations.
1853 ///
1854 /// ## Parameters
1855 /// - `texture`: the texture to query.
1856 /// - `blendMode`: a pointer filled in with the current [`SDL_BlendMode`].
1857 ///
1858 /// ## Return value
1859 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1860 /// information.
1861 ///
1862 /// ## Thread safety
1863 /// This function should only be called on the main thread.
1864 ///
1865 /// ## Availability
1866 /// This function is available since SDL 3.2.0.
1867 ///
1868 /// ## See also
1869 /// - [`SDL_SetTextureBlendMode`]
1870 pub fn SDL_GetTextureBlendMode(
1871 texture: *mut SDL_Texture,
1872 blendMode: *mut SDL_BlendMode,
1873 ) -> ::core::primitive::bool;
1874}
1875
1876unsafe extern "C" {
1877 /// Set the scale mode used for texture scale operations.
1878 ///
1879 /// The default texture scale mode is [`SDL_SCALEMODE_LINEAR`].
1880 ///
1881 /// If the scale mode is not supported, the closest supported mode is chosen.
1882 ///
1883 /// ## Parameters
1884 /// - `texture`: the texture to update.
1885 /// - `scaleMode`: the [`SDL_ScaleMode`] to use for texture scaling.
1886 ///
1887 /// ## Return value
1888 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1889 /// information.
1890 ///
1891 /// ## Thread safety
1892 /// This function should only be called on the main thread.
1893 ///
1894 /// ## Availability
1895 /// This function is available since SDL 3.2.0.
1896 ///
1897 /// ## See also
1898 /// - [`SDL_GetTextureScaleMode`]
1899 pub fn SDL_SetTextureScaleMode(
1900 texture: *mut SDL_Texture,
1901 scaleMode: SDL_ScaleMode,
1902 ) -> ::core::primitive::bool;
1903}
1904
1905unsafe extern "C" {
1906 /// Get the scale mode used for texture scale operations.
1907 ///
1908 /// ## Parameters
1909 /// - `texture`: the texture to query.
1910 /// - `scaleMode`: a pointer filled in with the current scale mode.
1911 ///
1912 /// ## Return value
1913 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1914 /// information.
1915 ///
1916 /// ## Thread safety
1917 /// This function should only be called on the main thread.
1918 ///
1919 /// ## Availability
1920 /// This function is available since SDL 3.2.0.
1921 ///
1922 /// ## See also
1923 /// - [`SDL_SetTextureScaleMode`]
1924 pub fn SDL_GetTextureScaleMode(
1925 texture: *mut SDL_Texture,
1926 scaleMode: *mut SDL_ScaleMode,
1927 ) -> ::core::primitive::bool;
1928}
1929
1930unsafe extern "C" {
1931 /// Update the given texture rectangle with new pixel data.
1932 ///
1933 /// The pixel data must be in the pixel format of the texture, which can be
1934 /// queried using the [`SDL_PROP_TEXTURE_FORMAT_NUMBER`] property.
1935 ///
1936 /// This is a fairly slow function, intended for use with static textures that
1937 /// do not change often.
1938 ///
1939 /// If the texture is intended to be updated often, it is preferred to create
1940 /// the texture as streaming and use the locking functions referenced below.
1941 /// While this function will work with streaming textures, for optimization
1942 /// reasons you may not get the pixels back if you lock the texture afterward.
1943 ///
1944 /// ## Parameters
1945 /// - `texture`: the texture to update.
1946 /// - `rect`: an [`SDL_Rect`] structure representing the area to update, or NULL
1947 /// to update the entire texture.
1948 /// - `pixels`: the raw pixel data in the format of the texture.
1949 /// - `pitch`: the number of bytes in a row of pixel data, including padding
1950 /// between lines.
1951 ///
1952 /// ## Return value
1953 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1954 /// information.
1955 ///
1956 /// ## Thread safety
1957 /// This function should only be called on the main thread.
1958 ///
1959 /// ## Availability
1960 /// This function is available since SDL 3.2.0.
1961 ///
1962 /// ## See also
1963 /// - [`SDL_LockTexture`]
1964 /// - [`SDL_UnlockTexture`]
1965 /// - [`SDL_UpdateNVTexture`]
1966 /// - [`SDL_UpdateYUVTexture`]
1967 pub fn SDL_UpdateTexture(
1968 texture: *mut SDL_Texture,
1969 rect: *const SDL_Rect,
1970 pixels: *const ::core::ffi::c_void,
1971 pitch: ::core::ffi::c_int,
1972 ) -> ::core::primitive::bool;
1973}
1974
1975unsafe extern "C" {
1976 /// Update a rectangle within a planar YV12 or IYUV texture with new pixel
1977 /// data.
1978 ///
1979 /// You can use [`SDL_UpdateTexture()`] as long as your pixel data is a contiguous
1980 /// block of Y and U/V planes in the proper order, but this function is
1981 /// available if your pixel data is not contiguous.
1982 ///
1983 /// ## Parameters
1984 /// - `texture`: the texture to update.
1985 /// - `rect`: a pointer to the rectangle of pixels to update, or NULL to
1986 /// update the entire texture.
1987 /// - `Yplane`: the raw pixel data for the Y plane.
1988 /// - `Ypitch`: the number of bytes between rows of pixel data for the Y
1989 /// plane.
1990 /// - `Uplane`: the raw pixel data for the U plane.
1991 /// - `Upitch`: the number of bytes between rows of pixel data for the U
1992 /// plane.
1993 /// - `Vplane`: the raw pixel data for the V plane.
1994 /// - `Vpitch`: the number of bytes between rows of pixel data for the V
1995 /// plane.
1996 ///
1997 /// ## Return value
1998 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1999 /// information.
2000 ///
2001 /// ## Thread safety
2002 /// This function should only be called on the main thread.
2003 ///
2004 /// ## Availability
2005 /// This function is available since SDL 3.2.0.
2006 ///
2007 /// ## See also
2008 /// - [`SDL_UpdateNVTexture`]
2009 /// - [`SDL_UpdateTexture`]
2010 pub fn SDL_UpdateYUVTexture(
2011 texture: *mut SDL_Texture,
2012 rect: *const SDL_Rect,
2013 Yplane: *const Uint8,
2014 Ypitch: ::core::ffi::c_int,
2015 Uplane: *const Uint8,
2016 Upitch: ::core::ffi::c_int,
2017 Vplane: *const Uint8,
2018 Vpitch: ::core::ffi::c_int,
2019 ) -> ::core::primitive::bool;
2020}
2021
2022unsafe extern "C" {
2023 /// Update a rectangle within a planar NV12 or NV21 texture with new pixels.
2024 ///
2025 /// You can use [`SDL_UpdateTexture()`] as long as your pixel data is a contiguous
2026 /// block of NV12/21 planes in the proper order, but this function is available
2027 /// if your pixel data is not contiguous.
2028 ///
2029 /// ## Parameters
2030 /// - `texture`: the texture to update.
2031 /// - `rect`: a pointer to the rectangle of pixels to update, or NULL to
2032 /// update the entire texture.
2033 /// - `Yplane`: the raw pixel data for the Y plane.
2034 /// - `Ypitch`: the number of bytes between rows of pixel data for the Y
2035 /// plane.
2036 /// - `UVplane`: the raw pixel data for the UV plane.
2037 /// - `UVpitch`: the number of bytes between rows of pixel data for the UV
2038 /// plane.
2039 ///
2040 /// ## Return value
2041 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2042 /// information.
2043 ///
2044 /// ## Thread safety
2045 /// This function should only be called on the main thread.
2046 ///
2047 /// ## Availability
2048 /// This function is available since SDL 3.2.0.
2049 ///
2050 /// ## See also
2051 /// - [`SDL_UpdateTexture`]
2052 /// - [`SDL_UpdateYUVTexture`]
2053 pub fn SDL_UpdateNVTexture(
2054 texture: *mut SDL_Texture,
2055 rect: *const SDL_Rect,
2056 Yplane: *const Uint8,
2057 Ypitch: ::core::ffi::c_int,
2058 UVplane: *const Uint8,
2059 UVpitch: ::core::ffi::c_int,
2060 ) -> ::core::primitive::bool;
2061}
2062
2063unsafe extern "C" {
2064 /// Lock a portion of the texture for **write-only** pixel access.
2065 ///
2066 /// As an optimization, the pixels made available for editing don't necessarily
2067 /// contain the old texture data. This is a write-only operation, and if you
2068 /// need to keep a copy of the texture data you should do that at the
2069 /// application level.
2070 ///
2071 /// You must use [`SDL_UnlockTexture()`] to unlock the pixels and apply any
2072 /// changes.
2073 ///
2074 /// ## Parameters
2075 /// - `texture`: the texture to lock for access, which was created with
2076 /// [`SDL_TEXTUREACCESS_STREAMING`].
2077 /// - `rect`: an [`SDL_Rect`] structure representing the area to lock for access;
2078 /// NULL to lock the entire texture.
2079 /// - `pixels`: this is filled in with a pointer to the locked pixels,
2080 /// appropriately offset by the locked area.
2081 /// - `pitch`: this is filled in with the pitch of the locked pixels; the
2082 /// pitch is the length of one row in bytes.
2083 ///
2084 /// ## Return value
2085 /// Returns true on success or false if the texture is not valid or was not
2086 /// created with [`SDL_TEXTUREACCESS_STREAMING`]; call [`SDL_GetError()`]
2087 /// for more information.
2088 ///
2089 /// ## Thread safety
2090 /// This function should only be called on the main thread.
2091 ///
2092 /// ## Availability
2093 /// This function is available since SDL 3.2.0.
2094 ///
2095 /// ## See also
2096 /// - [`SDL_LockTextureToSurface`]
2097 /// - [`SDL_UnlockTexture`]
2098 pub fn SDL_LockTexture(
2099 texture: *mut SDL_Texture,
2100 rect: *const SDL_Rect,
2101 pixels: *mut *mut ::core::ffi::c_void,
2102 pitch: *mut ::core::ffi::c_int,
2103 ) -> ::core::primitive::bool;
2104}
2105
2106unsafe extern "C" {
2107 /// Lock a portion of the texture for **write-only** pixel access, and expose
2108 /// it as a SDL surface.
2109 ///
2110 /// Besides providing an [`SDL_Surface`] instead of raw pixel data, this function
2111 /// operates like [`SDL_LockTexture`].
2112 ///
2113 /// As an optimization, the pixels made available for editing don't necessarily
2114 /// contain the old texture data. This is a write-only operation, and if you
2115 /// need to keep a copy of the texture data you should do that at the
2116 /// application level.
2117 ///
2118 /// You must use [`SDL_UnlockTexture()`] to unlock the pixels and apply any
2119 /// changes.
2120 ///
2121 /// The returned surface is freed internally after calling [`SDL_UnlockTexture()`]
2122 /// or [`SDL_DestroyTexture()`]. The caller should not free it.
2123 ///
2124 /// ## Parameters
2125 /// - `texture`: the texture to lock for access, which must be created with
2126 /// [`SDL_TEXTUREACCESS_STREAMING`].
2127 /// - `rect`: a pointer to the rectangle to lock for access. If the rect is
2128 /// NULL, the entire texture will be locked.
2129 /// - `surface`: a pointer to an SDL surface of size **rect**. Don't assume
2130 /// any specific pixel content.
2131 ///
2132 /// ## Return value
2133 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2134 /// information.
2135 ///
2136 /// ## Thread safety
2137 /// This function should only be called on the main thread.
2138 ///
2139 /// ## Availability
2140 /// This function is available since SDL 3.2.0.
2141 ///
2142 /// ## See also
2143 /// - [`SDL_LockTexture`]
2144 /// - [`SDL_UnlockTexture`]
2145 pub fn SDL_LockTextureToSurface(
2146 texture: *mut SDL_Texture,
2147 rect: *const SDL_Rect,
2148 surface: *mut *mut SDL_Surface,
2149 ) -> ::core::primitive::bool;
2150}
2151
2152unsafe extern "C" {
2153 /// Unlock a texture, uploading the changes to video memory, if needed.
2154 ///
2155 /// **Warning**: Please note that [`SDL_LockTexture()`] is intended to be
2156 /// write-only; it will not guarantee the previous contents of the texture will
2157 /// be provided. You must fully initialize any area of a texture that you lock
2158 /// before unlocking it, as the pixels might otherwise be uninitialized memory.
2159 ///
2160 /// Which is to say: locking and immediately unlocking a texture can result in
2161 /// corrupted textures, depending on the renderer in use.
2162 ///
2163 /// ## Parameters
2164 /// - `texture`: a texture locked by [`SDL_LockTexture()`].
2165 ///
2166 /// ## Thread safety
2167 /// This function should only be called on the main thread.
2168 ///
2169 /// ## Availability
2170 /// This function is available since SDL 3.2.0.
2171 ///
2172 /// ## See also
2173 /// - [`SDL_LockTexture`]
2174 pub fn SDL_UnlockTexture(texture: *mut SDL_Texture);
2175}
2176
2177unsafe extern "C" {
2178 /// Set a texture as the current rendering target.
2179 ///
2180 /// The default render target is the window for which the renderer was created.
2181 /// To stop rendering to a texture and render to the window again, call this
2182 /// function with a NULL `texture`.
2183 ///
2184 /// Viewport, cliprect, scale, and logical presentation are unique to each
2185 /// render target. Get and set functions for these states apply to the current
2186 /// render target set by this function, and those states persist on each target
2187 /// when the current render target changes.
2188 ///
2189 /// ## Parameters
2190 /// - `renderer`: the rendering context.
2191 /// - `texture`: the targeted texture, which must be created with the
2192 /// [`SDL_TEXTUREACCESS_TARGET`] flag, or NULL to render to the
2193 /// window instead of a texture.
2194 ///
2195 /// ## Return value
2196 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2197 /// information.
2198 ///
2199 /// ## Thread safety
2200 /// This function should only be called on the main thread.
2201 ///
2202 /// ## Availability
2203 /// This function is available since SDL 3.2.0.
2204 ///
2205 /// ## See also
2206 /// - [`SDL_GetRenderTarget`]
2207 pub fn SDL_SetRenderTarget(
2208 renderer: *mut SDL_Renderer,
2209 texture: *mut SDL_Texture,
2210 ) -> ::core::primitive::bool;
2211}
2212
2213unsafe extern "C" {
2214 /// Get the current render target.
2215 ///
2216 /// The default render target is the window for which the renderer was created,
2217 /// and is reported a NULL here.
2218 ///
2219 /// ## Parameters
2220 /// - `renderer`: the rendering context.
2221 ///
2222 /// ## Return value
2223 /// Returns the current render target or NULL for the default render target.
2224 ///
2225 /// ## Thread safety
2226 /// This function should only be called on the main thread.
2227 ///
2228 /// ## Availability
2229 /// This function is available since SDL 3.2.0.
2230 ///
2231 /// ## See also
2232 /// - [`SDL_SetRenderTarget`]
2233 pub fn SDL_GetRenderTarget(renderer: *mut SDL_Renderer) -> *mut SDL_Texture;
2234}
2235
2236unsafe extern "C" {
2237 /// Set a device-independent resolution and presentation mode for rendering.
2238 ///
2239 /// This function sets the width and height of the logical rendering output.
2240 /// The renderer will act as if the current render target is always the
2241 /// requested dimensions, scaling to the actual resolution as necessary.
2242 ///
2243 /// This can be useful for games that expect a fixed size, but would like to
2244 /// scale the output to whatever is available, regardless of how a user resizes
2245 /// a window, or if the display is high DPI.
2246 ///
2247 /// Logical presentation can be used with both render target textures and the
2248 /// renderer's window; the state is unique to each render target, and this
2249 /// function sets the state for the current render target. It might be useful
2250 /// to draw to a texture that matches the window dimensions with logical
2251 /// presentation enabled, and then draw that texture across the entire window
2252 /// with logical presentation disabled. Be careful not to render both with
2253 /// logical presentation enabled, however, as this could produce
2254 /// double-letterboxing, etc.
2255 ///
2256 /// You can disable logical coordinates by setting the mode to
2257 /// [`SDL_LOGICAL_PRESENTATION_DISABLED`], and in that case you get the full pixel
2258 /// resolution of the render target; it is safe to toggle logical presentation
2259 /// during the rendering of a frame: perhaps most of the rendering is done to
2260 /// specific dimensions but to make fonts look sharp, the app turns off logical
2261 /// presentation while drawing text, for example.
2262 ///
2263 /// You can convert coordinates in an event into rendering coordinates using
2264 /// [`SDL_ConvertEventToRenderCoordinates()`].
2265 ///
2266 /// ## Parameters
2267 /// - `renderer`: the rendering context.
2268 /// - `w`: the width of the logical resolution.
2269 /// - `h`: the height of the logical resolution.
2270 /// - `mode`: the presentation mode used.
2271 ///
2272 /// ## Return value
2273 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2274 /// information.
2275 ///
2276 /// ## Thread safety
2277 /// This function should only be called on the main thread.
2278 ///
2279 /// ## Availability
2280 /// This function is available since SDL 3.2.0.
2281 ///
2282 /// ## See also
2283 /// - [`SDL_ConvertEventToRenderCoordinates`]
2284 /// - [`SDL_GetRenderLogicalPresentation`]
2285 /// - [`SDL_GetRenderLogicalPresentationRect`]
2286 pub fn SDL_SetRenderLogicalPresentation(
2287 renderer: *mut SDL_Renderer,
2288 w: ::core::ffi::c_int,
2289 h: ::core::ffi::c_int,
2290 mode: SDL_RendererLogicalPresentation,
2291 ) -> ::core::primitive::bool;
2292}
2293
2294unsafe extern "C" {
2295 /// Get device independent resolution and presentation mode for rendering.
2296 ///
2297 /// This function gets the width and height of the logical rendering output, or
2298 /// 0 if a logical resolution is not enabled.
2299 ///
2300 /// Each render target has its own logical presentation state. This function
2301 /// gets the state for the current render target.
2302 ///
2303 /// ## Parameters
2304 /// - `renderer`: the rendering context.
2305 /// - `w`: an int filled with the logical presentation width.
2306 /// - `h`: an int filled with the logical presentation height.
2307 /// - `mode`: a variable filled with the logical presentation mode being
2308 /// used.
2309 ///
2310 /// ## Return value
2311 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2312 /// information.
2313 ///
2314 /// ## Thread safety
2315 /// This function should only be called on the main thread.
2316 ///
2317 /// ## Availability
2318 /// This function is available since SDL 3.2.0.
2319 ///
2320 /// ## See also
2321 /// - [`SDL_SetRenderLogicalPresentation`]
2322 pub fn SDL_GetRenderLogicalPresentation(
2323 renderer: *mut SDL_Renderer,
2324 w: *mut ::core::ffi::c_int,
2325 h: *mut ::core::ffi::c_int,
2326 mode: *mut SDL_RendererLogicalPresentation,
2327 ) -> ::core::primitive::bool;
2328}
2329
2330unsafe extern "C" {
2331 /// Get the final presentation rectangle for rendering.
2332 ///
2333 /// This function returns the calculated rectangle used for logical
2334 /// presentation, based on the presentation mode and output size. If logical
2335 /// presentation is disabled, it will fill the rectangle with the output size,
2336 /// in pixels.
2337 ///
2338 /// Each render target has its own logical presentation state. This function
2339 /// gets the rectangle for the current render target.
2340 ///
2341 /// ## Parameters
2342 /// - `renderer`: the rendering context.
2343 /// - `rect`: a pointer filled in with the final presentation rectangle, may
2344 /// be NULL.
2345 ///
2346 /// ## Return value
2347 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2348 /// information.
2349 ///
2350 /// ## Thread safety
2351 /// This function should only be called on the main thread.
2352 ///
2353 /// ## Availability
2354 /// This function is available since SDL 3.2.0.
2355 ///
2356 /// ## See also
2357 /// - [`SDL_SetRenderLogicalPresentation`]
2358 pub fn SDL_GetRenderLogicalPresentationRect(
2359 renderer: *mut SDL_Renderer,
2360 rect: *mut SDL_FRect,
2361 ) -> ::core::primitive::bool;
2362}
2363
2364unsafe extern "C" {
2365 /// Get a point in render coordinates when given a point in window coordinates.
2366 ///
2367 /// This takes into account several states:
2368 ///
2369 /// - The window dimensions.
2370 /// - The logical presentation settings ([`SDL_SetRenderLogicalPresentation`])
2371 /// - The scale ([`SDL_SetRenderScale`])
2372 /// - The viewport ([`SDL_SetRenderViewport`])
2373 ///
2374 /// ## Parameters
2375 /// - `renderer`: the rendering context.
2376 /// - `window_x`: the x coordinate in window coordinates.
2377 /// - `window_y`: the y coordinate in window coordinates.
2378 /// - `x`: a pointer filled with the x coordinate in render coordinates.
2379 /// - `y`: a pointer filled with the y coordinate in render coordinates.
2380 ///
2381 /// ## Return value
2382 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2383 /// information.
2384 ///
2385 /// ## Thread safety
2386 /// This function should only be called on the main thread.
2387 ///
2388 /// ## Availability
2389 /// This function is available since SDL 3.2.0.
2390 ///
2391 /// ## See also
2392 /// - [`SDL_SetRenderLogicalPresentation`]
2393 /// - [`SDL_SetRenderScale`]
2394 pub fn SDL_RenderCoordinatesFromWindow(
2395 renderer: *mut SDL_Renderer,
2396 window_x: ::core::ffi::c_float,
2397 window_y: ::core::ffi::c_float,
2398 x: *mut ::core::ffi::c_float,
2399 y: *mut ::core::ffi::c_float,
2400 ) -> ::core::primitive::bool;
2401}
2402
2403unsafe extern "C" {
2404 /// Get a point in window coordinates when given a point in render coordinates.
2405 ///
2406 /// This takes into account several states:
2407 ///
2408 /// - The window dimensions.
2409 /// - The logical presentation settings ([`SDL_SetRenderLogicalPresentation`])
2410 /// - The scale ([`SDL_SetRenderScale`])
2411 /// - The viewport ([`SDL_SetRenderViewport`])
2412 ///
2413 /// ## Parameters
2414 /// - `renderer`: the rendering context.
2415 /// - `x`: the x coordinate in render coordinates.
2416 /// - `y`: the y coordinate in render coordinates.
2417 /// - `window_x`: a pointer filled with the x coordinate in window
2418 /// coordinates.
2419 /// - `window_y`: a pointer filled with the y coordinate in window
2420 /// coordinates.
2421 ///
2422 /// ## Return value
2423 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2424 /// information.
2425 ///
2426 /// ## Thread safety
2427 /// This function should only be called on the main thread.
2428 ///
2429 /// ## Availability
2430 /// This function is available since SDL 3.2.0.
2431 ///
2432 /// ## See also
2433 /// - [`SDL_SetRenderLogicalPresentation`]
2434 /// - [`SDL_SetRenderScale`]
2435 /// - [`SDL_SetRenderViewport`]
2436 pub fn SDL_RenderCoordinatesToWindow(
2437 renderer: *mut SDL_Renderer,
2438 x: ::core::ffi::c_float,
2439 y: ::core::ffi::c_float,
2440 window_x: *mut ::core::ffi::c_float,
2441 window_y: *mut ::core::ffi::c_float,
2442 ) -> ::core::primitive::bool;
2443}
2444
2445unsafe extern "C" {
2446 /// Convert the coordinates in an event to render coordinates.
2447 ///
2448 /// This takes into account several states:
2449 ///
2450 /// - The window dimensions.
2451 /// - The logical presentation settings ([`SDL_SetRenderLogicalPresentation`])
2452 /// - The scale ([`SDL_SetRenderScale`])
2453 /// - The viewport ([`SDL_SetRenderViewport`])
2454 ///
2455 /// Various event types are converted with this function: mouse, touch, pen,
2456 /// etc.
2457 ///
2458 /// Touch coordinates are converted from normalized coordinates in the window
2459 /// to non-normalized rendering coordinates.
2460 ///
2461 /// Relative mouse coordinates (xrel and yrel event fields) are _also_
2462 /// converted. Applications that do not want these fields converted should use
2463 /// [`SDL_RenderCoordinatesFromWindow()`] on the specific event fields instead of
2464 /// converting the entire event structure.
2465 ///
2466 /// Once converted, coordinates may be outside the rendering area.
2467 ///
2468 /// ## Parameters
2469 /// - `renderer`: the rendering context.
2470 /// - `event`: the event to modify.
2471 ///
2472 /// ## Return value
2473 /// Returns true if the event is converted or doesn't need conversion, or
2474 /// false on failure; call [`SDL_GetError()`] for more information.
2475 ///
2476 /// ## Thread safety
2477 /// This function should only be called on the main thread.
2478 ///
2479 /// ## Availability
2480 /// This function is available since SDL 3.2.0.
2481 ///
2482 /// ## See also
2483 /// - [`SDL_RenderCoordinatesFromWindow`]
2484 pub fn SDL_ConvertEventToRenderCoordinates(
2485 renderer: *mut SDL_Renderer,
2486 event: *mut SDL_Event,
2487 ) -> ::core::primitive::bool;
2488}
2489
2490unsafe extern "C" {
2491 /// Set the drawing area for rendering on the current target.
2492 ///
2493 /// Drawing will clip to this area (separately from any clipping done with
2494 /// [`SDL_SetRenderClipRect`]), and the top left of the area will become coordinate
2495 /// (0, 0) for future drawing commands.
2496 ///
2497 /// The area's width and height must be >= 0.
2498 ///
2499 /// Each render target has its own viewport. This function sets the viewport
2500 /// for the current render target.
2501 ///
2502 /// ## Parameters
2503 /// - `renderer`: the rendering context.
2504 /// - `rect`: the [`SDL_Rect`] structure representing the drawing area, or NULL
2505 /// to set the viewport to the entire target.
2506 ///
2507 /// ## Return value
2508 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2509 /// information.
2510 ///
2511 /// ## Thread safety
2512 /// This function should only be called on the main thread.
2513 ///
2514 /// ## Availability
2515 /// This function is available since SDL 3.2.0.
2516 ///
2517 /// ## See also
2518 /// - [`SDL_GetRenderViewport`]
2519 /// - [`SDL_RenderViewportSet`]
2520 pub fn SDL_SetRenderViewport(
2521 renderer: *mut SDL_Renderer,
2522 rect: *const SDL_Rect,
2523 ) -> ::core::primitive::bool;
2524}
2525
2526unsafe extern "C" {
2527 /// Get the drawing area for the current target.
2528 ///
2529 /// Each render target has its own viewport. This function gets the viewport
2530 /// for the current render target.
2531 ///
2532 /// ## Parameters
2533 /// - `renderer`: the rendering context.
2534 /// - `rect`: an [`SDL_Rect`] structure filled in with the current drawing area.
2535 ///
2536 /// ## Return value
2537 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2538 /// information.
2539 ///
2540 /// ## Thread safety
2541 /// This function should only be called on the main thread.
2542 ///
2543 /// ## Availability
2544 /// This function is available since SDL 3.2.0.
2545 ///
2546 /// ## See also
2547 /// - [`SDL_RenderViewportSet`]
2548 /// - [`SDL_SetRenderViewport`]
2549 pub fn SDL_GetRenderViewport(
2550 renderer: *mut SDL_Renderer,
2551 rect: *mut SDL_Rect,
2552 ) -> ::core::primitive::bool;
2553}
2554
2555unsafe extern "C" {
2556 /// Return whether an explicit rectangle was set as the viewport.
2557 ///
2558 /// This is useful if you're saving and restoring the viewport and want to know
2559 /// whether you should restore a specific rectangle or NULL.
2560 ///
2561 /// Each render target has its own viewport. This function checks the viewport
2562 /// for the current render target.
2563 ///
2564 /// ## Parameters
2565 /// - `renderer`: the rendering context.
2566 ///
2567 /// ## Return value
2568 /// Returns true if the viewport was set to a specific rectangle, or false if
2569 /// it was set to NULL (the entire target).
2570 ///
2571 /// ## Thread safety
2572 /// This function should only be called on the main thread.
2573 ///
2574 /// ## Availability
2575 /// This function is available since SDL 3.2.0.
2576 ///
2577 /// ## See also
2578 /// - [`SDL_GetRenderViewport`]
2579 /// - [`SDL_SetRenderViewport`]
2580 pub fn SDL_RenderViewportSet(renderer: *mut SDL_Renderer) -> ::core::primitive::bool;
2581}
2582
2583unsafe extern "C" {
2584 /// Get the safe area for rendering within the current viewport.
2585 ///
2586 /// Some devices have portions of the screen which are partially obscured or
2587 /// not interactive, possibly due to on-screen controls, curved edges, camera
2588 /// notches, TV overscan, etc. This function provides the area of the current
2589 /// viewport which is safe to have interactible content. You should continue
2590 /// rendering into the rest of the render target, but it should not contain
2591 /// visually important or interactible content.
2592 ///
2593 /// ## Parameters
2594 /// - `renderer`: the rendering context.
2595 /// - `rect`: a pointer filled in with the area that is safe for interactive
2596 /// content.
2597 ///
2598 /// ## Return value
2599 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2600 /// information.
2601 ///
2602 /// ## Thread safety
2603 /// This function should only be called on the main thread.
2604 ///
2605 /// ## Availability
2606 /// This function is available since SDL 3.2.0.
2607 pub fn SDL_GetRenderSafeArea(
2608 renderer: *mut SDL_Renderer,
2609 rect: *mut SDL_Rect,
2610 ) -> ::core::primitive::bool;
2611}
2612
2613unsafe extern "C" {
2614 /// Set the clip rectangle for rendering on the specified target.
2615 ///
2616 /// Each render target has its own clip rectangle. This function sets the
2617 /// cliprect for the current render target.
2618 ///
2619 /// ## Parameters
2620 /// - `renderer`: the rendering context.
2621 /// - `rect`: an [`SDL_Rect`] structure representing the clip area, relative to
2622 /// the viewport, or NULL to disable clipping.
2623 ///
2624 /// ## Return value
2625 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2626 /// information.
2627 ///
2628 /// ## Thread safety
2629 /// This function should only be called on the main thread.
2630 ///
2631 /// ## Availability
2632 /// This function is available since SDL 3.2.0.
2633 ///
2634 /// ## See also
2635 /// - [`SDL_GetRenderClipRect`]
2636 /// - [`SDL_RenderClipEnabled`]
2637 pub fn SDL_SetRenderClipRect(
2638 renderer: *mut SDL_Renderer,
2639 rect: *const SDL_Rect,
2640 ) -> ::core::primitive::bool;
2641}
2642
2643unsafe extern "C" {
2644 /// Get the clip rectangle for the current target.
2645 ///
2646 /// Each render target has its own clip rectangle. This function gets the
2647 /// cliprect for the current render target.
2648 ///
2649 /// ## Parameters
2650 /// - `renderer`: the rendering context.
2651 /// - `rect`: an [`SDL_Rect`] structure filled in with the current clipping area
2652 /// or an empty rectangle if clipping is disabled.
2653 ///
2654 /// ## Return value
2655 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2656 /// information.
2657 ///
2658 /// ## Thread safety
2659 /// This function should only be called on the main thread.
2660 ///
2661 /// ## Availability
2662 /// This function is available since SDL 3.2.0.
2663 ///
2664 /// ## See also
2665 /// - [`SDL_RenderClipEnabled`]
2666 /// - [`SDL_SetRenderClipRect`]
2667 pub fn SDL_GetRenderClipRect(
2668 renderer: *mut SDL_Renderer,
2669 rect: *mut SDL_Rect,
2670 ) -> ::core::primitive::bool;
2671}
2672
2673unsafe extern "C" {
2674 /// Get whether clipping is enabled on the given render target.
2675 ///
2676 /// Each render target has its own clip rectangle. This function checks the
2677 /// cliprect for the current render target.
2678 ///
2679 /// ## Parameters
2680 /// - `renderer`: the rendering context.
2681 ///
2682 /// ## Return value
2683 /// Returns true if clipping is enabled or false if not; call [`SDL_GetError()`]
2684 /// for more information.
2685 ///
2686 /// ## Thread safety
2687 /// This function should only be called on the main thread.
2688 ///
2689 /// ## Availability
2690 /// This function is available since SDL 3.2.0.
2691 ///
2692 /// ## See also
2693 /// - [`SDL_GetRenderClipRect`]
2694 /// - [`SDL_SetRenderClipRect`]
2695 pub fn SDL_RenderClipEnabled(renderer: *mut SDL_Renderer) -> ::core::primitive::bool;
2696}
2697
2698unsafe extern "C" {
2699 /// Set the drawing scale for rendering on the current target.
2700 ///
2701 /// The drawing coordinates are scaled by the x/y scaling factors before they
2702 /// are used by the renderer. This allows resolution independent drawing with a
2703 /// single coordinate system.
2704 ///
2705 /// If this results in scaling or subpixel drawing by the rendering backend, it
2706 /// will be handled using the appropriate quality hints. For best results use
2707 /// integer scaling factors.
2708 ///
2709 /// Each render target has its own scale. This function sets the scale for the
2710 /// current render target.
2711 ///
2712 /// ## Parameters
2713 /// - `renderer`: the rendering context.
2714 /// - `scaleX`: the horizontal scaling factor.
2715 /// - `scaleY`: the vertical scaling factor.
2716 ///
2717 /// ## Return value
2718 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2719 /// information.
2720 ///
2721 /// ## Thread safety
2722 /// This function should only be called on the main thread.
2723 ///
2724 /// ## Availability
2725 /// This function is available since SDL 3.2.0.
2726 ///
2727 /// ## See also
2728 /// - [`SDL_GetRenderScale`]
2729 pub fn SDL_SetRenderScale(
2730 renderer: *mut SDL_Renderer,
2731 scaleX: ::core::ffi::c_float,
2732 scaleY: ::core::ffi::c_float,
2733 ) -> ::core::primitive::bool;
2734}
2735
2736unsafe extern "C" {
2737 /// Get the drawing scale for the current target.
2738 ///
2739 /// Each render target has its own scale. This function gets the scale for the
2740 /// current render target.
2741 ///
2742 /// ## Parameters
2743 /// - `renderer`: the rendering context.
2744 /// - `scaleX`: a pointer filled in with the horizontal scaling factor.
2745 /// - `scaleY`: a pointer filled in with the vertical scaling factor.
2746 ///
2747 /// ## Return value
2748 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2749 /// information.
2750 ///
2751 /// ## Thread safety
2752 /// This function should only be called on the main thread.
2753 ///
2754 /// ## Availability
2755 /// This function is available since SDL 3.2.0.
2756 ///
2757 /// ## See also
2758 /// - [`SDL_SetRenderScale`]
2759 pub fn SDL_GetRenderScale(
2760 renderer: *mut SDL_Renderer,
2761 scaleX: *mut ::core::ffi::c_float,
2762 scaleY: *mut ::core::ffi::c_float,
2763 ) -> ::core::primitive::bool;
2764}
2765
2766unsafe extern "C" {
2767 /// Set the color used for drawing operations.
2768 ///
2769 /// Set the color for drawing or filling rectangles, lines, and points, and for
2770 /// [`SDL_RenderClear()`].
2771 ///
2772 /// ## Parameters
2773 /// - `renderer`: the rendering context.
2774 /// - `r`: the red value used to draw on the rendering target.
2775 /// - `g`: the green value used to draw on the rendering target.
2776 /// - `b`: the blue value used to draw on the rendering target.
2777 /// - `a`: the alpha value used to draw on the rendering target; usually
2778 /// [`SDL_ALPHA_OPAQUE`] (255). Use [`SDL_SetRenderDrawBlendMode`] to
2779 /// specify how the alpha channel is used.
2780 ///
2781 /// ## Return value
2782 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2783 /// information.
2784 ///
2785 /// ## Thread safety
2786 /// This function should only be called on the main thread.
2787 ///
2788 /// ## Availability
2789 /// This function is available since SDL 3.2.0.
2790 ///
2791 /// ## See also
2792 /// - [`SDL_GetRenderDrawColor`]
2793 /// - [`SDL_SetRenderDrawColorFloat`]
2794 pub fn SDL_SetRenderDrawColor(
2795 renderer: *mut SDL_Renderer,
2796 r: Uint8,
2797 g: Uint8,
2798 b: Uint8,
2799 a: Uint8,
2800 ) -> ::core::primitive::bool;
2801}
2802
2803unsafe extern "C" {
2804 /// Set the color used for drawing operations (Rect, Line and Clear).
2805 ///
2806 /// Set the color for drawing or filling rectangles, lines, and points, and for
2807 /// [`SDL_RenderClear()`].
2808 ///
2809 /// ## Parameters
2810 /// - `renderer`: the rendering context.
2811 /// - `r`: the red value used to draw on the rendering target.
2812 /// - `g`: the green value used to draw on the rendering target.
2813 /// - `b`: the blue value used to draw on the rendering target.
2814 /// - `a`: the alpha value used to draw on the rendering target. Use
2815 /// [`SDL_SetRenderDrawBlendMode`] to specify how the alpha channel is
2816 /// used.
2817 ///
2818 /// ## Return value
2819 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2820 /// information.
2821 ///
2822 /// ## Thread safety
2823 /// This function should only be called on the main thread.
2824 ///
2825 /// ## Availability
2826 /// This function is available since SDL 3.2.0.
2827 ///
2828 /// ## See also
2829 /// - [`SDL_GetRenderDrawColorFloat`]
2830 /// - [`SDL_SetRenderDrawColor`]
2831 pub fn SDL_SetRenderDrawColorFloat(
2832 renderer: *mut SDL_Renderer,
2833 r: ::core::ffi::c_float,
2834 g: ::core::ffi::c_float,
2835 b: ::core::ffi::c_float,
2836 a: ::core::ffi::c_float,
2837 ) -> ::core::primitive::bool;
2838}
2839
2840unsafe extern "C" {
2841 /// Get the color used for drawing operations (Rect, Line and Clear).
2842 ///
2843 /// ## Parameters
2844 /// - `renderer`: the rendering context.
2845 /// - `r`: a pointer filled in with the red value used to draw on the
2846 /// rendering target.
2847 /// - `g`: a pointer filled in with the green value used to draw on the
2848 /// rendering target.
2849 /// - `b`: a pointer filled in with the blue value used to draw on the
2850 /// rendering target.
2851 /// - `a`: a pointer filled in with the alpha value used to draw on the
2852 /// rendering target; usually [`SDL_ALPHA_OPAQUE`] (255).
2853 ///
2854 /// ## Return value
2855 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2856 /// information.
2857 ///
2858 /// ## Thread safety
2859 /// This function should only be called on the main thread.
2860 ///
2861 /// ## Availability
2862 /// This function is available since SDL 3.2.0.
2863 ///
2864 /// ## See also
2865 /// - [`SDL_GetRenderDrawColorFloat`]
2866 /// - [`SDL_SetRenderDrawColor`]
2867 pub fn SDL_GetRenderDrawColor(
2868 renderer: *mut SDL_Renderer,
2869 r: *mut Uint8,
2870 g: *mut Uint8,
2871 b: *mut Uint8,
2872 a: *mut Uint8,
2873 ) -> ::core::primitive::bool;
2874}
2875
2876unsafe extern "C" {
2877 /// Get the color used for drawing operations (Rect, Line and Clear).
2878 ///
2879 /// ## Parameters
2880 /// - `renderer`: the rendering context.
2881 /// - `r`: a pointer filled in with the red value used to draw on the
2882 /// rendering target.
2883 /// - `g`: a pointer filled in with the green value used to draw on the
2884 /// rendering target.
2885 /// - `b`: a pointer filled in with the blue value used to draw on the
2886 /// rendering target.
2887 /// - `a`: a pointer filled in with the alpha value used to draw on the
2888 /// rendering target.
2889 ///
2890 /// ## Return value
2891 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2892 /// information.
2893 ///
2894 /// ## Thread safety
2895 /// This function should only be called on the main thread.
2896 ///
2897 /// ## Availability
2898 /// This function is available since SDL 3.2.0.
2899 ///
2900 /// ## See also
2901 /// - [`SDL_SetRenderDrawColorFloat`]
2902 /// - [`SDL_GetRenderDrawColor`]
2903 pub fn SDL_GetRenderDrawColorFloat(
2904 renderer: *mut SDL_Renderer,
2905 r: *mut ::core::ffi::c_float,
2906 g: *mut ::core::ffi::c_float,
2907 b: *mut ::core::ffi::c_float,
2908 a: *mut ::core::ffi::c_float,
2909 ) -> ::core::primitive::bool;
2910}
2911
2912unsafe extern "C" {
2913 /// Set the color scale used for render operations.
2914 ///
2915 /// The color scale is an additional scale multiplied into the pixel color
2916 /// value while rendering. This can be used to adjust the brightness of colors
2917 /// during HDR rendering, or changing HDR video brightness when playing on an
2918 /// SDR display.
2919 ///
2920 /// The color scale does not affect the alpha channel, only the color
2921 /// brightness.
2922 ///
2923 /// ## Parameters
2924 /// - `renderer`: the rendering context.
2925 /// - `scale`: the color scale value.
2926 ///
2927 /// ## Return value
2928 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2929 /// information.
2930 ///
2931 /// ## Thread safety
2932 /// This function should only be called on the main thread.
2933 ///
2934 /// ## Availability
2935 /// This function is available since SDL 3.2.0.
2936 ///
2937 /// ## See also
2938 /// - [`SDL_GetRenderColorScale`]
2939 pub fn SDL_SetRenderColorScale(
2940 renderer: *mut SDL_Renderer,
2941 scale: ::core::ffi::c_float,
2942 ) -> ::core::primitive::bool;
2943}
2944
2945unsafe extern "C" {
2946 /// Get the color scale used for render operations.
2947 ///
2948 /// ## Parameters
2949 /// - `renderer`: the rendering context.
2950 /// - `scale`: a pointer filled in with the current color scale value.
2951 ///
2952 /// ## Return value
2953 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2954 /// information.
2955 ///
2956 /// ## Thread safety
2957 /// This function should only be called on the main thread.
2958 ///
2959 /// ## Availability
2960 /// This function is available since SDL 3.2.0.
2961 ///
2962 /// ## See also
2963 /// - [`SDL_SetRenderColorScale`]
2964 pub fn SDL_GetRenderColorScale(
2965 renderer: *mut SDL_Renderer,
2966 scale: *mut ::core::ffi::c_float,
2967 ) -> ::core::primitive::bool;
2968}
2969
2970unsafe extern "C" {
2971 /// Set the blend mode used for drawing operations (Fill and Line).
2972 ///
2973 /// If the blend mode is not supported, the closest supported mode is chosen.
2974 ///
2975 /// ## Parameters
2976 /// - `renderer`: the rendering context.
2977 /// - `blendMode`: the [`SDL_BlendMode`] to use for blending.
2978 ///
2979 /// ## Return value
2980 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2981 /// information.
2982 ///
2983 /// ## Thread safety
2984 /// This function should only be called on the main thread.
2985 ///
2986 /// ## Availability
2987 /// This function is available since SDL 3.2.0.
2988 ///
2989 /// ## See also
2990 /// - [`SDL_GetRenderDrawBlendMode`]
2991 pub fn SDL_SetRenderDrawBlendMode(
2992 renderer: *mut SDL_Renderer,
2993 blendMode: SDL_BlendMode,
2994 ) -> ::core::primitive::bool;
2995}
2996
2997unsafe extern "C" {
2998 /// Get the blend mode used for drawing operations.
2999 ///
3000 /// ## Parameters
3001 /// - `renderer`: the rendering context.
3002 /// - `blendMode`: a pointer filled in with the current [`SDL_BlendMode`].
3003 ///
3004 /// ## Return value
3005 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3006 /// information.
3007 ///
3008 /// ## Thread safety
3009 /// This function should only be called on the main thread.
3010 ///
3011 /// ## Availability
3012 /// This function is available since SDL 3.2.0.
3013 ///
3014 /// ## See also
3015 /// - [`SDL_SetRenderDrawBlendMode`]
3016 pub fn SDL_GetRenderDrawBlendMode(
3017 renderer: *mut SDL_Renderer,
3018 blendMode: *mut SDL_BlendMode,
3019 ) -> ::core::primitive::bool;
3020}
3021
3022unsafe extern "C" {
3023 /// Clear the current rendering target with the drawing color.
3024 ///
3025 /// This function clears the entire rendering target, ignoring the viewport and
3026 /// the clip rectangle. Note, that clearing will also set/fill all pixels of
3027 /// the rendering target to current renderer draw color, so make sure to invoke
3028 /// [`SDL_SetRenderDrawColor()`] when needed.
3029 ///
3030 /// ## Parameters
3031 /// - `renderer`: the rendering context.
3032 ///
3033 /// ## Return value
3034 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3035 /// information.
3036 ///
3037 /// ## Thread safety
3038 /// This function should only be called on the main thread.
3039 ///
3040 /// ## Availability
3041 /// This function is available since SDL 3.2.0.
3042 ///
3043 /// ## See also
3044 /// - [`SDL_SetRenderDrawColor`]
3045 pub fn SDL_RenderClear(renderer: *mut SDL_Renderer) -> ::core::primitive::bool;
3046}
3047
3048unsafe extern "C" {
3049 /// Draw a point on the current rendering target at subpixel precision.
3050 ///
3051 /// ## Parameters
3052 /// - `renderer`: the renderer which should draw a point.
3053 /// - `x`: the x coordinate of the point.
3054 /// - `y`: the y coordinate of the point.
3055 ///
3056 /// ## Return value
3057 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3058 /// information.
3059 ///
3060 /// ## Thread safety
3061 /// This function should only be called on the main thread.
3062 ///
3063 /// ## Availability
3064 /// This function is available since SDL 3.2.0.
3065 ///
3066 /// ## See also
3067 /// - [`SDL_RenderPoints`]
3068 pub fn SDL_RenderPoint(
3069 renderer: *mut SDL_Renderer,
3070 x: ::core::ffi::c_float,
3071 y: ::core::ffi::c_float,
3072 ) -> ::core::primitive::bool;
3073}
3074
3075unsafe extern "C" {
3076 /// Draw multiple points on the current rendering target at subpixel precision.
3077 ///
3078 /// ## Parameters
3079 /// - `renderer`: the renderer which should draw multiple points.
3080 /// - `points`: the points to draw.
3081 /// - `count`: the number of points to draw.
3082 ///
3083 /// ## Return value
3084 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3085 /// information.
3086 ///
3087 /// ## Thread safety
3088 /// This function should only be called on the main thread.
3089 ///
3090 /// ## Availability
3091 /// This function is available since SDL 3.2.0.
3092 ///
3093 /// ## See also
3094 /// - [`SDL_RenderPoint`]
3095 pub fn SDL_RenderPoints(
3096 renderer: *mut SDL_Renderer,
3097 points: *const SDL_FPoint,
3098 count: ::core::ffi::c_int,
3099 ) -> ::core::primitive::bool;
3100}
3101
3102unsafe extern "C" {
3103 /// Draw a line on the current rendering target at subpixel precision.
3104 ///
3105 /// ## Parameters
3106 /// - `renderer`: the renderer which should draw a line.
3107 /// - `x1`: the x coordinate of the start point.
3108 /// - `y1`: the y coordinate of the start point.
3109 /// - `x2`: the x coordinate of the end point.
3110 /// - `y2`: the y coordinate of the end point.
3111 ///
3112 /// ## Return value
3113 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3114 /// information.
3115 ///
3116 /// ## Thread safety
3117 /// This function should only be called on the main thread.
3118 ///
3119 /// ## Availability
3120 /// This function is available since SDL 3.2.0.
3121 ///
3122 /// ## See also
3123 /// - [`SDL_RenderLines`]
3124 pub fn SDL_RenderLine(
3125 renderer: *mut SDL_Renderer,
3126 x1: ::core::ffi::c_float,
3127 y1: ::core::ffi::c_float,
3128 x2: ::core::ffi::c_float,
3129 y2: ::core::ffi::c_float,
3130 ) -> ::core::primitive::bool;
3131}
3132
3133unsafe extern "C" {
3134 /// Draw a series of connected lines on the current rendering target at
3135 /// subpixel precision.
3136 ///
3137 /// ## Parameters
3138 /// - `renderer`: the renderer which should draw multiple lines.
3139 /// - `points`: the points along the lines.
3140 /// - `count`: the number of points, drawing count-1 lines.
3141 ///
3142 /// ## Return value
3143 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3144 /// information.
3145 ///
3146 /// ## Thread safety
3147 /// This function should only be called on the main thread.
3148 ///
3149 /// ## Availability
3150 /// This function is available since SDL 3.2.0.
3151 ///
3152 /// ## See also
3153 /// - [`SDL_RenderLine`]
3154 pub fn SDL_RenderLines(
3155 renderer: *mut SDL_Renderer,
3156 points: *const SDL_FPoint,
3157 count: ::core::ffi::c_int,
3158 ) -> ::core::primitive::bool;
3159}
3160
3161unsafe extern "C" {
3162 /// Draw a rectangle on the current rendering target at subpixel precision.
3163 ///
3164 /// ## Parameters
3165 /// - `renderer`: the renderer which should draw a rectangle.
3166 /// - `rect`: a pointer to the destination rectangle, or NULL to outline the
3167 /// entire rendering target.
3168 ///
3169 /// ## Return value
3170 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3171 /// information.
3172 ///
3173 /// ## Thread safety
3174 /// This function should only be called on the main thread.
3175 ///
3176 /// ## Availability
3177 /// This function is available since SDL 3.2.0.
3178 ///
3179 /// ## See also
3180 /// - [`SDL_RenderRects`]
3181 pub fn SDL_RenderRect(
3182 renderer: *mut SDL_Renderer,
3183 rect: *const SDL_FRect,
3184 ) -> ::core::primitive::bool;
3185}
3186
3187unsafe extern "C" {
3188 /// Draw some number of rectangles on the current rendering target at subpixel
3189 /// precision.
3190 ///
3191 /// ## Parameters
3192 /// - `renderer`: the renderer which should draw multiple rectangles.
3193 /// - `rects`: a pointer to an array of destination rectangles.
3194 /// - `count`: the number of rectangles.
3195 ///
3196 /// ## Return value
3197 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3198 /// information.
3199 ///
3200 /// ## Thread safety
3201 /// This function should only be called on the main thread.
3202 ///
3203 /// ## Availability
3204 /// This function is available since SDL 3.2.0.
3205 ///
3206 /// ## See also
3207 /// - [`SDL_RenderRect`]
3208 pub fn SDL_RenderRects(
3209 renderer: *mut SDL_Renderer,
3210 rects: *const SDL_FRect,
3211 count: ::core::ffi::c_int,
3212 ) -> ::core::primitive::bool;
3213}
3214
3215unsafe extern "C" {
3216 /// Fill a rectangle on the current rendering target with the drawing color at
3217 /// subpixel precision.
3218 ///
3219 /// ## Parameters
3220 /// - `renderer`: the renderer which should fill a rectangle.
3221 /// - `rect`: a pointer to the destination rectangle, or NULL for the entire
3222 /// rendering target.
3223 ///
3224 /// ## Return value
3225 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3226 /// information.
3227 ///
3228 /// ## Thread safety
3229 /// This function should only be called on the main thread.
3230 ///
3231 /// ## Availability
3232 /// This function is available since SDL 3.2.0.
3233 ///
3234 /// ## See also
3235 /// - [`SDL_RenderFillRects`]
3236 pub fn SDL_RenderFillRect(
3237 renderer: *mut SDL_Renderer,
3238 rect: *const SDL_FRect,
3239 ) -> ::core::primitive::bool;
3240}
3241
3242unsafe extern "C" {
3243 /// Fill some number of rectangles on the current rendering target with the
3244 /// drawing color at subpixel precision.
3245 ///
3246 /// ## Parameters
3247 /// - `renderer`: the renderer which should fill multiple rectangles.
3248 /// - `rects`: a pointer to an array of destination rectangles.
3249 /// - `count`: the number of rectangles.
3250 ///
3251 /// ## Return value
3252 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3253 /// information.
3254 ///
3255 /// ## Thread safety
3256 /// This function should only be called on the main thread.
3257 ///
3258 /// ## Availability
3259 /// This function is available since SDL 3.2.0.
3260 ///
3261 /// ## See also
3262 /// - [`SDL_RenderFillRect`]
3263 pub fn SDL_RenderFillRects(
3264 renderer: *mut SDL_Renderer,
3265 rects: *const SDL_FRect,
3266 count: ::core::ffi::c_int,
3267 ) -> ::core::primitive::bool;
3268}
3269
3270unsafe extern "C" {
3271 /// Copy a portion of the texture to the current rendering target at subpixel
3272 /// precision.
3273 ///
3274 /// ## Parameters
3275 /// - `renderer`: the renderer which should copy parts of a texture.
3276 /// - `texture`: the source texture.
3277 /// - `srcrect`: a pointer to the source rectangle, or NULL for the entire
3278 /// texture.
3279 /// - `dstrect`: a pointer to the destination rectangle, or NULL for the
3280 /// entire rendering target.
3281 ///
3282 /// ## Return value
3283 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3284 /// information.
3285 ///
3286 /// ## Thread safety
3287 /// This function should only be called on the main thread.
3288 ///
3289 /// ## Availability
3290 /// This function is available since SDL 3.2.0.
3291 ///
3292 /// ## See also
3293 /// - [`SDL_RenderTextureRotated`]
3294 /// - [`SDL_RenderTextureTiled`]
3295 pub fn SDL_RenderTexture(
3296 renderer: *mut SDL_Renderer,
3297 texture: *mut SDL_Texture,
3298 srcrect: *const SDL_FRect,
3299 dstrect: *const SDL_FRect,
3300 ) -> ::core::primitive::bool;
3301}
3302
3303unsafe extern "C" {
3304 /// Copy a portion of the source texture to the current rendering target, with
3305 /// rotation and flipping, at subpixel precision.
3306 ///
3307 /// ## Parameters
3308 /// - `renderer`: the renderer which should copy parts of a texture.
3309 /// - `texture`: the source texture.
3310 /// - `srcrect`: a pointer to the source rectangle, or NULL for the entire
3311 /// texture.
3312 /// - `dstrect`: a pointer to the destination rectangle, or NULL for the
3313 /// entire rendering target.
3314 /// - `angle`: an angle in degrees that indicates the rotation that will be
3315 /// applied to dstrect, rotating it in a clockwise direction.
3316 /// - `center`: a pointer to a point indicating the point around which
3317 /// dstrect will be rotated (if NULL, rotation will be done
3318 /// around dstrect.w/2, dstrect.h/2).
3319 /// - `flip`: an [`SDL_FlipMode`] value stating which flipping actions should be
3320 /// performed on the texture.
3321 ///
3322 /// ## Return value
3323 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3324 /// information.
3325 ///
3326 /// ## Thread safety
3327 /// This function should only be called on the main thread.
3328 ///
3329 /// ## Availability
3330 /// This function is available since SDL 3.2.0.
3331 ///
3332 /// ## See also
3333 /// - [`SDL_RenderTexture`]
3334 pub fn SDL_RenderTextureRotated(
3335 renderer: *mut SDL_Renderer,
3336 texture: *mut SDL_Texture,
3337 srcrect: *const SDL_FRect,
3338 dstrect: *const SDL_FRect,
3339 angle: ::core::ffi::c_double,
3340 center: *const SDL_FPoint,
3341 flip: SDL_FlipMode,
3342 ) -> ::core::primitive::bool;
3343}
3344
3345unsafe extern "C" {
3346 /// Copy a portion of the source texture to the current rendering target, with
3347 /// affine transform, at subpixel precision.
3348 ///
3349 /// ## Parameters
3350 /// - `renderer`: the renderer which should copy parts of a texture.
3351 /// - `texture`: the source texture.
3352 /// - `srcrect`: a pointer to the source rectangle, or NULL for the entire
3353 /// texture.
3354 /// - `origin`: a pointer to a point indicating where the top-left corner of
3355 /// srcrect should be mapped to, or NULL for the rendering
3356 /// target's origin.
3357 /// - `right`: a pointer to a point indicating where the top-right corner of
3358 /// srcrect should be mapped to, or NULL for the rendering
3359 /// target's top-right corner.
3360 /// - `down`: a pointer to a point indicating where the bottom-left corner of
3361 /// srcrect should be mapped to, or NULL for the rendering target's
3362 /// bottom-left corner.
3363 ///
3364 /// ## Return value
3365 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3366 /// information.
3367 ///
3368 /// ## Thread safety
3369 /// You may only call this function from the main thread.
3370 ///
3371 /// ## Availability
3372 /// This function is available since SDL 3.2.0.
3373 ///
3374 /// ## See also
3375 /// - [`SDL_RenderTexture`]
3376 pub fn SDL_RenderTextureAffine(
3377 renderer: *mut SDL_Renderer,
3378 texture: *mut SDL_Texture,
3379 srcrect: *const SDL_FRect,
3380 origin: *const SDL_FPoint,
3381 right: *const SDL_FPoint,
3382 down: *const SDL_FPoint,
3383 ) -> ::core::primitive::bool;
3384}
3385
3386unsafe extern "C" {
3387 /// Tile a portion of the texture to the current rendering target at subpixel
3388 /// precision.
3389 ///
3390 /// The pixels in `srcrect` will be repeated as many times as needed to
3391 /// completely fill `dstrect`.
3392 ///
3393 /// ## Parameters
3394 /// - `renderer`: the renderer which should copy parts of a texture.
3395 /// - `texture`: the source texture.
3396 /// - `srcrect`: a pointer to the source rectangle, or NULL for the entire
3397 /// texture.
3398 /// - `scale`: the scale used to transform srcrect into the destination
3399 /// rectangle, e.g. a 32x32 texture with a scale of 2 would fill
3400 /// 64x64 tiles.
3401 /// - `dstrect`: a pointer to the destination rectangle, or NULL for the
3402 /// entire rendering target.
3403 ///
3404 /// ## Return value
3405 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3406 /// information.
3407 ///
3408 /// ## Thread safety
3409 /// This function should only be called on the main thread.
3410 ///
3411 /// ## Availability
3412 /// This function is available since SDL 3.2.0.
3413 ///
3414 /// ## See also
3415 /// - [`SDL_RenderTexture`]
3416 pub fn SDL_RenderTextureTiled(
3417 renderer: *mut SDL_Renderer,
3418 texture: *mut SDL_Texture,
3419 srcrect: *const SDL_FRect,
3420 scale: ::core::ffi::c_float,
3421 dstrect: *const SDL_FRect,
3422 ) -> ::core::primitive::bool;
3423}
3424
3425unsafe extern "C" {
3426 /// Perform a scaled copy using the 9-grid algorithm to the current rendering
3427 /// target at subpixel precision.
3428 ///
3429 /// The pixels in the texture are split into a 3x3 grid, using the different
3430 /// corner sizes for each corner, and the sides and center making up the
3431 /// remaining pixels. The corners are then scaled using `scale` and fit into
3432 /// the corners of the destination rectangle. The sides and center are then
3433 /// stretched into place to cover the remaining destination rectangle.
3434 ///
3435 /// ## Parameters
3436 /// - `renderer`: the renderer which should copy parts of a texture.
3437 /// - `texture`: the source texture.
3438 /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be used
3439 /// for the 9-grid, or NULL to use the entire texture.
3440 /// - `left_width`: the width, in pixels, of the left corners in `srcrect`.
3441 /// - `right_width`: the width, in pixels, of the right corners in `srcrect`.
3442 /// - `top_height`: the height, in pixels, of the top corners in `srcrect`.
3443 /// - `bottom_height`: the height, in pixels, of the bottom corners in
3444 /// `srcrect`.
3445 /// - `scale`: the scale used to transform the corner of `srcrect` into the
3446 /// corner of `dstrect`, or 0.0f for an unscaled copy.
3447 /// - `dstrect`: a pointer to the destination rectangle, or NULL for the
3448 /// entire rendering target.
3449 ///
3450 /// ## Return value
3451 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3452 /// information.
3453 ///
3454 /// ## Thread safety
3455 /// This function should only be called on the main thread.
3456 ///
3457 /// ## Availability
3458 /// This function is available since SDL 3.2.0.
3459 ///
3460 /// ## See also
3461 /// - [`SDL_RenderTexture`]
3462 /// - [`SDL_RenderTexture9GridTiled`]
3463 pub fn SDL_RenderTexture9Grid(
3464 renderer: *mut SDL_Renderer,
3465 texture: *mut SDL_Texture,
3466 srcrect: *const SDL_FRect,
3467 left_width: ::core::ffi::c_float,
3468 right_width: ::core::ffi::c_float,
3469 top_height: ::core::ffi::c_float,
3470 bottom_height: ::core::ffi::c_float,
3471 scale: ::core::ffi::c_float,
3472 dstrect: *const SDL_FRect,
3473 ) -> ::core::primitive::bool;
3474}
3475
3476unsafe extern "C" {
3477 /// Perform a scaled copy using the 9-grid algorithm to the current rendering
3478 /// target at subpixel precision.
3479 ///
3480 /// The pixels in the texture are split into a 3x3 grid, using the different
3481 /// corner sizes for each corner, and the sides and center making up the
3482 /// remaining pixels. The corners are then scaled using `scale` and fit into
3483 /// the corners of the destination rectangle. The sides and center are then
3484 /// tiled into place to cover the remaining destination rectangle.
3485 ///
3486 /// ## Parameters
3487 /// - `renderer`: the renderer which should copy parts of a texture.
3488 /// - `texture`: the source texture.
3489 /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be used
3490 /// for the 9-grid, or NULL to use the entire texture.
3491 /// - `left_width`: the width, in pixels, of the left corners in `srcrect`.
3492 /// - `right_width`: the width, in pixels, of the right corners in `srcrect`.
3493 /// - `top_height`: the height, in pixels, of the top corners in `srcrect`.
3494 /// - `bottom_height`: the height, in pixels, of the bottom corners in
3495 /// `srcrect`.
3496 /// - `scale`: the scale used to transform the corner of `srcrect` into the
3497 /// corner of `dstrect`, or 0.0f for an unscaled copy.
3498 /// - `dstrect`: a pointer to the destination rectangle, or NULL for the
3499 /// entire rendering target.
3500 /// - `tileScale`: the scale used to transform the borders and center of
3501 /// `srcrect` into the borders and middle of `dstrect`, or
3502 /// 1.0f for an unscaled copy.
3503 ///
3504 /// ## Return value
3505 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3506 /// information.
3507 ///
3508 /// ## Thread safety
3509 /// This function should only be called on the main thread.
3510 ///
3511 /// ## Availability
3512 /// This function is available since SDL 3.4.0.
3513 ///
3514 /// ## See also
3515 /// - [`SDL_RenderTexture`]
3516 /// - [`SDL_RenderTexture9Grid`]
3517 pub fn SDL_RenderTexture9GridTiled(
3518 renderer: *mut SDL_Renderer,
3519 texture: *mut SDL_Texture,
3520 srcrect: *const SDL_FRect,
3521 left_width: ::core::ffi::c_float,
3522 right_width: ::core::ffi::c_float,
3523 top_height: ::core::ffi::c_float,
3524 bottom_height: ::core::ffi::c_float,
3525 scale: ::core::ffi::c_float,
3526 dstrect: *const SDL_FRect,
3527 tileScale: ::core::ffi::c_float,
3528 ) -> ::core::primitive::bool;
3529}
3530
3531unsafe extern "C" {
3532 /// Render a list of triangles, optionally using a texture and indices into the
3533 /// vertex array Color and alpha modulation is done per vertex
3534 /// ([`SDL_SetTextureColorMod`] and [`SDL_SetTextureAlphaMod`] are ignored).
3535 ///
3536 /// ## Parameters
3537 /// - `renderer`: the rendering context.
3538 /// - `texture`: (optional) The SDL texture to use.
3539 /// - `vertices`: vertices.
3540 /// - `num_vertices`: number of vertices.
3541 /// - `indices`: (optional) An array of integer indices into the 'vertices'
3542 /// array, if NULL all vertices will be rendered in sequential
3543 /// order.
3544 /// - `num_indices`: number of indices.
3545 ///
3546 /// ## Return value
3547 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3548 /// information.
3549 ///
3550 /// ## Thread safety
3551 /// This function should only be called on the main thread.
3552 ///
3553 /// ## Availability
3554 /// This function is available since SDL 3.2.0.
3555 ///
3556 /// ## See also
3557 /// - [`SDL_RenderGeometryRaw`]
3558 /// - [`SDL_SetRenderTextureAddressMode`]
3559 pub fn SDL_RenderGeometry(
3560 renderer: *mut SDL_Renderer,
3561 texture: *mut SDL_Texture,
3562 vertices: *const SDL_Vertex,
3563 num_vertices: ::core::ffi::c_int,
3564 indices: *const ::core::ffi::c_int,
3565 num_indices: ::core::ffi::c_int,
3566 ) -> ::core::primitive::bool;
3567}
3568
3569unsafe extern "C" {
3570 /// Render a list of triangles, optionally using a texture and indices into the
3571 /// vertex arrays Color and alpha modulation is done per vertex
3572 /// ([`SDL_SetTextureColorMod`] and [`SDL_SetTextureAlphaMod`] are ignored).
3573 ///
3574 /// ## Parameters
3575 /// - `renderer`: the rendering context.
3576 /// - `texture`: (optional) The SDL texture to use.
3577 /// - `xy`: vertex positions.
3578 /// - `xy_stride`: byte size to move from one element to the next element.
3579 /// - `color`: vertex colors (as [`SDL_FColor`]).
3580 /// - `color_stride`: byte size to move from one element to the next element.
3581 /// - `uv`: vertex normalized texture coordinates.
3582 /// - `uv_stride`: byte size to move from one element to the next element.
3583 /// - `num_vertices`: number of vertices.
3584 /// - `indices`: (optional) An array of indices into the 'vertices' arrays,
3585 /// if NULL all vertices will be rendered in sequential order.
3586 /// - `num_indices`: number of indices.
3587 /// - `size_indices`: index size: 1 (byte), 2 (short), 4 (int).
3588 ///
3589 /// ## Return value
3590 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3591 /// information.
3592 ///
3593 /// ## Thread safety
3594 /// This function should only be called on the main thread.
3595 ///
3596 /// ## Availability
3597 /// This function is available since SDL 3.2.0.
3598 ///
3599 /// ## See also
3600 /// - [`SDL_RenderGeometry`]
3601 /// - [`SDL_SetRenderTextureAddressMode`]
3602 pub fn SDL_RenderGeometryRaw(
3603 renderer: *mut SDL_Renderer,
3604 texture: *mut SDL_Texture,
3605 xy: *const ::core::ffi::c_float,
3606 xy_stride: ::core::ffi::c_int,
3607 color: *const SDL_FColor,
3608 color_stride: ::core::ffi::c_int,
3609 uv: *const ::core::ffi::c_float,
3610 uv_stride: ::core::ffi::c_int,
3611 num_vertices: ::core::ffi::c_int,
3612 indices: *const ::core::ffi::c_void,
3613 num_indices: ::core::ffi::c_int,
3614 size_indices: ::core::ffi::c_int,
3615 ) -> ::core::primitive::bool;
3616}
3617
3618unsafe extern "C" {
3619 /// Set the texture addressing mode used in [`SDL_RenderGeometry()`].
3620 ///
3621 /// ## Parameters
3622 /// - `renderer`: the rendering context.
3623 /// - `u_mode`: the [`SDL_TextureAddressMode`] to use for horizontal texture
3624 /// coordinates in [`SDL_RenderGeometry()`].
3625 /// - `v_mode`: the [`SDL_TextureAddressMode`] to use for vertical texture
3626 /// coordinates in [`SDL_RenderGeometry()`].
3627 ///
3628 /// ## Return value
3629 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3630 /// information.
3631 ///
3632 /// ## Availability
3633 /// This function is available since SDL 3.4.0.
3634 ///
3635 /// ## See also
3636 /// - [`SDL_RenderGeometry`]
3637 /// - [`SDL_RenderGeometryRaw`]
3638 /// - [`SDL_GetRenderTextureAddressMode`]
3639 pub fn SDL_SetRenderTextureAddressMode(
3640 renderer: *mut SDL_Renderer,
3641 u_mode: SDL_TextureAddressMode,
3642 v_mode: SDL_TextureAddressMode,
3643 ) -> ::core::primitive::bool;
3644}
3645
3646unsafe extern "C" {
3647 /// Get the texture addressing mode used in [`SDL_RenderGeometry()`].
3648 ///
3649 /// ## Parameters
3650 /// - `renderer`: the rendering context.
3651 /// - `u_mode`: a pointer filled in with the [`SDL_TextureAddressMode`] to use
3652 /// for horizontal texture coordinates in [`SDL_RenderGeometry()`],
3653 /// may be NULL.
3654 /// - `v_mode`: a pointer filled in with the [`SDL_TextureAddressMode`] to use
3655 /// for vertical texture coordinates in [`SDL_RenderGeometry()`], may
3656 /// be NULL.
3657 ///
3658 /// ## Return value
3659 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3660 /// information.
3661 ///
3662 /// ## Availability
3663 /// This function is available since SDL 3.4.0.
3664 ///
3665 /// ## See also
3666 /// - [`SDL_SetRenderTextureAddressMode`]
3667 pub fn SDL_GetRenderTextureAddressMode(
3668 renderer: *mut SDL_Renderer,
3669 u_mode: *mut SDL_TextureAddressMode,
3670 v_mode: *mut SDL_TextureAddressMode,
3671 ) -> ::core::primitive::bool;
3672}
3673
3674unsafe extern "C" {
3675 /// Read pixels from the current rendering target.
3676 ///
3677 /// The returned surface contains pixels inside the desired area clipped to the
3678 /// current viewport, and should be freed with [`SDL_DestroySurface()`].
3679 ///
3680 /// Note that this returns the actual pixels on the screen, so if you are using
3681 /// logical presentation you should use [`SDL_GetRenderLogicalPresentationRect()`]
3682 /// to get the area containing your content.
3683 ///
3684 /// **WARNING**: This is a very slow operation, and should not be used
3685 /// frequently. If you're using this on the main rendering target, it should be
3686 /// called after rendering and before [`SDL_RenderPresent()`].
3687 ///
3688 /// ## Parameters
3689 /// - `renderer`: the rendering context.
3690 /// - `rect`: an [`SDL_Rect`] structure representing the area to read, which will
3691 /// be clipped to the current viewport, or NULL for the entire
3692 /// viewport.
3693 ///
3694 /// ## Return value
3695 /// Returns a new [`SDL_Surface`] on success or NULL on failure; call
3696 /// [`SDL_GetError()`] for more information.
3697 ///
3698 /// ## Thread safety
3699 /// This function should only be called on the main thread.
3700 ///
3701 /// ## Availability
3702 /// This function is available since SDL 3.2.0.
3703 pub fn SDL_RenderReadPixels(
3704 renderer: *mut SDL_Renderer,
3705 rect: *const SDL_Rect,
3706 ) -> *mut SDL_Surface;
3707}
3708
3709unsafe extern "C" {
3710 /// Update the screen with any rendering performed since the previous call.
3711 ///
3712 /// SDL's rendering functions operate on a backbuffer; that is, calling a
3713 /// rendering function such as [`SDL_RenderLine()`] does not directly put a line on
3714 /// the screen, but rather updates the backbuffer. As such, you compose your
3715 /// entire scene and *present* the composed backbuffer to the screen as a
3716 /// complete picture.
3717 ///
3718 /// Therefore, when using SDL's rendering API, one does all drawing intended
3719 /// for the frame, and then calls this function once per frame to present the
3720 /// final drawing to the user.
3721 ///
3722 /// The backbuffer should be considered invalidated after each present; do not
3723 /// assume that previous contents will exist between frames. You are strongly
3724 /// encouraged to call [`SDL_RenderClear()`] to initialize the backbuffer before
3725 /// starting each new frame's drawing, even if you plan to overwrite every
3726 /// pixel.
3727 ///
3728 /// Please note, that in case of rendering to a texture - there is **no need**
3729 /// to call [`SDL_RenderPresent`] after drawing needed objects to a texture, and
3730 /// should not be done; you are only required to change back the rendering
3731 /// target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
3732 /// textures by themselves do not have a concept of backbuffers. Calling
3733 /// [`SDL_RenderPresent`] while rendering to a texture will fail.
3734 ///
3735 /// ## Parameters
3736 /// - `renderer`: the rendering context.
3737 ///
3738 /// ## Return value
3739 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3740 /// information.
3741 ///
3742 /// ## Thread safety
3743 /// This function should only be called on the main thread.
3744 ///
3745 /// ## Availability
3746 /// This function is available since SDL 3.2.0.
3747 ///
3748 /// ## See also
3749 /// - [`SDL_CreateRenderer`]
3750 /// - [`SDL_RenderClear`]
3751 /// - [`SDL_RenderFillRect`]
3752 /// - [`SDL_RenderFillRects`]
3753 /// - [`SDL_RenderLine`]
3754 /// - [`SDL_RenderLines`]
3755 /// - [`SDL_RenderPoint`]
3756 /// - [`SDL_RenderPoints`]
3757 /// - [`SDL_RenderRect`]
3758 /// - [`SDL_RenderRects`]
3759 /// - [`SDL_SetRenderDrawBlendMode`]
3760 /// - [`SDL_SetRenderDrawColor`]
3761 pub fn SDL_RenderPresent(renderer: *mut SDL_Renderer) -> ::core::primitive::bool;
3762}
3763
3764unsafe extern "C" {
3765 /// Destroy the specified texture.
3766 ///
3767 /// Passing NULL or an otherwise invalid texture will set the SDL error message
3768 /// to "Invalid texture".
3769 ///
3770 /// ## Parameters
3771 /// - `texture`: the texture to destroy.
3772 ///
3773 /// ## Thread safety
3774 /// This function should only be called on the main thread.
3775 ///
3776 /// ## Availability
3777 /// This function is available since SDL 3.2.0.
3778 ///
3779 /// ## See also
3780 /// - [`SDL_CreateTexture`]
3781 /// - [`SDL_CreateTextureFromSurface`]
3782 pub fn SDL_DestroyTexture(texture: *mut SDL_Texture);
3783}
3784
3785unsafe extern "C" {
3786 /// Destroy the rendering context for a window and free all associated
3787 /// textures.
3788 ///
3789 /// This should be called before destroying the associated window.
3790 ///
3791 /// ## Parameters
3792 /// - `renderer`: the rendering context.
3793 ///
3794 /// ## Thread safety
3795 /// This function should only be called on the main thread.
3796 ///
3797 /// ## Availability
3798 /// This function is available since SDL 3.2.0.
3799 ///
3800 /// ## See also
3801 /// - [`SDL_CreateRenderer`]
3802 pub fn SDL_DestroyRenderer(renderer: *mut SDL_Renderer);
3803}
3804
3805unsafe extern "C" {
3806 /// Force the rendering context to flush any pending commands and state.
3807 ///
3808 /// You do not need to (and in fact, shouldn't) call this function unless you
3809 /// are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
3810 /// addition to using an [`SDL_Renderer`].
3811 ///
3812 /// This is for a very-specific case: if you are using SDL's render API, and
3813 /// you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
3814 /// calls. If this applies, you should call this function between calls to
3815 /// SDL's render API and the low-level API you're using in cooperation.
3816 ///
3817 /// In all other cases, you can ignore this function.
3818 ///
3819 /// This call makes SDL flush any pending rendering work it was queueing up to
3820 /// do later in a single batch, and marks any internal cached state as invalid,
3821 /// so it'll prepare all its state again later, from scratch.
3822 ///
3823 /// This means you do not need to save state in your rendering code to protect
3824 /// the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
3825 /// OpenGL state that can confuse things; you should use your best judgment and
3826 /// be prepared to make changes if specific state needs to be protected.
3827 ///
3828 /// ## Parameters
3829 /// - `renderer`: the rendering context.
3830 ///
3831 /// ## Return value
3832 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3833 /// information.
3834 ///
3835 /// ## Thread safety
3836 /// This function should only be called on the main thread.
3837 ///
3838 /// ## Availability
3839 /// This function is available since SDL 3.2.0.
3840 pub fn SDL_FlushRenderer(renderer: *mut SDL_Renderer) -> ::core::primitive::bool;
3841}
3842
3843unsafe extern "C" {
3844 /// Get the CAMetalLayer associated with the given Metal renderer.
3845 ///
3846 /// This function returns `void *`, so SDL doesn't have to include Metal's
3847 /// headers, but it can be safely cast to a `CAMetalLayer *`.
3848 ///
3849 /// ## Parameters
3850 /// - `renderer`: the renderer to query.
3851 ///
3852 /// ## Return value
3853 /// Returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
3854 /// Metal renderer.
3855 ///
3856 /// ## Thread safety
3857 /// This function should only be called on the main thread.
3858 ///
3859 /// ## Availability
3860 /// This function is available since SDL 3.2.0.
3861 ///
3862 /// ## See also
3863 /// - [`SDL_GetRenderMetalCommandEncoder`]
3864 pub fn SDL_GetRenderMetalLayer(renderer: *mut SDL_Renderer) -> *mut ::core::ffi::c_void;
3865}
3866
3867unsafe extern "C" {
3868 /// Get the Metal command encoder for the current frame.
3869 ///
3870 /// This function returns `void *`, so SDL doesn't have to include Metal's
3871 /// headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
3872 ///
3873 /// This will return NULL if Metal refuses to give SDL a drawable to render to,
3874 /// which might happen if the window is hidden/minimized/offscreen. This
3875 /// doesn't apply to command encoders for render targets, just the window's
3876 /// backbuffer. Check your return values!
3877 ///
3878 /// ## Parameters
3879 /// - `renderer`: the renderer to query.
3880 ///
3881 /// ## Return value
3882 /// Returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
3883 /// renderer isn't a Metal renderer or there was an error.
3884 ///
3885 /// ## Thread safety
3886 /// This function should only be called on the main thread.
3887 ///
3888 /// ## Availability
3889 /// This function is available since SDL 3.2.0.
3890 ///
3891 /// ## See also
3892 /// - [`SDL_GetRenderMetalLayer`]
3893 pub fn SDL_GetRenderMetalCommandEncoder(
3894 renderer: *mut SDL_Renderer,
3895 ) -> *mut ::core::ffi::c_void;
3896}
3897
3898unsafe extern "C" {
3899 /// Add a set of synchronization semaphores for the current frame.
3900 ///
3901 /// The Vulkan renderer will wait for `wait_semaphore` before submitting
3902 /// rendering commands and signal `signal_semaphore` after rendering commands
3903 /// are complete for this frame.
3904 ///
3905 /// This should be called each frame that you want semaphore synchronization.
3906 /// The Vulkan renderer may have multiple frames in flight on the GPU, so you
3907 /// should have multiple semaphores that are used for synchronization. Querying
3908 /// [`SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`] will give you the
3909 /// maximum number of semaphores you'll need.
3910 ///
3911 /// ## Parameters
3912 /// - `renderer`: the rendering context.
3913 /// - `wait_stage_mask`: the VkPipelineStageFlags for the wait.
3914 /// - `wait_semaphore`: a VkSempahore to wait on before rendering the current
3915 /// frame, or 0 if not needed.
3916 /// - `signal_semaphore`: a VkSempahore that SDL will signal when rendering
3917 /// for the current frame is complete, or 0 if not
3918 /// needed.
3919 ///
3920 /// ## Return value
3921 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3922 /// information.
3923 ///
3924 /// ## Thread safety
3925 /// It is **NOT** safe to call this function from two threads at
3926 /// once.
3927 ///
3928 /// ## Availability
3929 /// This function is available since SDL 3.2.0.
3930 pub fn SDL_AddVulkanRenderSemaphores(
3931 renderer: *mut SDL_Renderer,
3932 wait_stage_mask: Uint32,
3933 wait_semaphore: Sint64,
3934 signal_semaphore: Sint64,
3935 ) -> ::core::primitive::bool;
3936}
3937
3938unsafe extern "C" {
3939 /// Toggle VSync of the given renderer.
3940 ///
3941 /// When a renderer is created, vsync defaults to [`SDL_RENDERER_VSYNC_DISABLED`].
3942 ///
3943 /// The `vsync` parameter can be 1 to synchronize present with every vertical
3944 /// refresh, 2 to synchronize present with every second vertical refresh, etc.,
3945 /// [`SDL_RENDERER_VSYNC_ADAPTIVE`] for late swap tearing (adaptive vsync), or
3946 /// [`SDL_RENDERER_VSYNC_DISABLED`] to disable. Not every value is supported by
3947 /// every driver, so you should check the return value to see whether the
3948 /// requested setting is supported.
3949 ///
3950 /// ## Parameters
3951 /// - `renderer`: the renderer to toggle.
3952 /// - `vsync`: the vertical refresh sync interval.
3953 ///
3954 /// ## Return value
3955 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3956 /// information.
3957 ///
3958 /// ## Thread safety
3959 /// This function should only be called on the main thread.
3960 ///
3961 /// ## Availability
3962 /// This function is available since SDL 3.2.0.
3963 ///
3964 /// ## See also
3965 /// - [`SDL_GetRenderVSync`]
3966 pub fn SDL_SetRenderVSync(
3967 renderer: *mut SDL_Renderer,
3968 vsync: ::core::ffi::c_int,
3969 ) -> ::core::primitive::bool;
3970}
3971
3972pub const SDL_RENDERER_VSYNC_DISABLED: ::core::ffi::c_int = (0 as ::core::ffi::c_int);
3973
3974pub const SDL_RENDERER_VSYNC_ADAPTIVE: ::core::ffi::c_int = (-1_i32 as ::core::ffi::c_int);
3975
3976unsafe extern "C" {
3977 /// Get VSync of the given renderer.
3978 ///
3979 /// ## Parameters
3980 /// - `renderer`: the renderer to toggle.
3981 /// - `vsync`: an int filled with the current vertical refresh sync interval.
3982 /// See [`SDL_SetRenderVSync()`] for the meaning of the value.
3983 ///
3984 /// ## Return value
3985 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3986 /// information.
3987 ///
3988 /// ## Thread safety
3989 /// This function should only be called on the main thread.
3990 ///
3991 /// ## Availability
3992 /// This function is available since SDL 3.2.0.
3993 ///
3994 /// ## See also
3995 /// - [`SDL_SetRenderVSync`]
3996 pub fn SDL_GetRenderVSync(
3997 renderer: *mut SDL_Renderer,
3998 vsync: *mut ::core::ffi::c_int,
3999 ) -> ::core::primitive::bool;
4000}
4001
4002/// The size, in pixels, of a single [`SDL_RenderDebugText()`] character.
4003///
4004/// The font is monospaced and square, so this applies to all characters.
4005///
4006/// ## Availability
4007/// This macro is available since SDL 3.2.0.
4008///
4009/// ## See also
4010/// - [`SDL_RenderDebugText`]
4011pub const SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE: ::core::primitive::i32 = 8;
4012
4013unsafe extern "C" {
4014 /// Draw debug text to an [`SDL_Renderer`].
4015 ///
4016 /// This function will render a string of text to an [`SDL_Renderer`]. Note that
4017 /// this is a convenience function for debugging, with severe limitations, and
4018 /// not intended to be used for production apps and games.
4019 ///
4020 /// Among these limitations:
4021 ///
4022 /// - It accepts UTF-8 strings, but will only renders ASCII characters.
4023 /// - It has a single, tiny size (8x8 pixels). You can use logical presentation
4024 /// or [`SDL_SetRenderScale()`] to adjust it.
4025 /// - It uses a simple, hardcoded bitmap font. It does not allow different font
4026 /// selections and it does not support truetype, for proper scaling.
4027 /// - It does no word-wrapping and does not treat newline characters as a line
4028 /// break. If the text goes out of the window, it's gone.
4029 ///
4030 /// For serious text rendering, there are several good options, such as
4031 /// SDL_ttf, stb_truetype, or other external libraries.
4032 ///
4033 /// On first use, this will create an internal texture for rendering glyphs.
4034 /// This texture will live until the renderer is destroyed.
4035 ///
4036 /// The text is drawn in the color specified by [`SDL_SetRenderDrawColor()`].
4037 ///
4038 /// ## Parameters
4039 /// - `renderer`: the renderer which should draw a line of text.
4040 /// - `x`: the x coordinate where the top-left corner of the text will draw.
4041 /// - `y`: the y coordinate where the top-left corner of the text will draw.
4042 /// - `str`: the string to render.
4043 ///
4044 /// ## Return value
4045 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4046 /// information.
4047 ///
4048 /// ## Thread safety
4049 /// This function should only be called on the main thread.
4050 ///
4051 /// ## Availability
4052 /// This function is available since SDL 3.2.0.
4053 ///
4054 /// ## See also
4055 /// - [`SDL_RenderDebugTextFormat`]
4056 /// - [`SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE`]
4057 pub fn SDL_RenderDebugText(
4058 renderer: *mut SDL_Renderer,
4059 x: ::core::ffi::c_float,
4060 y: ::core::ffi::c_float,
4061 str: *const ::core::ffi::c_char,
4062 ) -> ::core::primitive::bool;
4063}
4064
4065unsafe extern "C" {
4066 /// Draw debug text to an [`SDL_Renderer`].
4067 ///
4068 /// This function will render a printf()-style format string to a renderer.
4069 /// Note that this is a convenience function for debugging, with severe
4070 /// limitations, and is not intended to be used for production apps and games.
4071 ///
4072 /// For the full list of limitations and other useful information, see
4073 /// [`SDL_RenderDebugText`].
4074 ///
4075 /// ## Parameters
4076 /// - `renderer`: the renderer which should draw the text.
4077 /// - `x`: the x coordinate where the top-left corner of the text will draw.
4078 /// - `y`: the y coordinate where the top-left corner of the text will draw.
4079 /// - `fmt`: the format string to draw.
4080 /// - `...`: additional parameters matching % tokens in the `fmt` string, if
4081 /// any.
4082 ///
4083 /// ## Return value
4084 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4085 /// information.
4086 ///
4087 /// ## Thread safety
4088 /// This function should only be called on the main thread.
4089 ///
4090 /// ## Availability
4091 /// This function is available since SDL 3.2.0.
4092 ///
4093 /// ## See also
4094 /// - [`SDL_RenderDebugText`]
4095 /// - [`SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE`]
4096 pub fn SDL_RenderDebugTextFormat(
4097 renderer: *mut SDL_Renderer,
4098 x: ::core::ffi::c_float,
4099 y: ::core::ffi::c_float,
4100 fmt: *const ::core::ffi::c_char,
4101 ...
4102 ) -> ::core::primitive::bool;
4103}
4104
4105unsafe extern "C" {
4106 /// Set default scale mode for new textures for given renderer.
4107 ///
4108 /// When a renderer is created, scale_mode defaults to [`SDL_SCALEMODE_LINEAR`].
4109 ///
4110 /// ## Parameters
4111 /// - `renderer`: the renderer to update.
4112 /// - `scale_mode`: the scale mode to change to for new textures.
4113 ///
4114 /// ## Return value
4115 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4116 /// information.
4117 ///
4118 /// ## Thread safety
4119 /// This function should only be called on the main thread.
4120 ///
4121 /// ## Availability
4122 /// This function is available since SDL 3.4.0.
4123 ///
4124 /// ## See also
4125 /// - [`SDL_GetDefaultTextureScaleMode`]
4126 pub fn SDL_SetDefaultTextureScaleMode(
4127 renderer: *mut SDL_Renderer,
4128 scale_mode: SDL_ScaleMode,
4129 ) -> ::core::primitive::bool;
4130}
4131
4132unsafe extern "C" {
4133 /// Get default texture scale mode of the given renderer.
4134 ///
4135 /// ## Parameters
4136 /// - `renderer`: the renderer to get data from.
4137 /// - `scale_mode`: a [`SDL_ScaleMode`] filled with current default scale mode.
4138 /// See [`SDL_SetDefaultTextureScaleMode()`] for the meaning of
4139 /// the value.
4140 ///
4141 /// ## Return value
4142 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4143 /// information.
4144 ///
4145 /// ## Thread safety
4146 /// This function should only be called on the main thread.
4147 ///
4148 /// ## Availability
4149 /// This function is available since SDL 3.4.0.
4150 ///
4151 /// ## See also
4152 /// - [`SDL_SetDefaultTextureScaleMode`]
4153 pub fn SDL_GetDefaultTextureScaleMode(
4154 renderer: *mut SDL_Renderer,
4155 scale_mode: *mut SDL_ScaleMode,
4156 ) -> ::core::primitive::bool;
4157}
4158
4159/// A structure specifying the parameters of a GPU render state.
4160///
4161/// ## Availability
4162/// This struct is available since SDL 3.4.0.
4163///
4164/// ## See also
4165/// - [`SDL_CreateGPURenderState`]
4166#[repr(C)]
4167#[cfg_attr(feature = "debug-impls", derive(Debug))]
4168pub struct SDL_GPURenderStateCreateInfo {
4169 /// The fragment shader to use when this render state is active
4170 pub fragment_shader: *mut SDL_GPUShader,
4171 /// The number of additional fragment samplers to bind when this render state is active
4172 pub num_sampler_bindings: Sint32,
4173 /// Additional fragment samplers to bind when this render state is active
4174 pub sampler_bindings: *const SDL_GPUTextureSamplerBinding,
4175 /// The number of storage textures to bind when this render state is active
4176 pub num_storage_textures: Sint32,
4177 /// Storage textures to bind when this render state is active
4178 pub storage_textures: *const *mut SDL_GPUTexture,
4179 /// The number of storage buffers to bind when this render state is active
4180 pub num_storage_buffers: Sint32,
4181 /// Storage buffers to bind when this render state is active
4182 pub storage_buffers: *const *mut SDL_GPUBuffer,
4183 /// A properties ID for extensions. Should be 0 if no extensions are needed.
4184 pub props: SDL_PropertiesID,
4185}
4186
4187impl ::core::default::Default for SDL_GPURenderStateCreateInfo {
4188 /// Initialize all fields to zero
4189 #[inline(always)]
4190 fn default() -> Self {
4191 unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
4192 }
4193}
4194
4195unsafe extern "C" {
4196 /// Create custom GPU render state.
4197 ///
4198 /// ## Parameters
4199 /// - `renderer`: the renderer to use.
4200 /// - `createinfo`: a struct describing the GPU render state to create.
4201 ///
4202 /// ## Return value
4203 /// Returns a custom GPU render state or NULL on failure; call [`SDL_GetError()`]
4204 /// for more information.
4205 ///
4206 /// ## Thread safety
4207 /// This function should be called on the thread that created the
4208 /// renderer.
4209 ///
4210 /// ## Availability
4211 /// This function is available since SDL 3.4.0.
4212 ///
4213 /// ## See also
4214 /// - [`SDL_SetGPURenderStateFragmentUniforms`]
4215 /// - [`SDL_SetGPURenderState`]
4216 /// - [`SDL_DestroyGPURenderState`]
4217 pub fn SDL_CreateGPURenderState(
4218 renderer: *mut SDL_Renderer,
4219 createinfo: *mut SDL_GPURenderStateCreateInfo,
4220 ) -> *mut SDL_GPURenderState;
4221}
4222
4223unsafe extern "C" {
4224 /// Set fragment shader uniform variables in a custom GPU render state.
4225 ///
4226 /// The data is copied and will be pushed using
4227 /// [`SDL_PushGPUFragmentUniformData()`] during draw call execution.
4228 ///
4229 /// ## Parameters
4230 /// - `state`: the state to modify.
4231 /// - `slot_index`: the fragment uniform slot to push data to.
4232 /// - `data`: client data to write.
4233 /// - `length`: the length of the data to write.
4234 ///
4235 /// ## Return value
4236 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4237 /// information.
4238 ///
4239 /// ## Thread safety
4240 /// This function should be called on the thread that created the
4241 /// renderer.
4242 ///
4243 /// ## Availability
4244 /// This function is available since SDL 3.4.0.
4245 pub fn SDL_SetGPURenderStateFragmentUniforms(
4246 state: *mut SDL_GPURenderState,
4247 slot_index: Uint32,
4248 data: *const ::core::ffi::c_void,
4249 length: Uint32,
4250 ) -> ::core::primitive::bool;
4251}
4252
4253unsafe extern "C" {
4254 /// Set custom GPU render state.
4255 ///
4256 /// This function sets custom GPU render state for subsequent draw calls. This
4257 /// allows using custom shaders with the GPU renderer.
4258 ///
4259 /// ## Parameters
4260 /// - `renderer`: the renderer to use.
4261 /// - `state`: the state to to use, or NULL to clear custom GPU render state.
4262 ///
4263 /// ## Return value
4264 /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4265 /// information.
4266 ///
4267 /// ## Thread safety
4268 /// This function should be called on the thread that created the
4269 /// renderer.
4270 ///
4271 /// ## Availability
4272 /// This function is available since SDL 3.4.0.
4273 pub fn SDL_SetGPURenderState(
4274 renderer: *mut SDL_Renderer,
4275 state: *mut SDL_GPURenderState,
4276 ) -> ::core::primitive::bool;
4277}
4278
4279unsafe extern "C" {
4280 /// Destroy custom GPU render state.
4281 ///
4282 /// ## Parameters
4283 /// - `state`: the state to destroy.
4284 ///
4285 /// ## Thread safety
4286 /// This function should be called on the thread that created the
4287 /// renderer.
4288 ///
4289 /// ## Availability
4290 /// This function is available since SDL 3.4.0.
4291 ///
4292 /// ## See also
4293 /// - [`SDL_CreateGPURenderState`]
4294 pub fn SDL_DestroyGPURenderState(state: *mut SDL_GPURenderState);
4295}
4296
4297/// A custom GPU render state.
4298///
4299/// ## Availability
4300/// This struct is available since SDL 3.4.0.
4301///
4302/// ## See also
4303/// - [`SDL_CreateGPURenderState`]
4304/// - [`SDL_SetGPURenderStateFragmentUniforms`]
4305/// - [`SDL_SetGPURenderState`]
4306/// - [`SDL_DestroyGPURenderState`]
4307#[repr(C)]
4308pub struct SDL_GPURenderState {
4309 _opaque: [::core::primitive::u8; 0],
4310}
4311
4312/// A structure representing rendering state
4313///
4314/// ## Availability
4315/// This struct is available since SDL 3.2.0.
4316#[repr(C)]
4317pub struct SDL_Renderer {
4318 _opaque: [::core::primitive::u8; 0],
4319}
4320
4321#[cfg(doc)]
4322use crate::everything::*;