SDL_ExitProcess() was ignoring exit code parameter.
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
25 * Header file for ::SDL_surface definition and management functions.
28 #ifndef _SDL_surface_h
29 #define _SDL_surface_h
31 #include "SDL_stdinc.h"
32 #include "SDL_pixels.h"
34 #include "SDL_blendmode.h"
35 #include "SDL_rwops.h"
37 #include "begin_code.h"
38 /* Set up for C function definitions, even when using C++ */
48 * These are the currently supported flags for the ::SDL_surface.
51 * Used internally (read-only).
54 #define SDL_SWSURFACE 0 /**< Just here for compatibility */
55 #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */
56 #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */
57 #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */
58 /*@}*//*Surface flags*/
61 * Evaluates to true if the surface needs to be locked before access.
63 #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
66 * \brief A collection of pixels used in software blitting.
68 * \note This structure should be treated as read-only, except for \c pixels,
69 * which, if not NULL, contains the raw pixel data for the surface.
71 typedef struct SDL_Surface
73 Uint32 flags; /**< Read-only */
74 SDL_PixelFormat *format; /**< Read-only */
75 int w, h; /**< Read-only */
76 int pitch; /**< Read-only */
77 void *pixels; /**< Read-write */
79 /** Application data associated with the surface */
80 void *userdata; /**< Read-write */
82 /** information needed for surfaces requiring locks */
83 int locked; /**< Read-only */
84 void *lock_data; /**< Read-only */
86 /** clipping information */
87 SDL_Rect clip_rect; /**< Read-only */
89 /** info for fast blit mapping to other surfaces */
90 struct SDL_BlitMap *map; /**< Private */
92 /** Reference count -- used when freeing surface */
93 int refcount; /**< Read-mostly */
97 * \brief The type of function used for surface blitting functions.
99 typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
100 struct SDL_Surface * dst, SDL_Rect * dstrect);
103 * Allocate and free an RGB surface.
105 * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
106 * If the depth is greater than 8 bits, the pixel format is set using the
109 * If the function runs out of memory, it will return NULL.
111 * \param flags The \c flags are obsolete and should be set to 0.
113 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
114 (Uint32 flags, int width, int height, int depth,
115 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
116 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
125 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
128 * \brief Set the palette used by a surface.
130 * \return 0, or -1 if the surface format doesn't use a palette.
132 * \note A single palette can be shared with many surfaces.
134 extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
135 SDL_Palette * palette);
138 * \brief Sets up a surface for directly accessing the pixels.
140 * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
141 * to and read from \c surface->pixels, using the pixel format stored in
142 * \c surface->format. Once you are done accessing the surface, you should
143 * use SDL_UnlockSurface() to release it.
145 * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
146 * to 0, then you can read and write to the surface at any time, and the
147 * pixel format of the surface will not change.
149 * No operating system or library calls should be made between lock/unlock
150 * pairs, as critical system locks may be held during this time.
152 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
154 * \sa SDL_UnlockSurface()
156 extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
157 /** \sa SDL_LockSurface() */
158 extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
161 * Load a surface from a seekable SDL data stream (memory or file).
163 * If \c freesrc is non-zero, the stream will be closed after being read.
165 * The new surface should be freed with SDL_FreeSurface().
167 * \return the new surface, or NULL if there was an error.
169 extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
173 * Load a surface from a file.
177 #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
180 * Save a surface to a seekable SDL data stream (memory or file).
182 * If \c freedst is non-zero, the stream will be closed after being written.
184 * \return 0 if successful or -1 if there was an error.
186 extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
187 (SDL_Surface * surface, SDL_RWops * dst, int freedst);
190 * Save a surface to a file.
194 #define SDL_SaveBMP(surface, file) \
195 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
198 * \brief Sets the RLE acceleration hint for a surface.
200 * \return 0 on success, or -1 if the surface is not valid
202 * \note If RLE is enabled, colorkey and alpha blending blits are much faster,
203 * but the surface must be locked before directly accessing the pixels.
205 extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
209 * \brief Sets the color key (transparent pixel) in a blittable surface.
211 * \param surface The surface to update
212 * \param flag Non-zero to enable colorkey and 0 to disable colorkey
213 * \param key The transparent pixel in the native surface format
215 * \return 0 on success, or -1 if the surface is not valid
217 * You can pass SDL_RLEACCEL to enable RLE accelerated blits.
219 extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
220 int flag, Uint32 key);
223 * \brief Gets the color key (transparent pixel) in a blittable surface.
225 * \param surface The surface to update
226 * \param key A pointer filled in with the transparent pixel in the native
229 * \return 0 on success, or -1 if the surface is not valid or colorkey is not
232 extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
236 * \brief Set an additional color value used in blit operations.
238 * \param surface The surface to update.
239 * \param r The red color value multiplied into blit operations.
240 * \param g The green color value multiplied into blit operations.
241 * \param b The blue color value multiplied into blit operations.
243 * \return 0 on success, or -1 if the surface is not valid.
245 * \sa SDL_GetSurfaceColorMod()
247 extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
248 Uint8 r, Uint8 g, Uint8 b);
252 * \brief Get the additional color value used in blit operations.
254 * \param surface The surface to query.
255 * \param r A pointer filled in with the current red color value.
256 * \param g A pointer filled in with the current green color value.
257 * \param b A pointer filled in with the current blue color value.
259 * \return 0 on success, or -1 if the surface is not valid.
261 * \sa SDL_SetSurfaceColorMod()
263 extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
264 Uint8 * r, Uint8 * g,
268 * \brief Set an additional alpha value used in blit operations.
270 * \param surface The surface to update.
271 * \param alpha The alpha value multiplied into blit operations.
273 * \return 0 on success, or -1 if the surface is not valid.
275 * \sa SDL_GetSurfaceAlphaMod()
277 extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
281 * \brief Get the additional alpha value used in blit operations.
283 * \param surface The surface to query.
284 * \param alpha A pointer filled in with the current alpha value.
286 * \return 0 on success, or -1 if the surface is not valid.
288 * \sa SDL_SetSurfaceAlphaMod()
290 extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
294 * \brief Set the blend mode used for blit operations.
296 * \param surface The surface to update.
297 * \param blendMode ::SDL_BlendMode to use for blit blending.
299 * \return 0 on success, or -1 if the parameters are not valid.
301 * \sa SDL_GetSurfaceBlendMode()
303 extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
304 SDL_BlendMode blendMode);
307 * \brief Get the blend mode used for blit operations.
309 * \param surface The surface to query.
310 * \param blendMode A pointer filled in with the current blend mode.
312 * \return 0 on success, or -1 if the surface is not valid.
314 * \sa SDL_SetSurfaceBlendMode()
316 extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
317 SDL_BlendMode *blendMode);
320 * Sets the clipping rectangle for the destination surface in a blit.
322 * If the clip rectangle is NULL, clipping will be disabled.
324 * If the clip rectangle doesn't intersect the surface, the function will
325 * return SDL_FALSE and blits will be completely clipped. Otherwise the
326 * function returns SDL_TRUE and blits to the surface will be clipped to
327 * the intersection of the surface area and the clipping rectangle.
329 * Note that blits are automatically clipped to the edges of the source
330 * and destination surfaces.
332 extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
333 const SDL_Rect * rect);
336 * Gets the clipping rectangle for the destination surface in a blit.
338 * \c rect must be a pointer to a valid rectangle which will be filled
339 * with the correct values.
341 extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
345 * Creates a new surface of the specified format, and then copies and maps
346 * the given surface to it so the blit of the converted surface will be as
347 * fast as possible. If this function fails, it returns NULL.
349 * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those
350 * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and
351 * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
354 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
355 (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
356 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
357 (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
360 * \brief Copy a block of pixels of one format to another format
362 * \return 0 on success, or -1 if there was an error
364 extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
366 const void * src, int src_pitch,
368 void * dst, int dst_pitch);
371 * Performs a fast fill of the given rectangle with \c color.
373 * If \c rect is NULL, the whole surface will be filled with \c color.
375 * The color should be a pixel of the format used by the surface, and
376 * can be generated by the SDL_MapRGB() function.
378 * \return 0 on success, or -1 on error.
380 extern DECLSPEC int SDLCALL SDL_FillRect
381 (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
382 extern DECLSPEC int SDLCALL SDL_FillRects
383 (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
386 * Performs a fast blit from the source surface to the destination surface.
388 * This assumes that the source and destination rectangles are
389 * the same size. If either \c srcrect or \c dstrect are NULL, the entire
390 * surface (\c src or \c dst) is copied. The final blit rectangles are saved
391 * in \c srcrect and \c dstrect after all clipping is performed.
393 * \return If the blit is successful, it returns 0, otherwise it returns -1.
395 * The blit function should not be called on a locked surface.
397 * The blit semantics for surfaces with and without alpha and colorkey
398 * are defined as follows:
402 alpha-blend (using alpha-channel).
403 SDL_SRCCOLORKEY ignored.
404 SDL_SRCALPHA not set:
406 if SDL_SRCCOLORKEY set, only copy the pixels matching the
407 RGB values of the source colour key, ignoring alpha in the
412 alpha-blend (using the source per-surface alpha value);
413 set destination alpha to opaque.
414 SDL_SRCALPHA not set:
415 copy RGB, set destination alpha to source per-surface alpha value.
417 if SDL_SRCCOLORKEY set, only copy the pixels matching the
422 alpha-blend (using the source alpha channel) the RGB values;
423 leave destination alpha untouched. [Note: is this correct?]
424 SDL_SRCCOLORKEY ignored.
425 SDL_SRCALPHA not set:
426 copy all of RGBA to the destination.
427 if SDL_SRCCOLORKEY set, only copy the pixels matching the
428 RGB values of the source colour key, ignoring alpha in the
433 alpha-blend (using the source per-surface alpha value).
434 SDL_SRCALPHA not set:
437 if SDL_SRCCOLORKEY set, only copy the pixels matching the
441 * You should call SDL_BlitSurface() unless you know exactly how SDL
442 * blitting works internally and how to use the other blit functions.
444 #define SDL_BlitSurface SDL_UpperBlit
447 * This is the public blit function, SDL_BlitSurface(), and it performs
448 * rectangle validation and clipping before passing it to SDL_LowerBlit()
450 extern DECLSPEC int SDLCALL SDL_UpperBlit
451 (SDL_Surface * src, const SDL_Rect * srcrect,
452 SDL_Surface * dst, SDL_Rect * dstrect);
455 * This is a semi-private blit function and it performs low-level surface
458 extern DECLSPEC int SDLCALL SDL_LowerBlit
459 (SDL_Surface * src, SDL_Rect * srcrect,
460 SDL_Surface * dst, SDL_Rect * dstrect);
463 * \brief Perform a fast, low quality, stretch blit between two surfaces of the
466 * \note This function uses a static buffer, and is not thread-safe.
468 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
469 const SDL_Rect * srcrect,
471 const SDL_Rect * dstrect);
473 #define SDL_BlitScaled SDL_UpperBlitScaled
476 * This is the public scaled blit function, SDL_BlitScaled(), and it performs
477 * rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
479 extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
480 (SDL_Surface * src, const SDL_Rect * srcrect,
481 SDL_Surface * dst, SDL_Rect * dstrect);
484 * This is a semi-private blit function and it performs low-level surface
485 * scaled blitting only.
487 extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
488 (SDL_Surface * src, SDL_Rect * srcrect,
489 SDL_Surface * dst, SDL_Rect * dstrect);
492 /* Ends C function definitions when using C++ */
498 #include "close_code.h"
500 #endif /* _SDL_surface_h */
502 /* vi: set ts=4 sw=4 expandtab: */