actual version
[sdl-headers.git] / sdlsurface.inc
1 //from "sdl_surface.h"
2
3 const
4   {**
5    *  Surface flags
6    *
7    *  These are the currently supported flags for the ::SDL_surface.
8    *
9    *  Used internally (read-only).
10    *}
11
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 *}
16
17   {*Surface flags*}
18
19   {**
20    *  Evaluates to true if the surface needs to be locked before access.
21    *}
22
23   //SDL_MUSTLOCK(S)     (((S)->flags & SDL_RLEACCEL) != 0)
24
25 type
26   {**
27    *  A collection of pixels used in software blitting.
28    *
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.
31    *}
32
33   PSDL_BlitMap = ^TSDL_BlitMap;
34   TSDL_BlitMap = record
35     map: Pointer;
36   end;
37
38   PSDL_Surface = ^TSDL_Surface;
39   TSDL_Surface = record
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 *}
45
46     {** Application data associated with the surface *}
47     userdata: Pointer;          {**< Read-write *}
48
49     {** information needed for surfaces requiring locks *}
50     locked: SInt32;             {**< Read-only *}
51     lock_data: Pointer;         {**< Read-only *}
52
53     {** clipping information *}
54     clip_rect: PSDL_Rect;       {**< Read-only *}
55
56     {** info for fast blit mapping to other surfaces *}
57     map: Pointer;               {**< Private *} //SDL_BlitMap
58
59     {** Reference count -- used when freeing surface *}
60     refcount: SInt32;           {**< Read-mostly *}
61   end;
62
63   {**
64    *  The type of function used for surface blitting functions.
65    *}
66
67    TSDL_Blit = function(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32;
68
69   {**
70    *  Allocate and free an RGB surface.
71    *
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
74    *  flags '[RGB]mask'.
75    *
76    *  If the function runs out of memory, it will return NULL.
77    *
78    *  flags The flags are obsolete and should be set to 0.
79    *}
80
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};
84
85   {**
86    *  Set the palette used by a surface.
87    *
88    *  0, or -1 if the surface format doesn't use a palette.
89    *
90    *  A single palette can be shared with many surfaces.
91    *}
92
93 function SDL_SetSurfacePalette(surface: PSDL_Surface; palette: PSDL_Palette): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfacePalette' {$ENDIF} {$ENDIF};
94
95   {**
96    *  Sets up a surface for directly accessing the pixels.
97    *
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.
102    *
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.
106    *
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.
109    *
110    *  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
111    *
112    *  SDL_UnlockSurface()
113    *}
114
115 function SDL_LockSurface(surface: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockSurface' {$ENDIF} {$ENDIF};
116
117   {** SDL_LockSurface() *}
118
119 procedure SDL_UnlockSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockSurface' {$ENDIF} {$ENDIF};
120
121   {**
122    *  Load a surface from a seekable SDL data stream (memory or file).
123    *
124    *  If freesrc is non-zero, the stream will be closed after being read.
125    *
126    *  The new surface should be freed with SDL_FreeSurface().
127    *
128    *  the new surface, or NULL if there was an error.
129    *}
130
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};
132
133   {**
134    *  Load a surface from a file.
135    *
136    *  Convenience macro.
137    *}
138
139 function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
140
141   {**
142    *  Save a surface to a seekable SDL data stream (memory or file).
143    *
144    *  If freedst is non-zero, the stream will be closed after being written.
145    *
146    *  0 if successful or -1 if there was an error.
147    *}
148
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};
150
151     {**
152      *  Save a surface to a file.
153      *
154      *  Convenience macro.
155      *}
156   {
157   #define SDL_SaveBMP(surface, file) \
158       SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
159   }
160
161   {**
162    *  Sets the RLE acceleration hint for a surface.
163    *
164    *  0 on success, or -1 if the surface is not valid
165    *  
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.
168    *}
169
170 function SDL_SetSurfaceRLE(surface: PSDL_Surface; flag: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceRLE' {$ENDIF} {$ENDIF};
171
172   {**
173    *  Sets the color key (transparent pixel) in a blittable surface.
174    *
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
178    *
179    *  0 on success, or -1 if the surface is not valid
180    *
181    *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
182    *}
183
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};
185
186   {**
187    *  Gets the color key (transparent pixel) in a blittable surface.
188    *
189    *  surface The surface to update
190    *  key A pointer filled in with the transparent pixel in the native
191    *      surface format
192    *
193    *  0 on success, or -1 if the surface is not valid or colorkey is not
194    *  enabled.
195    *}
196
197 function SDL_GetColorKey(surface: PSDL_Surface; key: PUInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetColorKey' {$ENDIF} {$ENDIF};
198
199   {**
200    *  Set an additional color value used in blit operations.
201    *
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.
206    *
207    *  0 on success, or -1 if the surface is not valid.
208    *
209    *  SDL_GetSurfaceColorMod()
210    *}
211
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};
213
214  {**
215    *  Get the additional color value used in blit operations.
216    *
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.
221    *
222    *  0 on success, or -1 if the surface is not valid.
223    *
224    *  SDL_SetSurfaceColorMod()
225    *}
226
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};
228
229   {**
230    *  Set an additional alpha value used in blit operations.
231    *
232    *  surface The surface to update.
233    *  alpha The alpha value multiplied into blit operations.
234    *
235    *  0 on success, or -1 if the surface is not valid.
236    *
237    *  SDL_GetSurfaceAlphaMod()
238    *}
239
240 function SDL_SetSurfaceAlphaMod(surface: PSDL_Surface; alpha: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
241
242   {**
243    *  Get the additional alpha value used in blit operations.
244    *
245    *  surface The surface to query.
246    *  alpha A pointer filled in with the current alpha value.
247    *
248    *  0 on success, or -1 if the surface is not valid.
249    *
250    *  SDL_SetSurfaceAlphaMod()
251    *}
252
253 function SDL_GetSurfaceAlphaMod(surface: PSDL_Surface; alpha: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
254
255   {**
256    *  Set the blend mode used for blit operations.
257    *
258    *  surface The surface to update.
259    *  blendMode ::SDL_BlendMode to use for blit blending.
260    *
261    *  0 on success, or -1 if the parameters are not valid.
262    *
263    *  SDL_GetSurfaceBlendMode()
264    *}
265
266 function SDL_SetSurfaceBlendMode(surface: PSDL_Surface; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceBlendMode' {$ENDIF} {$ENDIF};
267
268   {**
269    *  Get the blend mode used for blit operations.
270    *
271    *  surface   The surface to query.
272    *  blendMode A pointer filled in with the current blend mode.
273    *
274    *  0 on success, or -1 if the surface is not valid.
275    *
276    *  SDL_SetSurfaceBlendMode()
277    *}
278
279 function SDL_GetSurfaceBlendMode(surface: PSDL_Surface; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceBlendMode' {$ENDIF} {$ENDIF};
280
281   {**
282    *  Sets the clipping rectangle for the destination surface in a blit.
283    *
284    *  If the clip rectangle is NULL, clipping will be disabled.
285    *
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.
290    *
291    *  Note that blits are automatically clipped to the edges of the source
292    *  and destination surfaces.
293    *}
294
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};
296
297   {**
298    *  Gets the clipping rectangle for the destination surface in a blit.
299    *
300    *  rect must be a pointer to a valid rectangle which will be filled
301    *  with the correct values.
302    *}
303
304 procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetClipRect' {$ENDIF} {$ENDIF};
305
306   {**
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.
310    *
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
314    *  surface.
315    *}
316
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};
319
320   {**
321    *  Copy a block of pixels of one format to another format
322    *
323    *  0 on success, or -1 if there was an error
324    *}
325
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};
327
328   {**
329    *  Performs a fast fill of the given rectangle with color.
330    *
331    *  If rect is NULL, the whole surface will be filled with color.
332    *
333    *  The color should be a pixel of the format used by the surface, and 
334    *  can be generated by the SDL_MapRGB() function.
335    *  
336    *  0 on success, or -1 on error.
337    *}
338
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};
341
342   {**
343    *  Performs a fast blit from the source surface to the destination surface.
344    *
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.
349    *
350    *  If the blit is successful, it returns 0, otherwise it returns -1.
351    *
352    *  The blit function should not be called on a locked surface.
353    *
354    *  The blit semantics for surfaces with and without alpha and colorkey
355    *  are defined as follows:
356    *
357       RGBA->RGB:
358         SDL_SRCALPHA set:
359           alpha-blend (using alpha-channel).
360           SDL_SRCCOLORKEY ignored.
361         SDL_SRCALPHA not set:
362           copy RGB.
363           if SDL_SRCCOLORKEY set, only copy the pixels matching the
364           RGB values of the source colour key, ignoring alpha in the
365           comparison.
366
367       RGB->RGBA:
368         SDL_SRCALPHA set:
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.
373         both:
374           if SDL_SRCCOLORKEY set, only copy the pixels matching the
375           source colour key.
376
377       RGBA->RGBA:
378         SDL_SRCALPHA set:
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
386          comparison.
387
388       RGB->RGB:
389         SDL_SRCALPHA set:
390           alpha-blend (using the source per-surface alpha value).
391         SDL_SRCALPHA not set:
392           copy RGB.
393         both:
394           if SDL_SRCCOLORKEY set, only copy the pixels matching the
395           source colour key.r
396    *
397    *  You should call SDL_BlitSurface() unless you know exactly how SDL
398    *  blitting works internally and how to use the other blit functions.
399    *}
400
401   {**
402    *  This is the public blit function, SDL_BlitSurface(), and it performs
403    *  rectangle validation and clipping before passing it to SDL_LowerBlit()
404    *}
405
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};
407
408   //SDL_BlitSurface = SDL_UpperBlit;
409
410   {**
411    *  This is a semi-private blit function and it performs low-level surface
412    *  blitting only.
413    *}
414
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};
416
417   {**
418    *  Perform a fast, low quality, stretch blit between two surfaces of the
419    *  same pixel format.
420    *
421    *  This function uses a static buffer, and is not thread-safe.
422    *}
423
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};
425
426   //SDL_BlitScaled = SDL_UpperBlitScaled;
427
428   {**
429    *  This is the public scaled blit function, SDL_BlitScaled(), and it performs
430    *  rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
431    *}
432
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};
434
435   {**
436    *  This is a semi-private blit function and it performs low-level surface
437    *  scaled blitting only.
438    *}
439
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};