slouken@2275
|
1 |
/*
|
slouken@2275
|
2 |
SDL - Simple DirectMedia Layer
|
slouken@3697
|
3 |
Copyright (C) 1997-2010 Sam Lantinga
|
slouken@2275
|
4 |
|
slouken@2275
|
5 |
This library is free software; you can redistribute it and/or
|
slouken@2275
|
6 |
modify it under the terms of the GNU Lesser General Public
|
slouken@2275
|
7 |
License as published by the Free Software Foundation; either
|
slouken@2275
|
8 |
version 2.1 of the License, or (at your option) any later version.
|
slouken@2275
|
9 |
|
slouken@2275
|
10 |
This library is distributed in the hope that it will be useful,
|
slouken@2275
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
slouken@2275
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
slouken@2275
|
13 |
Lesser General Public License for more details.
|
slouken@2275
|
14 |
|
slouken@2275
|
15 |
You should have received a copy of the GNU Lesser General Public
|
slouken@2275
|
16 |
License along with this library; if not, write to the Free Software
|
slouken@2275
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
slouken@2275
|
18 |
|
slouken@2275
|
19 |
Sam Lantinga
|
slouken@2275
|
20 |
slouken@libsdl.org
|
slouken@2275
|
21 |
*/
|
slouken@2275
|
22 |
|
slouken@2275
|
23 |
/**
|
slouken@3407
|
24 |
* \file SDL_surface.h
|
slouken@3407
|
25 |
*
|
slouken@3407
|
26 |
* Header file for ::SDL_surface definition and management functions.
|
slouken@2275
|
27 |
*/
|
slouken@2275
|
28 |
|
slouken@2275
|
29 |
#ifndef _SDL_surface_h
|
slouken@2275
|
30 |
#define _SDL_surface_h
|
slouken@2275
|
31 |
|
slouken@2275
|
32 |
#include "SDL_stdinc.h"
|
slouken@2275
|
33 |
#include "SDL_pixels.h"
|
slouken@2275
|
34 |
#include "SDL_rect.h"
|
slouken@4929
|
35 |
#include "SDL_blendmode.h"
|
slouken@4929
|
36 |
#include "SDL_scalemode.h"
|
slouken@2275
|
37 |
#include "SDL_rwops.h"
|
slouken@2275
|
38 |
|
slouken@2275
|
39 |
#include "begin_code.h"
|
slouken@2275
|
40 |
/* Set up for C function definitions, even when using C++ */
|
slouken@2275
|
41 |
#ifdef __cplusplus
|
slouken@2275
|
42 |
/* *INDENT-OFF* */
|
slouken@2275
|
43 |
extern "C" {
|
slouken@2275
|
44 |
/* *INDENT-ON* */
|
slouken@2275
|
45 |
#endif
|
slouken@2275
|
46 |
|
slouken@3407
|
47 |
/**
|
slouken@3407
|
48 |
* \name Surface flags
|
slouken@3407
|
49 |
*
|
slouken@3407
|
50 |
* These are the currently supported flags for the ::SDL_surface.
|
slouken@3407
|
51 |
*
|
slouken@3407
|
52 |
* \internal
|
slouken@3407
|
53 |
* Used internally (read-only).
|
slouken@3341
|
54 |
*/
|
slouken@3341
|
55 |
/*@{*/
|
slouken@3341
|
56 |
#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */
|
slouken@3341
|
57 |
#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */
|
slouken@3407
|
58 |
/*@}*//*Surface flags*/
|
slouken@2275
|
59 |
|
slouken@3407
|
60 |
/**
|
slouken@3407
|
61 |
* Evaluates to true if the surface needs to be locked before access.
|
slouken@3407
|
62 |
*/
|
slouken@2275
|
63 |
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
|
slouken@2275
|
64 |
|
slouken@2275
|
65 |
/**
|
slouken@3407
|
66 |
* \brief A collection of pixels used in software blitting.
|
slouken@2275
|
67 |
*
|
slouken@3407
|
68 |
* \note This structure should be treated as read-only, except for \c pixels,
|
slouken@2275
|
69 |
* which, if not NULL, contains the raw pixel data for the surface.
|
slouken@2275
|
70 |
*/
|
slouken@2275
|
71 |
typedef struct SDL_Surface
|
slouken@2275
|
72 |
{
|
slouken@2275
|
73 |
Uint32 flags; /**< Read-only */
|
slouken@2275
|
74 |
SDL_PixelFormat *format; /**< Read-only */
|
slouken@2275
|
75 |
int w, h; /**< Read-only */
|
slouken@2275
|
76 |
int pitch; /**< Read-only */
|
slouken@2275
|
77 |
void *pixels; /**< Read-write */
|
slouken@2275
|
78 |
|
slouken@3708
|
79 |
/** Application data associated with the surface */
|
slouken@2275
|
80 |
void *userdata; /**< Read-write */
|
slouken@2275
|
81 |
|
slouken@3407
|
82 |
/** information needed for surfaces requiring locks */
|
slouken@2275
|
83 |
int locked; /**< Read-only */
|
slouken@2275
|
84 |
void *lock_data; /**< Read-only */
|
slouken@2275
|
85 |
|
slouken@3407
|
86 |
/** clipping information */
|
slouken@2275
|
87 |
SDL_Rect clip_rect; /**< Read-only */
|
slouken@2275
|
88 |
|
slouken@3407
|
89 |
/** info for fast blit mapping to other surfaces */
|
slouken@2275
|
90 |
struct SDL_BlitMap *map; /**< Private */
|
slouken@2275
|
91 |
|
slouken@3407
|
92 |
/** format version, bumped at every change to invalidate blit maps */
|
slouken@4929
|
93 |
int format_version; /**< Private */
|
slouken@2275
|
94 |
|
slouken@3407
|
95 |
/** Reference count -- used when freeing surface */
|
slouken@2275
|
96 |
int refcount; /**< Read-mostly */
|
slouken@2275
|
97 |
} SDL_Surface;
|
slouken@2275
|
98 |
|
slouken@2275
|
99 |
/**
|
slouken@3407
|
100 |
* \brief The type of function used for surface blitting functions.
|
slouken@2275
|
101 |
*/
|
slouken@2275
|
102 |
typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
|
slouken@2275
|
103 |
struct SDL_Surface * dst, SDL_Rect * dstrect);
|
slouken@2275
|
104 |
|
slouken@3341
|
105 |
/**
|
slouken@4424
|
106 |
* Allocate and free an RGB surface.
|
slouken@3407
|
107 |
*
|
slouken@3407
|
108 |
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
|
slouken@3407
|
109 |
* If the depth is greater than 8 bits, the pixel format is set using the
|
slouken@3407
|
110 |
* flags '[RGB]mask'.
|
slouken@3407
|
111 |
*
|
slouken@3407
|
112 |
* If the function runs out of memory, it will return NULL.
|
slouken@3407
|
113 |
*
|
slouken@3407
|
114 |
* \param flags The \c flags are obsolete and should be set to 0.
|
slouken@2275
|
115 |
*/
|
slouken@2275
|
116 |
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
|
slouken@2275
|
117 |
(Uint32 flags, int width, int height, int depth,
|
slouken@2275
|
118 |
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
slouken@2275
|
119 |
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
|
slouken@2275
|
120 |
int width,
|
slouken@2275
|
121 |
int height,
|
slouken@2275
|
122 |
int depth,
|
slouken@2275
|
123 |
int pitch,
|
slouken@2275
|
124 |
Uint32 Rmask,
|
slouken@2275
|
125 |
Uint32 Gmask,
|
slouken@2275
|
126 |
Uint32 Bmask,
|
slouken@2275
|
127 |
Uint32 Amask);
|
slouken@2275
|
128 |
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
|
slouken@2275
|
129 |
|
slouken@2275
|
130 |
/**
|
slouken@3407
|
131 |
* \brief Set the palette used by a surface.
|
slouken@3407
|
132 |
*
|
slouken@3407
|
133 |
* \return 0, or -1 if the surface format doesn't use a palette.
|
slouken@3407
|
134 |
*
|
slouken@3407
|
135 |
* \note A single palette can be shared with many surfaces.
|
slouken@2275
|
136 |
*/
|
slouken@2275
|
137 |
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
|
slouken@2275
|
138 |
SDL_Palette * palette);
|
slouken@2275
|
139 |
|
slouken@3341
|
140 |
/**
|
slouken@3407
|
141 |
* \brief Sets up a surface for directly accessing the pixels.
|
slouken@3407
|
142 |
*
|
slouken@3407
|
143 |
* Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
|
slouken@3407
|
144 |
* to and read from \c surface->pixels, using the pixel format stored in
|
slouken@3407
|
145 |
* \c surface->format. Once you are done accessing the surface, you should
|
slouken@3407
|
146 |
* use SDL_UnlockSurface() to release it.
|
slouken@3407
|
147 |
*
|
slouken@3407
|
148 |
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
|
slouken@3407
|
149 |
* to 0, then you can read and write to the surface at any time, and the
|
slouken@3407
|
150 |
* pixel format of the surface will not change.
|
slouken@3407
|
151 |
*
|
slouken@3407
|
152 |
* No operating system or library calls should be made between lock/unlock
|
slouken@3407
|
153 |
* pairs, as critical system locks may be held during this time.
|
slouken@3407
|
154 |
*
|
slouken@3407
|
155 |
* SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
|
slouken@3407
|
156 |
*
|
slouken@3407
|
157 |
* \sa SDL_UnlockSurface()
|
slouken@2275
|
158 |
*/
|
slouken@2275
|
159 |
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
|
slouken@3341
|
160 |
/** \sa SDL_LockSurface() */
|
slouken@2275
|
161 |
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
|
slouken@2275
|
162 |
|
slouken@3341
|
163 |
/**
|
slouken@3407
|
164 |
* Load a surface from a seekable SDL data source (memory or file).
|
slouken@3407
|
165 |
*
|
slouken@3407
|
166 |
* If \c freesrc is non-zero, the source will be closed after being read.
|
slouken@3407
|
167 |
*
|
slouken@3407
|
168 |
* The new surface should be freed with SDL_FreeSurface().
|
slouken@3407
|
169 |
*
|
slouken@3407
|
170 |
* \return the new surface, or NULL if there was an error.
|
slouken@2275
|
171 |
*/
|
slouken@2275
|
172 |
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
|
slouken@2275
|
173 |
int freesrc);
|
slouken@2275
|
174 |
|
slouken@3407
|
175 |
/**
|
slouken@3407
|
176 |
* Load a surface from a file.
|
slouken@3407
|
177 |
*
|
slouken@3407
|
178 |
* Convenience macro.
|
slouken@3407
|
179 |
*/
|
slouken@2275
|
180 |
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
|
slouken@2275
|
181 |
|
slouken@3341
|
182 |
/**
|
slouken@3407
|
183 |
* Save a surface to a seekable SDL data source (memory or file).
|
slouken@3407
|
184 |
*
|
slouken@3407
|
185 |
* If \c freedst is non-zero, the source will be closed after being written.
|
slouken@3407
|
186 |
*
|
slouken@3407
|
187 |
* \return 0 if successful or -1 if there was an error.
|
slouken@2275
|
188 |
*/
|
slouken@2275
|
189 |
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
slouken@2275
|
190 |
(SDL_Surface * surface, SDL_RWops * dst, int freedst);
|
slouken@2275
|
191 |
|
slouken@3407
|
192 |
/**
|
slouken@3407
|
193 |
* Save a surface to a file.
|
slouken@3407
|
194 |
*
|
slouken@3407
|
195 |
* Convenience macro.
|
slouken@3407
|
196 |
*/
|
slouken@2275
|
197 |
#define SDL_SaveBMP(surface, file) \
|
slouken@2275
|
198 |
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
|
slouken@2275
|
199 |
|
slouken@3341
|
200 |
/**
|
slouken@3407
|
201 |
* \brief Sets the RLE acceleration hint for a surface.
|
slouken@3407
|
202 |
*
|
slouken@3407
|
203 |
* \return 0 on success, or -1 if the surface is not valid
|
slouken@3407
|
204 |
*
|
slouken@3407
|
205 |
* \note If RLE is enabled, colorkey and alpha blending blits are much faster,
|
slouken@3407
|
206 |
* but the surface must be locked before directly accessing the pixels.
|
slouken@2275
|
207 |
*/
|
slouken@2275
|
208 |
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
|
slouken@2275
|
209 |
int flag);
|
slouken@2275
|
210 |
|
slouken@3341
|
211 |
/**
|
slouken@3407
|
212 |
* \brief Sets the color key (transparent pixel) in a blittable surface.
|
slouken@3407
|
213 |
*
|
slouken@3407
|
214 |
* \param surface The surface to update
|
slouken@3407
|
215 |
* \param flag Non-zero to enable colorkey and 0 to disable colorkey
|
slouken@3407
|
216 |
* \param key The transparent pixel in the native surface format
|
slouken@3407
|
217 |
*
|
slouken@3407
|
218 |
* \return 0 on success, or -1 if the surface is not valid
|
slouken@2275
|
219 |
*/
|
slouken@2275
|
220 |
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
|
slouken@3560
|
221 |
int flag, Uint32 key);
|
slouken@2275
|
222 |
|
slouken@3341
|
223 |
/**
|
slouken@3550
|
224 |
* \brief Gets the color key (transparent pixel) in a blittable surface.
|
slouken@3407
|
225 |
*
|
slouken@3407
|
226 |
* \param surface The surface to update
|
slouken@3407
|
227 |
* \param key A pointer filled in with the transparent pixel in the native
|
slouken@3407
|
228 |
* surface format
|
slouken@3407
|
229 |
*
|
slouken@3407
|
230 |
* \return 0 on success, or -1 if the surface is not valid or colorkey is not
|
slouken@3407
|
231 |
* enabled.
|
slouken@3103
|
232 |
*/
|
slouken@3103
|
233 |
extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
|
slouken@3103
|
234 |
Uint32 * key);
|
slouken@3103
|
235 |
|
slouken@2275
|
236 |
/**
|
slouken@3407
|
237 |
* \brief Set an additional color value used in blit operations.
|
slouken@3407
|
238 |
*
|
slouken@3407
|
239 |
* \param surface The surface to update.
|
slouken@3407
|
240 |
* \param r The red source color value multiplied into blit operations.
|
slouken@3407
|
241 |
* \param g The green source color value multiplied into blit operations.
|
slouken@3407
|
242 |
* \param b The blue source color value multiplied into blit operations.
|
slouken@3407
|
243 |
*
|
slouken@3407
|
244 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
245 |
*
|
slouken@3407
|
246 |
* \sa SDL_GetSurfaceColorMod()
|
slouken@2275
|
247 |
*/
|
slouken@2275
|
248 |
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
|
slouken@2275
|
249 |
Uint8 r, Uint8 g, Uint8 b);
|
slouken@2275
|
250 |
|
slouken@2275
|
251 |
|
slouken@2275
|
252 |
/**
|
slouken@3407
|
253 |
* \brief Get the additional color value used in blit operations.
|
slouken@3407
|
254 |
*
|
slouken@3407
|
255 |
* \param surface The surface to query.
|
slouken@3407
|
256 |
* \param r A pointer filled in with the source red color value.
|
slouken@3407
|
257 |
* \param g A pointer filled in with the source green color value.
|
slouken@3407
|
258 |
* \param b A pointer filled in with the source blue color value.
|
slouken@3407
|
259 |
*
|
slouken@3407
|
260 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
261 |
*
|
slouken@3407
|
262 |
* \sa SDL_SetSurfaceColorMod()
|
slouken@2275
|
263 |
*/
|
slouken@2275
|
264 |
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
|
slouken@2275
|
265 |
Uint8 * r, Uint8 * g,
|
slouken@2275
|
266 |
Uint8 * b);
|
slouken@2275
|
267 |
|
slouken@2275
|
268 |
/**
|
slouken@3407
|
269 |
* \brief Set an additional alpha value used in blit operations.
|
slouken@3407
|
270 |
*
|
slouken@3407
|
271 |
* \param surface The surface to update.
|
slouken@3407
|
272 |
* \param alpha The source alpha value multiplied into blit operations.
|
slouken@3407
|
273 |
*
|
slouken@3407
|
274 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
275 |
*
|
slouken@3407
|
276 |
* \sa SDL_GetSurfaceAlphaMod()
|
slouken@2275
|
277 |
*/
|
slouken@2275
|
278 |
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
|
slouken@2275
|
279 |
Uint8 alpha);
|
slouken@2275
|
280 |
|
slouken@2275
|
281 |
/**
|
slouken@3407
|
282 |
* \brief Get the additional alpha value used in blit operations.
|
slouken@3407
|
283 |
*
|
slouken@3407
|
284 |
* \param surface The surface to query.
|
slouken@3407
|
285 |
* \param alpha A pointer filled in with the source alpha value.
|
slouken@3407
|
286 |
*
|
slouken@3407
|
287 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
288 |
*
|
slouken@3407
|
289 |
* \sa SDL_SetSurfaceAlphaMod()
|
slouken@2275
|
290 |
*/
|
slouken@2275
|
291 |
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
|
slouken@2275
|
292 |
Uint8 * alpha);
|
slouken@2275
|
293 |
|
slouken@2275
|
294 |
/**
|
slouken@3407
|
295 |
* \brief Set the blend mode used for blit operations.
|
slouken@3407
|
296 |
*
|
slouken@3407
|
297 |
* \param surface The surface to update.
|
slouken@3407
|
298 |
* \param blendMode ::SDL_BlendMode to use for blit blending.
|
slouken@3407
|
299 |
*
|
slouken@3407
|
300 |
* \return 0 on success, or -1 if the parameters are not valid.
|
slouken@3407
|
301 |
*
|
slouken@3407
|
302 |
* \sa SDL_GetSurfaceBlendMode()
|
slouken@2275
|
303 |
*/
|
slouken@2275
|
304 |
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
|
slouken@4929
|
305 |
SDL_BlendMode blendMode);
|
slouken@2275
|
306 |
|
slouken@2275
|
307 |
/**
|
slouken@3407
|
308 |
* \brief Get the blend mode used for blit operations.
|
slouken@3407
|
309 |
*
|
slouken@3407
|
310 |
* \param surface The surface to query.
|
slouken@3407
|
311 |
* \param blendMode A pointer filled in with the current blend mode.
|
slouken@3407
|
312 |
*
|
slouken@3407
|
313 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
314 |
*
|
slouken@3407
|
315 |
* \sa SDL_SetSurfaceBlendMode()
|
slouken@2275
|
316 |
*/
|
slouken@2275
|
317 |
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
|
slouken@4929
|
318 |
SDL_BlendMode *blendMode);
|
slouken@2275
|
319 |
|
slouken@2275
|
320 |
/**
|
slouken@3407
|
321 |
* \brief Set the scale mode used for blit operations.
|
slouken@3407
|
322 |
*
|
slouken@3407
|
323 |
* \param surface The surface to update.
|
slouken@4929
|
324 |
* \param scaleMode ::SDL_ScaleMode to use for blit scaling.
|
slouken@3407
|
325 |
*
|
slouken@3407
|
326 |
* \return 0 on success, or -1 if the surface is not valid or the scale mode is
|
slouken@3407
|
327 |
* not supported.
|
slouken@3407
|
328 |
*
|
slouken@3407
|
329 |
* \note If the scale mode is not supported, the closest supported mode is
|
slouken@3407
|
330 |
* chosen. Currently only ::SDL_TEXTURESCALEMODE_FAST is supported on
|
slouken@3407
|
331 |
* surfaces.
|
slouken@3407
|
332 |
*
|
slouken@3407
|
333 |
* \sa SDL_GetSurfaceScaleMode()
|
slouken@2275
|
334 |
*/
|
slouken@2275
|
335 |
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
|
slouken@4929
|
336 |
SDL_ScaleMode scaleMode);
|
slouken@2275
|
337 |
|
slouken@2275
|
338 |
/**
|
slouken@3407
|
339 |
* \brief Get the scale mode used for blit operations.
|
slouken@3407
|
340 |
*
|
slouken@3407
|
341 |
* \param surface The surface to query.
|
slouken@3407
|
342 |
* \param scaleMode A pointer filled in with the current scale mode.
|
slouken@3407
|
343 |
*
|
slouken@3407
|
344 |
* \return 0 on success, or -1 if the surface is not valid.
|
slouken@3407
|
345 |
*
|
slouken@3407
|
346 |
* \sa SDL_SetSurfaceScaleMode()
|
slouken@2275
|
347 |
*/
|
slouken@2275
|
348 |
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
|
slouken@4929
|
349 |
SDL_ScaleMode *scaleMode);
|
slouken@2275
|
350 |
|
slouken@3341
|
351 |
/**
|
slouken@3407
|
352 |
* Sets the clipping rectangle for the destination surface in a blit.
|
slouken@3407
|
353 |
*
|
slouken@3407
|
354 |
* If the clip rectangle is NULL, clipping will be disabled.
|
slouken@3407
|
355 |
*
|
slouken@3407
|
356 |
* If the clip rectangle doesn't intersect the surface, the function will
|
slouken@3407
|
357 |
* return SDL_FALSE and blits will be completely clipped. Otherwise the
|
slouken@3407
|
358 |
* function returns SDL_TRUE and blits to the surface will be clipped to
|
slouken@3407
|
359 |
* the intersection of the surface area and the clipping rectangle.
|
slouken@3407
|
360 |
*
|
slouken@3407
|
361 |
* Note that blits are automatically clipped to the edges of the source
|
slouken@3407
|
362 |
* and destination surfaces.
|
slouken@2275
|
363 |
*/
|
slouken@2275
|
364 |
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
|
slouken@2275
|
365 |
const SDL_Rect * rect);
|
slouken@2275
|
366 |
|
slouken@3341
|
367 |
/**
|
slouken@3407
|
368 |
* Gets the clipping rectangle for the destination surface in a blit.
|
slouken@3407
|
369 |
*
|
slouken@3407
|
370 |
* \c rect must be a pointer to a valid rectangle which will be filled
|
slouken@3407
|
371 |
* with the correct values.
|
slouken@2275
|
372 |
*/
|
slouken@2275
|
373 |
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
|
slouken@2275
|
374 |
SDL_Rect * rect);
|
slouken@2275
|
375 |
|
slouken@3341
|
376 |
/**
|
slouken@3407
|
377 |
* Creates a new surface of the specified format, and then copies and maps
|
slouken@3407
|
378 |
* the given surface to it so the blit of the converted surface will be as
|
slouken@3407
|
379 |
* fast as possible. If this function fails, it returns NULL.
|
slouken@3407
|
380 |
*
|
slouken@3407
|
381 |
* The \c flags parameter is passed to SDL_CreateRGBSurface() and has those
|
slouken@3407
|
382 |
* semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and
|
slouken@3407
|
383 |
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
|
slouken@3407
|
384 |
* surface.
|
slouken@2275
|
385 |
*/
|
slouken@2275
|
386 |
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
|
slouken@2275
|
387 |
(SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
|
slouken@2275
|
388 |
|
slouken@3341
|
389 |
/**
|
slouken@3434
|
390 |
* \brief Copy a block of pixels of one format to another format
|
slouken@3434
|
391 |
*/
|
slouken@3434
|
392 |
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
|
slouken@3434
|
393 |
Uint32 src_format,
|
slouken@3434
|
394 |
const void * src, int src_pitch,
|
slouken@3434
|
395 |
Uint32 dst_format,
|
slouken@3434
|
396 |
void * dst, int dst_pitch);
|
slouken@3434
|
397 |
|
slouken@3434
|
398 |
/**
|
slouken@3407
|
399 |
* Draws a point with \c color.
|
slouken@3407
|
400 |
*
|
slouken@3407
|
401 |
* The color should be a pixel of the format used by the surface, and
|
slouken@3407
|
402 |
* can be generated by the SDL_MapRGB() function.
|
slouken@3407
|
403 |
*
|
slouken@3407
|
404 |
* \return 0 on success, or -1 on error.
|
slouken@2901
|
405 |
*/
|
slouken@2901
|
406 |
extern DECLSPEC int SDLCALL SDL_DrawPoint
|
slouken@2901
|
407 |
(SDL_Surface * dst, int x, int y, Uint32 color);
|
slouken@3536
|
408 |
extern DECLSPEC int SDLCALL SDL_DrawPoints
|
slouken@3536
|
409 |
(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
slouken@2901
|
410 |
|
slouken@3341
|
411 |
/**
|
slouken@3407
|
412 |
* Blends a point with an RGBA value.
|
slouken@3407
|
413 |
*
|
slouken@3407
|
414 |
* \return 0 on success, or -1 on error.
|
slouken@2901
|
415 |
*/
|
slouken@3596
|
416 |
extern DECLSPEC int SDLCALL SDL_BlendPoint
|
slouken@3536
|
417 |
(SDL_Surface * dst, int x, int y,
|
slouken@4929
|
418 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3536
|
419 |
extern DECLSPEC int SDLCALL SDL_BlendPoints
|
slouken@3536
|
420 |
(SDL_Surface * dst, const SDL_Point * points, int count,
|
slouken@4929
|
421 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@2901
|
422 |
|
slouken@3341
|
423 |
/**
|
slouken@3407
|
424 |
* Draws a line with \c color.
|
slouken@3407
|
425 |
*
|
slouken@3407
|
426 |
* The color should be a pixel of the format used by the surface, and
|
slouken@3407
|
427 |
* can be generated by the SDL_MapRGB() function.
|
slouken@3407
|
428 |
*
|
slouken@3407
|
429 |
* \return 0 on success, or -1 on error.
|
slouken@2888
|
430 |
*/
|
slouken@2888
|
431 |
extern DECLSPEC int SDLCALL SDL_DrawLine
|
slouken@2888
|
432 |
(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
|
slouken@3536
|
433 |
extern DECLSPEC int SDLCALL SDL_DrawLines
|
slouken@3536
|
434 |
(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
slouken@2888
|
435 |
|
slouken@3341
|
436 |
/**
|
slouken@3407
|
437 |
* Blends an RGBA value along a line.
|
slouken@3407
|
438 |
*
|
slouken@3407
|
439 |
* \return 0 on success, or -1 on error.
|
slouken@2888
|
440 |
*/
|
slouken@2888
|
441 |
extern DECLSPEC int SDLCALL SDL_BlendLine
|
slouken@3536
|
442 |
(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
slouken@4929
|
443 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3536
|
444 |
extern DECLSPEC int SDLCALL SDL_BlendLines
|
slouken@3536
|
445 |
(SDL_Surface * dst, const SDL_Point * points, int count,
|
slouken@4929
|
446 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@2888
|
447 |
|
slouken@3341
|
448 |
/**
|
slouken@3593
|
449 |
* Draws the given rectangle with \c color.
|
slouken@3593
|
450 |
*
|
slouken@3593
|
451 |
* If \c rect is NULL, the whole surface will be outlined with \c color.
|
slouken@3593
|
452 |
*
|
slouken@3593
|
453 |
* The color should be a pixel of the format used by the surface, and
|
slouken@3593
|
454 |
* can be generated by the SDL_MapRGB() function.
|
slouken@3593
|
455 |
*
|
slouken@3593
|
456 |
* \return 0 on success, or -1 on error.
|
slouken@3593
|
457 |
*/
|
slouken@3593
|
458 |
extern DECLSPEC int SDLCALL SDL_DrawRect
|
slouken@3593
|
459 |
(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
|
slouken@3593
|
460 |
extern DECLSPEC int SDLCALL SDL_DrawRects
|
slouken@3593
|
461 |
(SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);
|
slouken@3593
|
462 |
|
slouken@3593
|
463 |
/**
|
slouken@3596
|
464 |
* Blends an RGBA value into the outline of the given rectangle.
|
slouken@3593
|
465 |
*
|
slouken@3596
|
466 |
* If \c rect is NULL, the whole surface will have a blended outline.
|
slouken@3593
|
467 |
*
|
slouken@3593
|
468 |
* \return 0 on success, or -1 on error.
|
slouken@3593
|
469 |
*/
|
slouken@3593
|
470 |
extern DECLSPEC int SDLCALL SDL_BlendRect
|
slouken@3593
|
471 |
(SDL_Surface * dst, const SDL_Rect * rect,
|
slouken@4929
|
472 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3593
|
473 |
extern DECLSPEC int SDLCALL SDL_BlendRects
|
slouken@3593
|
474 |
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
|
slouken@4929
|
475 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3593
|
476 |
|
slouken@3593
|
477 |
/**
|
slouken@3407
|
478 |
* Performs a fast fill of the given rectangle with \c color.
|
slouken@3407
|
479 |
*
|
slouken@3536
|
480 |
* If \c rect is NULL, the whole surface will be filled with \c color.
|
slouken@3407
|
481 |
*
|
slouken@3407
|
482 |
* The color should be a pixel of the format used by the surface, and
|
slouken@3407
|
483 |
* can be generated by the SDL_MapRGB() function.
|
slouken@3407
|
484 |
*
|
slouken@3407
|
485 |
* \return 0 on success, or -1 on error.
|
slouken@2275
|
486 |
*/
|
slouken@2275
|
487 |
extern DECLSPEC int SDLCALL SDL_FillRect
|
slouken@3536
|
488 |
(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
|
slouken@3536
|
489 |
extern DECLSPEC int SDLCALL SDL_FillRects
|
slouken@3536
|
490 |
(SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);
|
slouken@2275
|
491 |
|
slouken@3341
|
492 |
/**
|
slouken@3407
|
493 |
* Blends an RGBA value into the given rectangle.
|
slouken@3407
|
494 |
*
|
slouken@3596
|
495 |
* If \c rect is NULL, the whole surface will be blended with the color.
|
slouken@3407
|
496 |
*
|
slouken@3407
|
497 |
* \return This function returns 0 on success, or -1 on error.
|
slouken@2888
|
498 |
*/
|
slouken@3593
|
499 |
extern DECLSPEC int SDLCALL SDL_BlendFillRect
|
slouken@3536
|
500 |
(SDL_Surface * dst, const SDL_Rect * rect,
|
slouken@4929
|
501 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3593
|
502 |
extern DECLSPEC int SDLCALL SDL_BlendFillRects
|
slouken@3536
|
503 |
(SDL_Surface * dst, const SDL_Rect ** rects, int count,
|
slouken@4929
|
504 |
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
slouken@3596
|
505 |
|
slouken@3341
|
506 |
/**
|
slouken@3407
|
507 |
* Performs a fast blit from the source surface to the destination surface.
|
slouken@3407
|
508 |
*
|
slouken@3407
|
509 |
* This assumes that the source and destination rectangles are
|
slouken@3407
|
510 |
* the same size. If either \c srcrect or \c dstrect are NULL, the entire
|
slouken@3407
|
511 |
* surface (\c src or \c dst) is copied. The final blit rectangles are saved
|
slouken@3407
|
512 |
* in \c srcrect and \c dstrect after all clipping is performed.
|
slouken@3407
|
513 |
*
|
slouken@3407
|
514 |
* \return If the blit is successful, it returns 0, otherwise it returns -1.
|
slouken@2275
|
515 |
*
|
slouken@3407
|
516 |
* The blit function should not be called on a locked surface.
|
slouken@2275
|
517 |
*
|
slouken@3407
|
518 |
* The blit semantics for surfaces with and without alpha and colorkey
|
slouken@3407
|
519 |
* are defined as follows:
|
slouken@3407
|
520 |
* \verbatim
|
slouken@3407
|
521 |
RGBA->RGB:
|
slouken@3407
|
522 |
SDL_SRCALPHA set:
|
slouken@3407
|
523 |
alpha-blend (using alpha-channel).
|
slouken@3407
|
524 |
SDL_SRCCOLORKEY ignored.
|
slouken@3407
|
525 |
SDL_SRCALPHA not set:
|
slouken@3407
|
526 |
copy RGB.
|
slouken@3407
|
527 |
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
slouken@3407
|
528 |
RGB values of the source colour key, ignoring alpha in the
|
slouken@3407
|
529 |
comparison.
|
slouken@3407
|
530 |
|
slouken@3407
|
531 |
RGB->RGBA:
|
slouken@3407
|
532 |
SDL_SRCALPHA set:
|
slouken@3407
|
533 |
alpha-blend (using the source per-surface alpha value);
|
slouken@3407
|
534 |
set destination alpha to opaque.
|
slouken@3407
|
535 |
SDL_SRCALPHA not set:
|
slouken@3407
|
536 |
copy RGB, set destination alpha to source per-surface alpha value.
|
slouken@3407
|
537 |
both:
|
slouken@3407
|
538 |
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
slouken@3407
|
539 |
source colour key.
|
slouken@3407
|
540 |
|
slouken@3407
|
541 |
RGBA->RGBA:
|
slouken@3407
|
542 |
SDL_SRCALPHA set:
|
slouken@3407
|
543 |
alpha-blend (using the source alpha channel) the RGB values;
|
slouken@3407
|
544 |
leave destination alpha untouched. [Note: is this correct?]
|
slouken@3407
|
545 |
SDL_SRCCOLORKEY ignored.
|
slouken@3407
|
546 |
SDL_SRCALPHA not set:
|
slouken@3407
|
547 |
copy all of RGBA to the destination.
|
slouken@3407
|
548 |
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
slouken@3407
|
549 |
RGB values of the source colour key, ignoring alpha in the
|
slouken@3407
|
550 |
comparison.
|
slouken@3407
|
551 |
|
slouken@3407
|
552 |
RGB->RGB:
|
slouken@3407
|
553 |
SDL_SRCALPHA set:
|
slouken@3407
|
554 |
alpha-blend (using the source per-surface alpha value).
|
slouken@3407
|
555 |
SDL_SRCALPHA not set:
|
slouken@3407
|
556 |
copy RGB.
|
slouken@3407
|
557 |
both:
|
slouken@3407
|
558 |
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
slouken@3407
|
559 |
source colour key.
|
slouken@3407
|
560 |
\endverbatim
|
slouken@3407
|
561 |
*
|
slouken@3407
|
562 |
* If either of the surfaces were in video memory, and the blit returns -2,
|
slouken@3407
|
563 |
* the video memory was lost, so it should be reloaded with artwork and
|
slouken@3407
|
564 |
* re-blitted:
|
slouken@3407
|
565 |
* @code
|
slouken@3407
|
566 |
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
|
slouken@3407
|
567 |
* while ( SDL_LockSurface(image) < 0 )
|
slouken@3407
|
568 |
* Sleep(10);
|
slouken@3407
|
569 |
* -- Write image pixels to image->pixels --
|
slouken@3407
|
570 |
* SDL_UnlockSurface(image);
|
slouken@3407
|
571 |
* }
|
slouken@3407
|
572 |
* @endcode
|
slouken@3407
|
573 |
*
|
slouken@3407
|
574 |
* This happens under DirectX 5.0 when the system switches away from your
|
slouken@3407
|
575 |
* fullscreen application. The lock will also fail until you have access
|
slouken@3407
|
576 |
* to the video memory again.
|
slouken@3407
|
577 |
*
|
slouken@3407
|
578 |
* You should call SDL_BlitSurface() unless you know exactly how SDL
|
slouken@3407
|
579 |
* blitting works internally and how to use the other blit functions.
|
slouken@2275
|
580 |
*/
|
slouken@2275
|
581 |
#define SDL_BlitSurface SDL_UpperBlit
|
slouken@2275
|
582 |
|
slouken@3407
|
583 |
/**
|
slouken@3407
|
584 |
* This is the public blit function, SDL_BlitSurface(), and it performs
|
slouken@3341
|
585 |
* rectangle validation and clipping before passing it to SDL_LowerBlit()
|
slouken@3341
|
586 |
*/
|
slouken@2275
|
587 |
extern DECLSPEC int SDLCALL SDL_UpperBlit
|
slouken@4949
|
588 |
(SDL_Surface * src, const SDL_Rect * srcrect,
|
slouken@2275
|
589 |
SDL_Surface * dst, SDL_Rect * dstrect);
|
slouken@3341
|
590 |
|
slouken@3407
|
591 |
/**
|
slouken@3407
|
592 |
* This is a semi-private blit function and it performs low-level surface
|
slouken@3341
|
593 |
* blitting only.
|
slouken@3341
|
594 |
*/
|
slouken@2275
|
595 |
extern DECLSPEC int SDLCALL SDL_LowerBlit
|
slouken@2275
|
596 |
(SDL_Surface * src, SDL_Rect * srcrect,
|
slouken@2275
|
597 |
SDL_Surface * dst, SDL_Rect * dstrect);
|
slouken@2275
|
598 |
|
slouken@2275
|
599 |
/**
|
slouken@3407
|
600 |
* \brief Perform a fast, low quality, stretch blit between two surfaces of the
|
slouken@3407
|
601 |
* same pixel format.
|
slouken@3407
|
602 |
*
|
slouken@3407
|
603 |
* \note This function uses a static buffer, and is not thread-safe.
|
slouken@2275
|
604 |
*/
|
slouken@2275
|
605 |
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
|
slouken@2828
|
606 |
const SDL_Rect * srcrect,
|
slouken@2275
|
607 |
SDL_Surface * dst,
|
slouken@2828
|
608 |
const SDL_Rect * dstrect);
|
slouken@2275
|
609 |
|
slouken@2275
|
610 |
/* Ends C function definitions when using C++ */
|
slouken@2275
|
611 |
#ifdef __cplusplus
|
slouken@2275
|
612 |
/* *INDENT-OFF* */
|
slouken@2275
|
613 |
}
|
slouken@2275
|
614 |
/* *INDENT-ON* */
|
slouken@2275
|
615 |
#endif
|
slouken@2275
|
616 |
#include "close_code.h"
|
slouken@2275
|
617 |
|
slouken@2275
|
618 |
#endif /* _SDL_surface_h */
|
slouken@2275
|
619 |
|
slouken@2275
|
620 |
/* vi: set ts=4 sw=4 expandtab: */
|