LZScene

Форк
0
/
SDL2.pas 
6453 строки · 233.7 Кб
1
{*******************************************************************************
2

3
  SDL2.pas        v1.0  29/07/2013 first version for DelphiXE
4
                  v1.1  27/08/2013 add MACOS compability
5

6
  Simple DirectMedia Layer
7
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
8

9
  Pascal-Header-Conversion SDL from the JEDI-Team written by Domenique Louis and others.
10
  Pascal-Header-Conversion SDL2 from the Copyright (C) 2012/13 Tim Blume aka End.
11

12
  convert SDL/SDL2 to SDL2 for DelphiXE by Kotai 2013  www.remakesonline.com
13

14
  The initial developer of this Pascal code was :
15
  Dominqiue Louis <Dominique@SavageSoftware.com.au>
16

17

18
*******************************************************************************}
19
unit SDL2;
20

21
{$I sdl2.inc}
22

23
interface
24

25
uses
26
    System.Classes,
27
    System.SysUtils
28
   {$IFDEF MSWINDOWS}
29
     ,Winapi.Windows;
30
    {$ELSE}
31
    {$IFDEF LINUX}
32
      ,X
33
      ,XLib;
34
    {$ELSE}
35
          ;
36
    {$ENDIF}
37
   {$ENDIF}
38

39
const
40
  {$IFDEF MSWINDOWS}
41
    SDL_LibName = 'SDL2.dll';
42
  {$ENDIF}
43

44
  {$IFDEF UNIX}
45
    {$IFDEF DARWIN}
46
      SDL_LibName = 'libSDL2.dylib';
47
    {$ELSE}
48
        SDL_LibName = 'libSDL2.so';
49
      {$ENDIF}
50
    {$ENDIF}
51
  {$ENDIF}
52

53
  {$IFDEF MACOS}
54
    SDL_LibName = 'SDL2';
55
      {$linklib libSDL2}
56
  {$ENDIF}
57

58
////////////////////////////////////////////////////////////////////////////////////////////////////////
59
//////////////////////  SDLtype_s.h / SDL_stdinc.h  ////////////////////////////////////////////////////
60
////////////////////////////////////////////////////////////////////////////////////////////////////////
61

62
type
63

64
  TSDL_Bool = (SDL_FALSE,SDL_TRUE);
65

66
  DWord = LongWord;
67

68
  PUInt8Array = ^TUInt8Array;
69
  PUInt8 = ^UInt8;
70
  PPUInt8 = ^PUInt8;
71
  UInt8 = Byte;
72
  {$EXTERNALSYM UInt8}
73
  TUInt8Array = array [0..MAXINT shr 1] of UInt8;
74

75
  PUInt16 = ^UInt16;
76
  UInt16 = word;
77
  {$EXTERNALSYM UInt16}
78

79
  PSInt8 = ^SInt8;
80
  SInt8 = Shortint;
81
  {$EXTERNALSYM SInt8}
82

83
  PSInt16 = ^SInt16;
84
  SInt16 = smallint;
85
  {$EXTERNALSYM SInt16}
86

87
  PUInt32 = ^UInt32;
88
  UInt32 = Cardinal;
89
  {$EXTERNALSYM UInt32}
90

91
  SInt32 = LongInt;
92
  {$EXTERNALSYM SInt32}
93

94
  PFloat = ^Float;
95
  PInt = ^LongInt;
96

97
  PShortInt = ^ShortInt;
98

99
  {$IFNDEF Has_Int64}
100
  PUInt64 = ^UInt64;
101
  UInt64 = record
102
    hi: UInt32;
103
    lo: UInt32;
104
  end;
105
  {$EXTERNALSYM UInt64}
106

107
  PInt64 = ^Int64;
108
  Int64 = record
109
    hi: UInt32;
110
    lo: UInt32;
111
  end;
112
  {$EXTERNALSYM Int64}
113

114
  PSInt64 = ^SInt64;
115
  SInt64 = Int64;
116
  {$EXTERNALSYM SInt64}
117
  {$ELSE}
118
  PSInt64 = ^SInt64;
119
  SInt64 = Int64;
120
  {$ENDIF}
121

122
  {$IFDEF WIN64}
123
    size_t = UInt64;
124
  {$ELSE}
125
    size_t = UInt32;
126
  {$ENDIF}
127
  {$EXTERNALSYM SIZE_T}
128

129
  Float = Single;
130
  {$EXTERNALSYM Float}
131

132

133

134
////////////////////////////////////////////////////////////////////////////////////////////////////////
135
//////////////////////        SDL_version.h         ////////////////////////////////////////////////////
136
////////////////////////////////////////////////////////////////////////////////////////////////////////
137

138
  {**
139
   *  Information the version of SDL in use.
140
   *
141
   *  Represents the library's version as three levels: major revision
142
   *  (increments with massive changes, additions, and enhancements),
143
   *  minor revision (increments with backwards-compatible changes to the
144
   *  major revision), and patchlevel (increments with fixes to the minor
145
   *  revision).
146
   *
147
   *  SDL_VERSION
148
   *  SDL_GetVersion
149
   *}
150
type
151
  PSDL_Version = ^TSDL_Version;
152
  TSDL_Version = record
153
    major,         {**< major version *}
154
    minor,         {**< minor version *}
155
    patch: UInt8;  {**< update version *}
156
  end;
157

158
{* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
159
*}
160
const
161
  SDL_MAJOR_VERSION = 2;
162
  SDL_MINOR_VERSION = 0;
163
  SDL_PATCHLEVEL    = 0;
164

165
{**
166
 *  Macro to determine SDL version program was compiled against.
167
 *
168
 *  This macro fills in a SDL_version structure with the version of the
169
 *  library you compiled against. This is determined by what header the
170
 *  compiler uses. Note that if you dynamically linked the library, you might
171
 *  have a slightly newer or older version at runtime. That version can be
172
 *  determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
173
 *  is not a macro.
174
 *
175
 *   x A pointer to a SDL_version struct to initialize.
176
 *
177
 *  SDL_version
178
 *  SDL_GetVersion
179
 *}
180
procedure SDL_VERSION(x: PSDL_Version);
181

182
{**
183
 *  This macro turns the version numbers into a numeric value:
184
 *
185
 *  (1,2,3) -> (1203)
186
 *
187
 *
188
 *  This assumes that there will never be more than 100 patchlevels.
189
 *}
190
function SDL_VERSIONNUM(X,Y,Z: UInt32): Cardinal;
191

192
  {**
193
   *  This is the version number macro for the current SDL version.
194
   *}
195
function SDL_COMPILEDVERSION: Cardinal;
196

197
  {**
198
   *  This macro will evaluate to true if compiled with SDL at least X.Y.Z.
199
   *}
200
function SDL_VERSION_ATLEAST(X,Y,Z: Cardinal): Boolean;
201

202
  {**
203
   *  Get the version of SDL that is linked against your program.
204
   *
205
   *  If you are linking to SDL dynamically, then it is possible that the
206
   *  current version will be different than the version you compiled against.
207
   *  This function returns the current version, while SDL_VERSION() is a
208
   *  macro that tells you what version you compiled with.
209
   *
210
   *
211
   *  compiled: TSDL_Version;
212
   *  linked: TSDL_Version;
213
   *
214
   *  SDL_VERSION(@compiled);
215
   *  SDL_GetVersion(@linked);
216
   *  WriteLn('We compiled against SDL version: ' +
217
   *           IntToStr(compiled.major) +
218
   *           IntToStr(compiled.minor) +
219
   *           IntToStr(compiled.patch));
220
   *  WriteLn('But we linked against SDL version:' +
221
   *           IntToStr(compiled.major) +
222
   *           IntToStr(compiled.minor) +
223
   *           IntToStr(compiled.patch));
224
   *
225
   *
226
   *  This function may be called safely at any time, even before SDL_Init().
227
   *
228
   *  SDL_VERSION
229
   *}
230
procedure SDL_GetVersion(ver: PSDL_Version) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetVersion' {$ENDIF};
231

232
  {**
233
   *  Get the code revision of SDL that is linked against your program.
234
   *
235
   *  Returns an arbitrary string (a hash value) uniquely identifying the
236
   *  exact revision of the SDL library in use, and is only useful in comparing
237
   *  against other revisions. It is NOT an incrementing number.
238
   *}
239
function SDL_GetRevision: PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRevision' {$ENDIF};
240

241
  {**
242
   *  Get the revision number of SDL that is linked against your program.
243
   *
244
   *  Returns a number uniquely identifying the exact revision of the SDL
245
   *  library in use. It is an incrementing number based on commits to
246
   *  hg.libsdl.org.
247
   *}
248
function SDL_GetRevisionNumber: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRevisionNumber' {$ENDIF};
249
 
250

251

252
////////////////////////////////////////////////////////////////////////////////////////////////////////  
253
//////////////////////         SDL_error.h          ////////////////////////////////////////////////////
254
////////////////////////////////////////////////////////////////////////////////////////////////////////  
255

256
const
257
  ERR_MAX_STRLEN = 128;
258
  ERR_MAX_ARGS   = 5;
259

260
  {* Public functions *}
261

262
  {* SDL_SetError() unconditionally returns -1. *}
263
function SDL_SetError(const fmt: PAnsiChar): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetError' {$ENDIF};
264
function SDL_GetError: PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetError' {$ENDIF};
265
procedure SDL_ClearError cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ClearError' {$ENDIF};
266
  {*Internal error functions*}
267
  {**
268
   *  Internal error functions
269
   *
270
   *  Private error reporting function - used internally.
271
   *}
272

273
    {
274
#define SDL_OutOfMemory()   SDL_Error(SDL_ENOMEM)
275
#define SDL_Unsupported()   SDL_Error(SDL_UNSUPPORTED)
276
#define SDL_InvalidParamError(param)    SDL_SetError("Parameter '%s' is invalid", (param))
277
   }
278
type
279
  TSDL_ErrorCode = (SDL_ENOMEM,
280
                    SDL_EFREAD,
281
                    SDL_EFWRITE,
282
                    SDL_EFSEEK,
283
                    SDL_UNSUPPORTED,
284
                    SDL_LASTERROR);
285

286
  TSDL_Error = record
287
    {* This is a numeric value corresponding to the current error *}
288
    error: SInt32;
289

290
    {* This is a key used to index into a language hashtable containing
291
       internationalized versions of the SDL error messages.  If the key
292
       is not in the hashtable, or no hashtable is available, the key is
293
       used directly as an error message format string.
294
     *}
295
    key: String[ERR_MAX_STRLEN];
296

297
    {* These are the arguments for the error functions *}
298
    argc: SInt32;
299
    case SInt32 of
300
         {* What is a character anyway?  (UNICODE issues) *}
301
      0: (value_c: Byte;);
302
      1: (value_ptr: Pointer;);
303
      2: (value_i: SInt32;);
304
      3: (value_f: Double;);
305
      4: (buf: String[ERR_MAX_STRLEN];);
306
  end;
307

308
  {* SDL_Error() unconditionally returns -1. *}
309
function SDL_Error(code: TSDL_ErrorCode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_Error' {$ENDIF};
310
		 
311

312

313
////////////////////////////////////////////////////////////////////////////////////////////////////////  
314
//////////////////////         SDL_power.h          ////////////////////////////////////////////////////
315
////////////////////////////////////////////////////////////////////////////////////////////////////////  
316

317
  {**
318
   *  The basic state for the system's power supply.
319
   *}
320
type
321
  TSDL_PowerState = (SDL_POWERSTATE_UNKNOWN,      {**< cannot determine power status *}
322
                     SDL_POWERSTATE_ON_BATTERY,   {**< Not plugged in, running on the battery *}
323
                     SDL_POWERSTATE_NO_BATTERY,   {**< Plugged in, no battery available *}
324
                     SDL_POWERSTATE_CHARGING,     {**< Plugged in, charging battery *}
325
                     SDL_POWERSTATE_CHARGED);     {**< Plugged in, battery charged *}
326

327
  {**
328
   *  Get the current power supply details.
329
   *
330
   *   secs Seconds of battery life left. You can pass a NULL here if
331
   *        you don't care. Will return -1 if we can't determine a
332
   *        value, or we're not running on a battery.
333
   *
334
   *   pct Percentage of battery life left, between 0 and 100. You can
335
   *       pass a NULL here if you don't care. Will return -1 if we
336
   *       can't determine a value, or we're not running on a battery.
337
   *
338
   *  The state of the battery (if any).
339
   *}
340
function SDL_GetPowerInfo(secs: PInt; pct: PInt): TSDL_PowerState cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetPowerInfo' {$ENDIF};
341

342
	  
343

344
////////////////////////////////////////////////////////////////////////////////////////////////////////
345
//////////////////////        SDL_thread .h         ////////////////////////////////////////////////////
346
////////////////////////////////////////////////////////////////////////////////////////////////////////
347

348
{* The SDL thread structure, defined in SDL_thread.c *}
349
//todo!
350
type
351
  {* The SDL thread priority
352
   *
353
   * Note: On many systems you require special privileges to set high priority.
354
   *}
355

356
  TSDL_ThreadPriority = (SDL_THREAD_PRIORITY_LOW,
357
                         SDL_THREAD_PRIORITY_NORMAL,
358
                         SDL_THREAD_PRIORITY_HIGH);
359

360
  {* The function passed to SDL_CreateThread()
361
     It is passed a void* user context parameter and returns an int.
362
   *}
363
  PSDL_ThreadFunction = ^TSDL_ThreadFunction;
364
  TSDL_ThreadFunction = function(data: Pointer): Integer; cdecl;
365

366
  {* The SDL thread ID *}
367
  TSDL_ThreadID = LongWord;
368
   {
369
  PSDL_Thread = Pointer;
370
     }
371

372
  PSDL_Thread = ^TSDL_Thread;
373
  TSDL_Thread = record
374
    threadid: TSDL_ThreadID;
375
    handle: THandle;
376
    status: SInt32;
377
    errbuf: TSDL_Error;
378
    name: PAnsiChar;
379
    data: Pointer;
380
  end;
381

382
  TSDL_TLSID = Cardinal;
383

384
{$IFDEF MSWINDOWS}
385
  {**
386
   *  SDL_thread.h
387
   *
388
   *  We compile SDL into a DLL. This means, that it's the DLL which
389
   *  creates a new thread for the calling process with the SDL_CreateThread()
390
   *  API. There is a problem with this, that only the RTL of the SDL.DLL will
391
   *  be initialized for those threads, and not the RTL of the calling
392
   *  application!
393
   *
394
   *  To solve this, we make a little hack here.
395
   *
396
   *  We'll always use the caller's _beginthread() and _endthread() APIs to
397
   *  start a new thread. This way, if it's the SDL.DLL which uses this API,
398
   *  then the RTL of SDL.DLL will be used to create the new thread, and if it's
399
   *  the application, then the RTL of the application will be used.
400
   *
401
   *  So, in short:
402
   *  Always use the _beginthread() and _endthread() of the calling runtime
403
   *  library!
404
   *}
405
{$DEFINE SDL_PASSED_BEGINTHREAD_ENDTHREAD}
406

407
type
408
  {$IFNDEF DELPHI16UP}
409
    TThreadID = Cardinal;
410
  {$ENDIF}
411

412
  TpfnSDL_CurrentBeginThread = function(SecurityAttributes: Pointer; StackSize: LongWord; ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord; var ThreadId: TThreadID): Integer;
413

414
  TpfnSDL_CurrentEndThread = procedure(ExitCode: Integer);
415

416
  {**
417
   *  Create a thread.
418
   *}
419
function SDL_CreateThread(fn: TSDL_ThreadFunction; name: PAnsiChar; data: Pointer; pfnBeginThread: TpfnSDL_CurrentBeginThread; pfnEndThread: TpfnSDL_CurrentEndThread): PSDL_Thread; cdecl; overload; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateThread' {$ENDIF};
420

421
  {**
422
   *  Create a thread.
423
   *}
424
function SDL_CreateThread(fn: TSDL_ThreadFunction; name: PAnsiChar; data: Pointer): PSDL_Thread; overload;
425

426
{$ELSE}
427

428
  {**
429
   *  Create a thread.
430
   *
431
   *   Thread naming is a little complicated: Most systems have very small
432
   *    limits for the string length (BeOS has 32 bytes, Linux currently has 16,
433
   *    Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll
434
   *    have to see what happens with your system's debugger. The name should be
435
   *    UTF-8 (but using the naming limits of C identifiers is a better bet).
436
   *   There are no requirements for thread naming conventions, so long as the
437
   *    string is null-terminated UTF-8, but these guidelines are helpful in
438
   *    choosing a name:
439
   *
440
   *    http://stackoverflow.com/questions/149932/naming-conventions-for-threads
441
   *
442
   *   If a system imposes requirements, SDL will try to munge the string for
443
   *    it (truncate, etc), but the original string contents will be available
444
   *    from SDL_GetThreadName().
445
   *}
446
function SDL_CreateThread(fn: TSDL_ThreadFunction; name: PAnsiChar; data: Pointer): PSDL_Thread; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateThread' {$ENDIF};
447

448
{$ENDIF}
449

450
  {**
451
   * Get the thread name, as it was specified in SDL_CreateThread().
452
   *  This function returns a pointer to a UTF-8 string that names the
453
   *  specified thread, or NULL if it doesn't have a name. This is internal
454
   *  memory, not to be free()'d by the caller, and remains valid until the
455
   *  specified thread is cleaned up by SDL_WaitThread().
456
   *}
457
function SDL_GetThreadName(thread: PSDL_Thread): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetThreadName' {$ENDIF};
458

459
  {**
460
   *  Get the thread identifier for the current thread.
461
   *}
462
function SDL_ThreadID: TSDL_ThreadID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ThreadID' {$ENDIF};
463

464
  {**
465
   *  Get the thread identifier for the specified thread.
466
   *
467
   *  Equivalent to SDL_ThreadID() if the specified thread is NULL.
468
   *}
469
function SDL_GetThreadID(thread: PSDL_Thread): TSDL_ThreadID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetThreadID' {$ENDIF};
470

471
  {**
472
   *  Set the priority for the current thread
473
   *}
474
function SDL_SetThreadPriority(priority: TSDL_ThreadPriority): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetThreadPriority' {$ENDIF};
475

476
  {**
477
   *  Wait for a thread to finish.
478
   *
479
   *  The return code for the thread function is placed in the area
480
   *  pointed to by status, if status is not NULL.
481
   *}
482
procedure SDL_WaitThread(thread: PSDL_Thread; status: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WaitThread' {$ENDIF};
483

484
  {**
485
   *  Create an identifier that is globally visible to all threads but refers to data that is thread-specific.
486
   *
487
   *   The newly created thread local storage identifier, or 0 on error
488
   *
489
   *  static SDL_SpinLock tls_lock;
490
   *  static SDL_TLSID thread_local_storage;
491
   *
492
   *  void SetMyThreadData(void *value)
493
   *  {
494
   *      if (!thread_local_storage) {
495
   *          SDL_AtomicLock(&tls_lock);
496
   *          if (!thread_local_storage) {
497
   *              thread_local_storage = SDL_TLSCreate();
498
   *          }   {
499
   *          SDL_AtomicUnLock(&tls_lock);
500
   *      } {
501
   *      SDL_TLSSet(thread_local_storage, value);
502
   *  } {
503
   *
504
   *  void *GetMyThreadData(void)
505
   *  {
506
   *      return SDL_TLSGet(thread_local_storage);
507
   *  }{
508
   *
509
   *   SDL_TLSGet()
510
   *   SDL_TLSSet()
511
   *}
512
function SDL_TLSCreate: TSDL_TLSID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_TLSCreate' {$ENDIF};
513

514
  {**
515
   *  Get the value associated with a thread local storage ID for the current thread.
516
   *
517
   *   id The thread local storage ID
518
   *
519
   *   The value associated with the ID for the current thread, or NULL if no value has been set.
520
   *
521
   *   SDL_TLSCreate()
522
   *   SDL_TLSSet()
523
   *}
524
function SDL_TLSGet(id: TSDL_TLSID): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_TLSGet' {$ENDIF};
525

526
  {**
527
   *  Set the value associated with a thread local storage ID for the current thread.
528
   *
529
   *   id The thread local storage ID
530
   *   value The value to associate with the ID for the current thread
531
   *   destructor_ A function called when the thread exits, to free the value.
532
   *
533
   *   0 on success, -1 on error
534
   *
535
   *   SDL_TLSCreate()
536
   *   SDL_TLSGet()
537
   *}
538
function SDL_TLSSet(id: TSDL_TLSID; value: Pointer; destructor_: Pointer): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_TLSSet' {$ENDIF};
539

540
  
541

542
////////////////////////////////////////////////////////////////////////////////////////////////////////  
543
//////////////////////          SDL_mutex.h         ////////////////////////////////////////////////////
544
////////////////////////////////////////////////////////////////////////////////////////////////////////  
545

546
  {**
547
   *  Synchronization functions which can time out return this value
548
   *  if they time out.
549
   *}
550
const
551
  SDL_MUTEX_TIMEDOUT = 1;
552

553
  {**
554
   *  This is the timeout value which corresponds to never time out.
555
   *}
556
  //SDL_MUTEX_MAXWAIT   (~(Uint32)0)
557

558

559
  {**
560
   *  Mutex functions
561
   *}
562
type
563
  {* The SDL mutex structure, defined in SDL_mutex.c *}
564
  PSDL_Mutex = Pointer; //todo!
565

566
  {**
567
   *  Create a mutex, initialized unlocked.
568
   *}
569
function SDL_CreateMutex: PSDL_Mutex cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateMutex' {$ENDIF};
570

571
  {**
572
   *  Lock the mutex.
573
   *
574
   *   0, or -1 on error.
575
   *}
576
//#define SDL_mutexP(m)   SDL_LockMutex(m)
577
function SDL_LockMutex(mutex: PSDL_Mutex): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LockMutex' {$ENDIF};
578

579
  {**
580
   *  Try to lock the mutex
581
   *
582
   *   0, SDL_MUTEX_TIMEDOUT, or -1 on error
583
   *}
584
function SDL_TryLockMutex(mutex: PSDL_Mutex): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_TryLockMutex' {$ENDIF};
585

586
  {**
587
   *  Unlock the mutex.
588
   *
589
   *   0, or -1 on error.
590
   *
591
   *   It is an error to unlock a mutex that has not been locked by
592
   *   the current thread, and doing so results in undefined behavior.
593
   *}
594
//#define SDL_mutexV(m)   SDL_UnlockMutex(m)
595
function SDL_UnlockMutex(mutex: PSDL_Mutex): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UnlockMutex' {$ENDIF};
596

597
  {**
598
   *  Destroy a mutex.
599
   *}
600
procedure SDL_DestroyMutex(mutex: PSDL_Mutex) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroyMutex' {$ENDIF};
601

602
  {*Mutex functions*}
603

604
  {**
605
   *   Semaphore functions
606
   *}
607
type
608
  {* The SDL semaphore structure, defined in SDL_sem.c *}
609
  PSDL_Sem = Pointer; //todo!
610

611
  {**
612
   *  Create a semaphore, initialized with value, returns NULL on failure.
613
   *}
614
function SDL_CreateSemaphore(initial_value: UInt32): PSDL_sem cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateSemaphore' {$ENDIF};
615

616
  {**
617
   *  Destroy a semaphore.
618
   *}
619
procedure SDL_DestroySemaphore(sem: PSDL_Sem) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroySemaphore' {$ENDIF};
620

621
  {**
622
   *  This function suspends the calling thread until the semaphore pointed
623
   *  to by sem has a positive count. It then atomically decreases the
624
   *  semaphore count.
625
   *}
626
function SDL_SemWait(sem: PSDL_Sem): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SemWait' {$ENDIF};
627

628
  {**
629
   *  Non-blocking variant of SDL_SemWait().
630
   *
631
   *   0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait would
632
   *   block, and -1 on error.
633
   *}
634
function SDL_SemTryWait(sem: PSDL_Sem): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SemTryWait' {$ENDIF};
635

636
  {**
637
   *  Variant of SDL_SemWait() with a timeout in milliseconds.
638
   *
639
   *   0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not
640
   *   succeed in the allotted time, and -1 on error.
641
   *
642
   *   On some platforms this function is implemented by looping with a
643
   *   delay of 1 ms, and so should be avoided if possible.
644
   *}
645
function SDL_SemWaitTimeout(sem: PSDL_Sem; ms: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SemWaitTimeout' {$ENDIF};
646

647
  {**
648
   *  Atomically increases the semaphore's count (not blocking).
649
   *
650
   *   0, or -1 on error.
651
   *}
652
function SDL_SemPost(sem: PSDL_Sem): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SemPost' {$ENDIF};
653

654
  {**
655
   *  Returns the current count of the semaphore.
656
   *}
657
function SDL_SemValue(sem: PSDL_Sem): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SemValue' {$ENDIF};
658

659
  {*Semaphore functions*}
660

661
  {**
662
   *  Condition variable functions
663
   * }
664
type
665
  {* The SDL condition variable structure, defined in SDL_cond.c *}
666
  PSDL_Cond = Pointer; //todo!!
667

668
  {**
669
   *  Create a condition variable.
670
   *
671
   *  Typical use of condition variables:
672
   *
673
   *  Thread A:
674
   *    SDL_LockMutex(lock);
675
   *    while ( not condition )
676
   *    begin
677
   *      SDL_CondWait(cond, lock);
678
   *    end;
679
   *    SDL_UnlockMutex(lock);
680
   *
681
   *  Thread B:
682
   *    SDL_LockMutex(lock);
683
   *    ...
684
   *    condition := true;
685
   *    ...
686
   *    SDL_CondSignal(cond);
687
   *    SDL_UnlockMutex(lock);
688
   *
689
   *  There is some discussion whether to signal the condition variable
690
   *  with the mutex locked or not.  There is some potential performance
691
   *  benefit to unlocking first on some platforms, but there are some
692
   *  potential race conditions depending on how your code is structured.
693
   *
694
   *  In general it's safer to signal the condition variable while the
695
   *  mutex is locked.
696
   *}
697
function SDL_CreateCond: PSDL_Cond cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateCond' {$ENDIF};
698

699
  {**
700
   *  Destroy a condition variable.
701
   *}
702
procedure SDL_DestroyCond(cond: PSDL_Cond) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroyCond' {$ENDIF};
703

704
  {**
705
   *  Restart one of the threads that are waiting on the condition variable.
706
   *
707
   *   0 or -1 on error.
708
   *}
709
function SDL_CondSignal(cond: PSDL_Cond): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CondSignal' {$ENDIF};
710

711
  {**
712
   *  Restart all threads that are waiting on the condition variable.
713
   *
714
   *   0 or -1 on error.
715
   *}
716
function SDL_CondBroadcast(cond: PSDL_Cond): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CondBroadcast' {$ENDIF};
717

718
  {**
719
   *  Wait on the condition variable, unlocking the provided mutex.
720
   *
721
   *   The mutex must be locked before entering this function!
722
   *
723
   *  The mutex is re-locked once the condition variable is signaled.
724
   *
725
   *   0 when it is signaled, or -1 on error.
726
   *}
727
function SDL_CondWait(cond: PSDL_Cond; mutex: PSDL_Mutex): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CondWait' {$ENDIF};
728

729
  {**
730
   *  Waits for at most ms milliseconds, and returns 0 if the condition
731
   *  variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
732
   *  signaled in the allotted time, and -1 on error.
733
   *
734
   *   On some platforms this function is implemented by looping with a
735
   *   delay of 1 ms, and so should be avoided if possible.
736
   *}
737
function SDL_CondWaitTimeout(cond: PSDL_Cond; mutex: PSDL_Mutex; ms: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CondWaitTimeout' {$ENDIF};
738

739
		 
740

741
////////////////////////////////////////////////////////////////////////////////////////////////////////  
742
//////////////////////         SDL_timer.h          ////////////////////////////////////////////////////
743
////////////////////////////////////////////////////////////////////////////////////////////////////////  
744

745
  {**
746
   *  Get the number of milliseconds since the SDL library initialization.
747
   *
748
   *  This value wraps if the program runs for more than ~49 days.
749
   *}
750
function SDL_GetTicks: UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTicks' {$ENDIF};
751

752
  {**
753
   *  Get the current value of the high resolution counter
754
   *}
755
function SDL_GetPerformanceCounter: UInt64 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetPerformanceCounter' {$ENDIF};
756

757
  {**
758
   *  Get the count per second of the high resolution counter
759
   *}
760
function SDL_GetPerformanceFrequency: UInt64 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetPerformanceFrequency' {$ENDIF};
761

762
  {**
763
   *  Wait a specified number of milliseconds before returning.
764
   *}
765
procedure SDL_Delay(ms: UInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_Delay' {$ENDIF};
766

767
  {**
768
   *  Function prototype for the timer callback function.
769
   *
770
   *  The callback function is passed the current timer interval and returns
771
   *  the next timer interval.  If the returned value is the same as the one
772
   *  passed in, the periodic alarm continues, otherwise a new alarm is
773
   *  scheduled.  If the callback returns 0, the periodic alarm is cancelled.
774
   *}
775

776
type
777
  TSDL_TimerCallback = function(interval: UInt32; param: Pointer): UInt32;
778

779
  {**
780
   * Definition of the timer ID type.
781
   *}
782
  TSDL_TimerID = SInt32;
783

784
  {**
785
   *  Add a new timer to the pool of timers already running.
786
   *
787
   *  A timer ID, or NULL when an error occurs.
788
   *}
789
function SDL_AddTimer(interval: UInt32; callback: TSDL_TimerCallback; param: Pointer): TSDL_TimerID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_AddTimer' {$ENDIF};
790

791
  {**
792
   *  Remove a timer knowing its ID.
793
   *
794
   *  A boolean value indicating success or failure.
795
   *
796
   *  It is not safe to remove a timer multiple times.
797
   *}
798
function SDL_RemoveTimer(id: TSDL_TimerID): Boolean cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RemoveTimer' {$ENDIF};
799

800
   
801

802
////////////////////////////////////////////////////////////////////////////////////////////////////////
803
//////////////////////          SDL_pixels.h         ///////////////////////////////////////////////////
804
////////////////////////////////////////////////////////////////////////////////////////////////////////
805

806
  {**
807
   *  Transparency definitions
808
   *
809
   *  These define alpha as the opacity of a surface.
810
   *}
811

812
  const
813
    SDL_ALPHA_OPAQUE = 255;
814
    SDL_ALPHA_TRANSPARENT = 0;
815

816
    {** Pixel type. *}
817
    SDL_PIXELTYPE_UNKNOWN = 0;
818
    SDL_PIXELTYPE_INDEX1 = 1;
819
    SDL_PIXELTYPE_INDEX4 = 2;
820
    SDL_PIXELTYPE_INDEX8 = 3;
821
    SDL_PIXELTYPE_PACKED8 = 4;
822
    SDL_PIXELTYPE_PACKED16 = 5;
823
    SDL_PIXELTYPE_PACKED32 = 6;
824
    SDL_PIXELTYPE_ARRAYU8 = 7;
825
    SDL_PIXELTYPE_ARRAYU16 = 8;
826
    SDL_PIXELTYPE_ARRAYU32 = 9;
827
    SDL_PIXELTYPE_ARRAYF16 = 10;
828
    SDL_PIXELTYPE_ARRAYF32 = 11;
829

830
    {** Bitmap pixel order, high bit -> low bit. *}
831
    SDL_BITMAPORDER_NONE = 0;
832
    SDL_BITMAPORDER_4321 = 1;
833
    SDL_BITMAPORDER_1234 = 2;
834

835
    {** Packed component order, high bit -> low bit. *}
836

837
    SDL_PACKEDORDER_NONE = 0;
838
    SDL_PACKEDORDER_XRGB = 1;
839
    SDL_PACKEDORDER_RGBX = 2;
840
    SDL_PACKEDORDER_ARGB = 3;
841
    SDL_PACKEDORDER_RGBA = 4;
842
    SDL_PACKEDORDER_XBGR = 5;
843
    SDL_PACKEDORDER_BGRX = 6;
844
    SDL_PACKEDORDER_ABGR = 7;
845
    SDL_PACKEDORDER_BGRA = 8;
846

847
    {** Array component order, low byte -> high byte. *}
848
    SDL_ARRAYORDER_NONE = 0;
849
    SDL_ARRAYORDER_RGB = 1;
850
    SDL_ARRAYORDER_RGBA = 2;
851
    SDL_ARRAYORDER_ARGB = 3;
852
    SDL_ARRAYORDER_BGR = 4;
853
    SDL_ARRAYORDER_BGRA = 5;
854
    SDL_ARRAYORDER_ABGR = 6;
855

856
    {** Packed component layout. *}
857
    SDL_PACKEDLAYOUT_NONE = 0;
858
    SDL_PACKEDLAYOUT_332 = 1;
859
    SDL_PACKEDLAYOUT_4444 = 2;
860
    SDL_PACKEDLAYOUT_1555 = 3;
861
    SDL_PACKEDLAYOUT_5551 = 4;
862
    SDL_PACKEDLAYOUT_565 = 5;
863
    SDL_PACKEDLAYOUT_8888 = 6;
864
    SDL_PACKEDLAYOUT_2101010 = 7;
865
    SDL_PACKEDLAYOUT_1010102 = 8;
866

867
    {
868
        //todo!!
869
function SDL_DEFINE_PIXELFORMAT(type, order, layour, bit, bytes: UInt32): Result;
870

871
function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
872

873
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
874
    ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
875
     ((bits) << 8) | ((bytes) << 0))
876
       }
877

878
function SDL_PIXELFLAG(X: Cardinal): Boolean;
879
function SDL_PIXELTYPE(X: Cardinal): Boolean;
880
function SDL_PIXELORDER(X: Cardinal): Boolean;
881
function SDL_PIXELLAYOUT(X: Cardinal): Boolean;
882
function SDL_BITSPERPIXEL(X: Cardinal): Boolean;
883
     {
884
#define SDL_BYTESPERPIXEL(X) \
885
    (SDL_ISPIXELFORMAT_FOURCC(X) ? \
886
        ((((X) == SDL_PIXELFORMAT_YUY2) || \
887
          ((X) == SDL_PIXELFORMAT_UYVY) || \
888
          ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
889

890
#define SDL_ISPIXELFORMAT_INDEXED(format)   \
891
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
892
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
893
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
894
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
895

896
#define SDL_ISPIXELFORMAT_ALPHA(format)   \
897
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
898
     ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
899
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
900
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
901
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
902

903
  function SDL_IsPixelFormat_FOURCC(format: Variant);
904

905
  {* Note: If you modify this list, update SDL_GetPixelFormatName() *}
906

907
const
908
    SDL_PIXELFORMAT_UNKNOWN = 0;
909
    SDL_PIXELFORMAT_INDEX1LSB = (1 shl 28)                    or
910
                                (SDL_PIXELTYPE_INDEX1 shl 24) or
911
                                (SDL_BITMAPORDER_4321 shl 20) or
912
                                (0 shl 16)                    or
913
                                (1 shl 8)                     or
914
                                (0 shl 0);
915

916
    SDL_PIXELFORMAT_INDEX1MSB = (1 shl 28)                    or
917
                                (SDL_PIXELTYPE_INDEX1 shl 24) or
918
                                (SDL_BITMAPORDER_1234 shl 20) or
919
                                (0 shl 16)                    or
920
                                (1 shl 8)                     or
921
                                (0 shl 0);
922

923
    SDL_PIXELFORMAT_INDEX4LSB = (1 shl 28)                    or
924
                                (SDL_PIXELTYPE_INDEX4 shl 24) or
925
                                (SDL_BITMAPORDER_4321 shl 20) or
926
                                (0 shl 16)                    or
927
                                (4 shl 8)                     or
928
                                (0 shl 0);
929

930
    SDL_PIXELFORMAT_INDEX4MSB = (1 shl 28)                    or
931
                                (SDL_PIXELTYPE_INDEX4 shl 24) or
932
                                (SDL_BITMAPORDER_1234 shl 20) or
933
                                (0 shl 16)                    or
934
                                (4 shl 8)                     or
935
                                (0 shl 0);
936

937
    SDL_PIXELFORMAT_INDEX8 =    (1 shl 28)                      or
938
                                (SDL_PIXELTYPE_PACKED8 shl 24)  or
939
                                (0 shl 20)                      or
940
                                (0 shl 16)                      or
941
                                (8 shl 8)                       or
942
                                (1 shl 0);
943
                                
944
    SDL_PIXELFORMAT_RGB332 =    (1 shl 28)                      or
945
                                (SDL_PIXELTYPE_PACKED8 shl 24)  or
946
                                (SDL_PACKEDORDER_XRGB shl 20)   or
947
                                (SDL_PACKEDLAYOUT_332 shl 16)   or
948
                                (8 shl 8)                       or
949
                                (1 shl 0);
950

951
    SDL_PIXELFORMAT_RGB444 =    (1 shl 28)                      or
952
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
953
                                (SDL_PACKEDORDER_XRGB shl 20)   or
954
                                (SDL_PACKEDLAYOUT_4444 shl 16)  or
955
                                (12 shl 8)                      or
956
                                (2 shl 0);
957

958
    SDL_PIXELFORMAT_RGB555 =    (1 shl 28)                      or
959
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
960
                                (SDL_PACKEDORDER_XRGB shl 20)   or
961
                                (SDL_PACKEDLAYOUT_1555 shl 16)  or
962
                                (15 shl 8)                      or
963
                                (2 shl 0);
964

965
    SDL_PIXELFORMAT_BGR555 =    (1 shl 28)                      or
966
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
967
                                (SDL_PACKEDORDER_XBGR shl 20)   or
968
                                (SDL_PACKEDLAYOUT_1555 shl 16)  or
969
                                (15 shl 8)                      or
970
                                (2 shl 0);
971

972
    SDL_PIXELFORMAT_ARGB4444 =  (1 shl 28)                      or
973
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
974
                                (SDL_PACKEDORDER_ARGB shl 20)   or
975
                                (SDL_PACKEDLAYOUT_4444 shl 16)  or
976
                                (16 shl 8)                      or
977
                                (2 shl 0);
978

979
    SDL_PIXELFORMAT_RGBA4444 =  (1 shl 28)                      or
980
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
981
                                (SDL_PACKEDORDER_RGBA shl 20)   or
982
                                (SDL_PACKEDLAYOUT_4444 shl 16)  or
983
                                (16 shl 8)                      or
984
                                (2 shl 0);
985

986
    SDL_PIXELFORMAT_ABGR4444 =  (1 shl 28)                      or
987
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
988
                                (SDL_PACKEDORDER_ABGR shl 20)   or
989
                                (SDL_PACKEDLAYOUT_4444 shl 16)  or
990
                                (16 shl 8)                      or
991
                                (2 shl 0);
992

993
    SDL_PIXELFORMAT_BGRA4444 =  (1 shl 28)                      or
994
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
995
                                (SDL_PACKEDORDER_BGRA shl 20)   or
996
                                (SDL_PACKEDLAYOUT_4444 shl 16)  or
997
                                (16 shl 8)                      or
998
                                (2 shl 0);
999

1000
    SDL_PIXELFORMAT_ARGB1555 =  (1 shl 28)                      or
1001
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1002
                                (SDL_PACKEDORDER_ARGB shl 20)   or
1003
                                (SDL_PACKEDLAYOUT_1555 shl 16)  or
1004
                                (16 shl 8)                      or
1005
                                (2 shl 0);
1006

1007
    SDL_PIXELFORMAT_RGBA5551 =  (1 shl 28)                      or
1008
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1009
                                (SDL_PACKEDORDER_RGBA shl 20)   or
1010
                                (SDL_PACKEDLAYOUT_5551 shl 16)  or
1011
                                (16 shl 8)                      or
1012
                                (2 shl 0);
1013

1014
    SDL_PIXELFORMAT_ABGR1555 =  (1 shl 28)                      or
1015
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1016
                                (SDL_PACKEDORDER_ABGR shl 20)   or
1017
                                (SDL_PACKEDLAYOUT_1555 shl 16)  or
1018
                                (16 shl 8)                      or
1019
                                (2 shl 0);
1020

1021
    SDL_PIXELFORMAT_BGRA5551 =  (1 shl 28)                      or
1022
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1023
                                (SDL_PACKEDORDER_BGRA shl 20)   or
1024
                                (SDL_PACKEDLAYOUT_5551 shl 16)  or
1025
                                (16 shl 8)                      or
1026
                                (2 shl 0);
1027

1028
    SDL_PIXELFORMAT_RGB565 =    (1 shl 28)                      or
1029
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1030
                                (SDL_PACKEDORDER_XRGB shl 20)   or
1031
                                (SDL_PACKEDLAYOUT_565 shl 16)   or
1032
                                (16 shl 8)                      or
1033
                                (2 shl 0);
1034

1035
    SDL_PIXELFORMAT_BGR565 =    (1 shl 28)                      or
1036
                                (SDL_PIXELTYPE_PACKED16 shl 24) or
1037
                                (SDL_PACKEDORDER_XBGR shl 20)   or
1038
                                (SDL_PACKEDLAYOUT_1555 shl 16)  or
1039
                                (16 shl 8)                      or
1040
                                (2 shl 0);
1041

1042
    SDL_PIXELFORMAT_RGB24 =     (1 shl 28)                      or
1043
                                (SDL_PIXELTYPE_ARRAYU8 shl 24)  or
1044
                                (SDL_ARRAYORDER_RGB shl 20)     or
1045
                                (0 shl 16)                      or
1046
                                (24 shl 8)                      or
1047
                                (3 shl 0);
1048

1049
    SDL_PIXELFORMAT_BGR24 =     (1 shl 28)                      or
1050
                                (SDL_PIXELTYPE_ARRAYU8 shl 24)  or
1051
                                (SDL_ARRAYORDER_BGR shl 20)     or
1052
                                (0 shl 16)                      or
1053
                                (24 shl 8)                      or
1054
                                (3 shl 0);
1055

1056
    SDL_PIXELFORMAT_RGB888 =    (1 shl 28)                      or
1057
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1058
                                (SDL_PACKEDORDER_XRGB shl 20)   or
1059
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1060
                                (24 shl 8)                      or
1061
                                (4 shl 0);
1062

1063
    SDL_PIXELFORMAT_RGBX8888 =  (1 shl 28)                      or
1064
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1065
                                (SDL_PACKEDORDER_RGBX shl 20)   or
1066
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1067
                                (24 shl 8)                      or
1068
                                (4 shl 0);
1069

1070
    SDL_PIXELFORMAT_BGR888 =    (1 shl 28)                      or
1071
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1072
                                (SDL_PACKEDORDER_XBGR shl 20)   or
1073
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1074
                                (24 shl 8)                      or
1075
                                (4 shl 0);
1076

1077
    SDL_PIXELFORMAT_BGRX8888 =  (1 shl 28)                      or
1078
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1079
                                (SDL_PACKEDORDER_BGRX shl 20)   or
1080
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1081
                                (24 shl 8)                      or
1082
                                (4 shl 0);
1083

1084
    SDL_PIXELFORMAT_ARGB8888 =  (1 shl 28)                      or
1085
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1086
                                (SDL_PACKEDORDER_ARGB shl 20)   or
1087
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1088
                                (32 shl 8)                      or
1089
                                (4 shl 0);
1090

1091
    SDL_PIXELFORMAT_RGBA8888 =  (1 shl 28)                      or
1092
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1093
                                (SDL_PACKEDORDER_RGBA shl 20)   or
1094
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1095
                                (32 shl 8)                      or
1096
                                (4 shl 0);
1097

1098
    SDL_PIXELFORMAT_ABGR8888 =  (1 shl 28)                      or
1099
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1100
                                (SDL_PACKEDORDER_ABGR shl 20)   or
1101
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1102
                                (32 shl 8)                      or
1103
                                (4 shl 0);
1104

1105
    SDL_PIXELFORMAT_BGRA8888 =  (1 shl 28)                      or
1106
                                (SDL_PIXELTYPE_PACKED32 shl 24) or
1107
                                (SDL_PACKEDORDER_RGBX shl 20)   or
1108
                                (SDL_PACKEDLAYOUT_8888 shl 16)  or
1109
                                (32 shl 8)                      or
1110
                                (4 shl 0);
1111

1112
    SDL_PIXELFORMAT_ARGB2101010 = (1 shl 28)                       or
1113
                                  (SDL_PIXELTYPE_PACKED32 shl 24)  or
1114
                                  (SDL_PACKEDORDER_ARGB shl 20)    or
1115
                                  (SDL_PACKEDLAYOUT_2101010 shl 16)or
1116
                                  (32 shl 8)                       or
1117
                                  (4 shl 0);
1118

1119
    {**< Planar mode: Y + V + U  (3 planes) *}
1120
    SDL_PIXELFORMAT_YV12 = (Integer('Y')       ) or
1121
                           (Integer('V') shl  8) or
1122
                           (Integer('1') shl 16) or
1123
                           (Integer('2') shl 24);
1124
    {**< Planar mode: Y + U + V  (3 planes) *}
1125
    SDL_PIXELFORMAT_IYUV = (Integer('I')       ) or
1126
                           (Integer('Y') shl  8) or
1127
                           (Integer('U') shl 16) or
1128
                           (Integer('V') shl 24);
1129
    {**< Packed mode: Y0+U0+Y1+V0 (1 plane) *}
1130
    SDL_PIXELFORMAT_YUY2 = (Integer('Y')       ) or
1131
                           (Integer('U') shl  8) or
1132
                           (Integer('Y') shl 16) or
1133
                           (Integer('2') shl 24);
1134
    {**< Packed mode: U0+Y0+V0+Y1 (1 plane) *}
1135
    SDL_PIXELFORMAT_UYVY = (Integer('U')       ) or
1136
                           (Integer('Y') shl  8) or
1137
                           (Integer('V') shl 16) or
1138
                           (Integer('Y') shl 24);
1139
    {**< Packed mode: Y0+V0+Y1+U0 (1 plane) *}
1140
    SDL_PIXELFORMAT_YVYU = (Integer('Y')       ) or
1141
                           (Integer('V') shl  8) or
1142
                           (Integer('Y') shl 16) or
1143
                           (Integer('U') shl 24);
1144

1145
type
1146
  PSDL_Color = ^TSDL_Color;
1147
  TSDL_Color = record
1148
    r: UInt8;
1149
    g: UInt8;
1150
    b: UInt8;
1151
    unused: UInt8;
1152
  end;
1153

1154
  TSDL_Colour = TSDL_Color;
1155
  PSDL_Colour = ^TSDL_Colour;
1156

1157
  PSDL_Palette = ^TSDL_Palette;
1158
  TSDL_Palette = record
1159
    ncolors: SInt32;
1160
    colors: PSDL_Color;
1161
    version: UInt32;
1162
    refcount: SInt32;
1163
  end;
1164

1165
  {**
1166
   *  Everything in the pixel format structure is read-only.
1167
   *}
1168

1169
  PSDL_PixelFormat = ^TSDL_PixelFormat;
1170
  TSDL_PixelFormat = record
1171
    format: UInt32;
1172
    palette: PSDL_Palette;
1173
    BitsPerPixel: UInt8;
1174
    BytesPerPixel: UInt8;
1175
    padding: array[0..1] of UInt8;
1176
    Rmask: UInt32;
1177
    Gmask: UInt32;
1178
    Bmask: UInt32;
1179
    Amask: UInt32;
1180
    Rloss: UInt8;
1181
    Gloss: UInt8;
1182
    Bloss: UInt8;
1183
    Aloss: UInt8;
1184
    Rshift: UInt8;
1185
    Gshift: UInt8;
1186
    Bshift: UInt8;
1187
    Ashift: UInt8;
1188
    refcount: SInt32;
1189
    next: PSDL_PixelFormat;
1190
  end;
1191

1192
  {**
1193
   *  Get the human readable name of a pixel format
1194
   *}
1195

1196
function SDL_GetPixelFormatName(format: UInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetPixelFormatName' {$ENDIF};
1197

1198
  {**
1199
   *  Convert one of the enumerated pixel formats to a bpp and RGBA masks.
1200
   *
1201
   *  SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
1202
   *
1203
   *  SDL_MasksToPixelFormatEnum()
1204
   *}
1205

1206
function SDL_PixelFormatEnumToMasks(format: UInt32; bpp: PInt; Rmask: PUInt32; Gmask: PUInt32; Bmask: PUInt32; Amask: PUInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_PixelFormatEnumToMasks' {$ENDIF};
1207

1208
  {**
1209
   *  Convert a bpp and RGBA masks to an enumerated pixel format.
1210
   *
1211
   *  The pixel format, or SDL_PIXELFORMAT_UNKNOWN if the conversion
1212
   *  wasn't possible.
1213
   *
1214
   *  SDL_PixelFormatEnumToMasks()
1215
   *}
1216

1217
function SDL_MasksToPixelFormatEnum(bpp: SInt32; Rmask: UInt32; Gmask: UInt32; Bmask: UInt32; Amask: UInt32): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_MasksToPixelFormatEnum' {$ENDIF};
1218

1219
  {**
1220
   *  Create an SDL_PixelFormat structure from a pixel format enum.
1221
   *}
1222

1223
function SDL_AllocFormat(pixel_format: UInt32): PSDL_PixelFormat cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_AllocFormat' {$ENDIF};
1224

1225
  {**
1226
   *  Free an SDL_PixelFormat structure.
1227
   *}
1228

1229
procedure SDL_FreeFormat(format: PSDL_PixelFormat) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FreeFormat' {$ENDIF};
1230

1231
  {**
1232
   *  Create a palette structure with the specified number of color
1233
   *  entries.
1234
   *
1235
   *  A new palette, or nil if there wasn't enough memory.
1236
   *
1237
   *  The palette entries are initialized to white.
1238
   *  
1239
   *  SDL_FreePalette()
1240
   *}
1241

1242
function SDL_AllocPalette(ncolors: SInt32): PSDL_Palette cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_AllocPalette' {$ENDIF};
1243

1244
  {**
1245
   *  Set the palette for a pixel format structure.
1246
   *}
1247

1248
function SDL_SetPixelFormatPalette(format: PSDL_PixelFormat; palette: PSDL_Palette): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetPixelFormatPalette' {$ENDIF};
1249

1250
  {**
1251
   *  Set a range of colors in a palette.
1252
   *
1253
   *  palette    The palette to modify.
1254
   *  colors     An array of colors to copy into the palette.
1255
   *  firstcolor The index of the first palette entry to modify.
1256
   *  ncolors    The number of entries to modify.
1257
   *
1258
   *  0 on success, or -1 if not all of the colors could be set.
1259
   *}
1260

1261
function SDL_SetPaletteColors(palette: PSDL_Palette; const colors: PSDL_Color; firstcolor: SInt32; ncolors: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetPaletteColors' {$ENDIF};
1262

1263
  {**
1264
   *  Free a palette created with SDL_AllocPalette().
1265
   *
1266
   *  SDL_AllocPalette()
1267
   *}
1268

1269
procedure SDL_FreePalette(palette: PSDL_Palette) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FreePalette' {$ENDIF};
1270

1271
  {**
1272
   *  Maps an RGB triple to an opaque pixel value for a given pixel format.
1273
   *
1274
   *  SDL_MapRGBA
1275
   *}
1276

1277
function SDL_MapRGB(const format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_MapRGB' {$ENDIF};
1278

1279
  {**
1280
   *  Maps an RGBA quadruple to a pixel value for a given pixel format.
1281
   *
1282
   *  SDL_MapRGB
1283
   *}
1284

1285
function SDL_MapRGBA(const format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8; a: UInt8): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_MapRGBA' {$ENDIF};
1286

1287
  {**
1288
   *  Get the RGB components from a pixel of the specified format.
1289
   *
1290
   *  SDL_GetRGBA
1291
   *}
1292

1293
procedure SDL_GetRGB(pixel: UInt32; const format: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRGB' {$ENDIF};
1294

1295
  {**
1296
   *  Get the RGBA components from a pixel of the specified format.
1297
   *
1298
   *  SDL_GetRGB
1299
   *}
1300

1301
procedure SDL_GetRGBA(pixel: UInt32; const format: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRGBA' {$ENDIF};
1302

1303
  {**
1304
   *  Calculate a 256 entry gamma ramp for a gamma value.
1305
   *}
1306

1307
procedure SDL_CalculateGammaRamp(gamma: Float; ramp: PUInt16) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CalculateGammaRamp' {$ENDIF};
1308

1309

1310

1311
////////////////////////////////////////////////////////////////////////////////////////////////////////
1312
//////////////////////          SDL_rect.h          ////////////////////////////////////////////////////
1313
////////////////////////////////////////////////////////////////////////////////////////////////////////
1314

1315
type
1316
  {**
1317
   *  The structure that defines a point
1318
   *
1319
   *  SDL_EnclosePoints
1320
   *}
1321

1322
  PSDL_Point = ^TSDL_Point;
1323
  TSDL_Point = record
1324
    x: SInt32;
1325
    y: SInt32;
1326
  end;
1327

1328
  {**
1329
   *  A rectangle, with the origin at the upper left.
1330
   *
1331
   *  SDL_RectEmpty
1332
   *  SDL_RectEquals
1333
   *  SDL_HasIntersection
1334
   *  SDL_IntersectRect
1335
   *  SDL_UnionRect
1336
   *  SDL_EnclosePoints
1337
   *}
1338

1339
  PSDL_Rect = ^TSDL_Rect;
1340
  TSDL_Rect = record
1341
    x,y: SInt32;
1342
    w,h: SInt32;
1343
  end;
1344

1345
  {**
1346
   *  Returns true if the rectangle has no area.
1347
   *}
1348

1349
  //changed from variant(b?????h!) to TSDL_Rect
1350
  //maybe PSDL_Rect?
1351
function SDL_RectEmpty(X: TSDL_Rect): Boolean;
1352

1353
    {**
1354
     *  Returns true if the two rectangles are equal.
1355
     *}
1356

1357
function SDL_RectEquals(A: TSDL_Rect; B: TSDL_Rect): Boolean;
1358

1359
  {**
1360
   *  Determine whether two rectangles intersect.
1361
   *
1362
   *  SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
1363
   *}
1364

1365
function SDL_HasIntersection(const A: PSDL_Rect; const B: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_HasIntersection' {$ENDIF};
1366

1367
  {**
1368
   *  Calculate the intersection of two rectangles.
1369
   *
1370
   *  SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
1371
   *}
1372

1373
function SDL_IntersectRect(const A: PSDL_Rect; const B: PSDL_Rect; result: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IntersectRect' {$ENDIF};
1374

1375
  {**
1376
   *  Calculate the union of two rectangles.
1377
   *}
1378

1379
procedure SDL_UnionRect(const A: PSDL_Rect; const B: PSDL_Rect; result: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UnionRect' {$ENDIF};
1380

1381
  {**
1382
   *  Calculate a minimal rectangle enclosing a set of points
1383
   *
1384
   *  SDL_TRUE if any points were within the clipping rect
1385
   *}
1386

1387
function SDL_EnclosePoints(const points: PSDL_Point; count: SInt32; const clip: PSDL_Rect; result: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_EnclosePoints' {$ENDIF};
1388

1389
  {**
1390
   *  Calculate the intersection of a rectangle and line segment.
1391
   *
1392
   *  SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
1393
   *}
1394

1395
function SDL_IntersectRectAndLine(const rect: PSDL_Rect; X1: PInt; Y1: PInt; X2: PInt; Y2: PInt): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IntersectRectAndLine' {$ENDIF};
1396

1397

1398

1399
////////////////////////////////////////////////////////////////////////////////////////////////////////
1400
//////////////////////         SDL_rwops.h          ////////////////////////////////////////////////////
1401
////////////////////////////////////////////////////////////////////////////////////////////////////////
1402

1403
const
1404
  {* RWops Types *}
1405
  SDL_RWOPS_UNKNOWN	  = 0;	{* Unknown stream type *}
1406
  SDL_RWOPS_WINFILE	  = 1;	{* Win32 file *}
1407
  SDL_RWOPS_STDFILE	  = 2;	{* Stdio file *}
1408
  SDL_RWOPS_JNIFILE	  = 3;	{* Android asset *}
1409
  SDL_RWOPS_MEMORY    =	4;	{* Memory stream *}
1410
  SDL_RWOPS_MEMORY_RO =	5;	{* Read-Only memory stream *}
1411

1412
type
1413
  PSDL_RWops = ^TSDL_RWops;
1414

1415
  {**
1416
   * This is the read/write operation structure -- very basic.
1417
   *}
1418

1419
  {**
1420
   *  Return the size of the file in this rwops, or -1 if unknown
1421
   *}
1422
  TSize = function(context: PSDL_RWops): SInt64; cdecl;
1423
  
1424
  {**
1425
   *  Seek to offset relative to whence, one of stdio's whence values:
1426
   *  RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
1427
   *
1428
   *  the final offset in the data stream, or -1 on error.
1429
   *}
1430
  TSeek = function(context: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64; cdecl;
1431
                   
1432
  {**
1433
   *  Read up to maxnum objects each of size size from the data
1434
   *  stream to the area pointed at by ptr.
1435
   *
1436
   *  the number of objects read, or 0 at error or end of file.
1437
   *}
1438

1439
   TRead = function(context: PSDL_RWops; ptr: Pointer; size: size_t; maxnum: size_t): size_t; cdecl;
1440
   
1441
  {**
1442
   *  Write exactly num objects each of size size from the area
1443
   *  pointed at by ptr to data stream.
1444
   *  
1445
   *  the number of objects written, or 0 at error or end of file.
1446
   *}
1447
	
1448
   TWrite = function(context: PSDL_RWops; const ptr: Pointer; size: size_t; num: size_t): size_t; cdecl;
1449
	
1450
  {**
1451
   *  Close and free an allocated SDL_RWops structure.
1452
   *  
1453
   *  0 if successful or -1 on write error when flushing data.
1454
   *}
1455

1456
  TClose =  function(context: PSDL_RWops): SInt32; cdecl;
1457

1458
  TStdio = record
1459
    autoclose: TSDL_Bool;
1460
	fp: file;
1461
  end;
1462
  
1463
  TMem = record
1464
    base: PUInt8;
1465
	here: PUInt8;
1466
	stop: PUInt8;
1467
  end;
1468
  
1469
  TUnknown = record
1470
    data1: Pointer;
1471
  end;
1472
  
1473
  TAndroidIO = record
1474
    fileNameRef: Pointer;
1475
    inputStreamRef: Pointer;
1476
    readableByteChannelRef: Pointer;
1477
    readMethod: Pointer;
1478
    assetFileDescriptorRef: Pointer;
1479
    position: LongInt;
1480
    size: LongInt;
1481
    offset: LongInt;
1482
    fd: SInt32;
1483
  end;
1484
  
1485
  TWindowsIOBuffer = record
1486
    data: Pointer;
1487
	size: size_t;
1488
	left: size_t;
1489
  end;
1490
  
1491
  TWindowsIO = record
1492
    append: TSDL_Bool;
1493
    h: Pointer;
1494
    buffer: TWindowsIOBuffer;
1495
  end;
1496
	
1497
  TSDL_RWops = packed record
1498
    size: TSize;
1499
    seek: TSeek;
1500
    read: TRead;
1501
    write: TWrite;
1502
    close: TClose;
1503

1504
    _type: UInt32;
1505

1506
	case Integer of
1507
	  0: (stdio: TStdio);
1508
	  1: (mem: TMem);
1509
	  2: (unknown: TUnknown);
1510
	  {$IFDEF ANDROID}
1511
	  3: (androidio: TAndroidIO);
1512
	  {$ENDIF}
1513
	  {$IFDEF MSWINDOWS}
1514
	  3: (windowsio: TWindowsIO);
1515
	  {$ENDIF}
1516
  end;
1517

1518
  {**
1519
   *  RWFrom functions
1520
   *
1521
   *  Functions to create SDL_RWops structures from various data streams.
1522
   *}
1523

1524
function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RWFromFile' {$ENDIF};
1525

1526
  {function SDL_RWFromFP(fp: file; autoclose: TSDL_Bool): PSDL_RWops; cdecl; external SDL_LibName;} //don't know if this works
1527

1528
function SDL_RWFromFP(fp: Pointer; autoclose: TSDL_Bool): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RWFromFP' {$ENDIF};
1529

1530
function SDL_RWFromMem(mem: Pointer; size: SInt32): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RWFromMem' {$ENDIF};
1531
function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RWFromConstMem' {$ENDIF};
1532

1533
{*RWFrom functions*}
1534

1535

1536
function SDL_AllocRW: PSDL_RWops; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_AllocRW' {$ENDIF};
1537
procedure SDL_FreeRW(area: PSDL_RWops); cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FreeRW' {$ENDIF};
1538

1539
const
1540
  RW_SEEK_SET = 0;       {**< Seek from the beginning of data *}
1541
  RW_SEEK_CUR = 1;       {**< Seek relative to current read point *}
1542
  RW_SEEK_END = 2;       {**< Seek relative to the end of data *}
1543

1544
  {**
1545
   *  Read/write macros
1546
   *
1547
   *  Macros to easily read and write from an SDL_RWops structure.
1548
   *}
1549

1550
  function SDL_RWsize(ctx: PSDL_RWops): SInt64;
1551
  function SDL_RWseek(ctx: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64;
1552
  function SDL_RWtell(ctx: PSDL_RWops): SInt64;
1553
  function SDL_RWread(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
1554
  function SDL_RWwrite(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
1555
  function SDL_RWclose(ctx: PSDL_RWops): SInt32;
1556
  { Read/write macros }
1557

1558

1559
  {**
1560
   *  Read endian functions
1561
   *
1562
   *  Read an item of the specified endianness and return in native format.
1563
   *}
1564

1565
function SDL_ReadU8(src: PSDL_RWops): UInt8 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadU8' {$ENDIF};
1566
function SDL_ReadLE16(src: PSDL_RWops): UInt16 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadLE16' {$ENDIF};
1567
function SDL_ReadBE16(src: PSDL_RWops): UInt16 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadBE16' {$ENDIF};
1568
function SDL_ReadLE32(src: PSDL_RWops): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadLE32' {$ENDIF};
1569
function SDL_ReadBE32(src: PSDL_RWops): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadBE32' {$ENDIF};
1570
function SDL_ReadLE64(src: PSDL_RWops): UInt64 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadLE64' {$ENDIF};
1571
function SDL_ReadBE64(src: PSDL_RWops): UInt64 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ReadBE64' {$ENDIF};
1572

1573
  {*Read endian functions*}
1574

1575
  {**
1576
   *  Write endian functions
1577
   *
1578
   *  Write an item of native format to the specified endianness.
1579
   *}
1580

1581
function SDL_WriteU8(dst: PSDL_RWops; value: UInt8): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteU8' {$ENDIF};
1582
function SDL_WriteLE16(dst: PSDL_RWops; value: UInt16): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteLE16' {$ENDIF};
1583
function SDL_WriteBE16(dst: PSDL_RWops; value: UInt16): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteBE16' {$ENDIF};
1584
function SDL_WriteLE32(dst: PSDL_RWops; value: UInt32): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteLE32' {$ENDIF};
1585
function SDL_WriteBE32(dst: PSDL_RWops; value: UInt32): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteBE32' {$ENDIF};
1586
function SDL_WriteLE64(dst: PSDL_RWops; value: UInt64): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteLE64' {$ENDIF};
1587
function SDL_WriteBE64(dst: PSDL_RWops; value: UInt64): size_t cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WriteBE64' {$ENDIF};
1588
  { Write endian functions }
1589

1590

1591

1592
////////////////////////////////////////////////////////////////////////////////////////////////////////  
1593
//////////////////////        SDL_blendmode.h       ////////////////////////////////////////////////////
1594
////////////////////////////////////////////////////////////////////////////////////////////////////////  
1595

1596
{**
1597
 *  The blend mode used in SDL_RenderCopy() and drawing operations.
1598
 *}
1599
 
1600
type
1601
  PSDL_BlendMode = ^TSDL_BlendMode;
1602
  TSDL_BlendMode = DWord;
1603
 
1604
const
1605
  SDL_BLENDMODE_NONE  = $00000000;    {**< No blending *}
1606
  SDL_BLENDMODE_BLEND = $00000001;    {**< dst = (src * A) + (dst * (1-A)) *}
1607
  SDL_BLENDMODE_ADD   = $00000002;    {**< dst = (src * A) + dst *}
1608
  SDL_BLENDMODE_MOD   = $00000004;    {**< dst = src * dst *}
1609

1610

1611

1612
////////////////////////////////////////////////////////////////////////////////////////////////////////  
1613
//////////////////////        SDL_surface.h         ////////////////////////////////////////////////////
1614
////////////////////////////////////////////////////////////////////////////////////////////////////////  
1615

1616
const
1617
  {**
1618
   *  Surface flags
1619
   *
1620
   *  These are the currently supported flags for the ::SDL_surface.
1621
   *
1622
   *  Used internally (read-only).
1623
   *}
1624

1625
  SDL_SWSURFACE = 0;          {**< Just here for compatibility *}
1626
  SDL_PREALLOC  = $00000001;  {**< Surface uses preallocated memory *}
1627
  SDL_RLEACCEL  = $00000002;  {**< Surface is RLE encoded *}
1628
  SDL_DONTFREE  = $00000004;  {**< Surface is referenced internally *}
1629

1630
  {*Surface flags*}
1631

1632
  {**
1633
   *  Evaluates to true if the surface needs to be locked before access.
1634
   *}
1635

1636
  //SDL_MUSTLOCK(S)	(((S)->flags & SDL_RLEACCEL) != 0)
1637

1638
type
1639
  {**
1640
   *  A collection of pixels used in software blitting.
1641
   *
1642
   *  This structure should be treated as read-only, except for \c pixels,
1643
   *  which, if not NULL, contains the raw pixel data for the surface.
1644
   *}
1645

1646
  PSDL_BlitMap = ^TSDL_BlitMap;
1647
  TSDL_BlitMap = record
1648
    map: Pointer;
1649
  end;
1650

1651
  PSDL_Surface = ^TSDL_Surface;
1652
  TSDL_Surface = record
1653
    flags: UInt32;              {**< Read-only *}
1654
    format: PSDL_PixelFormat;   {**< Read-only *}
1655
    w, h: SInt32;               {**< Read-only *}
1656
    pitch: SInt32;              {**< Read-only *}
1657
    pixels: Pointer;            {**< Read-write *}
1658

1659
    {** Application data associated with the surface *}
1660
    userdata: Pointer;          {**< Read-write *}
1661

1662
    {** information needed for surfaces requiring locks *}
1663
    locked: SInt32;             {**< Read-only *}
1664
    lock_data: Pointer;         {**< Read-only *}
1665

1666
    {** clipping information *}
1667
    clip_rect: PSDL_Rect;       {**< Read-only *}
1668

1669
    {** info for fast blit mapping to other surfaces *}
1670
    map: Pointer;               {**< Private *} //SDL_BlitMap
1671

1672
    {** Reference count -- used when freeing surface *}
1673
    refcount: SInt32;           {**< Read-mostly *}
1674
  end;
1675

1676
  {**
1677
   *  The type of function used for surface blitting functions.
1678
   *}
1679

1680
   TSDL_Blit = function(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32;
1681

1682
  {**
1683
   *  Allocate and free an RGB surface.
1684
   *
1685
   *  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
1686
   *  If the depth is greater than 8 bits, the pixel format is set using the
1687
   *  flags '[RGB]mask'.
1688
   *
1689
   *  If the function runs out of memory, it will return NULL.
1690
   *
1691
   *  flags The flags are obsolete and should be set to 0.
1692
   *}
1693

1694
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 MACOS} name '_SDL_CreateRGBSurface' {$ENDIF};
1695
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 MACOS} name '_SDL_CreateRGBSurfaceFrom' {$ENDIF};
1696
procedure SDL_FreeSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FreeSurface' {$ENDIF};
1697

1698
  {**
1699
   *  Set the palette used by a surface.
1700
   *
1701
   *  0, or -1 if the surface format doesn't use a palette.
1702
   *
1703
   *  A single palette can be shared with many surfaces.
1704
   *}
1705

1706
function SDL_SetSurfacePalette(surface: PSDL_Surface; palette: PSDL_Palette): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetSurfacePalette' {$ENDIF};
1707

1708
  {**
1709
   *  Sets up a surface for directly accessing the pixels.
1710
   *
1711
   *  Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
1712
   *  to and read from surface.pixels, using the pixel format stored in
1713
   *  surface.format. Once you are done accessing the surface, you should
1714
   *  use SDL_UnlockSurface() to release it.
1715
   *
1716
   *  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
1717
   *  to 0, then you can read and write to the surface at any time, and the
1718
   *  pixel format of the surface will not change.
1719
   *
1720
   *  No operating system or library calls should be made between lock/unlock
1721
   *  pairs, as critical system locks may be held during this time.
1722
   *
1723
   *  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
1724
   *
1725
   *  SDL_UnlockSurface()
1726
   *}
1727

1728
function SDL_LockSurface(surface: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LockSurface' {$ENDIF};
1729

1730
  {** SDL_LockSurface() *}
1731

1732
procedure SDL_UnlockSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UnlockSurface' {$ENDIF};
1733

1734
  {**
1735
   *  Load a surface from a seekable SDL data stream (memory or file).
1736
   *
1737
   *  If freesrc is non-zero, the stream will be closed after being read.
1738
   *
1739
   *  The new surface should be freed with SDL_FreeSurface().
1740
   *
1741
   *  the new surface, or NULL if there was an error.
1742
   *}
1743

1744
function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: SInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF};
1745

1746
  {**
1747
   *  Load a surface from a file.
1748
   *
1749
   *  Convenience macro.
1750
   *}
1751

1752
function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
1753

1754
  {**
1755
   *  Save a surface to a seekable SDL data stream (memory or file).
1756
   *
1757
   *  If freedst is non-zero, the stream will be closed after being written.
1758
   *
1759
   *  0 if successful or -1 if there was an error.
1760
   *}
1761

1762
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF};
1763

1764
    {**
1765
     *  Save a surface to a file.
1766
     *
1767
     *  Convenience macro.
1768
     *}
1769
  {
1770
  #define SDL_SaveBMP(surface, file) \
1771
      SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
1772
  }
1773

1774
function SDL_SaveBMP(surface: PSDL_Surface; _file: PAnsiChar): SInt32;
1775

1776
  {**
1777
   *  Sets the RLE acceleration hint for a surface.
1778
   *
1779
   *  0 on success, or -1 if the surface is not valid
1780
   *  
1781
   *  If RLE is enabled, colorkey and alpha blending blits are much faster,
1782
   *  but the surface must be locked before directly accessing the pixels.
1783
   *}
1784

1785
function SDL_SetSurfaceRLE(surface: PSDL_Surface; flag: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetSurfaceRLE' {$ENDIF};
1786

1787
  {**
1788
   *  Sets the color key (transparent pixel) in a blittable surface.
1789
   *
1790
   *  surface The surface to update
1791
   *  flag Non-zero to enable colorkey and 0 to disable colorkey
1792
   *  key The transparent pixel in the native surface format
1793
   *  
1794
   *  0 on success, or -1 if the surface is not valid
1795
   *
1796
   *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
1797
   *}
1798

1799
function SDL_SetColorKey(surface: PSDL_Surface; flag: SInt32; key: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetColorKey' {$ENDIF};
1800

1801
  {**
1802
   *  Gets the color key (transparent pixel) in a blittable surface.
1803
   *  
1804
   *  surface The surface to update
1805
   *  key A pointer filled in with the transparent pixel in the native
1806
   *      surface format
1807
   *
1808
   *  0 on success, or -1 if the surface is not valid or colorkey is not
1809
   *  enabled.
1810
   *}
1811

1812
function SDL_GetColorKey(surface: PSDL_Surface; key: PUInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetColorKey' {$ENDIF};
1813

1814
  {**
1815
   *  Set an additional color value used in blit operations.
1816
   *
1817
   *  surface The surface to update.
1818
   *  r The red color value multiplied into blit operations.
1819
   *  g The green color value multiplied into blit operations.
1820
   *  b The blue color value multiplied into blit operations.
1821
   *
1822
   *  0 on success, or -1 if the surface is not valid.
1823
   *
1824
   *  SDL_GetSurfaceColorMod()
1825
   *}
1826

1827
function SDL_SetSurfaceColorMod(surface: PSDL_Surface; r: UInt8; g: UInt8; b: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetSurfaceColorMod' {$ENDIF};
1828

1829
  {**
1830
   *  Get the additional color value used in blit operations.
1831
   *
1832
   *  surface The surface to query.
1833
   *  r A pointer filled in with the current red color value.
1834
   *  g A pointer filled in with the current green color value.
1835
   *  b A pointer filled in with the current blue color value.
1836
   *
1837
   *  0 on success, or -1 if the surface is not valid.
1838
   *
1839
   *  SDL_SetSurfaceColorMod()
1840
   *}
1841

1842
function SDL_GetSurfaceColorMod(surface: PSDL_Surface; r: PUInt8; g: PUInt8; b: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetSurfaceColorMod' {$ENDIF};
1843

1844
  {**
1845
   *  Set an additional alpha value used in blit operations.
1846
   *
1847
   *  surface The surface to update.
1848
   *  alpha The alpha value multiplied into blit operations.
1849
   *
1850
   *  0 on success, or -1 if the surface is not valid.
1851
   *
1852
   *  SDL_GetSurfaceAlphaMod()
1853
   *}
1854

1855
function SDL_SetSurfaceAlphaMod(surface: PSDL_Surface; alpha: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetSurfaceAlphaMod' {$ENDIF};
1856

1857
  {**
1858
   *  Get the additional alpha value used in blit operations.
1859
   *
1860
   *  surface The surface to query.
1861
   *  alpha A pointer filled in with the current alpha value.
1862
   *
1863
   *  0 on success, or -1 if the surface is not valid.
1864
   *
1865
   *  SDL_SetSurfaceAlphaMod()
1866
   *}
1867

1868
function SDL_GetSurfaceAlphaMod(surface: PSDL_Surface; alpha: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetSurfaceAlphaMod' {$ENDIF};
1869

1870
  {**
1871
   *  Set the blend mode used for blit operations.
1872
   *
1873
   *  surface The surface to update.
1874
   *  blendMode ::SDL_BlendMode to use for blit blending.
1875
   *
1876
   *  0 on success, or -1 if the parameters are not valid.
1877
   *
1878
   *  SDL_GetSurfaceBlendMode()
1879
   *}
1880

1881
function SDL_SetSurfaceBlendMode(surface: PSDL_Surface; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetSurfaceBlendMode' {$ENDIF};
1882

1883
  {**
1884
   *  Get the blend mode used for blit operations.
1885
   *
1886
   *  surface   The surface to query.
1887
   *  blendMode A pointer filled in with the current blend mode.
1888
   *
1889
   *  0 on success, or -1 if the surface is not valid.
1890
   *
1891
   *  SDL_SetSurfaceBlendMode()
1892
   *}
1893

1894
function SDL_GetSurfaceBlendMode(surface: PSDL_Surface; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetSurfaceBlendMode' {$ENDIF};
1895

1896
  {**
1897
   *  Sets the clipping rectangle for the destination surface in a blit.
1898
   *
1899
   *  If the clip rectangle is NULL, clipping will be disabled.
1900
   *
1901
   *  If the clip rectangle doesn't intersect the surface, the function will
1902
   *  return SDL_FALSE and blits will be completely clipped.  Otherwise the
1903
   *  function returns SDL_TRUE and blits to the surface will be clipped to
1904
   *  the intersection of the surface area and the clipping rectangle.
1905
   *
1906
   *  Note that blits are automatically clipped to the edges of the source
1907
   *  and destination surfaces.
1908
   *}
1909

1910
function SDL_SetClipRect(surface: PSDL_Surface; const rect: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetClipRect' {$ENDIF};
1911

1912
  {**
1913
   *  Gets the clipping rectangle for the destination surface in a blit.
1914
   *
1915
   *  rect must be a pointer to a valid rectangle which will be filled
1916
   *  with the correct values.
1917
   *}
1918

1919
procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetClipRect' {$ENDIF};
1920

1921
  {**
1922
   *  Creates a new surface of the specified format, and then copies and maps
1923
   *  the given surface to it so the blit of the converted surface will be as
1924
   *  fast as possible.  If this function fails, it returns NULL.
1925
   *
1926
   *  The flags parameter is passed to SDL_CreateRGBSurface() and has those
1927
   *  semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
1928
   *  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
1929
   *  surface.
1930
   *}
1931

1932
function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ConvertSurface' {$ENDIF};
1933
function SDL_ConvertSurfaceFormat(src: PSDL_Surface; pixel_format: UInt32; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ConvertSurfaceFormat' {$ENDIF};
1934

1935
  {**
1936
   *  Copy a block of pixels of one format to another format
1937
   *
1938
   *  0 on success, or -1 if there was an error
1939
   *}
1940

1941
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 MACOS} name '_SDL_ConvertPixels' {$ENDIF};
1942

1943
  {**
1944
   *  Performs a fast fill of the given rectangle with color.
1945
   *
1946
   *  If rect is NULL, the whole surface will be filled with color.
1947
   *
1948
   *  The color should be a pixel of the format used by the surface, and 
1949
   *  can be generated by the SDL_MapRGB() function.
1950
   *  
1951
   *  0 on success, or -1 on error.
1952
   *}
1953

1954
function SDL_FillRect(dst: PSDL_Surface; const rect: PSDL_Rect; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FillRect' {$ENDIF};
1955
function SDL_FillRects(dst: PSDL_Surface; const rects: PSDL_Rect; count: SInt32; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FillRects' {$ENDIF};
1956

1957
  {**
1958
   *  Performs a fast blit from the source surface to the destination surface.
1959
   *
1960
   *  This assumes that the source and destination rectangles are
1961
   *  the same size.  If either \c srcrect or \c dstrect are NULL, the entire
1962
   *  surface ( src or  dst) is copied.  The final blit rectangles are saved
1963
   *  in srcrect and dstrect after all clipping is performed.
1964
   *
1965
   *  If the blit is successful, it returns 0, otherwise it returns -1.
1966
   *
1967
   *  The blit function should not be called on a locked surface.
1968
   *
1969
   *  The blit semantics for surfaces with and without alpha and colorkey
1970
   *  are defined as follows:
1971
   *
1972
      RGBA->RGB:
1973
        SDL_SRCALPHA set:
1974
          alpha-blend (using alpha-channel).
1975
          SDL_SRCCOLORKEY ignored.
1976
        SDL_SRCALPHA not set:
1977
          copy RGB.
1978
          if SDL_SRCCOLORKEY set, only copy the pixels matching the
1979
          RGB values of the source colour key, ignoring alpha in the
1980
          comparison.
1981
   
1982
      RGB->RGBA:
1983
        SDL_SRCALPHA set:
1984
          alpha-blend (using the source per-surface alpha value);
1985
          set destination alpha to opaque.
1986
        SDL_SRCALPHA not set:
1987
          copy RGB, set destination alpha to source per-surface alpha value.
1988
        both:
1989
          if SDL_SRCCOLORKEY set, only copy the pixels matching the
1990
          source colour key.
1991
   
1992
      RGBA->RGBA:
1993
        SDL_SRCALPHA set:
1994
          alpha-blend (using the source alpha channel) the RGB values;
1995
          leave destination alpha untouched. [Note: is this correct?]
1996
          SDL_SRCCOLORKEY ignored.
1997
        SDL_SRCALPHA not set:
1998
          copy all of RGBA to the destination.
1999
          if SDL_SRCCOLORKEY set, only copy the pixels matching the
2000
          RGB values of the source colour key, ignoring alpha in the
2001
         comparison.
2002

2003
      RGB->RGB:
2004
        SDL_SRCALPHA set:
2005
          alpha-blend (using the source per-surface alpha value).
2006
        SDL_SRCALPHA not set:
2007
          copy RGB.
2008
        both:
2009
          if SDL_SRCCOLORKEY set, only copy the pixels matching the
2010
          source colour key.r
2011
   *
2012
   *  You should call SDL_BlitSurface() unless you know exactly how SDL
2013
   *  blitting works internally and how to use the other blit functions.
2014
   *}
2015

2016
  {**
2017
   *  This is the public blit function, SDL_BlitSurface(), and it performs
2018
   *  rectangle validation and clipping before passing it to SDL_LowerBlit()
2019
   *}
2020

2021
function SDL_UpperBlit(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UpperBlit' {$ENDIF};
2022

2023
  //SDL_BlitSurface = SDL_UpperBlit;
2024

2025
  {**
2026
   *  This is a semi-private blit function and it performs low-level surface
2027
   *  blitting only.
2028
   *}
2029

2030
function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LowerBlit' {$ENDIF};
2031

2032
  {**
2033
   *  Perform a fast, low quality, stretch blit between two surfaces of the
2034
   *  same pixel format.
2035
   *  
2036
   *  This function uses a static buffer, and is not thread-safe.
2037
   *}
2038

2039
function SDL_SoftStretch(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; const dstrect: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SoftStretch' {$ENDIF};
2040

2041
  //SDL_BlitScaled = SDL_UpperBlitScaled;
2042

2043
  {**
2044
   *  This is the public scaled blit function, SDL_BlitScaled(), and it performs
2045
   *  rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
2046
   *}
2047

2048
function SDL_UpperBlitScaled(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UpperBlitScaled' {$ENDIF};
2049

2050
  {**
2051
   *  This is a semi-private blit function and it performs low-level surface
2052
   *  scaled blitting only.
2053
   *}
2054

2055
function SDL_LowerBlitScaled(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LowerBlitScaled' {$ENDIF};
2056

2057

2058

2059
////////////////////////////////////////////////////////////////////////////////////////////////////////  
2060
//////////////////////         SDL_shape.h          ////////////////////////////////////////////////////
2061
////////////////////////////////////////////////////////////////////////////////////////////////////////  
2062

2063
{**  SDL_shape.h
2064
 *
2065
 * Header file for the shaped window API.
2066
 *}
2067
const
2068
  SDL_NONSHAPEABLE_WINDOW = -1;
2069
  SDL_INVALID_SHAPE_ARGUMENT = -2;
2070
  SDL_WINDOW_LACKS_SHAPE = -3;
2071
  
2072
type
2073
  PPSDL_Window = ^PSDL_Window;
2074
  PSDL_Window = ^TSDL_Window;
2075

2076
  {** An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. *}
2077
  TWindowShapeMode = ({** The default mode, a binarized alpha cutoff of 1. *}
2078
                      ShapeModeDefault,
2079
                      {** A binarized alpha cutoff with a given integer value. *}
2080
                      ShapeModeBinarizeAlpha,
2081
                      {** A binarized alpha cutoff with a given integer value, but with the opposite comparison. *}
2082
                      ShapeModeReverseBinarizeAlpha,
2083
                      {** A color key is applied. *}
2084
                      ShapeModeColorKey);
2085

2086
//#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
2087

2088
  {** A union containing parameters for shaped windows. *}
2089
  TSDL_WindowShapeParams = record
2090
    case Integer of
2091
      {** a cutoff alpha value for binarization of the window shape's alpha channel. *}
2092
      0: (binarizationCutoff: UInt8;);
2093
      1: (colorKey: TSDL_Color;);
2094
  end;
2095

2096
  {** A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. *}
2097
  PSDL_WindowShapeMode = ^TSDL_WindowShapeMode;
2098
  TSDL_WindowShapeMode = record
2099
    {** The mode of these window-shape parameters. *}
2100
    mode: TWindowShapeMode;
2101
    {** Window-shape parameters. *}
2102
    parameters: TSDL_WindowShapeParams;
2103
  end;
2104

2105

2106

2107
////////////////////////////////////////////////////////////////////////////////////////////////////////
2108
//////////////////////        SDL_video.h           ////////////////////////////////////////////////////
2109
////////////////////////////////////////////////////////////////////////////////////////////////////////
2110

2111
  {**
2112
   *  The structure that defines a display mode
2113
   *
2114
   *   SDL_GetNumDisplayModes()
2115
   *   SDL_GetDisplayMode()
2116
   *   SDL_GetDesktopDisplayMode()
2117
   *   SDL_GetCurrentDisplayMode()
2118
   *   SDL_GetClosestDisplayMode()
2119
   *   SDL_SetWindowDisplayMode()
2120
   *   SDL_GetWindowDisplayMode()
2121
   *}
2122

2123
  PSDL_DisplayMode = ^TSDL_DisplayMode;
2124
  TSDL_DisplayMode = record
2125
    format: UInt32;              {**< pixel format *}
2126
    w: SInt32;                   {**< width *}
2127
    h: SInt32;                   {**< height *}
2128
    refresh_rate: SInt32;        {**< refresh rate (or zero for unspecified) *}
2129
    driverdata: Pointer;         {**< driver-specific data, initialize to 0 *}
2130
  end;
2131

2132
  {* Define the SDL window-shaper structure *}
2133
  PSDL_WindowShaper = ^TSDL_WindowShaper;
2134
  TSDL_WindowShaper = record
2135
    {* The window associated with the shaper *}
2136
    window: PSDL_Window;
2137

2138
    {* The user's specified coordinates for the window, for once we give it a shape. *}
2139
    userx,usery: UInt32;
2140

2141
    {* The parameters for shape calculation. *}
2142
    mode: TSDL_WindowShapeMode;
2143

2144
    {* Has this window been assigned a shape? *}
2145
    hasshape: TSDL_Bool;
2146

2147
    driverdata: Pointer;
2148
  end;
2149

2150
  PSDL_WindowUserData = ^TSDL_WindowUserData;
2151
  TSDL_WindowUserData = record
2152
    name: PAnsiChar;
2153
    data: Pointer;
2154
    next: PSDL_WindowUserData;
2155
  end;
2156

2157
  {* Define the SDL window structure, corresponding to toplevel windows *}
2158
  TSDL_Window = record
2159
    magic: Pointer;
2160
    id: UInt32;
2161
    title: PAnsiChar;
2162
    fin_UTF8_title: SInt32;  // esta variable est� puesta porque la �ltima versi�n SDL2.dll devuelve un caracter de m�s en el title y se desplazan todos los otros campos
2163
    x,y: SInt32;
2164
    w,h: SInt32;
2165
    min_w, min_h: SInt32;
2166
    max_w, max_h: SInt32;
2167
    flags: UInt32;
2168

2169
    {* Stored position and size for windowed mode * }
2170
    windowed: TSDL_Rect;
2171

2172
    fullscreen_mode: TSDL_DisplayMode;
2173

2174
    brightness: Float;
2175
    gamma: PUInt16;
2176
    saved_gamma: PUInt16;  {* (just offset into gamma) *}
2177

2178
    surface: PSDL_Surface;
2179
    surface_valid: TSDL_Bool;
2180

2181
    shaper: PSDL_WindowShaper;
2182

2183
    data: PSDL_WindowUserData;
2184

2185
    driverdata: Pointer;
2186

2187
    prev: PSDL_Window;
2188
    next: PSDL_Window;
2189
  end;
2190

2191
  {**
2192
   * Get the shape parameters of a shaped window.
2193
   *
2194
   *  window The shaped window whose parameters should be retrieved.
2195
   *  shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
2196
   *
2197
   *  0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
2198
   *  data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
2199
   *  the SDL_Window* given is a shapeable window currently lacking a shape.
2200
   *
2201
   *  SDL_WindowShapeMode
2202
   *  SDL_SetWindowShape
2203
   *}
2204
function SDL_GetShapedWindowMode(window: PSDL_Window; shape_mode: TSDL_WindowShapeMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetShapedWindowMode' {$ENDIF};
2205

2206
  {**
2207
   * Set the shape and parameters of a shaped window.
2208
   *
2209
   *  window The shaped window whose parameters should be set.
2210
   *  shape A surface encoding the desired shape for the window.
2211
   *  shape_mode The parameters to set for the shaped window.
2212
   *
2213
   *  0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
2214
   *  if the SDL_Window* given does not reference a valid shaped window.
2215
   *
2216
   *  SDL_WindowShapeMode
2217
   *  SDL_GetShapedWindowMode.
2218
   *}
2219
function SDL_SetWindowShape(window: PSDL_Window; shape: PSDL_Surface; shape_mode: PSDL_WindowShapeMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowShape' {$ENDIF};
2220

2221
  {**
2222
   *  Create a window that can be shaped with the specified position, dimensions, and flags.
2223
   *
2224
   *   title The title of the window, in UTF-8 encoding.
2225
   *   x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
2226
   *               ::SDL_WINDOWPOS_UNDEFINED.
2227
   *   y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
2228
   *               ::SDL_WINDOWPOS_UNDEFINED.
2229
   *   w     The width of the window.
2230
   *   h     The height of the window.
2231
   *   flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
2232
   *         SDL_WINDOW_OPENGL,     SDL_WINDOW_INPUT_GRABBED,
2233
   *         SDL_WINDOW_SHOWN,      SDL_WINDOW_RESIZABLE,
2234
   *         SDL_WINDOW_MAXIMIZED,  SDL_WINDOW_MINIMIZED,
2235
   *         SDL_WINDOW_BORDERLESS is always set, and SDL_WINDOW_FULLSCREEN is always unset.
2236
   *
2237
   *   The window created, or NULL if window creation failed.
2238
   *
2239
   *  SDL_DestroyWindow()
2240
   *}
2241
function SDL_CreateShapedWindow(title: PAnsiChar; x: UInt32; y: UInt32; w: UInt32; h: UInt32; flags: UInt32): PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateShapedWindow' {$ENDIF};
2242

2243
  {**
2244
   * Return whether the given window is a shaped window.
2245
   *
2246
   *  window The window to query for being shaped.
2247
   *
2248
   *  SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
2249
   *  SDL_CreateShapedWindow
2250
   *}
2251
function SDL_IsShapedWindow(window: PSDL_Window): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IsShapedWindow' {$ENDIF};
2252

2253
  {**
2254
   *  The type used to identify a window
2255
   *  
2256
   *   SDL_CreateWindow()
2257
   *   SDL_CreateWindowFrom()
2258
   *   SDL_DestroyWindow()
2259
   *   SDL_GetWindowData()
2260
   *   SDL_GetWindowFlags()
2261
   *   SDL_GetWindowGrab()
2262
   *   SDL_GetWindowPosition()
2263
   *   SDL_GetWindowSize()
2264
   *   SDL_GetWindowTitle()
2265
   *   SDL_HideWindow()
2266
   *   SDL_MaximizeWindow()
2267
   *   SDL_MinimizeWindow()
2268
   *   SDL_RaiseWindow()
2269
   *   SDL_RestoreWindow()
2270
   *   SDL_SetWindowData()
2271
   *   SDL_SetWindowFullscreen()
2272
   *   SDL_SetWindowGrab()
2273
   *   SDL_SetWindowIcon()
2274
   *   SDL_SetWindowPosition()
2275
   *   SDL_SetWindowSize()
2276
   *   SDL_SetWindowBordered()
2277
   *   SDL_SetWindowTitle()
2278
   *   SDL_ShowWindow()
2279
   *}
2280

2281
const
2282
  {**
2283
   *  The flags on a window
2284
   *  
2285
   *   SDL_GetWindowFlags()
2286
   *}
2287

2288
  SDL_WINDOW_FULLSCREEN = $00000001;         {**< fullscreen window *}
2289
  SDL_WINDOW_OPENGL = $00000002;             {**< window usable with OpenGL context *}
2290
  SDL_WINDOW_SHOWN = $00000004;              {**< window is visible *}
2291
  SDL_WINDOW_HIDDEN = $00000008;             {**< window is not visible *}
2292
  SDL_WINDOW_BORDERLESS = $00000010;         {**< no window decoration *}
2293
  SDL_WINDOW_RESIZABLE = $00000020;          {**< window can be resized *}
2294
  SDL_WINDOW_MINIMIZED = $00000040;          {**< window is minimized *}
2295
  SDL_WINDOW_MAXIMIZED = $00000080;          {**< window is maximized *}
2296
  SDL_WINDOW_INPUT_GRABBED = $00000100;      {**< window has grabbed input focus *}
2297
  SDL_WINDOW_INPUT_FOCUS = $00000200;        {**< window has input focus *}
2298
  SDL_WINDOW_MOUSE_FOCUS = $00000400;        {**< window has mouse focus *}
2299
  SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN or $00001000;
2300
  SDL_WINDOW_FOREIGN = $00000800;            {**< window not created by SDL *}
2301

2302
type
2303
  TSDL_WindowFlags = DWord;
2304

2305
function SDL_WindowPos_IsUndefined(X: Variant): Variant;
2306
function SDL_WindowPos_IsCentered(X: Variant): Variant;
2307

2308
const
2309
   {**
2310
   *  Used to indicate that you don't care what the window position is.
2311
   *}
2312

2313
  SDL_WINDOWPOS_UNDEFINED_MASK = $1FFF0000;
2314
  SDL_WINDOWPOS_UNDEFINED = SDL_WINDOWPOS_UNDEFINED_MASK or 0;
2315

2316

2317
  {**
2318
   *  Used to indicate that the window position should be centered.
2319
   *}
2320

2321
  SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000;
2322
  SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_MASK or 0;
2323

2324
  {**
2325
   *  Event subtype for window events
2326
   *}
2327

2328
  SDL_WINDOWEVENT_NONE = 0;           {**< Never used *}
2329
  SDL_WINDOWEVENT_SHOWN = 1;          {**< Window has been shown *}
2330
  SDL_WINDOWEVENT_HIDDEN = 2;         {**< Window has been hidden *}
2331
  SDL_WINDOWEVENT_EXPOSED = 3;        {**< Window has been exposed and should be redrawn *}
2332
  SDL_WINDOWEVENT_MOVED = 4;          {**< Window has been moved to data1; data2 *}
2333
  SDL_WINDOWEVENT_RESIZED = 5;        {**< Window has been resized to data1xdata2 *}
2334
  SDL_WINDOWEVENT_SIZE_CHANGED = 6;   {**< The window size has changed; either as a result of an API call or through the system or user changing the window size. *}
2335
  SDL_WINDOWEVENT_MINIMIZED = 7;      {**< Window has been minimized *}
2336
  SDL_WINDOWEVENT_MAXIMIZED = 8;      {**< Window has been maximized *}
2337
  SDL_WINDOWEVENT_RESTORED = 9;       {**< Window has been restored to normal size and position *}
2338
  SDL_WINDOWEVENT_ENTER = 10;          {**< Window has gained mouse focus *}
2339
  SDL_WINDOWEVENT_LEAVE = 11;          {**< Window has lost mouse focus *}
2340
  SDL_WINDOWEVENT_FOCUS_GAINED = 12;   {**< Window has gained keyboard focus *}
2341
  SDL_WINDOWEVENT_FOCUS_LOST = 13;     {**< Window has lost keyboard focus *}
2342
  SDL_WINDOWEVENT_CLOSE = 14;          {**< The window manager requests that the window be closed *}
2343

2344
type
2345
  TSDL_WindowEventID = DWord;
2346

2347
  {**
2348
   *  An opaque handle to an OpenGL context.
2349
   *}
2350

2351
  TSDL_GLContext = Pointer;
2352

2353
  {**
2354
   *  OpenGL configuration attributes
2355
   *}
2356
   
2357
const
2358
  SDL_GL_RED_SIZE = 0;
2359
  SDL_GL_GREEN_SIZE = 1;
2360
  SDL_GL_BLUE_SIZE = 2;
2361
  SDL_GL_ALPHA_SIZE = 3;
2362
  SDL_GL_BUFFER_SIZE = 4;
2363
  SDL_GL_DOUBLEBUFFER = 5;
2364
  SDL_GL_DEPTH_SIZE = 6;
2365
  SDL_GL_STENCIL_SIZE = 7;
2366
  SDL_GL_ACCUM_RED_SIZE = 8;
2367
  SDL_GL_ACCUM_GREEN_SIZE = 9;
2368
  SDL_GL_ACCUM_BLUE_SIZE = 10;
2369
  SDL_GL_ACCUM_ALPHA_SIZE = 11;
2370
  SDL_GL_STEREO = 12;
2371
  SDL_GL_MULTISAMPLEBUFFERS = 13;
2372
  SDL_GL_MULTISAMPLESAMPLES = 14;
2373
  SDL_GL_ACCELERATED_VISUAL = 15;
2374
  SDL_GL_RETAINED_BACKING = 16;
2375
  SDL_GL_CONTEXT_MAJOR_VERSION = 17;
2376
  SDL_GL_CONTEXT_MINOR_VERSION = 18;
2377
  SDL_GL_CONTEXT_EGL = 19;
2378
  SDL_GL_CONTEXT_FLAGS = 20;
2379
  SDL_GL_CONTEXT_PROFILE_MASK = 21;
2380
  SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22;
2381

2382
type
2383
  TSDL_GLattr = DWord;
2384

2385
const
2386
  SDL_GL_CONTEXT_PROFILE_CORE           = $0001;
2387
  SDL_GL_CONTEXT_PROFILE_COMPATIBILITY  = $0002;
2388
  SDL_GL_CONTEXT_PROFILE_ES             = $0004;
2389

2390
type
2391
  TSDL_GLprofile = DWord;
2392

2393
const
2394
  SDL_GL_CONTEXT_DEBUG_FLAG              = $0001;
2395
  SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = $0002;
2396
  SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG      = $0004;
2397
  SDL_GL_CONTEXT_RESET_ISOLATION_FLAG    = $0008;
2398

2399
type
2400
  TSDL_GLcontextFlag = DWord;
2401

2402
  {* Function prototypes *}
2403

2404
  {**
2405
   *  Get the number of video drivers compiled into SDL
2406
   *
2407
   *  SDL_GetVideoDriver()
2408
   *}
2409

2410
function SDL_GetNumVideoDrivers: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumVideoDrivers' {$ENDIF};
2411

2412
  {**
2413
   *  Get the name of a built in video driver.
2414
   *
2415
   *  The video drivers are presented in the order in which they are
2416
   *  normally checked during initialization.
2417
   *
2418
   *  SDL_GetNumVideoDrivers()
2419
   *}
2420

2421
function SDL_GetVideoDriver(index: SInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetVideoDriver' {$ENDIF};
2422

2423
  {**
2424
   *  Initialize the video subsystem, optionally specifying a video driver.
2425
   *  
2426
   *  driver_name Initialize a specific driver by name, or nil for the
2427
   *  default video driver.
2428
   *  
2429
   *  0 on success, -1 on error
2430
   *  
2431
   *  This function initializes the video subsystem; setting up a connection
2432
   *  to the window manager, etc, and determines the available display modes
2433
   *  and pixel formats, but does not initialize a window or graphics mode.
2434
   *  
2435
   *  SDL_Video Quit()
2436
   *}
2437

2438
function SDL_VideoInit(const driver_name: PAnsiChar): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_VideoInit' {$ENDIF};
2439

2440
  {**
2441
   *  Shuts down the video subsystem.
2442
   *  
2443
   *  function closes all windows, and restores the original video mode.
2444
   *  
2445
   *  SDL_VideoInit()
2446
   *}
2447
procedure SDL_VideoQuit cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_VideoQuit' {$ENDIF};
2448

2449
  {**
2450
   *  Returns the name of the currently initialized video driver.
2451
   *
2452
   *  The name of the current video driver or nil if no driver
2453
   *  has been initialized
2454
   *  
2455
   *  SDL_GetNumVideoDrivers()
2456
   *  SDL_GetVideoDriver()
2457
   *}
2458

2459
function SDL_GetCurrentVideoDriver: PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetCurrentVideoDriver' {$ENDIF};
2460

2461
  {**
2462
   *  Returns the number of available video displays.
2463
   *  
2464
   *  SDL_GetDisplayBounds()
2465
   *}
2466

2467
function SDL_GetNumVideoDisplays: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumVideoDisplays' {$ENDIF};
2468

2469
  {**
2470
   *  Get the name of a display in UTF-8 encoding
2471
   *
2472
   *  The name of a display, or nil for an invalid display index.
2473
   *  
2474
   *  SDL_GetNumVideoDisplays()
2475
   *}
2476

2477
function SDL_GetDisplayName(displayIndex: SInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetDisplayName' {$ENDIF};
2478

2479
  {**
2480
   *  Get the desktop area represented by a display, with the primary
2481
   *  display located at 0,0
2482
   *
2483
   *  0 on success, or -1 if the index is out of range.
2484
   *  
2485
   *  SDL_GetNumVideoDisplays()
2486
   *}
2487

2488
function SDL_GetDisplayBounds(displayIndex: SInt32; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetDisplayBounds' {$ENDIF};
2489

2490
  {**
2491
   *  Returns the number of available display modes.
2492
   *  
2493
   *  SDL_GetDisplayMode()
2494
   *}
2495

2496
function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumDisplayModes' {$ENDIF};
2497

2498
  {**
2499
   *  Fill in information about a specific display mode.
2500
   *
2501
   *  The display modes are sorted in this priority:
2502
   *        bits per pixel -> more colors to fewer colors
2503
   *        width -> largest to smallest
2504
   *        height -> largest to smallest
2505
   *        refresh rate -> highest to lowest
2506
   *
2507
   *  SDL_GetNumDisplayModes()
2508
   *}
2509

2510
function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetDisplayMode' {$ENDIF};
2511

2512
  {**
2513
   *  Fill in information about the desktop display mode.
2514
   *}
2515

2516
function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetDesktopDisplayMode' {$ENDIF};
2517

2518
  {**
2519
   *  Fill in information about the current display mode.
2520
   *}
2521

2522
function SDL_GetCurrentDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetCurrentDisplayIndex' {$ENDIF};
2523

2524
  {**
2525
   *  Get the closest match to the requested display mode.
2526
   *  
2527
   *  mode The desired display mode
2528
   *  closest A pointer to a display mode to be filled in with the closest
2529
   *  match of the available display modes.
2530
   *  
2531
   *  The passed in value closest, or nil if no matching video mode
2532
   *  was available.
2533
   *  
2534
   *  The available display modes are scanned, and closest is filled in with the
2535
   *  closest mode matching the requested mode and returned.  The mode format and 
2536
   *  refresh_rate default to the desktop mode if they are 0.  The modes are 
2537
   *  scanned with size being first priority, format being second priority, and 
2538
   *  finally checking the refresh_rate.  If all the available modes are too 
2539
   *  small, then nil is returned.
2540
   *  
2541
   *  SDL_GetNumDisplayModes()
2542
   *  SDL_GetDisplayMode()
2543
   *}
2544

2545
function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetClosestDisplayMode' {$ENDIF};
2546

2547
  {**
2548
   *  Get the display index associated with a window.
2549
   *  
2550
   *  the display index of the display containing the center of the
2551
   *  window, or -1 on error.
2552
   *}
2553

2554
function SDL_GetWindowDisplayIndex(window: PSDL_Window): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowDisplayIndex' {$ENDIF};
2555

2556
  {**
2557
   *  Set the display mode used when a fullscreen window is visible.
2558
   *
2559
   *  By default the window's dimensions and the desktop format and refresh rate
2560
   *  are used.
2561
   *  
2562
   *  mode The mode to use, or nil for the default mode.
2563
   *  
2564
   *  0 on success, or -1 if setting the display mode failed.
2565
   *  
2566
   *  SDL_GetWindowDisplayMode()
2567
   *  SDL_SetWindowFullscreen()
2568
   *}
2569

2570
function SDL_SetWindowDisplayMode(window: PSDL_Window; const mode: PSDL_DisplayMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowDisplayMode' {$ENDIF};
2571

2572
  {**
2573
   *  Fill in information about the display mode used when a fullscreen
2574
   *  window is visible.
2575
   *
2576
   *  SDL_SetWindowDisplayMode()
2577
   *  SDL_SetWindowFullscreen()
2578
   *}
2579

2580
function SDL_GetWindowDisplayMode(window: PSDL_Window; mode: PSDL_DisplayMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowDisplayMode' {$ENDIF};
2581

2582
  {**
2583
   *  Get the pixel format associated with the window.
2584
   *}
2585

2586
function SDL_GetWindowPixelFormat(window: PSDL_Window): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowPixelFormat' {$ENDIF};
2587

2588
  {**
2589
   *  Create a window with the specified position, dimensions, and flags.
2590
   *  
2591
   *  title The title of the window, in UTF-8 encoding.
2592
   *  x     The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
2593
   *               ::SDL_WINDOWPOS_UNDEFINED.
2594
   *  y     The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
2595
   *               ::SDL_WINDOWPOS_UNDEFINED.
2596
   *  w     The width of the window.
2597
   *  h     The height of the window.
2598
   *  flags The flags for the window, a mask of any of the following:
2599
   *               ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, 
2600
   *               ::SDL_WINDOW_SHOWN,      ::SDL_WINDOW_BORDERLESS, 
2601
   *               ::SDL_WINDOW_RESIZABLE,  ::SDL_WINDOW_MAXIMIZED, 
2602
   *               ::SDL_WINDOW_MINIMIZED,  ::SDL_WINDOW_INPUT_GRABBED.
2603
   *  
2604
   *  The id of the window created, or zero if window creation failed.
2605
   *  
2606
   *  SDL_DestroyWindow()
2607
   *}
2608

2609
function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateWindow' {$ENDIF};
2610

2611
  {**
2612
   *  Create an SDL window from an existing native window.
2613
   *  
2614
   *  data A pointer to driver-dependent window creation data
2615
   *  
2616
   *  The id of the window created, or zero if window creation failed.
2617
   *
2618
   *  SDL_DestroyWindow()
2619
   *}
2620

2621
function SDL_CreateWindowFrom(const data: Pointer): PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateWindowFrom' {$ENDIF};
2622

2623
  {**
2624
   *  Get the numeric ID of a window, for logging purposes.
2625
   *}
2626

2627
function SDL_GetWindowID(window: PSDL_Window): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowID' {$ENDIF};
2628

2629
  {**
2630
   *  Get a window from a stored ID, or nil if it doesn't exist.
2631
   *}
2632

2633
function SDL_GetWindowFromID(id: UInt32): PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowFromID' {$ENDIF};
2634

2635
  {**
2636
   *  Get the window flags.
2637
   *}
2638

2639
function SDL_GetWindowFlags(window: PSDL_Window): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowFlags' {$ENDIF};
2640

2641
  {**
2642
   *  Set the title of a window, in UTF-8 format.
2643
   *  
2644
   *  SDL_GetWindowTitle()
2645
   *}
2646

2647
procedure SDL_SetWindowTitle(window: PSDL_Window; const title: PAnsiChar) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowTitle' {$ENDIF};
2648

2649
  {**
2650
   *  Get the title of a window, in UTF-8 format.
2651
   *  
2652
   *  SDL_SetWindowTitle()
2653
   *}
2654

2655
function SDL_GetWindowTitle(window: PSDL_Window): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowTitle' {$ENDIF};
2656

2657
  {**
2658
   *  Set the icon for a window.
2659
   *  
2660
   *  icon The icon for the window.
2661
   *}
2662

2663
procedure SDL_SetWindowIcon(window: PSDL_Window; icon: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowIcon' {$ENDIF};
2664

2665
  {**
2666
   *  Associate an arbitrary named pointer with a window.
2667
   *  
2668
   *  window   The window to associate with the pointer.
2669
   *  name     The name of the pointer.
2670
   *  userdata The associated pointer.
2671
   *
2672
   *  The previous value associated with 'name'
2673
   *
2674
   *  The name is case-sensitive.
2675
   *
2676
   *  SDL_GetWindowData()
2677
   *}
2678

2679
function SDL_SetWindowData(window: PSDL_Window; const name: PAnsiChar; userdata: Pointer): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowData' {$ENDIF};
2680

2681
  {**
2682
   *  Retrieve the data pointer associated with a window.
2683
   *  
2684
   *  window   The window to query.
2685
   *  name     The name of the pointer.
2686
   *
2687
   *  The value associated with 'name'
2688
   *  
2689
   *  SDL_SetWindowData()
2690
   *}
2691

2692
function SDL_GetWindowData(window: PSDL_Window; const name: PAnsiChar): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowData' {$ENDIF};
2693

2694
  {**
2695
   *  Set the position of a window.
2696
   *  
2697
   *  window   The window to reposition.
2698
   *  x        The x coordinate of the window, SDL_WINDOWPOS_CENTERED, or
2699
   *                  SDL_WINDOWPOS_UNDEFINED.
2700
   *  y        The y coordinate of the window, SDL_WINDOWPOS_CENTERED, or
2701
   *                  SDL_WINDOWPOS_UNDEFINED.
2702
   *  
2703
   *  The window coordinate origin is the upper left of the display.
2704
   *  
2705
   *  SDL_GetWindowPosition()
2706
   *}
2707

2708
procedure SDL_SetWindowPosition(window: PSDL_Window; x: SInt32; y: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowPosition' {$ENDIF};
2709

2710
  {**
2711
   *  Get the position of a window.
2712
   *  
2713
   *  x        Pointer to variable for storing the x position, may be nil
2714
   *  y        Pointer to variable for storing the y position, may be nil
2715
   *
2716
   *  SDL_SetWindowPosition()
2717
   *}
2718

2719
procedure SDL_GetWindowPosition(window: PSDL_Window; x: PInt; y: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowPosition' {$ENDIF};
2720

2721
  {**
2722
   *  Set the size of a window's client area.
2723
   *  
2724
   *  w        The width of the window, must be >0
2725
   *  h        The height of the window, must be >0
2726
   *
2727
   *  You can't change the size of a fullscreen window, it automatically
2728
   *  matches the size of the display mode.
2729
   *  
2730
   *  SDL_GetWindowSize()
2731
   *}
2732

2733
procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowSize' {$ENDIF};
2734

2735
  {**
2736
   *  Get the size of a window's client area.
2737
   *  
2738
   *  w        Pointer to variable for storing the width, may be nil
2739
   *  h        Pointer to variable for storing the height, may be nil
2740
   *  
2741
   *  SDL_SetWindowSize()
2742
   *}
2743

2744
procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowSize' {$ENDIF};
2745
    
2746
  {**
2747
   *  Set the minimum size of a window's client area.
2748
   *  
2749
   *  min_w     The minimum width of the window, must be >0
2750
   *  min_h     The minimum height of the window, must be >0
2751
   *
2752
   *  You can't change the minimum size of a fullscreen window, it
2753
   *  automatically matches the size of the display mode.
2754
   *
2755
   *  SDL_GetWindowMinimumSize()
2756
   *  SDL_SetWindowMaximumSize()
2757
   *}
2758

2759
procedure SDL_SetWindowMinimumSize(window: PSDL_Window; min_w: SInt32; min_h: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowMinimumSize' {$ENDIF};
2760
    
2761
  {**
2762
   *  Get the minimum size of a window's client area.
2763
   *  
2764
   *  w        Pointer to variable for storing the minimum width, may be nil
2765
   *  h        Pointer to variable for storing the minimum height, may be nil
2766
   *  
2767
   *  SDL_GetWindowMaximumSize()
2768
   *  SDL_SetWindowMinimumSize()
2769
   *}
2770

2771
procedure SDL_GetWindowMinimumSize(window: PSDL_Window; w: PInt; h: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowMinimumSize' {$ENDIF};
2772

2773
  {**
2774
   *  Set the maximum size of a window's client area.
2775
   *
2776
   *  max_w     The maximum width of the window, must be >0
2777
   *  max_h     The maximum height of the window, must be >0
2778
   *
2779
   *  You can't change the maximum size of a fullscreen window, it
2780
   *  automatically matches the size of the display mode.
2781
   *
2782
   *  SDL_GetWindowMaximumSize()
2783
   *  SDL_SetWindowMinimumSize()
2784
   *}
2785

2786
procedure SDL_SetWindowMaximumSize(window: PSDL_Window; max_w: SInt32; max_h: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowMaximumSize' {$ENDIF};
2787

2788
  {**
2789
   *  Get the maximum size of a window's client area.
2790
   *  
2791
   *  w        Pointer to variable for storing the maximum width, may be nil
2792
   *  h        Pointer to variable for storing the maximum height, may be nil
2793
   *
2794
   *  SDL_GetWindowMinimumSize()
2795
   *  SDL_SetWindowMaximumSize()
2796
   *}
2797

2798
procedure SDL_GetWindowMaximumSize(window: PSDL_Window; w: PInt; h: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowMaximumSize' {$ENDIF};
2799

2800
  {**
2801
   *  Set the border state of a window.
2802
   *
2803
   *  This will add or remove the window's SDL_WINDOW_BORDERLESS flag and
2804
   *  add or remove the border from the actual window. This is a no-op if the
2805
   *  window's border already matches the requested state.
2806
   *
2807
   *  window The window of which to change the border state.
2808
   *  bordered SDL_FALSE to remove border, SDL_TRUE to add border.
2809
   *
2810
   *  You can't change the border state of a fullscreen window.
2811
   *  
2812
   *  SDL_GetWindowFlags()
2813
   *}
2814

2815
procedure SDL_SetWindowBordered(window: PSDL_Window; bordered: TSDL_Bool) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowBordered' {$ENDIF};
2816

2817
  {**
2818
   *  Show a window.
2819
   *  
2820
   *  SDL_HideWindow()
2821
   *}
2822

2823
procedure SDL_ShowWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ShowWindow' {$ENDIF};
2824

2825
  {**
2826
   *  Hide a window.
2827
   *  
2828
   *  SDL_ShowWindow()
2829
   *}
2830

2831
procedure SDL_HideWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_HideWindow' {$ENDIF};
2832

2833
  {**
2834
   *  Raise a window above other windows and set the input focus.
2835
   *}
2836

2837
procedure SDL_RaiseWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RaiseWindow' {$ENDIF};
2838

2839
  {**
2840
   *  Make a window as large as possible.
2841
   *  
2842
   *  SDL_RestoreWindow()
2843
   *}
2844

2845
procedure SDL_MaximizeWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_MaximizeWindow' {$ENDIF};
2846

2847
  {**
2848
   *  Minimize a window to an iconic representation.
2849
   *  
2850
   *  SDL_RestoreWindow()
2851
   *}
2852

2853
procedure SDL_MinimizeWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_MinimizeWindow' {$ENDIF};
2854

2855
  {**
2856
   *  Restore the size and position of a minimized or maximized window.
2857
   *
2858
   *  SDL_MaximizeWindow()
2859
   *  SDL_MinimizeWindow()
2860
   *}
2861

2862
procedure SDL_RestoreWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RestoreWindow' {$ENDIF};
2863

2864
  {**
2865
   *  Set a window's fullscreen state.
2866
   *  
2867
   *  0 on success, or -1 if setting the display mode failed.
2868
   *  
2869
   *  SDL_SetWindowDisplayMode()
2870
   *  SDL_GetWindowDisplayMode()
2871
   *}
2872

2873
function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowFullscreen' {$ENDIF};
2874

2875
  {**
2876
   *  Get the SDL surface associated with the window.
2877
   *
2878
   *  The window's framebuffer surface, or nil on error.
2879
   *
2880
   *  A new surface will be created with the optimal format for the window,
2881
   *  if necessary. This surface will be freed when the window is destroyed.
2882
   *
2883
   *  You may not combine this with 3D or the rendering API on this window.
2884
   *
2885
   *  SDL_UpdateWindowSurface()
2886
   *  SDL_UpdateWindowSurfaceRects()
2887
   *}
2888

2889
function SDL_GetWindowSurface(window: PSDL_Window): PSDL_Surface cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowSurface' {$ENDIF};
2890

2891
  {**
2892
   *  Copy the window surface to the screen.
2893
   *
2894
   *  0 on success, or -1 on error.
2895
   *
2896
   *  SDL_GetWindowSurface()
2897
   *  SDL_UpdateWindowSurfaceRects()
2898
   *}
2899

2900
function SDL_UpdateWindowSurface(window: PSDL_Window): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UpdateWindowSurface' {$ENDIF};
2901

2902
  {**
2903
   *  Copy a number of rectangles on the window surface to the screen.
2904
   *
2905
   *  0 on success, or -1 on error.
2906
   *
2907
   *  SDL_GetWindowSurface()
2908
   *  SDL_UpdateWindowSurfaceRect()
2909
   *}
2910

2911
function SDL_UpdateWindowSurfaceRects(window: PSDL_Window; rects: PSDL_Rect; numrects: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UpdateWindowSurfaceRects' {$ENDIF};
2912

2913
  {**
2914
   *  Set a window's input grab mode.
2915
   *  
2916
   *  grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input.
2917
   *  
2918
   *  SDL_GetWindowGrab()
2919
   *}
2920

2921
procedure SDL_SetWindowGrab(window: PSDL_Window; grabbed: TSDL_Bool) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowGrab' {$ENDIF};
2922

2923
  {**
2924
   *  Get a window's input grab mode.
2925
   *  
2926
   *  This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise.
2927
   *
2928
   *  SDL_SetWindowGrab()
2929
   *}
2930

2931
function SDL_GetWindowGrab(window: PSDL_Window): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowGrab' {$ENDIF};
2932

2933
  {**
2934
   *  Set the brightness (gamma correction) for a window.
2935
   *
2936
   *  0 on success, or -1 if setting the brightness isn't supported.
2937
   *  
2938
   *  SDL_GetWindowBrightness()
2939
   *  SDL_SetWindowGammaRamp()
2940
   *}
2941

2942
function SDL_SetWindowBrightness(window: PSDL_Window; brightness: Float): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowBrightness' {$ENDIF};
2943

2944
  {**
2945
   *  Get the brightness (gamma correction) for a window.
2946
   *  
2947
   *  The last brightness value passed to SDL_SetWindowBrightness()
2948
   *  
2949
   *  SDL_SetWindowBrightness()
2950
   *}
2951

2952
function SDL_GetWindowBrightness(window: PSDL_Window): Float cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowBrightness' {$ENDIF};
2953

2954
  {**
2955
   *  Set the gamma ramp for a window.
2956
   *  
2957
   *  red The translation table for the red channel, or nil.
2958
   *  green The translation table for the green channel, or nil.
2959
   *  blue The translation table for the blue channel, or nil.
2960
   *
2961
   *  0 on success, or -1 if gamma ramps are unsupported.
2962
   *  
2963
   *  Set the gamma translation table for the red, green, and blue channels
2964
   *  of the video hardware.  Each table is an array of 256 16-bit quantities,
2965
   *  representing a mapping between the input and output for that channel.
2966
   *  The input is the index into the array, and the output is the 16-bit
2967
   *  gamma value at that index, scaled to the output color precision.
2968
   *
2969
   *  SDL_GetWindowGammaRamp()
2970
   *}
2971

2972
function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetWindowGammaRamp' {$ENDIF};
2973

2974
  {**
2975
   *  Get the gamma ramp for a window.
2976
   *  
2977
   *  red   A pointer to a 256 element array of 16-bit quantities to hold
2978
   *        the translation table for the red channel, or nil.
2979
   *  green A pointer to a 256 element array of 16-bit quantities to hold
2980
   *        the translation table for the green channel, or nil.
2981
   *  blue  A pointer to a 256 element array of 16-bit quantities to hold
2982
   *        the translation table for the blue channel, or nil.
2983
   *   
2984
   *  0 on success, or -1 if gamma ramps are unsupported.
2985
   *  
2986
   *  SDL_SetWindowGammaRamp()
2987
   *}
2988

2989
function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetWindowGammaRamp' {$ENDIF};
2990

2991
  {**
2992
   *  Destroy a window.
2993
   *}
2994

2995
procedure SDL_DestroyWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroyWindow' {$ENDIF};
2996

2997
  {**
2998
   *  Returns whether the screensaver is currently enabled (default on).
2999
   *  
3000
   *  SDL_EnableScreenSaver()
3001
   *  SDL_DisableScreenSaver()
3002
   *}
3003

3004
function SDL_IsScreenSaverEnabled: TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IsScreenSaverEnabled' {$ENDIF};
3005

3006
  {**
3007
   *  Allow the screen to be blanked by a screensaver
3008
   *  
3009
   *  SDL_IsScreenSaverEnabled()
3010
   *  SDL_DisableScreenSaver()
3011
   *}
3012

3013
procedure SDL_EnableScreenSaver cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_EnableScreenSaver' {$ENDIF};
3014

3015
  {**
3016
   *  Prevent the screen from being blanked by a screensaver
3017
   *  
3018
   *  SDL_IsScreenSaverEnabled()
3019
   *  SDL_EnableScreenSaver()
3020
   *}
3021

3022
procedure SDL_DisableScreenSaver cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DisableScreenSaver' {$ENDIF};
3023

3024
  {**
3025
   *  OpenGL support functions
3026
   *}
3027

3028
  {**
3029
   *  Dynamically load an OpenGL library.
3030
   *  
3031
   *  path The platform dependent OpenGL library name, or nil to open the
3032
   *              default OpenGL library.
3033
   *  
3034
   *  0 on success, or -1 if the library couldn't be loaded.
3035
   *
3036
   *  This should be done after initializing the video driver, but before
3037
   *  creating any OpenGL windows.  If no OpenGL library is loaded, the default
3038
   *  library will be loaded upon creation of the first OpenGL window.
3039
   *  
3040
   *  If you do this, you need to retrieve all of the GL functions used in
3041
   *  your program from the dynamic library using SDL_GL_GetProcAddress().
3042
   *  
3043
   *  SDL_GL_GetProcAddress()
3044
   *  SDL_GL_UnloadLibrary()
3045
   *}
3046

3047
function SDL_GL_LoadLibrary(const path: PAnsiChar): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_LoadLibrary' {$ENDIF};
3048

3049
  {**
3050
   *  Get the address of an OpenGL function.
3051
   *}
3052

3053
function SDL_GL_GetProcAddress(const proc: PAnsiChar): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_GetProcAddress' {$ENDIF};
3054

3055
  {**
3056
   *  Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
3057
   *
3058
   *  SDL_GL_LoadLibrary()
3059
   *}
3060

3061
procedure SDL_GL_UnloadLibrary cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_UnloadLibrary' {$ENDIF};
3062

3063
  {**
3064
   *  Return true if an OpenGL extension is supported for the current
3065
   *  context.
3066
   *}
3067

3068
function SDL_GL_ExtensionSupported(const extension: PAnsiChar): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_ExtensionSupported' {$ENDIF};
3069

3070
  {**
3071
   *  Set an OpenGL window attribute before window creation.
3072
   *}
3073

3074
function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_SetAttribute' {$ENDIF};
3075

3076
  {**
3077
   *  Get the actual value for an attribute from the current context.
3078
   *}
3079

3080
function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_GetAttribute' {$ENDIF};
3081

3082
  {**
3083
   *  Create an OpenGL context for use with an OpenGL window, and make it
3084
   *  current.
3085
   *
3086
   *  SDL_GL_DeleteContext()
3087
   *}
3088

3089
function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_CreateContext' {$ENDIF};
3090

3091
  {**
3092
   *  Set up an OpenGL context for rendering into an OpenGL window.
3093
   *  
3094
   *  The context must have been created with a compatible window.
3095
   *}
3096

3097
function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_MakeCurrent' {$ENDIF};
3098

3099
  {**
3100
   *  Get the currently active OpenGL window.
3101
   *}
3102
function SDL_GL_GetCurrentWindow: PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_GetCurrentWindow' {$ENDIF};
3103

3104
  {**
3105
   *  Get the currently active OpenGL context.
3106
   *}
3107
function SDL_GL_GetCurrentContext: TSDL_GLContext cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_GetCurrentContext' {$ENDIF};
3108

3109
  {**
3110
   *  Set the swap interval for the current OpenGL context.
3111
   *  
3112
   *  interval 0 for immediate updates, 1 for updates synchronized with the
3113
   *  vertical retrace. If the system supports it, you may
3114
   *  specify -1 to allow late swaps to happen immediately
3115
   *  instead of waiting for the next retrace.
3116
   *
3117
   *  0 on success, or -1 if setting the swap interval is not supported.
3118
   *  
3119
   *  SDL_GL_GetSwapInterval()
3120
   *}
3121

3122
function SDL_GL_SetSwapInterval(interval: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_SetSwapInterval' {$ENDIF};
3123

3124
  {**
3125
   *  Get the swap interval for the current OpenGL context.
3126
   *  
3127
   *  0 if there is no vertical retrace synchronization, 1 if the buffer
3128
   *  swap is synchronized with the vertical retrace, and -1 if late
3129
   *  swaps happen immediately instead of waiting for the next retrace.
3130
   *  If the system can't determine the swap interval, or there isn't a
3131
   *  valid current context, this will return 0 as a safe default.
3132
   *
3133
   *  SDL_GL_SetSwapInterval()
3134
   *}
3135

3136
function SDL_GL_GetSwapInterval: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_GetSwapInterval' {$ENDIF};
3137

3138
  {**
3139
   *  Swap the OpenGL buffers for a window, if double-buffering is
3140
   *  supported.
3141
   *}
3142

3143
procedure SDL_GL_SwapWindow(window: PSDL_Window) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_SwapWindow' {$ENDIF};
3144

3145
  {**
3146
   *  Delete an OpenGL context.
3147
   *  
3148
   *  SDL_GL_CreateContext()
3149
   *}
3150

3151
procedure SDL_GL_DeleteContext(context: TSDL_GLContext) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_DeleteContext' {$ENDIF};
3152

3153
  {*OpenGL support functions*}
3154

3155

3156

3157
////////////////////////////////////////////////////////////////////////////////////////////////////////
3158
//////////////////////        SDL_renderer.h         ///////////////////////////////////////////////////
3159
////////////////////////////////////////////////////////////////////////////////////////////////////////  
3160

3161
  {**
3162
   *  Flags used when creating a rendering context
3163
   *}
3164
const
3165
  SDL_RENDERER_SOFTWARE = $00000001;          {**< The renderer is a software fallback *}
3166
  SDL_RENDERER_ACCELERATED = $00000002;       {**< The renderer uses hardware
3167
                                                   acceleration *}
3168
  SDL_RENDERER_PRESENTVSYNC = $00000004;      {**< Present is synchronized
3169
                                                   with the refresh rate *}
3170
  SDL_RENDERER_TARGETTEXTURE = $00000008;     {**< The renderer supports
3171
                                                   rendering to texture *}
3172

3173
type
3174
  PSDL_RendererFlags = ^TSDL_RendererFlags;
3175
  TSDL_RendererFlags = Word;
3176

3177
  {**
3178
   *  Information on the capabilities of a render driver or context.
3179
   *}
3180
  PSDL_RendererInfo = ^TSDL_RendererInfo;
3181
  TSDL_RendererInfo = record  
3182
    name: PAnsiChar;                         {**< The name of the renderer *}
3183
    flags: UInt32;                           {**< Supported ::SDL_RendererFlags *}
3184
    num_texture_formats: UInt32;             {**< The number of available texture formats *}
3185
    texture_formats: array[0..15] of UInt32; {**< The available texture formats *}
3186
    max_texture_width: SInt32;               {**< The maximimum texture width *}
3187
    max_texture_height: SInt32;              {**< The maximimum texture height *}
3188
  end;
3189

3190
  {**
3191
   *  The access pattern allowed for a texture.
3192
   *}
3193
type
3194
  PSDL_TextureAccess = ^TSDL_TextureAccess;
3195
  TSDL_TextureAccess = (
3196
                        SDL_TEXTUREACCESS_STATIC,    {**< Changes rarely, not lockable *}
3197
                        SDL_TEXTUREACCESS_STREAMING, {**< Changes frequently, lockable *}
3198
                        SDL_TEXTUREACCESS_TARGET     {**< Texture can be used as a render target *}
3199
                        );
3200

3201
  {**
3202
   *  The texture channel modulation used in SDL_RenderCopy().
3203
   *}
3204
  PSDL_TextureModulate = ^TSDL_TextureModulate;
3205
  TSDL_TextureModulate = (
3206
                          SDL_TEXTUREMODULATE_NONE,     {**< No modulation *}
3207
                          SDL_TEXTUREMODULATE_COLOR,    {**< srcC = srcC * color *}
3208
                          SDL_TEXTUREMODULATE_ALPHA     {**< srcA = srcA * alpha *}
3209
                          );
3210

3211
  {**
3212
   *  Flip constants for SDL_RenderCopyEx
3213
   *}
3214
type
3215
  PSDL_RendererFlip = ^TSDL_RendererFlip;
3216
  TSDL_RendererFlip = (SDL_FLIP_NONE,       {**< Do not flip *}
3217
                       SDL_FLIP_HORIZONTAL, {**< flip horizontally *}
3218
                       SDL_FLIP_VERTICAL    {**< flip vertically *}
3219
                       );
3220

3221
  {**
3222
   *  A structure representing rendering state
3223
   *}
3224

3225
  PPSDL_Renderer = ^PSDL_Renderer;
3226
  PSDL_Renderer = Pointer; //todo!
3227

3228
  {**
3229
   *  An efficient driver-specific representation of pixel data
3230
   *}
3231
  PSDL_Texture = Pointer; //todo!
3232

3233
  {* Function prototypes *}
3234

3235
  {**
3236
   *  Get the number of 2D rendering drivers available for the current
3237
   *  display.
3238
   *
3239
   *  A render driver is a set of code that handles rendering and texture
3240
   *  management on a particular display.  Normally there is only one, but
3241
   *  some drivers may have several available with different capabilities.
3242
   *
3243
   *   SDL_GetRenderDriverInfo()
3244
   *   SDL_CreateRenderer()
3245
   *}
3246
function SDL_GetNumRenderDrivers: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumRenderDrivers' {$ENDIF};
3247

3248
  {**
3249
   *  Get information about a specific 2D rendering driver for the current
3250
   *  display.
3251
   *
3252
   *   index The index of the driver to query information about.
3253
   *   info  A pointer to an SDL_RendererInfo struct to be filled with
3254
   *               information on the rendering driver.
3255
   *
3256
   *   0 on success, -1 if the index was out of range.
3257
   *
3258
   *   SDL_CreateRenderer()
3259
   *}
3260
function SDL_GetRenderDriverInfo(index: SInt32; info: PSDL_RendererInfo): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRenderDriverInfo' {$ENDIF};
3261

3262
  {**
3263
   *  Create a window and default renderer
3264
   *
3265
   *   width    The width of the window
3266
   *   height   The height of the window
3267
   *   window_flags The flags used to create the window
3268
   *   window   A pointer filled with the window, or NULL on error
3269
   *   renderer A pointer filled with the renderer, or NULL on error
3270
   *
3271
   *   0 on success, or -1 on error
3272
   *}
3273
function SDL_CreateWindowAndRenderer(width: SInt32; height: SInt32; window_flags: UInt32; window: PPSDL_Window; renderer: PPSDL_Renderer): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateWindowAndRenderer' {$ENDIF};
3274

3275
  {**
3276
   *  Create a 2D rendering context for a window.
3277
   *
3278
   *   window The window where rendering is displayed.
3279
   *   index    The index of the rendering driver to initialize, or -1 to
3280
   *                  initialize the first one supporting the requested flags.
3281
   *   flags    ::SDL_RendererFlags.
3282
   *
3283
   *   A valid rendering context or NULL if there was an error.
3284
   *
3285
   *   SDL_CreateSoftwareRenderer()
3286
   *   SDL_GetRendererInfo()
3287
   *   SDL_DestroyRenderer()
3288
   *}
3289
function SDL_CreateRenderer(window: PSDL_Window; index: SInt32; flags: UInt32): PSDL_Renderer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateRenderer' {$ENDIF};
3290

3291
  {**
3292
   *  Create a 2D software rendering context for a surface.
3293
   *
3294
   *   surface The surface where rendering is done.
3295
   *
3296
   *   A valid rendering context or NULL if there was an error.
3297
   *
3298
   *   SDL_CreateRenderer()
3299
   *   SDL_DestroyRenderer()
3300
   *}
3301
function SDL_CreateSoftwareRenderer(surface: PSDL_Surface): PSDL_Renderer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateSoftwareRenderer' {$ENDIF};
3302

3303
  {**
3304
   *  Get the renderer associated with a window.
3305
   *}
3306
function SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRenderer' {$ENDIF};
3307

3308
  {**
3309
   *  Get information about a rendering context.
3310
   *}
3311
function SDL_GetRendererInfo(renderer: PSDL_Renderer; info: PSDL_RendererInfo): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRendererInfo' {$ENDIF};
3312

3313
  {**
3314
   *  Get the output size of a rendering context.
3315
   *}
3316
function SDL_GetRendererOutputSize(renderer: PSDL_Renderer; w: PInt; h: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRendererOutputSize' {$ENDIF};
3317

3318
  {**
3319
   *  Create a texture for a rendering context.
3320
   *
3321
   *   renderer The renderer.
3322
   *   format The format of the texture.
3323
   *   access One of the enumerated values in ::SDL_TextureAccess.
3324
   *   w      The width of the texture in pixels.
3325
   *   h      The height of the texture in pixels.
3326
   *
3327
   *   The created texture is returned, or 0 if no rendering context was
3328
   *   active,  the format was unsupported, or the width or height were out
3329
   *   of range.
3330
   *
3331
   *  SDL_QueryTexture()
3332
   *  SDL_UpdateTexture()
3333
   *  SDL_DestroyTexture()
3334
   *}
3335
function SDL_CreateTexture(renderer: PSDL_Renderer; format: UInt32; access: SInt32; w: SInt32; h: SInt32): PSDL_Texture cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateTexture' {$ENDIF};
3336

3337
  {**
3338
   *  Create a texture from an existing surface.
3339
   *
3340
   *   renderer The renderer.
3341
   *   surface The surface containing pixel data used to fill the texture.
3342
   *
3343
   *   The created texture is returned, or 0 on error.
3344
   *
3345
   *   The surface is not modified or freed by this function.
3346
   *
3347
   *   SDL_QueryTexture()
3348
   *   SDL_DestroyTexture()
3349
   *}
3350
function SDL_CreateTextureFromSurface(renderer: PSDL_Renderer; surface: PSDL_Surface): PSDL_Texture cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateTextureFromSurface' {$ENDIF};
3351

3352
  {**
3353
   *  Query the attributes of a texture
3354
   *
3355
   *   texture A texture to be queried.
3356
   *   format  A pointer filled in with the raw format of the texture.  The
3357
   *           actual format may differ, but pixel transfers will use this
3358
   *           format.
3359
   *   access  A pointer filled in with the actual access to the texture.
3360
   *   w       A pointer filled in with the width of the texture in pixels.
3361
   *   h       A pointer filled in with the height of the texture in pixels.
3362
   *
3363
   *   0 on success, or -1 if the texture is not valid.
3364
   *}
3365
function SDL_QueryTexture(texture: PSDL_Texture; format: PUInt32; access: PInt; w: PInt; h: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_QueryTexture' {$ENDIF};
3366

3367
  {**
3368
   *  Set an additional color value used in render copy operations.
3369
   *
3370
   *   texture The texture to update.
3371
   *   r       The red color value multiplied into copy operations.
3372
   *   g       The green color value multiplied into copy operations.
3373
   *   b       The blue color value multiplied into copy operations.
3374
   *
3375
   *   0 on success, or -1 if the texture is not valid or color modulation
3376
   *   is not supported.
3377
   *
3378
   *   SDL_GetTextureColorMod()
3379
   *}
3380
function SDL_SetTextureColorMod(texture: PSDL_Texture; r: UInt8; g: UInt8; b: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetTextureColorMod' {$ENDIF};
3381

3382
  {**
3383
   *  Get the additional color value used in render copy operations.
3384
   *
3385
   *   texture The texture to query.
3386
   *   r         A pointer filled in with the current red color value.
3387
   *   g         A pointer filled in with the current green color value.
3388
   *   b         A pointer filled in with the current blue color value.
3389
   *
3390
   *   0 on success, or -1 if the texture is not valid.
3391
   *
3392
   *   SDL_SetTextureColorMod()
3393
   *}
3394
function SDL_GetTextureColorMod(texture: PSDL_Texture; r: PUInt8; g: PUInt8; b: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTextureColorMod' {$ENDIF};
3395

3396
  {**
3397
   *  Set an additional alpha value used in render copy operations.
3398
   *
3399
   *   texture The texture to update.
3400
   *   alpha     The alpha value multiplied into copy operations.
3401
   *
3402
   *   0 on success, or -1 if the texture is not valid or alpha modulation
3403
   *   is not supported.
3404
   *
3405
   *   SDL_GetTextureAlphaMod()
3406
   *}
3407
function SDL_SetTextureAlphaMod(texture: PSDL_Texture; alpha: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetTextureAlphaMod' {$ENDIF};
3408

3409
  {**
3410
   *  Get the additional alpha value used in render copy operations.
3411
   *
3412
   *   texture The texture to query.
3413
   *   alpha     A pointer filled in with the current alpha value.
3414
   *
3415
   *   0 on success, or -1 if the texture is not valid.
3416
   *
3417
   *   SDL_SetTextureAlphaMod()
3418
   *}
3419
function SDL_GetTextureAlphaMod(texture: PSDL_Texture; alpha: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTextureAlphaMod' {$ENDIF};
3420

3421
  {**
3422
   *   Set the blend mode used for texture copy operations.
3423
   *
3424
   *   texture The texture to update.
3425
   *   blendMode ::SDL_BlendMode to use for texture blending.
3426
   *
3427
   *   0 on success, or -1 if the texture is not valid or the blend mode is
3428
   *   not supported.
3429
   *
3430
   *   If the blend mode is not supported, the closest supported mode is
3431
   *   chosen.
3432
   *
3433
   *   SDL_GetTextureBlendMode()
3434
   *}
3435
function SDL_SetTextureBlendMode(texture: PSDL_Texture; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetTextureBlendMode' {$ENDIF};
3436

3437
  {**
3438
   *  Get the blend mode used for texture copy operations.
3439
   *
3440
   *   texture   The texture to query.
3441
   *   blendMode A pointer filled in with the current blend mode.
3442
   *
3443
   *   0 on success, or -1 if the texture is not valid.
3444
   *
3445
   *   SDL_SetTextureBlendMode()
3446
   *}
3447
function SDL_GetTextureBlendMode(texture: PSDL_Texture; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTextureBlendMode' {$ENDIF};
3448

3449
  {**
3450
   *  Update the given texture rectangle with new pixel data.
3451
   *
3452
   *   texture   The texture to update
3453
   *   rect      A pointer to the rectangle of pixels to update, or NULL to
3454
   *                   update the entire texture.
3455
   *   pixels    The raw pixel data.
3456
   *   pitch     The number of bytes between rows of pixel data.
3457
   *
3458
   *   0 on success, or -1 if the texture is not valid.
3459
   *
3460
   *   This is a fairly slow function.
3461
   *}
3462
function SDL_UpdateTexture(texture: PSDL_Texture; rect: PSDL_Rect; pixels: Pointer; pitch: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UpdateTexture' {$ENDIF};
3463

3464
  {**
3465
   *  Lock a portion of the texture for write-only pixel access.
3466
   *
3467
   *   texture   The texture to lock for access, which was created with
3468
   *             SDL_TEXTUREACCESS_STREAMING.
3469
   *   rect      A pointer to the rectangle to lock for access. If the rect
3470
   *             is NULL, the entire texture will be locked.
3471
   *   pixels    This is filled in with a pointer to the locked pixels,
3472
   *             appropriately offset by the locked area.
3473
   *   pitch     This is filled in with the pitch of the locked pixels.
3474
   *
3475
   *   0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
3476
   *
3477
   *   SDL_UnlockTexture()
3478
   *}
3479
function SDL_LockTexture(texture: PSDL_Texture; rect: PSDL_Rect; pixels: PPointer; pitch: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LockTexture' {$ENDIF};
3480

3481
  {**
3482
   *  Unlock a texture, uploading the changes to video memory, if needed.
3483
   *
3484
   *   SDL_LockTexture()
3485
   *}
3486
procedure SDL_UnlockTexture(texture: PSDL_Texture) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LockTexture' {$ENDIF};
3487

3488
  {**
3489
   *  Determines whether a window supports the use of render targets
3490
   *
3491
   *  renderer The renderer that will be checked
3492
   *
3493
   *  SDL_TRUE if supported, SDL_FALSE if not.
3494
   *}
3495
function SDL_RenderTargetSupported(renderer: PSDL_Renderer): Boolean cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderTargetSupported' {$ENDIF};
3496

3497
  {**
3498
   *  Set a texture as the current rendering target.
3499
   *
3500
   *  renderer The renderer.
3501
   *  texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
3502
   *
3503
   *  0 on success, or -1 on error
3504
   *
3505
   *   SDL_GetRenderTarget()
3506
   *}
3507
function SDL_SetRenderTarget(renderer: PSDL_Renderer; texture: PSDL_Texture): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetRenderTarget' {$ENDIF};
3508

3509
  {**
3510
   *  Get the current render target or NULL for the default render target.
3511
   *
3512
   *  The current render target
3513
   *
3514
   *   SDL_SetRenderTarget()
3515
   *}
3516
function SDL_GetRenderTarget(renderer: PSDL_Renderer): PSDL_Texture cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRenderTarget' {$ENDIF};
3517

3518
  {**
3519
   *  Set device independent resolution for rendering
3520
   *
3521
   *   renderer The renderer for which resolution should be set.
3522
   *   w      The width of the logical resolution
3523
   *   h      The height of the logical resolution
3524
   *
3525
   *  This function uses the viewport and scaling functionality to allow a fixed logical
3526
   *  resolution for rendering, regardless of the actual output resolution.  If the actual
3527
   *  output resolution doesn't have the same aspect ratio the output rendering will be
3528
   *  centered within the output display.
3529
   *
3530
   *  If the output display is a window, mouse events in the window will be filtered
3531
   *  and scaled so they seem to arrive within the logical resolution.
3532
   *
3533
   *   If this function results in scaling or subpixel drawing by the
3534
   *   rendering backend, it will be handled using the appropriate
3535
   *   quality hints.
3536
   *
3537
   *   SDL_RenderGetLogicalSize()
3538
   *   SDL_RenderSetScale()
3539
   *   SDL_RenderSetViewport()
3540
   *}
3541
function SDL_RenderSetLogicalSize(renderer: PSDL_Renderer; w: SInt32; h: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderSetLogicalSize' {$ENDIF};
3542

3543
  {**
3544
   *  Get device independent resolution for rendering
3545
   *
3546
   *   renderer The renderer from which resolution should be queried.
3547
   *   w      A pointer filled with the width of the logical resolution
3548
   *   h      A pointer filled with the height of the logical resolution
3549
   *
3550
   *   SDL_RenderSetLogicalSize()
3551
   *}
3552
procedure SDL_RenderGetLogicalSize(renderer: PSDL_Renderer; w: PInt; h: PInt) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderGetLogicalSize' {$ENDIF};
3553

3554
  {**
3555
   *  Set the drawing area for rendering on the current target.
3556
   *
3557
   *   renderer The renderer for which the drawing area should be set.
3558
   *   rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
3559
   *
3560
   *  The x,y of the viewport rect represents the origin for rendering.
3561
   *
3562
   *   0 on success, or -1 on error
3563
   *
3564
   *  If the window associated with the renderer is resized, the viewport is automatically reset.
3565
   *
3566
   *   SDL_RenderGetViewport()
3567
   *   SDL_RenderSetLogicalSize()
3568
   *}
3569
function SDL_RenderSetViewport(renderer: PSDL_Renderer; const rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderSetViewport' {$ENDIF};
3570

3571
  {**
3572
   *  Get the drawing area for the current target.
3573
   *
3574
   *   SDL_RenderSetViewport()
3575
   *}
3576
procedure SDL_RenderGetViewport(renderer: PSDL_Renderer; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderGetViewport' {$ENDIF};
3577

3578
  {**
3579
   *  Set the clip rectangle for the current target.
3580
   *
3581
   *   renderer The renderer for which clip rectangle should be set.
3582
   *   rect   A pointer to the rectangle to set as the clip rectangle, or
3583
   *          NULL to disable clipping.
3584
   *
3585
   *   0 on success, or -1 on error
3586
   *
3587
   *   SDL_RenderGetClipRect()
3588
   *}
3589
function SDL_RenderSetClipRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderSetClipRect' {$ENDIF};
3590

3591
  {**
3592
   *  Get the clip rectangle for the current target.
3593
   *
3594
   *   renderer The renderer from which clip rectangle should be queried.
3595
   *   rect   A pointer filled in with the current clip rectangle, or
3596
   *          an empty rectangle if clipping is disabled.
3597
   *
3598
   *   SDL_RenderSetClipRect()
3599
   *}
3600
procedure SDL_RenderGetClipRect(renderer: PSDL_Renderer; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderGetClipRect' {$ENDIF};
3601

3602
  {**
3603
   *  Set the drawing scale for rendering on the current target.
3604
   *
3605
   *   renderer The renderer for which the drawing scale should be set.
3606
   *   scaleX The horizontal scaling factor
3607
   *   scaleY The vertical scaling factor
3608
   *
3609
   *  The drawing coordinates are scaled by the x/y scaling factors
3610
   *  before they are used by the renderer.  This allows resolution
3611
   *  independent drawing with a single coordinate system.
3612
   *
3613
   *  If this results in scaling or subpixel drawing by the
3614
   *  rendering backend, it will be handled using the appropriate
3615
   *  quality hints.  For best results use integer scaling factors.
3616
   *
3617
   *   SDL_RenderGetScale()
3618
   *   SDL_RenderSetLogicalSize()
3619
   *}
3620
function SDL_RenderSetScale(renderer: PSDL_Renderer; scaleX: Float; scaleY: Float): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderSetScale' {$ENDIF};
3621

3622
  {**
3623
   *  Get the drawing scale for the current target.
3624
   *
3625
   *   renderer The renderer from which drawing scale should be queried.
3626
   *   scaleX A pointer filled in with the horizontal scaling factor
3627
   *   scaleY A pointer filled in with the vertical scaling factor
3628
   *
3629
   *   SDL_RenderSetScale()
3630
   *}
3631
procedure SDL_RenderGetScale(renderer: PSDL_Renderer; scaleX: PFloat; scaleY: PFloat) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderGetScale' {$ENDIF};
3632

3633
  {**
3634
   *  Set the color used for drawing operations (Rect, Line and Clear).
3635
   *
3636
   *   renderer The renderer for which drawing color should be set.
3637
   *   r The red value used to draw on the rendering target.
3638
   *   g The green value used to draw on the rendering target.
3639
   *   b The blue value used to draw on the rendering target.
3640
   *   a The alpha value used to draw on the rendering target, usually
3641
   *     SDL_ALPHA_OPAQUE (255).
3642
   *
3643
   *   0 on success, or -1 on error
3644
   *}
3645
function SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r: UInt8; g: UInt8; b: UInt8; a: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetRenderDrawColor' {$ENDIF};
3646

3647
  {**
3648
   *  Get the color used for drawing operations (Rect, Line and Clear).
3649
   *
3650
   *   renderer The renderer from which drawing color should be queried.
3651
   *   r A pointer to the red value used to draw on the rendering target.
3652
   *   g A pointer to the green value used to draw on the rendering target.
3653
   *   b A pointer to the blue value used to draw on the rendering target.
3654
   *   a A pointer to the alpha value used to draw on the rendering target,
3655
   *     usually SDL_ALPHA_OPAQUE (255).
3656
   *
3657
   *   0 on success, or -1 on error
3658
   *}
3659
function SDL_GetRenderDrawColor(renderer: PSDL_Renderer; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRenderDrawColor' {$ENDIF};
3660

3661
  {**
3662
   *  Set the blend mode used for drawing operations (Fill and Line).
3663
   *
3664
   *   renderer The renderer for which blend mode should be set.
3665
   *   blendMode SDL_BlendMode to use for blending.
3666
   *
3667
   *   0 on success, or -1 on error
3668
   *
3669
   *   If the blend mode is not supported, the closest supported mode is
3670
   *        chosen.
3671
   *
3672
   *   SDL_GetRenderDrawBlendMode()
3673
   *}
3674
function SDL_SetRenderDrawBlendMode(renderer: PSDL_Renderer; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetRenderDrawBlendMode' {$ENDIF};
3675

3676
  {**
3677
   *  Get the blend mode used for drawing operations.
3678
   *
3679
   *   renderer The renderer from which blend mode should be queried.
3680
   *   blendMode A pointer filled in with the current blend mode.
3681
   *
3682
   *   0 on success, or -1 on error
3683
   *
3684
   *   SDL_SetRenderDrawBlendMode()
3685
   *}
3686
function SDL_GetRenderDrawBlendMode(renderer: PSDL_Renderer; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRenderDrawBlendMode' {$ENDIF};
3687

3688
  {**
3689
   *  Clear the current rendering target with the drawing color
3690
   *
3691
   *  This function clears the entire rendering target, ignoring the viewport.
3692
   *
3693
   *   0 on success, or -1 on error
3694
   *}
3695
function SDL_RenderClear(renderer: PSDL_Renderer): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderClear' {$ENDIF};
3696

3697
  {**
3698
   *  Draw a point on the current rendering target.
3699
   *
3700
   *   renderer The renderer which should draw a point.
3701
   *   x The x coordinate of the point.
3702
   *   y The y coordinate of the point.
3703
   *
3704
   *   0 on success, or -1 on error
3705
   *}
3706
function SDL_RenderDrawPoint(renderer: PSDL_Renderer; x: SInt32; y: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawPoint' {$ENDIF};
3707

3708
  {**
3709
   *  Draw multiple points on the current rendering target.
3710
   *
3711
   *   renderer The renderer which should draw multiple points.
3712
   *   points The points to draw
3713
   *   count The number of points to draw
3714
   *
3715
   *   0 on success, or -1 on error
3716
   *}
3717
function SDL_RenderDrawPoints(renderer: PSDL_Renderer; points: PSDL_Point; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawPoints' {$ENDIF};
3718

3719
  {**
3720
   *  Draw a line on the current rendering target.
3721
   *
3722
   *   renderer The renderer which should draw a line.
3723
   *   x1 The x coordinate of the start point.
3724
   *   y1 The y coordinate of the start point.
3725
   *   x2 The x coordinate of the end point.
3726
   *   y2 The y coordinate of the end point.
3727
   *
3728
   *   0 on success, or -1 on error
3729
   *}
3730
function SDL_RenderDrawLine(renderer: PSDL_Renderer; x1: SInt32; y1: SInt32; x2: SInt32; y2: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawLine' {$ENDIF};
3731

3732
  {**
3733
   *  \brief Draw a series of connected lines on the current rendering target.
3734
   *
3735
   *  \param renderer The renderer which should draw multiple lines.
3736
   *  \param points The points along the lines
3737
   *  \param count The number of points, drawing count-1 lines
3738
   *
3739
   *  \return 0 on success, or -1 on error
3740
   *}
3741
function SDL_RenderDrawLines(renderer: PSDL_Renderer; points: PSDL_Point; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawLines' {$ENDIF};
3742

3743
  {**
3744
   *  Draw a rectangle on the current rendering target.
3745
   *
3746
   *   renderer The renderer which should draw a rectangle.
3747
   *   rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
3748
   *
3749
   *   0 on success, or -1 on error
3750
   *}
3751
function SDL_RenderDrawRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawRect' {$ENDIF};
3752

3753
  {**
3754
   *  Draw some number of rectangles on the current rendering target.
3755
   *
3756
   *   renderer The renderer which should draw multiple rectangles.
3757
   *   rects A pointer to an array of destination rectangles.
3758
   *   count The number of rectangles.
3759
   *
3760
   *   0 on success, or -1 on error
3761
   *}
3762
function SDL_RenderDrawRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderDrawRects' {$ENDIF};
3763

3764
  {**
3765
   *  Fill a rectangle on the current rendering target with the drawing color.
3766
   *
3767
   *   renderer The renderer which should fill a rectangle.
3768
   *   rect A pointer to the destination rectangle, or NULL for the entire
3769
   *        rendering target.
3770
   *
3771
   *   0 on success, or -1 on error
3772
   *}
3773
function SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderFillRect' {$ENDIF};
3774

3775
  {**
3776
   *  Fill some number of rectangles on the current rendering target with the drawing color.
3777
   *
3778
   *   renderer The renderer which should fill multiple rectangles.
3779
   *   rects A pointer to an array of destination rectangles.
3780
   *   count The number of rectangles.
3781
   *
3782
   *   0 on success, or -1 on error
3783
   *}
3784
function SDL_RenderFillRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderFillRects' {$ENDIF};
3785

3786
  {**
3787
   *  Copy a portion of the texture to the current rendering target.
3788
   *
3789
   *   renderer The renderer which should copy parts of a texture.
3790
   *   texture The source texture.
3791
   *   srcrect   A pointer to the source rectangle, or NULL for the entire
3792
   *             texture.
3793
   *   dstrect   A pointer to the destination rectangle, or NULL for the
3794
   *             entire rendering target.
3795
   *
3796
   *   0 on success, or -1 on error
3797
   *}
3798
function SDL_RenderCopy(renderer: PSDL_Renderer; texture: PSDL_Texture; srcrect: PSDL_Rect; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderCopy' {$ENDIF};
3799

3800
  {**
3801
   *  Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
3802
   *
3803
   *   renderer The renderer which should copy parts of a texture.
3804
   *   texture The source texture.
3805
   *   srcrect   A pointer to the source rectangle, or NULL for the entire
3806
   *                   texture.
3807
   *   dstrect   A pointer to the destination rectangle, or NULL for the
3808
   *                   entire rendering target.
3809
   *   angle    An angle in degrees that indicates the rotation that will be applied to dstrect
3810
   *   center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
3811
   *   flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
3812
   *
3813
   *   0 on success, or -1 on error
3814
   *}
3815
function SDL_RenderCopyEx(renderer: PSDL_Renderer; texture: PSDL_Texture; const srcrect: PSDL_Rect; dstrect: PSDL_Rect; angle: Double; center: PSDL_Point; flip: PSDL_RendererFlip): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderCopyEx' {$ENDIF};
3816

3817
  {**
3818
   *  Read pixels from the current rendering target.
3819
   *
3820
   *   renderer The renderer from which pixels should be read.
3821
   *   rect   A pointer to the rectangle to read, or NULL for the entire
3822
   *                render target.
3823
   *   format The desired format of the pixel data, or 0 to use the format
3824
   *                of the rendering target
3825
   *   pixels A pointer to be filled in with the pixel data
3826
   *   pitch  The pitch of the pixels parameter.
3827
   *
3828
   *   0 on success, or -1 if pixel reading is not supported.
3829
   *
3830
   *   This is a very slow operation, and should not be used frequently.
3831
   *}
3832
function SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: UInt32; pixels: Pointer; pitch: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderReadPixels' {$ENDIF};
3833

3834
  {**
3835
   *  Update the screen with rendering performed.
3836
   *}
3837
procedure SDL_RenderPresent(renderer: PSDL_Renderer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RenderPresent' {$ENDIF};
3838

3839
  {**
3840
   *  Destroy the specified texture.
3841
   *
3842
   *   SDL_CreateTexture()
3843
   *   SDL_CreateTextureFromSurface()
3844
   *}
3845
procedure SDL_DestroyTexture(texture: PSDL_Texture) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroyTexture' {$ENDIF};
3846

3847
  {**
3848
   *  Destroy the rendering context for a window and free associated
3849
   *  textures.
3850
   *
3851
   *   SDL_CreateRenderer()
3852
   *}
3853
procedure SDL_DestroyRenderer(renderer: PSDL_Renderer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DestroyRenderer' {$ENDIF};
3854

3855
  {**
3856
   *  Bind the texture to the current OpenGL/ES/ES2 context for use with
3857
   *  OpenGL instructions.
3858
   *
3859
   *   texture  The SDL texture to bind
3860
   *   texw     A pointer to a float that will be filled with the texture width
3861
   *   texh     A pointer to a float that will be filled with the texture height
3862
   *
3863
   *   0 on success, or -1 if the operation is not supported
3864
   *}
3865
function SDL_GL_BindTexture(texture: PSDL_Texture; texw: PFloat; texh: PFloat): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_BindTexture' {$ENDIF};
3866

3867
  {**
3868
   *  Unbind a texture from the current OpenGL/ES/ES2 context.
3869
   *
3870
   *   texture  The SDL texture to unbind
3871
   *
3872
   *   0 on success, or -1 if the operation is not supported
3873
   *}
3874
function SDL_GL_UnbindTexture(texture: PSDL_Texture): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GL_UnbindTexture' {$ENDIF};
3875

3876

3877

3878
////////////////////////////////////////////////////////////////////////////////////////////////////////  
3879
//////////////////////        SDL_scancode.h        ////////////////////////////////////////////////////
3880
////////////////////////////////////////////////////////////////////////////////////////////////////////  
3881

3882
  {**
3883
   *  The SDL keyboard scancode representation.
3884
   *
3885
   *  Values of this type are used to represent keyboard keys, among other places
3886
   *  in the SDL_Keysym.scancode key.keysym.scancode \endlink field of the
3887
   *  SDL_Event structure.
3888
   *
3889
   *  The values in this enumeration are based on the USB usage page standard:
3890
   *  http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
3891
   *}
3892

3893
const
3894
  SDL_SCANCODE_UNKNOWN = 0;
3895

3896
  {**
3897
   *  Usage page $07
3898
   *
3899
   *  These values are from usage page $07 (USB keyboard page).
3900
   *}
3901

3902
  SDL_SCANCODE_A = 4;
3903
  SDL_SCANCODE_B = 5;
3904
  SDL_SCANCODE_C = 6;
3905
  SDL_SCANCODE_D = 7;
3906
  SDL_SCANCODE_E = 8;
3907
  SDL_SCANCODE_F = 9;
3908
  SDL_SCANCODE_G = 10;
3909
  SDL_SCANCODE_H = 11;
3910
  SDL_SCANCODE_I = 12;
3911
  SDL_SCANCODE_J = 13;
3912
  SDL_SCANCODE_K = 14;
3913
  SDL_SCANCODE_L = 15;
3914
  SDL_SCANCODE_M = 16;
3915
  SDL_SCANCODE_N = 17;
3916
  SDL_SCANCODE_O = 18;
3917
  SDL_SCANCODE_P = 19;
3918
  SDL_SCANCODE_Q = 20;
3919
  SDL_SCANCODE_R = 21;
3920
  SDL_SCANCODE_S = 22;
3921
  SDL_SCANCODE_T = 23;
3922
  SDL_SCANCODE_U = 24;
3923
  SDL_SCANCODE_V = 25;
3924
  SDL_SCANCODE_W = 26;
3925
  SDL_SCANCODE_X = 27;
3926
  SDL_SCANCODE_Y = 28;
3927
  SDL_SCANCODE_Z = 29;
3928

3929
  SDL_SCANCODE_1 = 30;
3930
  SDL_SCANCODE_2 = 31;
3931
  SDL_SCANCODE_3 = 32;
3932
  SDL_SCANCODE_4 = 33;
3933
  SDL_SCANCODE_5 = 34;
3934
  SDL_SCANCODE_6 = 35;
3935
  SDL_SCANCODE_7 = 36;
3936
  SDL_SCANCODE_8 = 37;
3937
  SDL_SCANCODE_9 = 38;
3938
  SDL_SCANCODE_0 = 39;
3939

3940
  SDL_SCANCODE_RETURN = 40;
3941
  SDL_SCANCODE_ESCAPE = 41;
3942
  SDL_SCANCODE_BACKSPACE = 42;
3943
  SDL_SCANCODE_TAB = 43;
3944
  SDL_SCANCODE_SPACE = 44;
3945

3946
  SDL_SCANCODE_MINUS = 45;
3947
  SDL_SCANCODE_EQUALS = 46;
3948
  SDL_SCANCODE_LEFTBRACKET = 47;
3949
  SDL_SCANCODE_RIGHTBRACKET = 48;
3950
  SDL_SCANCODE_BACKSLASH = 49; {**< Located at the lower left of the return
3951
                                *   key on ISO keyboards and at the right end
3952
                                *   of the QWERTY row on ANSI keyboards.
3953
                                *   Produces REVERSE SOLIDUS (backslash) and
3954
                                *   VERTICAL LINE in a US layout; REVERSE 
3955
                                *   SOLIDUS and VERTICAL LINE in a UK Mac
3956
                                *   layout; NUMBER SIGN and TILDE in a UK 
3957
                                *   Windows layout; DOLLAR SIGN and POUND SIGN
3958
                                *   in a Swiss German layout; NUMBER SIGN and
3959
                                *   APOSTROPHE in a German layout; GRAVE
3960
                                *   ACCENT and POUND SIGN in a French Mac 
3961
                                *   layout; and ASTERISK and MICRO SIGN in a
3962
                                *   French Windows layout.
3963
                                *}
3964
  SDL_SCANCODE_NONUSHASH = 50; {**< ISO USB keyboards actually use this code
3965
                                *   instead of 49 for the same key; but all
3966
                                *   OSes I've seen treat the two codes 
3967
                                *   identically. So; as an implementor; unless
3968
                                *   your keyboard generates both of those 
3969
                                *   codes and your OS treats them differently;
3970
                                *   you should generate SDL_SCANCODE_BACKSLASH
3971
                                *   instead of this code. As a user; you
3972
                                *   should not rely on this code because SDL
3973
                                *   will never generate it with most (all?)
3974
                                *   keyboards.
3975
                                *}
3976
  SDL_SCANCODE_SEMICOLON = 51;
3977
  SDL_SCANCODE_APOSTROPHE = 52;
3978
  SDL_SCANCODE_GRAVE = 53;     {**< Located in the top left corner (on both ANSI
3979
                                *   and ISO keyboards). Produces GRAVE ACCENT and
3980
                                *   TILDE in a US Windows layout and in US and UK
3981
                                *   Mac layouts on ANSI keyboards; GRAVE ACCENT
3982
                                *   and NOT SIGN in a UK Windows layout; SECTION
3983
                                *   SIGN and PLUS-MINUS SIGN in US and UK Mac
3984
                                *   layouts on ISO keyboards; SECTION SIGN and
3985
                                *   DEGREE SIGN in a Swiss German layout (Mac:
3986
                                *   only on ISO keyboards); CIRCUMFLEX ACCENT and
3987
                                *   DEGREE SIGN in a German layout (Mac: only on
3988
                                *   ISO keyboards); SUPERSCRIPT TWO and TILDE in a
3989
                                *   French Windows layout; COMMERCIAL AT and
3990
                                *   NUMBER SIGN in a French Mac layout on ISO
3991
                                *   keyboards; and LESS-THAN SIGN and GREATER-THAN
3992
                                *   SIGN in a Swiss German; German; or French Mac
3993
                                *   layout on ANSI keyboards.
3994
                                *}
3995
  SDL_SCANCODE_COMMA = 54;
3996
  SDL_SCANCODE_PERIOD = 55;
3997
  SDL_SCANCODE_SLASH = 56;
3998

3999
  SDL_SCANCODE_CAPSLOCK = 57;
4000

4001
  SDL_SCANCODE_F1 = 58;
4002
  SDL_SCANCODE_F2 = 59;
4003
  SDL_SCANCODE_F3 = 60;
4004
  SDL_SCANCODE_F4 = 61;
4005
  SDL_SCANCODE_F5 = 62;
4006
  SDL_SCANCODE_F6 = 63;
4007
  SDL_SCANCODE_F7 = 64;
4008
  SDL_SCANCODE_F8 = 65;
4009
  SDL_SCANCODE_F9 = 66;
4010
  SDL_SCANCODE_F10 = 67;
4011
  SDL_SCANCODE_F11 = 68;
4012
  SDL_SCANCODE_F12 = 69;
4013

4014
  SDL_SCANCODE_PRINTSCREEN = 70;
4015
  SDL_SCANCODE_SCROLLLOCK = 71;
4016
  SDL_SCANCODE_PAUSE = 72;
4017
  SDL_SCANCODE_INSERT = 73; {**< insert on PC; help on some Mac keyboards (but
4018
                                 does send code 73; not 117) *}
4019
  SDL_SCANCODE_HOME = 74;
4020
  SDL_SCANCODE_PAGEUP = 75;
4021
  SDL_SCANCODE_DELETE = 76;
4022
  SDL_SCANCODE_END = 77;
4023
  SDL_SCANCODE_PAGEDOWN = 78;
4024
  SDL_SCANCODE_RIGHT = 79;
4025
  SDL_SCANCODE_LEFT = 80;
4026
  SDL_SCANCODE_DOWN = 81;
4027
  SDL_SCANCODE_UP = 82;
4028

4029
  SDL_SCANCODE_NUMLOCKCLEAR = 83; {**< num lock on PC; clear on Mac keyboards
4030
                                   *}
4031
  SDL_SCANCODE_KP_DIVIDE = 84;
4032
  SDL_SCANCODE_KP_MULTIPLY = 85;
4033
  SDL_SCANCODE_KP_MINUS = 86;
4034
  SDL_SCANCODE_KP_PLUS = 87;
4035
  SDL_SCANCODE_KP_ENTER = 88;
4036
  SDL_SCANCODE_KP_1 = 89;
4037
  SDL_SCANCODE_KP_2 = 90;
4038
  SDL_SCANCODE_KP_3 = 91;
4039
  SDL_SCANCODE_KP_4 = 92;
4040
  SDL_SCANCODE_KP_5 = 93;
4041
  SDL_SCANCODE_KP_6 = 94;
4042
  SDL_SCANCODE_KP_7 = 95;
4043
  SDL_SCANCODE_KP_8 = 96;
4044
  SDL_SCANCODE_KP_9 = 97;
4045
  SDL_SCANCODE_KP_0 = 98;
4046
  SDL_SCANCODE_KP_PERIOD = 99;
4047

4048
  SDL_SCANCODE_NONUSBACKSLASH = 100; {**< This is the additional key that ISO
4049
                                      *   keyboards have over ANSI ones; 
4050
                                      *   located between left shift and Y. 
4051
                                      *   Produces GRAVE ACCENT and TILDE in a
4052
                                      *   US or UK Mac layout; REVERSE SOLIDUS
4053
                                      *   (backslash) and VERTICAL LINE in a 
4054
                                      *   US or UK Windows layout; and 
4055
                                      *   LESS-THAN SIGN and GREATER-THAN SIGN
4056
                                      *   in a Swiss German; German; or French
4057
                                      *   layout. *}
4058
  SDL_SCANCODE_APPLICATION = 101;    {**< windows contextual menu; compose *}
4059
  SDL_SCANCODE_POWER = 102;          {**< The USB document says this is a status flag;
4060
                                       *  not a physical key - but some Mac keyboards
4061
                                       *  do have a power key. *}
4062
  SDL_SCANCODE_KP_EQUALS = 103;
4063
  SDL_SCANCODE_F13 = 104;
4064
  SDL_SCANCODE_F14 = 105;
4065
  SDL_SCANCODE_F15 = 106;
4066
  SDL_SCANCODE_F16 = 107;
4067
  SDL_SCANCODE_F17 = 108;
4068
  SDL_SCANCODE_F18 = 109;
4069
  SDL_SCANCODE_F19 = 110;
4070
  SDL_SCANCODE_F20 = 111;
4071
  SDL_SCANCODE_F21 = 112;
4072
  SDL_SCANCODE_F22 = 113;
4073
  SDL_SCANCODE_F23 = 114;
4074
  SDL_SCANCODE_F24 = 115;
4075
  SDL_SCANCODE_EXECUTE = 116;
4076
  SDL_SCANCODE_HELP = 117;
4077
  SDL_SCANCODE_MENU = 118;
4078
  SDL_SCANCODE_SELECT = 119;
4079
  SDL_SCANCODE_STOP = 120;
4080
  SDL_SCANCODE_AGAIN = 121;   {**< redo *}
4081
  SDL_SCANCODE_UNDO = 122;
4082
  SDL_SCANCODE_CUT = 123;
4083
  SDL_SCANCODE_COPY = 124;
4084
  SDL_SCANCODE_PASTE = 125;
4085
  SDL_SCANCODE_FIND = 126;
4086
  SDL_SCANCODE_MUTE = 127;
4087
  SDL_SCANCODE_VOLUMEUP = 128;
4088
  SDL_SCANCODE_VOLUMEDOWN = 129;
4089
  {* not sure whether there's a reason to enable these *}
4090
  {*     SDL_SCANCODE_LOCKINGCAPSLOCK = 130;  *}
4091
  {*     SDL_SCANCODE_LOCKINGNUMLOCK = 131; *}
4092
  {*     SDL_SCANCODE_LOCKINGSCROLLLOCK = 132; *}
4093
  SDL_SCANCODE_KP_COMMA = 133;
4094
  SDL_SCANCODE_KP_EQUALSAS400 = 134;
4095

4096
  SDL_SCANCODE_INTERNATIONAL1 = 135; {**< used on Asian keyboards; see footnotes in USB doc *}
4097
  SDL_SCANCODE_INTERNATIONAL2 = 136;
4098
  SDL_SCANCODE_INTERNATIONAL3 = 137; {**< Yen *}
4099
  SDL_SCANCODE_INTERNATIONAL4 = 138;
4100
  SDL_SCANCODE_INTERNATIONAL5 = 139;
4101
  SDL_SCANCODE_INTERNATIONAL6 = 140;
4102
  SDL_SCANCODE_INTERNATIONAL7 = 141;
4103
  SDL_SCANCODE_INTERNATIONAL8 = 142;
4104
  SDL_SCANCODE_INTERNATIONAL9 = 143;
4105
  SDL_SCANCODE_LANG1 = 144; {**< Hangul{English toggle *}
4106
  SDL_SCANCODE_LANG2 = 145; {**< Hanja conversion *}
4107
  SDL_SCANCODE_LANG3 = 146; {**< Katakana *}
4108
  SDL_SCANCODE_LANG4 = 147; {**< Hiragana *}
4109
  SDL_SCANCODE_LANG5 = 148; {**< Zenkaku{Hankaku *}
4110
  SDL_SCANCODE_LANG6 = 149; {**< reserved *}
4111
  SDL_SCANCODE_LANG7 = 150; {**< reserved *}
4112
  SDL_SCANCODE_LANG8 = 151; {**< reserved *}
4113
  SDL_SCANCODE_LANG9 = 152; {**< reserved *}
4114

4115
  SDL_SCANCODE_ALTERASE = 153; {**< Erase-Eaze *}
4116
  SDL_SCANCODE_SYSREQ = 154;
4117
  SDL_SCANCODE_CANCEL = 155;
4118
  SDL_SCANCODE_CLEAR = 156;
4119
  SDL_SCANCODE_PRIOR = 157;
4120
  SDL_SCANCODE_RETURN2 = 158;
4121
  SDL_SCANCODE_SEPARATOR = 159;
4122
  SDL_SCANCODE_OUT = 160;
4123
  SDL_SCANCODE_OPER = 161;
4124
  SDL_SCANCODE_CLEARAGAIN = 162;
4125
  SDL_SCANCODE_CRSEL = 163;
4126
  SDL_SCANCODE_EXSEL = 164;
4127

4128
  SDL_SCANCODE_KP_00 = 176;
4129
  SDL_SCANCODE_KP_000 = 177;
4130
  SDL_SCANCODE_THOUSANDSSEPARATOR = 178;
4131
  SDL_SCANCODE_DECIMALSEPARATOR = 179;
4132
  SDL_SCANCODE_CURRENCYUNIT = 180;
4133
  SDL_SCANCODE_CURRENCYSUBUNIT = 181;
4134
  SDL_SCANCODE_KP_LEFTPAREN = 182;
4135
  SDL_SCANCODE_KP_RIGHTPAREN = 183;
4136
  SDL_SCANCODE_KP_LEFTBRACE = 184;
4137
  SDL_SCANCODE_KP_RIGHTBRACE = 185;
4138
  SDL_SCANCODE_KP_TAB = 186;
4139
  SDL_SCANCODE_KP_BACKSPACE = 187;
4140
  SDL_SCANCODE_KP_A = 188;
4141
  SDL_SCANCODE_KP_B = 189;
4142
  SDL_SCANCODE_KP_C = 190;
4143
  SDL_SCANCODE_KP_D = 191;
4144
  SDL_SCANCODE_KP_E = 192;
4145
  SDL_SCANCODE_KP_F = 193;
4146
  SDL_SCANCODE_KP_XOR = 194;
4147
  SDL_SCANCODE_KP_POWER = 195;
4148
  SDL_SCANCODE_KP_PERCENT = 196;
4149
  SDL_SCANCODE_KP_LESS = 197;
4150
  SDL_SCANCODE_KP_GREATER = 198;
4151
  SDL_SCANCODE_KP_AMPERSAND = 199;
4152
  SDL_SCANCODE_KP_DBLAMPERSAND = 200;
4153
  SDL_SCANCODE_KP_VERTICALBAR = 201;
4154
  SDL_SCANCODE_KP_DBLVERTICALBAR = 202;
4155
  SDL_SCANCODE_KP_COLON = 203;
4156
  SDL_SCANCODE_KP_HASH = 204;
4157
  SDL_SCANCODE_KP_SPACE = 205;
4158
  SDL_SCANCODE_KP_AT = 206;
4159
  SDL_SCANCODE_KP_EXCLAM = 207;
4160
  SDL_SCANCODE_KP_MEMSTORE = 208;
4161
  SDL_SCANCODE_KP_MEMRECALL = 209;
4162
  SDL_SCANCODE_KP_MEMCLEAR = 210;
4163
  SDL_SCANCODE_KP_MEMADD = 211;
4164
  SDL_SCANCODE_KP_MEMSUBTRACT = 212;
4165
  SDL_SCANCODE_KP_MEMMULTIPLY = 213;
4166
  SDL_SCANCODE_KP_MEMDIVIDE = 214;
4167
  SDL_SCANCODE_KP_PLUSMINUS = 215;
4168
  SDL_SCANCODE_KP_CLEAR = 216;
4169
  SDL_SCANCODE_KP_CLEARENTRY = 217;
4170
  SDL_SCANCODE_KP_BINARY = 218;
4171
  SDL_SCANCODE_KP_OCTAL = 219;
4172
  SDL_SCANCODE_KP_DECIMAL = 220;
4173
  SDL_SCANCODE_KP_HEXADECIMAL = 221;
4174

4175
  SDL_SCANCODE_LCTRL = 224;
4176
  SDL_SCANCODE_LSHIFT = 225;
4177
  SDL_SCANCODE_LALT = 226; {**< alt; option *}
4178
  SDL_SCANCODE_LGUI = 227; {**< windows; command (apple); meta *}
4179
  SDL_SCANCODE_RCTRL = 228;
4180
  SDL_SCANCODE_RSHIFT = 229;
4181
  SDL_SCANCODE_RALT = 230; {**< alt gr; option *}
4182
  SDL_SCANCODE_RGUI = 231; {**< windows; command (apple); meta *}
4183

4184
  SDL_SCANCODE_MODE = 257;    {**< I'm not sure if this is really not covered 
4185
                               *   by any of the above; but since there's a 
4186
                               *   special KMOD_MODE for it I'm adding it here
4187
                               *}
4188
    
4189
  {*Usage page $07*}
4190

4191
  {**
4192
   *  Usage page $0C
4193
   *
4194
   *  These values are mapped from usage page $0C (USB consumer page).
4195
   *}
4196

4197
  SDL_SCANCODE_AUDIONEXT = 258;
4198
  SDL_SCANCODE_AUDIOPREV = 259;
4199
  SDL_SCANCODE_AUDIOSTOP = 260;
4200
  SDL_SCANCODE_AUDIOPLAY = 261;
4201
  SDL_SCANCODE_AUDIOMUTE = 262;
4202
  SDL_SCANCODE_MEDIASELECT = 263;
4203
  SDL_SCANCODE_WWW = 264;
4204
  SDL_SCANCODE_MAIL = 265;
4205
  SDL_SCANCODE_CALCULATOR = 266;
4206
  SDL_SCANCODE_COMPUTER = 267;
4207
  SDL_SCANCODE_AC_SEARCH = 268;
4208
  SDL_SCANCODE_AC_HOME = 269;
4209
  SDL_SCANCODE_AC_BACK = 270;
4210
  SDL_SCANCODE_AC_FORWARD = 271;
4211
  SDL_SCANCODE_AC_STOP = 272;
4212
  SDL_SCANCODE_AC_REFRESH = 273;
4213
  SDL_SCANCODE_AC_BOOKMARKS = 274;
4214

4215
  {*Usage page $0C*}
4216

4217
  {**
4218
   *  Walther keys
4219
   *
4220
   *  These are values that Christian Walther added (for mac keyboard?).
4221
   *}
4222

4223
  SDL_SCANCODE_BRIGHTNESSDOWN = 275;
4224
  SDL_SCANCODE_BRIGHTNESSUP = 276;
4225
  SDL_SCANCODE_DISPLAYSWITCH = 277; {**< display mirroring{dual display
4226
                                         switch; video mode switch *}
4227
  SDL_SCANCODE_KBDILLUMTOGGLE = 278;
4228
  SDL_SCANCODE_KBDILLUMDOWN = 279;
4229
  SDL_SCANCODE_KBDILLUMUP = 280;
4230
  SDL_SCANCODE_EJECT = 281;
4231
  SDL_SCANCODE_SLEEP = 282;
4232

4233
	SDL_SCANCODE_APP1 = 283;
4234
	SDL_SCANCODE_APP2 = 284;
4235

4236
  {*Walther keys*}
4237

4238
  {* Add any other keys here. *}
4239

4240
  SDL_NUM_SCANCODES = 512; {**< not a key, just marks the number of scancodes
4241
                               for array bounds *}
4242

4243
type
4244
  PSDL_ScanCode = ^TSDL_ScanCode;
4245
  TSDL_ScanCode = DWord;
4246

4247
  //from "sdl_keycode.h"
4248

4249

4250
  {**
4251
   *  The SDL virtual key representation.
4252
   *
4253
   *  Values of this type are used to represent keyboard keys using the current
4254
   *  layout of the keyboard.  These values include Unicode values representing
4255
   *  the unmodified character that would be generated by pressing the key, or
4256
   *  an SDLK_* constant for those keys that do not generate characters.
4257
   *}
4258
  PSDL_KeyCode = ^TSDL_KeyCode;
4259
  TSDL_KeyCode = SInt32;
4260

4261
const
4262
  SDLK_SCANCODE_MASK = 1 shl 30;
4263

4264
  SDLK_UNKNOWN = 0;
4265

4266
  SDLK_RETURN = '\r';
4267
  SDLK_ESCAPE = '\033';
4268
  SDLK_BACKSPACE = '\b';
4269
  SDLK_TAB = '\t';
4270
  SDLK_SPACE = ' ';
4271
  SDLK_EXCLAIM = '!';
4272
  SDLK_QUOTEDBL = '"';
4273
  SDLK_HASH = '#';
4274
  SDLK_PERCENT = '%';
4275
  SDLK_DOLLAR = '$';
4276
  SDLK_AMPERSAND = '&';
4277
  SDLK_QUOTE = '\';
4278
  SDLK_LEFTPAREN = '(';
4279
  SDLK_RIGHTPAREN = ')';
4280
  SDLK_ASTERISK = '*';
4281
  SDLK_PLUS = '+';
4282
  SDLK_COMMA = ';';
4283
  SDLK_MINUS = '-';
4284
  SDLK_PERIOD = '.';
4285
  SDLK_SLASH = '/';
4286
  SDLK_0 = '0';
4287
  SDLK_1 = '1';
4288
  SDLK_2 = '2';
4289
  SDLK_3 = '3';
4290
  SDLK_4 = '4';
4291
  SDLK_5 = '5';
4292
  SDLK_6 = '6';
4293
  SDLK_7 = '7';
4294
  SDLK_8 = '8';
4295
  SDLK_9 = '9';
4296
  SDLK_COLON = ':';
4297
  SDLK_SEMICOLON = ';';
4298
  SDLK_LESS = '<';
4299
  SDLK_EQUALS = '=';
4300
  SDLK_GREATER = '>';
4301
  SDLK_QUESTION = '?';
4302
  SDLK_AT = '@';
4303
  {*
4304
     Skip uppercase letters
4305
   *}
4306
  SDLK_LEFTBRACKET = '[';
4307
  SDLK_BACKSLASH = '\\';
4308
  SDLK_RIGHTBRACKET = ']';
4309
  SDLK_CARET = '^';
4310
  SDLK_UNDERSCORE = '_';
4311
  SDLK_BACKQUOTE = '`';
4312
  SDLK_a = 'a';
4313
  SDLK_b = 'b';
4314
  SDLK_c = 'c';
4315
  SDLK_d = 'd';
4316
  SDLK_e = 'e';
4317
  SDLK_f = 'f';
4318
  SDLK_g = 'g';
4319
  SDLK_h = 'h';
4320
  SDLK_i = 'i';
4321
  SDLK_j = 'j';
4322
  SDLK_k = 'k';
4323
  SDLK_l = 'l';
4324
  SDLK_m = 'm';
4325
  SDLK_n = 'n';
4326
  SDLK_o = 'o';
4327
  SDLK_p = 'p';
4328
  SDLK_q = 'q';
4329
  SDLK_r = 'r';
4330
  SDLK_s = 's';
4331
  SDLK_t = 't';
4332
  SDLK_u = 'u';
4333
  SDLK_v = 'v';
4334
  SDLK_w = 'w';
4335
  SDLK_x = 'x';
4336
  SDLK_y = 'y';
4337
  SDLK_z = 'z';
4338

4339
  SDLK_CAPSLOCK = SDL_SCANCODE_CAPSLOCK or SDLK_SCANCODE_MASK;
4340

4341
  SDLK_F1 = SDL_SCANCODE_F1 or SDLK_SCANCODE_MASK;
4342
  SDLK_F2 = SDL_SCANCODE_F2 or SDLK_SCANCODE_MASK;
4343
  SDLK_F3 = SDL_SCANCODE_F3 or SDLK_SCANCODE_MASK;
4344
  SDLK_F4 = SDL_SCANCODE_F4 or SDLK_SCANCODE_MASK;
4345
  SDLK_F5 = SDL_SCANCODE_F5 or SDLK_SCANCODE_MASK;
4346
  SDLK_F6 = SDL_SCANCODE_F6 or SDLK_SCANCODE_MASK;
4347
  SDLK_F7 = SDL_SCANCODE_F7 or SDLK_SCANCODE_MASK;
4348
  SDLK_F8 = SDL_SCANCODE_F8 or SDLK_SCANCODE_MASK;
4349
  SDLK_F9 = SDL_SCANCODE_F9 or SDLK_SCANCODE_MASK;
4350
  SDLK_F10 = SDL_SCANCODE_F10 or SDLK_SCANCODE_MASK;
4351
  SDLK_F11 = SDL_SCANCODE_F11 or SDLK_SCANCODE_MASK;
4352
  SDLK_F12 = SDL_SCANCODE_F12 or SDLK_SCANCODE_MASK;
4353

4354
  SDLK_PRINTSCREEN = SDL_SCANCODE_PRINTSCREEN or SDLK_SCANCODE_MASK;
4355
  SDLK_SCROLLLOCK = SDL_SCANCODE_SCROLLLOCK or SDLK_SCANCODE_MASK;
4356
  SDLK_PAUSE = SDL_SCANCODE_PAUSE or SDLK_SCANCODE_MASK;
4357
  SDLK_INSERT = SDL_SCANCODE_INSERT or SDLK_SCANCODE_MASK;
4358
  SDLK_HOME = SDL_SCANCODE_HOME or SDLK_SCANCODE_MASK;
4359
  SDLK_PAGEUP = SDL_SCANCODE_PAGEUP or SDLK_SCANCODE_MASK;
4360
  SDLK_DELETE = '\177';
4361
  SDLK_END = SDL_SCANCODE_END or SDLK_SCANCODE_MASK;
4362
  SDLK_PAGEDOWN = SDL_SCANCODE_PAGEDOWN or SDLK_SCANCODE_MASK;
4363
  SDLK_RIGHT = SDL_SCANCODE_RIGHT or SDLK_SCANCODE_MASK;
4364
  SDLK_LEFT = SDL_SCANCODE_LEFT or SDLK_SCANCODE_MASK;
4365
  SDLK_DOWN = SDL_SCANCODE_DOWN or SDLK_SCANCODE_MASK;
4366
  SDLK_UP = SDL_SCANCODE_UP or SDLK_SCANCODE_MASK;
4367

4368
  SDLK_NUMLOCKCLEAR = SDL_SCANCODE_NUMLOCKCLEAR or SDLK_SCANCODE_MASK;
4369
  SDLK_KP_DIVIDE = SDL_SCANCODE_KP_DIVIDE or SDLK_SCANCODE_MASK;
4370
  SDLK_KP_MULTIPLY = SDL_SCANCODE_KP_MULTIPLY or SDLK_SCANCODE_MASK;
4371
  SDLK_KP_MINUS = SDL_SCANCODE_KP_MINUS or SDLK_SCANCODE_MASK;
4372
  SDLK_KP_PLUS = SDL_SCANCODE_KP_PLUS or SDLK_SCANCODE_MASK;
4373
  SDLK_KP_ENTER = SDL_SCANCODE_KP_ENTER or SDLK_SCANCODE_MASK;
4374
  SDLK_KP_1 = SDL_SCANCODE_KP_1 or SDLK_SCANCODE_MASK;
4375
  SDLK_KP_2 = SDL_SCANCODE_KP_2 or SDLK_SCANCODE_MASK;
4376
  SDLK_KP_3 = SDL_SCANCODE_KP_3 or SDLK_SCANCODE_MASK;
4377
  SDLK_KP_4 = SDL_SCANCODE_KP_4 or SDLK_SCANCODE_MASK;
4378
  SDLK_KP_5 = SDL_SCANCODE_KP_5 or SDLK_SCANCODE_MASK;
4379
  SDLK_KP_6 = SDL_SCANCODE_KP_6 or SDLK_SCANCODE_MASK;
4380
  SDLK_KP_7 = SDL_SCANCODE_KP_7 or SDLK_SCANCODE_MASK;
4381
  SDLK_KP_8 = SDL_SCANCODE_KP_8 or SDLK_SCANCODE_MASK;
4382
  SDLK_KP_9 = SDL_SCANCODE_KP_9 or SDLK_SCANCODE_MASK;
4383
  SDLK_KP_0 = SDL_SCANCODE_KP_0 or SDLK_SCANCODE_MASK;
4384
  SDLK_KP_PERIOD = SDL_SCANCODE_KP_PERIOD or SDLK_SCANCODE_MASK;
4385

4386
  SDLK_APPLICATION = SDL_SCANCODE_APPLICATION or SDLK_SCANCODE_MASK;
4387
  SDLK_POWER = SDL_SCANCODE_POWER or SDLK_SCANCODE_MASK;
4388
  SDLK_KP_EQUALS = SDL_SCANCODE_KP_EQUALS or SDLK_SCANCODE_MASK;
4389
  SDLK_F13 = SDL_SCANCODE_F13 or SDLK_SCANCODE_MASK;
4390
  SDLK_F14 = SDL_SCANCODE_F14 or SDLK_SCANCODE_MASK;
4391
  SDLK_F15 = SDL_SCANCODE_F15 or SDLK_SCANCODE_MASK;
4392
  SDLK_F16 = SDL_SCANCODE_F16 or SDLK_SCANCODE_MASK;
4393
  SDLK_F17 = SDL_SCANCODE_F17 or SDLK_SCANCODE_MASK;
4394
  SDLK_F18 = SDL_SCANCODE_F18 or SDLK_SCANCODE_MASK;
4395
  SDLK_F19 = SDL_SCANCODE_F19 or SDLK_SCANCODE_MASK;
4396
  SDLK_F20 = SDL_SCANCODE_F20 or SDLK_SCANCODE_MASK;
4397
  SDLK_F21 = SDL_SCANCODE_F21 or SDLK_SCANCODE_MASK;
4398
  SDLK_F22 = SDL_SCANCODE_F22 or SDLK_SCANCODE_MASK;
4399
  SDLK_F23 = SDL_SCANCODE_F23 or SDLK_SCANCODE_MASK;
4400
  SDLK_F24 = SDL_SCANCODE_F24 or SDLK_SCANCODE_MASK;
4401
  SDLK_EXECUTE = SDL_SCANCODE_EXECUTE or SDLK_SCANCODE_MASK;
4402
  SDLK_HELP = SDL_SCANCODE_HELP or SDLK_SCANCODE_MASK;
4403
  SDLK_MENU = SDL_SCANCODE_MENU or SDLK_SCANCODE_MASK;
4404
  SDLK_SELECT = SDL_SCANCODE_SELECT or SDLK_SCANCODE_MASK;
4405
  SDLK_STOP = SDL_SCANCODE_STOP or SDLK_SCANCODE_MASK;
4406
  SDLK_AGAIN = SDL_SCANCODE_AGAIN or SDLK_SCANCODE_MASK;
4407
  SDLK_UNDO = SDL_SCANCODE_UNDO or SDLK_SCANCODE_MASK;
4408
  SDLK_CUT = SDL_SCANCODE_CUT or SDLK_SCANCODE_MASK;
4409
  SDLK_COPY = SDL_SCANCODE_COPY or SDLK_SCANCODE_MASK;
4410
  SDLK_PASTE = SDL_SCANCODE_PASTE or SDLK_SCANCODE_MASK;
4411
  SDLK_FIND = SDL_SCANCODE_FIND or SDLK_SCANCODE_MASK;
4412
  SDLK_MUTE = SDL_SCANCODE_MUTE or SDLK_SCANCODE_MASK;
4413
  SDLK_VOLUMEUP = SDL_SCANCODE_VOLUMEUP or SDLK_SCANCODE_MASK;
4414
  SDLK_VOLUMEDOWN = SDL_SCANCODE_VOLUMEDOWN or SDLK_SCANCODE_MASK;
4415
  SDLK_KP_COMMA = SDL_SCANCODE_KP_COMMA or SDLK_SCANCODE_MASK;
4416
  SDLK_KP_EQUALSAS400 = SDL_SCANCODE_KP_EQUALSAS400 or SDLK_SCANCODE_MASK;
4417

4418
  SDLK_ALTERASE = SDL_SCANCODE_ALTERASE or SDLK_SCANCODE_MASK;
4419
  SDLK_SYSREQ = SDL_SCANCODE_SYSREQ or SDLK_SCANCODE_MASK;
4420
  SDLK_CANCEL = SDL_SCANCODE_CANCEL or SDLK_SCANCODE_MASK;
4421
  SDLK_CLEAR = SDL_SCANCODE_CLEAR or SDLK_SCANCODE_MASK;
4422
  SDLK_PRIOR = SDL_SCANCODE_PRIOR or SDLK_SCANCODE_MASK;
4423
  SDLK_RETURN2 = SDL_SCANCODE_RETURN2 or SDLK_SCANCODE_MASK;
4424
  SDLK_SEPARATOR = SDL_SCANCODE_SEPARATOR or SDLK_SCANCODE_MASK;
4425
  SDLK_OUT = SDL_SCANCODE_OUT or SDLK_SCANCODE_MASK;
4426
  SDLK_OPER = SDL_SCANCODE_OPER or SDLK_SCANCODE_MASK;
4427
  SDLK_CLEARAGAIN = SDL_SCANCODE_CLEARAGAIN or SDLK_SCANCODE_MASK;
4428
  SDLK_CRSEL = SDL_SCANCODE_CRSEL or SDLK_SCANCODE_MASK;
4429
  SDLK_EXSEL = SDL_SCANCODE_EXSEL or SDLK_SCANCODE_MASK;
4430

4431
  SDLK_KP_00 = SDL_SCANCODE_KP_00 or SDLK_SCANCODE_MASK;
4432
  SDLK_KP_000 = SDL_SCANCODE_KP_000 or SDLK_SCANCODE_MASK;
4433
  SDLK_THOUSANDSSEPARATOR = SDL_SCANCODE_THOUSANDSSEPARATOR or SDLK_SCANCODE_MASK;
4434
  SDLK_DECIMALSEPARATOR = SDL_SCANCODE_DECIMALSEPARATOR or SDLK_SCANCODE_MASK;
4435
  SDLK_CURRENCYUNIT = SDL_SCANCODE_CURRENCYUNIT or SDLK_SCANCODE_MASK;
4436
  SDLK_CURRENCYSUBUNIT = SDL_SCANCODE_CURRENCYSUBUNIT or SDLK_SCANCODE_MASK;
4437
  SDLK_KP_LEFTPAREN = SDL_SCANCODE_KP_LEFTPAREN or SDLK_SCANCODE_MASK;
4438
  SDLK_KP_RIGHTPAREN = SDL_SCANCODE_KP_RIGHTPAREN or SDLK_SCANCODE_MASK;
4439
  SDLK_KP_LEFTBRACE = SDL_SCANCODE_KP_LEFTBRACE or SDLK_SCANCODE_MASK;
4440
  SDLK_KP_RIGHTBRACE = SDL_SCANCODE_KP_RIGHTBRACE or SDLK_SCANCODE_MASK;
4441
  SDLK_KP_TAB = SDL_SCANCODE_KP_TAB or SDLK_SCANCODE_MASK;
4442
  SDLK_KP_BACKSPACE = SDL_SCANCODE_KP_BACKSPACE or SDLK_SCANCODE_MASK;
4443
  SDLK_KP_A = SDL_SCANCODE_KP_A or SDLK_SCANCODE_MASK;
4444
  SDLK_KP_B = SDL_SCANCODE_KP_B or SDLK_SCANCODE_MASK;
4445
  SDLK_KP_C = SDL_SCANCODE_KP_C or SDLK_SCANCODE_MASK;
4446
  SDLK_KP_D = SDL_SCANCODE_KP_D or SDLK_SCANCODE_MASK;
4447
  SDLK_KP_E = SDL_SCANCODE_KP_E or SDLK_SCANCODE_MASK;
4448
  SDLK_KP_F = SDL_SCANCODE_KP_F or SDLK_SCANCODE_MASK;
4449
  SDLK_KP_XOR = SDL_SCANCODE_KP_XOR or SDLK_SCANCODE_MASK;
4450
  SDLK_KP_POWER = SDL_SCANCODE_KP_POWER or SDLK_SCANCODE_MASK;
4451
  SDLK_KP_PERCENT = SDL_SCANCODE_KP_PERCENT or SDLK_SCANCODE_MASK;
4452
  SDLK_KP_LESS = SDL_SCANCODE_KP_LESS or SDLK_SCANCODE_MASK;
4453
  SDLK_KP_GREATER = SDL_SCANCODE_KP_GREATER or SDLK_SCANCODE_MASK;
4454
  SDLK_KP_AMPERSAND = SDL_SCANCODE_KP_AMPERSAND or SDLK_SCANCODE_MASK;
4455
  SDLK_KP_DBLAMPERSAND = SDL_SCANCODE_KP_DBLAMPERSAND or SDLK_SCANCODE_MASK;
4456
  SDLK_KP_VERTICALBAR = SDL_SCANCODE_KP_VERTICALBAR or SDLK_SCANCODE_MASK;
4457
  SDLK_KP_DBLVERTICALBAR = SDL_SCANCODE_KP_DBLVERTICALBAR or SDLK_SCANCODE_MASK;
4458
  SDLK_KP_COLON = SDL_SCANCODE_KP_COLON or SDLK_SCANCODE_MASK;
4459
  SDLK_KP_HASH = SDL_SCANCODE_KP_HASH or SDLK_SCANCODE_MASK;
4460
  SDLK_KP_SPACE = SDL_SCANCODE_KP_SPACE or SDLK_SCANCODE_MASK;
4461
  SDLK_KP_AT = SDL_SCANCODE_KP_AT or SDLK_SCANCODE_MASK;
4462
  SDLK_KP_EXCLAM = SDL_SCANCODE_KP_EXCLAM or SDLK_SCANCODE_MASK;
4463
  SDLK_KP_MEMSTORE = SDL_SCANCODE_KP_MEMSTORE or SDLK_SCANCODE_MASK;
4464
  SDLK_KP_MEMRECALL = SDL_SCANCODE_KP_MEMRECALL or SDLK_SCANCODE_MASK;
4465
  SDLK_KP_MEMCLEAR = SDL_SCANCODE_KP_MEMCLEAR or SDLK_SCANCODE_MASK;
4466
  SDLK_KP_MEMADD = SDL_SCANCODE_KP_MEMADD or SDLK_SCANCODE_MASK;
4467
  SDLK_KP_MEMSUBTRACT = SDL_SCANCODE_KP_MEMSUBTRACT or SDLK_SCANCODE_MASK;
4468
  SDLK_KP_MEMMULTIPLY = SDL_SCANCODE_KP_MEMMULTIPLY or SDLK_SCANCODE_MASK;
4469
  SDLK_KP_MEMDIVIDE = SDL_SCANCODE_KP_MEMDIVIDE or SDLK_SCANCODE_MASK;
4470
  SDLK_KP_PLUSMINUS = SDL_SCANCODE_KP_PLUSMINUS or SDLK_SCANCODE_MASK;
4471
  SDLK_KP_CLEAR = SDL_SCANCODE_KP_CLEAR or SDLK_SCANCODE_MASK;
4472
  SDLK_KP_CLEARENTRY = SDL_SCANCODE_KP_CLEARENTRY or SDLK_SCANCODE_MASK;
4473
  SDLK_KP_BINARY = SDL_SCANCODE_KP_BINARY or SDLK_SCANCODE_MASK;
4474
  SDLK_KP_OCTAL = SDL_SCANCODE_KP_OCTAL or SDLK_SCANCODE_MASK;
4475
  SDLK_KP_DECIMAL = SDL_SCANCODE_KP_DECIMAL or SDLK_SCANCODE_MASK;
4476
  SDLK_KP_HEXADECIMAL = SDL_SCANCODE_KP_HEXADECIMAL or SDLK_SCANCODE_MASK;
4477

4478
  SDLK_LCTRL = SDL_SCANCODE_LCTRL or SDLK_SCANCODE_MASK;
4479
  SDLK_LSHIFT = SDL_SCANCODE_LSHIFT or SDLK_SCANCODE_MASK;
4480
  SDLK_LALT = SDL_SCANCODE_LALT or SDLK_SCANCODE_MASK;
4481
  SDLK_LGUI = SDL_SCANCODE_LGUI or SDLK_SCANCODE_MASK;
4482
  SDLK_RCTRL = SDL_SCANCODE_RCTRL or SDLK_SCANCODE_MASK;
4483
  SDLK_RSHIFT = SDL_SCANCODE_RSHIFT or SDLK_SCANCODE_MASK;
4484
  SDLK_RALT = SDL_SCANCODE_RALT or SDLK_SCANCODE_MASK;
4485
  SDLK_RGUI = SDL_SCANCODE_RGUI or SDLK_SCANCODE_MASK;
4486

4487
  SDLK_MODE = SDL_SCANCODE_MODE or SDLK_SCANCODE_MASK;
4488

4489
  SDLK_AUDIONEXT = SDL_SCANCODE_AUDIONEXT or SDLK_SCANCODE_MASK;
4490
  SDLK_AUDIOPREV = SDL_SCANCODE_AUDIOPREV or SDLK_SCANCODE_MASK;
4491
  SDLK_AUDIOSTOP = SDL_SCANCODE_AUDIOSTOP or SDLK_SCANCODE_MASK;
4492
  SDLK_AUDIOPLAY = SDL_SCANCODE_AUDIOPLAY or SDLK_SCANCODE_MASK;
4493
  SDLK_AUDIOMUTE = SDL_SCANCODE_AUDIOMUTE or SDLK_SCANCODE_MASK;
4494
  SDLK_MEDIASELECT = SDL_SCANCODE_MEDIASELECT or SDLK_SCANCODE_MASK;
4495
  SDLK_WWW = SDL_SCANCODE_WWW or SDLK_SCANCODE_MASK;
4496
  SDLK_MAIL = SDL_SCANCODE_MAIL or SDLK_SCANCODE_MASK;
4497
  SDLK_CALCULATOR = SDL_SCANCODE_CALCULATOR or SDLK_SCANCODE_MASK;
4498
  SDLK_COMPUTER = SDL_SCANCODE_COMPUTER or SDLK_SCANCODE_MASK;
4499
  SDLK_AC_SEARCH = SDL_SCANCODE_AC_SEARCH or SDLK_SCANCODE_MASK;
4500
  SDLK_AC_HOME = SDL_SCANCODE_AC_HOME or SDLK_SCANCODE_MASK;
4501
  SDLK_AC_BACK = SDL_SCANCODE_AC_BACK or SDLK_SCANCODE_MASK;
4502
  SDLK_AC_FORWARD = SDL_SCANCODE_AC_FORWARD or SDLK_SCANCODE_MASK;
4503
  SDLK_AC_STOP = SDL_SCANCODE_AC_STOP or SDLK_SCANCODE_MASK;
4504
  SDLK_AC_REFRESH = SDL_SCANCODE_AC_REFRESH or SDLK_SCANCODE_MASK;
4505
  SDLK_AC_BOOKMARKS = SDL_SCANCODE_AC_BOOKMARKS or SDLK_SCANCODE_MASK;
4506

4507
  SDLK_BRIGHTNESSDOWN = SDL_SCANCODE_BRIGHTNESSDOWN or SDLK_SCANCODE_MASK;
4508
  SDLK_BRIGHTNESSUP = SDL_SCANCODE_BRIGHTNESSUP or SDLK_SCANCODE_MASK;
4509
  SDLK_DISPLAYSWITCH = SDL_SCANCODE_DISPLAYSWITCH or SDLK_SCANCODE_MASK;
4510
  SDLK_KBDILLUMTOGGLE = SDL_SCANCODE_KBDILLUMTOGGLE or SDLK_SCANCODE_MASK;
4511
  SDLK_KBDILLUMDOWN = SDL_SCANCODE_KBDILLUMDOWN or SDLK_SCANCODE_MASK;
4512
  SDLK_KBDILLUMUP = SDL_SCANCODE_KBDILLUMUP or SDLK_SCANCODE_MASK;
4513
  SDLK_EJECT = SDL_SCANCODE_EJECT or SDLK_SCANCODE_MASK;
4514
  SDLK_SLEEP = SDL_SCANCODE_SLEEP or SDLK_SCANCODE_MASK;
4515

4516
  {**
4517
   *  Enumeration of valid key mods (possibly OR'd together).
4518
   *}
4519

4520
  KMOD_NONE = $0000;
4521
  KMOD_LSHIFT = $0001;
4522
  KMOD_RSHIFT = $0002;
4523
  KMOD_LCTRL = $0040;
4524
  KMOD_RCTRL = $0080;
4525
  KMOD_LALT = $0100;
4526
  KMOD_RALT = $0200;
4527
  KMOD_LGUI = $0400;
4528
  KMOD_RGUI = $0800;
4529
  KMOD_NUM = $1000;
4530
  KMOD_CAPS = $2000;
4531
  KMOD_MODE = $4000;
4532
  KMOD_RESERVED = $8000;
4533

4534
type
4535
  PSDL_KeyMod = ^TSDL_KeyMod;
4536
  TSDL_KeyMod = Word;
4537

4538
const
4539
  KMOD_CTRL	 = KMOD_LCTRL  or KMOD_RCTRL;
4540
  KMOD_SHIFT = KMOD_LSHIFT or KMOD_RSHIFT;
4541
  KMOD_ALT	 = KMOD_LALT   or KMOD_RALT;
4542
  KMOD_GUI	 = KMOD_LGUI   or KMOD_RGUI;
4543

4544

4545

4546
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4547
//////////////////////        SDL_keyboard.h        ////////////////////////////////////////////////////
4548
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4549

4550
type  
4551
  {**
4552
   *  The SDL keysym structure, used in key events.
4553
   *}
4554
  PSDL_Keysym = ^TSDL_Keysym;
4555
  TSDL_Keysym = record
4556
    scancode: TSDL_ScanCode;      // SDL physical key code - see SDL_Scancode for details
4557
    sym: TSDL_KeyCode;            // SDL virtual key code - see SDL_Keycode for details
4558
    _mod: UInt16;                 // current key modifiers
4559
    unicode: UInt32;              // (deprecated) use SDL_TextInputEvent instead
4560
  end;
4561

4562
  {**
4563
   *  Get the window which currently has keyboard focus.
4564
   *}
4565

4566
  function SDL_GetKeyboardFocus: PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetKeyboardFocus' {$ENDIF};
4567

4568
  {**
4569
   *  Get a snapshot of the current state of the keyboard.
4570
   *
4571
   *  numkeys if non-nil, receives the length of the returned array.
4572
   *  
4573
   *  An array of key states. Indexes into this array are obtained by using SDL_Scancode values.
4574
   *
4575
   *}
4576

4577
  function SDL_GetKeyboardState(numkeys: PInt): PUInt8 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetKeyboardState' {$ENDIF};
4578

4579
  {**
4580
   *  Get the current key modifier state for the keyboard.
4581
   *}
4582

4583
  function SDL_GetModState: TSDL_KeyMod cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetModState' {$ENDIF};
4584

4585
  {**
4586
   *  Set the current key modifier state for the keyboard.
4587
   *  
4588
   *  This does not change the keyboard state, only the key modifier flags.
4589
   *}
4590

4591
  procedure SDL_SetModState(modstate: TSDL_KeyMod) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetModState' {$ENDIF};
4592

4593
  {**
4594
   *  Get the key code corresponding to the given scancode according
4595
   *         to the current keyboard layout.
4596
   *
4597
   *  See SDL_Keycode for details.
4598
   *  
4599
   *  SDL_GetKeyName()
4600
   *}
4601

4602
  function SDL_GetKeyFromScancode(scancode: TSDL_ScanCode): TSDL_KeyCode cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetKeyFromScancode' {$ENDIF};
4603

4604
  {**
4605
   *  Get the scancode corresponding to the given key code according to the
4606
   *         current keyboard layout.
4607
   *
4608
   *  See SDL_Scancode for details.
4609
   *
4610
   *  SDL_GetScancodeName()
4611
   *}
4612

4613
  function SDL_GetScancodeFromKey(key: TSDL_KeyCode): TSDL_ScanCode cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetScancodeFromKey' {$ENDIF};
4614

4615
  {**
4616
   *  Get a human-readable name for a scancode.
4617
   *
4618
   *  A pointer to the name for the scancode.
4619
   *
4620
   *  If the scancode doesn't have a name, this function returns
4621
   *  an empty string ("").
4622
   *
4623
   *}
4624

4625
  function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetScancodeName' {$ENDIF};
4626

4627
  {**
4628
   *  Get a scancode from a human-readable name
4629
   *
4630
   *  scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
4631
   *
4632
   *  SDL_Scancode
4633
   *}
4634

4635
  function SDL_GetScancodeFromName(const name: PAnsiChar): TSDL_ScanCode cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetScancodeFromName' {$ENDIF};
4636

4637
  {**
4638
   *  Get a human-readable name for a key.
4639
   *
4640
   *  A pointer to a UTF-8 string that stays valid at least until the next
4641
   *  call to this function. If you need it around any longer, you must
4642
   *  copy it.  If the key doesn't have a name, this function returns an
4643
   *  empty string ("").
4644
   *  
4645
   *  SDL_Key
4646
   *}
4647

4648
  function SDL_GetKeyName(key: TSDL_ScanCode): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetKeyName' {$ENDIF};
4649

4650
  {**
4651
   *  Get a key code from a human-readable name
4652
   *
4653
   *  key code, or SDLK_UNKNOWN if the name wasn't recognized
4654
   *
4655
   *  SDL_Keycode
4656
   *}
4657

4658
  function SDL_GetKeyFromName(const name: PAnsiChar): TSDL_KeyCode cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetKeyFromName' {$ENDIF};
4659

4660
  {**
4661
   *  Start accepting Unicode text input events.
4662
   *  This function will show the on-screen keyboard if supported.
4663
   *  
4664
   *  SDL_StopTextInput()
4665
   *  SDL_SetTextInputRect()
4666
   *  SDL_HasScreenKeyboardSupport()
4667
   *}
4668

4669
  procedure SDL_StartTextInput cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_StartTextInput' {$ENDIF};
4670

4671
  {**
4672
   *  Return whether or not Unicode text input events are enabled.
4673
   *
4674
   *  SDL_StartTextInput()
4675
   *  SDL_StopTextInput()
4676
   *}
4677

4678
  function SDL_IsTextInputActive: TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IsTextInputActive' {$ENDIF};
4679

4680
  {**
4681
   *  Stop receiving any text input events.
4682
   *  This function will hide the on-screen keyboard if supported.
4683
   *  
4684
   *  SDL_StartTextInput()
4685
   *  SDL_HasScreenKeyboardSupport()
4686
   *}
4687

4688
  procedure SDL_StopTextInput cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_StopTextInput' {$ENDIF};
4689

4690
  {**
4691
   *  Set the rectangle used to type Unicode text inputs.
4692
   *  This is used as a hint for IME and on-screen keyboard placement.
4693
   *  
4694
   *  SDL_StartTextInput()
4695
   *}
4696

4697
  procedure SDL_SetTextInputRect(rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetTextInputRect' {$ENDIF};
4698

4699
  {**
4700
   *  Returns whether the platform has some screen keyboard support.
4701
   *  
4702
   *  SDL_TRUE if some keyboard support is available else SDL_FALSE.
4703
   *
4704
   *  Not all screen keyboard functions are supported on all platforms.
4705
   *
4706
   *  SDL_IsScreenKeyboardShown()
4707
   *}
4708

4709
  function SDL_HasScreenKeyboardSupport: TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_HasScreenKeyboardSupport' {$ENDIF};
4710

4711
  {**
4712
   *  Returns whether the screen keyboard is shown for given window.
4713
   *
4714
   *  window The window for which screen keyboard should be queried.
4715
   *
4716
   *  Result - SDL_TRUE if screen keyboard is shown else SDL_FALSE.
4717
   *
4718
   *  SDL_HasScreenKeyboardSupport()
4719
   *}
4720

4721
  function SDL_IsScreenKeyboardShown(window: PSDL_Window): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_IsScreenKeyboardShown' {$ENDIF};
4722

4723

4724

4725
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4726
//////////////////////         SDL_mouse.h          ////////////////////////////////////////////////////
4727
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4728

4729
type
4730
  PSDL_Cursor = Pointer;
4731
  
4732
const
4733

4734
  {**
4735
   *  Cursor types for SDL_CreateSystemCursor.
4736
   *}
4737

4738
  SDL_SYSTEM_CURSOR_ARROW = 0;     // Arrow
4739
  SDL_SYSTEM_CURSOR_IBEAM = 1;     // I-beam
4740
  SDL_SYSTEM_CURSOR_WAIT = 2;      // Wait
4741
  SDL_SYSTEM_CURSOR_CROSSHAIR = 3; // Crosshair
4742
  SDL_SYSTEM_CURSOR_WAITARROW = 4; // Small wait cursor (or Wait if not available)
4743
  SDL_SYSTEM_CURSOR_SIZENWSE = 5;  // Double arrow pointing northwest and southeast
4744
  SDL_SYSTEM_CURSOR_SIZENESW = 6;  // Double arrow pointing northeast and southwest
4745
  SDL_SYSTEM_CURSOR_SIZEWE = 7;    // Double arrow pointing west and east
4746
  SDL_SYSTEM_CURSOR_SIZENS = 8;    // Double arrow pointing north and south
4747
  SDL_SYSTEM_CURSOR_SIZEALL = 9;   // Four pointed arrow pointing north, south, east, and west
4748
  SDL_SYSTEM_CURSOR_NO = 10;        // Slashed circle or crossbones
4749
  SDL_SYSTEM_CURSOR_HAND = 11;      // Hand
4750
  SDL_NUM_SYSTEM_CURSORS = 12;
4751

4752
type
4753
  PSDL_SystemCursor = ^TSDL_SystemCursor;
4754
  TSDL_SystemCursor = Word;
4755

4756
  {* Function prototypes *}
4757

4758
  {**
4759
   *  Get the window which currently has mouse focus.
4760
   *}
4761

4762
  function SDL_GetMouseFocus: PSDL_Window cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetMouseFocus' {$ENDIF};
4763

4764
  {**
4765
   *  Retrieve the current state of the mouse.
4766
   *  
4767
   *  The current button state is returned as a button bitmask, which can
4768
   *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
4769
   *  mouse cursor position relative to the focus window for the currently
4770
   *  selected mouse.  You can pass nil for either x or y.
4771
   *
4772
   * SDL_Button = 1 shl ((X)-1)
4773
   *}
4774

4775
  function SDL_GetMouseState(x: PInt; y: PInt): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetMouseState' {$ENDIF};
4776

4777
  {**
4778
   *  Retrieve the relative state of the mouse.
4779
   *
4780
   *  The current button state is returned as a button bitmask, which can
4781
   *  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
4782
   *  mouse deltas since the last call to SDL_GetRelativeMouseState().
4783
   *}
4784

4785
  function SDL_GetRelativeMouseState(x: PInt; y: PInt): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRelativeMouseState' {$ENDIF};
4786

4787
  {**
4788
   *  Moves the mouse to the given position within the window.
4789
   *
4790
   *   window The window to move the mouse into, or nil for the current mouse focus
4791
   *   x The x coordinate within the window
4792
   *   y The y coordinate within the window
4793
   *
4794
   *  This function generates a mouse motion event
4795
   *}
4796

4797
  procedure SDL_WarpMouseInWindow(window: PSDL_Window; x: SInt32; y: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WarpMouseInWindow' {$ENDIF};
4798

4799
  {**
4800
   *  Set relative mouse mode.
4801
   *
4802
   *  enabled Whether or not to enable relative mode
4803
   *
4804
   *  0 on success, or -1 if relative mode is not supported.
4805
   *
4806
   *  While the mouse is in relative mode, the cursor is hidden, and the
4807
   *  driver will try to report continuous motion in the current window.
4808
   *  Only relative motion events will be delivered, the mouse position
4809
   *  will not change.
4810
   *  
4811
   *  This function will flush any pending mouse motion.
4812
   *  
4813
   *  SDL_GetRelativeMouseMode()
4814
   *}
4815

4816
  function SDL_SetRelativeMouseMode(enabled: TSDL_Bool): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetRelativeMouseMode' {$ENDIF};
4817

4818
  {**
4819
   *  Query whether relative mouse mode is enabled.
4820
   *  
4821
   *  SDL_SetRelativeMouseMode()
4822
   *}
4823

4824
  function SDL_GetRelativeMouseMode: TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetRelativeMouseMode' {$ENDIF};
4825

4826
  {**
4827
   *  Create a cursor, using the specified bitmap data and
4828
   *  mask (in MSB format).
4829
   *
4830
   *  The cursor width must be a multiple of 8 bits.
4831
   *
4832
   *  The cursor is created in black and white according to the following:
4833
   *  <table>
4834
   *  <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>
4835
   *  <tr><td>  0   </td><td>  1   </td><td> White </td></tr>
4836
   *  <tr><td>  1   </td><td>  1   </td><td> Black </td></tr>
4837
   *  <tr><td>  0   </td><td>  0   </td><td> Transparent </td></tr>
4838
   *  <tr><td>  1   </td><td>  0   </td><td> Inverted color if possible, black 
4839
   *                                         if not. </td></tr>
4840
   *  </table>
4841
   *  
4842
   *  SDL_FreeCursor()
4843
   *}
4844

4845
  function SDL_CreateCursor(const data: PUInt8; const mask: PUInt8; w: SInt32; h: SInt32; hot_x: SInt32; hot_y: SInt32): PSDL_Cursor cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateCursor' {$ENDIF};
4846

4847
  {**
4848
   *  Create a color cursor.
4849
   *
4850
   *  SDL_FreeCursor()
4851
   *}
4852

4853
  function SDL_CreateColorCursor(surface: PSDL_Surface; hot_x: SInt32; hot_y: SInt32): PSDL_Cursor cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateColorCursor' {$ENDIF};
4854

4855
  {**
4856
   *  Create a system cursor.
4857
   *
4858
   *  SDL_FreeCursor()
4859
   *}
4860

4861
  function SDL_CreateSystemCursor(id: TSDL_SystemCursor): PSDL_Cursor cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_CreateSystemCursor' {$ENDIF};
4862

4863
  {**
4864
   *  Set the active cursor.
4865
   *}
4866

4867
  procedure SDL_SetCursor(cursor: PSDL_Cursor) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetCursor' {$ENDIF};
4868

4869
  {**
4870
   *  Return the active cursor.
4871
   *}
4872

4873
  function SDL_GetCursor: PSDL_Cursor cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetCursor' {$ENDIF};
4874

4875
  {**
4876
   *  Frees a cursor created with SDL_CreateCursor().
4877
   *
4878
   *  SDL_CreateCursor()
4879
   *}
4880

4881
  procedure SDL_FreeCursor(cursor: PSDL_Cursor) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FreeCursor' {$ENDIF};
4882

4883
  {**
4884
   *  Toggle whether or not the cursor is shown.
4885
   *
4886
   *  toggle 1 to show the cursor, 0 to hide it, -1 to query the current
4887
   *                state.
4888
   *  
4889
   *  1 if the cursor is shown, or 0 if the cursor is hidden.
4890
   *}
4891

4892
  function SDL_ShowCursor(toggle: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ShowCursor' {$ENDIF};
4893

4894
const
4895
  {**
4896
   *  Used as a mask when testing buttons in buttonstate.
4897
   *   - Button 1:  Left mouse button
4898
   *   - Button 2:  Middle mouse button
4899
   *   - Button 3:  Right mouse button
4900
   *}
4901

4902
  SDL_BUTTON_LEFT	= 1;
4903
  SDL_BUTTON_MIDDLE	= 2;
4904
  SDL_BUTTON_RIGHT	= 3;
4905
  SDL_BUTTON_X1	    = 4;
4906
  SDL_BUTTON_X2	    = 5;
4907
  SDL_BUTTON_LMASK  = 1 shl ((SDL_BUTTON_LEFT) - 1);
4908
  SDL_BUTTON_MMASK  = 1 shl ((SDL_BUTTON_MIDDLE) - 1);
4909
  SDL_BUTTON_RMASK  = 1 shl ((SDL_BUTTON_RIGHT) - 1);
4910
  SDL_BUTTON_X1MASK = 1 shl ((SDL_BUTTON_X1) - 1);
4911
  SDL_BUTTON_X2MASK = 1 shl ((SDL_BUTTON_X2) - 1);
4912

4913

4914

4915
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4916
//////////////////////        SDL_joystick.h        ////////////////////////////////////////////////////
4917
////////////////////////////////////////////////////////////////////////////////////////////////////////  
4918

4919
  {**
4920
   *  SDL_joystick.h
4921
   *
4922
   *  In order to use these functions, SDL_Init() must have been called
4923
   *  with the ::SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
4924
   *  for joysticks, and load appropriate drivers.
4925
   *}
4926

4927
type
4928

4929
  {* The joystick structure used to identify an SDL joystick *}
4930
  PSDL_Joystick = Pointer; // todo!!
4931

4932
{* A structure that encodes the stable unique id for a joystick device *}
4933

4934
  TSDL_JoystickGUID = record
4935
    data: array[0..15] of UInt8;
4936
  end;
4937

4938
  TSDL_JoystickID = SInt32;
4939

4940
  {* Function prototypes *}
4941
  {**
4942
   *  Count the number of joysticks attached to the system right now
4943
   *}
4944
function SDL_NumJoysticks: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_NumJoysticks' {$ENDIF};
4945

4946
  {**
4947
   *  Get the implementation dependent name of a joystick.
4948
   *  This can be called before any joysticks are opened.
4949
   *  If no name can be found, this function returns NULL.
4950
   *}
4951
function SDL_JoystickNameForIndex(device_index: SInt32): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickNameForIndex' {$ENDIF};
4952

4953
  {**
4954
   *  Open a joystick for use.
4955
   *  The index passed as an argument refers tothe N'th joystick on the system.
4956
   *  This index is the value which will identify this joystick in future joystick
4957
   *  events.
4958
   *
4959
   *  A joystick identifier, or NULL if an error occurred.
4960
   *}
4961
function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickOpen' {$ENDIF};
4962

4963
  {**
4964
   *  Return the name for this currently opened joystick.
4965
   *  If no name can be found, this function returns NULL.
4966
   *}
4967
function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickName' {$ENDIF};
4968

4969
  {**
4970
   *  Return the GUID for the joystick at this index
4971
   *}
4972
function SDL_JoystickGetDeviceGUID(device_index: SInt32): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetDeviceGUID' {$ENDIF};
4973

4974
  {**
4975
   *  Return the GUID for this opened joystick
4976
   *}
4977
function SDL_JoystickGetGUID(joystick: PSDL_Joystick): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetGUID' {$ENDIF};
4978

4979
  {**
4980
   *  Return a string representation for this guid. pszGUID must point to at least 33 bytes
4981
   *  (32 for the string plus a NULL terminator).
4982
   *}
4983
procedure SDL_JoystickGetGUIDString(guid: TSDL_JoystickGUId; pszGUID: PAnsiChar; cbGUID: SInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetGUIDString' {$ENDIF};
4984

4985
  {**
4986
   *  convert a string into a joystick formatted guid
4987
   *}
4988
function SDL_JoystickGetGUIDFromString(const pchGUID: PAnsiChar): TSDL_JoystickGUID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetGUIDFromString' {$ENDIF};
4989

4990
  {**
4991
   *  Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
4992
   *}
4993
function SDL_JoystickGetAttached(joystick: PSDL_Joystick): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetAttached' {$ENDIF};
4994

4995
  {**
4996
   *  Get the instance ID of an opened joystick or -1 if the joystick is invalid.
4997
   *}
4998
function SDL_JoystickInstanceID(joystick: PSDL_Joystick): TSDL_JoystickID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickInstanceID' {$ENDIF};
4999

5000
  {**
5001
   *  Get the number of general axis controls on a joystick.
5002
   *}
5003
function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickNumAxes' {$ENDIF};
5004

5005
  {**
5006
   *  Get the number of trackballs on a joystick.
5007
   *
5008
   *  Joystick trackballs have only relative motion events associated
5009
   *  with them and their state cannot be polled.
5010
   *}
5011
function SDL_JoystickNumBalls(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickNumBalls' {$ENDIF};
5012

5013
  {**
5014
   *  Get the number of POV hats on a joystick.
5015
   *}
5016
function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickNumHats' {$ENDIF};
5017

5018
  {**
5019
   *  Get the number of buttons on a joystick.
5020
   *}
5021
function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickNumButtons' {$ENDIF};
5022

5023
  {**
5024
   *  Update the current state of the open joysticks.
5025
   *
5026
   *  This is called automatically by the event loop if any joystick
5027
   *  events are enabled.
5028
   *}
5029
procedure SDL_JoystickUpdate cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickUpdate' {$ENDIF};
5030

5031
  {**
5032
   *  Enable/disable joystick event polling.
5033
   *
5034
   *  If joystick events are disabled, you must call SDL_JoystickUpdate()
5035
   *  yourself and check the state of the joystick when you want joystick
5036
   *  information.
5037
   *
5038
   *  The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
5039
   *}
5040
function SDL_JoystickEventState(state: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickEventState' {$ENDIF};
5041

5042
  {**
5043
   *  Get the current state of an axis control on a joystick.
5044
   *
5045
   *  The state is a value ranging from -32768 to 32767.
5046
   *
5047
   *  The axis indices start at index 0.
5048
   *}
5049
function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetAxis' {$ENDIF};
5050

5051
  {**
5052
   *  Hat positions
5053
   *}
5054
const
5055
  SDL_HAT_CENTERED  = $00;
5056
  SDL_HAT_UP        = $01;
5057
  SDL_HAT_RIGHT     = $02;
5058
  SDL_HAT_DOWN      = $04;
5059
  SDL_HAT_LEFT      = $08;
5060
  SDL_HAT_RIGHTUP   = SDL_HAT_RIGHT or SDL_HAT_UP;
5061
  SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
5062
  SDL_HAT_LEFTUP    = SDL_HAT_LEFT or SDL_HAT_UP;
5063
  SDL_HAT_LEFTDOWN  = SDL_HAT_LEFT or SDL_HAT_DOWN;
5064

5065
  {**
5066
   *  Get the current state of a POV hat on a joystick.
5067
   *
5068
   *  The hat indices start at index 0.
5069
   *
5070
   *  The return value is one of the following positions:
5071
   *   - SDL_HAT_CENTERED
5072
   *   - SDL_HAT_UP
5073
   *   - SDL_HAT_RIGHT
5074
   *   - SDL_HAT_DOWN
5075
   *   - SDL_HAT_LEFT
5076
   *   - SDL_HAT_RIGHTUP
5077
   *   - SDL_HAT_RIGHTDOWN
5078
   *   - SDL_HAT_LEFTUP
5079
   *   - SDL_HAT_LEFTDOWN
5080
   *}
5081
function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetHat' {$ENDIF};
5082

5083
  {**
5084
   *  Get the ball axis change since the last poll.
5085
   *
5086
   *  0, or -1 if you passed it invalid parameters.
5087
   *
5088
   *  The ball indices start at index 0.
5089
   *}
5090
function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: SInt32; dx: PInt; dy: PInt): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetBall' {$ENDIF};
5091

5092
  {**
5093
   *  Get the current state of a button on a joystick.
5094
   *
5095
   *  The button indices start at index 0.
5096
   *}
5097
function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickGetButton' {$ENDIF};
5098
  {**
5099
   *  Close a joystick previously opened with SDL_JoystickOpen().
5100
   *}
5101
procedure SDL_JoystickClose(joystick: PSDL_Joystick) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_JoystickClose' {$ENDIF};
5102

5103

5104

5105
////////////////////////////////////////////////////////////////////////////////////////////////////////  
5106
//////////////////////         SDL_touch.h          ////////////////////////////////////////////////////
5107
////////////////////////////////////////////////////////////////////////////////////////////////////////
5108

5109
type
5110
  PSDL_TouchID  = ^TSDL_TouchID;
5111
  TSDL_TouchID  = SInt64;
5112

5113
  PSDL_FingerID = ^TSDL_FingerID;
5114
  TSDL_FingerID = SInt64;
5115

5116
  PSDL_Finger = ^TSDL_Finger;
5117
  TSDL_Finger = record
5118
    id: TSDL_FingerID;
5119
    x: Float;
5120
    y: Float;
5121
    pressure: Float;
5122
  end;
5123

5124
{* Used as the device ID for mouse events simulated with touch input *}
5125
const
5126
  SDL_TOUCH_MOUSEID = UInt32(-1);
5127

5128
  {* Function prototypes *}
5129

5130
  {**
5131
   *  Get the number of registered touch devices.
5132
   *}
5133
function SDL_GetNumTouchDevices: SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumTouchDevices' {$ENDIF};
5134

5135
  {**
5136
   *  Get the touch ID with the given index, or 0 if the index is invalid.
5137
   *}
5138
function SDL_GetTouchDevice(index: SInt32): TSDL_TouchID cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTouchDevice' {$ENDIF};
5139

5140
  {**
5141
   *  Get the number of active fingers for a given touch device.
5142
   *}
5143
function SDL_GetNumTouchFingers(touchID: TSDL_TouchID): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetNumTouchFingers' {$ENDIF};
5144

5145
  {**
5146
   *  Get the finger object of the given touch, with the given index.
5147
   *}
5148
function SDL_GetTouchFinger(touchID: TSDL_TouchID; index: SInt32): PSDL_Finger cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetTouchFinger' {$ENDIF};
5149

5150

5151

5152
////////////////////////////////////////////////////////////////////////////////////////////////////////  
5153
//////////////////////        SDL_gesture.h         ////////////////////////////////////////////////////
5154
////////////////////////////////////////////////////////////////////////////////////////////////////////  
5155

5156
type
5157
  TSDL_GestureID = SInt64;
5158

5159
  {* Function prototypes *}
5160

5161
  {**
5162
   *  Begin Recording a gesture on the specified touch, or all touches (-1)
5163
   *
5164
   *
5165
   *}
5166
function SDL_RecordGesture(touchId: TSDL_TouchID): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RecordGesture' {$ENDIF};
5167

5168
  {**
5169
   *  Save all currently loaded Dollar Gesture templates
5170
   *
5171
   *
5172
   *}
5173
function SDL_SaveAllDollarTemplates(src: PSDL_RWops): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SaveAllDollarTemplates' {$ENDIF};
5174

5175
  {**
5176
   *  Save a currently loaded Dollar Gesture template
5177
   *
5178
   *
5179
   *}
5180
function SDL_SaveDollarTemplate(gestureId: TSDL_GestureID; src: PSDL_RWops): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SaveDollarTemplate' {$ENDIF};
5181

5182

5183
  {**
5184
   *  Load Dollar Gesture templates from a file
5185
   *
5186
   *
5187
   *}
5188
function SDL_LoadDollarTemplates(touchId: TSDL_TouchID; src: PSDL_RWops): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LoadDollarTemplates' {$ENDIF};
5189

5190

5191

5192
////////////////////////////////////////////////////////////////////////////////////////////////////////
5193
//////////////////////        SDL_events.h          ////////////////////////////////////////////////////
5194
////////////////////////////////////////////////////////////////////////////////////////////////////////
5195

5196
  {**
5197
   *  The types of events that can be delivered.
5198
   *}
5199

5200
const
5201

5202
  SDL_FIRSTEVENT       = 0;     // Unused (do not remove) (needed in pascal?)
5203

5204
  SDL_COMMONEVENT      = 1;     //added for pascal-compatibility
5205

5206
  { Application events }
5207
  SDL_QUITEV           = $100;  // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
5208

5209

5210
  {* These application events have special meaning on iOS, see README.iOS for details *}
5211
  SDL_APP_TERMINATING  = $101;   {**< The application is being terminated by the OS
5212
                                      Called on iOS in applicationWillTerminate()
5213
                                      Called on Android in onDestroy()
5214
                                  *}
5215
  SDL_APP_LOWMEMORY    = $102;   {**< The application is low on memory, free memory if possible.
5216
                                      Called on iOS in applicationDidReceiveMemoryWarning()
5217
                                      Called on Android in onLowMemory()
5218
                                  *}
5219
  SDL_APP_WILLENTERBACKGROUND = $103; {**< The application is about to enter the background
5220
                                           Called on iOS in applicationWillResignActive()
5221
                                           Called on Android in onPause()
5222
                                       *}
5223
  SDL_APP_DIDENTERBACKGROUND = $104;  {**< The application did enter the background and may not get CPU for some time
5224
                                           Called on iOS in applicationDidEnterBackground()
5225
                                           Called on Android in onPause()
5226
                                       *}
5227
  SDL_APP_WILLENTERFOREGROUND = $105; {**< The application is about to enter the foreground
5228
                                           Called on iOS in applicationWillEnterForeground()
5229
                                           Called on Android in onResume()
5230
                                       *}
5231
  SDL_APP_DIDENTERFOREGROUND = $106;  {**< The application is now interactive
5232
                                           Called on iOS in applicationDidBecomeActive()
5233
                                           Called on Android in onResume()
5234
                                       *}
5235

5236
  { Window events }
5237
  SDL_WINDOWEVENT      = $200;  // Window state change
5238
  SDL_SYSWMEVENT       = $201;  // System specific event
5239

5240
  { Keyboard events }
5241
  SDL_KEYDOWN          = $300;  // Key pressed
5242
  SDL_KEYUP            = $301;  // Key released
5243
  SDL_TEXTEDITING      = $302;  // Keyboard text editing (composition)
5244
  SDL_TEXTINPUT        = $303;  // Keyboard text input
5245

5246
  { Mouse events }
5247
  SDL_MOUSEMOTION      = $400;  // Mouse moved
5248
  SDL_MOUSEBUTTONDOWN  = $401;  // Mouse button pressed
5249
  SDL_MOUSEBUTTONUP    = $402;  // Mouse button released
5250
  SDL_MOUSEWHEEL       = $403;  // Mouse wheel motion
5251

5252
  { Joystick events }
5253
  SDL_JOYAXISMOTION    = $600;  // Joystick axis motion
5254
  SDL_JOYBALLMOTION    = $601;  // Joystick trackball motion
5255
  SDL_JOYHATMOTION     = $602;  // Joystick hat position change
5256
  SDL_JOYBUTTONDOWN    = $603;  // Joystick button pressed
5257
  SDL_JOYBUTTONUP      = $604;  // Joystick button released
5258
  SDL_JOYDEVICEADDED   = $605;  // A new joystick has been inserted into the system 
5259
  SDL_JOYDEVICEREMOVED = $606;  // An opened joystick has been removed 
5260

5261
  { Game controller events }
5262
  SDL_CONTROLLERAXISMOTION     = $650;  // Game controller axis motion
5263
  SDL_CONTROLLERBUTTONDOWN     = $651;  // Game controller button pressed 
5264
  SDL_CONTROLLERBUTTONUP       = $652;  // Game controller button released 
5265
  SDL_CONTROLLERDEVICEADDED    = $653;  // A new Game controller has been inserted into the system 
5266
  SDL_CONTROLLERDEVICEREMOVED  = $654;  // An opened Game controller has been removed 
5267
  SDL_CONTROLLERDEVICEREMAPPED = $655;  // The controller mapping was updated 
5268

5269
  { Touch events }
5270
  SDL_FINGERDOWN      = $700;
5271
  SDL_FINGERUP        = $701;
5272
  SDL_FINGERMOTION    = $702;
5273

5274
  { Gesture events }
5275
  SDL_DOLLARGESTURE   = $800;
5276
  SDL_DOLLARRECORD    = $801;
5277
  SDL_MULTIGESTURE    = $802;
5278

5279
  { Clipboard events }
5280
  SDL_CLIPBOARDUPDATE = $900; // The clipboard changed
5281

5282
  { Drag and drop events }
5283
  SDL_DROPFILE        = $1000; // The system requests a file open
5284

5285
  {** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
5286
   *  and should be allocated with SDL_RegisterEvents()
5287
   *}
5288
  SDL_USEREVENT    = $8000;
5289

5290
  {**
5291
   *  This last event is only for bounding internal arrays (needed in pascal ??)
5292
   *}
5293
  SDL_LASTEVENT    = $FFFF;
5294

5295
type
5296

5297
  TSDL_EventType = Word;
5298

5299
  {**
5300
   *  Fields shared by every event
5301
   *}
5302

5303
  TSDL_CommonEvent = record
5304
    type_: UInt32;
5305
    timestamp: UInt32;
5306
  end;
5307

5308
  {**
5309
   *  Window state change event data (event.window.*)
5310
   *}
5311

5312
  TSDL_WindowEvent = record
5313
    type_: UInt32;       // SDL_WINDOWEVENT 
5314
    timestamp: UInt32;
5315
    windowID: UInt32;    // The associated window 
5316
    event: UInt8;        // SDL_WindowEventID 
5317
    padding1: UInt8;
5318
    padding2: UInt8;
5319
    padding3: UInt8;
5320
    data1: SInt32;       // event dependent data
5321
    data2: SInt32;       // event dependent data 
5322
  end;
5323

5324
  {**
5325
   *  Keyboard button event structure (event.key.*)
5326
   *}
5327
  TSDL_KeyboardEvent = record
5328
    type_: UInt32;        // SDL_KEYDOWN or SDL_KEYUP 
5329
    timestamp: UInt32;
5330
    windowID: UInt32;     // The window with keyboard focus, if any 
5331
    state: UInt8;         // SDL_PRESSED or SDL_RELEASED 
5332
    _repeat: UInt8;       // Non-zero if this is a key repeat
5333
    padding2: UInt8;
5334
    padding3: UInt8;
5335
    keysym: TSDL_KeySym;  // The key that was pressed or released
5336
  end;
5337

5338
const
5339
  SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
5340
  
5341
type
5342
 
5343
  {**
5344
   *  Keyboard text editing event structure (event.edit.*)
5345
   *}
5346
 
5347
  TSDL_TextEditingEvent = record
5348
    type_: UInt32;                               // SDL_TEXTEDITING 
5349
    timestamp: UInt32;
5350
    windowID: UInt32;                            // The window with keyboard focus, if any
5351
    text: array[0..SDL_TEXTEDITINGEVENT_TEXT_SIZE] of Char;  // The editing text 
5352
    start: SInt32;                               // The start cursor of selected editing text 
5353
    length: SInt32;                              // The length of selected editing text
5354
  end;
5355

5356
const
5357
  SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
5358

5359
type
5360

5361
  {**
5362
   *  Keyboard text input event structure (event.text.*)
5363
   *}
5364
 
5365
  TSDL_TextInputEvent = record
5366
    type_: UInt32;                                          // SDL_TEXTINPUT 
5367
    timestamp: UInt32;
5368
    windowID: UInt32;                                       // The window with keyboard focus, if any
5369
    text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char;   // The input text 
5370
  end;
5371

5372
  {**
5373
   *  Mouse motion event structure (event.motion.*)
5374
   *}
5375
 
5376
  TSDL_MouseMotionEvent = record
5377
    type_: UInt32;       // SDL_MOUSEMOTION
5378
    timestamp: UInt32;
5379
    windowID: UInt32;    // The window with mouse focus, if any 
5380
    which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID
5381
    state: UInt8;        // The current button state 
5382
    padding1: UInt8;
5383
    padding2: UInt8;
5384
    padding3: UInt8;
5385
    x: SInt32;           // X coordinate, relative to window 
5386
    y: SInt32;           // Y coordinate, relative to window
5387
    xrel: SInt32;        // The relative motion in the X direction 
5388
    yrel: SInt32;        // The relative motion in the Y direction 
5389
  end;
5390

5391
  {**
5392
   *  Mouse button event structure (event.button.*)
5393
   *}
5394
 
5395
  TSDL_MouseButtonEvent = record
5396
    type_: UInt32;       // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP 
5397
    timestamp: UInt32;
5398
    windowID: UInt32;    // The window with mouse focus, if any
5399
    which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID 
5400
    button: UInt8;       // The mouse button index 
5401
    state: UInt8;        // SDL_PRESSED or SDL_RELEASED
5402
    padding1: UInt8;
5403
    padding2: UInt8;
5404
    x: SInt32;           // X coordinate, relative to window
5405
    y: SInt32;           // Y coordinate, relative to window 
5406
  end;
5407

5408
  {**
5409
   *  Mouse wheel event structure (event.wheel.*)
5410
   *}
5411
 
5412
  TSDL_MouseWheelEvent = record
5413
    type_: UInt32;        // SDL_MOUSEWHEEL
5414
    timestamp: UInt32;
5415
    windowID: UInt32;    // The window with mouse focus, if any 
5416
    which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID
5417
    x: SInt32;           // The amount scrolled horizontally 
5418
    y: SInt32;           // The amount scrolled vertically
5419
  end;
5420

5421
  {**
5422
   *  Joystick axis motion event structure (event.jaxis.*)
5423
   *}
5424
 
5425
  TSDL_JoyAxisEvent = record
5426
    type_: UInt32;         // SDL_JOYAXISMOTION 
5427
    timestamp: UInt32;
5428
    which: TSDL_JoystickID; // The joystick instance id
5429
    axis: UInt8;           // The joystick axis index 
5430
    padding1: UInt8;
5431
    padding2: UInt8;
5432
    padding3: UInt8;
5433
    value: SInt16;         // The axis value (range: -32768 to 32767) 
5434
    padding4: UInt16;
5435
  end;
5436

5437
  {**
5438
   *  Joystick trackball motion event structure (event.jball.*)
5439
   *}
5440

5441
  TSDL_JoyBallEvent = record
5442
    type_: UInt32;         // SDL_JOYBALLMOTION
5443
    timestamp: UInt32;
5444
    which: TSDL_JoystickID; // The joystick instance id
5445
    ball: UInt8;           // The joystick trackball index
5446
    padding1: UInt8;
5447
    padding2: UInt8;
5448
    padding3: UInt8;
5449
    xrel: SInt16;          // The relative motion in the X direction
5450
    yrel: SInt16;          // The relative motion in the Y direction
5451
  end;
5452

5453
  {**
5454
   *  Joystick hat position change event structure (event.jhat.*)
5455
   *}
5456

5457
  TSDL_JoyHatEvent = record
5458
    type_: UInt32;         // SDL_JOYHATMOTION
5459
    timestamp: UInt32;
5460
    which: TSDL_JoystickID; // The joystick instance id
5461
    hat: UInt8;            // The joystick hat index
5462
    value: UInt8;         {*  The hat position value.
5463
                           *  SDL_HAT_LEFTUP   SDL_HAT_UP       SDL_HAT_RIGHTUP
5464
                           *  SDL_HAT_LEFT     SDL_HAT_CENTERED SDL_HAT_RIGHT
5465
                           *  SDL_HAT_LEFTDOWN SDL_HAT_DOWN     SDL_HAT_RIGHTDOWN
5466
                           *
5467
                           *  Note that zero means the POV is centered.
5468
                           *}
5469
    padding1: UInt8;
5470
    padding2: UInt8;
5471
  end;
5472

5473
  {**
5474
   *  Joystick button event structure (event.jbutton.*)
5475
   *}
5476

5477
  TSDL_JoyButtonEvent = record
5478
    type_: UInt32;        // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
5479
    timestamp: UInt32;
5480
    which: TSDL_JoystickID; // The joystick instance id 
5481
    button: UInt8;         // The joystick button index 
5482
    state: UInt8;          // SDL_PRESSED or SDL_RELEASED
5483
    padding1: UInt8;
5484
    padding2: UInt8;
5485
  end;
5486

5487
  {**
5488
   *  Joystick device event structure (event.jdevice.*)
5489
   *}
5490

5491
  TSDL_JoyDeviceEvent = record
5492
    type_: UInt32;      // SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED
5493
    timestamp: UInt32;
5494
    which: SInt32;      // The joystick device index for the ADDED event, instance id for the REMOVED event
5495
  end;
5496

5497
  {**
5498
   *  Game controller axis motion event structure (event.caxis.*)
5499
   *}
5500

5501
  TSDL_ControllerAxisEvent = record
5502
    type_: UInt32;         // SDL_CONTROLLERAXISMOTION
5503
    timestamp: UInt32;
5504
    which: TSDL_JoystickID; // The joystick instance id
5505
    axis: UInt8;           // The controller axis (SDL_GameControllerAxis)
5506
    padding1: UInt8;
5507
    padding2: UInt8;
5508
    padding3: UInt8;
5509
    value: SInt16;         // The axis value (range: -32768 to 32767)
5510
    padding4: UInt16;
5511
  end;
5512

5513
  {**
5514
   *  Game controller button event structure (event.cbutton.*)
5515
   *}
5516

5517
  TSDL_ControllerButtonEvent = record
5518
    type_: UInt32;         // SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP
5519
    timestamp: UInt32;
5520
    which: TSDL_JoystickID; // The joystick instance id
5521
    button: UInt8;         // The controller button (SDL_GameControllerButton)
5522
    state: UInt8;          // SDL_PRESSED or SDL_RELEASED
5523
    padding1: UInt8;
5524
    padding2: UInt8;
5525
  end;
5526

5527

5528
  {**
5529
   *  Controller device event structure (event.cdevice.*)
5530
   *}
5531

5532
  TSDL_ControllerDeviceEvent = record
5533
    type_: UInt32;       // SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, or SDL_CONTROLLERDEVICEREMAPPED
5534
    timestamp: UInt32;
5535
    which: SInt32;       // The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event
5536
  end;
5537

5538
  {**
5539
   *  Touch finger event structure (event.tfinger.*)
5540
   *}
5541

5542
  TSDL_TouchFingerEvent = record
5543
    type_: UInt32;         // SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP
5544
    timestamp: UInt32;
5545
    touchId: TSDL_TouchID;  // The touch device id
5546
    fingerId: TSDL_FingerID;
5547
    x: Float;              // Normalized in the range 0...1
5548
    y: Float;              // Normalized in the range 0...1
5549
    dx: Float;             // Normalized in the range 0...1
5550
    dy: Float;             // Normalized in the range 0...1
5551
    pressure: Float;       // Normalized in the range 0...1
5552
  end;
5553

5554
  {**
5555
   *  Multiple Finger Gesture Event (event.mgesture.*)
5556
   *}
5557
  TSDL_MultiGestureEvent = record
5558
    type_: UInt32;        // SDL_MULTIGESTURE
5559
    timestamp: UInt32;
5560
    touchId: TSDL_TouchID; // The touch device index
5561
    dTheta: Float;
5562
    dDist: Float;
5563
    x: Float;
5564
    y: Float;
5565
    numFingers: UInt16;
5566
    padding: UInt16;
5567
  end;
5568

5569

5570
  {* (event.dgesture.*) *}
5571
  TSDL_DollarGestureEvent = record
5572
    type_: UInt32;         // SDL_DOLLARGESTURE
5573
    timestamp: UInt32;
5574
    touchId: TSDL_TouchID;  // The touch device id
5575
    gestureId: TSDL_GestureID;
5576
    numFingers: UInt32;
5577
    error: Float;
5578
    x: Float;              // Normalized center of gesture
5579
    y: Float;              // Normalized center of gesture
5580
  end;
5581

5582

5583
  {**
5584
   *  An event used to request a file open by the system (event.drop.*)
5585
   *  This event is disabled by default, you can enable it with SDL_EventState()
5586
   *  If you enable this event, you must free the filename in the event.
5587
   *}
5588

5589
  TSDL_DropEvent = record
5590
    type_: UInt32;      // SDL_DROPFILE
5591
    timestamp: UInt32;
5592
    _file: PAnsiChar;   // The file name, which should be freed with SDL_free() 
5593
  end;
5594

5595
  {**
5596
   *  The "quit requested" event
5597
   *}
5598

5599
  TSDL_QuitEvent = record
5600
    type_: UInt32;        // SDL_QUIT
5601
    timestamp: UInt32;
5602
  end;
5603

5604
  {**
5605
   *  A user-defined event type (event.user.*)
5606
   *}
5607

5608
  TSDL_UserEvent = record
5609
    type_: UInt32;       // SDL_USEREVENT through SDL_NUMEVENTS-1
5610
    timestamp: UInt32;
5611
    windowID: UInt32;    // The associated window if any
5612
    code: SInt32;        // User defined event code
5613
    data1: Pointer;      // User defined data pointer
5614
    data2: Pointer;      // User defined data pointer
5615
  end;
5616

5617
  {$IFDEF Unix}
5618
    //These are the various supported subsystems under UNIX
5619
    TSDL_SysWm = ( SDL_SYSWM_X11 ) ;
5620
  {$ENDIF}
5621

5622
  // The windows custom event structure
5623
  {$IFDEF Windows}
5624
    PSDL_SysWMmsg = ^TSDL_SysWMmsg;
5625
    TSDL_SysWMmsg = record
5626
      version: TSDL_Version;
5627
      h_wnd: HWND; // The window for the message
5628
      msg: UInt32; // The type of message
5629
      w_Param: WPARAM; // WORD message parameter
5630
      lParam: LPARAM; // LONG message parameter
5631
    end;
5632
  {$ELSE}
5633

5634
    {$IFDEF Unix}
5635
      { The Linux custom event structure }
5636
      PSDL_SysWMmsg = ^TSDL_SysWMmsg;
5637
      TSDL_SysWMmsg = record
5638
        version : TSDL_Version;
5639
        subsystem : TSDL_SysWm;
5640

5641
          {$IFNDEF DARWIN}
5642
          event : TXEvent;
5643
          {$ENDIF}
5644

5645
      end;
5646
    {$ELSE}
5647
      { The generic custom event structure }
5648
      PSDL_SysWMmsg = ^TSDL_SysWMmsg;
5649
      TSDL_SysWMmsg = record
5650
        version: TSDL_Version;
5651
        data: Integer;
5652
      end;
5653
    {$ENDIF}
5654

5655
  {$ENDIF}
5656

5657
  // The Windows custom window manager information structure
5658
  {$IFDEF Windows}
5659
    PSDL_SysWMinfo = ^TSDL_SysWMinfo;
5660
    TSDL_SysWMinfo = record
5661
      version : TSDL_Version;
5662
      window : HWnd;	// The display window
5663
    end;
5664
  {$ELSE}
5665
    // The Linux custom window manager information structure
5666
    {$IFDEF Unix}
5667
      {$IFNDEF DARWIN}
5668
      TX11 = record
5669
        display : PDisplay;	// The X11 display
5670
        window : TWindow;		// The X11 display window */
5671
        {* These locking functions should be called around
5672
           any X11 functions using the display variable.
5673
           They lock the event thread, so should not be
5674
           called around event functions or from event filters.
5675
         *}
5676
        lock_func : Pointer;
5677
        unlock_func : Pointer;
5678

5679
        // Introduced in SDL 1.0.2
5680
        fswindow : TWindow;	// The X11 fullscreen window */
5681
        wmwindow : TWindow;	// The X11 managed input window */
5682
      end;
5683
      {$ENDIF}
5684

5685
      PSDL_SysWMinfo = ^TSDL_SysWMinfo;
5686
      TSDL_SysWMinfo = record
5687
         version : TSDL_Version;
5688
         subsystem : TSDL_SysWm;
5689
         {$IFNDEF DARWIN}
5690
         X11 : TX11;
5691
         {$ENDIF}
5692
      end;
5693
    {$ELSE}
5694
      // The generic custom window manager information structure
5695
      PSDL_SysWMinfo = ^TSDL_SysWMinfo;
5696
      TSDL_SysWMinfo = record
5697
        version : TSDL_Version;
5698
        data : integer;
5699
      end;
5700
    {$ENDIF}
5701

5702
  {$ENDIF}
5703

5704
  {**
5705
   *  A video driver dependent system event (event.syswm.*)
5706
   *  This event is disabled by default, you can enable it with SDL_EventState()
5707
   *
5708
   *  If you want to use this event, you should include SDL_syswm.h.
5709
   *}
5710

5711
  PSDL_SysWMEvent = ^TSDL_SysWMEvent;
5712
  TSDL_SysWMEvent = record
5713
    type_: UInt32;       // SDL_SYSWMEVENT
5714
    timestamp: UInt32;
5715
    msg: PSDL_SysWMmsg;  // driver dependent data (defined in SDL_syswm.h)
5716
  end;
5717

5718
  {**
5719
   *  General event structure
5720
   *}
5721

5722
  PSDL_Event = ^TSDL_Event;
5723
  TSDL_Event = record
5724
    case Integer of
5725
      0:  (type_: UInt32);
5726

5727
      SDL_COMMONEVENT:  (common: TSDL_CommonEvent);
5728
      SDL_WINDOWEVENT:  (window: TSDL_WindowEvent);
5729

5730
      SDL_KEYUP,
5731
      SDL_KEYDOWN:  (key: TSDL_KeyboardEvent);
5732
      SDL_TEXTEDITING:  (edit: TSDL_TextEditingEvent);
5733
      SDL_TEXTINPUT:  (text: TSDL_TextInputEvent);
5734

5735
      SDL_MOUSEMOTION:  (motion: TSDL_MouseMotionEvent);
5736
      SDL_MOUSEBUTTONUP,
5737
      SDL_MOUSEBUTTONDOWN:  (button: TSDL_MouseButtonEvent);
5738
      SDL_MOUSEWHEEL:  (wheel: TSDL_MouseWheelEvent);
5739
	  
5740
      SDL_JOYAXISMOTION:  (jaxis: TSDL_JoyAxisEvent);
5741
      SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
5742
      SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
5743
      SDL_JOYBUTTONDOWN,
5744
      SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
5745
      SDL_JOYDEVICEADDED,
5746
      SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
5747

5748
      SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
5749
      SDL_CONTROLLERBUTTONUP,
5750
      SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
5751
      SDL_CONTROLLERDEVICEADDED,
5752
      SDL_CONTROLLERDEVICEREMOVED,
5753
      SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
5754

5755
      SDL_QUITEV: (quit: TSDL_QuitEvent);
5756

5757
      SDL_USEREVENT: (user: TSDL_UserEvent);
5758
      SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
5759

5760
      SDL_FINGERDOWN,
5761
      SDL_FINGERUP,
5762
      SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
5763
      SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
5764
      SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
5765

5766
      SDL_DROPFILE: (drop: TSDL_DropEvent);
5767
  end;
5768

5769

5770
  {* Function prototypes *}
5771

5772
  {**
5773
   *  Pumps the event loop, gathering events from the input devices.
5774
   *  
5775
   *  This function updates the event queue and internal input device state.
5776
   *  
5777
   *  This should only be run in the thread that sets the video mode.
5778
   *}
5779
  procedure SDL_PumpEvents cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF};
5780

5781
const
5782
  SDL_ADDEVENT = 0;
5783
  SDL_PEEKEVENT = 1;
5784
  SDL_GETEVENT = 2;
5785

5786
type
5787
  TSDL_EventAction = Word;
5788

5789
  {**
5790
   *  Checks the event queue for messages and optionally returns them.
5791
   *
5792
   *  If action is SDL_ADDEVENT, up to numevents events will be added to
5793
   *  the back of the event queue.
5794
   *
5795
   *  If action is SDL_PEEKEVENT, up to numevents events at the front
5796
   *  of the event queue, within the specified minimum and maximum type,
5797
   *  will be returned and will not be removed from the queue.
5798
   *
5799
   *  If action is SDL_GETEVENT, up to numevents events at the front
5800
   *  of the event queue, within the specified minimum and maximum type,
5801
   *  will be returned and will be removed from the queue.
5802
   *
5803
   *  Result: The number of events actually stored, or -1 if there was an error.
5804
   *
5805
   *  This function is thread-safe.
5806
   *}
5807

5808
  function SDL_PeepEvents(events: PSDL_Event; numevents: SInt32; action: TSDL_EventAction; minType: UInt32; maxType: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_PeepEvents' {$ENDIF};
5809

5810
  {**
5811
   *  Checks to see if certain event types are in the event queue.
5812
   *}
5813
 
5814
  function SDL_HasEvent(type_: UInt32): TSDL_Bool  cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF};
5815
  function SDL_HasEvents(minType: UInt32; maxType: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF};
5816

5817
  {**
5818
   *  This function clears events from the event queue
5819
   *}
5820

5821
  procedure SDL_FlushEvent(type_: UInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF};
5822
  procedure SDL_FlushEvents(minType: UInt32; maxType: UInt32) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF};
5823

5824
  {**
5825
   *  Polls for currently pending events.
5826
   *
5827
   *  1 if there are any pending events, or 0 if there are none available.
5828
   *  
5829
   *  event - If not nil, the next event is removed from the queue and
5830
   *               stored in that area.
5831
   *}
5832

5833
  function SDL_PollEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_PollEvent' {$ENDIF};
5834

5835
  {**
5836
   *  Waits indefinitely for the next available event.
5837
   *  
5838
   *  1, or 0 if there was an error while waiting for events.
5839
   *   
5840
   *  event - If not nil, the next event is removed from the queue and 
5841
   *  stored in that area.
5842
   *}
5843
 
5844
  function SDL_WaitEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WaitEvent' {$ENDIF};
5845

5846
  {**
5847
   *  Waits until the specified timeout (in milliseconds) for the next
5848
   *  available event.
5849
   *  
5850
   *  1, or 0 if there was an error while waiting for events.
5851
   *  
5852
   *  event - If not nil, the next event is removed from the queue and
5853
   *  stored in that area.
5854
   *}
5855

5856
  function SDL_WaitEventTimeout(event: PSDL_Event; timeout: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WaitEventTimeout' {$ENDIF};
5857

5858
  {**
5859
   *  Add an event to the event queue.
5860
   *  
5861
   *  1 on success, 0 if the event was filtered, or -1 if the event queue
5862
   *  was full or there was some other error.
5863
   *}
5864

5865
  function SDL_PushEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF};
5866

5867
type
5868
  PSDL_EventFilter = ^TSDL_EventFilter;
5869
  TSDL_EventFilter = function( event: PSDL_Event ): Integer; cdecl;
5870

5871
  {**
5872
   *  Sets up a filter to process all events before they change internal state and
5873
   *  are posted to the internal event queue.
5874
   *  
5875
   *  If the filter returns 1, then the event will be added to the internal queue.
5876
   *  If it returns 0, then the event will be dropped from the queue, but the 
5877
   *  internal state will still be updated.  This allows selective filtering of
5878
   *  dynamically arriving events.
5879
   *  
5880
   *  Be very careful of what you do in the event filter function, as
5881
   *  it may run in a different thread!
5882
   *  
5883
   *  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
5884
   *  event filter is only called when the window manager desires to close the
5885
   *  application window.  If the event filter returns 1, then the window will
5886
   *  be closed, otherwise the window will remain open if possible.
5887
   *
5888
   *  If the quit event is generated by an interrupt signal, it will bypass the
5889
   *  internal queue and be delivered to the application at the next event poll.
5890
   *}
5891

5892
  procedure SDL_SetEventFilter(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetEventFilter' {$ENDIF};
5893

5894
  {**
5895
   *  Return the current event filter - can be used to "chain" filters.
5896
   *  If there is no event filter set, this function returns SDL_FALSE.
5897
   *}
5898

5899
  function SDL_GetEventFilter(filter: PSDL_EventFilter; userdata: Pointer): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetEventFilter' {$ENDIF};
5900

5901
  {**
5902
   *  Add a function which is called when an event is added to the queue.
5903
   *}
5904
 
5905
  procedure SDL_AddEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_AddEventWatch' {$ENDIF};
5906

5907
  {**
5908
   *  Remove an event watch function added with SDL_AddEventWatch()
5909
   *}
5910
 
5911
  procedure SDL_DelEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_DelEventWatch' {$ENDIF};
5912

5913
  {**
5914
   *  Run the filter function on the current event queue, removing any
5915
   *  events for which the filter returns 0.
5916
   *}
5917

5918
  procedure SDL_FilterEvents(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_FilterEvents' {$ENDIF};
5919

5920
const
5921

5922
  SDL_QUERY   =	-1;
5923
  SDL_IGNORE  =	 0;
5924
  SDL_DISABLE =	 0;
5925
  SDL_ENABLE  =  1;
5926

5927
  {**
5928
   *  This function allows you to set the state of processing certain events.
5929
   *   - If state is set to SDL_IGNORE, that event will be automatically
5930
   *     dropped from the event queue and will not event be filtered.
5931
   *   - If state is set to SDL_ENABLE, that event will be processed
5932
   *     normally.
5933
   *   - If state is set to SDL_QUERY, SDL_EventState() will return the
5934
   *     current processing state of the specified event.
5935
   *}
5936

5937
  function SDL_EventState(type_: UInt32; state: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF};
5938

5939
  function SDL_GetEventState(type_: UInt32): UInt8;
5940

5941
  {**
5942
   *  This function allocates a set of user-defined events, and returns
5943
   *  the beginning event number for that set of events.
5944
   *
5945
   *  If there aren't enough user-defined events left, this function
5946
   *  returns (Uint32)-1
5947
   *}
5948
   
5949
  function SDL_RegisterEvents(numevents: SInt32): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_RegisterEvents' {$ENDIF};
5950

5951

5952

5953
////////////////////////////////////////////////////////////////////////////////////////////////////////
5954
//////////////////////           SDL.h              ////////////////////////////////////////////////////
5955
////////////////////////////////////////////////////////////////////////////////////////////////////////
5956

5957
const
5958

5959
  SDL_INIT_TIMER          = $00000001;
5960
  {$EXTERNALSYM SDL_INIT_TIMER}
5961
  SDL_INIT_AUDIO          = $00000010;
5962
  {$EXTERNALSYM SDL_INIT_AUDIO}
5963
  SDL_INIT_VIDEO          = $00000020;
5964
  {$EXTERNALSYM SDL_INIT_VIDEO}
5965
  SDL_INIT_JOYSTICK       = $00000200;
5966
  {$EXTERNALSYM SDL_INIT_JOYSTICK}
5967
  SDL_INIT_HAPTIC         = $00001000;
5968
  {$EXTERNALSYM SDL_INIT_HAPTIC}
5969
  SDL_INIT_GAMECONTROLLER = $00002000;  //turn on game controller also implicitly does JOYSTICK
5970
  {$EXTERNALSYM SDL_INIT_GAMECONTROLLER}
5971
  SDL_INIT_NOPARACHUTE    = $00100000;  //Don't catch fatal signals
5972
  {$EXTERNALSYM SDL_INIT_NOPARACHUTE}
5973
  SDL_INIT_EVERYTHING     = SDL_INIT_TIMER    or
5974
							SDL_INIT_AUDIO    or
5975
							SDL_INIT_VIDEO    or
5976
							SDL_INIT_JOYSTICK or
5977
							SDL_INIT_HAPTIC   or
5978
							SDL_INIT_GAMECONTROLLER;
5979
  {$EXTERNALSYM SDL_INIT_EVERYTHING}
5980

5981
{**
5982
 *  This function initializes  the subsystems specified by flags
5983
 *  Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
5984
 *  signal handlers for some commonly ignored fatal signals (like SIGSEGV).
5985
 *}
5986

5987
function SDL_Init(flags: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_Init' {$ENDIF};
5988

5989
{**
5990
 *  This function initializes specific SDL subsystems
5991
 *}
5992

5993
function SDL_InitSubSystem(flags: UInt32): SInt32; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_InitSubSystem' {$ENDIF};
5994

5995
{**
5996
 *  This function cleans up specific SDL subsystems
5997
 *}
5998

5999
procedure SDL_QuitSubSystem(flags: UInt32); cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_QuitSubSystem' {$ENDIF};
6000

6001
{**
6002
 *  This function returns a mask of the specified subsystems which have
6003
 *  previously been initialized.
6004
 *
6005
 *  If flags is 0, it returns a mask of all initialized subsystems.
6006
 *}
6007

6008
function SDL_WasInit(flags: UInt32): UInt32; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_WasInit' {$ENDIF};
6009

6010
{**
6011
 *  This function cleans up all initialized subsystems. You should
6012
 *  call it upon all exit conditions.
6013
 *}
6014

6015
procedure SDL_Quit; cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_Quit' {$ENDIF};
6016

6017

6018

6019
////////////////////////////////////////////////////////////////////////////////////////////////////////
6020
//////////////////////        SDL_loadso.h          ////////////////////////////////////////////////////
6021
////////////////////////////////////////////////////////////////////////////////////////////////////////
6022

6023
{**
6024
 *  This function dynamically loads a shared object and returns a pointer
6025
 *  to the object handle (or NULL if there was an error).
6026
 *  The 'sofile' parameter is a system dependent name of the object file.
6027
 *}
6028
function SDL_LoadObject(sofile: PAnsiChar): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LoadObject' {$ENDIF};
6029

6030
{**
6031
 *  Given an object handle, this function looks up the address of the
6032
 *  named function in the shared object and returns it.  This address
6033
 *  is no longer valid after calling SDL_UnloadObject().
6034
 *}
6035
function SDL_LoadFunction(handle: Pointer; name: PAnsiChar): Pointer cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_LoadFunction' {$ENDIF};
6036

6037
{**
6038
 *  Unload a shared object from memory.
6039
 *}
6040
procedure SDL_UnloadObject(handle: Pointer) cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_UnloadObject' {$ENDIF};
6041

6042

6043

6044
////////////////////////////////////////////////////////////////////////////////////////////////////////
6045
//////////////////////        SDL_platform.h         ////////////////////////////////////////////////////
6046
////////////////////////////////////////////////////////////////////////////////////////////////////////
6047

6048
{**
6049
 *  Gets the name of the platform.
6050
 *}
6051
function SDL_GetPlatform: PAnsiChar cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_GetPlatform' {$ENDIF};
6052

6053

6054

6055
////////////////////////////////////////////////////////////////////////////////////////////////////////
6056
//////////////////////         SDL_hints.h          ////////////////////////////////////////////////////
6057
////////////////////////////////////////////////////////////////////////////////////////////////////////
6058

6059
const
6060
  SDL_HINT_FRAMEBUFFER_ACCELERATION = 'SDL_FRAMEBUFFER_ACCELERATION';
6061
  SDL_HINT_IDLE_TIMER_DISABLED      = 'SDL_IOS_IDLE_TIMER_DISABLED';
6062
  SDL_HINT_ORIENTATIONS             = 'SDL_IOS_ORIENTATIONS';
6063
  SDL_HINT_RENDER_DRIVER            = 'SDL_RENDER_DRIVER';
6064
  SDL_HINT_RENDER_OPENGL_SHADERS    = 'SDL_RENDER_OPENGL_SHADERS';
6065
  SDL_HINT_RENDER_SCALE_QUALITY     = 'SDL_RENDER_SCALE_QUALITY';
6066
  SDL_HINT_RENDER_VSYNC             = 'SDL_RENDER_VSYNC';
6067

6068
function SDL_SetHint(name : PAnsiChar; value : PAnsiChar): TSDL_Bool cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_SetHint' {$ENDIF};
6069

6070

6071

6072
////////////////////////////////////////////////////////////////////////////////////////////////////////
6073
//////////////////////         SDL_byteorder.h          ////////////////////////////////////////////////
6074
////////////////////////////////////////////////////////////////////////////////////////////////////////
6075

6076
const
6077
  // SDL_byteorder.h constants
6078
  // The two types of endianness
6079
  SDL_LIL_ENDIAN = 1234;
6080
{$EXTERNALSYM SDL_LIL_ENDIAN}
6081
  SDL_BIG_ENDIAN = 4321;
6082
{$EXTERNALSYM SDL_BIG_ENDIAN}
6083

6084
{$IFDEF IA32}
6085
  SDL_BYTEORDER = SDL_LIL_ENDIAN;
6086
  {$EXTERNALSYM SDL_BYTEORDER}
6087
{$ELSE}
6088
  SDL_BYTEORDER = SDL_BIG_ENDIAN;
6089
  {$EXTERNALSYM SDL_BYTEORDER}
6090
{$ENDIF}
6091

6092

6093
////////////////////////////////////////////////////////////////////////////////////////////////////////
6094
//////////////////////       SDL_messagebox.h       ////////////////////////////////////////////////////
6095
////////////////////////////////////////////////////////////////////////////////////////////////////////
6096

6097
const
6098

6099
  //SDL_MessageBoxFlags;
6100
  SDL_MESSAGEBOX_ERROR        = $00000010;   //**< error dialog */
6101
  SDL_MESSAGEBOX_WARNING      = $00000020;   //**< warning dialog */
6102
  SDL_MESSAGEBOX_INFORMATION  = $00000040;   //**< informational dialog */
6103

6104
  //SDL_MessageBoxButtonFlags;
6105
  SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = $00000001;  //**< Marks the default button when return is hit */
6106
  SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = $00000002;  //**< Marks the default button when escape is hit */
6107

6108
function SDL_ShowSimpleMessageBox(flags : Uint32; const title : PAnsiChar; const message : PAnsiChar; window : PSDL_Window): UInt32 cdecl; external SDL_LibName {$IFDEF MACOS} name '_SDL_ShowSimpleMessageBox' {$ENDIF};
6109

6110

6111
////////////////////////////////////////////////////////////////////////////////////////////////////////
6112
//////////////////////            *** KTI ***           ////////////////////////////////////////////////
6113
////////////////////////////////////////////////////////////////////////////////////////////////////////
6114

6115
type
6116
   // SDLPantalla contiene la ventana SDL el Render donde se pinta y el zoom de los ejes X e Y
6117
   PSDLPantalla = ^TSDLPantalla;
6118
   TSDLPantalla = record
6119
      Window   : PSDL_Window;
6120
      Renderer : PSDL_Renderer;
6121
   end;
6122

6123

6124
   EinvalidContainer=class(Exception);
6125

6126

6127
function SDL_Swap32(D: Uint32): Uint32;
6128
function SDLStreamSetup( stream : TStream ) : PSDL_RWops;
6129
function LoadSDLBMPFromStream( Stream : TStream ) : PSDL_Surface;
6130
procedure SaveSDLBMPToStream( SDL_Surface : PSDL_Surface; stream : TStream );
6131
procedure SDLStreamCloseRWops( SDL_RWops : PSDL_RWops );
6132

6133

6134
implementation
6135

6136
////////////////////////////////////////////////////////////////////////////////////////////////////////
6137
//////////////////////        SDL_version.h         ////////////////////////////////////////////////////
6138
////////////////////////////////////////////////////////////////////////////////////////////////////////
6139

6140
procedure SDL_VERSION(x: PSDL_Version);
6141
begin
6142
     x.major := SDL_MAJOR_VERSION;
6143
     x.minor := SDL_MINOR_VERSION;
6144
     x.patch := SDL_PATCHLEVEL;
6145
end;
6146

6147
//******************************************************************************
6148

6149
function SDL_VERSIONNUM(X,Y,Z: UInt32): Cardinal;
6150
begin
6151
     Result := X*1000 + Y*100 + Z;
6152
end;
6153

6154
//******************************************************************************
6155

6156
function SDL_COMPILEDVERSION: Cardinal;
6157
begin
6158
     Result := SDL_VERSIONNUM(SDL_MAJOR_VERSION,
6159
                              SDL_MINOR_VERSION,
6160
                              SDL_PATCHLEVEL);
6161
end;
6162

6163
//******************************************************************************
6164

6165
function SDL_VERSION_ATLEAST(X,Y,Z: Cardinal): Boolean;
6166
begin
6167
     Result := SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X,Y,Z);
6168
end;
6169

6170

6171

6172
////////////////////////////////////////////////////////////////////////////////////////////////////////
6173
//////////////////////        SDL_thread .h         ////////////////////////////////////////////////////
6174
////////////////////////////////////////////////////////////////////////////////////////////////////////
6175

6176
{$IFDEF MSWINDOWS}
6177
   function SDL_CreateThread(fn: TSDL_ThreadFunction; name: PAnsiChar; data: Pointer): PSDL_Thread; overload;
6178
   begin
6179
        Result := SDL_CreateThread(fn,name,data,nil,nil);
6180
   end;
6181
{$ENDIF}
6182

6183
////////////////////////////////////////////////////////////////////////////////////////////////////////
6184
//////////////////////          SDL_rect.h          ////////////////////////////////////////////////////
6185
////////////////////////////////////////////////////////////////////////////////////////////////////////
6186

6187
function SDL_RectEmpty(X: TSDL_Rect): Boolean;
6188
begin
6189
     Result := (X.w <= 0) or (X.h <= 0);
6190
end;
6191

6192
//******************************************************************************
6193

6194
function SDL_RectEquals(A: TSDL_Rect; B: TSDL_Rect): Boolean;
6195
begin
6196
     Result := (A.x = B.x) and (A.y = B.y) and (A.w = B.w) and (A.h = B.h);
6197
end;
6198

6199

6200

6201
////////////////////////////////////////////////////////////////////////////////////////////////////////
6202
//////////////////////         SDL_rwops.h          ////////////////////////////////////////////////////
6203
////////////////////////////////////////////////////////////////////////////////////////////////////////
6204

6205
function SDL_RWsize(ctx: PSDL_RWops): SInt64;
6206
begin
6207
     Result := ctx^.size(ctx);
6208
end;
6209

6210
//******************************************************************************
6211

6212
function SDL_RWseek(ctx: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64;
6213
begin
6214
     Result := ctx^.seek(ctx,offset,whence);
6215
end;
6216

6217
//******************************************************************************
6218

6219
function SDL_RWtell(ctx: PSDL_RWops): SInt64;
6220
var
6221
  offset: Int64;
6222
begin
6223
  offset.lo := 0;
6224
  offset.hi := 0;
6225
     Result := ctx^.seek(ctx, offset, RW_SEEK_CUR);
6226
end;
6227

6228
//******************************************************************************
6229

6230
function SDL_RWread(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
6231
begin
6232
     Result := ctx^.read(ctx, ptr, size, n);
6233
end;
6234

6235
//******************************************************************************
6236

6237
function SDL_RWwrite(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
6238
begin
6239
     Result := ctx^.write(ctx, ptr, size, n);
6240
end;
6241

6242
//******************************************************************************
6243

6244
function SDL_RWclose(ctx: PSDL_RWops): SInt32;
6245
begin
6246
     Result := ctx^.close(ctx);
6247
end;
6248

6249

6250

6251
////////////////////////////////////////////////////////////////////////////////////////////////////////
6252
//////////////////////          SDL_pixels.h         ///////////////////////////////////////////////////
6253
////////////////////////////////////////////////////////////////////////////////////////////////////////
6254

6255
function SDL_PIXELFLAG(X: Cardinal): Boolean;
6256
begin
6257
     Result := (X shr 28) = $0F;
6258
end;
6259

6260
//******************************************************************************
6261

6262
function SDL_PIXELTYPE(X: Cardinal): Boolean;
6263
begin
6264
     Result := (X shr 24) = $0F;
6265
end;
6266

6267
//******************************************************************************
6268

6269
function SDL_PIXELORDER(X: Cardinal): Boolean;
6270
begin
6271
     Result := (X shr 20) = $0F;
6272
end;
6273

6274
//******************************************************************************
6275

6276
function SDL_PIXELLAYOUT(X: Cardinal): Boolean;
6277
begin
6278
     Result := (X shr 16) = $0F;
6279
end;
6280

6281
//******************************************************************************
6282

6283
function SDL_BITSPERPIXEL(X: Cardinal): Boolean;
6284
begin
6285
     Result := (X shr 8) = $FF;
6286
end;
6287

6288
//******************************************************************************
6289

6290
function SDL_IsPixelFormat_FOURCC(format: Variant): Boolean;
6291
begin
6292
     {* The flag is set to 1 because 0x1? is not in the printable ASCII range *}
6293
     Result := format and SDL_PIXELFLAG(format) <> 1;
6294
end;
6295

6296

6297

6298
////////////////////////////////////////////////////////////////////////////////////////////////////////
6299
//////////////////////          SDL_surface.h         //////////////////////////////////////////////////
6300
////////////////////////////////////////////////////////////////////////////////////////////////////////
6301

6302
function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
6303
begin
6304
     Result := SDL_LoadBMP_RW(SDL_RWFromFile(_file, 'rb'), 1);
6305
end;
6306

6307
//******************************************************************************
6308

6309
function SDL_SaveBMP(surface: PSDL_Surface; _file: PAnsiChar): SInt32;
6310
begin
6311
     Result := SDL_SaveBMP_RW(surface, SDL_RWFromFile(_file, 'wb'), 1);
6312
end;
6313

6314
////////////////////////////////////////////////////////////////////////////////////////////////////////
6315
//////////////////////        SDL_video.h           ////////////////////////////////////////////////////
6316
////////////////////////////////////////////////////////////////////////////////////////////////////////
6317

6318
function SDL_WindowPos_IsUndefined(X: Variant): Variant;
6319
begin
6320
     Result := (X and $FFFF0000) = SDL_WINDOWPOS_UNDEFINED_MASK;
6321
end;
6322

6323
//******************************************************************************
6324

6325
function SDL_WindowPos_IsCentered(X: Variant): Variant;
6326
begin
6327
     Result := (X and $FFFF0000) = SDL_WINDOWPOS_CENTERED_MASK;
6328
end;
6329

6330
////////////////////////////////////////////////////////////////////////////////////////////////////////
6331
//////////////////////        SDL_events.h          ////////////////////////////////////////////////////
6332
////////////////////////////////////////////////////////////////////////////////////////////////////////
6333

6334
function SDL_GetEventState(type_: UInt32): UInt8;
6335
begin
6336
     Result := SDL_EventState(type_, SDL_QUERY);
6337
end;
6338

6339
////////////////////////////////////////////////////////////////////////////////////////////////////////
6340
//////////////////////            *** KTI ***           ////////////////////////////////////////////////
6341
////////////////////////////////////////////////////////////////////////////////////////////////////////
6342

6343
function SDL_Swap32(D: Uint32): Uint32;
6344
begin
6345
     Result := ((D shl 24) or ((D shl 8) and $00FF0000) or ((D shr 8) and $0000FF00) or (D shr 24));
6346
end;
6347

6348
//******************************************************************************
6349
function SdlStreamSeek( context : PSDL_RWops; offset : SInt64; whence : SInt32 ) : SInt64; cdecl;
6350
var
6351
   stream : TStream;
6352
   origin : Word;
6353
begin
6354
     stream := TStream(context.unknown);
6355
     if ( stream = nil ) then
6356
        raise EInvalidContainer.Create( 'SDLStreamSeek on nil' );
6357
     case whence of
6358
       0 : origin := soFromBeginning; //Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
6359
       1 : origin := soFromCurrent; //Offset is from the current position in the resource. Seek moves to Position + Offset.
6360
       2 : origin := soFromEnd;
6361
     else
6362
       origin := soFromBeginning; //just in case
6363
     end;
6364
     Result.hi := stream.Seek(offset.hi, origin);
6365
end;
6366

6367
//******************************************************************************
6368
function SDLStreamWrite( context : PSDL_RWops; const Ptr : Pointer;  size : size_t; num : size_t ) : size_t; cdecl;
6369
var
6370
   stream : TStream;
6371

6372
begin
6373
     stream := TStream( context.unknown );
6374
     if (stream = nil) then
6375
       raise EInvalidContainer.Create('SDLStreamWrite on nil');
6376
     try
6377
       Result := stream.Write(Ptr^, Size * num) div size;
6378
     except
6379
       Result := 0;
6380
     end;
6381
end;
6382

6383
//******************************************************************************
6384
function SdlStreamRead( context : PSDL_RWops; Ptr : Pointer; size : size_t; maxnum : size_t ) : size_t; cdecl;
6385
var
6386
   stream : TStream;
6387
begin
6388
     stream := TStream( context.unknown );
6389
     if ( stream = nil ) then
6390
       raise EInvalidContainer.Create('SDLStreamRead on nil');
6391
     try
6392
       Result := stream.Read(Ptr^, Size * maxnum) div size;
6393
     except
6394
       Result := 0;
6395
     end;
6396
end;
6397

6398
//******************************************************************************
6399
function SDLStreamClose( context : PSDL_RWops ) : Integer; cdecl;
6400
var
6401
   stream : TStream;
6402
begin
6403
     stream := TStream( context.unknown );
6404
     if (stream = nil) then
6405
        raise EInvalidContainer.Create( 'SDLStreamClose on nil' );
6406
     stream.Free;
6407
     Result := 1;
6408
end;
6409

6410
//******************************************************************************
6411
function SDLStreamSetup( stream : TStream ) : PSDL_RWops;
6412
begin
6413
     result := SDL_AllocRW;
6414
     if ( result = nil ) then
6415
       raise EInvalidContainer.Create( 'could not create SDLStream on nil' );
6416
     result.unknown := TUnknown( stream );
6417
     result.seek    := SDLStreamSeek;
6418
     result.read    := SDLStreamRead;
6419
     result.write   := SDLStreamWrite;
6420
     result.close   := SDLStreamClose;
6421
     Result._type   := 2; // TUnknown
6422
end;
6423

6424
//******************************************************************************
6425
procedure SDLStreamCloseRWops(SDL_RWops : PSDL_RWops);
6426
begin
6427
     // this only closes the SDL part of the stream, not the context
6428
     SDL_FreeRW(SDL_RWops);
6429
end;
6430

6431
//******************************************************************************
6432
function LoadSDLBMPFromStream(stream : TStream) : PSDL_Surface;
6433
var
6434
   SDL_RWops : PSDL_RWops;
6435
begin
6436
     SDL_RWops := SDLStreamSetup( stream );
6437
     result := SDL_LoadBMP_RW( SDL_RWops, 0 );
6438
     SDLStreamCloseRWops( SDL_RWops );
6439
end;
6440

6441
//******************************************************************************
6442

6443
procedure SaveSDLBMPToStream(SDL_Surface : PSDL_Surface; stream : TStream);
6444
var
6445
   SDL_RWops : PSDL_RWops;
6446
begin
6447
     SDL_RWops := SDLStreamSetup( stream );
6448
     SDL_SaveBMP_RW( SDL_Surface, SDL_RWops, 0 );
6449
     SDLStreamCloseRWops( SDL_RWops );
6450
     stream.Position := 0;
6451
end;
6452

6453
end.
6454

6455

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.