Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added SDL_RenderClear() as a fast method of clearing the screen to th…
Browse files Browse the repository at this point in the history
…e drawing color.

Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine().
Added API for rectangle drawing (as opposed to filling)
Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay.
Optimized software line drawing quite a bit.
Added support for Wu's anti-aliased line drawing, currently disabled by default.
  • Loading branch information
slouken committed Dec 23, 2009
1 parent c9900ab commit 404e0cd
Show file tree
Hide file tree
Showing 24 changed files with 1,628 additions and 492 deletions.
4 changes: 3 additions & 1 deletion include/SDL_compat.h
Expand Up @@ -295,7 +295,9 @@ extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);

#define SDL_RenderFill SDL_RenderRect
#define SDL_RenderPoint SDL_RenderDrawPoint
#define SDL_RenderLine SDL_RenderDrawLine
#define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()

extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);

Expand Down
93 changes: 86 additions & 7 deletions include/SDL_surface.h
Expand Up @@ -411,12 +411,9 @@ extern DECLSPEC int SDLCALL SDL_DrawPoints
/**
* Blends a point with an RGBA value.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendDrawPoint
extern DECLSPEC int SDLCALL SDL_BlendPoint
(SDL_Surface * dst, int x, int y,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC int SDLCALL SDL_BlendPoints
Expand Down Expand Up @@ -464,9 +461,9 @@ extern DECLSPEC int SDLCALL SDL_DrawRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);

/**
* Blends the given rectangle with \c color.
* Blends an RGBA value into the outline of the given rectangle.
*
* If \c rect is NULL, the whole surface will have a blended outline of \c color.
* If \c rect is NULL, the whole surface will have a blended outline.
*
* \return 0 on success, or -1 on error.
*/
Expand Down Expand Up @@ -495,7 +492,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects
/**
* Blends an RGBA value into the given rectangle.
*
* If \c rect is NULL, the whole surface will be blended with \c color.
* If \c rect is NULL, the whole surface will be blended with the color.
*
* \return This function returns 0 on success, or -1 on error.
*/
Expand All @@ -506,6 +503,88 @@ extern DECLSPEC int SDLCALL SDL_BlendFillRects
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

#if 0
/**
* Draws the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);

/**
* Blends an RGBA value into the outline of the given circle.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Fills the given circle with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillCircle
(SDL_Surface * dst, int x, int y, int radius, Uint32 color);

/**
* Blends an RGBA value into the given circle.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillCircle
(SDL_Surface * dst, int x, int y, int radius,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Draws the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_DrawEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);

/**
* Blends an RGBA value into the outline of the given ellipse.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);

/**
* Fills the given ellipse with \c color.
*
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
*
* \return 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_FillEllipse
(SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);

/**
* Blends an RGBA value into the given ellipse.
*
* \return This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_BlendFillEllipse
(SDL_Surface * dst, int x, int y, int w, int h,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
#endif // 0

/**
* Performs a fast blit from the source surface to the destination surface.
*
Expand Down
72 changes: 63 additions & 9 deletions include/SDL_video.h
Expand Up @@ -1137,6 +1137,11 @@ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(int blendMode);
*/
extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);

/**
* \brief Clear the current rendering target with the drawing color
*/
extern DECLSPEC int SDLCALL SDL_RenderClear();

/**
* \brief Draw a point on the current rendering target.
*
Expand All @@ -1145,7 +1150,7 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderPoint(int x, int y);
extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(int x, int y);

/**
* \brief Draw some number of points on the current rendering target.
Expand All @@ -1155,8 +1160,8 @@ extern DECLSPEC int SDLCALL SDL_RenderPoint(int x, int y);
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderPoints(const SDL_Point * points,
int count);
extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(const SDL_Point * points,
int count);

/**
* \brief Draw a line on the current rendering target.
Expand All @@ -1168,7 +1173,7 @@ extern DECLSPEC int SDLCALL SDL_RenderPoints(const SDL_Point * points,
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderLine(int x1, int y1, int x2, int y2);
extern DECLSPEC int SDLCALL SDL_RenderDrawLine(int x1, int y1, int x2, int y2);

/**
* \brief Draw a series of connected lines on the current rendering target.
Expand All @@ -1178,18 +1183,37 @@ extern DECLSPEC int SDLCALL SDL_RenderLine(int x1, int y1, int x2, int y2);
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderLines(const SDL_Point * points,
int count);
extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points,
int count);

/**
* \brief Draw a rectangle on the current rendering target with the drawing color.
*
* \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderDrawRect(const SDL_Rect * rect);

/**
* \brief Fill the current rendering target with the drawing color.
* \brief Draw some number of rectangles in the current rendering target with the drawing color.
*
* \param rects A pointer to an array of destination rectangles.
* \param count The number of rectangles.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rect, int count);

/**
* \brief Fill a rectangle on the current rendering target with the drawing color.
*
* \param rect A pointer to the destination rectangle, or NULL for the entire
* rendering target.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderRect(const SDL_Rect * rect);
extern DECLSPEC int SDLCALL SDL_RenderFillRect(const SDL_Rect * rect);

/**
* \brief Fill some number of rectangles in the current rendering target with the drawing color.
Expand All @@ -1199,7 +1223,37 @@ extern DECLSPEC int SDLCALL SDL_RenderRect(const SDL_Rect * rect);
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderRects(const SDL_Rect ** rect, int count);
extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count);

#if 0
/**
* \brief Draw a circle on the current rendering target with the drawing color.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderDrawCircle(int x, int y, int radius);

/**
* \brief Fill a circle on the current rendering target with the drawing color.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderFillCircle(int x, int y, int radius);

/**
* \brief Draw an ellipse on the current rendering target with the drawing color.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderDrawEllipse(int x, int y, int w, int h);

/**
* \brief Fill an ellipse on the current rendering target with the drawing color.
*
* \return 0 on success, or -1 if there is no rendering context current.
*/
extern DECLSPEC int SDLCALL SDL_RenderFillEllipse(int x, int y, int w, int h);
#endif // 0

/**
* \brief Copy a portion of the texture to the current rendering target.
Expand Down

0 comments on commit 404e0cd

Please sign in to comment.