Skip to content

Commit

Permalink
Added rectangle drawing functions which accept a GPU_Rect: GPU_Rectan…
Browse files Browse the repository at this point in the history
…gle2(), GPU_RectangleFilled2(), GPU_RectangleRound2(), and GPU_RectangleRoundFilled2().
  • Loading branch information
grimfang4 committed Oct 2, 2015
1 parent 7bcc529 commit 3a49673
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions include/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,13 @@ DECLSPEC void SDLCALL GPU_TriFilled(GPU_Target* target, float x1, float y1, floa
*/
DECLSPEC void SDLCALL GPU_Rectangle(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);

/*! Renders a colored rectangle outline.
* \param target The destination render target
* \param rect The rectangular area to draw
* \param color The color of the shape to render
*/
DECLSPEC void SDLCALL GPU_Rectangle2(GPU_Target* target, GPU_Rect rect, SDL_Color color);

/*! Renders a colored filled rectangle.
* \param target The destination render target
* \param x1 x-coord of top-left corner
Expand All @@ -1390,6 +1397,13 @@ DECLSPEC void SDLCALL GPU_Rectangle(GPU_Target* target, float x1, float y1, floa
*/
DECLSPEC void SDLCALL GPU_RectangleFilled(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);

/*! Renders a colored filled rectangle.
* \param target The destination render target
* \param rect The rectangular area to draw
* \param color The color of the shape to render
*/
DECLSPEC void SDLCALL GPU_RectangleFilled2(GPU_Target* target, GPU_Rect rect, SDL_Color color);

/*! Renders a colored rounded (filleted) rectangle outline.
* \param target The destination render target
* \param x1 x-coord of top-left corner
Expand All @@ -1401,6 +1415,14 @@ DECLSPEC void SDLCALL GPU_RectangleFilled(GPU_Target* target, float x1, float y1
*/
DECLSPEC void SDLCALL GPU_RectangleRound(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);

/*! Renders a colored rounded (filleted) rectangle outline.
* \param target The destination render target
* \param rect The rectangular area to draw
* \param radius The radius of the corners
* \param color The color of the shape to render
*/
DECLSPEC void SDLCALL GPU_RectangleRound2(GPU_Target* target, GPU_Rect rect, float radius, SDL_Color color);

/*! Renders a colored filled rounded (filleted) rectangle.
* \param target The destination render target
* \param x1 x-coord of top-left corner
Expand All @@ -1412,6 +1434,14 @@ DECLSPEC void SDLCALL GPU_RectangleRound(GPU_Target* target, float x1, float y1,
*/
DECLSPEC void SDLCALL GPU_RectangleRoundFilled(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);

/*! Renders a colored filled rounded (filleted) rectangle.
* \param target The destination render target
* \param rect The rectangular area to draw
* \param radius The radius of the corners
* \param color The color of the shape to render
*/
DECLSPEC void SDLCALL GPU_RectangleRoundFilled2(GPU_Target* target, GPU_Rect rect, float radius, SDL_Color color);

/*! Renders a colored polygon outline. The vertices are expected to define a convex polygon.
* \param target The destination render target
* \param num_vertices Number of vertices (x and y pairs)
Expand Down
24 changes: 24 additions & 0 deletions src/SDL_gpu_shapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,48 @@ void GPU_Rectangle(GPU_Target* target, float x1, float y1, float x2, float y2, S
renderer->impl->Rectangle(renderer, target, x1, y1, x2, y2, color);
}

void GPU_Rectangle2(GPU_Target* target, GPU_Rect rect, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->Rectangle(renderer, target, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, color);
}

void GPU_RectangleFilled(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleFilled(renderer, target, x1, y1, x2, y2, color);
}

void GPU_RectangleFilled2(GPU_Target* target, GPU_Rect rect, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleFilled(renderer, target, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, color);
}

void GPU_RectangleRound(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleRound(renderer, target, x1, y1, x2, y2, radius, color);
}

void GPU_RectangleRound2(GPU_Target* target, GPU_Rect rect, float radius, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleRound(renderer, target, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, radius, color);
}

void GPU_RectangleRoundFilled(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleRoundFilled(renderer, target, x1, y1, x2, y2, radius, color);
}

void GPU_RectangleRoundFilled2(GPU_Target* target, GPU_Rect rect, float radius, SDL_Color color)
{
CHECK_RENDERER();
renderer->impl->RectangleRoundFilled(renderer, target, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, radius, color);
}

void GPU_Polygon(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color)
{
CHECK_RENDERER();
Expand Down

0 comments on commit 3a49673

Please sign in to comment.