mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-23 07:45:38 +00:00
Finalized the SDL render API colorspaces
The renderer will always use the sRGB colorspace for drawing, and will default to the sRGB output colorspace. If you want blending in linear space and HDR support, you can select the scRGB output colorspace, which is supported by the direct3d11 and direct3d12
This commit is contained in:
@@ -558,6 +558,8 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_COLORSPACE_UNKNOWN,
|
||||
|
||||
/* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */
|
||||
SDL_COLORSPACE_SRGB = /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
|
||||
SDL_COLOR_RANGE_FULL,
|
||||
@@ -565,6 +567,8 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_SRGB,
|
||||
SDL_MATRIX_COEFFICIENTS_UNSPECIFIED,
|
||||
SDL_CHROMA_LOCATION_NONE),
|
||||
|
||||
/* scRGB is a linear colorspace and the default colorspace for floating point surfaces */
|
||||
SDL_COLORSPACE_SCRGB = /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
|
||||
SDL_COLOR_RANGE_FULL,
|
||||
@@ -572,6 +576,8 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_LINEAR,
|
||||
SDL_MATRIX_COEFFICIENTS_UNSPECIFIED,
|
||||
SDL_CHROMA_LOCATION_NONE),
|
||||
|
||||
/* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */
|
||||
SDL_COLORSPACE_HDR10 = /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB,
|
||||
SDL_COLOR_RANGE_FULL,
|
||||
@@ -579,6 +585,7 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_PQ,
|
||||
SDL_MATRIX_COEFFICIENTS_UNSPECIFIED,
|
||||
SDL_CHROMA_LOCATION_NONE),
|
||||
|
||||
SDL_COLORSPACE_BT601_LIMITED = /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
|
||||
SDL_COLOR_RANGE_LIMITED,
|
||||
@@ -586,6 +593,7 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_BT601,
|
||||
SDL_MATRIX_COEFFICIENTS_BT601,
|
||||
SDL_CHROMA_LOCATION_LEFT),
|
||||
|
||||
SDL_COLORSPACE_BT601_FULL = /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
|
||||
SDL_COLOR_RANGE_FULL,
|
||||
@@ -593,6 +601,7 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_BT601,
|
||||
SDL_MATRIX_COEFFICIENTS_BT601,
|
||||
SDL_CHROMA_LOCATION_LEFT),
|
||||
|
||||
SDL_COLORSPACE_BT709_LIMITED = /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
|
||||
SDL_COLOR_RANGE_LIMITED,
|
||||
@@ -600,6 +609,7 @@ typedef enum
|
||||
SDL_TRANSFER_CHARACTERISTICS_BT709,
|
||||
SDL_MATRIX_COEFFICIENTS_BT709,
|
||||
SDL_CHROMA_LOCATION_LEFT),
|
||||
|
||||
SDL_COLORSPACE_BT709_FULL = /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */
|
||||
SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR,
|
||||
SDL_COLOR_RANGE_FULL,
|
||||
|
||||
@@ -240,15 +240,9 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, co
|
||||
* is displayed, if you want a software renderer without a window
|
||||
* - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
|
||||
* to use, if a specific one is desired
|
||||
* - `SDL_PROP_RENDERER_CREATE_INPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace
|
||||
* value describing the colorspace for input colors, defaults to
|
||||
* SDL_COLORSPACE_SRGB
|
||||
* - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace
|
||||
* value describing the colorspace for output to the display, defaults to
|
||||
* SDL_COLORSPACE_SRGB
|
||||
* - `SDL_PROP_RENDERER_CREATE_COLORSPACE_CONVERSION_BOOLEAN`: true if you
|
||||
* want conversion between the input colorspace and the output colorspace,
|
||||
* defaults to SDL_TRUE
|
||||
* SDL_COLORSPACE_SRGB. The direct3d11 and direct3d12 renderers support SDL_COLORSPACE_SCRGB, which is a linear color space and supports HDR output.
|
||||
* - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN`: true if you want
|
||||
* present synchronized with the refresh rate
|
||||
*
|
||||
@@ -273,9 +267,7 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_Prop
|
||||
#define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "window"
|
||||
#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "surface"
|
||||
#define SDL_PROP_RENDERER_CREATE_NAME_STRING "name"
|
||||
#define SDL_PROP_RENDERER_CREATE_INPUT_COLORSPACE_NUMBER "input_colorspace"
|
||||
#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "output_colorspace"
|
||||
#define SDL_PROP_RENDERER_CREATE_COLORSPACE_CONVERSION_BOOLEAN "colorspace_conversion"
|
||||
#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN "present_vsync"
|
||||
|
||||
/**
|
||||
@@ -1360,44 +1352,6 @@ extern DECLSPEC int SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float sca
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
|
||||
|
||||
/**
|
||||
* Set the colorspace used for drawing operations
|
||||
*
|
||||
* The default colorspace for drawing operations is SDL_COLORSPACE_SRGB, but
|
||||
* you can change it to other colorspaces such as SDL_COLORSPACE_SCRGB for HDR
|
||||
* rendering.
|
||||
*
|
||||
* This does not affect the colorspace of textures, which is specified via
|
||||
* properties when the texture is created and does not change.
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \param colorspace an SDL_ColorSpace value describing the colorspace for
|
||||
* drawing operations
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetRenderDrawColorspace
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetRenderDrawColorspace(SDL_Renderer *renderer, SDL_Colorspace colorspace);
|
||||
|
||||
/**
|
||||
* Get the colorspace used for drawing operations
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \param colorspace a pointer filled in with an SDL_ColorSpace value
|
||||
* describing the colorspace for drawing operations
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawColorspace
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRenderDrawColorspace(SDL_Renderer *renderer, SDL_Colorspace *colorspace);
|
||||
|
||||
|
||||
/**
|
||||
* Set the color used for drawing operations.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user