mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
3349 lines
161 KiB
C#
3349 lines
161 KiB
C#
// <auto-generated/>
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// Get the number of 2D rendering drivers available for the current display.
|
|
/// </summary>
|
|
/// <returns>the number of built in render drivers.</returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// There may be none if SDL was compiled without render support.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// It is safe to call this function from any thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRenderer"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDriver"/>
|
|
public static int GetNumRenderDrivers() => PInvoke.GetNumRenderDrivers();
|
|
|
|
/// <summary>
|
|
/// Use this function to get the name of a built in 2D rendering driver.
|
|
/// </summary>
|
|
/// <param name="index">
|
|
/// the index of the rendering driver; the value ranges from 0 to
|
|
/// SDL_GetNumRenderDrivers() - 1.
|
|
/// </param>
|
|
/// <returns>
|
|
/// the name of the rendering driver at the requested index, or NULL
|
|
/// if an invalid index was specified.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// It is safe to call this function from any thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetNumRenderDrivers"/>
|
|
public static string? GetRenderDriver(int index) => PInvoke.GetRenderDriver(index);
|
|
|
|
/// <summary>
|
|
/// Create a window and default renderer.
|
|
/// </summary>
|
|
/// <param name="title">the title of the window, in UTF-8 encoding.</param>
|
|
/// <param name="width">the width of the window.</param>
|
|
/// <param name="height">the height of the window.</param>
|
|
/// <param name="window_flags">
|
|
/// the flags used to create the window (see
|
|
/// SDL_CreateWindow()).
|
|
/// </param>
|
|
/// <param name="window">a pointer filled with the window, or NULL on error.</param>
|
|
/// <param name="renderer">a pointer filled with the renderer, or NULL on error.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRenderer"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateWindow"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateRenderer</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="window">the window where rendering is displayed.</param>
|
|
/// <param name="name">
|
|
/// the name of the rendering driver to initialize, or NULL to let
|
|
/// SDL choose one.
|
|
/// </param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateRendererWithProperties</c>. Throws instead of returning a null
|
|
/// handle on failure.
|
|
/// </summary>
|
|
/// <param name="props">the properties to use.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlRenderer CreateRendererWithProperties(uint props)
|
|
{
|
|
SdlRenderer result = PInvoke.CreateRendererWithProperties(props);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateRendererWithProperties failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateGPURenderer</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="device">
|
|
/// the GPU device to use with the renderer, or NULL to create a
|
|
/// device.
|
|
/// </param>
|
|
/// <param name="window">
|
|
/// the window where rendering is displayed, or NULL to create an
|
|
/// offscreen renderer.
|
|
/// </param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetGPURendererDevice</c>.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlGpuDevice GetGpuRendererDevice(SdlRenderer renderer) =>
|
|
PInvoke.GetGpuRendererDevice(renderer);
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateSoftwareRenderer</c>. Throws instead of returning a null handle on
|
|
/// failure.
|
|
/// </summary>
|
|
/// <param name="surface">
|
|
/// the SDL_Surface structure representing the surface where
|
|
/// rendering is done.
|
|
/// </param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
public static SdlRenderer CreateSoftwareRenderer(SdlSurface* surface)
|
|
{
|
|
SdlRenderer result = PInvoke.CreateSoftwareRenderer(surface);
|
|
if (result.IsNull())
|
|
{
|
|
throw SdlException.FromError("SDL_CreateSoftwareRenderer failed");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetRenderer</c>.
|
|
/// </summary>
|
|
/// <param name="window">the window to query.</param>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlRenderer GetRenderer(SdlWindow window) => PInvoke.GetRenderer(window);
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetRenderWindow</c>.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to query.</param>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlWindow GetRenderWindow(SdlRenderer renderer) => PInvoke.GetRenderWindow(renderer);
|
|
|
|
/// <summary>
|
|
/// Get the name of a renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// the name of the selected renderer, or NULL on failure; call
|
|
/// SDL_GetError() for more information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// It is safe to call this function from any thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRenderer"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRendererWithProperties"/>
|
|
public static string? GetRendererName(SdlRenderer renderer) => PInvoke.GetRendererName(renderer);
|
|
|
|
/// <summary>
|
|
/// Get the properties associated with a renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// a valid property ID on success or 0 on failure; call
|
|
/// SDL_GetError() for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The following read-only properties are provided by SDL:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_NAME_STRING</c>: the name of the rendering driver
|
|
/// - <c>SDL_PROP_RENDERER_WINDOW_POINTER</c>: the window where rendering is
|
|
/// displayed, if any
|
|
/// - <c>SDL_PROP_RENDERER_SURFACE_POINTER</c>: the surface where rendering is
|
|
/// displayed, if this is a software renderer without a window
|
|
/// - <c>SDL_PROP_RENDERER_VSYNC_NUMBER</c>: the current vsync setting
|
|
/// - <c>SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER</c>: the maximum texture width
|
|
/// and height
|
|
/// - <c>SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER</c>: a (const SDL_PixelFormat *)
|
|
/// array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
|
|
/// representing the available texture formats for this renderer.
|
|
/// - <c>SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN</c>: true if the renderer
|
|
/// supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures.
|
|
/// - <c>SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER</c>: an SDL_Colorspace value
|
|
/// describing the colorspace for output to the display, defaults to
|
|
/// SDL_COLORSPACE_SRGB.
|
|
/// - <c>SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN</c>: 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.
|
|
/// - <c>SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT</c>: 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.
|
|
/// - <c>SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT</c>: 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// With the direct3d renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_D3D9_DEVICE_POINTER</c>: the IDirect3DDevice9 associated
|
|
/// with the renderer
|
|
/// </para>
|
|
/// <para>
|
|
/// With the direct3d11 renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_D3D11_DEVICE_POINTER</c>: the ID3D11Device associated
|
|
/// with the renderer
|
|
/// - <c>SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER</c>: the IDXGISwapChain1
|
|
/// associated with the renderer. This may change when the window is resized.
|
|
/// </para>
|
|
/// <para>
|
|
/// With the direct3d12 renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_D3D12_DEVICE_POINTER</c>: the ID3D12Device associated
|
|
/// with the renderer
|
|
/// - <c>SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER</c>: the IDXGISwapChain4
|
|
/// associated with the renderer.
|
|
/// - <c>SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER</c>: the ID3D12CommandQueue
|
|
/// associated with the renderer
|
|
/// </para>
|
|
/// <para>
|
|
/// With the vulkan renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER</c>: the VkInstance associated
|
|
/// with the renderer
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER</c>: the VkSurfaceKHR associated
|
|
/// with the renderer
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER</c>: the VkPhysicalDevice
|
|
/// associated with the renderer
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER</c>: the VkDevice associated with
|
|
/// the renderer
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER</c>: the queue
|
|
/// family index used for rendering
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER</c>: the queue
|
|
/// family index used for presentation
|
|
/// - <c>SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER</c>: the number of
|
|
/// swapchain images, or potential frames in flight, used by the Vulkan
|
|
/// renderer
|
|
/// </para>
|
|
/// <para>
|
|
/// With the gpu renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_RENDERER_GPU_DEVICE_POINTER</c>: the SDL_GPUDevice associated with
|
|
/// the renderer
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// It is safe to call this function from any thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
public static uint GetRendererProperties(SdlRenderer renderer) => PInvoke.GetRendererProperties(renderer);
|
|
|
|
/// <summary>
|
|
/// Get the output size in pixels of a rendering context.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="w">a pointer filled in with the width in pixels.</param>
|
|
/// <param name="h">a pointer filled in with the height in pixels.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This returns the true output size in pixels, ignoring any render targets or
|
|
/// logical size and presentation.
|
|
/// </para>
|
|
/// <para>
|
|
/// For the output size of the current rendering target, with logical size
|
|
/// adjustments, use SDL_GetCurrentRenderOutputSize() instead.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetCurrentRenderOutputSize"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the current output size in pixels of a rendering context.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="w">a pointer filled in with the current width.</param>
|
|
/// <param name="h">a pointer filled in with the current height.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// If a rendering target is active, this will return the size of the rendering
|
|
/// target in pixels, otherwise return the value of SDL_GetRenderOutputSize().
|
|
/// </para>
|
|
/// <para>
|
|
/// Rendering target or not, the output will be adjusted by the current logical
|
|
/// presentation state, dictated by SDL_SetRenderLogicalPresentation().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderOutputSize"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateTexture</c>. Throws instead of returning a null handle on failure.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="format">one of the enumerated values in SDL_PixelFormat.</param>
|
|
/// <param name="access">one of the enumerated values in SDL_TextureAccess.</param>
|
|
/// <param name="w">the width of the texture in pixels.</param>
|
|
/// <param name="h">the height of the texture in pixels.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateTextureFromSurface</c>. Throws instead of returning a null handle
|
|
/// on failure.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="surface">
|
|
/// the SDL_Surface structure containing pixel data used to fill
|
|
/// the texture.
|
|
/// </param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_CreateTextureWithProperties</c>. Throws instead of returning a null
|
|
/// handle on failure.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="props">the properties to use.</param>
|
|
/// <returns>The created handle (never a null handle).</returns>
|
|
/// <exception cref="SdlException">The SDL call failed; the message carries the
|
|
/// <c>SDL_GetError</c> text.</exception>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the properties associated with a texture.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <returns>
|
|
/// a valid property ID on success or 0 on failure; call
|
|
/// SDL_GetError() for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The following read-only properties are provided by SDL:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_COLORSPACE_NUMBER</c>: an SDL_Colorspace value describing
|
|
/// the texture colorspace.
|
|
/// - <c>SDL_PROP_TEXTURE_FORMAT_NUMBER</c>: one of the enumerated values in
|
|
/// SDL_PixelFormat.
|
|
/// - <c>SDL_PROP_TEXTURE_ACCESS_NUMBER</c>: one of the enumerated values in
|
|
/// SDL_TextureAccess.
|
|
/// - <c>SDL_PROP_TEXTURE_WIDTH_NUMBER</c>: the width of the texture in pixels.
|
|
/// - <c>SDL_PROP_TEXTURE_HEIGHT_NUMBER</c>: the height of the texture in pixels.
|
|
/// - <c>SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT</c>: 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.
|
|
/// - <c>SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT</c>: 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// With the direct3d11 renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER</c>: the ID3D11Texture2D associated
|
|
/// with the texture
|
|
/// - <c>SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER</c>: the ID3D11Texture2D
|
|
/// associated with the U plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER</c>: the ID3D11Texture2D
|
|
/// associated with the V plane of a YUV texture
|
|
/// </para>
|
|
/// <para>
|
|
/// With the direct3d12 renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER</c>: the ID3D12Resource associated
|
|
/// with the texture
|
|
/// - <c>SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER</c>: the ID3D12Resource associated
|
|
/// with the U plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER</c>: the ID3D12Resource associated
|
|
/// with the V plane of a YUV texture
|
|
/// </para>
|
|
/// <para>
|
|
/// With the vulkan renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER</c>: the VkImage associated with the
|
|
/// texture
|
|
/// </para>
|
|
/// <para>
|
|
/// With the opengl renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER</c>: the GLuint texture associated
|
|
/// with the texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER</c>: the GLuint texture
|
|
/// associated with the UV plane of an NV12 texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER</c>: the GLuint texture associated
|
|
/// with the U plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER</c>: the GLuint texture associated
|
|
/// with the V plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER</c>: the GLenum for the
|
|
/// texture target (<c>GL_TEXTURE_2D</c>, <c>GL_TEXTURE_RECTANGLE_ARB</c>, etc)
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT</c>: the texture coordinate width of
|
|
/// the texture (0.0 - 1.0)
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT</c>: the texture coordinate height of
|
|
/// the texture (0.0 - 1.0)
|
|
/// </para>
|
|
/// <para>
|
|
/// With the opengles2 renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER</c>: the GLuint texture
|
|
/// associated with the texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER</c>: the GLuint texture
|
|
/// associated with the UV plane of an NV12 texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER</c>: the GLuint texture
|
|
/// associated with the U plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER</c>: the GLuint texture
|
|
/// associated with the V plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER</c>: the GLenum for the
|
|
/// texture target (<c>GL_TEXTURE_2D</c>, <c>GL_TEXTURE_EXTERNAL_OES</c>, etc)
|
|
/// </para>
|
|
/// <para>
|
|
/// With the gpu renderer:
|
|
/// </para>
|
|
/// <para>
|
|
/// - <c>SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER</c>: the SDL_GPUTexture associated
|
|
/// with the texture
|
|
/// - <c>SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER</c>: the SDL_GPUTexture associated
|
|
/// with the UV plane of an NV12 texture
|
|
/// - <c>SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER</c>: the SDL_GPUTexture associated
|
|
/// with the U plane of a YUV texture
|
|
/// - <c>SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER</c>: the SDL_GPUTexture associated
|
|
/// with the V plane of a YUV texture
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// It is safe to call this function from any thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
public static uint GetTextureProperties(SdlTexture texture) => PInvoke.GetTextureProperties(texture);
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetRendererFromTexture</c>.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlRenderer GetRendererFromTexture(SdlTexture texture) =>
|
|
PInvoke.GetRendererFromTexture(texture);
|
|
|
|
/// <summary>
|
|
/// Get the size of a texture, as floating point values.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="w">
|
|
/// a pointer filled in with the width of the texture in pixels. This
|
|
/// argument can be NULL if you don't need this information.
|
|
/// </param>
|
|
/// <param name="h">
|
|
/// a pointer filled in with the height of the texture in pixels. This
|
|
/// argument can be NULL if you don't need this information.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the palette used by a texture.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="palette">the SDL_Palette structure to use.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Setting the palette keeps an internal reference to the palette, which can
|
|
/// be safely destroyed afterwards.
|
|
/// </para>
|
|
/// <para>
|
|
/// A single palette can be shared with many textures.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreatePalette"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTexturePalette"/>
|
|
public static bool SetTexturePalette(SdlTexture texture, SdlPalette* palette) =>
|
|
PInvoke.SetTexturePalette(texture, palette) != 0;
|
|
|
|
/// <summary>
|
|
/// Set an additional color value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="r">the red color value multiplied into copy operations.</param>
|
|
/// <param name="g">the green color value multiplied into copy operations.</param>
|
|
/// <param name="b">the blue color value multiplied into copy operations.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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:
|
|
/// </para>
|
|
/// <para>
|
|
/// <c>srcC = srcC * (color / 255)</c>
|
|
/// </para>
|
|
/// <para>
|
|
/// Color modulation is not always supported by the renderer; it will return
|
|
/// false if color modulation is not supported.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorModFloat"/>
|
|
public static bool SetTextureColorMod(SdlTexture texture, byte r, byte g, byte b) =>
|
|
PInvoke.SetTextureColorMod(texture, r, g, b) != 0;
|
|
|
|
/// <summary>
|
|
/// Set an additional color value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="r">the red color value multiplied into copy operations.</param>
|
|
/// <param name="g">the green color value multiplied into copy operations.</param>
|
|
/// <param name="b">the blue color value multiplied into copy operations.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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:
|
|
/// </para>
|
|
/// <para>
|
|
/// <c>srcC = srcC * color</c>
|
|
/// </para>
|
|
/// <para>
|
|
/// Color modulation is not always supported by the renderer; it will return
|
|
/// false if color modulation is not supported.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorMod"/>
|
|
public static bool SetTextureColorModFloat(SdlTexture texture, float r, float g, float b) =>
|
|
PInvoke.SetTextureColorModFloat(texture, r, g, b) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the additional color value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="r">a pointer filled in with the current red color value.</param>
|
|
/// <param name="g">a pointer filled in with the current green color value.</param>
|
|
/// <param name="b">a pointer filled in with the current blue color value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorMod"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the additional color value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="r">a pointer filled in with the current red color value.</param>
|
|
/// <param name="g">a pointer filled in with the current green color value.</param>
|
|
/// <param name="b">a pointer filled in with the current blue color value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorModFloat"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set an additional alpha value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="alpha">the source alpha value multiplied into copy operations.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// When this texture is rendered, during the copy operation the source alpha
|
|
/// value is modulated by this alpha value according to the following formula:
|
|
/// </para>
|
|
/// <para>
|
|
/// <c>srcA = srcA * (alpha / 255)</c>
|
|
/// </para>
|
|
/// <para>
|
|
/// Alpha modulation is not always supported by the renderer; it will return
|
|
/// false if alpha modulation is not supported.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorMod"/>
|
|
public static bool SetTextureAlphaMod(SdlTexture texture, byte alpha) =>
|
|
PInvoke.SetTextureAlphaMod(texture, alpha) != 0;
|
|
|
|
/// <summary>
|
|
/// Set an additional alpha value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="alpha">the source alpha value multiplied into copy operations.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// When this texture is rendered, during the copy operation the source alpha
|
|
/// value is modulated by this alpha value according to the following formula:
|
|
/// </para>
|
|
/// <para>
|
|
/// <c>srcA = srcA * alpha</c>
|
|
/// </para>
|
|
/// <para>
|
|
/// Alpha modulation is not always supported by the renderer; it will return
|
|
/// false if alpha modulation is not supported.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureColorModFloat"/>
|
|
public static bool SetTextureAlphaModFloat(SdlTexture texture, float alpha) =>
|
|
PInvoke.SetTextureAlphaModFloat(texture, alpha) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the additional alpha value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="alpha">a pointer filled in with the current alpha value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaMod"/>
|
|
public static bool GetTextureAlphaMod(SdlTexture texture, out byte alpha)
|
|
{
|
|
alpha = default;
|
|
fixed (byte* alphaPtr = &alpha)
|
|
{
|
|
return PInvoke.GetTextureAlphaMod(texture, alphaPtr) != 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the additional alpha value multiplied into render copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="alpha">a pointer filled in with the current alpha value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureAlphaMod"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureColorModFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureAlphaModFloat"/>
|
|
public static bool GetTextureAlphaModFloat(SdlTexture texture, out float alpha)
|
|
{
|
|
alpha = default;
|
|
fixed (float* alphaPtr = &alpha)
|
|
{
|
|
return PInvoke.GetTextureAlphaModFloat(texture, alphaPtr) != 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the blend mode for a texture, used by SDL_RenderTexture().
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="blendMode">the SDL_BlendMode to use for texture blending.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// If the blend mode is not supported, the closest supported mode is chosen
|
|
/// and this function returns false.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureBlendMode"/>
|
|
public static bool SetTextureBlendMode(SdlTexture texture, uint blendMode) =>
|
|
PInvoke.SetTextureBlendMode(texture, blendMode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the blend mode used for texture copy operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="blendMode">a pointer filled in with the current SDL_BlendMode.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureBlendMode"/>
|
|
public static bool GetTextureBlendMode(SdlTexture texture, uint* blendMode) =>
|
|
PInvoke.GetTextureBlendMode(texture, blendMode) != 0;
|
|
|
|
/// <summary>
|
|
/// Set the scale mode used for texture scale operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="scaleMode">the SDL_ScaleMode to use for texture scaling.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The default texture scale mode is SDL_SCALEMODE_LINEAR.
|
|
/// </para>
|
|
/// <para>
|
|
/// If the scale mode is not supported, the closest supported mode is chosen.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetTextureScaleMode"/>
|
|
public static bool SetTextureScaleMode(SdlTexture texture, SdlScaleMode scaleMode) =>
|
|
PInvoke.SetTextureScaleMode(texture, scaleMode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the scale mode used for texture scale operations.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to query.</param>
|
|
/// <param name="scaleMode">a pointer filled in with the current scale mode.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetTextureScaleMode"/>
|
|
public static bool GetTextureScaleMode(SdlTexture texture, out SdlScaleMode scaleMode)
|
|
{
|
|
scaleMode = default;
|
|
fixed (SdlScaleMode* scaleModePtr = &scaleMode)
|
|
{
|
|
return PInvoke.GetTextureScaleMode(texture, scaleModePtr) != 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the given texture rectangle with new pixel data.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="rect">
|
|
/// an SDL_Rect structure representing the area to update, or NULL
|
|
/// to update the entire texture.
|
|
/// </param>
|
|
/// <param name="pixels">the raw pixel data in the format of the texture.</param>
|
|
/// <param name="pitch">
|
|
/// the number of bytes in a row of pixel data, including padding
|
|
/// between lines.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The pixel data must be in the pixel format of the texture, which can be
|
|
/// queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
|
|
/// </para>
|
|
/// <para>
|
|
/// This is a fairly slow function, intended for use with static textures that
|
|
/// do not change often.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.LockTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UnlockTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateNVTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateYUVTexture"/>
|
|
public static bool UpdateTexture(SdlTexture texture, SdlRect* rect, void* pixels, int pitch) =>
|
|
PInvoke.UpdateTexture(texture, rect, pixels, pitch) != 0;
|
|
|
|
/// <summary>
|
|
/// Update a rectangle within a planar YV12 or IYUV texture with new pixel
|
|
/// data.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="rect">
|
|
/// a pointer to the rectangle of pixels to update, or NULL to
|
|
/// update the entire texture.
|
|
/// </param>
|
|
/// <param name="Yplane">the raw pixel data for the Y plane.</param>
|
|
/// <param name="Ypitch">
|
|
/// the number of bytes between rows of pixel data for the Y
|
|
/// plane.
|
|
/// </param>
|
|
/// <param name="Uplane">the raw pixel data for the U plane.</param>
|
|
/// <param name="Upitch">
|
|
/// the number of bytes between rows of pixel data for the U
|
|
/// plane.
|
|
/// </param>
|
|
/// <param name="Vplane">the raw pixel data for the V plane.</param>
|
|
/// <param name="Vpitch">
|
|
/// the number of bytes between rows of pixel data for the V
|
|
/// plane.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateNVTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateTexture"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Update a rectangle within a planar NV12 or NV21 texture with new pixels.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to update.</param>
|
|
/// <param name="rect">
|
|
/// a pointer to the rectangle of pixels to update, or NULL to
|
|
/// update the entire texture.
|
|
/// </param>
|
|
/// <param name="Yplane">the raw pixel data for the Y plane.</param>
|
|
/// <param name="Ypitch">
|
|
/// the number of bytes between rows of pixel data for the Y
|
|
/// plane.
|
|
/// </param>
|
|
/// <param name="UVplane">the raw pixel data for the UV plane.</param>
|
|
/// <param name="UVpitch">
|
|
/// the number of bytes between rows of pixel data for the UV
|
|
/// plane.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateYUVTexture"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Lock a portion of the texture for <b>write-only</b> pixel access.
|
|
/// </summary>
|
|
/// <param name="texture">
|
|
/// the texture to lock for access, which was created with
|
|
/// <c>SDL_TEXTUREACCESS_STREAMING</c>.
|
|
/// </param>
|
|
/// <param name="rect">
|
|
/// an SDL_Rect structure representing the area to lock for access;
|
|
/// NULL to lock the entire texture.
|
|
/// </param>
|
|
/// <param name="pixels">
|
|
/// this is filled in with a pointer to the locked pixels,
|
|
/// appropriately offset by the locked area.
|
|
/// </param>
|
|
/// <param name="pitch">
|
|
/// this is filled in with the pitch of the locked pixels; the
|
|
/// pitch is the length of one row in bytes.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false if the texture is not valid or was not
|
|
/// created with <c>SDL_TEXTUREACCESS_STREAMING</c>; call SDL_GetError()
|
|
/// for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// You must use SDL_UnlockTexture() to unlock the pixels and apply any
|
|
/// changes.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.LockTextureToSurface"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UnlockTexture"/>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lock a portion of the texture for <b>write-only</b> pixel access, and expose
|
|
/// it as a SDL surface.
|
|
/// </summary>
|
|
/// <param name="texture">
|
|
/// the texture to lock for access, which must be created with
|
|
/// <c>SDL_TEXTUREACCESS_STREAMING</c>.
|
|
/// </param>
|
|
/// <param name="rect">
|
|
/// a pointer to the rectangle to lock for access. If the rect is
|
|
/// NULL, the entire texture will be locked.
|
|
/// </param>
|
|
/// <param name="surface">
|
|
/// a pointer to an SDL surface of size <b>rect</b>. Don't assume
|
|
/// any specific pixel content.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Besides providing an SDL_Surface instead of raw pixel data, this function
|
|
/// operates like SDL_LockTexture.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// You must use SDL_UnlockTexture() to unlock the pixels and apply any
|
|
/// changes.
|
|
/// </para>
|
|
/// <para>
|
|
/// The returned surface is freed internally after calling SDL_UnlockTexture()
|
|
/// or SDL_DestroyTexture(). The caller should not free it.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.LockTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UnlockTexture"/>
|
|
public static bool LockTextureToSurface(SdlTexture texture, SdlRect* rect, SdlSurface** surface) =>
|
|
PInvoke.LockTextureToSurface(texture, rect, surface) != 0;
|
|
|
|
/// <summary>
|
|
/// Unlock a texture, uploading the changes to video memory, if needed.
|
|
/// </summary>
|
|
/// <param name="texture">a texture locked by SDL_LockTexture().</param>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// <b>Warning</b>: 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Which is to say: locking and immediately unlocking a texture can result in
|
|
/// corrupted textures, depending on the renderer in use.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.LockTexture"/>
|
|
public static void UnlockTexture(SdlTexture texture) => PInvoke.UnlockTexture(texture);
|
|
|
|
/// <summary>
|
|
/// Set a texture as the current rendering target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="texture">
|
|
/// the targeted texture, which must be created with the
|
|
/// <c>SDL_TEXTUREACCESS_TARGET</c> flag, or NULL to render to the
|
|
/// window instead of a texture.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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 <c>texture</c>.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderTarget"/>
|
|
public static bool SetRenderTarget(SdlRenderer renderer, SdlTexture texture) =>
|
|
PInvoke.SetRenderTarget(renderer, texture) != 0;
|
|
|
|
/// <summary>
|
|
/// Ergonomic wrapper over <c>SDL_GetRenderTarget</c>.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <remarks>
|
|
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
|
|
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
|
|
/// this call does not own. A null handle is returned on failure.
|
|
/// </remarks>
|
|
public static SdlTexture GetRenderTarget(SdlRenderer renderer) => PInvoke.GetRenderTarget(renderer);
|
|
|
|
/// <summary>
|
|
/// Set a device-independent resolution and presentation mode for rendering.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="w">the width of the logical resolution.</param>
|
|
/// <param name="h">the height of the logical resolution.</param>
|
|
/// <param name="mode">the presentation mode used.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// You can convert coordinates in an event into rendering coordinates using
|
|
/// SDL_ConvertEventToRenderCoordinates().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.ConvertEventToRenderCoordinates"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderLogicalPresentation"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderLogicalPresentationRect"/>
|
|
public static bool SetRenderLogicalPresentation(
|
|
SdlRenderer renderer,
|
|
int w,
|
|
int h,
|
|
SdlRendererLogicalPresentation mode
|
|
) => PInvoke.SetRenderLogicalPresentation(renderer, w, h, mode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get device independent resolution and presentation mode for rendering.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="w">an int filled with the logical presentation width.</param>
|
|
/// <param name="h">an int filled with the logical presentation height.</param>
|
|
/// <param name="mode">
|
|
/// a variable filled with the logical presentation mode being
|
|
/// used.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function gets the width and height of the logical rendering output, or
|
|
/// 0 if a logical resolution is not enabled.
|
|
/// </para>
|
|
/// <para>
|
|
/// Each render target has its own logical presentation state. This function
|
|
/// gets the state for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderLogicalPresentation"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the final presentation rectangle for rendering.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">
|
|
/// a pointer filled in with the final presentation rectangle, may
|
|
/// be NULL.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Each render target has its own logical presentation state. This function
|
|
/// gets the rectangle for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderLogicalPresentation"/>
|
|
public static bool GetRenderLogicalPresentationRect(SdlRenderer renderer, SdlFRect* rect) =>
|
|
PInvoke.GetRenderLogicalPresentationRect(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Get a point in render coordinates when given a point in window coordinates.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="window_x">the x coordinate in window coordinates.</param>
|
|
/// <param name="window_y">the y coordinate in window coordinates.</param>
|
|
/// <param name="x">a pointer filled with the x coordinate in render coordinates.</param>
|
|
/// <param name="y">a pointer filled with the y coordinate in render coordinates.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This takes into account several states:
|
|
/// </para>
|
|
/// <para>
|
|
/// - The window dimensions.
|
|
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
|
|
/// - The scale (SDL_SetRenderScale)
|
|
/// - The viewport (SDL_SetRenderViewport)
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderLogicalPresentation"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderScale"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get a point in window coordinates when given a point in render coordinates.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="x">the x coordinate in render coordinates.</param>
|
|
/// <param name="y">the y coordinate in render coordinates.</param>
|
|
/// <param name="window_x">
|
|
/// a pointer filled with the x coordinate in window
|
|
/// coordinates.
|
|
/// </param>
|
|
/// <param name="window_y">
|
|
/// a pointer filled with the y coordinate in window
|
|
/// coordinates.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This takes into account several states:
|
|
/// </para>
|
|
/// <para>
|
|
/// - The window dimensions.
|
|
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
|
|
/// - The scale (SDL_SetRenderScale)
|
|
/// - The viewport (SDL_SetRenderViewport)
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderLogicalPresentation"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderScale"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderViewport"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Convert the coordinates in an event to render coordinates.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="event">the event to modify.</param>
|
|
/// <returns>
|
|
/// true if the event is converted or doesn't need conversion, or
|
|
/// false on failure; call SDL_GetError() for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This takes into account several states:
|
|
/// </para>
|
|
/// <para>
|
|
/// - The window dimensions.
|
|
/// - The logical presentation settings (SDL_SetRenderLogicalPresentation)
|
|
/// - The scale (SDL_SetRenderScale)
|
|
/// - The viewport (SDL_SetRenderViewport)
|
|
/// </para>
|
|
/// <para>
|
|
/// Various event types are converted with this function: mouse, touch, pen,
|
|
/// etc.
|
|
/// </para>
|
|
/// <para>
|
|
/// Touch coordinates are converted from normalized coordinates in the window
|
|
/// to non-normalized rendering coordinates.
|
|
/// </para>
|
|
/// <para>
|
|
/// Relative mouse coordinates (xrel and yrel event fields) are <em>also</em>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Once converted, coordinates may be outside the rendering area.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderCoordinatesFromWindow"/>
|
|
public static bool ConvertEventToRenderCoordinates(SdlRenderer renderer, SdlEvent* @event) =>
|
|
PInvoke.ConvertEventToRenderCoordinates(renderer, @event) != 0;
|
|
|
|
/// <summary>
|
|
/// Set the drawing area for rendering on the current target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">
|
|
/// the SDL_Rect structure representing the drawing area, or NULL
|
|
/// to set the viewport to the entire target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// The area's width and height must be >= 0.
|
|
/// </para>
|
|
/// <para>
|
|
/// Each render target has its own viewport. This function sets the viewport
|
|
/// for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderViewport"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderViewportSet"/>
|
|
public static bool SetRenderViewport(SdlRenderer renderer, SdlRect* rect) =>
|
|
PInvoke.SetRenderViewport(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the drawing area for the current target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">an SDL_Rect structure filled in with the current drawing area.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Each render target has its own viewport. This function gets the viewport
|
|
/// for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderViewportSet"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderViewport"/>
|
|
public static bool GetRenderViewport(SdlRenderer renderer, SdlRect* rect) =>
|
|
PInvoke.GetRenderViewport(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Return whether an explicit rectangle was set as the viewport.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// true if the viewport was set to a specific rectangle, or false if
|
|
/// it was set to NULL (the entire target).
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This is useful if you're saving and restoring the viewport and want to know
|
|
/// whether you should restore a specific rectangle or NULL.
|
|
/// </para>
|
|
/// <para>
|
|
/// Each render target has its own viewport. This function checks the viewport
|
|
/// for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderViewport"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderViewport"/>
|
|
public static bool RenderViewportSet(SdlRenderer renderer) => PInvoke.RenderViewportSet(renderer) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the safe area for rendering within the current viewport.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">
|
|
/// a pointer filled in with the area that is safe for interactive
|
|
/// content.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
public static bool GetRenderSafeArea(SdlRenderer renderer, SdlRect* rect) =>
|
|
PInvoke.GetRenderSafeArea(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Set the clip rectangle for rendering on the specified target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">
|
|
/// an SDL_Rect structure representing the clip area, relative to
|
|
/// the viewport, or NULL to disable clipping.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Each render target has its own clip rectangle. This function sets the
|
|
/// cliprect for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderClipRect"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderClipEnabled"/>
|
|
public static bool SetRenderClipRect(SdlRenderer renderer, SdlRect* rect) =>
|
|
PInvoke.SetRenderClipRect(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the clip rectangle for the current target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="rect">
|
|
/// an SDL_Rect structure filled in with the current clipping area
|
|
/// or an empty rectangle if clipping is disabled.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Each render target has its own clip rectangle. This function gets the
|
|
/// cliprect for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderClipEnabled"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderClipRect"/>
|
|
public static bool GetRenderClipRect(SdlRenderer renderer, SdlRect* rect) =>
|
|
PInvoke.GetRenderClipRect(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Get whether clipping is enabled on the given render target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// true if clipping is enabled or false if not; call SDL_GetError()
|
|
/// for more information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Each render target has its own clip rectangle. This function checks the
|
|
/// cliprect for the current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderClipRect"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderClipRect"/>
|
|
public static bool RenderClipEnabled(SdlRenderer renderer) => PInvoke.RenderClipEnabled(renderer) != 0;
|
|
|
|
/// <summary>
|
|
/// Set the drawing scale for rendering on the current target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="scaleX">the horizontal scaling factor.</param>
|
|
/// <param name="scaleY">the vertical scaling factor.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Each render target has its own scale. This function sets the scale for the
|
|
/// current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderScale"/>
|
|
public static bool SetRenderScale(SdlRenderer renderer, float scaleX, float scaleY) =>
|
|
PInvoke.SetRenderScale(renderer, scaleX, scaleY) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the drawing scale for the current target.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="scaleX">a pointer filled in with the horizontal scaling factor.</param>
|
|
/// <param name="scaleY">a pointer filled in with the vertical scaling factor.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Each render target has its own scale. This function gets the scale for the
|
|
/// current render target.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderScale"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the color used for drawing operations.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="r">the red value used to draw on the rendering target.</param>
|
|
/// <param name="g">the green value used to draw on the rendering target.</param>
|
|
/// <param name="b">the blue value used to draw on the rendering target.</param>
|
|
/// <param name="a">
|
|
/// the alpha value used to draw on the rendering target; usually
|
|
/// <c>SDL_ALPHA_OPAQUE</c> (255). Use SDL_SetRenderDrawBlendMode to
|
|
/// specify how the alpha channel is used.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Set the color for drawing or filling rectangles, lines, and points, and for
|
|
/// SDL_RenderClear().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDrawColor"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColorFloat"/>
|
|
public static bool SetRenderDrawColor(SdlRenderer renderer, byte r, byte g, byte b, byte a) =>
|
|
PInvoke.SetRenderDrawColor(renderer, r, g, b, a) != 0;
|
|
|
|
/// <summary>
|
|
/// Set the color used for drawing operations (Rect, Line and Clear).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="r">the red value used to draw on the rendering target.</param>
|
|
/// <param name="g">the green value used to draw on the rendering target.</param>
|
|
/// <param name="b">the blue value used to draw on the rendering target.</param>
|
|
/// <param name="a">
|
|
/// the alpha value used to draw on the rendering target. Use
|
|
/// SDL_SetRenderDrawBlendMode to specify how the alpha channel is
|
|
/// used.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Set the color for drawing or filling rectangles, lines, and points, and for
|
|
/// SDL_RenderClear().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDrawColorFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColor"/>
|
|
public static bool SetRenderDrawColorFloat(SdlRenderer renderer, float r, float g, float b, float a) =>
|
|
PInvoke.SetRenderDrawColorFloat(renderer, r, g, b, a) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the color used for drawing operations (Rect, Line and Clear).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="r">
|
|
/// a pointer filled in with the red value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="g">
|
|
/// a pointer filled in with the green value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="b">
|
|
/// a pointer filled in with the blue value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="a">
|
|
/// a pointer filled in with the alpha value used to draw on the
|
|
/// rendering target; usually <c>SDL_ALPHA_OPAQUE</c> (255).
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDrawColorFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColor"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the color used for drawing operations (Rect, Line and Clear).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="r">
|
|
/// a pointer filled in with the red value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="g">
|
|
/// a pointer filled in with the green value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="b">
|
|
/// a pointer filled in with the blue value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <param name="a">
|
|
/// a pointer filled in with the alpha value used to draw on the
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColorFloat"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDrawColor"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the color scale used for render operations.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="scale">the color scale value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// The color scale does not affect the alpha channel, only the color
|
|
/// brightness.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderColorScale"/>
|
|
public static bool SetRenderColorScale(SdlRenderer renderer, float scale) =>
|
|
PInvoke.SetRenderColorScale(renderer, scale) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the color scale used for render operations.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="scale">a pointer filled in with the current color scale value.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderColorScale"/>
|
|
public static bool GetRenderColorScale(SdlRenderer renderer, out float scale)
|
|
{
|
|
scale = default;
|
|
fixed (float* scalePtr = &scale)
|
|
{
|
|
return PInvoke.GetRenderColorScale(renderer, scalePtr) != 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the blend mode used for drawing operations (Fill and Line).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="blendMode">the SDL_BlendMode to use for blending.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// If the blend mode is not supported, the closest supported mode is chosen.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderDrawBlendMode"/>
|
|
public static bool SetRenderDrawBlendMode(SdlRenderer renderer, uint blendMode) =>
|
|
PInvoke.SetRenderDrawBlendMode(renderer, blendMode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the blend mode used for drawing operations.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="blendMode">a pointer filled in with the current SDL_BlendMode.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawBlendMode"/>
|
|
public static bool GetRenderDrawBlendMode(SdlRenderer renderer, uint* blendMode) =>
|
|
PInvoke.GetRenderDrawBlendMode(renderer, blendMode) != 0;
|
|
|
|
/// <summary>
|
|
/// Clear the current rendering target with the drawing color.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColor"/>
|
|
public static bool RenderClear(SdlRenderer renderer) => PInvoke.RenderClear(renderer) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw a point on the current rendering target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw a point.</param>
|
|
/// <param name="x">the x coordinate of the point.</param>
|
|
/// <param name="y">the y coordinate of the point.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderPoints"/>
|
|
public static bool RenderPoint(SdlRenderer renderer, float x, float y) =>
|
|
PInvoke.RenderPoint(renderer, x, y) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw multiple points on the current rendering target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw multiple points.</param>
|
|
/// <param name="points">the points to draw.</param>
|
|
/// <param name="count">the number of points to draw.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderPoint"/>
|
|
public static bool RenderPoints(SdlRenderer renderer, SdlFPoint* points, int count) =>
|
|
PInvoke.RenderPoints(renderer, points, count) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw a line on the current rendering target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw a line.</param>
|
|
/// <param name="x1">the x coordinate of the start point.</param>
|
|
/// <param name="y1">the y coordinate of the start point.</param>
|
|
/// <param name="x2">the x coordinate of the end point.</param>
|
|
/// <param name="y2">the y coordinate of the end point.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderLines"/>
|
|
public static bool RenderLine(SdlRenderer renderer, float x1, float y1, float x2, float y2) =>
|
|
PInvoke.RenderLine(renderer, x1, y1, x2, y2) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw a series of connected lines on the current rendering target at
|
|
/// subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw multiple lines.</param>
|
|
/// <param name="points">the points along the lines.</param>
|
|
/// <param name="count">the number of points, drawing count-1 lines.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderLine"/>
|
|
public static bool RenderLines(SdlRenderer renderer, SdlFPoint* points, int count) =>
|
|
PInvoke.RenderLines(renderer, points, count) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw a rectangle on the current rendering target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw a rectangle.</param>
|
|
/// <param name="rect">
|
|
/// a pointer to the destination rectangle, or NULL to outline the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderRects"/>
|
|
public static bool RenderRect(SdlRenderer renderer, SdlFRect* rect) =>
|
|
PInvoke.RenderRect(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Draw some number of rectangles on the current rendering target at subpixel
|
|
/// precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw multiple rectangles.</param>
|
|
/// <param name="rects">a pointer to an array of destination rectangles.</param>
|
|
/// <param name="count">the number of rectangles.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderRect"/>
|
|
public static bool RenderRects(SdlRenderer renderer, SdlFRect* rects, int count) =>
|
|
PInvoke.RenderRects(renderer, rects, count) != 0;
|
|
|
|
/// <summary>
|
|
/// Fill a rectangle on the current rendering target with the drawing color at
|
|
/// subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should fill a rectangle.</param>
|
|
/// <param name="rect">
|
|
/// a pointer to the destination rectangle, or NULL for the entire
|
|
/// rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderFillRects"/>
|
|
public static bool RenderFillRect(SdlRenderer renderer, SdlFRect* rect) =>
|
|
PInvoke.RenderFillRect(renderer, rect) != 0;
|
|
|
|
/// <summary>
|
|
/// Fill some number of rectangles on the current rendering target with the
|
|
/// drawing color at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should fill multiple rectangles.</param>
|
|
/// <param name="rects">a pointer to an array of destination rectangles.</param>
|
|
/// <param name="count">the number of rectangles.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderFillRect"/>
|
|
public static bool RenderFillRects(SdlRenderer renderer, SdlFRect* rects, int count) =>
|
|
PInvoke.RenderFillRects(renderer, rects, count) != 0;
|
|
|
|
/// <summary>
|
|
/// Copy a portion of the texture to the current rendering target at subpixel
|
|
/// precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// a pointer to the source rectangle, or NULL for the entire
|
|
/// texture.
|
|
/// </param>
|
|
/// <param name="dstrect">
|
|
/// a pointer to the destination rectangle, or NULL for the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTextureRotated"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTextureTiled"/>
|
|
public static bool RenderTexture(
|
|
SdlRenderer renderer,
|
|
SdlTexture texture,
|
|
SdlFRect* srcrect,
|
|
SdlFRect* dstrect
|
|
) => PInvoke.RenderTexture(renderer, texture, srcrect, dstrect) != 0;
|
|
|
|
/// <summary>
|
|
/// Copy a portion of the source texture to the current rendering target, with
|
|
/// rotation and flipping, at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// a pointer to the source rectangle, or NULL for the entire
|
|
/// texture.
|
|
/// </param>
|
|
/// <param name="dstrect">
|
|
/// a pointer to the destination rectangle, or NULL for the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <param name="angle">
|
|
/// an angle in degrees that indicates the rotation that will be
|
|
/// applied to dstrect, rotating it in a clockwise direction.
|
|
/// </param>
|
|
/// <param name="center">
|
|
/// 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).
|
|
/// </param>
|
|
/// <param name="flip">
|
|
/// an SDL_FlipMode value stating which flipping actions should be
|
|
/// performed on the texture.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Copy a portion of the source texture to the current rendering target, with
|
|
/// affine transform, at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// a pointer to the source rectangle, or NULL for the entire
|
|
/// texture.
|
|
/// </param>
|
|
/// <param name="origin">
|
|
/// 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.
|
|
/// </param>
|
|
/// <param name="right">
|
|
/// 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.
|
|
/// </param>
|
|
/// <param name="down">
|
|
/// 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.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// You may only call this function from the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Tile a portion of the texture to the current rendering target at subpixel
|
|
/// precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// a pointer to the source rectangle, or NULL for the entire
|
|
/// texture.
|
|
/// </param>
|
|
/// <param name="scale">
|
|
/// the scale used to transform srcrect into the destination
|
|
/// rectangle, e.g. a 32x32 texture with a scale of 2 would fill
|
|
/// 64x64 tiles.
|
|
/// </param>
|
|
/// <param name="dstrect">
|
|
/// a pointer to the destination rectangle, or NULL for the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The pixels in <c>srcrect</c> will be repeated as many times as needed to
|
|
/// completely fill <c>dstrect</c>.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture"/>
|
|
public static bool RenderTextureTiled(
|
|
SdlRenderer renderer,
|
|
SdlTexture texture,
|
|
SdlFRect* srcrect,
|
|
float scale,
|
|
SdlFRect* dstrect
|
|
) => PInvoke.RenderTextureTiled(renderer, texture, srcrect, scale, dstrect) != 0;
|
|
|
|
/// <summary>
|
|
/// Perform a scaled copy using the 9-grid algorithm to the current rendering
|
|
/// target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// the SDL_Rect structure representing the rectangle to be used
|
|
/// for the 9-grid, or NULL to use the entire texture.
|
|
/// </param>
|
|
/// <param name="left_width">the width, in pixels, of the left corners in <c>srcrect</c>.</param>
|
|
/// <param name="right_width">the width, in pixels, of the right corners in <c>srcrect</c>.</param>
|
|
/// <param name="top_height">the height, in pixels, of the top corners in <c>srcrect</c>.</param>
|
|
/// <param name="bottom_height">
|
|
/// the height, in pixels, of the bottom corners in
|
|
/// <c>srcrect</c>.
|
|
/// </param>
|
|
/// <param name="scale">
|
|
/// the scale used to transform the corner of <c>srcrect</c> into the
|
|
/// corner of <c>dstrect</c>, or 0.0f for an unscaled copy.
|
|
/// </param>
|
|
/// <param name="dstrect">
|
|
/// a pointer to the destination rectangle, or NULL for the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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 <c>scale</c> and fit into
|
|
/// the corners of the destination rectangle. The sides and center are then
|
|
/// stretched into place to cover the remaining destination rectangle.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture9GridTiled"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Perform a scaled copy using the 9-grid algorithm to the current rendering
|
|
/// target at subpixel precision.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should copy parts of a texture.</param>
|
|
/// <param name="texture">the source texture.</param>
|
|
/// <param name="srcrect">
|
|
/// the SDL_Rect structure representing the rectangle to be used
|
|
/// for the 9-grid, or NULL to use the entire texture.
|
|
/// </param>
|
|
/// <param name="left_width">the width, in pixels, of the left corners in <c>srcrect</c>.</param>
|
|
/// <param name="right_width">the width, in pixels, of the right corners in <c>srcrect</c>.</param>
|
|
/// <param name="top_height">the height, in pixels, of the top corners in <c>srcrect</c>.</param>
|
|
/// <param name="bottom_height">
|
|
/// the height, in pixels, of the bottom corners in
|
|
/// <c>srcrect</c>.
|
|
/// </param>
|
|
/// <param name="scale">
|
|
/// the scale used to transform the corner of <c>srcrect</c> into the
|
|
/// corner of <c>dstrect</c>, or 0.0f for an unscaled copy.
|
|
/// </param>
|
|
/// <param name="dstrect">
|
|
/// a pointer to the destination rectangle, or NULL for the
|
|
/// entire rendering target.
|
|
/// </param>
|
|
/// <param name="tileScale">
|
|
/// the scale used to transform the borders and center of
|
|
/// <c>srcrect</c> into the borders and middle of <c>dstrect</c>, or
|
|
/// 1.0f for an unscaled copy.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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 <c>scale</c> and fit into
|
|
/// the corners of the destination rectangle. The sides and center are then
|
|
/// tiled into place to cover the remaining destination rectangle.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderTexture9Grid"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// 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).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="texture">(optional) The SDL texture to use.</param>
|
|
/// <param name="vertices">vertices.</param>
|
|
/// <param name="num_vertices">number of vertices.</param>
|
|
/// <param name="indices">
|
|
/// (optional) An array of integer indices into the 'vertices'
|
|
/// array, if NULL all vertices will be rendered in sequential
|
|
/// order.
|
|
/// </param>
|
|
/// <param name="num_indices">number of indices.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderGeometryRaw"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderTextureAddressMode"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// 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).
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="texture">(optional) The SDL texture to use.</param>
|
|
/// <param name="xy">vertex positions.</param>
|
|
/// <param name="xy_stride">byte size to move from one element to the next element.</param>
|
|
/// <param name="color">vertex colors (as SDL_FColor).</param>
|
|
/// <param name="color_stride">byte size to move from one element to the next element.</param>
|
|
/// <param name="uv">vertex normalized texture coordinates.</param>
|
|
/// <param name="uv_stride">byte size to move from one element to the next element.</param>
|
|
/// <param name="num_vertices">number of vertices.</param>
|
|
/// <param name="indices">
|
|
/// (optional) An array of indices into the 'vertices' arrays,
|
|
/// if NULL all vertices will be rendered in sequential order.
|
|
/// </param>
|
|
/// <param name="num_indices">number of indices.</param>
|
|
/// <param name="size_indices">index size: 1 (byte), 2 (short), 4 (int).</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderGeometry"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderTextureAddressMode"/>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Set the texture addressing mode used in SDL_RenderGeometry().
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="u_mode">
|
|
/// the SDL_TextureAddressMode to use for horizontal texture
|
|
/// coordinates in SDL_RenderGeometry().
|
|
/// </param>
|
|
/// <param name="v_mode">
|
|
/// the SDL_TextureAddressMode to use for vertical texture
|
|
/// coordinates in SDL_RenderGeometry().
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderGeometry"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderGeometryRaw"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderTextureAddressMode"/>
|
|
public static bool SetRenderTextureAddressMode(
|
|
SdlRenderer renderer,
|
|
SdlTextureAddressMode u_mode,
|
|
SdlTextureAddressMode v_mode
|
|
) => PInvoke.SetRenderTextureAddressMode(renderer, u_mode, v_mode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get the texture addressing mode used in SDL_RenderGeometry().
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="u_mode">
|
|
/// a pointer filled in with the SDL_TextureAddressMode to use
|
|
/// for horizontal texture coordinates in SDL_RenderGeometry(),
|
|
/// may be NULL.
|
|
/// </param>
|
|
/// <param name="v_mode">
|
|
/// a pointer filled in with the SDL_TextureAddressMode to use
|
|
/// for vertical texture coordinates in SDL_RenderGeometry(), may
|
|
/// be NULL.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderTextureAddressMode"/>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the screen with any rendering performed since the previous call.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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 <em>present</em> the composed backbuffer to the screen as a
|
|
/// complete picture.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Please note, that in case of rendering to a texture - there is <b>no need</b>
|
|
/// to call <c>SDL_RenderPresent</c> 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 <c>SDL_SetRenderTarget(renderer, NULL)</c> afterwards, as
|
|
/// textures by themselves do not have a concept of backbuffers. Calling
|
|
/// SDL_RenderPresent while rendering to a texture will fail.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRenderer"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderClear"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderFillRect"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderFillRects"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderLine"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderLines"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderPoint"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderPoints"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderRect"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RenderRects"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawBlendMode"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderDrawColor"/>
|
|
public static bool RenderPresent(SdlRenderer renderer) => PInvoke.RenderPresent(renderer) != 0;
|
|
|
|
/// <summary>
|
|
/// Destroy the specified texture.
|
|
/// </summary>
|
|
/// <param name="texture">the texture to destroy.</param>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Passing NULL or an otherwise invalid texture will set the SDL error message
|
|
/// to "Invalid texture".
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateTexture"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateTextureFromSurface"/>
|
|
public static void DestroyTexture(SdlTexture texture) => PInvoke.DestroyTexture(texture);
|
|
|
|
/// <summary>
|
|
/// Destroy the rendering context for a window and free all associated
|
|
/// textures.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This should be called before destroying the associated window.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateRenderer"/>
|
|
public static void DestroyRenderer(SdlRenderer renderer) => PInvoke.DestroyRenderer(renderer);
|
|
|
|
/// <summary>
|
|
/// Force the rendering context to flush any pending commands and state.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// In all other cases, you can ignore this function.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
public static bool FlushRenderer(SdlRenderer renderer) => PInvoke.FlushRenderer(renderer) != 0;
|
|
|
|
/// <summary>
|
|
/// Add a set of synchronization semaphores for the current frame.
|
|
/// </summary>
|
|
/// <param name="renderer">the rendering context.</param>
|
|
/// <param name="wait_stage_mask">the VkPipelineStageFlags for the wait.</param>
|
|
/// <param name="wait_semaphore">
|
|
/// a VkSempahore to wait on before rendering the current
|
|
/// frame, or 0 if not needed.
|
|
/// </param>
|
|
/// <param name="signal_semaphore">
|
|
/// a VkSempahore that SDL will signal when rendering
|
|
/// for the current frame is complete, or 0 if not
|
|
/// needed.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The Vulkan renderer will wait for <c>wait_semaphore</c> before submitting
|
|
/// rendering commands and signal <c>signal_semaphore</c> after rendering commands
|
|
/// are complete for this frame.
|
|
/// </para>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// It is <b>NOT</b> safe to call this function from two threads at
|
|
/// once.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Toggle VSync of the given renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to toggle.</param>
|
|
/// <param name="vsync">the vertical refresh sync interval.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
|
|
/// </para>
|
|
/// <para>
|
|
/// The <c>vsync</c> 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRenderVSync"/>
|
|
public static bool SetRenderVSync(SdlRenderer renderer, int vsync) =>
|
|
PInvoke.SetRenderVSync(renderer, vsync) != 0;
|
|
|
|
/// <summary>
|
|
/// Get VSync of the given renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to toggle.</param>
|
|
/// <param name="vsync">
|
|
/// an int filled with the current vertical refresh sync interval.
|
|
/// See SDL_SetRenderVSync() for the meaning of the value.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetRenderVSync"/>
|
|
public static bool GetRenderVSync(SdlRenderer renderer, out int vsync)
|
|
{
|
|
vsync = default;
|
|
fixed (int* vsyncPtr = &vsync)
|
|
{
|
|
return PInvoke.GetRenderVSync(renderer, vsyncPtr) != 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draw debug text to an SDL_Renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer which should draw a line of text.</param>
|
|
/// <param name="x">the x coordinate where the top-left corner of the text will draw.</param>
|
|
/// <param name="y">the y coordinate where the top-left corner of the text will draw.</param>
|
|
/// <param name="str">the string to render.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// Among these limitations:
|
|
/// </para>
|
|
/// <para>
|
|
/// - 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// For serious text rendering, there are several good options, such as
|
|
/// SDL_ttf, stb_truetype, or other external libraries.
|
|
/// </para>
|
|
/// <para>
|
|
/// On first use, this will create an internal texture for rendering glyphs.
|
|
/// This texture will live until the renderer is destroyed.
|
|
/// </para>
|
|
/// <para>
|
|
/// The text is drawn in the color specified by SDL_SetRenderDrawColor().
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.2.0.
|
|
/// </since>
|
|
public static bool RenderDebugText(SdlRenderer renderer, float x, float y, string str) =>
|
|
PInvoke.RenderDebugText(renderer, x, y, str) != 0;
|
|
|
|
/// <summary>
|
|
/// Set default scale mode for new textures for given renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to update.</param>
|
|
/// <param name="scale_mode">the scale mode to change to for new textures.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetDefaultTextureScaleMode"/>
|
|
public static bool SetDefaultTextureScaleMode(SdlRenderer renderer, SdlScaleMode scale_mode) =>
|
|
PInvoke.SetDefaultTextureScaleMode(renderer, scale_mode) != 0;
|
|
|
|
/// <summary>
|
|
/// Get default texture scale mode of the given renderer.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to get data from.</param>
|
|
/// <param name="scale_mode">
|
|
/// a SDL_ScaleMode filled with current default scale mode.
|
|
/// See SDL_SetDefaultTextureScaleMode() for the meaning of
|
|
/// the value.
|
|
/// </param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should only be called on the main thread.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetDefaultTextureScaleMode"/>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create custom GPU render state.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to use.</param>
|
|
/// <param name="createinfo">a struct describing the GPU render state to create.</param>
|
|
/// <returns>
|
|
/// a custom GPU render state or NULL on failure; call SDL_GetError()
|
|
/// for more information.
|
|
/// </returns>
|
|
/// <threadsafety>
|
|
/// This function should be called on the thread that created the
|
|
/// renderer.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGpuRenderStateFragmentUniforms"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGpuRenderState"/>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.DestroyGpuRenderState"/>
|
|
public static nint CreateGpuRenderState(SdlRenderer renderer, SdlGpuRenderStateCreateInfo* createinfo) =>
|
|
PInvoke.CreateGpuRenderState(renderer, createinfo);
|
|
|
|
/// <summary>
|
|
/// Set fragment shader uniform variables in a custom GPU render state.
|
|
/// </summary>
|
|
/// <param name="state">the state to modify.</param>
|
|
/// <param name="slot_index">the fragment uniform slot to push data to.</param>
|
|
/// <param name="data">client data to write.</param>
|
|
/// <param name="length">the length of the data to write.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The data is copied and will be pushed using
|
|
/// SDL_PushGPUFragmentUniformData() during draw call execution.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should be called on the thread that created the
|
|
/// renderer.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
public static bool SetGpuRenderStateFragmentUniforms(
|
|
nint state,
|
|
uint slot_index,
|
|
void* data,
|
|
uint length
|
|
) => PInvoke.SetGpuRenderStateFragmentUniforms(state, slot_index, data, length) != 0;
|
|
|
|
/// <summary>
|
|
/// Set custom GPU render state.
|
|
/// </summary>
|
|
/// <param name="renderer">the renderer to use.</param>
|
|
/// <param name="state">the state to to use, or NULL to clear custom GPU render state.</param>
|
|
/// <returns>
|
|
/// true on success or false on failure; call SDL_GetError() for more
|
|
/// information.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// This function sets custom GPU render state for subsequent draw calls. This
|
|
/// allows using custom shaders with the GPU renderer.
|
|
/// </para>
|
|
/// </remarks>
|
|
/// <threadsafety>
|
|
/// This function should be called on the thread that created the
|
|
/// renderer.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
public static bool SetGpuRenderState(SdlRenderer renderer, nint state) =>
|
|
PInvoke.SetGpuRenderState(renderer, state) != 0;
|
|
|
|
/// <summary>
|
|
/// Destroy custom GPU render state.
|
|
/// </summary>
|
|
/// <param name="state">the state to destroy.</param>
|
|
/// <threadsafety>
|
|
/// This function should be called on the thread that created the
|
|
/// renderer.
|
|
/// </threadsafety>
|
|
/// <since>
|
|
/// This function is available since SDL 3.4.0.
|
|
/// </since>
|
|
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.CreateGpuRenderState"/>
|
|
public static void DestroyGpuRenderState(nint state) => PInvoke.DestroyGpuRenderState(state);
|
|
}
|
|
}
|
|
}
|