SDL standard library

Dependents:   H261_encoder

Committer:
miruga27
Date:
Wed Sep 07 18:46:53 2016 +0000
Revision:
0:dda4f4550403
7/09/2016;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:dda4f4550403 1 /*
miruga27 0:dda4f4550403 2 Simple DirectMedia Layer
miruga27 0:dda4f4550403 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:dda4f4550403 4
miruga27 0:dda4f4550403 5 This software is provided 'as-is', without any express or implied
miruga27 0:dda4f4550403 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:dda4f4550403 7 arising from the use of this software.
miruga27 0:dda4f4550403 8
miruga27 0:dda4f4550403 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:dda4f4550403 10 including commercial applications, and to alter it and redistribute it
miruga27 0:dda4f4550403 11 freely, subject to the following restrictions:
miruga27 0:dda4f4550403 12
miruga27 0:dda4f4550403 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:dda4f4550403 14 claim that you wrote the original software. If you use this software
miruga27 0:dda4f4550403 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:dda4f4550403 16 appreciated but is not required.
miruga27 0:dda4f4550403 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:dda4f4550403 18 misrepresented as being the original software.
miruga27 0:dda4f4550403 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:dda4f4550403 20 */
miruga27 0:dda4f4550403 21
miruga27 0:dda4f4550403 22 /**
miruga27 0:dda4f4550403 23 * \file SDL_rect.h
miruga27 0:dda4f4550403 24 *
miruga27 0:dda4f4550403 25 * Header file for SDL_rect definition and management functions.
miruga27 0:dda4f4550403 26 */
miruga27 0:dda4f4550403 27
miruga27 0:dda4f4550403 28 #ifndef _SDL_rect_h
miruga27 0:dda4f4550403 29 #define _SDL_rect_h
miruga27 0:dda4f4550403 30
miruga27 0:dda4f4550403 31 #include "SDL_stdinc.h"
miruga27 0:dda4f4550403 32 #include "SDL_error.h"
miruga27 0:dda4f4550403 33 #include "SDL_pixels.h"
miruga27 0:dda4f4550403 34 #include "SDL_rwops.h"
miruga27 0:dda4f4550403 35
miruga27 0:dda4f4550403 36 #include "begin_code.h"
miruga27 0:dda4f4550403 37 /* Set up for C function definitions, even when using C++ */
miruga27 0:dda4f4550403 38 #ifdef __cplusplus
miruga27 0:dda4f4550403 39 extern "C" {
miruga27 0:dda4f4550403 40 #endif
miruga27 0:dda4f4550403 41
miruga27 0:dda4f4550403 42 /**
miruga27 0:dda4f4550403 43 * \brief The structure that defines a point
miruga27 0:dda4f4550403 44 *
miruga27 0:dda4f4550403 45 * \sa SDL_EnclosePoints
miruga27 0:dda4f4550403 46 */
miruga27 0:dda4f4550403 47 typedef struct SDL_Point
miruga27 0:dda4f4550403 48 {
miruga27 0:dda4f4550403 49 int x;
miruga27 0:dda4f4550403 50 int y;
miruga27 0:dda4f4550403 51 } SDL_Point;
miruga27 0:dda4f4550403 52
miruga27 0:dda4f4550403 53 /**
miruga27 0:dda4f4550403 54 * \brief A rectangle, with the origin at the upper left.
miruga27 0:dda4f4550403 55 *
miruga27 0:dda4f4550403 56 * \sa SDL_RectEmpty
miruga27 0:dda4f4550403 57 * \sa SDL_RectEquals
miruga27 0:dda4f4550403 58 * \sa SDL_HasIntersection
miruga27 0:dda4f4550403 59 * \sa SDL_IntersectRect
miruga27 0:dda4f4550403 60 * \sa SDL_UnionRect
miruga27 0:dda4f4550403 61 * \sa SDL_EnclosePoints
miruga27 0:dda4f4550403 62 */
miruga27 0:dda4f4550403 63 typedef struct SDL_Rect
miruga27 0:dda4f4550403 64 {
miruga27 0:dda4f4550403 65 int x, y;
miruga27 0:dda4f4550403 66 int w, h;
miruga27 0:dda4f4550403 67 } SDL_Rect;
miruga27 0:dda4f4550403 68
miruga27 0:dda4f4550403 69 /**
miruga27 0:dda4f4550403 70 * \brief Returns true if the rectangle has no area.
miruga27 0:dda4f4550403 71 */
miruga27 0:dda4f4550403 72 SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
miruga27 0:dda4f4550403 73 {
miruga27 0:dda4f4550403 74 return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
miruga27 0:dda4f4550403 75 }
miruga27 0:dda4f4550403 76
miruga27 0:dda4f4550403 77 /**
miruga27 0:dda4f4550403 78 * \brief Returns true if the two rectangles are equal.
miruga27 0:dda4f4550403 79 */
miruga27 0:dda4f4550403 80 SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
miruga27 0:dda4f4550403 81 {
miruga27 0:dda4f4550403 82 return (a && b && (a->x == b->x) && (a->y == b->y) &&
miruga27 0:dda4f4550403 83 (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
miruga27 0:dda4f4550403 84 }
miruga27 0:dda4f4550403 85
miruga27 0:dda4f4550403 86 /**
miruga27 0:dda4f4550403 87 * \brief Determine whether two rectangles intersect.
miruga27 0:dda4f4550403 88 *
miruga27 0:dda4f4550403 89 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:dda4f4550403 90 */
miruga27 0:dda4f4550403 91 extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
miruga27 0:dda4f4550403 92 const SDL_Rect * B);
miruga27 0:dda4f4550403 93
miruga27 0:dda4f4550403 94 /**
miruga27 0:dda4f4550403 95 * \brief Calculate the intersection of two rectangles.
miruga27 0:dda4f4550403 96 *
miruga27 0:dda4f4550403 97 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:dda4f4550403 98 */
miruga27 0:dda4f4550403 99 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
miruga27 0:dda4f4550403 100 const SDL_Rect * B,
miruga27 0:dda4f4550403 101 SDL_Rect * result);
miruga27 0:dda4f4550403 102
miruga27 0:dda4f4550403 103 /**
miruga27 0:dda4f4550403 104 * \brief Calculate the union of two rectangles.
miruga27 0:dda4f4550403 105 */
miruga27 0:dda4f4550403 106 extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
miruga27 0:dda4f4550403 107 const SDL_Rect * B,
miruga27 0:dda4f4550403 108 SDL_Rect * result);
miruga27 0:dda4f4550403 109
miruga27 0:dda4f4550403 110 /**
miruga27 0:dda4f4550403 111 * \brief Calculate a minimal rectangle enclosing a set of points
miruga27 0:dda4f4550403 112 *
miruga27 0:dda4f4550403 113 * \return SDL_TRUE if any points were within the clipping rect
miruga27 0:dda4f4550403 114 */
miruga27 0:dda4f4550403 115 extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
miruga27 0:dda4f4550403 116 int count,
miruga27 0:dda4f4550403 117 const SDL_Rect * clip,
miruga27 0:dda4f4550403 118 SDL_Rect * result);
miruga27 0:dda4f4550403 119
miruga27 0:dda4f4550403 120 /**
miruga27 0:dda4f4550403 121 * \brief Calculate the intersection of a rectangle and line segment.
miruga27 0:dda4f4550403 122 *
miruga27 0:dda4f4550403 123 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:dda4f4550403 124 */
miruga27 0:dda4f4550403 125 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
miruga27 0:dda4f4550403 126 rect, int *X1,
miruga27 0:dda4f4550403 127 int *Y1, int *X2,
miruga27 0:dda4f4550403 128 int *Y2);
miruga27 0:dda4f4550403 129
miruga27 0:dda4f4550403 130 /* Ends C function definitions when using C++ */
miruga27 0:dda4f4550403 131 #ifdef __cplusplus
miruga27 0:dda4f4550403 132 }
miruga27 0:dda4f4550403 133 #endif
miruga27 0:dda4f4550403 134 #include "close_code.h"
miruga27 0:dda4f4550403 135
miruga27 0:dda4f4550403 136 #endif /* _SDL_rect_h */
miruga27 0:dda4f4550403 137
miruga27 0:dda4f4550403 138 /* vi: set ts=4 sw=4 expandtab: */