annotate include/SDL_poly.h @ 4776:29dcad9c58b3

Removed and added back SDL_shape.{c,h} wholesale. Will this get them tracked properly?
author Eli Gottlieb <eligottlieb@gmail.com>
date Sat, 05 Jun 2010 15:07:14 -0400
parents 590e680cc4e4
children
rev   line source
4771
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
1 /*
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
3 Copyright (C) 2010 Eli Gottlieb
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
4
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
9
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
13 Lesser General Public License for more details.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
14
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
18
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
19 Eli Gottlieb
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
20 eligottlieb@gmail.com
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
21 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
22
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
23 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
24 * \file SDL_poly.h
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
25 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
26 * Header file for SDL_poly definition and management functions.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
27 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
28
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
29 #ifndef _SDL_poly_h
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
30 #define _SDL_poly_h
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
31
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
32 #include "SDL_stdinc.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
33 #include "SDL_error.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
34 #include "SDL_pixels.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
35 #include "SDL_rwops.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
36 #include "SDL_rect.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
37
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
38 #include "begin_code.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
39 /* Set up for C function definitions, even when using C++ */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
40 #ifdef __cplusplus
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
41 /* *INDENT-OFF* */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
42 extern "C" {
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
43 /* *INDENT-ON* */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
44 #endif
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
45
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
46 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
47 * \brief The structure that defines an polygon.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
48 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
49 * \sa SDL_PolyEmpty
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
50 * \sa SDL_PolyEquals
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
51 * \sa SDL_PolysIntersect
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
52 * \sa SDL_IntersectPoly
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
53 * \sa SDL_WrapPoints
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
54 * \sa SDL_IntersectPolyAndLine
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
55 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
56 typedef struct SDL_Poly {
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
57 SDL_Point *vertices;
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
58 int count;
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
59 } SDL_Poly;
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
60
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
61 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
62 * \brief Returns true if the polygon has no area.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
63 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
64 #define SDL_PolyEmpty(X) (((X)->vertices == NULL) || ((X)->count <= 2))
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
65
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
66 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
67 * \brief Determine whether two polygons are equal.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
68 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
69 * \return SDL_TRUE if the polygons are equal, SDL_FALSE otherwise.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
70 */
4773
590e680cc4e4 Fixed up new functions and files so that they build as part of SDL.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4771
diff changeset
71 extern DECLSPEC SDL_bool SDLCALL SDL_PolyEquals(const SDL_Poly *A,const SDL_Poly *B);
4771
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
72
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
73 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
74 * \brief Determine whether two rectangles intersect.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
75 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
76 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
77 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
78 extern DECLSPEC SDL_bool SDLCALL SDL_PolysIntersect(const SDL_Poly * A,const SDL_Poly * B);
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
79
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
80 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
81 * \brief Calculate the intersection of two rectangles.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
82 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
83 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
84 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
85 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectPoly(const SDL_Poly * A,const SDL_Poly * B,SDL_Poly * result);
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
86
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
87 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
88 * \brief Calculate a minimal polygon wrapping a set of points
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
89 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
90 * \return 0 on success, -1 if the parameters were invalid, and -2 if an insufficient number of points were supplied
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
91 * in the output polygon.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
92 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
93 extern DECLSPEC int SDLCALL SDL_WrapPoints(const SDL_Point * points,int count,SDL_Poly *result);
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
94
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
95 /**
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
96 * \brief Calculate the intersection of a polygon and line segment.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
97 *
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
98 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
99 */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
100 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectPolyAndLine(const SDL_Poly *poly,int *X1,int *Y1,int *X2,int *Y2);
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
101
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
102 /* Ends C function definitions when using C++ */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
103 #ifdef __cplusplus
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
104 /* *INDENT-OFF* */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
105 }
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
106 /* *INDENT-ON* */
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
107 #endif
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
108 #include "close_code.h"
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
109
c500594c4246 Added management and drawing functions for ellipses and polygons.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
110 #endif /* _SDL_poly_h */