use argument struct, rename to RenderGeometryEx

This commit is contained in:
expikr 2025-03-28 12:51:29 +08:00
parent 989c55b564
commit 72c0fd1017
2 changed files with 78 additions and 33 deletions

View file

@ -2294,7 +2294,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(SDL_Renderer *rende
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_RenderGeometryRaw
* \sa SDL_RenderGeometryRawEx
* \sa SDL_RenderGeometryEx
*/
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
SDL_Texture *texture,
@ -2327,7 +2327,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_RenderGeometry
* \sa SDL_RenderGeometryRawEx
* \sa SDL_RenderGeometryEx
*/
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
SDL_Texture *texture,
@ -2337,6 +2337,29 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
int num_vertices,
const void *indices, int num_indices, int size_indices);
/**
* Argument struct for SDL_RenderGeometryEx.
*
* \since This struct is available since SDL 3.4.0.
*/
typedef struct SDL_RenderGeometryEx_Arg
{
size_t arg_size; /**< the size of this struct, must be set with sizeof() */
int ver_len; /**< number of vertices. */
const void *map; /**< (optional) An array of indices into the 'vertices' arrays, if NULL all vertices will be rendered in sequential order. */
int map_size; /**< index size: 1 (byte), 2 (short), 4 (int). */
int map_len; /**< number of indices. */
const float *pos; /**< vertex positions. */
int pos_stride; /**< byte size to move from one element to the next element. */
int pos_len; /**< how many vertext position coordinates, must be 2, 3, or 4. */
const SDL_FColor *col; /**< vertex colors (as SDL_FColor). */
int col_stride; /**< byte size to move from one element to the next element. */
const float *tex; /**< vertex normalized texture coordinates. */
int tex_stride; /**< byte size to move from one element to the next element. */
} SDL_RenderGeometryEx_Arg;
/**
* Render a list of triangles, optionally using a texture and indices into the
@ -2346,18 +2369,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
*
* \param renderer the rendering context.
* \param texture (optional) The SDL texture to use.
* \param pos vertex positions.
* \param pos_stride byte size to move from one element to the next element.
* \param pos_len how many vertext position coordinates, must be 2, 3, or 4.
* \param color vertex colors (as SDL_FColor).
* \param color_stride byte size to move from one element to the next element.
* \param uv vertex normalized texture coordinates.
* \param uv_stride byte size to move from one element to the next element.
* \param num_vertices number of vertices.
* \param indices (optional) An array of indices into the 'vertices' arrays,
* if NULL all vertices will be rendered in sequential order.
* \param num_indices number of indices.
* \param size_indices index size: 1 (byte), 2 (short), 4 (int).
* \param arg pointer to an SDL_RenderGeometryEx_Arg struct of vertex info.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
@ -2368,13 +2380,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
* \sa SDL_RenderGeometry
* \sa SDL_RenderGeometryRaw
*/
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRawEx(SDL_Renderer *renderer,
SDL_Texture *texture,
const float *pos, int pos_stride, Uint8 pos_len,
const SDL_FColor *color, int color_stride,
const float *uv, int uv_stride,
int num_vertices,
const void *indices, int num_indices, int size_indices);
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryEx(SDL_Renderer *renderer,
SDL_Texture *texture, const SDL_RenderGeometryEx_Arg *arg);
/**
* Read pixels from the current rendering target.