//
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi
{
public static unsafe partial class Sdl
{
public static unsafe partial class Render
{
///
/// Get the number of 2D rendering drivers available for the current display.
///
/// the number of built in render drivers.
///
///
/// A render driver is a set of code that handles rendering and texture
/// management on a particular display. Normally there is only one, but some
/// drivers may have several available with different capabilities.
///
///
/// There may be none if SDL was compiled without render support.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static int GetNumRenderDrivers() => PInvoke.GetNumRenderDrivers();
///
/// Use this function to get the name of a built in 2D rendering driver.
///
///
/// the index of the rendering driver; the value ranges from 0 to
/// SDL_GetNumRenderDrivers() - 1.
///
///
/// the name of the rendering driver at the requested index, or NULL
/// if an invalid index was specified.
///
///
///
/// The list of rendering drivers is given in the order that they are normally
/// initialized by default; the drivers that seem more reasonable to choose
/// first (as far as the SDL developers believe) are earlier in the list.
///
///
/// The names of drivers are all simple, low-ASCII identifiers, like "opengl",
/// "direct3d12" or "metal". These never have Unicode characters, and are not
/// meant to be proper names.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetRenderDriver(int index) => PInvoke.GetRenderDriver(index);
///
/// Create a window and default renderer.
///
/// the title of the window, in UTF-8 encoding.
/// the width of the window.
/// the height of the window.
///
/// the flags used to create the window (see
/// SDL_CreateWindow()).
///
/// a pointer filled with the window, or NULL on error.
/// a pointer filled with the renderer, or NULL on error.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool CreateWindowAndRenderer(
string title,
int width,
int height,
SdlWindowFlags window_flags,
SdlWindow* window,
SdlRenderer* renderer
) => PInvoke.CreateWindowAndRenderer(title, width, height, window_flags, window, renderer) != 0;
///
/// Ergonomic wrapper over SDL_CreateRenderer. Throws instead of returning a null handle on
/// failure.
///
/// the window where rendering is displayed.
///
/// the name of the rendering driver to initialize, or NULL to let
/// SDL choose one.
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlRenderer CreateRenderer(SdlWindow window, string name)
{
SdlRenderer result = PInvoke.CreateRenderer(window, name);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateRenderer failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_CreateRendererWithProperties. Throws instead of returning a null
/// handle on failure.
///
/// the properties to use.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlRenderer CreateRendererWithProperties(uint props)
{
SdlRenderer result = PInvoke.CreateRendererWithProperties(props);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateRendererWithProperties failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_CreateGPURenderer. Throws instead of returning a null handle on
/// failure.
///
///
/// the GPU device to use with the renderer, or NULL to create a
/// device.
///
///
/// the window where rendering is displayed, or NULL to create an
/// offscreen renderer.
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlRenderer CreateGpuRenderer(SdlGpuDevice device, SdlWindow window)
{
SdlRenderer result = PInvoke.CreateGpuRenderer(device, window);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateGPURenderer failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_GetGPURendererDevice.
///
/// the rendering context.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlGpuDevice GetGpuRendererDevice(SdlRenderer renderer) =>
PInvoke.GetGpuRendererDevice(renderer);
///
/// Ergonomic wrapper over SDL_CreateSoftwareRenderer. Throws instead of returning a null handle on
/// failure.
///
///
/// the SDL_Surface structure representing the surface where
/// rendering is done.
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlRenderer CreateSoftwareRenderer(SdlSurface* surface)
{
SdlRenderer result = PInvoke.CreateSoftwareRenderer(surface);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateSoftwareRenderer failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_GetRenderer.
///
/// the window to query.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlRenderer GetRenderer(SdlWindow window) => PInvoke.GetRenderer(window);
///
/// Ergonomic wrapper over SDL_GetRenderWindow.
///
/// the renderer to query.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlWindow GetRenderWindow(SdlRenderer renderer) => PInvoke.GetRenderWindow(renderer);
///
/// Get the name of a renderer.
///
/// the rendering context.
///
/// the name of the selected renderer, or NULL on failure; call
/// SDL_GetError() for more information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static string? GetRendererName(SdlRenderer renderer) => PInvoke.GetRendererName(renderer);
///
/// Get the properties associated with a renderer.
///
/// the rendering context.
///
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
///
///
///
/// The following read-only properties are provided by SDL:
///
///
/// - SDL_PROP_RENDERER_NAME_STRING: the name of the rendering driver
/// - SDL_PROP_RENDERER_WINDOW_POINTER: the window where rendering is
/// displayed, if any
/// - SDL_PROP_RENDERER_SURFACE_POINTER: the surface where rendering is
/// displayed, if this is a software renderer without a window
/// - SDL_PROP_RENDERER_VSYNC_NUMBER: the current vsync setting
/// - SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER: the maximum texture width
/// and height
/// - SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER: a (const SDL_PixelFormat *)
/// array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
/// representing the available texture formats for this renderer.
/// - SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN: true if the renderer
/// supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures.
/// - SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER: an SDL_Colorspace value
/// describing the colorspace for output to the display, defaults to
/// SDL_COLORSPACE_SRGB.
/// - SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN: true if the output colorspace is
/// SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with
/// HDR enabled. This property can change dynamically when
/// SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
/// - SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT: the value of SDR white in the
/// SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is
/// automatically multiplied into the color scale. This property can change
/// dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
/// - SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT: the additional high dynamic range
/// that can be displayed, in terms of the SDR white point. When HDR is not
/// enabled, this will be 1.0. This property can change dynamically when
/// SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
///
///
/// With the direct3d renderer:
///
///
/// - SDL_PROP_RENDERER_D3D9_DEVICE_POINTER: the IDirect3DDevice9 associated
/// with the renderer
///
///
/// With the direct3d11 renderer:
///
///
/// - SDL_PROP_RENDERER_D3D11_DEVICE_POINTER: the ID3D11Device associated
/// with the renderer
/// - SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER: the IDXGISwapChain1
/// associated with the renderer. This may change when the window is resized.
///
///
/// With the direct3d12 renderer:
///
///
/// - SDL_PROP_RENDERER_D3D12_DEVICE_POINTER: the ID3D12Device associated
/// with the renderer
/// - SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER: the IDXGISwapChain4
/// associated with the renderer.
/// - SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER: the ID3D12CommandQueue
/// associated with the renderer
///
///
/// With the vulkan renderer:
///
///
/// - SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER: the VkInstance associated
/// with the renderer
/// - SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER: the VkSurfaceKHR associated
/// with the renderer
/// - SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER: the VkPhysicalDevice
/// associated with the renderer
/// - SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER: the VkDevice associated with
/// the renderer
/// - SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER: the queue
/// family index used for rendering
/// - SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER: the queue
/// family index used for presentation
/// - SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER: the number of
/// swapchain images, or potential frames in flight, used by the Vulkan
/// renderer
///
///
/// With the gpu renderer:
///
///
/// - SDL_PROP_RENDERER_GPU_DEVICE_POINTER: the SDL_GPUDevice associated with
/// the renderer
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static uint GetRendererProperties(SdlRenderer renderer) => PInvoke.GetRendererProperties(renderer);
///
/// Get the output size in pixels of a rendering context.
///
/// the rendering context.
/// a pointer filled in with the width in pixels.
/// a pointer filled in with the height in pixels.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This returns the true output size in pixels, ignoring any render targets or
/// logical size and presentation.
///
///
/// For the output size of the current rendering target, with logical size
/// adjustments, use SDL_GetCurrentRenderOutputSize() instead.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderOutputSize(SdlRenderer renderer, out int w, out int h)
{
w = default;
h = default;
fixed (int* wPtr = &w)
{
fixed (int* hPtr = &h)
{
return PInvoke.GetRenderOutputSize(renderer, wPtr, hPtr) != 0;
}
}
}
///
/// Get the current output size in pixels of a rendering context.
///
/// the rendering context.
/// a pointer filled in with the current width.
/// a pointer filled in with the current height.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// If a rendering target is active, this will return the size of the rendering
/// target in pixels, otherwise return the value of SDL_GetRenderOutputSize().
///
///
/// Rendering target or not, the output will be adjusted by the current logical
/// presentation state, dictated by SDL_SetRenderLogicalPresentation().
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetCurrentRenderOutputSize(SdlRenderer renderer, out int w, out int h)
{
w = default;
h = default;
fixed (int* wPtr = &w)
{
fixed (int* hPtr = &h)
{
return PInvoke.GetCurrentRenderOutputSize(renderer, wPtr, hPtr) != 0;
}
}
}
///
/// Ergonomic wrapper over SDL_CreateTexture. Throws instead of returning a null handle on failure.
///
/// the rendering context.
/// one of the enumerated values in SDL_PixelFormat.
/// one of the enumerated values in SDL_TextureAccess.
/// the width of the texture in pixels.
/// the height of the texture in pixels.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlTexture CreateTexture(
SdlRenderer renderer,
SdlPixelFormat format,
SdlTextureAccess access,
int w,
int h
)
{
SdlTexture result = PInvoke.CreateTexture(renderer, format, access, w, h);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateTexture failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_CreateTextureFromSurface. Throws instead of returning a null handle
/// on failure.
///
/// the rendering context.
///
/// the SDL_Surface structure containing pixel data used to fill
/// the texture.
///
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlTexture CreateTextureFromSurface(SdlRenderer renderer, SdlSurface* surface)
{
SdlTexture result = PInvoke.CreateTextureFromSurface(renderer, surface);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateTextureFromSurface failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_CreateTextureWithProperties. Throws instead of returning a null
/// handle on failure.
///
/// the rendering context.
/// the properties to use.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlTexture CreateTextureWithProperties(SdlRenderer renderer, uint props)
{
SdlTexture result = PInvoke.CreateTextureWithProperties(renderer, props);
if (result.IsNull())
{
throw SdlException.FromError("SDL_CreateTextureWithProperties failed");
}
return result;
}
///
/// Get the properties associated with a texture.
///
/// the texture to query.
///
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
///
///
///
/// The following read-only properties are provided by SDL:
///
///
/// - SDL_PROP_TEXTURE_COLORSPACE_NUMBER: an SDL_Colorspace value describing
/// the texture colorspace.
/// - SDL_PROP_TEXTURE_FORMAT_NUMBER: one of the enumerated values in
/// SDL_PixelFormat.
/// - SDL_PROP_TEXTURE_ACCESS_NUMBER: one of the enumerated values in
/// SDL_TextureAccess.
/// - SDL_PROP_TEXTURE_WIDTH_NUMBER: the width of the texture in pixels.
/// - SDL_PROP_TEXTURE_HEIGHT_NUMBER: the height of the texture in pixels.
/// - SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT: for HDR10 and floating point
/// textures, this defines the value of 100% diffuse white, with higher
/// values being displayed in the High Dynamic Range headroom. This defaults
/// to 100 for HDR10 textures and 1.0 for other textures.
/// - SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT: for HDR10 and floating point
/// textures, this defines the maximum dynamic range used by the content, in
/// terms of the SDR white point. If this is defined, any values outside the
/// range supported by the display will be scaled into the available HDR
/// headroom, otherwise they are clipped. This defaults to 1.0 for SDR
/// textures, 4.0 for HDR10 textures, and no default for floating point
/// textures.
///
///
/// With the direct3d11 renderer:
///
///
/// - SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER: the ID3D11Texture2D associated
/// with the texture
/// - SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER: the ID3D11Texture2D
/// associated with the U plane of a YUV texture
/// - SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER: the ID3D11Texture2D
/// associated with the V plane of a YUV texture
///
///
/// With the direct3d12 renderer:
///
///
/// - SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER: the ID3D12Resource associated
/// with the texture
/// - SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER: the ID3D12Resource associated
/// with the U plane of a YUV texture
/// - SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER: the ID3D12Resource associated
/// with the V plane of a YUV texture
///
///
/// With the vulkan renderer:
///
///
/// - SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER: the VkImage associated with the
/// texture
///
///
/// With the opengl renderer:
///
///
/// - SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER: the GLuint texture associated
/// with the texture
/// - SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER: the GLuint texture
/// associated with the UV plane of an NV12 texture
/// - SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER: the GLuint texture associated
/// with the U plane of a YUV texture
/// - SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER: the GLuint texture associated
/// with the V plane of a YUV texture
/// - SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER: the GLenum for the
/// texture target (GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, etc)
/// - SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT: the texture coordinate width of
/// the texture (0.0 - 1.0)
/// - SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT: the texture coordinate height of
/// the texture (0.0 - 1.0)
///
///
/// With the opengles2 renderer:
///
///
/// - SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER: the GLuint texture
/// associated with the texture
/// - SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER: the GLuint texture
/// associated with the UV plane of an NV12 texture
/// - SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER: the GLuint texture
/// associated with the U plane of a YUV texture
/// - SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER: the GLuint texture
/// associated with the V plane of a YUV texture
/// - SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER: the GLenum for the
/// texture target (GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES, etc)
///
///
/// With the gpu renderer:
///
///
/// - SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER: the SDL_GPUTexture associated
/// with the texture
/// - SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER: the SDL_GPUTexture associated
/// with the UV plane of an NV12 texture
/// - SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER: the SDL_GPUTexture associated
/// with the U plane of a YUV texture
/// - SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER: the SDL_GPUTexture associated
/// with the V plane of a YUV texture
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static uint GetTextureProperties(SdlTexture texture) => PInvoke.GetTextureProperties(texture);
///
/// Ergonomic wrapper over SDL_GetRendererFromTexture.
///
/// the texture to query.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlRenderer GetRendererFromTexture(SdlTexture texture) =>
PInvoke.GetRendererFromTexture(texture);
///
/// Get the size of a texture, as floating point values.
///
/// the texture to query.
///
/// a pointer filled in with the width of the texture in pixels. This
/// argument can be NULL if you don't need this information.
///
///
/// a pointer filled in with the height of the texture in pixels. This
/// argument can be NULL if you don't need this information.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool GetTextureSize(SdlTexture texture, out float w, out float h)
{
w = default;
h = default;
fixed (float* wPtr = &w)
{
fixed (float* hPtr = &h)
{
return PInvoke.GetTextureSize(texture, wPtr, hPtr) != 0;
}
}
}
///
/// Set the palette used by a texture.
///
/// the texture to update.
/// the SDL_Palette structure to use.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Setting the palette keeps an internal reference to the palette, which can
/// be safely destroyed afterwards.
///
///
/// A single palette can be shared with many textures.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
///
public static bool SetTexturePalette(SdlTexture texture, SdlPalette* palette) =>
PInvoke.SetTexturePalette(texture, palette) != 0;
///
/// Set an additional color value multiplied into render copy operations.
///
/// the texture to update.
/// the red color value multiplied into copy operations.
/// the green color value multiplied into copy operations.
/// the blue color value multiplied into copy operations.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When this texture is rendered, during the copy operation each source color
/// channel is modulated by the appropriate color value according to the
/// following formula:
///
///
/// srcC = srcC * (color / 255)
///
///
/// Color modulation is not always supported by the renderer; it will return
/// false if color modulation is not supported.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool SetTextureColorMod(SdlTexture texture, byte r, byte g, byte b) =>
PInvoke.SetTextureColorMod(texture, r, g, b) != 0;
///
/// Set an additional color value multiplied into render copy operations.
///
/// the texture to update.
/// the red color value multiplied into copy operations.
/// the green color value multiplied into copy operations.
/// the blue color value multiplied into copy operations.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When this texture is rendered, during the copy operation each source color
/// channel is modulated by the appropriate color value according to the
/// following formula:
///
///
/// srcC = srcC * color
///
///
/// Color modulation is not always supported by the renderer; it will return
/// false if color modulation is not supported.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool SetTextureColorModFloat(SdlTexture texture, float r, float g, float b) =>
PInvoke.SetTextureColorModFloat(texture, r, g, b) != 0;
///
/// Get the additional color value multiplied into render copy operations.
///
/// the texture to query.
/// a pointer filled in with the current red color value.
/// a pointer filled in with the current green color value.
/// a pointer filled in with the current blue color value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool GetTextureColorMod(SdlTexture texture, out byte r, out byte g, out byte b)
{
r = default;
g = default;
b = default;
fixed (byte* rPtr = &r)
{
fixed (byte* gPtr = &g)
{
fixed (byte* bPtr = &b)
{
return PInvoke.GetTextureColorMod(texture, rPtr, gPtr, bPtr) != 0;
}
}
}
}
///
/// Get the additional color value multiplied into render copy operations.
///
/// the texture to query.
/// a pointer filled in with the current red color value.
/// a pointer filled in with the current green color value.
/// a pointer filled in with the current blue color value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool GetTextureColorModFloat(SdlTexture texture, out float r, out float g, out float b)
{
r = default;
g = default;
b = default;
fixed (float* rPtr = &r)
{
fixed (float* gPtr = &g)
{
fixed (float* bPtr = &b)
{
return PInvoke.GetTextureColorModFloat(texture, rPtr, gPtr, bPtr) != 0;
}
}
}
}
///
/// Set an additional alpha value multiplied into render copy operations.
///
/// the texture to update.
/// the source alpha value multiplied into copy operations.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When this texture is rendered, during the copy operation the source alpha
/// value is modulated by this alpha value according to the following formula:
///
///
/// srcA = srcA * (alpha / 255)
///
///
/// Alpha modulation is not always supported by the renderer; it will return
/// false if alpha modulation is not supported.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool SetTextureAlphaMod(SdlTexture texture, byte alpha) =>
PInvoke.SetTextureAlphaMod(texture, alpha) != 0;
///
/// Set an additional alpha value multiplied into render copy operations.
///
/// the texture to update.
/// the source alpha value multiplied into copy operations.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When this texture is rendered, during the copy operation the source alpha
/// value is modulated by this alpha value according to the following formula:
///
///
/// srcA = srcA * alpha
///
///
/// Alpha modulation is not always supported by the renderer; it will return
/// false if alpha modulation is not supported.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool SetTextureAlphaModFloat(SdlTexture texture, float alpha) =>
PInvoke.SetTextureAlphaModFloat(texture, alpha) != 0;
///
/// Get the additional alpha value multiplied into render copy operations.
///
/// the texture to query.
/// a pointer filled in with the current alpha value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool GetTextureAlphaMod(SdlTexture texture, out byte alpha)
{
alpha = default;
fixed (byte* alphaPtr = &alpha)
{
return PInvoke.GetTextureAlphaMod(texture, alphaPtr) != 0;
}
}
///
/// Get the additional alpha value multiplied into render copy operations.
///
/// the texture to query.
/// a pointer filled in with the current alpha value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool GetTextureAlphaModFloat(SdlTexture texture, out float alpha)
{
alpha = default;
fixed (float* alphaPtr = &alpha)
{
return PInvoke.GetTextureAlphaModFloat(texture, alphaPtr) != 0;
}
}
///
/// Set the blend mode for a texture, used by SDL_RenderTexture().
///
/// the texture to update.
/// the SDL_BlendMode to use for texture blending.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// If the blend mode is not supported, the closest supported mode is chosen
/// and this function returns false.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetTextureBlendMode(SdlTexture texture, uint blendMode) =>
PInvoke.SetTextureBlendMode(texture, blendMode) != 0;
///
/// Get the blend mode used for texture copy operations.
///
/// the texture to query.
/// a pointer filled in with the current SDL_BlendMode.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetTextureBlendMode(SdlTexture texture, uint* blendMode) =>
PInvoke.GetTextureBlendMode(texture, blendMode) != 0;
///
/// Set the scale mode used for texture scale operations.
///
/// the texture to update.
/// the SDL_ScaleMode to use for texture scaling.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The default texture scale mode is SDL_SCALEMODE_LINEAR.
///
///
/// If the scale mode is not supported, the closest supported mode is chosen.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetTextureScaleMode(SdlTexture texture, SdlScaleMode scaleMode) =>
PInvoke.SetTextureScaleMode(texture, scaleMode) != 0;
///
/// Get the scale mode used for texture scale operations.
///
/// the texture to query.
/// a pointer filled in with the current scale mode.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetTextureScaleMode(SdlTexture texture, out SdlScaleMode scaleMode)
{
scaleMode = default;
fixed (SdlScaleMode* scaleModePtr = &scaleMode)
{
return PInvoke.GetTextureScaleMode(texture, scaleModePtr) != 0;
}
}
///
/// Update the given texture rectangle with new pixel data.
///
/// the texture to update.
///
/// an SDL_Rect structure representing the area to update, or NULL
/// to update the entire texture.
///
/// the raw pixel data in the format of the texture.
///
/// the number of bytes in a row of pixel data, including padding
/// between lines.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The pixel data must be in the pixel format of the texture, which can be
/// queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
///
///
/// This is a fairly slow function, intended for use with static textures that
/// do not change often.
///
///
/// If the texture is intended to be updated often, it is preferred to create
/// the texture as streaming and use the locking functions referenced below.
/// While this function will work with streaming textures, for optimization
/// reasons you may not get the pixels back if you lock the texture afterward.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
///
public static bool UpdateTexture(SdlTexture texture, SdlRect* rect, void* pixels, int pitch) =>
PInvoke.UpdateTexture(texture, rect, pixels, pitch) != 0;
///
/// Update a rectangle within a planar YV12 or IYUV texture with new pixel
/// data.
///
/// the texture to update.
///
/// a pointer to the rectangle of pixels to update, or NULL to
/// update the entire texture.
///
/// the raw pixel data for the Y plane.
///
/// the number of bytes between rows of pixel data for the Y
/// plane.
///
/// the raw pixel data for the U plane.
///
/// the number of bytes between rows of pixel data for the U
/// plane.
///
/// the raw pixel data for the V plane.
///
/// the number of bytes between rows of pixel data for the V
/// plane.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
/// block of Y and U/V planes in the proper order, but this function is
/// available if your pixel data is not contiguous.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool UpdateYUVTexture(
SdlTexture texture,
SdlRect* rect,
byte* Yplane,
int Ypitch,
byte* Uplane,
int Upitch,
byte* Vplane,
int Vpitch
) => PInvoke.UpdateYUVTexture(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) != 0;
///
/// Update a rectangle within a planar NV12 or NV21 texture with new pixels.
///
/// the texture to update.
///
/// a pointer to the rectangle of pixels to update, or NULL to
/// update the entire texture.
///
/// the raw pixel data for the Y plane.
///
/// the number of bytes between rows of pixel data for the Y
/// plane.
///
/// the raw pixel data for the UV plane.
///
/// the number of bytes between rows of pixel data for the UV
/// plane.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
/// block of NV12/21 planes in the proper order, but this function is available
/// if your pixel data is not contiguous.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool UpdateNVTexture(
SdlTexture texture,
SdlRect* rect,
byte* Yplane,
int Ypitch,
byte* UVplane,
int UVpitch
) => PInvoke.UpdateNVTexture(texture, rect, Yplane, Ypitch, UVplane, UVpitch) != 0;
///
/// Lock a portion of the texture for write-only pixel access.
///
///
/// the texture to lock for access, which was created with
/// SDL_TEXTUREACCESS_STREAMING.
///
///
/// an SDL_Rect structure representing the area to lock for access;
/// NULL to lock the entire texture.
///
///
/// this is filled in with a pointer to the locked pixels,
/// appropriately offset by the locked area.
///
///
/// this is filled in with the pitch of the locked pixels; the
/// pitch is the length of one row in bytes.
///
///
/// true on success or false if the texture is not valid or was not
/// created with SDL_TEXTUREACCESS_STREAMING; call SDL_GetError()
/// for more information.
///
///
///
/// As an optimization, the pixels made available for editing don't necessarily
/// contain the old texture data. This is a write-only operation, and if you
/// need to keep a copy of the texture data you should do that at the
/// application level.
///
///
/// You must use SDL_UnlockTexture() to unlock the pixels and apply any
/// changes.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool LockTexture(SdlTexture texture, SdlRect* rect, void** pixels, out int pitch)
{
pitch = default;
fixed (int* pitchPtr = &pitch)
{
return PInvoke.LockTexture(texture, rect, pixels, pitchPtr) != 0;
}
}
///
/// Lock a portion of the texture for write-only pixel access, and expose
/// it as a SDL surface.
///
///
/// the texture to lock for access, which must be created with
/// SDL_TEXTUREACCESS_STREAMING.
///
///
/// a pointer to the rectangle to lock for access. If the rect is
/// NULL, the entire texture will be locked.
///
///
/// a pointer to an SDL surface of size rect. Don't assume
/// any specific pixel content.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Besides providing an SDL_Surface instead of raw pixel data, this function
/// operates like SDL_LockTexture.
///
///
/// As an optimization, the pixels made available for editing don't necessarily
/// contain the old texture data. This is a write-only operation, and if you
/// need to keep a copy of the texture data you should do that at the
/// application level.
///
///
/// You must use SDL_UnlockTexture() to unlock the pixels and apply any
/// changes.
///
///
/// The returned surface is freed internally after calling SDL_UnlockTexture()
/// or SDL_DestroyTexture(). The caller should not free it.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool LockTextureToSurface(SdlTexture texture, SdlRect* rect, SdlSurface** surface) =>
PInvoke.LockTextureToSurface(texture, rect, surface) != 0;
///
/// Unlock a texture, uploading the changes to video memory, if needed.
///
/// a texture locked by SDL_LockTexture().
///
///
/// Warning: Please note that SDL_LockTexture() is intended to be
/// write-only; it will not guarantee the previous contents of the texture will
/// be provided. You must fully initialize any area of a texture that you lock
/// before unlocking it, as the pixels might otherwise be uninitialized memory.
///
///
/// Which is to say: locking and immediately unlocking a texture can result in
/// corrupted textures, depending on the renderer in use.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static void UnlockTexture(SdlTexture texture) => PInvoke.UnlockTexture(texture);
///
/// Set a texture as the current rendering target.
///
/// the rendering context.
///
/// the targeted texture, which must be created with the
/// SDL_TEXTUREACCESS_TARGET flag, or NULL to render to the
/// window instead of a texture.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The default render target is the window for which the renderer was created.
/// To stop rendering to a texture and render to the window again, call this
/// function with a NULL texture.
///
///
/// Viewport, cliprect, scale, and logical presentation are unique to each
/// render target. Get and set functions for these states apply to the current
/// render target set by this function, and those states persist on each target
/// when the current render target changes.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetRenderTarget(SdlRenderer renderer, SdlTexture texture) =>
PInvoke.SetRenderTarget(renderer, texture) != 0;
///
/// Ergonomic wrapper over SDL_GetRenderTarget.
///
/// the rendering context.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlTexture GetRenderTarget(SdlRenderer renderer) => PInvoke.GetRenderTarget(renderer);
///
/// Set a device-independent resolution and presentation mode for rendering.
///
/// the rendering context.
/// the width of the logical resolution.
/// the height of the logical resolution.
/// the presentation mode used.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function sets the width and height of the logical rendering output.
/// The renderer will act as if the current render target is always the
/// requested dimensions, scaling to the actual resolution as necessary.
///
///
/// This can be useful for games that expect a fixed size, but would like to
/// scale the output to whatever is available, regardless of how a user resizes
/// a window, or if the display is high DPI.
///
///
/// Logical presentation can be used with both render target textures and the
/// renderer's window; the state is unique to each render target, and this
/// function sets the state for the current render target. It might be useful
/// to draw to a texture that matches the window dimensions with logical
/// presentation enabled, and then draw that texture across the entire window
/// with logical presentation disabled. Be careful not to render both with
/// logical presentation enabled, however, as this could produce
/// double-letterboxing, etc.
///
///
/// You can disable logical coordinates by setting the mode to
/// SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
/// resolution of the render target; it is safe to toggle logical presentation
/// during the rendering of a frame: perhaps most of the rendering is done to
/// specific dimensions but to make fonts look sharp, the app turns off logical
/// presentation while drawing text, for example.
///
///
/// You can convert coordinates in an event into rendering coordinates using
/// SDL_ConvertEventToRenderCoordinates().
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool SetRenderLogicalPresentation(
SdlRenderer renderer,
int w,
int h,
SdlRendererLogicalPresentation mode
) => PInvoke.SetRenderLogicalPresentation(renderer, w, h, mode) != 0;
///
/// Get device independent resolution and presentation mode for rendering.
///
/// the rendering context.
/// an int filled with the logical presentation width.
/// an int filled with the logical presentation height.
///
/// a variable filled with the logical presentation mode being
/// used.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function gets the width and height of the logical rendering output, or
/// 0 if a logical resolution is not enabled.
///
///
/// Each render target has its own logical presentation state. This function
/// gets the state for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderLogicalPresentation(
SdlRenderer renderer,
out int w,
out int h,
out SdlRendererLogicalPresentation mode
)
{
w = default;
h = default;
mode = default;
fixed (int* wPtr = &w)
{
fixed (int* hPtr = &h)
{
fixed (SdlRendererLogicalPresentation* modePtr = &mode)
{
return PInvoke.GetRenderLogicalPresentation(renderer, wPtr, hPtr, modePtr) != 0;
}
}
}
}
///
/// Get the final presentation rectangle for rendering.
///
/// the rendering context.
///
/// a pointer filled in with the final presentation rectangle, may
/// be NULL.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function returns the calculated rectangle used for logical
/// presentation, based on the presentation mode and output size. If logical
/// presentation is disabled, it will fill the rectangle with the output size,
/// in pixels.
///
///
/// Each render target has its own logical presentation state. This function
/// gets the rectangle for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderLogicalPresentationRect(SdlRenderer renderer, SdlFRect* rect) =>
PInvoke.GetRenderLogicalPresentationRect(renderer, rect) != 0;
///
/// Get a point in render coordinates when given a point in window coordinates.
///
/// the rendering context.
/// the x coordinate in window coordinates.
/// the y coordinate in window coordinates.
/// a pointer filled with the x coordinate in render coordinates.
/// a pointer filled with the y coordinate in render coordinates.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This takes into account several states:
///
///
/// - The window dimensions.
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
/// - The scale (SDL_SetRenderScale)
/// - The viewport (SDL_SetRenderViewport)
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderCoordinatesFromWindow(
SdlRenderer renderer,
float window_x,
float window_y,
out float x,
out float y
)
{
x = default;
y = default;
fixed (float* xPtr = &x)
{
fixed (float* yPtr = &y)
{
return PInvoke.RenderCoordinatesFromWindow(renderer, window_x, window_y, xPtr, yPtr) != 0;
}
}
}
///
/// Get a point in window coordinates when given a point in render coordinates.
///
/// the rendering context.
/// the x coordinate in render coordinates.
/// the y coordinate in render coordinates.
///
/// a pointer filled with the x coordinate in window
/// coordinates.
///
///
/// a pointer filled with the y coordinate in window
/// coordinates.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This takes into account several states:
///
///
/// - The window dimensions.
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
/// - The scale (SDL_SetRenderScale)
/// - The viewport (SDL_SetRenderViewport)
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool RenderCoordinatesToWindow(
SdlRenderer renderer,
float x,
float y,
out float window_x,
out float window_y
)
{
window_x = default;
window_y = default;
fixed (float* window_xPtr = &window_x)
{
fixed (float* window_yPtr = &window_y)
{
return PInvoke.RenderCoordinatesToWindow(renderer, x, y, window_xPtr, window_yPtr) != 0;
}
}
}
///
/// Convert the coordinates in an event to render coordinates.
///
/// the rendering context.
/// the event to modify.
///
/// true if the event is converted or doesn't need conversion, or
/// false on failure; call SDL_GetError() for more information.
///
///
///
/// This takes into account several states:
///
///
/// - The window dimensions.
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
/// - The scale (SDL_SetRenderScale)
/// - The viewport (SDL_SetRenderViewport)
///
///
/// Various event types are converted with this function: mouse, touch, pen,
/// etc.
///
///
/// Touch coordinates are converted from normalized coordinates in the window
/// to non-normalized rendering coordinates.
///
///
/// Relative mouse coordinates (xrel and yrel event fields) are also
/// converted. Applications that do not want these fields converted should use
/// SDL_RenderCoordinatesFromWindow() on the specific event fields instead of
/// converting the entire event structure.
///
///
/// Once converted, coordinates may be outside the rendering area.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool ConvertEventToRenderCoordinates(SdlRenderer renderer, SdlEvent* @event) =>
PInvoke.ConvertEventToRenderCoordinates(renderer, @event) != 0;
///
/// Set the drawing area for rendering on the current target.
///
/// the rendering context.
///
/// the SDL_Rect structure representing the drawing area, or NULL
/// to set the viewport to the entire target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Drawing will clip to this area (separately from any clipping done with
/// SDL_SetRenderClipRect), and the top left of the area will become coordinate
/// (0, 0) for future drawing commands.
///
///
/// The area's width and height must be >= 0.
///
///
/// Each render target has its own viewport. This function sets the viewport
/// for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetRenderViewport(SdlRenderer renderer, SdlRect* rect) =>
PInvoke.SetRenderViewport(renderer, rect) != 0;
///
/// Get the drawing area for the current target.
///
/// the rendering context.
/// an SDL_Rect structure filled in with the current drawing area.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each render target has its own viewport. This function gets the viewport
/// for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GetRenderViewport(SdlRenderer renderer, SdlRect* rect) =>
PInvoke.GetRenderViewport(renderer, rect) != 0;
///
/// Return whether an explicit rectangle was set as the viewport.
///
/// the rendering context.
///
/// true if the viewport was set to a specific rectangle, or false if
/// it was set to NULL (the entire target).
///
///
///
/// This is useful if you're saving and restoring the viewport and want to know
/// whether you should restore a specific rectangle or NULL.
///
///
/// Each render target has its own viewport. This function checks the viewport
/// for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderViewportSet(SdlRenderer renderer) => PInvoke.RenderViewportSet(renderer) != 0;
///
/// Get the safe area for rendering within the current viewport.
///
/// the rendering context.
///
/// a pointer filled in with the area that is safe for interactive
/// content.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Some devices have portions of the screen which are partially obscured or
/// not interactive, possibly due to on-screen controls, curved edges, camera
/// notches, TV overscan, etc. This function provides the area of the current
/// viewport which is safe to have interactible content. You should continue
/// rendering into the rest of the render target, but it should not contain
/// visually important or interactible content.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool GetRenderSafeArea(SdlRenderer renderer, SdlRect* rect) =>
PInvoke.GetRenderSafeArea(renderer, rect) != 0;
///
/// Set the clip rectangle for rendering on the specified target.
///
/// the rendering context.
///
/// an SDL_Rect structure representing the clip area, relative to
/// the viewport, or NULL to disable clipping.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each render target has its own clip rectangle. This function sets the
/// cliprect for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetRenderClipRect(SdlRenderer renderer, SdlRect* rect) =>
PInvoke.SetRenderClipRect(renderer, rect) != 0;
///
/// Get the clip rectangle for the current target.
///
/// the rendering context.
///
/// an SDL_Rect structure filled in with the current clipping area
/// or an empty rectangle if clipping is disabled.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each render target has its own clip rectangle. This function gets the
/// cliprect for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GetRenderClipRect(SdlRenderer renderer, SdlRect* rect) =>
PInvoke.GetRenderClipRect(renderer, rect) != 0;
///
/// Get whether clipping is enabled on the given render target.
///
/// the rendering context.
///
/// true if clipping is enabled or false if not; call SDL_GetError()
/// for more information.
///
///
///
/// Each render target has its own clip rectangle. This function checks the
/// cliprect for the current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderClipEnabled(SdlRenderer renderer) => PInvoke.RenderClipEnabled(renderer) != 0;
///
/// Set the drawing scale for rendering on the current target.
///
/// the rendering context.
/// the horizontal scaling factor.
/// the vertical scaling factor.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The drawing coordinates are scaled by the x/y scaling factors before they
/// are used by the renderer. This allows resolution independent drawing with a
/// single coordinate system.
///
///
/// If this results in scaling or subpixel drawing by the rendering backend, it
/// will be handled using the appropriate quality hints. For best results use
/// integer scaling factors.
///
///
/// Each render target has its own scale. This function sets the scale for the
/// current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetRenderScale(SdlRenderer renderer, float scaleX, float scaleY) =>
PInvoke.SetRenderScale(renderer, scaleX, scaleY) != 0;
///
/// Get the drawing scale for the current target.
///
/// the rendering context.
/// a pointer filled in with the horizontal scaling factor.
/// a pointer filled in with the vertical scaling factor.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each render target has its own scale. This function gets the scale for the
/// current render target.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderScale(SdlRenderer renderer, out float scaleX, out float scaleY)
{
scaleX = default;
scaleY = default;
fixed (float* scaleXPtr = &scaleX)
{
fixed (float* scaleYPtr = &scaleY)
{
return PInvoke.GetRenderScale(renderer, scaleXPtr, scaleYPtr) != 0;
}
}
}
///
/// Set the color used for drawing operations.
///
/// the rendering context.
/// the red value used to draw on the rendering target.
/// the green value used to draw on the rendering target.
/// the blue value used to draw on the rendering target.
///
/// the alpha value used to draw on the rendering target; usually
/// SDL_ALPHA_OPAQUE (255). Use SDL_SetRenderDrawBlendMode to
/// specify how the alpha channel is used.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Set the color for drawing or filling rectangles, lines, and points, and for
/// SDL_RenderClear().
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetRenderDrawColor(SdlRenderer renderer, byte r, byte g, byte b, byte a) =>
PInvoke.SetRenderDrawColor(renderer, r, g, b, a) != 0;
///
/// Set the color used for drawing operations (Rect, Line and Clear).
///
/// the rendering context.
/// the red value used to draw on the rendering target.
/// the green value used to draw on the rendering target.
/// the blue value used to draw on the rendering target.
///
/// the alpha value used to draw on the rendering target. Use
/// SDL_SetRenderDrawBlendMode to specify how the alpha channel is
/// used.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Set the color for drawing or filling rectangles, lines, and points, and for
/// SDL_RenderClear().
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetRenderDrawColorFloat(SdlRenderer renderer, float r, float g, float b, float a) =>
PInvoke.SetRenderDrawColorFloat(renderer, r, g, b, a) != 0;
///
/// Get the color used for drawing operations (Rect, Line and Clear).
///
/// the rendering context.
///
/// a pointer filled in with the red value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the green value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the blue value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the alpha value used to draw on the
/// rendering target; usually SDL_ALPHA_OPAQUE (255).
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GetRenderDrawColor(SdlRenderer renderer, out byte r, out byte g, out byte b, out byte a)
{
r = default;
g = default;
b = default;
a = default;
fixed (byte* rPtr = &r)
{
fixed (byte* gPtr = &g)
{
fixed (byte* bPtr = &b)
{
fixed (byte* aPtr = &a)
{
return PInvoke.GetRenderDrawColor(renderer, rPtr, gPtr, bPtr, aPtr) != 0;
}
}
}
}
}
///
/// Get the color used for drawing operations (Rect, Line and Clear).
///
/// the rendering context.
///
/// a pointer filled in with the red value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the green value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the blue value used to draw on the
/// rendering target.
///
///
/// a pointer filled in with the alpha value used to draw on the
/// rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GetRenderDrawColorFloat(
SdlRenderer renderer,
out float r,
out float g,
out float b,
out float a
)
{
r = default;
g = default;
b = default;
a = default;
fixed (float* rPtr = &r)
{
fixed (float* gPtr = &g)
{
fixed (float* bPtr = &b)
{
fixed (float* aPtr = &a)
{
return PInvoke.GetRenderDrawColorFloat(renderer, rPtr, gPtr, bPtr, aPtr) != 0;
}
}
}
}
}
///
/// Set the color scale used for render operations.
///
/// the rendering context.
/// the color scale value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The color scale is an additional scale multiplied into the pixel color
/// value while rendering. This can be used to adjust the brightness of colors
/// during HDR rendering, or changing HDR video brightness when playing on an
/// SDR display.
///
///
/// The color scale does not affect the alpha channel, only the color
/// brightness.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetRenderColorScale(SdlRenderer renderer, float scale) =>
PInvoke.SetRenderColorScale(renderer, scale) != 0;
///
/// Get the color scale used for render operations.
///
/// the rendering context.
/// a pointer filled in with the current color scale value.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderColorScale(SdlRenderer renderer, out float scale)
{
scale = default;
fixed (float* scalePtr = &scale)
{
return PInvoke.GetRenderColorScale(renderer, scalePtr) != 0;
}
}
///
/// Set the blend mode used for drawing operations (Fill and Line).
///
/// the rendering context.
/// the SDL_BlendMode to use for blending.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// If the blend mode is not supported, the closest supported mode is chosen.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetRenderDrawBlendMode(SdlRenderer renderer, uint blendMode) =>
PInvoke.SetRenderDrawBlendMode(renderer, blendMode) != 0;
///
/// Get the blend mode used for drawing operations.
///
/// the rendering context.
/// a pointer filled in with the current SDL_BlendMode.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderDrawBlendMode(SdlRenderer renderer, uint* blendMode) =>
PInvoke.GetRenderDrawBlendMode(renderer, blendMode) != 0;
///
/// Clear the current rendering target with the drawing color.
///
/// the rendering context.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function clears the entire rendering target, ignoring the viewport and
/// the clip rectangle. Note, that clearing will also set/fill all pixels of
/// the rendering target to current renderer draw color, so make sure to invoke
/// SDL_SetRenderDrawColor() when needed.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderClear(SdlRenderer renderer) => PInvoke.RenderClear(renderer) != 0;
///
/// Draw a point on the current rendering target at subpixel precision.
///
/// the renderer which should draw a point.
/// the x coordinate of the point.
/// the y coordinate of the point.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderPoint(SdlRenderer renderer, float x, float y) =>
PInvoke.RenderPoint(renderer, x, y) != 0;
///
/// Draw multiple points on the current rendering target at subpixel precision.
///
/// the renderer which should draw multiple points.
/// the points to draw.
/// the number of points to draw.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderPoints(SdlRenderer renderer, SdlFPoint* points, int count) =>
PInvoke.RenderPoints(renderer, points, count) != 0;
///
/// Draw a line on the current rendering target at subpixel precision.
///
/// the renderer which should draw a line.
/// the x coordinate of the start point.
/// the y coordinate of the start point.
/// the x coordinate of the end point.
/// the y coordinate of the end point.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderLine(SdlRenderer renderer, float x1, float y1, float x2, float y2) =>
PInvoke.RenderLine(renderer, x1, y1, x2, y2) != 0;
///
/// Draw a series of connected lines on the current rendering target at
/// subpixel precision.
///
/// the renderer which should draw multiple lines.
/// the points along the lines.
/// the number of points, drawing count-1 lines.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderLines(SdlRenderer renderer, SdlFPoint* points, int count) =>
PInvoke.RenderLines(renderer, points, count) != 0;
///
/// Draw a rectangle on the current rendering target at subpixel precision.
///
/// the renderer which should draw a rectangle.
///
/// a pointer to the destination rectangle, or NULL to outline the
/// entire rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderRect(SdlRenderer renderer, SdlFRect* rect) =>
PInvoke.RenderRect(renderer, rect) != 0;
///
/// Draw some number of rectangles on the current rendering target at subpixel
/// precision.
///
/// the renderer which should draw multiple rectangles.
/// a pointer to an array of destination rectangles.
/// the number of rectangles.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderRects(SdlRenderer renderer, SdlFRect* rects, int count) =>
PInvoke.RenderRects(renderer, rects, count) != 0;
///
/// Fill a rectangle on the current rendering target with the drawing color at
/// subpixel precision.
///
/// the renderer which should fill a rectangle.
///
/// a pointer to the destination rectangle, or NULL for the entire
/// rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderFillRect(SdlRenderer renderer, SdlFRect* rect) =>
PInvoke.RenderFillRect(renderer, rect) != 0;
///
/// Fill some number of rectangles on the current rendering target with the
/// drawing color at subpixel precision.
///
/// the renderer which should fill multiple rectangles.
/// a pointer to an array of destination rectangles.
/// the number of rectangles.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderFillRects(SdlRenderer renderer, SdlFRect* rects, int count) =>
PInvoke.RenderFillRects(renderer, rects, count) != 0;
///
/// Copy a portion of the texture to the current rendering target at subpixel
/// precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// a pointer to the source rectangle, or NULL for the entire
/// texture.
///
///
/// a pointer to the destination rectangle, or NULL for the
/// entire rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderTexture(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
SdlFRect* dstrect
) => PInvoke.RenderTexture(renderer, texture, srcrect, dstrect) != 0;
///
/// Copy a portion of the source texture to the current rendering target, with
/// rotation and flipping, at subpixel precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// a pointer to the source rectangle, or NULL for the entire
/// texture.
///
///
/// a pointer to the destination rectangle, or NULL for the
/// entire rendering target.
///
///
/// an angle in degrees that indicates the rotation that will be
/// applied to dstrect, rotating it in a clockwise direction.
///
///
/// a pointer to a point indicating the point around which
/// dstrect will be rotated (if NULL, rotation will be done
/// around dstrect.w/2, dstrect.h/2).
///
///
/// an SDL_FlipMode value stating which flipping actions should be
/// performed on the texture.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderTextureRotated(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
SdlFRect* dstrect,
double angle,
SdlFPoint* center,
SdlFlipMode flip
) => PInvoke.RenderTextureRotated(renderer, texture, srcrect, dstrect, angle, center, flip) != 0;
///
/// Copy a portion of the source texture to the current rendering target, with
/// affine transform, at subpixel precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// a pointer to the source rectangle, or NULL for the entire
/// texture.
///
///
/// a pointer to a point indicating where the top-left corner of
/// srcrect should be mapped to, or NULL for the rendering
/// target's origin.
///
///
/// a pointer to a point indicating where the top-right corner of
/// srcrect should be mapped to, or NULL for the rendering
/// target's top-right corner.
///
///
/// a pointer to a point indicating where the bottom-left corner of
/// srcrect should be mapped to, or NULL for the rendering target's
/// bottom-left corner.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// You may only call this function from the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderTextureAffine(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
SdlFPoint* origin,
SdlFPoint* right,
SdlFPoint* down
) => PInvoke.RenderTextureAffine(renderer, texture, srcrect, origin, right, down) != 0;
///
/// Tile a portion of the texture to the current rendering target at subpixel
/// precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// a pointer to the source rectangle, or NULL for the entire
/// texture.
///
///
/// the scale used to transform srcrect into the destination
/// rectangle, e.g. a 32x32 texture with a scale of 2 would fill
/// 64x64 tiles.
///
///
/// a pointer to the destination rectangle, or NULL for the
/// entire rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The pixels in srcrect will be repeated as many times as needed to
/// completely fill dstrect.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool RenderTextureTiled(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
float scale,
SdlFRect* dstrect
) => PInvoke.RenderTextureTiled(renderer, texture, srcrect, scale, dstrect) != 0;
///
/// Perform a scaled copy using the 9-grid algorithm to the current rendering
/// target at subpixel precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// the SDL_Rect structure representing the rectangle to be used
/// for the 9-grid, or NULL to use the entire texture.
///
/// the width, in pixels, of the left corners in srcrect.
/// the width, in pixels, of the right corners in srcrect.
/// the height, in pixels, of the top corners in srcrect.
///
/// the height, in pixels, of the bottom corners in
/// srcrect.
///
///
/// the scale used to transform the corner of srcrect into the
/// corner of dstrect, or 0.0f for an unscaled copy.
///
///
/// a pointer to the destination rectangle, or NULL for the
/// entire rendering target.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The pixels in the texture are split into a 3x3 grid, using the different
/// corner sizes for each corner, and the sides and center making up the
/// remaining pixels. The corners are then scaled using scale and fit into
/// the corners of the destination rectangle. The sides and center are then
/// stretched into place to cover the remaining destination rectangle.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderTexture9Grid(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
SdlFRect* dstrect
) =>
PInvoke.RenderTexture9Grid(
renderer,
texture,
srcrect,
left_width,
right_width,
top_height,
bottom_height,
scale,
dstrect
) != 0;
///
/// Perform a scaled copy using the 9-grid algorithm to the current rendering
/// target at subpixel precision.
///
/// the renderer which should copy parts of a texture.
/// the source texture.
///
/// the SDL_Rect structure representing the rectangle to be used
/// for the 9-grid, or NULL to use the entire texture.
///
/// the width, in pixels, of the left corners in srcrect.
/// the width, in pixels, of the right corners in srcrect.
/// the height, in pixels, of the top corners in srcrect.
///
/// the height, in pixels, of the bottom corners in
/// srcrect.
///
///
/// the scale used to transform the corner of srcrect into the
/// corner of dstrect, or 0.0f for an unscaled copy.
///
///
/// a pointer to the destination rectangle, or NULL for the
/// entire rendering target.
///
///
/// the scale used to transform the borders and center of
/// srcrect into the borders and middle of dstrect, or
/// 1.0f for an unscaled copy.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The pixels in the texture are split into a 3x3 grid, using the different
/// corner sizes for each corner, and the sides and center making up the
/// remaining pixels. The corners are then scaled using scale and fit into
/// the corners of the destination rectangle. The sides and center are then
/// tiled into place to cover the remaining destination rectangle.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
///
public static bool RenderTexture9GridTiled(
SdlRenderer renderer,
SdlTexture texture,
SdlFRect* srcrect,
float left_width,
float right_width,
float top_height,
float bottom_height,
float scale,
SdlFRect* dstrect,
float tileScale
) =>
PInvoke.RenderTexture9GridTiled(
renderer,
texture,
srcrect,
left_width,
right_width,
top_height,
bottom_height,
scale,
dstrect,
tileScale
) != 0;
///
/// Render a list of triangles, optionally using a texture and indices into the
/// vertex array Color and alpha modulation is done per vertex
/// (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
///
/// the rendering context.
/// (optional) The SDL texture to use.
/// vertices.
/// number of vertices.
///
/// (optional) An array of integer indices into the 'vertices'
/// array, if NULL all vertices will be rendered in sequential
/// order.
///
/// number of indices.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderGeometry(
SdlRenderer renderer,
SdlTexture texture,
SdlVertex* vertices,
int num_vertices,
int* indices,
int num_indices
) => PInvoke.RenderGeometry(renderer, texture, vertices, num_vertices, indices, num_indices) != 0;
///
/// Render a list of triangles, optionally using a texture and indices into the
/// vertex arrays Color and alpha modulation is done per vertex
/// (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
///
/// the rendering context.
/// (optional) The SDL texture to use.
/// vertex positions.
/// byte size to move from one element to the next element.
/// vertex colors (as SDL_FColor).
/// byte size to move from one element to the next element.
/// vertex normalized texture coordinates.
/// byte size to move from one element to the next element.
/// number of vertices.
///
/// (optional) An array of indices into the 'vertices' arrays,
/// if NULL all vertices will be rendered in sequential order.
///
/// number of indices.
/// index size: 1 (byte), 2 (short), 4 (int).
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool RenderGeometryRaw(
SdlRenderer renderer,
SdlTexture texture,
float* xy,
int xy_stride,
SdlFColor* color,
int color_stride,
float* uv,
int uv_stride,
int num_vertices,
void* indices,
int num_indices,
int size_indices
) =>
PInvoke.RenderGeometryRaw(
renderer,
texture,
xy,
xy_stride,
color,
color_stride,
uv,
uv_stride,
num_vertices,
indices,
num_indices,
size_indices
) != 0;
///
/// Set the texture addressing mode used in SDL_RenderGeometry().
///
/// the rendering context.
///
/// the SDL_TextureAddressMode to use for horizontal texture
/// coordinates in SDL_RenderGeometry().
///
///
/// the SDL_TextureAddressMode to use for vertical texture
/// coordinates in SDL_RenderGeometry().
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
///
///
public static bool SetRenderTextureAddressMode(
SdlRenderer renderer,
SdlTextureAddressMode u_mode,
SdlTextureAddressMode v_mode
) => PInvoke.SetRenderTextureAddressMode(renderer, u_mode, v_mode) != 0;
///
/// Get the texture addressing mode used in SDL_RenderGeometry().
///
/// the rendering context.
///
/// a pointer filled in with the SDL_TextureAddressMode to use
/// for horizontal texture coordinates in SDL_RenderGeometry(),
/// may be NULL.
///
///
/// a pointer filled in with the SDL_TextureAddressMode to use
/// for vertical texture coordinates in SDL_RenderGeometry(), may
/// be NULL.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
public static bool GetRenderTextureAddressMode(
SdlRenderer renderer,
out SdlTextureAddressMode u_mode,
out SdlTextureAddressMode v_mode
)
{
u_mode = default;
v_mode = default;
fixed (SdlTextureAddressMode* u_modePtr = &u_mode)
{
fixed (SdlTextureAddressMode* v_modePtr = &v_mode)
{
return PInvoke.GetRenderTextureAddressMode(renderer, u_modePtr, v_modePtr) != 0;
}
}
}
///
/// Update the screen with any rendering performed since the previous call.
///
/// the rendering context.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// SDL's rendering functions operate on a backbuffer; that is, calling a
/// rendering function such as SDL_RenderLine() does not directly put a line on
/// the screen, but rather updates the backbuffer. As such, you compose your
/// entire scene and present the composed backbuffer to the screen as a
/// complete picture.
///
///
/// Therefore, when using SDL's rendering API, one does all drawing intended
/// for the frame, and then calls this function once per frame to present the
/// final drawing to the user.
///
///
/// The backbuffer should be considered invalidated after each present; do not
/// assume that previous contents will exist between frames. You are strongly
/// encouraged to call SDL_RenderClear() to initialize the backbuffer before
/// starting each new frame's drawing, even if you plan to overwrite every
/// pixel.
///
///
/// Please note, that in case of rendering to a texture - there is no need
/// to call SDL_RenderPresent after drawing needed objects to a texture, and
/// should not be done; you are only required to change back the rendering
/// target to default via SDL_SetRenderTarget(renderer, NULL) afterwards, as
/// textures by themselves do not have a concept of backbuffers. Calling
/// SDL_RenderPresent while rendering to a texture will fail.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
///
///
///
///
///
///
///
///
///
public static bool RenderPresent(SdlRenderer renderer) => PInvoke.RenderPresent(renderer) != 0;
///
/// Destroy the specified texture.
///
/// the texture to destroy.
///
///
/// Passing NULL or an otherwise invalid texture will set the SDL error message
/// to "Invalid texture".
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static void DestroyTexture(SdlTexture texture) => PInvoke.DestroyTexture(texture);
///
/// Destroy the rendering context for a window and free all associated
/// textures.
///
/// the rendering context.
///
///
/// This should be called before destroying the associated window.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static void DestroyRenderer(SdlRenderer renderer) => PInvoke.DestroyRenderer(renderer);
///
/// Force the rendering context to flush any pending commands and state.
///
/// the rendering context.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// You do not need to (and in fact, shouldn't) call this function unless you
/// are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
/// addition to using an SDL_Renderer.
///
///
/// This is for a very-specific case: if you are using SDL's render API, and
/// you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
/// calls. If this applies, you should call this function between calls to
/// SDL's render API and the low-level API you're using in cooperation.
///
///
/// In all other cases, you can ignore this function.
///
///
/// This call makes SDL flush any pending rendering work it was queueing up to
/// do later in a single batch, and marks any internal cached state as invalid,
/// so it'll prepare all its state again later, from scratch.
///
///
/// This means you do not need to save state in your rendering code to protect
/// the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
/// OpenGL state that can confuse things; you should use your best judgment and
/// be prepared to make changes if specific state needs to be protected.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool FlushRenderer(SdlRenderer renderer) => PInvoke.FlushRenderer(renderer) != 0;
///
/// Add a set of synchronization semaphores for the current frame.
///
/// the rendering context.
/// the VkPipelineStageFlags for the wait.
///
/// a VkSempahore to wait on before rendering the current
/// frame, or 0 if not needed.
///
///
/// a VkSempahore that SDL will signal when rendering
/// for the current frame is complete, or 0 if not
/// needed.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The Vulkan renderer will wait for wait_semaphore before submitting
/// rendering commands and signal signal_semaphore after rendering commands
/// are complete for this frame.
///
///
/// This should be called each frame that you want semaphore synchronization.
/// The Vulkan renderer may have multiple frames in flight on the GPU, so you
/// should have multiple semaphores that are used for synchronization. Querying
/// SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
/// maximum number of semaphores you'll need.
///
///
///
/// It is NOT safe to call this function from two threads at
/// once.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool AddVulkanRenderSemaphores(
SdlRenderer renderer,
uint wait_stage_mask,
long wait_semaphore,
long signal_semaphore
) => PInvoke.AddVulkanRenderSemaphores(renderer, wait_stage_mask, wait_semaphore, signal_semaphore) != 0;
///
/// Toggle VSync of the given renderer.
///
/// the renderer to toggle.
/// the vertical refresh sync interval.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
///
///
/// The vsync parameter can be 1 to synchronize present with every vertical
/// refresh, 2 to synchronize present with every second vertical refresh, etc.,
/// SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or
/// SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by
/// every driver, so you should check the return value to see whether the
/// requested setting is supported.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetRenderVSync(SdlRenderer renderer, int vsync) =>
PInvoke.SetRenderVSync(renderer, vsync) != 0;
///
/// Get VSync of the given renderer.
///
/// the renderer to toggle.
///
/// an int filled with the current vertical refresh sync interval.
/// See SDL_SetRenderVSync() for the meaning of the value.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GetRenderVSync(SdlRenderer renderer, out int vsync)
{
vsync = default;
fixed (int* vsyncPtr = &vsync)
{
return PInvoke.GetRenderVSync(renderer, vsyncPtr) != 0;
}
}
///
/// Draw debug text to an SDL_Renderer.
///
/// the renderer which should draw a line of text.
/// the x coordinate where the top-left corner of the text will draw.
/// the y coordinate where the top-left corner of the text will draw.
/// the string to render.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function will render a string of text to an SDL_Renderer. Note that
/// this is a convenience function for debugging, with severe limitations, and
/// not intended to be used for production apps and games.
///
///
/// Among these limitations:
///
///
/// - It accepts UTF-8 strings, but will only renders ASCII characters.
/// - It has a single, tiny size (8x8 pixels). You can use logical presentation
/// or SDL_SetRenderScale() to adjust it.
/// - It uses a simple, hardcoded bitmap font. It does not allow different font
/// selections and it does not support truetype, for proper scaling.
/// - It does no word-wrapping and does not treat newline characters as a line
/// break. If the text goes out of the window, it's gone.
///
///
/// For serious text rendering, there are several good options, such as
/// SDL_ttf, stb_truetype, or other external libraries.
///
///
/// On first use, this will create an internal texture for rendering glyphs.
/// This texture will live until the renderer is destroyed.
///
///
/// The text is drawn in the color specified by SDL_SetRenderDrawColor().
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool RenderDebugText(SdlRenderer renderer, float x, float y, string str) =>
PInvoke.RenderDebugText(renderer, x, y, str) != 0;
///
/// Set default scale mode for new textures for given renderer.
///
/// the renderer to update.
/// the scale mode to change to for new textures.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
///
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
public static bool SetDefaultTextureScaleMode(SdlRenderer renderer, SdlScaleMode scale_mode) =>
PInvoke.SetDefaultTextureScaleMode(renderer, scale_mode) != 0;
///
/// Get default texture scale mode of the given renderer.
///
/// the renderer to get data from.
///
/// a SDL_ScaleMode filled with current default scale mode.
/// See SDL_SetDefaultTextureScaleMode() for the meaning of
/// the value.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// This function should only be called on the main thread.
///
///
/// This function is available since SDL 3.4.0.
///
///
public static bool GetDefaultTextureScaleMode(SdlRenderer renderer, out SdlScaleMode scale_mode)
{
scale_mode = default;
fixed (SdlScaleMode* scale_modePtr = &scale_mode)
{
return PInvoke.GetDefaultTextureScaleMode(renderer, scale_modePtr) != 0;
}
}
///
/// Create custom GPU render state.
///
/// the renderer to use.
/// a struct describing the GPU render state to create.
///
/// a custom GPU render state or NULL on failure; call SDL_GetError()
/// for more information.
///
///
/// This function should be called on the thread that created the
/// renderer.
///
///
/// This function is available since SDL 3.4.0.
///
///
///
///
public static nint CreateGpuRenderState(SdlRenderer renderer, SdlGpuRenderStateCreateInfo* createinfo) =>
PInvoke.CreateGpuRenderState(renderer, createinfo);
///
/// Set fragment shader uniform variables in a custom GPU render state.
///
/// the state to modify.
/// the fragment uniform slot to push data to.
/// client data to write.
/// the length of the data to write.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// The data is copied and will be pushed using
/// SDL_PushGPUFragmentUniformData() during draw call execution.
///
///
///
/// This function should be called on the thread that created the
/// renderer.
///
///
/// This function is available since SDL 3.4.0.
///
public static bool SetGpuRenderStateFragmentUniforms(
nint state,
uint slot_index,
void* data,
uint length
) => PInvoke.SetGpuRenderStateFragmentUniforms(state, slot_index, data, length) != 0;
///
/// Set custom GPU render state.
///
/// the renderer to use.
/// the state to to use, or NULL to clear custom GPU render state.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This function sets custom GPU render state for subsequent draw calls. This
/// allows using custom shaders with the GPU renderer.
///
///
///
/// This function should be called on the thread that created the
/// renderer.
///
///
/// This function is available since SDL 3.4.0.
///
public static bool SetGpuRenderState(SdlRenderer renderer, nint state) =>
PInvoke.SetGpuRenderState(renderer, state) != 0;
///
/// Destroy custom GPU render state.
///
/// the state to destroy.
///
/// This function should be called on the thread that created the
/// renderer.
///
///
/// This function is available since SDL 3.4.0.
///
///
public static void DestroyGpuRenderState(nint state) => PInvoke.DestroyGpuRenderState(state);
}
}
}