DEADSOFTWARE

added opengl and sdl2 wrappers to allegro (WIP)
[d2df-sdl.git] / src / wrappers / sdl2 / sdl2stub.inc
1 {$INCLUDE ../shared/a_modes.inc}
2 {$SCOPEDENUMS OFF}
4 interface
6 {$I sdltype.inc}
7 {$I sdlscancode.inc}
9 const
10 SDL_HAT_CENTERED = $00;
11 SDL_HAT_UP = $01;
12 SDL_HAT_RIGHT = $02;
13 SDL_HAT_DOWN = $04;
14 SDL_HAT_LEFT = $08;
15 SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
16 SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
17 SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
18 SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
20 const
21 AUDIO_U8 = $0008;
22 AUDIO_S8 = $8008;
23 AUDIO_U16LSB = $0010;
24 AUDIO_S16LSB = $8010;
25 AUDIO_U16MSB = $1010;
26 AUDIO_S16MSB = $9010;
27 AUDIO_U16 = AUDIO_U16LSB;
28 AUDIO_S16 = AUDIO_S16LSB;
30 const
31 SDL_TOUCH_MOUSEID = UInt32(-1);
33 type
34 PSDL_Window = ^TSDL_Window;
35 TSDL_Window = record end;
37 PSDL_Joystick = Pointer;
38 TSDL_JoystickGUID = record
39 data: array[0..15] of UInt8;
40 end;
41 TSDL_JoystickID = SInt32;
43 PSDL_RWops = ^TSDL_RWops;
45 TSize = function(context: PSDL_RWops): SInt64; cdecl;
46 TSeek = function(context: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64; cdecl;
47 TRead = function(context: PSDL_RWops; ptr: Pointer; size: size_t; maxnum: size_t): size_t; cdecl;
48 TWrite = function(context: PSDL_RWops; const ptr: Pointer; size: size_t; num: size_t): size_t; cdecl;
49 TClose = function(context: PSDL_RWops): SInt32; cdecl;
51 TStdio = record
52 autoclose: TSDL_Bool;
53 fp: file;
54 end;
56 TMem = record
57 base: PUInt8;
58 here: PUInt8;
59 stop: PUInt8;
60 end;
62 TUnknown = record
63 data1: Pointer;
64 end;
66 TSDL_RWops = packed record
67 size: TSize;
68 seek: TSeek;
69 read: TRead;
70 write: TWrite;
71 close: TClose;
72 _type: UInt32;
73 case Integer of
74 0: (stdio: TStdio);
75 1: (mem: TMem);
76 2: (unknown: TUnknown);
77 {$IFDEF ANDROID}
78 3: (androidio: TAndroidIO);
79 {$ENDIF}
80 {$IFDEF WINDOWS}
81 3: (windowsio: TWindowsIO);
82 {$ENDIF}
83 end;
85 PSDL_TouchID = ^TSDL_TouchID;
86 TSDL_TouchID = SInt64;
88 PSDL_FingerID = ^TSDL_FingerID;
89 TSDL_FingerID = SInt64;
92 const
93 { Touch events }
94 SDL_FINGERDOWN = $700;
95 SDL_FINGERUP = $701;
96 SDL_FINGERMOTION = $702;
98 type
99 TSDL_TouchFingerEvent = record
100 type_: UInt32;
101 timestamp: UInt32;
102 touchId: TSDL_TouchID;
103 fingerId: TSDL_FingerID;
104 x, y, dx, dy: Float;
105 pressure: Float;
106 end;
109 const
110 SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000;
111 SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_MASK or 0;
113 type
114 PSDL_DisplayMode = ^TSDL_DisplayMode;
115 TSDL_DisplayMode = record
116 format: UInt32;
117 w: SInt32;
118 h: SInt32;
119 refresh_rate: SInt32;
120 driverdata: Pointer;
121 end;
123 TSDL_GLContext = Pointer;
125 const
126 SDL_WINDOW_FULLSCREEN = $00000001;
127 SDL_WINDOW_OPENGL = $00000002;
128 SDL_WINDOW_SHOWN = $00000004;
129 SDL_WINDOW_HIDDEN = $00000008;
130 SDL_WINDOW_BORDERLESS = $00000010;
131 SDL_WINDOW_RESIZABLE = $00000020;
132 SDL_WINDOW_MINIMIZED = $00000040;
133 SDL_WINDOW_MAXIMIZED = $00000080;
134 SDL_WINDOW_INPUT_GRABBED = $00000100;
135 SDL_WINDOW_INPUT_FOCUS = $00000200;
136 SDL_WINDOW_MOUSE_FOCUS = $00000400;
137 SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN or $00001000;
138 SDL_WINDOW_FOREIGN = $00000800;
139 SDL_WINDOW_ALLOW_HIGHDPI = $00002000;
141 SDL_WINDOWEVENT_EXPOSED = 3;
142 SDL_WINDOWEVENT_MOVED = 4;
143 SDL_WINDOWEVENT_RESIZED = 5;
144 SDL_WINDOWEVENT_MINIMIZED = 7;
145 SDL_WINDOWEVENT_MAXIMIZED = 8;
146 SDL_WINDOWEVENT_RESTORED = 9;
147 SDL_WINDOWEVENT_FOCUS_GAINED = 12;
148 SDL_WINDOWEVENT_FOCUS_LOST = 13;
150 SDL_DISABLE = 0;
151 SDL_ENABLE = 1;
153 SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
155 SDL_FIRSTEVENT = 0;
156 SDL_COMMONEVENT = 1;
157 SDL_QUITEV = $100;
158 SDL_WINDOWEVENT = $200;
159 SDL_KEYDOWN = $300;
160 SDL_KEYUP = $301;
161 //SDL_TEXTEDITING = $302;
162 SDL_TEXTINPUT = $303;
164 type
165 TSDL_WindowEvent = record
166 type_: UInt32; // SDL_WINDOWEVENT
167 timestamp: UInt32;
168 windowID: UInt32; // The associated window
169 event: UInt8; // SDL_WindowEventID
170 padding1: UInt8;
171 padding2: UInt8;
172 padding3: UInt8;
173 data1: SInt32; // event dependent data
174 data2: SInt32; // event dependent data
175 end;
177 PSDL_Keysym = ^TSDL_Keysym;
178 TSDL_Keysym = record
179 scancode: TSDL_ScanCode; // SDL physical key code - see SDL_Scancode for details
180 sym: TSDL_KeyCode; // SDL virtual key code - see SDL_Keycode for details
181 _mod: UInt16; // current key modifiers
182 unicode: UInt32; // (deprecated) use SDL_TextInputEvent instead
183 end;
185 TSDL_KeyboardEvent = record
186 type_: UInt32; // SDL_KEYDOWN or SDL_KEYUP
187 timestamp: UInt32;
188 windowID: UInt32; // The window with keyboard focus, if any
189 state: UInt8; // SDL_PRESSED or SDL_RELEASED
190 _repeat: UInt8; // Non-zero if this is a key repeat
191 padding2: UInt8;
192 padding3: UInt8;
193 keysym: TSDL_KeySym; // The key that was pressed or released
194 end;
196 TSDL_TextInputEvent = record
197 type_: UInt32; // SDL_TEXTINPUT
198 timestamp: UInt32;
199 windowID: UInt32; // The window with keyboard focus, if any
200 text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char; // The input text
201 end;
203 TSDL_QuitEvent = record
204 type_: UInt32; // SDL_QUIT
205 timestamp: UInt32;
206 end;
208 PSDL_Event = ^TSDL_Event;
209 TSDL_Event = record
210 case Integer of
211 0: (type_: UInt32);
212 //SDL_COMMONEVENT: (common: TSDL_CommonEvent);
213 SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
214 SDL_KEYUP,
215 SDL_KEYDOWN: (key: TSDL_KeyboardEvent);
216 //SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
217 SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
218 //SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
219 //SDL_MOUSEBUTTONUP,
220 //SDL_MOUSEBUTTONDOWN: (button: TSDL_MouseButtonEvent);
221 //SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
222 //SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
223 //SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
224 //SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
225 //SDL_JOYBUTTONDOWN,
226 //SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
227 //SDL_JOYDEVICEADDED,
228 //SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
229 //SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
230 //SDL_CONTROLLERBUTTONUP,
231 //SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
232 //SDL_CONTROLLERDEVICEADDED,
233 //SDL_CONTROLLERDEVICEREMOVED,
234 //SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
235 //SDL_AUDIODEVICEADDED,
236 //SDL_AUDIODEVICEREMOVED: (adevice: TSDL_AudioDeviceEvent);
237 SDL_QUITEV: (quit: TSDL_QuitEvent);
238 //SDL_USEREVENT: (user: TSDL_UserEvent);
239 //SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
240 SDL_FINGERDOWN,
241 SDL_FINGERUP,
242 SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
243 //SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
244 //SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
245 //SDL_DROPFILE: (drop: TSDL_DropEvent);
246 end;
248 const
249 SDL_GL_RED_SIZE = 0;
250 SDL_GL_GREEN_SIZE = 1;
251 SDL_GL_BLUE_SIZE = 2;
252 SDL_GL_ALPHA_SIZE = 3;
253 SDL_GL_BUFFER_SIZE = 4;
254 SDL_GL_DOUBLEBUFFER = 5;
255 SDL_GL_DEPTH_SIZE = 6;
256 SDL_GL_STENCIL_SIZE = 7;
257 SDL_GL_ACCUM_RED_SIZE = 8;
258 SDL_GL_ACCUM_GREEN_SIZE = 9;
259 SDL_GL_ACCUM_BLUE_SIZE = 10;
260 SDL_GL_ACCUM_ALPHA_SIZE = 11;
261 SDL_GL_STEREO = 12;
262 SDL_GL_MULTISAMPLEBUFFERS = 13;
263 SDL_GL_MULTISAMPLESAMPLES = 14;
264 SDL_GL_ACCELERATED_VISUAL = 15;
265 SDL_GL_RETAINED_BACKING = 16;
266 SDL_GL_CONTEXT_MAJOR_VERSION = 17;
267 SDL_GL_CONTEXT_MINOR_VERSION = 18;
268 SDL_GL_CONTEXT_EGL = 19;
269 SDL_GL_CONTEXT_FLAGS = 20;
270 SDL_GL_CONTEXT_PROFILE_MASK = 21;
271 SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22;
272 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE = 23;
274 type
275 TSDL_GLattr = DWord;
277 const
278 SDL_INIT_TIMER = $00000001;
279 SDL_INIT_AUDIO = $00000010;
280 SDL_INIT_VIDEO = $00000020;
281 SDL_INIT_JOYSTICK = $00000200;
282 SDL_INIT_HAPTIC = $00001000;
283 SDL_INIT_GAMECONTROLLER = $00002000; //turn on game controller also implicitly does JOYSTICK
284 SDL_INIT_NOPARACHUTE = $00100000; //Don't catch fatal signals
285 SDL_INIT_EVERYTHING = SDL_INIT_TIMER or SDL_INIT_AUDIO or
286 SDL_INIT_VIDEO or SDL_INIT_JOYSTICK or
287 SDL_INIT_HAPTIC or SDL_INIT_GAMECONTROLLER;
289 SDL_HINT_ACCELEROMETER_AS_JOYSTICK = 'SDL_ACCELEROMETER_AS_JOYSTICK';
291 /// MACRO ///
292 function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
294 /// FUNCTIONS ///
296 function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32;
297 function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32;
299 function SDL_NumJoysticks: SInt32;
300 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick;
301 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar;
302 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32;
303 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32;
304 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32;
305 procedure SDL_JoystickClose(joystick: PSDL_Joystick);
306 procedure SDL_JoystickUpdate;
307 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8;
308 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16;
309 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8;
311 function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar;
313 function SDL_GetPerformanceCounter: UInt64;
314 function SDL_GetPerformanceFrequency: UInt64;
316 function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops;
317 function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops;
319 function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32;
320 function SDL_IsTextInputActive: TSDL_Bool;
321 procedure SDL_StartTextInput;
322 procedure SDL_StopTextInput;
323 function SDL_GetNumTouchDevices: SInt32;
325 function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
326 function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode;
328 procedure SDL_DestroyWindow(window: PSDL_Window);
329 procedure SDL_GL_DeleteContext(context: TSDL_GLContext);
330 procedure SDL_RestoreWindow(window: PSDL_Window);
331 procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32);
332 function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window;
333 function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32;
334 function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32;
335 procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt);
336 function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32;
337 function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
339 function SDL_ShowCursor(toggle: SInt32): SInt32;
340 procedure SDL_Delay(ms: UInt32);
341 procedure SDL_GL_SwapWindow(window: PSDL_Window);
343 function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext;
344 function SDL_GetTicks: UInt32;
346 function SDL_PushEvent(event: PSDL_Event): SInt32;
347 function SDL_PollEvent(event: PSDL_Event): SInt32;
348 function SDL_GL_SetSwapInterval(interval: SInt32): SInt32;
349 function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32;
350 function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32;
352 function SDL_GetError: PAnsiChar;
354 function SDL_Init(flags: UInt32): SInt32;
355 procedure SDL_Quit();
356 function SDL_SetHint( const name: PChar; const value: PChar) : boolean;
358 implementation
359 /// MACRO ///
361 function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
362 begin
363 Result := (X shr 8) and $FF;
364 end;
366 /// FUNCTIONS ////
368 function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32;
369 begin
370 result := 0
371 end;
373 function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32;
374 begin
375 result := 0
376 end;
379 function SDL_NumJoysticks: SInt32;
380 begin
381 result := 0
382 end;
384 function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick;
385 begin
386 result := nil
387 end;
389 function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar;
390 begin
391 result := ''
392 end;
394 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32;
395 begin
396 result := 0
397 end;
399 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32;
400 begin
401 result := 0
402 end;
404 function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32;
405 begin
406 result := 0
407 end;
409 procedure SDL_JoystickClose(joystick: PSDL_Joystick);
410 begin
411 end;
413 procedure SDL_JoystickUpdate;
414 begin
415 end;
417 function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8;
418 begin
419 result := 0
420 end;
422 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16;
423 begin
424 result := 0
425 end;
427 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8;
428 begin
429 result := 0
430 end;
435 function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar;
436 begin
437 result := ''
438 end;
443 function SDL_GetPerformanceCounter: UInt64;
444 begin
445 result := 0
446 end;
448 function SDL_GetPerformanceFrequency: UInt64;
449 begin
450 result := 0
451 end;
455 function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops;
456 begin
457 result := nil
458 end;
460 function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops;
461 begin
462 result := nil
463 end;
468 function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32;
469 begin
470 result := 0
471 end;
473 function SDL_IsTextInputActive: TSDL_Bool;
474 begin
475 result := SDL_FALSE
476 end;
478 procedure SDL_StartTextInput;
479 begin
480 end;
482 procedure SDL_StopTextInput;
483 begin
484 end;
486 function SDL_GetNumTouchDevices: SInt32;
487 begin
488 result := 0
489 end;
493 function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
494 begin
495 result := 0
496 end;
498 function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode;
499 begin
500 result := nil
501 end;
503 procedure SDL_DestroyWindow(window: PSDL_Window);
504 begin
505 end;
507 procedure SDL_GL_DeleteContext(context: TSDL_GLContext);
508 begin
509 end;
511 procedure SDL_RestoreWindow(window: PSDL_Window);
512 begin
513 end;
515 procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32);
516 begin
517 end;
519 function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window;
520 begin
521 result := nil
522 end;
524 function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32;
525 begin
526 result := 0
527 end;
529 function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32;
530 begin
531 result := 0
532 end;
534 procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt);
535 begin
536 end;
538 function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32;
539 begin
540 result := 0
541 end;
543 function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32;
544 begin
545 result := 0
546 end;
548 function SDL_ShowCursor(toggle: SInt32): SInt32;
549 begin
550 result := 0
551 end;
553 procedure SDL_Delay(ms: UInt32);
554 begin
555 end;
557 procedure SDL_GL_SwapWindow(window: PSDL_Window);
558 begin
559 end;
561 function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext;
562 begin
563 result := nil
564 end;
566 function SDL_GetTicks: UInt32;
567 begin
568 result := 0
569 end;
571 function SDL_PushEvent(event: PSDL_Event): SInt32;
572 begin
573 result := 0
574 end;
576 function SDL_PollEvent(event: PSDL_Event): SInt32;
577 begin
578 result := 0
579 end;
581 function SDL_GL_SetSwapInterval(interval: SInt32): SInt32;
582 begin
583 result := 0
584 end;
586 function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32;
587 begin
588 result := 0
589 end;
591 function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32;
592 begin
593 result := 0
594 end;
596 function SDL_GetError: PAnsiChar;
597 begin
598 result := ''
599 end;
601 function SDL_Init(flags: UInt32): SInt32;
602 begin
603 result := 0
604 end;
606 procedure SDL_Quit();
607 begin
608 end;
610 function SDL_SetHint( const name: PChar; const value: PChar) : boolean;
611 begin
612 result := false
613 end;