Added SDL_CreateRendererWithProperties() and SDL_CreateTextureWithProperties()

This commit is contained in:
Sam Lantinga 2023-11-13 12:13:20 -08:00
parent 7203641597
commit 1c64366b80
16 changed files with 406 additions and 169 deletions

View file

@ -195,7 +195,6 @@ extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
*/
extern DECLSPEC const char *SDLCALL SDL_GetRenderDriver(int index);
/**
* Create a window and default renderer.
*
@ -215,14 +214,13 @@ extern DECLSPEC const char *SDLCALL SDL_GetRenderDriver(int index);
*/
extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer);
/**
* Create a 2D rendering context for a window.
*
* If you want a specific renderer, you can specify its name here. A list of
* available renderers can be obtained by calling SDL_GetRenderDriver multiple
* times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you don't
* need a specific renderer, specify NULL and SDL will attempt to chooes the
* need a specific renderer, specify NULL and SDL will attempt to choose the
* best option for you, based on what is available on the user's system.
*
* By default the rendering size matches the window size in pixels, but you
@ -238,13 +236,37 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, U
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateRendererWithProperties
* \sa SDL_CreateSoftwareRenderer
* \sa SDL_DestroyRenderer
* \sa SDL_GetNumRenderDrivers
* \sa SDL_GetRenderDriver
* \sa SDL_GetRendererInfo
*/
extern DECLSPEC SDL_Renderer *SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 flags);
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 flags);
/**
* Create a 2D rendering context for a window, with the specified properties.
*
* These are the supported properties:
*
* - "window" (pointer) - the window where rendering is displayed
* - "surface" (pointer) - the surface where rendering is displayed, if you want a software renderer without a window
* - "name" (string) - the name of the rendering driver to use, if a specific one is desired
* - "present_vsync" (boolean) - true if you want present synchronized with the refresh rate
*
* \param props the properties to use
* \returns a valid rendering context or NULL if there was an error; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateRenderer
* \sa SDL_CreateSoftwareRenderer
* \sa SDL_DestroyRenderer
* \sa SDL_GetRendererInfo
*/
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
/**
* Create a 2D software rendering context for a surface.
@ -309,7 +331,7 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_Rend
/**
* Get the properties associated with a renderer.
*
* The following properties are provided by SDL:
* The following read-only properties are provided by SDL:
*
* ```
* "SDL.renderer.d3d9.device" (pointer) - the IDirect3DDevice9 associated with the renderer
@ -386,6 +408,7 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *rendere
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateTextureFromSurface
* \sa SDL_CreateTextureWithProperties
* \sa SDL_DestroyTexture
* \sa SDL_QueryTexture
* \sa SDL_UpdateTexture
@ -413,50 +436,96 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, U
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateTexture
* \sa SDL_CreateTextureWithProperties
* \sa SDL_DestroyTexture
* \sa SDL_QueryTexture
*/
extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
/**
* Get the properties associated with a texture.
* Create a texture for a rendering context with the specified properties.
*
* The following properties are provided by SDL:
* These are the supported properties:
*
* - "format" (number) - one of the enumerated values in SDL_PixelFormatEnum, defaults to the best RGBA format for the renderer
* - "access" (number) - one of the enumerated values in SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
* - "width" (number) - the width of the texture in pixels, required
* - "height" (number) - the height of the texture in pixels, required
*
* With the direct3d11 renderer:
*
* ```
* "SDL.texture.d3d11.texture" (pointer) - the ID3D11Texture2D associated with the texture
* "SDL.texture.d3d11.texture_u" (pointer) - the ID3D11Texture2D associated with the U plane of a YUV texture
* "SDL.texture.d3d11.texture_v" (pointer) - the ID3D11Texture2D associated with the V plane of a YUV texture
* ```
* - "d3d11.texture" (pointer) - the ID3D11Texture2D associated with the texture, if you want to wrap an existing texture.
* - "d3d11.texture_u" (pointer) - the ID3D11Texture2D associated with the U plane of a YUV texture, if you want to wrap an existing texture.
* - "d3d11.texture_v" (pointer) - the ID3D11Texture2D associated with the V plane of a YUV texture, if you want to wrap an existing texture.
*
* With the direct3d12 renderer:
*
* ```
* "SDL.texture.d3d12.texture" (pointer) - the ID3D12Resource associated with the texture
* "SDL.texture.d3d12.texture_u" (pointer) - the ID3D12Resource associated with the U plane of a YUV texture
* "SDL.texture.d3d12.texture_v" (pointer) - the ID3D12Resource associated with the V plane of a YUV texture
* ```
* - "d3d12.texture" (pointer) - the ID3D12Resource associated with the texture, if you want to wrap an existing texture.
* - "d3d12.texture_u" (pointer) - the ID3D12Resource associated with the U plane of a YUV texture, if you want to wrap an existing texture.
* - "d3d12.texture_v" (pointer) - the ID3D12Resource associated with the V plane of a YUV texture, if you want to wrap an existing texture.
*
* With the opengl renderer:
*
* ```
* "SDL.texture.opengl.texture" (number) - the GLuint texture associated with the texture
* "SDL.texture.opengl.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture
* "SDL.texture.opengl.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture
* "SDL.texture.opengl.tex_w" (float) - the texture coordinate width of the texture (0.0 - 1.0)
* "SDL.texture.opengl.tex_h" (float) - the texture coordinate height of the texture (0.0 - 1.0)
* ```
* - "opengl.texture" (number) - the GLuint texture associated with the texture, if you want to wrap an existing texture.
* - "opengl.texture_uv" (number) - the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
* - "opengl.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
* - "opengl.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
*
* With the opengles2 renderer:
*
* ```
* "SDL.texture.opengles2.texture" (number) - the GLuint texture associated with the texture
* "SDL.texture.opengles2.texture_uv" (number) - the GLuint texture associated with the UV plane of an NV12 texture
* "SDL.texture.opengles2.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture
* "SDL.texture.opengles2.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture
* ```
* - "opengles2.texture" (number) - the GLuint texture associated with the texture, if you want to wrap an existing texture.
* - "opengles2.texture_uv" (number) - the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
* - "opengles2.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
* - "opengles2.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.
*
* \param renderer the rendering context
* \param props the properties to use
* \returns a pointer to the created texture or NULL if no rendering context
* was active, the format was unsupported, or the width or height
* were out of range; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateTextureFromSurface
* \sa SDL_CreateTexture
* \sa SDL_DestroyTexture
* \sa SDL_QueryTexture
* \sa SDL_UpdateTexture
*/
extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
/**
* Get the properties associated with a texture.
*
* The following read-only properties are provided by SDL:
*
* With the direct3d11 renderer:
*
* - "SDL.texture.d3d11.texture" (pointer) - the ID3D11Texture2D associated with the texture
* - "SDL.texture.d3d11.texture_u" (pointer) - the ID3D11Texture2D associated with the U plane of a YUV texture
* - "SDL.texture.d3d11.texture_v" (pointer) - the ID3D11Texture2D associated with the V plane of a YUV texture
*
* With the direct3d12 renderer:
*
* - "SDL.texture.d3d12.texture" (pointer) - the ID3D12Resource associated with the texture
* - "SDL.texture.d3d12.texture_u" (pointer) - the ID3D12Resource associated with the U plane of a YUV texture
* - "SDL.texture.d3d12.texture_v" (pointer) - the ID3D12Resource associated with the V plane of a YUV texture
*
* With the opengl renderer:
*
* - "SDL.texture.opengl.texture" (number) - the GLuint texture associated with the texture
* - "SDL.texture.opengl.texture_uv" (number) - the GLuint texture associated with the UV plane of an NV12 texture
* - "SDL.texture.opengl.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture
* - "SDL.texture.opengl.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture
* - "SDL.texture.opengl.tex_w" (float) - the texture coordinate width of the texture (0.0 - 1.0)
* - "SDL.texture.opengl.tex_h" (float) - the texture coordinate height of the texture (0.0 - 1.0)
*
* With the opengles2 renderer:
*
* - "SDL.texture.opengles2.texture" (number) - the GLuint texture associated with the texture
* - "SDL.texture.opengles2.texture_uv" (number) - the GLuint texture associated with the UV plane of an NV12 texture
* - "SDL.texture.opengles2.texture_u" (number) - the GLuint texture associated with the U plane of a YUV texture
* - "SDL.texture.opengles2.texture_v" (number) - the GLuint texture associated with the V plane of a YUV texture
*
* \param texture the texture to query
* \returns a valid property ID on success or 0 on failure; call