Added management and drawing functions for ellipses and polygons.
authorEli Gottlieb <eligottlieb@gmail.com>
Thu, 03 Jun 2010 14:43:38 -0400
changeset 4771c500594c4246
parent 4770 cf7976fd3258
child 4772 37e9f8154ac4
Added management and drawing functions for ellipses and polygons.
Makefile.in
include/SDL_ellipse.h
include/SDL_poly.h
include/SDL_video.h
     1.1 --- a/Makefile.in	Mon May 31 21:23:06 2010 -0400
     1.2 +++ b/Makefile.in	Thu Jun 03 14:43:38 2010 -0400
     1.3 @@ -44,7 +44,7 @@
     1.4  
     1.5  DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-Win32.zip WhatsNew Xcode Xcode-iPhoneOS
     1.6  
     1.7 -HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.8 +HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_ellipse.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_poly.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.9  
    1.10  LT_AGE      = @LT_AGE@
    1.11  LT_CURRENT  = @LT_CURRENT@
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/include/SDL_ellipse.h	Thu Jun 03 14:43:38 2010 -0400
     2.3 @@ -0,0 +1,92 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 2010 Eli Gottlieb
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Eli Gottlieb
    2.23 +    eligottlieb@gmail.com
    2.24 +*/
    2.25 +
    2.26 +/**
    2.27 + *  \file SDL_ellipse.h
    2.28 + *  
    2.29 + *  Header file for SDL_ellipse definition and management functions.
    2.30 + */
    2.31 +
    2.32 +#ifndef _SDL_ellipse_h
    2.33 +#define _SDL_ellipse_h
    2.34 +
    2.35 +#include "SDL_stdinc.h"
    2.36 +#include "SDL_error.h"
    2.37 +#include "SDL_pixels.h"
    2.38 +#include "SDL_rwops.h"
    2.39 +
    2.40 +#include "begin_code.h"
    2.41 +/* Set up for C function definitions, even when using C++ */
    2.42 +#ifdef __cplusplus
    2.43 +/* *INDENT-OFF* */
    2.44 +extern "C" {
    2.45 +/* *INDENT-ON* */
    2.46 +#endif
    2.47 +
    2.48 +/**
    2.49 + *  \brief  The structure that defines an ellipse.
    2.50 + *
    2.51 + *  \sa SDL_EllipseEmpty
    2.52 + *  \sa SDL_EllipseEquals
    2.53 + *  \sa SDL_EllipsesIntersect
    2.54 + *  \sa SDL_IntersectEllipseAndLine
    2.55 + */
    2.56 +typedef struct SDL_Ellipse {
    2.57 +	int x,y;
    2.58 +	int a,b;
    2.59 +	int r;
    2.60 +} SDL_Ellipse;
    2.61 +
    2.62 +/**
    2.63 + *  \brief Returns true if the ellipse has no area.
    2.64 + */
    2.65 +#define SDL_EllipseEmpty(X)    ((X)->r <= 0)
    2.66 +
    2.67 +/**
    2.68 + *  \brief Returns true if the two ellipses are equal.
    2.69 + */
    2.70 +#define SDL_EllipseEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
    2.71 +                                ((A)->a == (B)->a) && ((A)->b == (B)->b) && ((A)->r == (B)->r))
    2.72 +
    2.73 +/**
    2.74 + *  \brief Determine whether two ellipses intersect.
    2.75 + *  
    2.76 + *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    2.77 + */
    2.78 +extern DECLSPEC SDL_bool SDLCALL SDL_EllipsesIntersect(const SDL_Ellipse * A,const SDL_Ellipse * B);
    2.79 +
    2.80 +/**
    2.81 + *  \brief Calculate the intersection of an ellipse and line segment.
    2.82 + *  
    2.83 + *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    2.84 + */
    2.85 +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectEllipseAndLine(const SDL_Ellipse *ellipse,int *X1,int *Y1,int *X2,int *Y2);
    2.86 +
    2.87 +/* Ends C function definitions when using C++ */
    2.88 +#ifdef __cplusplus
    2.89 +/* *INDENT-OFF* */
    2.90 +}
    2.91 +/* *INDENT-ON* */
    2.92 +#endif
    2.93 +#include "close_code.h"
    2.94 +
    2.95 +#endif /* _SDL_ellipse_h */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/include/SDL_poly.h	Thu Jun 03 14:43:38 2010 -0400
     3.3 @@ -0,0 +1,110 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 2010 Eli Gottlieb
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Eli Gottlieb
    3.23 +    eligottlieb@gmail.com
    3.24 +*/
    3.25 +
    3.26 +/**
    3.27 + *  \file SDL_poly.h
    3.28 + *  
    3.29 + *  Header file for SDL_poly definition and management functions.
    3.30 + */
    3.31 +
    3.32 +#ifndef _SDL_poly_h
    3.33 +#define _SDL_poly_h
    3.34 +
    3.35 +#include "SDL_stdinc.h"
    3.36 +#include "SDL_error.h"
    3.37 +#include "SDL_pixels.h"
    3.38 +#include "SDL_rwops.h"
    3.39 +#include "SDL_rect.h"
    3.40 +
    3.41 +#include "begin_code.h"
    3.42 +/* Set up for C function definitions, even when using C++ */
    3.43 +#ifdef __cplusplus
    3.44 +/* *INDENT-OFF* */
    3.45 +extern "C" {
    3.46 +/* *INDENT-ON* */
    3.47 +#endif
    3.48 +
    3.49 +/**
    3.50 + *  \brief  The structure that defines an polygon.
    3.51 + *
    3.52 + *  \sa SDL_PolyEmpty
    3.53 + *  \sa SDL_PolyEquals
    3.54 + *  \sa SDL_PolysIntersect
    3.55 + *  \sa SDL_IntersectPoly
    3.56 + *  \sa SDL_WrapPoints
    3.57 + *  \sa SDL_IntersectPolyAndLine
    3.58 + */
    3.59 +typedef struct SDL_Poly {
    3.60 +	SDL_Point *vertices;
    3.61 +	int count;
    3.62 +} SDL_Poly;
    3.63 +
    3.64 +/**
    3.65 + *  \brief Returns true if the polygon has no area.
    3.66 + */
    3.67 +#define SDL_PolyEmpty(X)    (((X)->vertices == NULL) || ((X)->count <= 2))
    3.68 +
    3.69 +/**
    3.70 + *  \brief Determine whether two polygons are equal.
    3.71 + *  
    3.72 + *  \return SDL_TRUE if the polygons are equal, SDL_FALSE otherwise.
    3.73 + */
    3.74 +extern DECLSPEC SDL_bool SDLCALL SDL_PolyEquals(const SDL_Poly *A,const SDL_Poly *A);
    3.75 +
    3.76 +/**
    3.77 + *  \brief Determine whether two rectangles intersect.
    3.78 + *  
    3.79 + *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    3.80 + */
    3.81 +extern DECLSPEC SDL_bool SDLCALL SDL_PolysIntersect(const SDL_Poly * A,const SDL_Poly * B);
    3.82 +
    3.83 +/**
    3.84 + *  \brief Calculate the intersection of two rectangles.
    3.85 + *  
    3.86 + *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    3.87 + */
    3.88 +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectPoly(const SDL_Poly * A,const SDL_Poly * B,SDL_Poly * result);
    3.89 +
    3.90 +/**
    3.91 + *  \brief Calculate a minimal polygon wrapping a set of points
    3.92 + *
    3.93 + *  \return 0 on success, -1 if the parameters were invalid, and -2 if an insufficient number of points were supplied
    3.94 + *          in the output polygon.
    3.95 + */
    3.96 +extern DECLSPEC int SDLCALL SDL_WrapPoints(const SDL_Point * points,int count,SDL_Poly *result);
    3.97 +
    3.98 +/**
    3.99 + *  \brief Calculate the intersection of a polygon and line segment.
   3.100 + *  
   3.101 + *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
   3.102 + */
   3.103 +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectPolyAndLine(const SDL_Poly *poly,int *X1,int *Y1,int *X2,int *Y2);
   3.104 +                                                   
   3.105 +/* Ends C function definitions when using C++ */
   3.106 +#ifdef __cplusplus
   3.107 +/* *INDENT-OFF* */
   3.108 +}
   3.109 +/* *INDENT-ON* */
   3.110 +#endif
   3.111 +#include "close_code.h"
   3.112 +
   3.113 +#endif /* _SDL_poly_h */
     4.1 --- a/include/SDL_video.h	Mon May 31 21:23:06 2010 -0400
     4.2 +++ b/include/SDL_video.h	Thu Jun 03 14:43:38 2010 -0400
     4.3 @@ -32,6 +32,8 @@
     4.4  #include "SDL_stdinc.h"
     4.5  #include "SDL_pixels.h"
     4.6  #include "SDL_rect.h"
     4.7 +#include "SDL_ellipse.h"
     4.8 +#include "SDL_poly.h"
     4.9  #include "SDL_surface.h"
    4.10  
    4.11  #include "begin_code.h"
    4.12 @@ -1238,6 +1240,83 @@
    4.13  extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count);
    4.14  
    4.15  /**
    4.16 + *  \brief Draw an ellipse on the current rendering target with the drawing color.
    4.17 + *
    4.18 + *  \param ellipse The destination ellipse.
    4.19 + *
    4.20 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.21 + */
    4.22 +extern DECLSPEC int SDLCALL SDL_RenderDrawEllipse(const SDL_Ellipse ellipse);
    4.23 +
    4.24 +/**
    4.25 + *  \brief Draw some number of ellipses in the current rendering target with the drawing color.
    4.26 + *  
    4.27 + *  \param ellipse A pointer to an array of destination ellipses.
    4.28 + *  \param count The number of ellipses.
    4.29 + *  
    4.30 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.31 + */
    4.32 +extern DECLSPEC int SDLCALL SDL_RenderDrawEllipses(const SDL_Ellipse ** ellipse, int count);
    4.33 +
    4.34 +/**
    4.35 + *  \brief Fill an ellipse on the current rendering target with the drawing color.
    4.36 + *  
    4.37 + *  \param ellipse The destination ellipse
    4.38 + *  
    4.39 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.40 + */
    4.41 +extern DECLSPEC int SDLCALL SDL_RenderFillEllipse(const SDL_Ellipse ellipse);
    4.42 +
    4.43 +/**
    4.44 + *  \brief Fill some number of ellipses in the current rendering target with the drawing color.
    4.45 + *  
    4.46 + *  \param ellipse A pointer to an array of destination ellipses.
    4.47 + *  \param count The number of ellipses.
    4.48 + *  
    4.49 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.50 + */
    4.51 +extern DECLSPEC int SDLCALL SDL_RenderFillEllipses(const SDL_Ellipse ** ellipse, int count);
    4.52 +
    4.53 +/**
    4.54 + *  \brief Draw a polygon on the current rendering target with the drawing color.
    4.55 + *
    4.56 + *  \param poly The destination polygon.
    4.57 + *
    4.58 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.59 + */
    4.60 +extern DECLSPEC int SDLCALL SDL_RenderDrawPoly(const SDL_Poly poly);
    4.61 +
    4.62 +/**
    4.63 + *  \brief Draw some number of polygons in the current rendering target with the drawing color.
    4.64 + *  
    4.65 + *  \param poly A pointer to an array of destination polygons.
    4.66 + *  \param count The number of polygons.
    4.67 + *  
    4.68 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.69 + */
    4.70 +extern DECLSPEC int SDLCALL SDL_RenderDrawPolys(const SDL_Poly ** poly, int count);
    4.71 +
    4.72 +/**
    4.73 + *  \brief Fill a polygon on the current rendering target with the drawing color.
    4.74 + *  
    4.75 + *  \param poly The destination polygon
    4.76 + *  
    4.77 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.78 + */
    4.79 +extern DECLSPEC int SDLCALL SDL_RenderFillPoly(const SDL_Poly poly);
    4.80 +
    4.81 +/**
    4.82 + *  \brief Fill some number of polygons in the current rendering target with the drawing color.
    4.83 + *  
    4.84 + *  \param poly A pointer to an array of destination polygons.
    4.85 + *  \param count The number of polygons.
    4.86 + *  
    4.87 + *  \return 0 on success, or -1 if there is no rendering context current.
    4.88 + */
    4.89 +extern DECLSPEC int SDLCALL SDL_RenderFillPolys(const SDL_Poly ** poly, int count);
    4.90 +
    4.91 +
    4.92 +/**
    4.93   *  \brief Copy a portion of the texture to the current rendering target.
    4.94   *  
    4.95   *  \param texture The source texture.