7 * These are the currently supported flags for the ::SDL_surface.
9 * Used internally (read-only).
12 SDL_SWSURFACE = 0; {**< Just here for compatibility *}
13 SDL_PREALLOC = $00000001; {**< Surface uses preallocated memory *}
14 SDL_RLEACCEL = $00000002; {**< Surface is RLE encoded *}
15 SDL_DONTFREE = $00000004; {**< Surface is referenced internally *}
20 * Evaluates to true if the surface needs to be locked before access.
23 //SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
27 * A collection of pixels used in software blitting.
29 * This structure should be treated as read-only, except for \c pixels,
30 * which, if not NULL, contains the raw pixel data for the surface.
33 PSDL_BlitMap = ^TSDL_BlitMap;
38 PSDL_Surface = ^TSDL_Surface;
40 flags: UInt32; {**< Read-only *}
41 format: PSDL_PixelFormat; {**< Read-only *}
42 w, h: SInt32; {**< Read-only *}
43 pitch: SInt32; {**< Read-only *}
44 pixels: Pointer; {**< Read-write *}
46 {** Application data associated with the surface *}
47 userdata: Pointer; {**< Read-write *}
49 {** information needed for surfaces requiring locks *}
50 locked: SInt32; {**< Read-only *}
51 lock_data: Pointer; {**< Read-only *}
53 {** clipping information *}
54 clip_rect: PSDL_Rect; {**< Read-only *}
56 {** info for fast blit mapping to other surfaces *}
57 map: Pointer; {**< Private *} //SDL_BlitMap
59 {** Reference count -- used when freeing surface *}
60 refcount: SInt32; {**< Read-mostly *}
64 * The type of function used for surface blitting functions.
67 TSDL_Blit = function(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32;
70 * Allocate and free an RGB surface.
72 * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
73 * If the depth is greater than 8 bits, the pixel format is set using the
76 * If the function runs out of memory, it will return NULL.
78 * flags The flags are obsolete and should be set to 0.
81 function SDL_CreateRGBSurface(flags: UInt32; width: SInt32; height: SInt32; depth: SInt32; Rmask: UInt32; Gmask: UInt32; Bmask: UInt32; Amask: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CreateRGBSurface' {$ENDIF} {$ENDIF};
82 function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width: SInt32; height: SInt32; depth: SInt32; pitch: SInt32; Rmask: UInt32; Gmask: UInt32; Bmask: UInt32; Amask: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CreateRGBSurfaceFrom' {$ENDIF} {$ENDIF};
83 procedure SDL_FreeSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeSurface' {$ENDIF} {$ENDIF};
86 * Set the palette used by a surface.
88 * 0, or -1 if the surface format doesn't use a palette.
90 * A single palette can be shared with many surfaces.
93 function SDL_SetSurfacePalette(surface: PSDL_Surface; palette: PSDL_Palette): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfacePalette' {$ENDIF} {$ENDIF};
96 * Sets up a surface for directly accessing the pixels.
98 * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
99 * to and read from surface.pixels, using the pixel format stored in
100 * surface.format. Once you are done accessing the surface, you should
101 * use SDL_UnlockSurface() to release it.
103 * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
104 * to 0, then you can read and write to the surface at any time, and the
105 * pixel format of the surface will not change.
107 * No operating system or library calls should be made between lock/unlock
108 * pairs, as critical system locks may be held during this time.
110 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
112 * SDL_UnlockSurface()
115 function SDL_LockSurface(surface: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockSurface' {$ENDIF} {$ENDIF};
117 {** SDL_LockSurface() *}
119 procedure SDL_UnlockSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockSurface' {$ENDIF} {$ENDIF};
122 * Load a surface from a seekable SDL data stream (memory or file).
124 * If freesrc is non-zero, the stream will be closed after being read.
126 * The new surface should be freed with SDL_FreeSurface().
128 * the new surface, or NULL if there was an error.
131 function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: SInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF} {$ENDIF};
134 * Load a surface from a file.
139 function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
142 * Save a surface to a seekable SDL data stream (memory or file).
144 * If freedst is non-zero, the stream will be closed after being written.
146 * 0 if successful or -1 if there was an error.
149 function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF} {$ENDIF};
152 * Save a surface to a file.
157 #define SDL_SaveBMP(surface, file) \
158 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
162 * Sets the RLE acceleration hint for a surface.
164 * 0 on success, or -1 if the surface is not valid
166 * If RLE is enabled, colorkey and alpha blending blits are much faster,
167 * but the surface must be locked before directly accessing the pixels.
170 function SDL_SetSurfaceRLE(surface: PSDL_Surface; flag: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceRLE' {$ENDIF} {$ENDIF};
173 * Sets the color key (transparent pixel) in a blittable surface.
175 * surface The surface to update
176 * flag Non-zero to enable colorkey and 0 to disable colorkey
177 * key The transparent pixel in the native surface format
179 * 0 on success, or -1 if the surface is not valid
181 * You can pass SDL_RLEACCEL to enable RLE accelerated blits.
184 function SDL_SetColorKey(surface: PSDL_Surface; flag: SInt32; key: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetColorKey' {$ENDIF} {$ENDIF};
187 * Gets the color key (transparent pixel) in a blittable surface.
189 * surface The surface to update
190 * key A pointer filled in with the transparent pixel in the native
193 * 0 on success, or -1 if the surface is not valid or colorkey is not
197 function SDL_GetColorKey(surface: PSDL_Surface; key: PUInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetColorKey' {$ENDIF} {$ENDIF};
200 * Set an additional color value used in blit operations.
202 * surface The surface to update.
203 * r The red color value multiplied into blit operations.
204 * g The green color value multiplied into blit operations.
205 * b The blue color value multiplied into blit operations.
207 * 0 on success, or -1 if the surface is not valid.
209 * SDL_GetSurfaceColorMod()
212 function SDL_SetSurfaceColorMod(surface: PSDL_Surface; r: UInt8; g: UInt8; b: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceColorMod' {$ENDIF} {$ENDIF};
215 * Get the additional color value used in blit operations.
217 * surface The surface to query.
218 * r A pointer filled in with the current red color value.
219 * g A pointer filled in with the current green color value.
220 * b A pointer filled in with the current blue color value.
222 * 0 on success, or -1 if the surface is not valid.
224 * SDL_SetSurfaceColorMod()
227 function SDL_GetSurfaceColorMod(surface: PSDL_Surface; r: PUInt8; g: PUInt8; b: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceColorMod' {$ENDIF} {$ENDIF};
230 * Set an additional alpha value used in blit operations.
232 * surface The surface to update.
233 * alpha The alpha value multiplied into blit operations.
235 * 0 on success, or -1 if the surface is not valid.
237 * SDL_GetSurfaceAlphaMod()
240 function SDL_SetSurfaceAlphaMod(surface: PSDL_Surface; alpha: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
243 * Get the additional alpha value used in blit operations.
245 * surface The surface to query.
246 * alpha A pointer filled in with the current alpha value.
248 * 0 on success, or -1 if the surface is not valid.
250 * SDL_SetSurfaceAlphaMod()
253 function SDL_GetSurfaceAlphaMod(surface: PSDL_Surface; alpha: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
256 * Set the blend mode used for blit operations.
258 * surface The surface to update.
259 * blendMode ::SDL_BlendMode to use for blit blending.
261 * 0 on success, or -1 if the parameters are not valid.
263 * SDL_GetSurfaceBlendMode()
266 function SDL_SetSurfaceBlendMode(surface: PSDL_Surface; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceBlendMode' {$ENDIF} {$ENDIF};
269 * Get the blend mode used for blit operations.
271 * surface The surface to query.
272 * blendMode A pointer filled in with the current blend mode.
274 * 0 on success, or -1 if the surface is not valid.
276 * SDL_SetSurfaceBlendMode()
279 function SDL_GetSurfaceBlendMode(surface: PSDL_Surface; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceBlendMode' {$ENDIF} {$ENDIF};
282 * Sets the clipping rectangle for the destination surface in a blit.
284 * If the clip rectangle is NULL, clipping will be disabled.
286 * If the clip rectangle doesn't intersect the surface, the function will
287 * return SDL_FALSE and blits will be completely clipped. Otherwise the
288 * function returns SDL_TRUE and blits to the surface will be clipped to
289 * the intersection of the surface area and the clipping rectangle.
291 * Note that blits are automatically clipped to the edges of the source
292 * and destination surfaces.
295 function SDL_SetClipRect(surface: PSDL_Surface; const rect: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetClipRect' {$ENDIF} {$ENDIF};
298 * Gets the clipping rectangle for the destination surface in a blit.
300 * rect must be a pointer to a valid rectangle which will be filled
301 * with the correct values.
304 procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetClipRect' {$ENDIF} {$ENDIF};
307 * Creates a new surface of the specified format, and then copies and maps
308 * the given surface to it so the blit of the converted surface will be as
309 * fast as possible. If this function fails, it returns NULL.
311 * The flags parameter is passed to SDL_CreateRGBSurface() and has those
312 * semantics. You can also pass SDL_RLEACCEL in the flags parameter and
313 * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
317 function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertSurface' {$ENDIF} {$ENDIF};
318 function SDL_ConvertSurfaceFormat(src: PSDL_Surface; pixel_format: UInt32; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertSurfaceFormat' {$ENDIF} {$ENDIF};
321 * Copy a block of pixels of one format to another format
323 * 0 on success, or -1 if there was an error
326 function SDL_ConvertPixels(width: SInt32; height: SInt32; src_format: UInt32; const src: Pointer; src_pitch: SInt32; dst_format: UInt32; dst: Pointer; dst_pitch: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertPixels' {$ENDIF} {$ENDIF};
329 * Performs a fast fill of the given rectangle with color.
331 * If rect is NULL, the whole surface will be filled with color.
333 * The color should be a pixel of the format used by the surface, and
334 * can be generated by the SDL_MapRGB() function.
336 * 0 on success, or -1 on error.
339 function SDL_FillRect(dst: PSDL_Surface; const rect: PSDL_Rect; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FillRect' {$ENDIF} {$ENDIF};
340 function SDL_FillRects(dst: PSDL_Surface; const rects: PSDL_Rect; count: SInt32; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FillRects' {$ENDIF} {$ENDIF};
343 * Performs a fast blit from the source surface to the destination surface.
345 * This assumes that the source and destination rectangles are
346 * the same size. If either \c srcrect or \c dstrect are NULL, the entire
347 * surface ( src or dst) is copied. The final blit rectangles are saved
348 * in srcrect and dstrect after all clipping is performed.
350 * If the blit is successful, it returns 0, otherwise it returns -1.
352 * The blit function should not be called on a locked surface.
354 * The blit semantics for surfaces with and without alpha and colorkey
355 * are defined as follows:
359 alpha-blend (using alpha-channel).
360 SDL_SRCCOLORKEY ignored.
361 SDL_SRCALPHA not set:
363 if SDL_SRCCOLORKEY set, only copy the pixels matching the
364 RGB values of the source colour key, ignoring alpha in the
369 alpha-blend (using the source per-surface alpha value);
370 set destination alpha to opaque.
371 SDL_SRCALPHA not set:
372 copy RGB, set destination alpha to source per-surface alpha value.
374 if SDL_SRCCOLORKEY set, only copy the pixels matching the
379 alpha-blend (using the source alpha channel) the RGB values;
380 leave destination alpha untouched. [Note: is this correct?]
381 SDL_SRCCOLORKEY ignored.
382 SDL_SRCALPHA not set:
383 copy all of RGBA to the destination.
384 if SDL_SRCCOLORKEY set, only copy the pixels matching the
385 RGB values of the source colour key, ignoring alpha in the
390 alpha-blend (using the source per-surface alpha value).
391 SDL_SRCALPHA not set:
394 if SDL_SRCCOLORKEY set, only copy the pixels matching the
397 * You should call SDL_BlitSurface() unless you know exactly how SDL
398 * blitting works internally and how to use the other blit functions.
402 * This is the public blit function, SDL_BlitSurface(), and it performs
403 * rectangle validation and clipping before passing it to SDL_LowerBlit()
406 function SDL_UpperBlit(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpperBlit' {$ENDIF} {$ENDIF};
408 //SDL_BlitSurface = SDL_UpperBlit;
411 * This is a semi-private blit function and it performs low-level surface
415 function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LowerBlit' {$ENDIF} {$ENDIF};
418 * Perform a fast, low quality, stretch blit between two surfaces of the
421 * This function uses a static buffer, and is not thread-safe.
424 function SDL_SoftStretch(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; const dstrect: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SoftStretch' {$ENDIF} {$ENDIF};
426 //SDL_BlitScaled = SDL_UpperBlitScaled;
429 * This is the public scaled blit function, SDL_BlitScaled(), and it performs
430 * rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
433 function SDL_UpperBlitScaled(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpperBlitScaled' {$ENDIF} {$ENDIF};
436 * This is a semi-private blit function and it performs low-level surface
437 * scaled blitting only.
440 function SDL_LowerBlitScaled(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LowerBlitScaled' {$ENDIF} {$ENDIF};