diff --git a/compile_wasm.py b/compile_wasm.py index 663ef19..da42783 100644 --- a/compile_wasm.py +++ b/compile_wasm.py @@ -2,11 +2,47 @@ import os import ntpath import sys +def compile(sources, output): + files = [] + # r=root, d=directories, f = files + for path in sources: + for r, d, f in os.walk(path): + for file in f: + if ntpath.basename(file) != 'win_dll.d': + filename, file_extension = os.path.splitext(file) + if file_extension == '.d' and filename != 'package': + files.append(os.path.join(r, file)) + + ldc_cmd = 'ldc2 ' + shared_flags + ldc_flags + '-oq -mtriple=wasm32-unknown-unknown-wasm -betterC -L-allow-undefined --output-bc --od=.bc --singleobj --checkaction=C --of=' + output + ' ' + + for path in sources: + ldc_cmd += '-I' + path + ' ' + + for path in import_paths: + ldc_cmd += '-I' + path + ' ' + + for f in files: + ldc_cmd += f + ' ' + + print ldc_cmd + + if os.system(ldc_cmd): + exit(0) + print + shared_flags = '' clean = 0 +emc_flags = '' +ldc_flags = '' +import_paths = ['source','tests'] +build_tests = 0 -for arg in sys.argv: - if(arg == '-O3'): +for arg in sys.argv[1:]: + if(arg == '-release'): + ldc_flags += '-release ' + elif(arg == '-enable-inlining'): + ldc_flags += '-enable-inlining ' + elif(arg == '-O3'): shared_flags += '-O3 ' elif(arg == '-O2'): shared_flags += '-O2 ' @@ -20,71 +56,30 @@ for arg in sys.argv: shared_flags += '-Oz ' elif(arg == '-g'): shared_flags += '-g ' - elif(arg == '--clean'): - clean = 1 - -if clean == 1: - for path in ['bc']: - for r, d, f in os.walk(path): - for file in f: - filename, file_extension = os.path.splitext(file) - if file_extension == '.bc': - print('remove ' + os.path.join(r, file)) - os.remove(os.path.join(r, file)) - exit() - - -paths = ['tests', 'source'] - -files = [] -# r=root, d=directories, f = files -for path in paths: - for r, d, f in os.walk(path): - for file in f: - if ntpath.basename(file) != 'win_dll.d': - filename, file_extension = os.path.splitext(file) - if file_extension == '.d': - files.append(os.path.join(r, file)) - - -print('files:') -for f in files: - print(f) -print - -ldc_cmd = 'ldc2 ' + shared_flags + '-mtriple=wasm32-unknown-unknown-wasm -betterC -L-allow-undefined --output-bc --od=bc --checkaction=C ' - -for path in paths: - ldc_cmd += '-I' + path + ' ' + elif(arg == '--build-tests'): + build_tests = 1 + elif(arg == '--llvm-lto'): + emc_flags += '--llvm-lto 3 ' + elif(arg == '--simd'): + emc_flags += '-s SIMD=1 ' + elif(arg == '-opt'): + shared_flags += '-O3 ' + ldc_flags += '-release -enable-inlining ' + emc_flags += '--llvm-lto 3 -s SIMD=1 ' + else: + print('unknown argument: ' + arg) + exit() -for f in files: - ldc_cmd += f + ' ' - -print ldc_cmd - -os.system(ldc_cmd) - -print - -files = [] -# r=root, d=directories, f = files -for path in ['bc']: - for r, d, f in os.walk(path): - for file in f: - filename, file_extension = os.path.splitext(file) - if file_extension == '.bc': - files.append(os.path.join(r, file)) +compile(['source'], 'ecs.bc') + +if build_tests == 0: + exit(0) + +compile(['tests'], 'tests.bc') - -print('BC files:') -for f in files: - print(f) -print - -emcc_cmd = 'emcc -v ' + shared_flags + '-s ALLOW_MEMORY_GROWTH=1 -s MALLOC=dlmalloc -s WASM=1 -o index.html ' - -for f in files: - emcc_cmd += f + ' ' +emcc_cmd = 'emcc -v ' + shared_flags + emc_flags + '-s ALLOW_MEMORY_GROWTH=1 -s MALLOC=dlmalloc -s WASM=1 -o index.html ' + +emcc_cmd += 'ecs.bc tests.bc' print emcc_cmd diff --git a/demos/.gitignore b/demos/.gitignore new file mode 100644 index 0000000..c799805 --- /dev/null +++ b/demos/.gitignore @@ -0,0 +1,12 @@ +* +!*/ +!**/dub.json +!libs/ +!*.dll +!utils/**/*.d +!simple/**/*.d +!launcher/**/*.d +!assets/** +!external/**/*.d +!.gitignore +!compile_wasm.py \ No newline at end of file diff --git a/demos/SDL2.dll b/demos/SDL2.dll new file mode 100644 index 0000000..0edb386 Binary files /dev/null and b/demos/SDL2.dll differ diff --git a/demos/SDL2_image.dll b/demos/SDL2_image.dll new file mode 100644 index 0000000..d701655 Binary files /dev/null and b/demos/SDL2_image.dll differ diff --git a/demos/assets/textures/buckler.png b/demos/assets/textures/buckler.png new file mode 100644 index 0000000..243f747 Binary files /dev/null and b/demos/assets/textures/buckler.png differ diff --git a/demos/compile_wasm.py b/demos/compile_wasm.py new file mode 100644 index 0000000..a650b9e --- /dev/null +++ b/demos/compile_wasm.py @@ -0,0 +1,93 @@ +import os +import ntpath +import sys + +def compile(sources, output): + files = [] + # r=root, d=directories, f = files + for path in sources: + for r, d, f in os.walk(path): + for file in f: + if ntpath.basename(file) != 'win_dll.d': + filename, file_extension = os.path.splitext(file) + if file_extension == '.d' and filename != 'package': + files.append(os.path.join(r, file)) + + ldc_cmd = 'ldc2 ' + shared_flags + ldc_flags + '-oq -mtriple=wasm32-unknown-unknown-wasm -betterC -L-allow-undefined --output-bc --od=.bc --singleobj --checkaction=C --of=' + output + ' ' + + for path in sources: + ldc_cmd += '-I' + path + ' ' + + for path in import_paths: + ldc_cmd += '-I' + path + ' ' + + for f in files: + ldc_cmd += f + ' ' + + print ldc_cmd + + if os.system(ldc_cmd): + exit(0) + print + + +shared_flags = '' +clean = 0 +demo = 0 +sources = ['tests', 'source'] +emc_flags = '-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="[\'png\']" --preload-file assets ' +ldc_flags = '--d-version=SDL_209 --d-version=BindSDL_Static --d-version=BindSDL_Image ' +import_paths = ['external/imports', '../source', 'utils/source'] + +for arg in sys.argv[1:]: + if(arg == '-release'): + ldc_flags += '-release ' + elif(arg == '-enable-inlining'): + ldc_flags += '-enable-inlining ' + elif(arg == '-O3'): + shared_flags += '-O3 ' + elif(arg == '-O2'): + shared_flags += '-O2 ' + elif(arg == '-O1'): + shared_flags += '-O1 ' + elif(arg == '-O0'): + shared_flags += '-O0 ' + elif(arg == '-Os'): + shared_flags += '-Os ' + elif(arg == '-Oz'): + shared_flags += '-Oz ' + elif(arg == '-g'): + shared_flags += '-g ' + elif(arg == '--llvm-lto'): + emc_flags += '--llvm-lto 3 ' + elif(arg == '--simd'): + emc_flags += '-s SIMD=1 ' + elif(arg == '-opt'): + shared_flags += '-O3 ' + ldc_flags += '-release -enable-inlining ' + emc_flags += '--llvm-lto 3 -s SIMD=1 ' + elif(arg == '--clean'): + clean = 1 + elif(arg == '--demo=simple'): + demo = 0 + else: + print('unknown argument: ' + arg) + exit() + +compile(['external/imports/bindbc/sdl'], 'bindbc-sdl.bc') +compile(['utils/source'], 'utils.bc') +compile(['simple/source'], 'demo.bc') + +if clean or os.path.exists('../ecs.bc') == 0 or os.path.isfile('../ecs.bc') == 0: + compile(['../source'], '../ecs.bc') + +emcc_cmd = 'emcc -v ' + shared_flags + emc_flags + '-s ALLOW_MEMORY_GROWTH=1 -s MALLOC=dlmalloc -s WASM=1 -o index.html ' + +emcc_cmd += '../ecs.bc ' +emcc_cmd += 'utils.bc ' +emcc_cmd += 'bindbc-sdl.bc ' +emcc_cmd += 'demo.bc ' + +print emcc_cmd + +os.system(emcc_cmd) diff --git a/demos/external/imports/bindbc/sdl/bind/package.d b/demos/external/imports/bindbc/sdl/bind/package.d new file mode 100644 index 0000000..1a6697c --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/package.d @@ -0,0 +1,46 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind; + +public +import bindbc.sdl.bind.sdl, + bindbc.sdl.bind.sdlassert, + bindbc.sdl.bind.sdlaudio, + bindbc.sdl.bind.sdlblendmode, + bindbc.sdl.bind.sdlclipboard, + bindbc.sdl.bind.sdlcpuinfo, + bindbc.sdl.bind.sdlerror, + bindbc.sdl.bind.sdlevents, + bindbc.sdl.bind.sdlfilesystem, + bindbc.sdl.bind.sdlgamecontroller, + bindbc.sdl.bind.sdlgesture, + bindbc.sdl.bind.sdlhaptic, + bindbc.sdl.bind.sdlhints, + bindbc.sdl.bind.sdljoystick, + bindbc.sdl.bind.sdlkeyboard, + bindbc.sdl.bind.sdlkeycode, + bindbc.sdl.bind.sdlloadso, + bindbc.sdl.bind.sdllog, + bindbc.sdl.bind.sdlmessagebox, + bindbc.sdl.bind.sdlmouse, + bindbc.sdl.bind.sdlpixels, + bindbc.sdl.bind.sdlplatform, + bindbc.sdl.bind.sdlpower, + bindbc.sdl.bind.sdlrect, + bindbc.sdl.bind.sdlrender, + bindbc.sdl.bind.sdlrwops, + bindbc.sdl.bind.sdlscancode, + bindbc.sdl.bind.sdlshape, + bindbc.sdl.bind.sdlstdinc, + bindbc.sdl.bind.sdlsurface, + bindbc.sdl.bind.sdlsystem, + bindbc.sdl.bind.sdlsyswm, + bindbc.sdl.bind.sdltimer, + bindbc.sdl.bind.sdltouch, + bindbc.sdl.bind.sdlversion, + bindbc.sdl.bind.sdlvideo, + bindbc.sdl.bind.sdlvulkan; \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdl.d b/demos/external/imports/bindbc/sdl/bind/sdl.d new file mode 100644 index 0000000..7b384ef --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdl.d @@ -0,0 +1,69 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdl; + +import bindbc.sdl.config; + +static if(sdlSupport >= SDLSupport.sdl209) { + enum : uint { + SDL_INIT_TIMER = 0x00000001, + SDL_INIT_AUDIO = 0x00000010, + SDL_INIT_VIDEO = 0x00000020, + SDL_INIT_JOYSTICK = 0x00000200, + SDL_INIT_HAPTIC = 0x00001000, + SDL_INIT_GAMECONTROLLER = 0x00002000, + SDL_INIT_EVENTS = 0x00004000, + SDL_INIT_SENSOR = 0x00008000, + SDL_INIT_NOPARACHUTE = 0x00100000, + SDL_INIT_EVERYTHING = + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | + SDL_INIT_EVENTS | SDL_INIT_SENSOR + } +} else { + enum : uint { + SDL_INIT_TIMER = 0x00000001, + SDL_INIT_AUDIO = 0x00000010, + SDL_INIT_VIDEO = 0x00000020, + SDL_INIT_JOYSTICK = 0x00000200, + SDL_INIT_HAPTIC = 0x00001000, + SDL_INIT_GAMECONTROLLER = 0x00002000, + SDL_INIT_EVENTS = 0x00004000, + SDL_INIT_NOPARACHUTE = 0x00100000, + SDL_INIT_EVERYTHING = + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | + SDL_INIT_EVENTS + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_Init(uint); + int SDL_InitSubSystem(uint); + void SDL_QuitSubSystem(uint); + uint SDL_WasInit(uint); + void SDL_Quit(); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_Init = int function(uint); + alias pSDL_InitSubSystem = int function(uint); + alias pSDL_QuitSubSystem = void function(uint); + alias pSDL_WasInit = uint function(uint); + alias pSDL_Quit = void function(); + } + + __gshared { + pSDL_Init SDL_Init; + pSDL_InitSubSystem SDL_InitSubSystem; + pSDL_QuitSubSystem SDL_QuitSubSystem; + pSDL_WasInit SDL_WasInit; + pSDL_Quit SDL_Quit; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlassert.d b/demos/external/imports/bindbc/sdl/bind/sdlassert.d new file mode 100644 index 0000000..784e0e8 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlassert.d @@ -0,0 +1,70 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlassert; + +import bindbc.sdl.config; + +enum SDL_assert_state : uint { + SDL_ASSERTION_RETRY = 0, + SDL_ASSERTION_BREAK = 1, + SDL_ASSERTION_ABORT = 2, + SDL_ASSERTION_IGNORE = 3, + SDL_ASSERTION_ALWAYS_IGNORE = 4 +} +alias SDL_AssertState = SDL_assert_state; +mixin(expandEnum!SDL_AssertState); + +struct SDL_assert_data { + int always_ignore; + uint trigger_count; + const(char) *condition; + const(char) *filename; + int linenum; + const(char) *function_; + const(SDL_assert_data) *next; +} +alias SDL_AssertData = SDL_assert_data; + +extern(C) nothrow alias SDL_AssertionHandler = SDL_AssertState function(const(SDL_AssertData)* data, void* userdata); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_SetAssertionHandler(SDL_AssertionHandler,void*); + const(SDL_assert_data)* SDL_GetAssertionReport(); + void SDL_ResetAssertionReport(); + + static if(sdlSupport >= SDLSupport.sdl202) { + SDL_AssertionHandler SDL_GetAssertionHandler(void**); + SDL_AssertionHandler SDL_GetDefaultAssertionHandler(); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_SetAssertionHandler = void function(SDL_AssertionHandler,void*); + alias pSDL_GetAssertionReport = const(SDL_assert_data)* function(); + alias pSDL_ResetAssertionReport = void function(); + } + + __gshared { + pSDL_SetAssertionHandler SDL_SetAssertionHandler; + pSDL_GetAssertionReport SDL_GetAssertionReport; + pSDL_ResetAssertionReport SDL_ResetAssertionReport; + } + + static if(sdlSupport >= SDLSupport.sdl202) { + extern(C) @nogc nothrow { + alias pSDL_GetAssertionHandler = SDL_AssertionHandler function(void**); + alias pSDL_GetDefaultAssertionHandler = SDL_AssertionHandler function(); + } + + __gshared { + pSDL_GetAssertionHandler SDL_GetAssertionHandler; + pSDL_GetDefaultAssertionHandler SDL_GetDefaultAssertionHandler; + } + } +} diff --git a/demos/external/imports/bindbc/sdl/bind/sdlaudio.d b/demos/external/imports/bindbc/sdl/bind/sdlaudio.d new file mode 100644 index 0000000..3cb37d8 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlaudio.d @@ -0,0 +1,283 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlaudio; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlrwops; + +enum : ushort { + SDL_AUDIO_MASK_BITSIZE = 0xFF, + SDL_AUDIO_MASK_DATATYPE = 1<<8, + SDL_AUDIO_MASK_ENDIAN = 1<<12, + SDL_AUDIO_MASK_SIGNED = 1<<15, +} + +enum SDL_AudioFormat : ushort { + AUDIO_U8 = 0x0008, + AUDIO_S8 = 0x8008, + AUDIO_U16LSB = 0x0010, + AUDIO_S16LSB = 0x8010, + AUDIO_U16MSB = 0x1010, + AUDIO_S16MSB = 0x9010, + AUDIO_U16 = AUDIO_U16LSB, + AUDIO_S16 = AUDIO_S16LSB, + AUDIO_S32LSB = 0x8020, + AUDIO_S32MSB = 0x9020, + AUDIO_S32 = AUDIO_S32LSB, + AUDIO_F32LSB = 0x8120, + AUDIO_F32MSB = 0x9120, + AUDIO_F32 = AUDIO_F32LSB, +} +mixin(expandEnum!SDL_AudioFormat); + +version(LittleEndian) { + alias AUDIO_U16SYS = AUDIO_U16LSB; + alias AUDIO_S16SYS = AUDIO_S16LSB; + alias AUDIO_S32SYS = AUDIO_S32LSB; + alias AUDIO_F32SYS = AUDIO_F32LSB; +} else { + alias AUDIO_U16SYS = AUDIO_U16MSB; + alias AUDIO_S16SYS = AUDIO_S16MSB; + alias AUDIO_S32SYS = AUDIO_S32MSB; + alias AUDIO_F32SYS = AUDIO_F32MSB; +} + +enum SDL_AUDIO_BITSIZE(SDL_AudioFormat x) = x & SDL_AUDIO_MASK_BITSIZE; +enum SDL_AUDIO_ISFLOAT(SDL_AudioFormat x) = x & SDL_AUDIO_MASK_DATATYPE; +enum SDL_AUDIO_ISBIGENDIAN(SDL_AudioFormat x) = x & SDL_AUDIO_MASK_ENDIAN; +enum SDL_AUDIO_ISSIGNED(SDL_AudioFormat x) = x & SDL_AUDIO_MASK_SIGNED; +enum SDL_AUDIO_ISINT(SDL_AudioFormat x) = !SDL_AUDIO_ISFLOAT!x; +enum SDL_AUDIO_ISLITTLEENDIAN(SDL_AudioFormat x) = !SDL_AUDIO_ISBIGENDIAN!x; +enum SDL_AUDIO_ISUNSIGNED(SDL_AudioFormat x) = !SDL_AUDIO_ISSIGNED!x; + +static if(sdlSupport >= SDLSupport.sdl209) { + enum { + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001, + SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002, + SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004, + SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008, + SDL_AUDIO_ALLOW_ANY_CHANGE = SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | + SDL_AUDIO_ALLOW_FORMAT_CHANGE | + SDL_AUDIO_ALLOW_CHANNELS_CHANGE | + SDL_AUDIO_ALLOW_SAMPLES_CHANGE, + } +} +else { + enum { + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001, + SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002, + SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004, + SDL_AUDIO_ALLOW_ANY_CHANGE = SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | + SDL_AUDIO_ALLOW_FORMAT_CHANGE | + SDL_AUDIO_ALLOW_CHANNELS_CHANGE, + } +} + +extern(C) nothrow alias SDL_AudioCallback = void function(void* userdata, ubyte* stream, int len); +struct SDL_AudioSpec { + int freq; + SDL_AudioFormat format; + ubyte channels; + ubyte silence; + ushort samples; + ushort padding; + uint size; + SDL_AudioCallback callback; + void* userdata; +} + +// Declared in 2.0.6, but doesn't hurt to use here +enum SDL_AUDIOCVT_MAX_FILTERS = 9; + +extern(C) nothrow alias SDL_AudioFilter = void function(SDL_AudioCVT* cvt, SDL_AudioFormat format); +struct SDL_AudioCVT { + int needed; + SDL_AudioFormat src_format; + SDL_AudioFormat dst_format; + double rate_incr; + ubyte* buf; + int len; + int len_cvt; + int len_mult; + double len_ratio; + SDL_AudioFilter[SDL_AUDIOCVT_MAX_FILTERS + 1] filters; + int filter_index; +} + +alias SDL_AudioDeviceID = uint; + +enum SDL_AudioStatus { + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED, +} +mixin(expandEnum!SDL_AudioStatus); + +enum SDL_MIX_MAXVOLUME = 128; + +static if(sdlSupport >= SDLSupport.sdl207) { + struct SDL_AudioStream; +} + +@nogc nothrow +SDL_AudioSpec* SDL_LoadWAV(const(char)* file, SDL_AudioSpec* spec, ubyte** audio_buf, uint* len) { + pragma(inline, true); + return SDL_LoadWAV_RW(SDL_RWFromFile(file,"rb"),1,spec,audio_buf,len); +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GetNumAudioDrivers(); + const(char)* SDL_GetAudioDriver(int); + int SDL_AudioInit(const(char)*); + void SDL_AudioQuit(); + const(char)* SDL_GetCurrentAudioDriver(); + int SDL_OpenAudio(SDL_AudioSpec*,SDL_AudioSpec*); + int SDL_GetNumAudioDevices(int); + const(char)* SDL_GetAudioDeviceName(int,int); + SDL_AudioDeviceID SDL_OpenAudioDevice(const(char)*,int,const(SDL_AudioSpec)*,SDL_AudioSpec*,int); + SDL_AudioStatus SDL_GetAudioStatus(); + SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID); + void SDL_PauseAudio(int); + void SDL_PauseAudioDevice(SDL_AudioDeviceID,int); + SDL_AudioSpec* SDL_LoadWAV_RW(SDL_RWops*,int,SDL_AudioSpec*,ubyte**,uint*); + void SDL_FreeWAV(ubyte*); + int SDL_BuildAudioCVT(SDL_AudioCVT*,SDL_AudioFormat,ubyte,int,SDL_AudioFormat,ubyte,int); + int SDL_ConvertAudio(SDL_AudioCVT*); + void SDL_MixAudio(ubyte*,const(ubyte)*,uint,int); + void SDL_MixAudioFormat(ubyte*,const(ubyte)*,SDL_AudioFormat,uint,int); + void SDL_LockAudio(); + void SDL_LockAudioDevice(SDL_AudioDeviceID); + void SDL_UnlockAudio(); + void SDL_UnlockAudioDevice(SDL_AudioDeviceID); + void SDL_CloseAudio(); + void SDL_CloseAudioDevice(SDL_AudioDeviceID); + + static if(sdlSupport >= SDLSupport.sdl204) { + int SDL_ClearQueuedAudio(SDL_AudioDeviceID); + int SDL_GetQueuedAudioSize(SDL_AudioDeviceID); + int SDL_QueueAudio(SDL_AudioDeviceID,const (void)*,uint); + } + + static if(sdlSupport >= SDLSupport.sdl205) { + uint SDL_DequeueAudio(SDL_AudioDeviceID,void*,uint); + } + + static if(sdlSupport >= SDLSupport.sdl207) { + SDL_AudioStream* SDL_NewAudioStream(const(SDL_AudioFormat),const(ubyte),const(int),const(SDL_AudioFormat),const(ubyte),const(int)); + int SDL_AudioStreamPut(SDL_AudioStream*,const(void)*,int); + int SDL_AudioStreamGet(SDL_AudioStream*,void*,int); + int SDL_AudioStreamAvailable(SDL_AudioStream*); + int SDL_AudioStreamFlush(SDL_AudioStream*); + void SDL_AudioStreamClear(SDL_AudioStream*); + void SDL_FreeAudioStream(SDL_AudioStream*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetNumAudioDrivers = int function(); + alias pSDL_GetAudioDriver = const(char)* function(int); + alias pSDL_AudioInit = int function(const(char)*); + alias pSDL_AudioQuit = void function(); + alias pSDL_GetCurrentAudioDriver = const(char)* function(); + alias pSDL_OpenAudio = int function(SDL_AudioSpec*,SDL_AudioSpec*); + alias pSDL_GetNumAudioDevices = int function(int); + alias pSDL_GetAudioDeviceName = const(char)* function(int,int); + alias pSDL_OpenAudioDevice = SDL_AudioDeviceID function(const(char)*,int,const(SDL_AudioSpec)*,SDL_AudioSpec*,int); + alias pSDL_GetAudioStatus = SDL_AudioStatus function(); + alias pSDL_GetAudioDeviceStatus = SDL_AudioStatus function(SDL_AudioDeviceID); + alias pSDL_PauseAudio = void function(int); + alias pSDL_PauseAudioDevice = void function(SDL_AudioDeviceID,int); + alias pSDL_LoadWAV_RW = SDL_AudioSpec* function(SDL_RWops*,int,SDL_AudioSpec*,ubyte**,uint*); + alias pSDL_FreeWAV = void function(ubyte*); + alias pSDL_BuildAudioCVT = int function(SDL_AudioCVT*,SDL_AudioFormat,ubyte,int,SDL_AudioFormat,ubyte,int); + alias pSDL_ConvertAudio = int function(SDL_AudioCVT*); + alias pSDL_MixAudio = void function(ubyte*,const(ubyte)*,uint,int); + alias pSDL_MixAudioFormat = void function(ubyte*,const(ubyte)*,SDL_AudioFormat,uint,int); + alias pSDL_LockAudio = void function(); + alias pSDL_LockAudioDevice = void function(SDL_AudioDeviceID); + alias pSDL_UnlockAudio = void function(); + alias pSDL_UnlockAudioDevice = void function(SDL_AudioDeviceID); + alias pSDL_CloseAudio = void function(); + alias pSDL_CloseAudioDevice = void function(SDL_AudioDeviceID); + } + + __gshared { + pSDL_GetNumAudioDrivers SDL_GetNumAudioDrivers; + pSDL_GetAudioDriver SDL_GetAudioDriver; + pSDL_AudioInit SDL_AudioInit; + pSDL_AudioQuit SDL_AudioQuit; + pSDL_GetCurrentAudioDriver SDL_GetCurrentAudioDriver; + pSDL_OpenAudio SDL_OpenAudio; + pSDL_GetNumAudioDevices SDL_GetNumAudioDevices; + pSDL_GetAudioDeviceName SDL_GetAudioDeviceName; + pSDL_OpenAudioDevice SDL_OpenAudioDevice; + pSDL_GetAudioStatus SDL_GetAudioStatus; + pSDL_GetAudioDeviceStatus SDL_GetAudioDeviceStatus; + pSDL_PauseAudio SDL_PauseAudio; + pSDL_PauseAudioDevice SDL_PauseAudioDevice; + pSDL_LoadWAV_RW SDL_LoadWAV_RW; + pSDL_FreeWAV SDL_FreeWAV; + pSDL_BuildAudioCVT SDL_BuildAudioCVT; + pSDL_ConvertAudio SDL_ConvertAudio; + pSDL_MixAudio SDL_MixAudio; + pSDL_MixAudioFormat SDL_MixAudioFormat; + pSDL_LockAudio SDL_LockAudio; + pSDL_LockAudioDevice SDL_LockAudioDevice; + pSDL_UnlockAudio SDL_UnlockAudio; + pSDL_UnlockAudioDevice SDL_UnlockAudioDevice; + pSDL_CloseAudio SDL_CloseAudio; + pSDL_CloseAudioDevice SDL_CloseAudioDevice; + } + + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_ClearQueuedAudio = int function(SDL_AudioDeviceID); + alias pSDL_GetQueuedAudioSize = int function(SDL_AudioDeviceID); + alias pSDL_QueueAudio = int function(SDL_AudioDeviceID,const (void)*,uint); + } + + __gshared { + pSDL_ClearQueuedAudio SDL_ClearQueuedAudio; + pSDL_GetQueuedAudioSize SDL_GetQueuedAudioSize; + pSDL_QueueAudio SDL_QueueAudio; + } + } + + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_DequeueAudio = uint function(SDL_AudioDeviceID,void*,uint); + } + + __gshared { + pSDL_DequeueAudio SDL_DequeueAudio; + } + } + + static if(sdlSupport >= SDLSupport.sdl207) { + extern(C) @nogc nothrow { + alias pSDL_NewAudioStream = SDL_AudioStream* function(const(SDL_AudioFormat),const(ubyte),const(int),const(SDL_AudioFormat),const(ubyte),const(int)); + alias pSDL_AudioStreamPut = int function(SDL_AudioStream*,const(void)*,int); + alias pSDL_AudioStreamGet = int function(SDL_AudioStream*,void*,int); + alias pSDL_AudioStreamAvailable = int function(SDL_AudioStream*); + alias pSDL_AudioStreamFlush = int function(SDL_AudioStream*); + alias pSDL_AudioStreamClear = void function(SDL_AudioStream*); + alias pSDL_FreeAudioStream = void function(SDL_AudioStream*); + } + + __gshared { + pSDL_NewAudioStream SDL_NewAudioStream; + pSDL_AudioStreamPut SDL_AudioStreamPut; + pSDL_AudioStreamGet SDL_AudioStreamGet; + pSDL_AudioStreamAvailable SDL_AudioStreamAvailable; + pSDL_AudioStreamFlush SDL_AudioStreamFlush; + pSDL_AudioStreamClear SDL_AudioStreamClear; + pSDL_FreeAudioStream SDL_FreeAudioStream; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlblendmode.d b/demos/external/imports/bindbc/sdl/bind/sdlblendmode.d new file mode 100644 index 0000000..a3360c2 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlblendmode.d @@ -0,0 +1,71 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlblendmode; + +import bindbc.sdl.config; + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_BlendMode { + SDL_BLENDMODE_NONE = 0x00000000, + SDL_BLENDMODE_BLEND = 0x00000001, + SDL_BLENDMODE_ADD = 0x00000002, + SDL_BLENDMODE_MOD = 0x00000004, + SDL_BLENDMODE_INVALID = 0x7FFFFFFF, + } + mixin(expandEnum!SDL_BlendMode); + + enum SDL_BlendOperation { + SDL_BLENDOPERATION_ADD = 0x1, + SDL_BLENDOPERATION_SUBTRACT = 0x2, + SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, + SDL_BLENDOPERATION_MINIMUM = 0x4, + SDL_BLENDOPERATION_MAXIMUM = 0x5, + } + mixin(expandEnum!SDL_BlendOperation); + + enum SDL_BlendFactor { + SDL_BLENDFACTOR_ZERO = 0x1, + SDL_BLENDFACTOR_ONE = 0x2, + SDL_BLENDFACTOR_SRC_COLOR = 0x3, + SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, + SDL_BLENDFACTOR_SRC_ALPHA = 0x5, + SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, + SDL_BLENDFACTOR_DST_COLOR = 0x7, + SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, + SDL_BLENDFACTOR_DST_ALPHA = 0x9, + SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA, + } + mixin(expandEnum!SDL_BlendFactor); +} +else { + enum SDL_BlendMode { + SDL_BLENDMODE_NONE = 0x00000000, + SDL_BLENDMODE_BLEND = 0x00000001, + SDL_BLENDMODE_ADD = 0x00000002, + SDL_BLENDMODE_MOD = 0x00000004, + } + mixin(expandEnum!SDL_BlendMode); +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + static if(sdlSupport >= SDLSupport.sdl206) { + SDL_BlendMode SDL_ComposeCustomBlendMode(SDL_BlendFactor,SDL_BlendFactor,SDL_BlendOperation,SDL_BlendFactor,SDL_BlendFactor,SDL_BlendOperation); + } + } +} +else { + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_ComposeCustomBlendMode = SDL_BlendMode function(SDL_BlendFactor,SDL_BlendFactor,SDL_BlendOperation,SDL_BlendFactor,SDL_BlendFactor,SDL_BlendOperation); + } + + __gshared { + pSDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode; + } + } +} diff --git a/demos/external/imports/bindbc/sdl/bind/sdlclipboard.d b/demos/external/imports/bindbc/sdl/bind/sdlclipboard.d new file mode 100644 index 0000000..345c1ac --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlclipboard.d @@ -0,0 +1,31 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlclipboard; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_SetClipboardText(const(char)*); + char* SDL_GetClipboardText(); + SDL_bool SDL_HasClipboardText(); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_SetClipboardText = int function(const(char)*); + alias pSDL_GetClipboardText = char* function(); + alias pSDL_HasClipboardText = SDL_bool function(); + } + + __gshared { + pSDL_SetClipboardText SDL_SetClipboardText; + pSDL_GetClipboardText SDL_GetClipboardText; + pSDL_HasClipboardText SDL_HasClipboardText; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlcpuinfo.d b/demos/external/imports/bindbc/sdl/bind/sdlcpuinfo.d new file mode 100644 index 0000000..433ade0 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlcpuinfo.d @@ -0,0 +1,130 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlcpuinfo; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +enum SDL_CACHELINE_SIZE = 128; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GetCPUCount(); + int SDL_GetCPUCacheLineSize(); + SDL_bool SDL_HasRDTSC(); + SDL_bool SDL_HasAltiVec(); + SDL_bool SDL_HasMMX(); + SDL_bool SDL_Has3DNow(); + SDL_bool SDL_HasSSE(); + SDL_bool SDL_HasSSE2(); + SDL_bool SDL_HasSSE3(); + SDL_bool SDL_HasSSE41(); + SDL_bool SDL_HasSSE42(); + + static if(sdlSupport >= SDLSupport.sdl201) { + int SDL_GetSystemRAM(); + } + static if(sdlSupport >= SDLSupport.sdl202) { + SDL_bool SDL_HasAVX(); + } + static if(sdlSupport >= SDLSupport.sdl204) { + SDL_bool SDL_HasAVX2(); + } + static if(sdlSupport >= SDLSupport.sdl206) { + SDL_bool SDL_HasNEON(); + } + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_bool SDL_HasAVX512F(); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + size_t SDL_SIMDGetAlignment(); + void* SDL_SIMDAlloc(const(size_t)); + void SDL_SIMDFree(void*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetCPUCount = int function(); + alias pSDL_GetCPUCacheLineSize = int function(); + alias pSDL_HasRDTSC = SDL_bool function(); + alias pSDL_HasAltiVec = SDL_bool function(); + alias pSDL_HasMMX = SDL_bool function(); + alias pSDL_Has3DNow = SDL_bool function(); + alias pSDL_HasSSE = SDL_bool function(); + alias pSDL_HasSSE2 = SDL_bool function(); + alias pSDL_HasSSE3 = SDL_bool function(); + alias pSDL_HasSSE41 = SDL_bool function(); + alias pSDL_HasSSE42 = SDL_bool function(); + } + + __gshared { + pSDL_GetCPUCount SDL_GetCPUCount; + pSDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize; + pSDL_HasRDTSC SDL_HasRDTSC; + pSDL_HasAltiVec SDL_HasAltiVec; + pSDL_HasMMX SDL_HasMMX; + pSDL_Has3DNow SDL_Has3DNow; + pSDL_HasSSE SDL_HasSSE; + pSDL_HasSSE2 SDL_HasSSE2; + pSDL_HasSSE3 SDL_HasSSE3; + pSDL_HasSSE41 SDL_HasSSE41; + pSDL_HasSSE42 SDL_HasSSE42; + } + static if(sdlSupport >= SDLSupport.sdl201) { + extern(C) @nogc nothrow { + alias pSDL_GetSystemRAM = int function(); + } + __gshared { + pSDL_GetSystemRAM SDL_GetSystemRAM; + } + } + static if(sdlSupport >= SDLSupport.sdl202) { + extern(C) @nogc nothrow { + alias pSDL_HasAVX = SDL_bool function(); + } + __gshared { + pSDL_HasAVX SDL_HasAVX; + } + } + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_HasAVX2 = SDL_bool function(); + } + __gshared { + pSDL_HasAVX2 SDL_HasAVX2; + } + } + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_HasNEON = SDL_bool function(); + } + __gshared { + pSDL_HasNEON SDL_HasNEON; + } + } + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_HasAVX512F = SDL_bool function(); + } + __gshared { + pSDL_HasAVX512F SDL_HasAVX512F; + } + } + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_SIMDGetAlignment = size_t function(); + alias pSDL_SIMDAlloc = void* function(const(size_t)); + alias pSDL_SIMDFree = void function(void*); + } + __gshared { + pSDL_SIMDGetAlignment SDL_SIMDGetAlignment; + pSDL_SIMDAlloc SDL_SIMDAlloc; + pSDL_SIMDFree SDL_SIMDFree; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlerror.d b/demos/external/imports/bindbc/sdl/bind/sdlerror.d new file mode 100644 index 0000000..09b61e3 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlerror.d @@ -0,0 +1,28 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlerror; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_SetError(const(char)*,...); + const(char)* SDL_GetError(); + void SDL_ClearError(); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_SetError = void function(const(char)*,...); + alias pSDL_GetError = const(char)* function(); + alias pSDL_ClearError = void function(); + } + + __gshared { + pSDL_SetError SDL_SetError; + pSDL_GetError SDL_GetError; + pSDL_ClearError SDL_ClearError; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlevents.d b/demos/external/imports/bindbc/sdl/bind/sdlevents.d new file mode 100644 index 0000000..0fb7ce2 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlevents.d @@ -0,0 +1,674 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlevents; + +import bindbc.sdl.config; + +import bindbc.sdl.bind.sdlgesture, + bindbc.sdl.bind.sdljoystick, + bindbc.sdl.bind.sdlkeyboard, + bindbc.sdl.bind.sdlkeycode, + bindbc.sdl.bind.sdlstdinc, + bindbc.sdl.bind.sdlsyswm, + bindbc.sdl.bind.sdltouch, + bindbc.sdl.bind.sdlvideo; + +enum { + SDL_RELEASED = 0, + SDL_PRESSED = 1, +} + +static if(sdlSupport >= SDLSupport.sdl209) { + enum SDL_EventType { + SDL_FIRSTEVENT = 0, + SDL_QUIT = 0x100, + SDL_APP_TERMINATING, + SDL_APP_LOWMEMORY, + SDL_APP_WILLENTERBACKGROUND, + SDL_APP_DIDENTERBACKGROUND, + SDL_APP_WILLENTERFOREGROUND, + SDL_APP_DIDENTERFOREGROUND, + SDL_DISPLAYEVENT = 0x150, + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + SDL_KEYMAPCHANGED, + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + SDL_CLIPBOARDUPDATE = 0x900, + SDL_DROPFILE = 0x1000, + SDL_DROPTEXT, + SDL_DROPBEGIN, + SDL_DROPCOMPLETE, + SDL_AUDIODEVICEADDED = 0x1100, + SDL_AUDIODEVICEREMOVED, + SDL_SENSORUPDATE = 0x1200, + SDL_RENDER_TARGETS_RESET = 0x2000, + SDL_RENDER_DEVICE_RESET, + SDL_USEREVENT = 0x8000, + SDL_LASTEVENT = 0xFFFF + } +} +else static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_EventType { + SDL_FIRSTEVENT = 0, + SDL_QUIT = 0x100, + SDL_APP_TERMINATING, + SDL_APP_LOWMEMORY, + SDL_APP_WILLENTERBACKGROUND, + SDL_APP_DIDENTERBACKGROUND, + SDL_APP_WILLENTERFOREGROUND, + SDL_APP_DIDENTERFOREGROUND, + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + SDL_KEYMAPCHANGED, + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + SDL_CLIPBOARDUPDATE = 0x900, + SDL_DROPFILE = 0x1000, + SDL_DROPTEXT, + SDL_DROPBEGIN, + SDL_DROPCOMPLETE, + SDL_AUDIODEVICEADDED = 0x1100, + SDL_AUDIODEVICEREMOVED, + SDL_RENDER_TARGETS_RESET = 0x2000, + SDL_RENDER_DEVICE_RESET, + SDL_USEREVENT = 0x8000, + SDL_LASTEVENT = 0xFFFF + } +} +else static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_EventType { + SDL_FIRSTEVENT = 0, + SDL_QUIT = 0x100, + SDL_APP_TERMINATING, + SDL_APP_LOWMEMORY, + SDL_APP_WILLENTERBACKGROUND, + SDL_APP_DIDENTERBACKGROUND, + SDL_APP_WILLENTERFOREGROUND, + SDL_APP_DIDENTERFOREGROUND, + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + SDL_KEYMAPCHANGED, + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + SDL_CLIPBOARDUPDATE = 0x900, + SDL_DROPFILE = 0x1000, + SDL_AUDIODEVICEADDED = 0x1100, + SDL_AUDIODEVICEREMOVED, + SDL_RENDER_TARGETS_RESET = 0x2000, + SDL_RENDER_DEVICE_RESET, + SDL_USEREVENT = 0x8000, + SDL_LASTEVENT = 0xFFFF + } +} +else static if(sdlSupport >= SDLSupport.sdl201) { + enum SDL_EventType { + SDL_FIRSTEVENT = 0, + SDL_QUIT = 0x100, + SDL_APP_TERMINATING, + SDL_APP_LOWMEMORY, + SDL_APP_WILLENTERBACKGROUND, + SDL_APP_DIDENTERBACKGROUND, + SDL_APP_WILLENTERFOREGROUND, + SDL_APP_DIDENTERFOREGROUND, + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + SDL_CLIPBOARDUPDATE = 0x900, + SDL_DROPFILE = 0x1000, + SDL_RENDER_TARGETS_RESET = 0x2000, + SDL_USEREVENT = 0x8000, + SDL_LASTEVENT = 0xFFFF + } +} +else { + enum SDL_EventType { + SDL_FIRSTEVENT = 0, + SDL_QUIT = 0x100, + SDL_APP_TERMINATING, + SDL_APP_LOWMEMORY, + SDL_APP_WILLENTERBACKGROUND, + SDL_APP_DIDENTERBACKGROUND, + SDL_APP_WILLENTERFOREGROUND, + SDL_APP_DIDENTERFOREGROUND, + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + SDL_CLIPBOARDUPDATE = 0x900, + SDL_DROPFILE = 0x1000, + SDL_USEREVENT = 0x8000, + SDL_LASTEVENT = 0xFFFF + } +} +mixin(expandEnum!SDL_EventType); + +struct SDL_CommonEvent { + SDL_EventType type; + uint timestamp; +} + +static if(sdlSupport >= SDLSupport.sdl209) { + struct SDL_DisplayEvent { + SDL_EventType type; + uint timestamp; + uint display; + ubyte event; + ubyte padding1; + ubyte padding2; + ubyte padding3; + int data1; + } +} + +struct SDL_WindowEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + SDL_WindowEventID event; + ubyte padding1; + ubyte padding2; + ubyte padding3; + int data1; + int data2; +} + +struct SDL_KeyboardEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + ubyte state; + ubyte repeat; + ubyte padding2; + ubyte padding3; + SDL_Keysym keysym; +} + +enum SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32; +struct SDL_TextEditingEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + char[SDL_TEXTEDITINGEVENT_TEXT_SIZE] text; + int start; + int length; +} + +enum SDL_TEXTINPUTEVENT_TEXT_SIZE = 32; +struct SDL_TextInputEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + char[SDL_TEXTINPUTEVENT_TEXT_SIZE] text; +} + +struct SDL_MouseMotionEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + uint which; + uint state; + int x; + int y; + int xrel; + int yrel; +} + +struct SDL_MouseButtonEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + uint which; + ubyte button; + ubyte state; + static if(sdlSupport == SDLSupport.sdl200) { + ubyte padding1; + ubyte padding2; + } + else { + ubyte clicks; + ubyte padding1; + } + int x; + int y; +} + +struct SDL_MouseWheelEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + uint which; + int x; + int y; + static if(sdlSupport >= SDLSupport.sdl204) { + uint direction; + } +} + +struct SDL_JoyAxisEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte axis; + ubyte padding1; + ubyte padding2; + ubyte padding3; + short value; + ushort padding4; +} + +struct SDL_JoyBallEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte ball; + ubyte padding1; + ubyte padding2; + ubyte padding3; + short xrel; + short yrel; +} + +struct SDL_JoyHatEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte hat; + ubyte value; + ubyte padding1; + ubyte padding2; +} + +struct SDL_JoyButtonEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte button; + ubyte state; + ubyte padding1; + ubyte padding2; +} + +struct SDL_JoyDeviceEvent { + SDL_EventType type; + uint timestamp; + int which; +} + +struct SDL_ControllerAxisEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte axis; + ubyte padding1; + ubyte padding2; + ubyte padding3; + short value; + ushort padding4; +} + +struct SDL_ControllerButtonEvent { + SDL_EventType type; + uint timestamp; + SDL_JoystickID which; + ubyte button; + ubyte state; + ubyte padding1; + ubyte padding2; +} + +struct SDL_ControllerDeviceEvent { + SDL_EventType type; + uint timestamp; + int which; +} + +static if(sdlSupport >= SDLSupport.sdl204) { + struct SDL_AudioDeviceEvent { + uint type; + uint timestamp; + uint which; + ubyte iscapture; + ubyte padding1; + ubyte padding2; + ubyte padding3; + } +} + +struct SDL_TouchFingerEvent { + SDL_EventType type; + uint timestamp; + SDL_TouchID touchId; + SDL_FingerID fingerId; + float x; + float y; + float dx; + float dy; + float pressure; +} + +struct SDL_MultiGestureEvent { + SDL_EventType type; + uint timestamp; + SDL_TouchID touchId; + float dTheta; + float dDist; + float x; + float y; + ushort numFingers; + ushort padding; +} + +struct SDL_DollarGestureEvent { + SDL_EventType type; + uint timestamp; + SDL_TouchID touchId; + SDL_GestureID gestureId; + uint numFingers; + float error; + float x; + float y; +} + +struct SDL_DropEvent { + SDL_EventType type; + uint timestamp; + char* file; + static if(sdlSupport >= SDLSupport.sdl205) { + uint windowID; + } +} + +struct SDL_SensorEvent { + SDL_EventType type; + uint timestamp; + int which; + float[6] data; +} + +struct SDL_QuitEvent { + SDL_EventType type; + uint timestamp; +} + +struct SDL_OSEvent { + SDL_EventType type; + uint timestamp; +} + +struct SDL_UserEvent { + SDL_EventType type; + uint timestamp; + uint windowID; + int code; + void* data1; + void* data2; +} + +struct SDL_SysWMEvent { + SDL_EventType type; + uint timestamp; + SDL_SysWMmsg* msg; +} + +union SDL_Event { + SDL_EventType type; + SDL_CommonEvent common; + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_DisplayEvent display; + } + SDL_WindowEvent window; + SDL_KeyboardEvent key; + SDL_TextEditingEvent edit; + SDL_TextInputEvent text; + SDL_MouseMotionEvent motion; + SDL_MouseButtonEvent button; + SDL_MouseWheelEvent wheel; + SDL_JoyAxisEvent jaxis; + SDL_JoyBallEvent jball; + SDL_JoyHatEvent jhat; + SDL_JoyButtonEvent jbutton; + SDL_JoyDeviceEvent jdevice; + SDL_ControllerAxisEvent caxis; + SDL_ControllerButtonEvent cbutton; + SDL_ControllerDeviceEvent cdevice; + static if(sdlSupport >= SDLSupport.sdl204) { + SDL_AudioDeviceEvent adevice; + } + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_SensorEvent sensor; + } + SDL_QuitEvent quit; + SDL_UserEvent user; + SDL_SysWMEvent syswm; + SDL_TouchFingerEvent tfinger; + SDL_MultiGestureEvent mgesture; + SDL_DollarGestureEvent dgesture; + SDL_DropEvent drop; + + ubyte[56] padding; +} + +enum SDL_eventaction { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} +alias SDL_EventAction = SDL_eventaction; +mixin(expandEnum!SDL_EventAction); + +extern(C) nothrow alias SDL_EventFilter = int function(void* userdata, SDL_Event* event); + +enum { + SDL_QUERY = -1, + SDL_IGNORE = 0, + SDL_DISABLE = 0, + SDL_ENABLE = 1, +} + +@nogc nothrow { + int SDL_GetEventState(SDL_EventType type) { + pragma(inline, true); + return SDL_EventState(type, SDL_QUERY); + } + + // This is implemented in SDL_quit.h, but works better here. + bool SDL_QuitRequested() { + pragma(inline, true); + SDL_PumpEvents(); + return SDL_PeepEvents(null,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0; + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_PumpEvents(); + int SDL_PeepEvents(SDL_Event*,int,SDL_eventaction,uint,uint); + SDL_bool SDL_HasEvent(uint); + SDL_bool SDL_HasEvents(uint,uint); + void SDL_FlushEvent(uint); + void SDL_FlushEvents(uint,uint); + int SDL_PollEvent(SDL_Event*); + int SDL_WaitEvent(SDL_Event*); + int SDL_WaitEventTimeout(SDL_Event*,int); + int SDL_PushEvent(SDL_Event*); + void SDL_SetEventFilter(SDL_EventFilter,void*); + SDL_bool SDL_GetEventFilter(SDL_EventFilter*,void**); + void SDL_AddEventWatch(SDL_EventFilter,void*); + void SDL_DelEventWatch(SDL_EventFilter,void*); + void SDL_FilterEvents(SDL_EventFilter,void*); + ubyte SDL_EventState(uint,int); + uint SDL_RegisterEvents(int); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_PumpEvents = void function(); + alias pSDL_PeepEvents = int function(SDL_Event*,int,SDL_eventaction,uint,uint); + alias pSDL_HasEvent = SDL_bool function(uint); + alias pSDL_HasEvents = SDL_bool function(uint,uint); + alias pSDL_FlushEvent = void function(uint); + alias pSDL_FlushEvents = void function(uint,uint); + alias pSDL_PollEvent = int function(SDL_Event*); + alias pSDL_WaitEvent = int function(SDL_Event*); + alias pSDL_WaitEventTimeout = int function(SDL_Event*,int); + alias pSDL_PushEvent = int function(SDL_Event*); + alias pSDL_SetEventFilter = void function(SDL_EventFilter,void*); + alias pSDL_GetEventFilter = SDL_bool function(SDL_EventFilter*,void**); + alias pSDL_AddEventWatch = void function(SDL_EventFilter,void*); + alias pSDL_DelEventWatch = void function(SDL_EventFilter,void*); + alias pSDL_FilterEvents = void function(SDL_EventFilter,void*); + alias pSDL_EventState = ubyte function(uint,int); + alias pSDL_RegisterEvents = uint function(int); + } + + __gshared { + pSDL_PumpEvents SDL_PumpEvents; + pSDL_PeepEvents SDL_PeepEvents; + pSDL_HasEvent SDL_HasEvent; + pSDL_HasEvents SDL_HasEvents; + pSDL_FlushEvent SDL_FlushEvent; + pSDL_FlushEvents SDL_FlushEvents; + pSDL_PollEvent SDL_PollEvent; + pSDL_WaitEvent SDL_WaitEvent; + pSDL_WaitEventTimeout SDL_WaitEventTimeout; + pSDL_PushEvent SDL_PushEvent; + pSDL_SetEventFilter SDL_SetEventFilter; + pSDL_GetEventFilter SDL_GetEventFilter; + pSDL_AddEventWatch SDL_AddEventWatch; + pSDL_DelEventWatch SDL_DelEventWatch; + pSDL_FilterEvents SDL_FilterEvents; + pSDL_EventState SDL_EventState; + pSDL_RegisterEvents SDL_RegisterEvents; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlfilesystem.d b/demos/external/imports/bindbc/sdl/bind/sdlfilesystem.d new file mode 100644 index 0000000..a3edcdc --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlfilesystem.d @@ -0,0 +1,31 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlfilesystem; + +import bindbc.sdl.config; + +version(BindSDL_Static){ + extern(C) @nogc nothrow { + static if(sdlSupport >= SDLSupport.sdl201) { + char* SDL_GetBasePath(); + char* SDL_GetPrefPath(const(char)* org,const(char)* app); + } + } +} +else { + static if(sdlSupport >= SDLSupport.sdl201) { + extern(C) @nogc nothrow { + alias pSDL_GetBasePath = char* function(); + alias pSDL_GetPrefPath = char* function(const(char)* org,const(char)* app); + } + + __gshared { + pSDL_GetBasePath SDL_GetBasePath; + pSDL_GetPrefPath SDL_GetPrefPath; + } + } +} diff --git a/demos/external/imports/bindbc/sdl/bind/sdlgamecontroller.d b/demos/external/imports/bindbc/sdl/bind/sdlgamecontroller.d new file mode 100644 index 0000000..295d117 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlgamecontroller.d @@ -0,0 +1,225 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlgamecontroller; + +import bindbc.sdl.config; + +import bindbc.sdl.bind.sdljoystick, + bindbc.sdl.bind.sdlrwops; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +struct SDL_GameController; + +enum SDL_GameControllerBindType { + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT, +} +mixin(expandEnum!SDL_GameControllerBindType); + +struct SDL_GameControllerButtonBind { + SDL_GameControllerBindType bindType; + union value { + int button; + int axis; + struct hat { + int hat; + int hat_mask; + } + } + alias button = value.button; + alias axis = value.axis; + alias hat = value.hat; +} + +enum SDL_GameControllerAxis { + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} +mixin(expandEnum!SDL_GameControllerAxis); + +enum SDL_GameControllerButton { + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX +} +mixin(expandEnum!SDL_GameControllerButton); + +static if(sdlSupport >= SDLSupport.sdl202) { + @nogc nothrow + int SDL_GameControllerAddMappingsFromFile(const(char)* file) { + pragma(inline, true); + return SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file,"rb"),1); + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GameControllerAddMapping(const(char)*); + char* SDL_GameControllerMappingForGUID(SDL_JoystickGUID); + char* SDL_GameControllerMapping(SDL_GameController*); + SDL_bool SDL_IsGameController(int); + const(char)* SDL_GameControllerNameForIndex(int); + SDL_GameController* SDL_GameControllerOpen(int); + const(char)* SDL_GameControllerName(SDL_GameController*); + SDL_bool SDL_GameControllerGetAttached(SDL_GameController*); + SDL_Joystick* SDL_GameControllerGetJoystick(SDL_GameController*); + int SDL_GameControllerEventState(int); + void SDL_GameControllerUpdate(); + SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const(char)*); + const(char)* SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis); + SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController*,SDL_GameControllerAxis); + short SDL_GameControllerGetAxis(SDL_GameController*,SDL_GameControllerAxis); + SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const(char*)); + const(char)* SDL_GameControllerGetStringForButton(SDL_GameControllerButton); + SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController*,SDL_GameControllerButton); + ubyte SDL_GameControllerGetButton(SDL_GameController*,SDL_GameControllerButton); + void SDL_GameControllerClose(SDL_GameController*); + + static if(sdlSupport >= SDLSupport.sdl202) { + int SDL_GameControllerAddMappingsFromRW(SDL_RWops*,int); + } + static if(sdlSupport >= SDLSupport.sdl204) { + SDL_GameController* SDL_GameControllerFromInstanceID(SDL_JoystickID); + } + static if(sdlSupport >= SDLSupport.sdl206) { + ushort SDL_GameControllerGetProduct(SDL_GameController*); + ushort SDL_GameControllerGetProductVersion(SDL_GameController*); + ushort SDL_GameControllerGetVendor(SDL_GameController*); + char* SDL_GameControllerMappingForIndex(int); + int SDL_GameControllerNumMappings(); + } + static if(sdlSupport >= SDLSupport.sdl209) { + char* SDL_GameControllerMappingForDeviceIndex(int); + int SDL_GameControllerRumble(SDL_GameController*,ushort,ushort,uint); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + int SDL_GameControllerGetPlayerIndex(SDL_GameController*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GameControllerAddMapping = int function(const(char)*); + alias pSDL_GameControllerMappingForGUID = char* function(SDL_JoystickGUID); + alias pSDL_GameControllerMapping = char* function(SDL_GameController*); + alias pSDL_IsGameController = SDL_bool function(int); + alias pSDL_GameControllerNameForIndex = const(char)* function(int); + alias pSDL_GameControllerOpen = SDL_GameController* function(int); + alias pSDL_GameControllerName = const(char)* function(SDL_GameController*); + alias pSDL_GameControllerGetAttached = SDL_bool function(SDL_GameController*); + alias pSDL_GameControllerGetJoystick = SDL_Joystick* function(SDL_GameController*); + alias pSDL_GameControllerEventState = int function(int); + alias pSDL_GameControllerUpdate = void function(); + alias pSDL_GameControllerGetAxisFromString = SDL_GameControllerAxis function(const(char)*); + alias pSDL_GameControllerGetStringForAxis = const(char)* function(SDL_GameControllerAxis); + alias pSDL_GameControllerGetBindForAxis = SDL_GameControllerButtonBind function(SDL_GameController*,SDL_GameControllerAxis); + alias pSDL_GameControllerGetAxis = short function(SDL_GameController*,SDL_GameControllerAxis); + alias pSDL_GameControllerGetButtonFromString = SDL_GameControllerButton function(const(char*)); + alias pSDL_GameControllerGetStringForButton = const(char)* function(SDL_GameControllerButton); + alias pSDL_GameControllerGetBindForButton = SDL_GameControllerButtonBind function(SDL_GameController*,SDL_GameControllerButton); + alias pSDL_GameControllerGetButton = ubyte function(SDL_GameController*,SDL_GameControllerButton); + alias pSDL_GameControllerClose = void function(SDL_GameController*); + } + __gshared { + pSDL_GameControllerAddMapping SDL_GameControllerAddMapping; + pSDL_GameControllerMappingForGUID SDL_GameControllerMappingForGUID; + pSDL_GameControllerMapping SDL_GameControllerMapping; + pSDL_IsGameController SDL_IsGameController; + pSDL_GameControllerNameForIndex SDL_GameControllerNameForIndex; + pSDL_GameControllerOpen SDL_GameControllerOpen; + pSDL_GameControllerName SDL_GameControllerName; + pSDL_GameControllerGetAttached SDL_GameControllerGetAttached; + pSDL_GameControllerGetJoystick SDL_GameControllerGetJoystick; + pSDL_GameControllerEventState SDL_GameControllerEventState; + pSDL_GameControllerUpdate SDL_GameControllerUpdate; + pSDL_GameControllerGetAxisFromString SDL_GameControllerGetAxisFromString; + pSDL_GameControllerGetStringForAxis SDL_GameControllerGetStringForAxis; + pSDL_GameControllerGetBindForAxis SDL_GameControllerGetBindForAxis; + pSDL_GameControllerGetAxis SDL_GameControllerGetAxis; + pSDL_GameControllerGetButtonFromString SDL_GameControllerGetButtonFromString; + pSDL_GameControllerGetStringForButton SDL_GameControllerGetStringForButton; + pSDL_GameControllerGetBindForButton SDL_GameControllerGetBindForButton; + pSDL_GameControllerGetButton SDL_GameControllerGetButton; + pSDL_GameControllerClose SDL_GameControllerClose; + } + static if(sdlSupport >= SDLSupport.sdl202) { + extern(C) @nogc nothrow { + alias pSDL_GameControllerAddMappingsFromRW = int function(SDL_RWops*,int); + } + + __gshared { + pSDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW; + } + } + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_GameControllerFromInstanceID = SDL_GameController* function(SDL_JoystickID); + } + + __gshared { + pSDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID; + } + } + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_GameControllerGetProduct = ushort function(SDL_GameController*); + alias pSDL_GameControllerGetProductVersion = ushort function(SDL_GameController*); + alias pSDL_GameControllerGetVendor = ushort function(SDL_GameController*); + alias pSDL_GameControllerMappingForIndex = char* function(int); + alias pSDL_GameControllerNumMappings = int function(); + } + + __gshared { + pSDL_GameControllerGetProduct SDL_GameControllerGetProduct; + pSDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion; + pSDL_GameControllerGetVendor SDL_GameControllerGetVendor; + pSDL_GameControllerMappingForIndex SDL_GameControllerMappingForIndex; + pSDL_GameControllerNumMappings SDL_GameControllerNumMappings; + } + } + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_GameControllerMappingForDeviceIndex = char* function(int); + alias pSDL_GameControllerRumble = int function(SDL_GameController*,ushort,ushort,uint); + } + + __gshared { + pSDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex; + pSDL_GameControllerRumble SDL_GameControllerRumble; + } + } + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_GameControllerGetPlayerIndex = int function(SDL_GameController*); + } + __gshared { + pSDL_GameControllerGetPlayerIndex SDL_GameControllerGetPlayerIndex; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlgesture.d b/demos/external/imports/bindbc/sdl/bind/sdlgesture.d new file mode 100644 index 0000000..62ea0e5 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlgesture.d @@ -0,0 +1,36 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlgesture; + +import bindbc.sdl.bind.sdltouch : SDL_TouchID; +import bindbc.sdl.bind.sdlrwops : SDL_RWops; + +alias SDL_GestureID = long; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_RecordGesture(SDL_TouchID); + int SDL_SaveAllDollarTemplates(SDL_RWops*); + int SDL_SaveDollarTemplate(SDL_GestureID,SDL_RWops*); + int SDL_LoadDollarTemplates(SDL_TouchID,SDL_RWops*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_RecordGesture = int function(SDL_TouchID); + alias pSDL_SaveAllDollarTemplates = int function(SDL_RWops*); + alias pSDL_SaveDollarTemplate = int function(SDL_GestureID,SDL_RWops*); + alias pSDL_LoadDollarTemplates = int function(SDL_TouchID,SDL_RWops*); + } + + __gshared { + pSDL_RecordGesture SDL_RecordGesture; + pSDL_SaveAllDollarTemplates SDL_SaveAllDollarTemplates; + pSDL_SaveDollarTemplate SDL_SaveDollarTemplate; + pSDL_LoadDollarTemplates SDL_LoadDollarTemplates; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlhaptic.d b/demos/external/imports/bindbc/sdl/bind/sdlhaptic.d new file mode 100644 index 0000000..f706080 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlhaptic.d @@ -0,0 +1,240 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlhaptic; + +import bindbc.sdl.bind.sdljoystick : SDL_Joystick; + +struct SDL_Haptic; + +enum : ushort { + SDL_HAPTIC_CONSTANT = 1u<<0, + SDL_HAPTIC_SINE = 1u<<1, + SDL_HAPTIC_LEFTRIGHT = 1u<<2, + SDL_HAPTIC_TRIANGLE = 1u<<3, + SDL_HAPTIC_SAWTOOTHUP = 1u<<4, + SDL_HAPTIC_SAWTOOTHDOWN = 1u<<5, + SDL_HAPTIC_RAMP = 1u<<6, + SDL_HAPTIC_SPRING = 1u<<7, + SDL_HAPTIC_DAMPER = 1u<<8, + SDL_HAPTIC_INERTIA = 1u<<9, + SDL_HAPTIC_FRICTION = 1u<<10, + SDL_HAPTIC_CUSTOM = 1u<<11, + SDL_HAPTIC_GAIN = 1u<<12, + SDL_HAPTIC_AUTOCENTER = 1u<<13, + SDL_HAPTIC_STATUS = 1u<<14, + SDL_HAPTIC_PAUSE = 1u<<15, +} + +enum { + SDL_HAPTIC_POLAR = 0, + SDL_HAPTIC_CARTESIAN = 1, + SDL_HAPTIC_SPHERICAL = 2, +} + +enum SDL_HAPTIC_INFINITY = 4294967295U; + +struct SDL_HapticDirection { + ubyte type; + int[3] dir; +} + +struct SDL_HapticConstant { + ushort type; + SDL_HapticDirection direction; + uint length; + ushort delay; + ushort button; + ushort interval; + short level; + ushort attack_length; + ushort attack_level; + ushort fade_length; + ushort fade_level; +} + +struct SDL_HapticPeriodic { + ushort type; + SDL_HapticDirection direction; + uint length; + uint delay; + ushort button; + ushort interval; + ushort period; + short magnitude; + short offset; + ushort phase; + ushort attack_length; + ushort attack_level; + ushort fade_length; + ushort fade_level; +} + +struct SDL_HapticCondition { + ushort type; + SDL_HapticDirection direciton; + uint length; + ushort delay; + ushort button; + ushort interval; + ushort[3] right_sat; + ushort[3] left_sat; + short[3] right_coeff; + short[3] left_coeff; + ushort[3] deadband; + ushort[3] center; +} + +struct SDL_HapticRamp { + ushort type; + SDL_HapticDirection direction; + uint length; + ushort delay; + ushort button; + ushort interval; + short start; + short end; + ushort attack_length; + ushort attack_level; + ushort fade_length; + ushort fade_level; +} + +struct SDL_HapticLeftRight { + ushort type; + uint length; + ushort large_magnitude; + ushort small_magnitude; +} + +struct SDL_HapticCustom { + ushort type; + SDL_HapticDirection direction; + uint length; + ushort delay; + ushort button; + ushort interval; + ubyte channels; + ushort period; + ushort samples; + ushort* data; + ushort attack_length; + ushort attack_level; + ushort fade_length; + ushort fade_level; +} + +union SDL_HapticEffect { + ushort type; + SDL_HapticConstant constant; + SDL_HapticPeriodic periodic; + SDL_HapticCondition condition; + SDL_HapticRamp ramp; + SDL_HapticLeftRight leftright; + SDL_HapticCustom custom; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_NumHaptics(); + const(char)* SDL_HapticName(int); + SDL_Haptic* SDL_HapticOpen(int); + int SDL_HapticOpened(int); + int SDL_HapticIndex(SDL_Haptic*); + int SDL_MouseIsHaptic(); + SDL_Haptic* SDL_HapticOpenFromMouse(); + int SDL_JoystickIsHaptic(SDL_Joystick*); + SDL_Haptic* SDL_HapticOpenFromJoystick(SDL_Joystick*); + int SDL_HapticClose(SDL_Haptic*); + int SDL_HapticNumEffects(SDL_Haptic*); + int SDL_HapticNumEffectsPlaying(SDL_Haptic*); + uint SDL_HapticQuery(SDL_Haptic*); + int SDL_HapticNumAxes(SDL_Haptic*); + int SDL_HapticEffectSupported(SDL_Haptic*,SDL_HapticEffect*); + int SDL_HapticNewEffect(SDL_Haptic*,SDL_HapticEffect*); + int SDL_HapticUpdateEffect(SDL_Haptic*,int,SDL_HapticEffect*); + int SDL_HapticRunEffect(SDL_Haptic*,int,uint); + int SDL_HapticStopEffect(SDL_Haptic*,int); + int SDL_HapticDestroyEffect(SDL_Haptic*,int); + int SDL_HapticGetEffectStatus(SDL_Haptic*,int); + int SDL_HapticSetGain(SDL_Haptic*,int); + int SDL_HapticSetAutocenter(SDL_Haptic*,int); + int SDL_HapticPause(SDL_Haptic*); + int SDL_HapticUnpause(SDL_Haptic*); + int SDL_HapticStopAll(SDL_Haptic*); + int SDL_HapticRumbleSupported(SDL_Haptic*); + int SDL_HapticRumbleInit(SDL_Haptic*); + int SDL_HapticRumblePlay(SDL_Haptic*,float,uint); + int SDL_HapticRumbleStop(SDL_Haptic*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_NumHaptics = int function(); + alias pSDL_HapticName = const(char)* function(int); + alias pSDL_HapticOpen = SDL_Haptic* function(int); + alias pSDL_HapticOpened = int function(int); + alias pSDL_HapticIndex = int function(SDL_Haptic*); + alias pSDL_MouseIsHaptic = int function(); + alias pSDL_HapticOpenFromMouse = SDL_Haptic* function(); + alias pSDL_JoystickIsHaptic = int function(SDL_Joystick*); + alias pSDL_HapticOpenFromJoystick = SDL_Haptic* function(SDL_Joystick*); + alias pSDL_HapticClose = int function(SDL_Haptic*); + alias pSDL_HapticNumEffects = int function(SDL_Haptic*); + alias pSDL_HapticNumEffectsPlaying = int function(SDL_Haptic*); + alias pSDL_HapticQuery = uint function(SDL_Haptic*); + alias pSDL_HapticNumAxes = int function(SDL_Haptic*); + alias pSDL_HapticEffectSupported = int function(SDL_Haptic*,SDL_HapticEffect*); + alias pSDL_HapticNewEffect = int function(SDL_Haptic*,SDL_HapticEffect*); + alias pSDL_HapticUpdateEffect = int function(SDL_Haptic*,int,SDL_HapticEffect*); + alias pSDL_HapticRunEffect = int function(SDL_Haptic*,int,uint); + alias pSDL_HapticStopEffect = int function(SDL_Haptic*,int); + alias pSDL_HapticDestroyEffect = int function(SDL_Haptic*,int); + alias pSDL_HapticGetEffectStatus = int function(SDL_Haptic*,int); + alias pSDL_HapticSetGain = int function(SDL_Haptic*,int); + alias pSDL_HapticSetAutocenter = int function(SDL_Haptic*,int); + alias pSDL_HapticPause = int function(SDL_Haptic*); + alias pSDL_HapticUnpause = int function(SDL_Haptic*); + alias pSDL_HapticStopAll = int function(SDL_Haptic*); + alias pSDL_HapticRumbleSupported = int function(SDL_Haptic*); + alias pSDL_HapticRumbleInit = int function(SDL_Haptic*); + alias pSDL_HapticRumblePlay = int function(SDL_Haptic*,float,uint); + alias pSDL_HapticRumbleStop = int function(SDL_Haptic*); + } + + __gshared { + pSDL_NumHaptics SDL_NumHaptics; + pSDL_HapticName SDL_HapticName; + pSDL_HapticOpen SDL_HapticOpen; + pSDL_HapticOpened SDL_HapticOpened; + pSDL_HapticIndex SDL_HapticIndex; + pSDL_MouseIsHaptic SDL_MouseIsHaptic; + pSDL_HapticOpenFromMouse SDL_HapticOpenFromMouse; + pSDL_JoystickIsHaptic SDL_JoystickIsHaptic; + pSDL_HapticOpenFromJoystick SDL_HapticOpenFromJoystick; + pSDL_HapticClose SDL_HapticClose; + pSDL_HapticNumEffects SDL_HapticNumEffects; + pSDL_HapticNumEffectsPlaying SDL_HapticNumEffectsPlaying; + pSDL_HapticQuery SDL_HapticQuery; + pSDL_HapticNumAxes SDL_HapticNumAxes; + pSDL_HapticEffectSupported SDL_HapticEffectSupported; + pSDL_HapticNewEffect SDL_HapticNewEffect; + pSDL_HapticUpdateEffect SDL_HapticUpdateEffect; + pSDL_HapticRunEffect SDL_HapticRunEffect; + pSDL_HapticStopEffect SDL_HapticStopEffect; + pSDL_HapticDestroyEffect SDL_HapticDestroyEffect; + pSDL_HapticGetEffectStatus SDL_HapticGetEffectStatus; + pSDL_HapticSetGain SDL_HapticSetGain; + pSDL_HapticSetAutocenter SDL_HapticSetAutocenter; + pSDL_HapticPause SDL_HapticPause; + pSDL_HapticUnpause SDL_HapticUnpause; + pSDL_HapticStopAll SDL_HapticStopAll; + pSDL_HapticRumbleSupported SDL_HapticRumbleSupported; + pSDL_HapticRumbleInit SDL_HapticRumbleInit; + pSDL_HapticRumblePlay SDL_HapticRumblePlay; + pSDL_HapticRumbleStop SDL_HapticRumbleStop; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlhints.d b/demos/external/imports/bindbc/sdl/bind/sdlhints.d new file mode 100644 index 0000000..e5aad86 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlhints.d @@ -0,0 +1,186 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlhints; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +enum SDL_HINT_FRAMEBUFFER_ACCELERATION = "SDL_FRAMEBUFFER_ACCELERATION"; +enum SDL_HINT_RENDER_DRIVER = "SDL_RENDER_DRIVER"; +enum SDL_HINT_RENDER_OPENGL_SHADERS = "SDL_RENDER_OPENGL_SHADERS"; +enum SDL_HINT_RENDER_SCALE_QUALITY = "SDL_RENDER_SCALE_QUALITY"; +enum SDL_HINT_RENDER_VSYNC = "SDL_RENDER_VSYNC"; +enum SDL_HINT_VIDEO_X11_XVIDMODE = "SDL_VIDEO_X11_XVIDMODE"; +enum SDL_HINT_VIDEO_X11_XINERAMA = "SDL_VIDEO_X11_XINERAMA"; +enum SDL_HINT_VIDEO_X11_XRANDR = "SDL_VIDEO_X11_XRANDR"; +enum SDL_HINT_GRAB_KEYBOARD = "SDL_GRAB_KEYBOARD"; +enum SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"; +enum SDL_HINT_IDLE_TIMER_DISABLED = "SDL_IOS_IDLE_TIMER_DISABLED"; +enum SDL_HINT_ORIENTATIONS = "SDL_IOS_ORIENTATIONS"; +enum SDL_HINT_XINPUT_ENABLED = "SDL_XINPUT_ENABLED"; +enum SDL_HINT_GAMECONTROLLERCONFIG = "SDL_GAMECONTROLLERCONFIG"; +enum SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS = "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"; +enum SDL_HINT_ALLOW_TOPMOST = "SDL_ALLOW_TOPMOST"; +enum SDL_HINT_TIMER_RESOLUTION = "SDL_TIMER_RESOLUTION"; + +static if(sdlSupport >= SDLSupport.sdl201) { + enum SDL_HINT_RENDER_DIRECT3D_THREADSAFE = "SDL_RENDER_DIRECT3D_THREADSAFE"; + enum SDL_HINT_VIDEO_HIGHDPI_DISABLED = "SDL_VIDEO_HIGHDPI_DISABLED"; +} + +static if(sdlSupport >= SDLSupport.sdl202) { + enum SDL_HINT_VIDEO_ALLOW_SCREENSAVER = "SDL_VIDEO_ALLOW_SCREENSAVER"; + enum SDL_HINT_MOUSE_RELATIVE_MODE_WARP = "SDL_MOUSE_RELATIVE_MODE_WARP"; + enum SDL_HINT_ACCELEROMETER_AS_JOYSTICK = "SDL_ACCELEROMETER_AS_JOYSTICK"; + enum SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK = "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK"; + enum SDL_HINT_VIDEO_WIN_D3DCOMPILER = "SDL_VIDEO_WIN_D3DCOMPILER"; + enum SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT = "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"; + enum SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES = "SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES"; +} + +// This is *intended* to be == and not >=. The values for all of these changed in 2.0.4. +static if(sdlSupport == SDLSupport.sdl203) { + enum SDL_HINT_RENDER_DIRECT3D11_DEBUG = "SDL_HINT_RENDER_DIRECT3D11_DEBUG"; + enum SDL_HINT_WINRT_PRIVACY_POLICY_URL = "SDL_HINT_WINRT_PRIVACY_POLICY_URL"; + enum SDL_HINT_WINRT_PRIVACY_POLICY_LABEL = "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL"; + enum SDL_HINT_WINRT_HANDLE_BACK_BUTTON = "SDL_HINT_WINRT_HANDLE_BACK_BUTTON"; +} + +static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_HINT_VIDEO_X11_NET_WM_PING = "SDL_VIDEO_X11_NET_WM_PING"; + enum SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN = "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"; + enum SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP = "SDL_WINDOWS_ENABLE_MESSAGELOOP"; + enum SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING = "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING"; + enum SDL_HINT_THREAD_STACK_SIZE = "SDL_THREAD_STACK_SIZE"; + enum SDL_HINT_MAC_BACKGROUND_APP = "SDL_MAC_BACKGROUND_APP"; + enum SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION = "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"; + enum SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION = "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"; + enum SDL_HINT_IME_INTERNAL_EDITING = "SDL_IME_INTERNAL_EDITING"; + enum SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT = "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"; + enum SDL_HINT_NO_SIGNAL_HANDLERS = "SDL_NO_SIGNAL_HANDLERS"; + enum SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 = "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4"; + + // Changed values from those introduced in 2.0.3 + enum SDL_HINT_RENDER_DIRECT3D11_DEBUG = "SDL_RENDER_DIRECT3D11_DEBUG"; + enum SDL_HINT_WINRT_PRIVACY_POLICY_URL = "SDL_WINRT_PRIVACY_POLICY_URL"; + enum SDL_HINT_WINRT_PRIVACY_POLICY_LABEL = "SDL_WINRT_PRIVACY_POLICY_LABEL"; + enum SDL_HINT_WINRT_HANDLE_BACK_BUTTON = "SDL_WINRT_HANDLE_BACK_BUTTON"; +} + +static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH = "SDL_MOUSE_FOCUS_CLICKTHROUGH"; + enum SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS = "SDL_APPLE_TV_CONTROLLER_UI_EVENTS"; + enum SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION = "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"; + enum SDL_HINT_BMP_SAVE_LEGACY_FORMAT = "SDL_BMP_SAVE_LEGACY_FORMAT"; + enum SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING = "SDL_WINDOWS_DISABLE_THREAD_NAMING"; + enum SDL_HINT_RPI_VIDEO_LAYER = "SDL_RPI_VIDEO_LAYER"; +} + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_HINT_RENDER_LOGICAL_SIZE_MODE = "SDL_RENDER_LOGICAL_SIZE_MODE"; + enum SDL_HINT_WINDOWS_INTRESOURCE_ICON = "SDL_WINDOWS_INTRESOURCE_ICON"; + enum SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL = "SDL_WINDOWS_INTRESOURCE_ICON_SMALL"; + enum SDL_HINT_MOUSE_NORMAL_SPEED_SCALE = "SDL_MOUSE_NORMAL_SPEED_SCALE"; + enum SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE = "SDL_MOUSE_RELATIVE_SPEED_SCALE"; + enum SDL_HINT_TOUCH_MOUSE_EVENTS = "SDL_TOUCH_MOUSE_EVENTS"; + enum SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES = "SDL_GAMECONTROLLER_IGNORE_DEVICES"; + enum SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT = "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT"; + enum SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION = "SDL_QTWAYLAND_CONTENT_ORIENTATION"; + enum SDL_HINT_QTWAYLAND_WINDOW_FLAGS = "SDL_QTWAYLAND_WINDOW_FLAGS"; + enum SDL_HINT_OPENGL_ES_DRIVER = "SDL_OPENGL_ES_DRIVER"; + enum SDL_HINT_AUDIO_RESAMPLING_MODE = "SDL_AUDIO_RESAMPLING_MODE"; + enum SDL_HINT_AUDIO_CATEGORY = "SDL_AUDIO_CATEGORY"; +} + +static if(sdlSupport >= SDLSupport.sdl208) { + enum SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR = "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR"; + enum SDL_HINT_IOS_HIDE_HOME_INDICATOR = "SDL_IOS_HIDE_HOME_INDICATOR"; + enum SDL_HINT_TV_REMOTE_AS_JOYSTICK = "SDL_TV_REMOTE_AS_JOYSTICK"; + enum SDL_HINT_RETURN_KEY_HIDES_IME = "SDL_RETURN_KEY_HIDES_IME"; + enum SDL_HINT_VIDEO_DOUBLE_BUFFER = "SDL_VIDEO_DOUBLE_BUFFER"; +} + +static if(sdlSupport >= SDLSupport.sdl209) { + enum SDL_HINT_MOUSE_DOUBLE_CLICK_TIME = "SDL_MOUSE_DOUBLE_CLICK_TIME"; + enum SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS = "SDL_MOUSE_DOUBLE_CLICK_RADIUS"; + enum SDL_HINT_JOYSTICK_HIDAPI = "SDL_JOYSTICK_HIDAPI"; + enum SDL_HINT_JOYSTICK_HIDAPI_PS4 = "SDL_JOYSTICK_HIDAPI_PS4"; + enum SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE = "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"; + enum SDL_HINT_JOYSTICK_HIDAPI_STEAM = "SDL_JOYSTICK_HIDAPI_STEAM"; + enum SDL_HINT_JOYSTICK_HIDAPI_SWITCH = "SDL_JOYSTICK_HIDAPI_SWITCH"; + enum SDL_HINT_JOYSTICK_HIDAPI_XBOX = "SDL_JOYSTICK_HIDAPI_XBOX"; + enum SDL_HINT_ENABLE_STEAM_CONTROLLERS = "SDL_ENABLE_STEAM_CONTROLLERS"; + enum SDL_HINT_ANDROID_TRAP_BACK_BUTTON = "SDL_ANDROID_TRAP_BACK_BUTTON"; +} + +static if(sdlSupport >= SDLSupport.sdl2010) { + enum SDL_HINT_MOUSE_TOUCH_EVENTS = "SDL_MOUSE_TOUCH_EVENTS"; + enum SDL_HINT_GAMECONTROLLERCONFIG_FILE = "SDL_GAMECONTROLLERCONFIG_FILE"; + enum SDL_HINT_ANDROID_BLOCK_ON_PAUSE = "SDL_ANDROID_BLOCK_ON_PAUSE"; + enum SDL_HINT_RENDER_BATCHING = "SDL_RENDER_BATCHING"; + enum SDL_HINT_EVENT_LOGGING = "SDL_EVENT_LOGGING"; + enum SDL_HINT_WAVE_RIFF_CHUNK_SIZE = "SDL_WAVE_RIFF_CHUNK_SIZE"; + enum SDL_HINT_WAVE_TRUNCATION = "SDL_WAVE_TRUNCATION"; + enum SDL_HINT_WAVE_FACT_CHUNK = "SDL_WAVE_FACT_CHUNK"; +} +else static if(sdlSupport >= SDLSupport.sdl204) { + // Added in 2.0.4, removed in 2.0.10. + enum SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH = "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"; +} + +enum SDL_HintPriority { + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE, +} +mixin(expandEnum!SDL_HintPriority); + +extern(C) nothrow alias SDL_HintCallback = void function(void*, const(char)*, const(char)*); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_bool SDL_SetHintWithPriority(const(char)*,const(char)*,SDL_HintPriority); + SDL_bool SDL_SetHint(const(char)*,const(char)*); + const(char)* SDL_GetHint(const(char)*); + void SDL_AddHintCallback(const(char)*,SDL_HintCallback,void*); + void SDL_DelHintCallback(const(char)*,SDL_HintCallback,void*); + void SDL_ClearHints(); + + static if(sdlSupport >= SDLSupport.sdl205) { + SDL_bool SDL_GetHintBoolean(const(char)*,SDL_bool); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_SetHintWithPriority = SDL_bool function(const(char)*,const(char)*,SDL_HintPriority); + alias pSDL_SetHint = SDL_bool function(const(char)*,const(char)*); + alias pSDL_GetHint = const(char)* function(const(char)*); + alias pSDL_AddHintCallback = void function(const(char)*,SDL_HintCallback,void*); + alias pSDL_DelHintCallback = void function(const(char)*,SDL_HintCallback,void*); + alias pSDL_ClearHints = void function(); + } + + __gshared { + pSDL_SetHintWithPriority SDL_SetHintWithPriority; + pSDL_SetHint SDL_SetHint; + pSDL_GetHint SDL_GetHint; + pSDL_AddHintCallback SDL_AddHintCallback; + pSDL_DelHintCallback SDL_DelHintCallback; + pSDL_ClearHints SDL_ClearHints; + } + + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_GetHintBoolean = SDL_bool function(const(char)*,SDL_bool); + } + + __gshared { + pSDL_GetHintBoolean SDL_GetHintBoolean; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdljoystick.d b/demos/external/imports/bindbc/sdl/bind/sdljoystick.d new file mode 100644 index 0000000..32f54ec --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdljoystick.d @@ -0,0 +1,231 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdljoystick; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +struct SDL_Joystick; + +struct SDL_JoystickGUID { + ubyte[16] data; +} + +alias SDL_JoystickID = int; + +enum : ubyte { + SDL_HAT_CENTERED = 0x00, + SDL_HAT_UP = 0x01, + SDL_HAT_RIGHT = 0x02, + SDL_HAT_DOWN = 0x04, + SDL_HAT_LEFT = 0x08, + SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT|SDL_HAT_UP), + SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT|SDL_HAT_DOWN), + SDL_HAT_LEFTUP = (SDL_HAT_LEFT|SDL_HAT_UP), + SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT|SDL_HAT_DOWN), +} + +static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_JoystickPowerLevel { + SDL_JOYSTICK_POWER_UNKNOWN = -1, + SDL_JOYSTICK_POWER_EMPTY, + SDL_JOYSTICK_POWER_LOW, + SDL_JOYSTICK_POWER_MEDIUM, + SDL_JOYSTICK_POWER_FULL, + SDL_JOYSTICK_POWER_WIRED, + SDL_JOYSTICK_POWER_MAX + } + mixin(expandEnum!SDL_JoystickPowerLevel); +} + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_JoystickType { + SDL_JOYSTICK_TYPE_UNKNOWN, + SDL_JOYSTICK_TYPE_GAMECONTROLLER, + SDL_JOYSTICK_TYPE_WHEEL, + SDL_JOYSTICK_TYPE_ARCADE_STICK, + SDL_JOYSTICK_TYPE_FLIGHT_STICK, + SDL_JOYSTICK_TYPE_DANCE_PAD, + SDL_JOYSTICK_TYPE_GUITAR, + SDL_JOYSTICK_TYPE_DRUM_KIT, + SDL_JOYSTICK_TYPE_ARCADE_PAD, + SDL_JOYSTICK_TYPE_THROTTLE, + } + mixin(expandEnum!SDL_JoystickType); + + enum { + SDL_JOYSTICK_AXIS_MAX = 32767, + SDL_JOYSTICK_AXIS_MIN = -32768, + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_NumJoysticks(); + const(char)* SDL_JoystickNameForIndex(int); + SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int); + SDL_Joystick* SDL_JoystickOpen(int); + const(char)* SDL_JoystickName(SDL_Joystick*); + SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick*); + char* SDL_JoystickGetGUIDString(SDL_JoystickGUID); + SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const(char)*); + SDL_bool SDL_JoystickGetAttached(SDL_Joystick*); + SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick*); + int SDL_JoystickNumAxes(SDL_Joystick*); + int SDL_JoystickNumBalls(SDL_Joystick*); + int SDL_JoystickNumHats(SDL_Joystick*); + int SDL_JoystickNumButtons(SDL_Joystick*); + void SDL_JoystickUpdate(); + int SDL_JoystickEventState(int); + short SDL_JoystickGetAxis(SDL_Joystick*,int); + ubyte SDL_JoystickGetHat(SDL_Joystick*,int); + int SDL_JoystickGetBall(SDL_Joystick*,int,int*,int*); + ubyte SDL_JoystickGetButton(SDL_Joystick*,int); + void SDL_JoystickClose(SDL_Joystick*); + + static if(sdlSupport >= SDLSupport.sdl204) { + SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick*); + SDL_Joystick* SDL_JoystickFromInstanceID(SDL_JoystickID); + } + static if(sdlSupport >= SDLSupport.sdl206) { + SDL_bool SDL_JoystickGetAxisInitialState(SDL_Joystick*,int,short*); + SDL_JoystickType SDL_JoystickGetDeviceInstanceID(int); + ushort SDL_JoystickGetDeviceProduct(int); + ushort SDL_JoystickGetDeviceProductVersion(int); + SDL_JoystickType SDL_JoystickGetDeviceType(int); + ushort SDL_JoystickGetDeviceVendor(int); + ushort SDL_JoystickGetProduct(SDL_Joystick*); + ushort SDL_JoystickGetProductVersion(SDL_Joystick*); + SDL_JoystickType SDL_JoystickGetType(SDL_Joystick*); + ushort SDL_JoystickGetVendor(SDL_Joystick*); + } + static if(sdlSupport >= SDLSupport.sdl207) { + void SDL_LockJoysticks(); + void SDL_UnlockJoysticks(); + } + static if(sdlSupport >= SDLSupport.sdl209) { + int SDL_JoystickRumble(SDL_Joystick*,ushort,ushort,uint); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + int SDL_JoystickGetDevicePlayerIndex(int); + int SDL_JoystickGetPlayerIndex(SDL_Joystick*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_NumJoysticks = int function(); + alias pSDL_JoystickNameForIndex = const(char)* function(int); + alias pSDL_JoystickGetDeviceGUID = SDL_JoystickGUID function(int); + alias pSDL_JoystickOpen = SDL_Joystick* function(int); + alias pSDL_JoystickName = const(char)* function(SDL_Joystick*); + alias pSDL_JoystickGetGUID = SDL_JoystickGUID function(SDL_Joystick*); + alias pSDL_JoystickGetGUIDString = char* function(SDL_JoystickGUID); + alias pSDL_JoystickGetGUIDFromString = SDL_JoystickGUID function(const(char)*); + alias pSDL_JoystickGetAttached = SDL_bool function(SDL_Joystick*); + alias pSDL_JoystickInstanceID = SDL_JoystickID function(SDL_Joystick*); + alias pSDL_JoystickNumAxes = int function(SDL_Joystick*); + alias pSDL_JoystickNumBalls = int function(SDL_Joystick*); + alias pSDL_JoystickNumHats = int function(SDL_Joystick*); + alias pSDL_JoystickNumButtons = int function(SDL_Joystick*); + alias pSDL_JoystickUpdate = void function(); + alias pSDL_JoystickEventState = int function(int); + alias pSDL_JoystickGetAxis = short function(SDL_Joystick*,int); + alias pSDL_JoystickGetHat = ubyte function(SDL_Joystick*,int); + alias pSDL_JoystickGetBall = int function(SDL_Joystick*,int,int*,int*); + alias pSDL_JoystickGetButton = ubyte function(SDL_Joystick*,int); + alias pSDL_JoystickClose = void function(SDL_Joystick*); + } + __gshared { + pSDL_NumJoysticks SDL_NumJoysticks; + pSDL_JoystickNameForIndex SDL_JoystickNameForIndex; + pSDL_JoystickGetDeviceGUID SDL_JoystickGetDeviceGUID; + pSDL_JoystickOpen SDL_JoystickOpen; + pSDL_JoystickName SDL_JoystickName; + pSDL_JoystickGetGUID SDL_JoystickGetGUID; + pSDL_JoystickGetGUIDString SDL_JoystickGetGUIDString; + pSDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString; + pSDL_JoystickGetAttached SDL_JoystickGetAttached; + pSDL_JoystickInstanceID SDL_JoystickInstanceID; + pSDL_JoystickNumAxes SDL_JoystickNumAxes; + pSDL_JoystickNumBalls SDL_JoystickNumBalls; + pSDL_JoystickNumHats SDL_JoystickNumHats; + pSDL_JoystickNumButtons SDL_JoystickNumButtons; + pSDL_JoystickUpdate SDL_JoystickUpdate; + pSDL_JoystickEventState SDL_JoystickEventState; + pSDL_JoystickGetAxis SDL_JoystickGetAxis; + pSDL_JoystickGetHat SDL_JoystickGetHat; + pSDL_JoystickGetBall SDL_JoystickGetBall; + pSDL_JoystickGetButton SDL_JoystickGetButton; + pSDL_JoystickClose SDL_JoystickClose; + } + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_JoystickCurrentPowerLevel = SDL_JoystickPowerLevel function(SDL_Joystick*); + alias pSDL_JoystickFromInstanceID = SDL_Joystick* function(SDL_JoystickID); + } + __gshared { + pSDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel; + pSDL_JoystickFromInstanceID SDL_JoystickFromInstanceID; + } + } + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_JoystickGetAxisInitialState = SDL_bool function(SDL_Joystick*,int,short*); + alias pSDL_JoystickGetDeviceInstanceID = SDL_JoystickType function(int); + alias pSDL_JoystickGetDeviceProduct = ushort function(int); + alias pSDL_JoystickGetDeviceProductVersion = ushort function(int); + alias pSDL_JoystickGetDeviceType = SDL_JoystickType function(int); + alias pSDL_JoystickGetDeviceVendor = ushort function(int); + alias pSDL_JoystickGetProduct = ushort function(SDL_Joystick*); + alias pSDL_JoystickGetProductVersion = ushort function(SDL_Joystick*); + alias pSDL_JoystickGetType = SDL_JoystickType function(SDL_Joystick*); + alias pSDL_JoystickGetVendor = ushort function(SDL_Joystick*); + } + __gshared { + pSDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState; + pSDL_JoystickGetDeviceInstanceID SDL_JoystickGetDeviceInstanceID; + pSDL_JoystickGetDeviceProduct SDL_JoystickGetDeviceProduct; + pSDL_JoystickGetDeviceProductVersion SDL_JoystickGetDeviceProductVersion; + pSDL_JoystickGetDeviceType SDL_JoystickGetDeviceType; + pSDL_JoystickGetDeviceVendor SDL_JoystickGetDeviceVendor; + pSDL_JoystickGetProduct SDL_JoystickGetProduct; + pSDL_JoystickGetProductVersion SDL_JoystickGetProductVersion; + pSDL_JoystickGetType SDL_JoystickGetType; + pSDL_JoystickGetVendor SDL_JoystickGetVendor; + } + } + static if(sdlSupport >= SDLSupport.sdl207) { + extern(C) @nogc nothrow { + alias pSDL_LockJoysticks = void function(); + alias pSDL_UnlockJoysticks = void function(); + } + __gshared { + pSDL_LockJoysticks SDL_LockJoysticks; + pSDL_UnlockJoysticks SDL_UnlockJoysticks; + } + } + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_JoystickRumble = int function(SDL_Joystick*,ushort,ushort,uint); + } + __gshared { + pSDL_JoystickRumble SDL_JoystickRumble; + } + } + + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_JoystickGetDevicePlayerIndex = int function(int); + alias pSDL_JoystickGetPlayerIndex = int function(SDL_Joystick*); + } + __gshared { + pSDL_JoystickGetDevicePlayerIndex SDL_JoystickGetDevicePlayerIndex; + pSDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlkeyboard.d b/demos/external/imports/bindbc/sdl/bind/sdlkeyboard.d new file mode 100644 index 0000000..4f4fabe --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlkeyboard.d @@ -0,0 +1,80 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlkeyboard; + +import bindbc.sdl.bind.sdlkeycode : SDL_Keycode, SDL_Keymod; +import bindbc.sdl.bind.sdlrect : SDL_Rect; +import bindbc.sdl.bind.sdlscancode : SDL_Scancode; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +struct SDL_Keysym { + SDL_Scancode scancode; + SDL_Keycode sym; + ushort mod; + uint unused; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_Window* SDL_GetKeyboardFocus(); + ubyte* SDL_GetKeyboardState(int*); + SDL_Keymod SDL_GetModState(); + void SDL_SetModState(SDL_Keymod); + SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode); + SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode); + const(char)* SDL_GetScancodeName(SDL_Scancode); + SDL_Scancode SDL_GetScancodeFromName(const(char)*); + const(char)* SDL_GetKeyName(SDL_Keycode); + SDL_Keycode SDL_GetKeyFromName(const(char)*); + void SDL_StartTextInput(); + SDL_bool SDL_IsTextInputActive(); + void SDL_StopTextInput(); + void SDL_SetTextInputRect(SDL_Rect*); + SDL_bool SDL_HasScreenKeyboardSupport(); + SDL_bool SDL_IsScreenKeyboardShown(SDL_Window*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetKeyboardFocus = SDL_Window* function(); + alias pSDL_GetKeyboardState = ubyte* function(int*); + alias pSDL_GetModState = SDL_Keymod function(); + alias pSDL_SetModState = void function(SDL_Keymod); + alias pSDL_GetKeyFromScancode = SDL_Keycode function(SDL_Scancode); + alias pSDL_GetScancodeFromKey = SDL_Scancode function(SDL_Keycode); + alias pSDL_GetScancodeName = const(char)* function(SDL_Scancode); + alias pSDL_GetScancodeFromName = SDL_Scancode function(const(char)*); + alias pSDL_GetKeyName = const(char)* function(SDL_Keycode); + alias pSDL_GetKeyFromName = SDL_Keycode function(const(char)*); + alias pSDL_StartTextInput = void function(); + alias pSDL_IsTextInputActive = SDL_bool function(); + alias pSDL_StopTextInput = void function(); + alias pSDL_SetTextInputRect = void function(SDL_Rect*); + alias pSDL_HasScreenKeyboardSupport = SDL_bool function(); + alias pSDL_IsScreenKeyboardShown = SDL_bool function(SDL_Window*); + } + + __gshared { + pSDL_GetKeyboardFocus SDL_GetKeyboardFocus; + pSDL_GetKeyboardState SDL_GetKeyboardState; + pSDL_GetModState SDL_GetModState; + pSDL_SetModState SDL_SetModState; + pSDL_GetKeyFromScancode SDL_GetKeyFromScancode; + pSDL_GetScancodeFromKey SDL_GetScancodeFromKey; + pSDL_GetScancodeName SDL_GetScancodeName; + pSDL_GetScancodeFromName SDL_GetScancodeFromName; + pSDL_GetKeyName SDL_GetKeyName; + pSDL_GetKeyFromName SDL_GetKeyFromName; + pSDL_StartTextInput SDL_StartTextInput; + pSDL_IsTextInputActive SDL_IsTextInputActive; + pSDL_StopTextInput SDL_StopTextInput; + pSDL_SetTextInputRect SDL_SetTextInputRect; + pSDL_HasScreenKeyboardSupport SDL_HasScreenKeyboardSupport; + pSDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown; + } +} diff --git a/demos/external/imports/bindbc/sdl/bind/sdlkeycode.d b/demos/external/imports/bindbc/sdl/bind/sdlkeycode.d new file mode 100644 index 0000000..127067e --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlkeycode.d @@ -0,0 +1,288 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlkeycode; + +import bindbc.sdl.config, + bindbc.sdl.bind.sdlscancode; + +enum SDLK_SCANCODE_MASK = 1<<30; + +enum SDL_SCANCODE_TO_KEYCODE(SDL_Scancode x) = x | SDLK_SCANCODE_MASK; + +enum SDL_Keycode { + SDLK_UNKNOWN = 0, + SDLK_RETURN = '\r', + SDLK_ESCAPE = '\033', + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CAPSLOCK), + + SDLK_F1 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F1), + SDLK_F2 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F2), + SDLK_F3 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F3), + SDLK_F4 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F4), + SDLK_F5 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F5), + SDLK_F6 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F6), + SDLK_F7 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F7), + SDLK_F8 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F8), + SDLK_F9 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F9), + SDLK_F10 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F10), + SDLK_F11 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F11), + SDLK_F12 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F12), + + SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PRINTSCREEN), + SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_SCROLLLOCK), + SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PAUSE), + SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_INSERT), + SDLK_HOME = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_HOME), + SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PAGEUP), + SDLK_DELETE = '\177', + SDLK_END = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_END), + SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PAGEDOWN), + SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RIGHT), + SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_LEFT), + SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_DOWN), + SDLK_UP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_UP), + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR), + SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_DIVIDE), + SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY), + SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MINUS), + SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_PLUS), + SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_ENTER), + SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_1), + SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_2), + SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_3), + SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_4), + SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_5), + SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_6), + SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_7), + SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_8), + SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_9), + SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_0), + SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_PERIOD), + + SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_APPLICATION), + SDLK_POWER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_POWER), + SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_EQUALS), + SDLK_F13 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F13), + SDLK_F14 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F14), + SDLK_F15 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F15), + SDLK_F16 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F16), + SDLK_F17 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F17), + SDLK_F18 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F18), + SDLK_F19 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F19), + SDLK_F20 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F20), + SDLK_F21 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F21), + SDLK_F22 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F22), + SDLK_F23 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F23), + SDLK_F24 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_F24), + SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_EXECUTE), + SDLK_HELP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_HELP), + SDLK_MENU = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_MENU), + SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_SELECT), + SDLK_STOP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_STOP), + SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AGAIN), + SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_UNDO), + SDLK_CUT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CUT), + SDLK_COPY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_COPY), + SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PASTE), + SDLK_FIND = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_FIND), + SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_MUTE), + SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_VOLUMEUP), + SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_VOLUMEDOWN), + SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_COMMA), + SDLK_KP_EQUALSAS400 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_EQUALSAS400), + + SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_ALTERASE), + SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_SYSREQ), + SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CANCEL), + SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CLEAR), + SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_PRIOR), + SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RETURN2), + SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_SEPARATOR), + SDLK_OUT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_OUT), + SDLK_OPER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_OPER), + SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CLEARAGAIN), + SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CRSEL), + SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_EXSEL), + + SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_00), + SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_000), + SDLK_THOUSANDSSEPARATOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_THOUSANDSSEPARATOR), + SDLK_DECIMALSEPARATOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_DECIMALSEPARATOR), + SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CURRENCYUNIT), + SDLK_CURRENCYSUBUNIT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CURRENCYSUBUNIT), + SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_LEFTPAREN), + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_RIGHTPAREN), + SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_LEFTBRACE), + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_RIGHTBRACE), + SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_TAB), + SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_BACKSPACE), + SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_A), + SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_B), + SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_C), + SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_D), + SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_E), + SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_F), + SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_XOR), + SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_POWER), + SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_PERCENT), + SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_LESS), + SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_GREATER), + SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_AMPERSAND), + SDLK_KP_DBLAMPERSAND = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_DBLAMPERSAND), + SDLK_KP_VERTICALBAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_VERTICALBAR), + SDLK_KP_DBLVERTICALBAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_DBLVERTICALBAR), + SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_COLON), + SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_HASH), + SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_SPACE), + SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_AT), + SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_EXCLAM), + SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMSTORE), + SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMRECALL), + SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMCLEAR), + SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMADD), + SDLK_KP_MEMSUBTRACT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMSUBTRACT), + SDLK_KP_MEMMULTIPLY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMMULTIPLY), + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_MEMDIVIDE), + SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_PLUSMINUS), + SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_CLEAR), + SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_CLEARENTRY), + SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_BINARY), + SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_OCTAL), + SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_DECIMAL), + SDLK_KP_HEXADECIMAL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KP_HEXADECIMAL), + + SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_LCTRL), + SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_LSHIFT), + SDLK_LALT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_LALT), + SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_LGUI), + SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RCTRL), + SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RSHIFT), + SDLK_RALT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RALT), + SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_RGUI), + + SDLK_MODE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_MODE), + + SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AUDIONEXT), + SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AUDIOPREV), + SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AUDIOSTOP), + SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AUDIOPLAY), + SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AUDIOMUTE), + SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_MEDIASELECT), + SDLK_WWW = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_WWW), + SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_MAIL), + SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_CALCULATOR), + SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_COMPUTER), + SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_SEARCH), + SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_HOME), + SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_BACK), + SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_FORWARD), + SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_STOP), + SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_REFRESH), + SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_AC_BOOKMARKS), + + SDLK_BRIGHTNESSDOWN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_BRIGHTNESSDOWN), + SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_BRIGHTNESSUP), + SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_DISPLAYSWITCH), + SDLK_KBDILLUMTOGGLE = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KBDILLUMTOGGLE), + SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KBDILLUMDOWN), + SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_KBDILLUMUP), + SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_EJECT), + SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE!(SDL_Scancode.SDL_SCANCODE_SLEEP), +} +mixin(expandEnum!SDL_Keycode); + +enum SDL_Keymod { + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000, + + KMOD_CTRL = (KMOD_LCTRL|KMOD_RCTRL), + KMOD_SHIFT = (KMOD_LSHIFT|KMOD_RSHIFT), + KMOD_ALT = (KMOD_LALT|KMOD_RALT), + KMOD_GUI = (KMOD_LGUI|KMOD_RGUI), +} +mixin(expandEnum!SDL_Keymod); \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlloadso.d b/demos/external/imports/bindbc/sdl/bind/sdlloadso.d new file mode 100644 index 0000000..02f9b62 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlloadso.d @@ -0,0 +1,28 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlloadso; + +version(BindSDL_Static){ + extern(C) @nogc nothrow { + void* SDL_LoadObject(const(char)*); + void* SDL_LoadFunction(void*,const(char*)); + void SDL_UnloadObject(void*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_LoadObject = void* function(const(char)*); + alias pSDL_LoadFunction = void* function(void*,const(char*)); + alias pSDL_UnloadObject = void function(void*); + } + + __gshared { + pSDL_LoadObject SDL_LoadObject; + pSDL_LoadFunction SDL_LoadFunction; + pSDL_UnloadObject SDL_UnloadObject; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdllog.d b/demos/external/imports/bindbc/sdl/bind/sdllog.d new file mode 100644 index 0000000..3ff5b4c --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdllog.d @@ -0,0 +1,107 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdllog; + +import core.stdc.stdarg : va_list; +import bindbc.sdl.config; + +enum SDL_MAX_LOG_MESSAGE = 4096; + +enum { + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + SDL_LOG_CATEGORY_CUSTOM +} + +enum SDL_LogPriority { + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} +mixin(expandEnum!SDL_LogPriority); + +extern(C) nothrow alias SDL_LogOutputFunction = void function(void*, int, SDL_LogPriority, const(char)*); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_LogSetAllPriority(SDL_LogPriority); + void SDL_LogSetPriority(int,SDL_LogPriority); + SDL_LogPriority SDL_LogGetPriority(int); + void SDL_LogResetPriorities(); + void SDL_Log(const(char)*,...); + void SDL_LogVerbose(int,const(char)*,...); + void SDL_LogDebug(int,const(char)*,...); + void SDL_LogInfo(int,const(char)*,...); + void SDL_LogWarn(int,const(char)*,...); + void SDL_LogError(int,const(char)*,...); + void SDL_LogCritical(int,const(char)*,...); + void SDL_LogMessage(int,SDL_LogPriority,const(char)*,...); + void SDL_LogMessageV(int,SDL_LogPriority,const(char)*,va_list); + void SDL_LogGetOutputFunction(SDL_LogOutputFunction,void**); + void SDL_LogSetOutputFunction(SDL_LogOutputFunction,void*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_LogSetAllPriority = void function(SDL_LogPriority); + alias pSDL_LogSetPriority = void function(int,SDL_LogPriority); + alias pSDL_LogGetPriority = SDL_LogPriority function(int); + alias pSDL_LogResetPriorities = void function(); + alias pSDL_Log = void function(const(char)*,...); + alias pSDL_LogVerbose = void function(int,const(char)*,...); + alias pSDL_LogDebug = void function(int,const(char)*,...); + alias pSDL_LogInfo = void function(int,const(char)*,...); + alias pSDL_LogWarn = void function(int,const(char)*,...); + alias pSDL_LogError = void function(int,const(char)*,...); + alias pSDL_LogCritical = void function(int,const(char)*,...); + alias pSDL_LogMessage = void function(int,SDL_LogPriority,const(char)*,...); + alias pSDL_LogMessageV = void function(int,SDL_LogPriority,const(char)*,va_list); + alias pSDL_LogGetOutputFunction = void function(SDL_LogOutputFunction,void**); + alias pSDL_LogSetOutputFunction = void function(SDL_LogOutputFunction,void*); + } + + __gshared { + pSDL_LogSetAllPriority SDL_LogSetAllPriority; + pSDL_LogSetPriority SDL_LogSetPriority; + pSDL_LogGetPriority SDL_LogGetPriority; + pSDL_LogResetPriorities SDL_LogResetPriorities; + pSDL_Log SDL_Log; + pSDL_LogVerbose SDL_LogVerbose; + pSDL_LogDebug SDL_LogDebug; + pSDL_LogInfo SDL_LogInfo; + pSDL_LogWarn SDL_LogWarn; + pSDL_LogError SDL_LogError; + pSDL_LogCritical SDL_LogCritical; + pSDL_LogMessage SDL_LogMessage; + pSDL_LogMessageV SDL_LogMessageV; + pSDL_LogGetOutputFunction SDL_LogGetOutputFunction; + pSDL_LogSetOutputFunction SDL_LogSetOutputFunction; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlmessagebox.d b/demos/external/imports/bindbc/sdl/bind/sdlmessagebox.d new file mode 100644 index 0000000..89636f5 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlmessagebox.d @@ -0,0 +1,75 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlmessagebox; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +enum SDL_MessageBoxFlags { + SDL_MESSAGEBOX_ERROR = 0x00000010, + SDL_MESSAGEBOX_WARNING = 0x00000020, + SDL_MESSAGEBOX_INFORMATION = 0x00000040, +} +mixin(expandEnum!SDL_MessageBoxFlags); + +enum SDL_MessageBoxButtonFlags { + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002, +} +mixin(expandEnum!SDL_MessageBoxButtonFlags); + +struct SDL_MessageBoxButtonData { + uint flags; + int buttonid; + const(char)* text; +} + +struct SDL_MessageBoxColor { + ubyte r, g, b; +} + +enum SDL_MessageBoxColorType { + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX, +} +mixin(expandEnum!SDL_MessageBoxColorType); + +struct SDL_MessageBoxColorScheme { + SDL_MessageBoxColor[SDL_MESSAGEBOX_COLOR_MAX] colors; +} + +struct SDL_MessageBoxData { + uint flags; + SDL_Window* window; + const(char)* title; + const(char)* message; + int numbuttons; + const(SDL_MessageBoxButtonData)* buttons; + const(SDL_MessageBoxColorScheme)* colorScheme; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_ShowMessageBox(const(SDL_MessageBoxData)*,int*); + int SDL_ShowSimpleMessageBox(uint,const(char)*,const(char)*,SDL_Window*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_ShowMessageBox = int function(const(SDL_MessageBoxData)*,int*); + alias pSDL_ShowSimpleMessageBox = int function(uint,const(char)*,const(char)*,SDL_Window*); + } + + __gshared { + pSDL_ShowMessageBox SDL_ShowMessageBox; + pSDL_ShowSimpleMessageBox SDL_ShowSimpleMessageBox; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlmouse.d b/demos/external/imports/bindbc/sdl/bind/sdlmouse.d new file mode 100644 index 0000000..f9fc492 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlmouse.d @@ -0,0 +1,140 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlmouse; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +struct SDL_Cursor; + +enum SDL_SystemCursor { + SDL_SYSTEM_CURSOR_ARROW, + SDL_SYSTEM_CURSOR_IBEAM, + SDL_SYSTEM_CURSOR_WAIT, + SDL_SYSTEM_CURSOR_CROSSHAIR, + SDL_SYSTEM_CURSOR_WAITARROW, + SDL_SYSTEM_CURSOR_SIZENWSE, + SDL_SYSTEM_CURSOR_SIZENESW, + SDL_SYSTEM_CURSOR_SIZEWE, + SDL_SYSTEM_CURSOR_SIZENS, + SDL_SYSTEM_CURSOR_SIZEALL, + SDL_SYSTEM_CURSOR_NO, + SDL_SYSTEM_CURSOR_HAND, + SDL_NUM_SYSTEM_CURSORS +} + +alias SDL_SYSTEM_CURSOR_ARROW = SDL_SystemCursor.SDL_SYSTEM_CURSOR_ARROW; +alias SDL_SYSTEM_CURSOR_IBEAM = SDL_SystemCursor.SDL_SYSTEM_CURSOR_IBEAM; +alias SDL_SYSTEM_CURSOR_WAIT = SDL_SystemCursor.SDL_SYSTEM_CURSOR_WAIT; +alias SDL_SYSTEM_CURSOR_CROSSHAIR = SDL_SystemCursor.SDL_SYSTEM_CURSOR_CROSSHAIR; +alias SDL_SYSTEM_CURSOR_WAITARROW = SDL_SystemCursor.SDL_SYSTEM_CURSOR_WAITARROW; +alias SDL_SYSTEM_CURSOR_SIZENWSE = SDL_SystemCursor.SDL_SYSTEM_CURSOR_SIZENWSE; +alias SDL_SYSTEM_CURSOR_SIZENESW = SDL_SystemCursor.SDL_SYSTEM_CURSOR_SIZENESW; +alias SDL_SYSTEM_CURSOR_SIZEWE = SDL_SystemCursor.SDL_SYSTEM_CURSOR_SIZEWE; +alias SDL_SYSTEM_CURSOR_SIZENS = SDL_SystemCursor.SDL_SYSTEM_CURSOR_SIZENS; +alias SDL_SYSTEM_CURSOR_SIZEALL = SDL_SystemCursor.SDL_SYSTEM_CURSOR_SIZEALL; +alias SDL_SYSTEM_CURSOR_NO = SDL_SystemCursor.SDL_SYSTEM_CURSOR_NO; +alias SDL_SYSTEM_CURSOR_HAND = SDL_SystemCursor.SDL_SYSTEM_CURSOR_HAND; +alias SDL_NUM_SYSTEM_CURSORS = SDL_SystemCursor.SDL_NUM_SYSTEM_CURSORS; + +enum SDL_BUTTON(ubyte x) = 1 << (x-1); + +enum : ubyte { + SDL_BUTTON_LEFT = 1, + SDL_BUTTON_MIDDLE = 2, + SDL_BUTTON_RIGHT = 3, + SDL_BUTTON_X1 = 4, + SDL_BUTTON_X2 = 5, + SDL_BUTTON_LMASK = SDL_BUTTON!(SDL_BUTTON_LEFT), + SDL_BUTTON_MMASK = SDL_BUTTON!(SDL_BUTTON_MIDDLE), + SDL_BUTTON_RMASK = SDL_BUTTON!(SDL_BUTTON_RIGHT), + SDL_BUTTON_X1MASK = SDL_BUTTON!(SDL_BUTTON_X1), + SDL_BUTTON_X2MASK = SDL_BUTTON!(SDL_BUTTON_X2), +} + +static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_MouseWheelDirection { + SDL_MOUSEWHEEL_NORMAL, + SDL_MOUSEWHEEL_FLIPPED, + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_Window* SDL_GetMouseFocus(); + uint SDL_GetMouseState(int*,int*); + uint SDL_GetRelativeMouseState(int*,int*); + void SDL_WarpMouseInWindow(SDL_Window*,int,int); + int SDL_SetRelativeMouseMode(SDL_bool); + SDL_bool SDL_GetRelativeMouseMode(); + SDL_Cursor* SDL_CreateCursor(const(ubyte)*,const(ubyte)*,int,int,int,int); + SDL_Cursor* SDL_CreateColorCursor(SDL_Surface*,int,int); + SDL_Cursor* SDL_CreateSystemCursor(SDL_SystemCursor); + void SDL_SetCursor(SDL_Cursor*); + SDL_Cursor* SDL_GetCursor(); + SDL_Cursor* SDL_GetDefaultCursor(); + void SDL_FreeCursor(SDL_Cursor*); + int SDL_ShowCursor(int); + + static if(sdlSupport >= SDLSupport.sdl204) { + int SDL_CaptureMouse(SDL_bool); + uint SDL_GetGlobalMouseState(int*,int*); + void SDL_WarpMouseGlobal(int,int); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetMouseFocus = SDL_Window* function(); + alias pSDL_GetMouseState = uint function(int*,int*); + alias pSDL_GetRelativeMouseState = uint function(int*,int*); + alias pSDL_WarpMouseInWindow = void function(SDL_Window*,int,int); + alias pSDL_SetRelativeMouseMode = int function(SDL_bool); + alias pSDL_GetRelativeMouseMode = SDL_bool function(); + alias pSDL_CreateCursor = SDL_Cursor* function(const(ubyte)*,const(ubyte)*,int,int,int,int); + alias pSDL_CreateColorCursor = SDL_Cursor* function(SDL_Surface*,int,int); + alias pSDL_CreateSystemCursor = SDL_Cursor* function(SDL_SystemCursor); + alias pSDL_SetCursor = void function(SDL_Cursor*); + alias pSDL_GetCursor = SDL_Cursor* function(); + alias pSDL_GetDefaultCursor = SDL_Cursor* function(); + alias pSDL_FreeCursor = void function(SDL_Cursor*); + alias pSDL_ShowCursor = int function(int); + } + + __gshared { + pSDL_GetMouseFocus SDL_GetMouseFocus; + pSDL_GetMouseState SDL_GetMouseState; + pSDL_GetRelativeMouseState SDL_GetRelativeMouseState; + pSDL_WarpMouseInWindow SDL_WarpMouseInWindow; + pSDL_SetRelativeMouseMode SDL_SetRelativeMouseMode; + pSDL_GetRelativeMouseMode SDL_GetRelativeMouseMode; + pSDL_CreateCursor SDL_CreateCursor; + pSDL_CreateColorCursor SDL_CreateColorCursor; + pSDL_CreateSystemCursor SDL_CreateSystemCursor; + pSDL_SetCursor SDL_SetCursor; + pSDL_GetCursor SDL_GetCursor; + pSDL_GetDefaultCursor SDL_GetDefaultCursor; + pSDL_FreeCursor SDL_FreeCursor; + pSDL_ShowCursor SDL_ShowCursor; + } + + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_CaptureMouse = int function(SDL_bool); + alias pSDL_GetGlobalMouseState = uint function(int*,int*); + alias pSDL_WarpMouseGlobal = void function(int,int); + } + + __gshared { + pSDL_CaptureMouse SDL_CaptureMouse; + pSDL_GetGlobalMouseState SDL_GetGlobalMouseState; + pSDL_WarpMouseGlobal SDL_WarpMouseGlobal; + } + } +} diff --git a/demos/external/imports/bindbc/sdl/bind/sdlpixels.d b/demos/external/imports/bindbc/sdl/bind/sdlpixels.d new file mode 100644 index 0000000..7d65753 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlpixels.d @@ -0,0 +1,283 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlpixels; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_FOURCC, SDL_bool; + +enum SDL_ALPHA_OPAQUE = 255; +enum SDL_ALPHA_TRANSPARENT = 0; + +enum { + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 +} + +enum { + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +} + +enum { + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +} + +enum { + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +} + +enum { + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +} + +alias SDL_DEFINE_PIXELFOURCC = SDL_FOURCC; + +enum uint SDL_DEFINE_PIXELFORMAT(int type, int order, int layout, int bits, int bytes) = + (1 << 28) | (type << 24) | (order << 20) | (layout << 16) | (bits << 8) | (bytes << 0); + +enum uint SDL_PIXELFLAG(uint x) = (x >> 28) & 0x0F; +enum uint SDL_PIXELTYPE(uint x) = (x >> 24) & 0x0F; +enum uint SDL_PIXELORDER(uint x) = (x >> 20) & 0x0F; +enum uint SDL_PIXELLAYOUT(uint x) = (x >> 16) & 0x0F; +enum uint SDL_BITSPERPIXEL(uint x) = (x >> 8) & 0xFF; + +template SDL_BYTESPERPIXEL(uint x) { + static if(SDL_ISPIXELFORMAT_FOURCC!x) { + static if(x == SDL_PIXELFORMAT_YUY2 || x == SDL_PIXELFORMAT_UYVY || x == SDL_PIXELFORMAT_YVYU) + enum SDL_BYTESPERPIXEL = 2; + else enum SDL_BYTESPERPIXEL = 1; + } + else enum SDL_BYTESPERPIXEL = (x >> 0) & 0xFF; +} + +template SDL_ISPIXELFORMAT_INDEXED(uint format) { + static if(SDL_ISPIXELFORMAT_FOURCC!format) { + enum SDL_ISPIXELFORMAT_INDEXED = SDL_PIXELTYPE!format == SDL_PIXELTYPE_INDEX1 || SDL_PIXELTYPE!format == SDL_PIXELTYPE_INDEX4 || + SDL_PIXELTYPE!format == SDL_PIXELTYPE_INDEX8; + } + else enum SDL_ISPIXELFORMAT_INDEXED = false; +} + +template SDL_ISPIXELFORMAT_PACKED(uint format) { + static if(SDL_ISPIXELFORMAT_FOURCC!format) { + enum SDL_ISPIXELFORMAT_PACKED = SDL_PIXELTYPE!format == SDL_PIXELTYPE_PACKED8 || SDL_PIXELTYPE!format == SDL_PIXELTYPE_PACKED16 || + SDL_PIXELTYPE!format == SDL_PIXELTYPE_PACKED32; + } + else enum SDL_ISPIXELFORMAT_PACKED = false; +} + +static if(sdlSupport >= SDLSupport.sdl204) { + template SDL_ISPIXELFORMAT_ARRAY(uint format) { + static if(SDL_ISPIXELFORMAT_FOURCC!format) { + enum SDL_ISPIXELFORMAT_ARRAY = SDL_PIXELTYPE!format == SDL_PIXELTYPE_ARRAYU8 || SDL_PIXELTYPE!format == SDL_PIXELTYPE_ARRAYU16 || + SDL_PIXELTYPE!format == SDL_PIXELTYPE_ARRAYU32 || SDL_PIXELTYPE!format == SDL_PIXELTYPE_ARRAYF16 || + SDL_PIXELTYPE!format == SDL_PIXELTYPE_ARRAYF32; + } + else enum SDL_ISPIXELFORMAT_ARRAY = false; + } +} + +template SDL_ISPIXELFORMAT_ALPHA(uint format) { + static if(SDL_ISPIXELFORMAT_PACKED!format) { + enum SDL_ISPIXELFORMAT_ALPHA = (SDL_PIXELORDER!format == SDL_PACKEDORDER_ARGB || SDL_PIXELORDER!format == SDL_PACKEDORDER_RGBA || + SDL_PIXELORDER!format == SDL_PACKEDORDER_ABGR || SDL_PIXELORDER!format == SDL_PACKEDORDER_BGRA); + } + else static if(sdlSupport >= SDLSupport.sdl204 && SDL_ISPIXELFORMAT_ARRAY!format) { + enum SDL_ISPIXELFORMAT_ALPHA = (SDL_PIXELORDER!format == SDL_ARRAYORDER_ARGB || SDL_PIXELORDER!format == SDL_ARRAYORDER_RGBA || + SDL_PIXELORDER!format == SDL_ARRAYORDER_ABGR || SDL_PIXELORDER!format == SDL_ARRAYORDER_BGRA); + } + else enum SDL_ISPIXELFORMAT_ALPHA = false; +} + +enum SDL_ISPIXELFORMAT_FOURCC(uint format) = format && !(format & 0x80000000); + +enum SDL_PIXELFORMAT_UNKNOWN = 0; +enum SDL_PIXELFORMAT_INDEX1LSB = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0); +enum SDL_PIXELFORMAT_INDEX1MSB = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0); +enum SDL_PIXELFORMAT_INDEX4LSB = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0); +enum SDL_PIXELFORMAT_INDEX4MSB = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0); +enum SDL_PIXELFORMAT_INDEX8 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1); +enum SDL_PIXELFORMAT_RGB332 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1); +enum SDL_PIXELFORMAT_RGB444 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2); +enum SDL_PIXELFORMAT_RGB555 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2); +enum SDL_PIXELFORMAT_BGR555 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2); +enum SDL_PIXELFORMAT_ARGB4444 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2); +enum SDL_PIXELFORMAT_RGBA4444 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2); +enum SDL_PIXELFORMAT_ABGR4444 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2); +enum SDL_PIXELFORMAT_BGRA4444 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2); +enum SDL_PIXELFORMAT_ARGB1555 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2); +enum SDL_PIXELFORMAT_RGBA5551 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2); +enum SDL_PIXELFORMAT_ABGR1555 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2); +enum SDL_PIXELFORMAT_BGRA5551 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2); +enum SDL_PIXELFORMAT_RGB565 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2); +enum SDL_PIXELFORMAT_BGR565 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2); +enum SDL_PIXELFORMAT_RGB24 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3); +enum SDL_PIXELFORMAT_BGR24 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3); +enum SDL_PIXELFORMAT_RGB888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4); +enum SDL_PIXELFORMAT_RGBX8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4); +enum SDL_PIXELFORMAT_BGR888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4); +enum SDL_PIXELFORMAT_BGRX8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4); +enum SDL_PIXELFORMAT_ARGB8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4); +enum SDL_PIXELFORMAT_RGBA8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4); +enum SDL_PIXELFORMAT_ABGR8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4); +enum SDL_PIXELFORMAT_BGRA8888 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4); +enum SDL_PIXELFORMAT_ARGB2101010 = SDL_DEFINE_PIXELFORMAT!(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4); + +enum SDL_PIXELFORMAT_YV12 = SDL_DEFINE_PIXELFOURCC!('Y', 'V', '1', '2'); +enum SDL_PIXELFORMAT_IYUV = SDL_DEFINE_PIXELFOURCC!('I', 'Y', 'U', 'V'); +enum SDL_PIXELFORMAT_YUY2 = SDL_DEFINE_PIXELFOURCC!('Y', 'U', 'Y', '2'); +enum SDL_PIXELFORMAT_UYVY = SDL_DEFINE_PIXELFOURCC!('U', 'Y', 'V', 'Y'); +enum SDL_PIXELFORMAT_YVYU = SDL_DEFINE_PIXELFOURCC!('Y', 'V', 'Y', 'U'); + +static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_PIXELFORMAT_NV12 = SDL_DEFINE_PIXELFOURCC!('N', 'V', '1', '2'); + enum SDL_PIXELFORMAT_NV21 = SDL_DEFINE_PIXELFOURCC!('N', 'V', '2', '1'); +} + +static if(sdlSupport >= SDLSupport.sdl208) { + enum SDL_PIXELFORMAT_EXTERNAL_OES = SDL_DEFINE_PIXELFOURCC!('O', 'E', 'S', ' '); +} + +static assert(SDL_PIXELFORMAT_BGRX8888 == 0x16661804); + +// Added in SDL 2.0.5, but doesn't hurt to make available for every version. +version(BigEndian) { + alias SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888; + alias SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888; + alias SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888; + alias SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888; +} +else { + alias SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888; + alias SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888; + alias SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888; + alias SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888; +} + +struct SDL_Color { + ubyte r; + ubyte g; + ubyte b; + ubyte a; +} +alias SDL_Colour = SDL_Color; + +struct SDL_Palette { + int ncolors; + SDL_Color* colors; + uint version_; // NOTE: original was named 'version' + int refcount; +} + +struct SDL_PixelFormat { + uint format; + SDL_Palette *palette; + ubyte BitsPerPixel; + ubyte BytesPerPixel; + ubyte[2] padding; + uint Rmask; + uint Gmask; + uint Bmask; + uint Amask; + ubyte Rloss; + ubyte Gloss; + ubyte Bloss; + ubyte Aloss; + ubyte Rshift; + ubyte Gshift; + ubyte Bshift; + ubyte Ashift; + int refcount; + SDL_PixelFormat* next; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + const(char)* SDL_GetPixelFormatName(uint); + SDL_bool SDL_PixelFormatEnumToMasks(uint,int*,uint*,uint*,uint*,uint*); + uint SDL_MasksToPixelFormatEnum(int,uint,uint,uint,uint); + SDL_PixelFormat* SDL_AllocFormat(uint); + void SDL_FreeFormat(SDL_PixelFormat*); + SDL_Palette* SDL_AllocPalette(int); + int SDL_SetPixelFormatPalette(SDL_PixelFormat*,SDL_Palette*); + int SDL_SetPaletteColors(SDL_Palette*,const(SDL_Color)*,int,int); + void SDL_FreePalette(SDL_Palette*); + uint SDL_MapRGB(const(SDL_PixelFormat)*,ubyte,ubyte,ubyte); + uint SDL_MapRGBA(const(SDL_PixelFormat)*,ubyte,ubyte,ubyte,ubyte); + void SDL_GetRGB(uint,const(SDL_PixelFormat)*,ubyte*,ubyte*,ubyte*); + void SDL_GetRGBA(uint,const(SDL_PixelFormat)*,ubyte*,ubyte*,ubyte*,ubyte*); + void SDL_CalculateGammaRamp(float,ushort*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetPixelFormatName = const(char)* function(uint); + alias pSDL_PixelFormatEnumToMasks = SDL_bool function(uint,int*,uint*,uint*,uint*,uint*); + alias pSDL_MasksToPixelFormatEnum = uint function(int,uint,uint,uint,uint); + alias pSDL_AllocFormat = SDL_PixelFormat* function(uint); + alias pSDL_FreeFormat = void function(SDL_PixelFormat*); + alias pSDL_AllocPalette = SDL_Palette* function(int); + alias pSDL_SetPixelFormatPalette = int function(SDL_PixelFormat*,SDL_Palette*); + alias pSDL_SetPaletteColors = int function(SDL_Palette*,const(SDL_Color)*,int,int); + alias pSDL_FreePalette = void function(SDL_Palette*); + alias pSDL_MapRGB = uint function(const(SDL_PixelFormat)*,ubyte,ubyte,ubyte); + alias pSDL_MapRGBA = uint function(const(SDL_PixelFormat)*,ubyte,ubyte,ubyte,ubyte); + alias pSDL_GetRGB = void function(uint,const(SDL_PixelFormat)*,ubyte*,ubyte*,ubyte*); + alias pSDL_GetRGBA = void function(uint,const(SDL_PixelFormat)*,ubyte*,ubyte*,ubyte*,ubyte*); + alias pSDL_CalculateGammaRamp = void function(float,ushort*); + } + + __gshared { + pSDL_GetPixelFormatName SDL_GetPixelFormatName; + pSDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks; + pSDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum; + pSDL_AllocFormat SDL_AllocFormat; + pSDL_FreeFormat SDL_FreeFormat; + pSDL_AllocPalette SDL_AllocPalette; + pSDL_SetPixelFormatPalette SDL_SetPixelFormatPalette; + pSDL_SetPaletteColors SDL_SetPaletteColors; + pSDL_FreePalette SDL_FreePalette; + pSDL_MapRGB SDL_MapRGB; + pSDL_MapRGBA SDL_MapRGBA; + pSDL_GetRGB SDL_GetRGB; + pSDL_GetRGBA SDL_GetRGBA; + pSDL_CalculateGammaRamp SDL_CalculateGammaRamp; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlplatform.d b/demos/external/imports/bindbc/sdl/bind/sdlplatform.d new file mode 100644 index 0000000..da23ff7 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlplatform.d @@ -0,0 +1,22 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlplatform; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + const(char)* SDL_GetPlatform(); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetPlatform = const(char)* function(); + } + + __gshared { + pSDL_GetPlatform SDL_GetPlatform; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlpower.d b/demos/external/imports/bindbc/sdl/bind/sdlpower.d new file mode 100644 index 0000000..b6eac3b --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlpower.d @@ -0,0 +1,33 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlpower; + +import bindbc.sdl.config; + +enum SDL_PowerState { + SDL_POWERSTATE_UNKNOWN, + SDL_POWERSTATE_ON_BATTERY, + SDL_POWERSTATE_NO_BATTERY, + SDL_POWERSTATE_CHARGING, + SDL_POWERSTATE_CHARGED +} +mixin(expandEnum!SDL_PowerState); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_PowerState SDL_GetPowerInfo(int*,int*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetPowerInfo = SDL_PowerState function(int*,int*); + } + + __gshared { + pSDL_GetPowerInfo SDL_GetPowerInfo; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlrect.d b/demos/external/imports/bindbc/sdl/bind/sdlrect.d new file mode 100644 index 0000000..5122fa6 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlrect.d @@ -0,0 +1,80 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlrect; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +struct SDL_Point { + int x; + int y; +} + +struct SDL_Rect { + int x, y; + int w, h; +} + +static if(sdlSupport >= SDLSupport.sdl2010) { + struct SDL_FPoint { + float x, y; + } + + struct SDL_FRect { + float x, y; + float w, h; + } +} + +@nogc nothrow pure { + // This macro was added to SDL_rect.h in 2.0.4, but hurts nothing to implement for + // all versions. + bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) { + pragma(inline, true); + return ((p.x >= r.x) && (p.x < (r.x + r.w)) && + (p.y >= r.y) && (p.y < (r.y + r.h))); + } + + bool SDL_RectEmpty(const(SDL_Rect)* X) { + pragma(inline, true); + return !X || (X.w <= 0) || (X.h <= 0); + } + + bool SDL_RectEquals(const(SDL_Rect)* A, const(SDL_Rect)* B) { + pragma(inline, true); + return A && B && + (A.x == B.x) && (A.y == B.y) && + (A.w == B.w) && (A.h == B.h); + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_bool SDL_HasIntersection(const(SDL_Rect)*,const(SDL_Rect)*); + SDL_bool SDL_IntersectRect(const(SDL_Rect)*,const(SDL_Rect)*,SDL_Rect*); + void SDL_UnionRect(const(SDL_Rect)*,const(SDL_Rect)*,SDL_Rect*); + SDL_bool SDL_EnclosePoints(const(SDL_Point)*,int,const(SDL_Rect)*,SDL_Rect*); + SDL_bool SDL_IntersectRectAndLine(const(SDL_Rect)*,int*,int*,int*,int*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_HasIntersection = SDL_bool function(const(SDL_Rect)*,const(SDL_Rect)*); + alias pSDL_IntersectRect = SDL_bool function(const(SDL_Rect)*,const(SDL_Rect)*,SDL_Rect*); + alias pSDL_UnionRect = void function(const(SDL_Rect)*,const(SDL_Rect)*,SDL_Rect*); + alias pSDL_EnclosePoints = SDL_bool function(const(SDL_Point)*,int,const(SDL_Rect)*,SDL_Rect*); + alias pSDL_IntersectRectAndLine = SDL_bool function(const(SDL_Rect)*,int*,int*,int*,int*); + } + + __gshared { + pSDL_HasIntersection SDL_HasIntersection; + pSDL_IntersectRect SDL_IntersectRect; + pSDL_UnionRect SDL_UnionRect; + pSDL_EnclosePoints SDL_EnclosePoints; + pSDL_IntersectRectAndLine SDL_IntersectRectAndLine; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlrender.d b/demos/external/imports/bindbc/sdl/bind/sdlrender.d new file mode 100644 index 0000000..b6b4d65 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlrender.d @@ -0,0 +1,316 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlrender; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlblendmode : SDL_BlendMode; +import bindbc.sdl.bind.sdlrect; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +enum SDL_RendererFlags : uint { + SDL_RENDERER_SOFTWARE = 0x00000001, + SDL_RENDERER_ACCELERATED = 0x00000002, + SDL_RENDERER_PRESENTVSYNC = 0x00000004, + SDL_RENDERER_TARGETTEXTURE = 0x00000008, +} + +mixin(expandEnum!SDL_RendererFlags); + +struct SDL_RendererInfo { + const(char)* name; + SDL_RendererFlags flags; + uint num_texture_formats; + uint[16] texture_formats; + int max_texture_width; + int max_texture_height; +} + +enum SDL_TextureAccess { + SDL_TEXTUREACCESS_STATIC, + SDL_TEXTUREACCESS_STREAMING, + SDL_TEXTUREACCESS_TARGET, +} +mixin(expandEnum!SDL_TextureAccess); + +enum SDL_TextureModulate { + SDL_TEXTUREMODULATE_NONE = 0x00000000, + SDL_TEXTUREMODULATE_COLOR = 0x00000001, + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 +} +mixin(expandEnum!SDL_TextureModulate); + +enum SDL_RendererFlip { + SDL_FLIP_NONE = 0x00000000, + SDL_FLIP_HORIZONTAL = 0x00000001, + SDL_FLIP_VERTICAL = 0x00000002, +} +mixin(expandEnum!SDL_RendererFlip); + +struct SDL_Renderer; +struct SDL_Texture; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GetNumRenderDrivers(); + int SDL_GetRenderDriverInfo(int,SDL_RendererInfo*); + int SDL_CreateWindowAndRenderer(int,int,uint,SDL_Window**,SDL_Renderer**); + SDL_Renderer* SDL_CreateRenderer(SDL_Window*,int,SDL_RendererFlags); + SDL_Renderer* SDL_CreateSoftwareRenderer(SDL_Surface*); + SDL_Renderer* SDL_GetRenderer(SDL_Window*); + int SDL_GetRendererInfo(SDL_Renderer*,SDL_RendererInfo*); + int SDL_GetRendererOutputSize(SDL_Renderer*,int*,int*); + SDL_Texture* SDL_CreateTexture(SDL_Renderer*,uint,SDL_TextureAccess,int,int); + SDL_Texture* SDL_CreateTextureFromSurface(SDL_Renderer*,SDL_Surface*); + int SDL_QueryTexture(SDL_Texture*,uint*,int*,int*,int*); + int SDL_SetTextureColorMod(SDL_Texture*,ubyte,ubyte,ubyte); + int SDL_GetTextureColorMod(SDL_Texture*,ubyte*,ubyte*,ubyte*); + int SDL_SetTextureAlphaMod(SDL_Texture*,ubyte); + int SDL_GetTextureAlphaMod(SDL_Texture*,ubyte*); + int SDL_SetTextureBlendMode(SDL_Texture*,SDL_BlendMode); + int SDL_GetTextureBlendMode(SDL_Texture*,SDL_BlendMode*); + int SDL_UpdateTexture(SDL_Texture*,const(SDL_Rect)*,const(void)*,int); + int SDL_LockTexture(SDL_Texture*,const(SDL_Rect)*,void**,int*); + void SDL_UnlockTexture(SDL_Texture*); + SDL_bool SDL_RenderTargetSupported(SDL_Renderer*); + int SDL_SetRenderTarget(SDL_Renderer*,SDL_Texture*); + SDL_Texture* SDL_GetRenderTarget(SDL_Renderer*); + int SDL_RenderSetClipRect(SDL_Renderer*,const(SDL_Rect)*); + void SDL_RenderGetClipRect(SDL_Renderer* renderer,SDL_Rect*); + int SDL_RenderSetLogicalSize(SDL_Renderer*,int,int); + void SDL_RenderGetLogicalSize(SDL_Renderer*,int*,int*); + int SDL_RenderSetViewport(SDL_Renderer*,const(SDL_Rect)*); + void SDL_RenderGetViewport(SDL_Renderer*,SDL_Rect*); + int SDL_RenderSetScale(SDL_Renderer*,float,float); + int SDL_RenderGetScale(SDL_Renderer*,float*,float*); + int SDL_SetRenderDrawColor(SDL_Renderer*,ubyte,ubyte,ubyte,ubyte); + int SDL_GetRenderDrawColor(SDL_Renderer*,ubyte*,ubyte*,ubyte*,ubyte*); + int SDL_SetRenderDrawBlendMode(SDL_Renderer*,SDL_BlendMode); + int SDL_GetRenderDrawBlendMode(SDL_Renderer*,SDL_BlendMode*); + int SDL_RenderClear(SDL_Renderer*); + int SDL_RenderDrawPoint(SDL_Renderer*,int,int); + int SDL_RenderDrawPoints(SDL_Renderer*,const(SDL_Point)*,int); + int SDL_RenderDrawLine(SDL_Renderer*,int,int,int,int); + int SDL_RenderDrawLines(SDL_Renderer*,const(SDL_Point)*,int); + int SDL_RenderDrawRect(SDL_Renderer*,const(SDL_Rect)*); + int SDL_RenderDrawRects(SDL_Renderer*,const(SDL_Rect)*,int); + int SDL_RenderFillRect(SDL_Renderer*,const(SDL_Rect)*); + int SDL_RenderFillRects(SDL_Renderer*,const(SDL_Rect)*,int); + int SDL_RenderCopy(SDL_Renderer*,SDL_Texture*,const(SDL_Rect)*,const(SDL_Rect*)); + int SDL_RenderCopyEx(SDL_Renderer*,SDL_Texture*,const(SDL_Rect)*,const(SDL_Rect)*,const(double),const(SDL_Point)*,const(SDL_RendererFlip)); + int SDL_RenderReadPixels(SDL_Renderer*,const(SDL_Rect)*,uint,void*,int); + void SDL_RenderPresent(SDL_Renderer*); + void SDL_DestroyTexture(SDL_Texture*); + void SDL_DestroyRenderer(SDL_Renderer*); + int SDL_GL_BindTexture(SDL_Texture*,float*,float*); + int SDL_GL_UnbindTexture(SDL_Texture*); + + static if(sdlSupport >= SDLSupport.sdl201) { + int SDL_UpdateYUVTexture(SDL_Texture*,const(SDL_Rect)*,const(ubyte)*,int,const(ubyte)*,int,const(ubyte)*,int); + } + static if(sdlSupport >= SDLSupport.sdl204) { + SDL_bool SDL_RenderIsClipEnabled(SDL_Renderer*); + } + static if(sdlSupport >= SDLSupport.sdl205) { + SDL_bool SDL_RenderGetIntegerScale(SDL_Renderer*); + int SDL_RenderSetIntegerScale(SDL_Renderer*,SDL_bool); + } + static if(sdlSupport >= SDLSupport.sdl208) { + void* SDL_RenderGetMetalLayer(SDL_Renderer*); + void* SDL_RenderGetMetalCommandEncoder(SDL_Renderer*); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + int SDL_RenderDrawPointF(SDL_Renderer*,float,float); + int SDL_RenderDrawPointsF(SDL_Renderer*,const(SDL_FPoint)*,int); + int SDL_RenderDrawLineF(SDL_Renderer*,float,float,float,float); + int SDL_RenderDrawLinesF(SDL_Renderer*,const(SDL_FPoint)*,int); + int SDL_RenderDrawRectF(SDL_Renderer*,const(SDL_FRect)*); + int SDL_RenderDrawRectsF(SDL_Renderer*,const(SDL_FRect)*,int); + int SDL_RenderFillRectF(SDL_Renderer*,const(SDL_FRect)*); + int SDL_RenderFillRectsF(SDL_Renderer*,const(SDL_FRect)*,int); + int SDL_RenderCopyF(SDL_Renderer*,SDL_Texture*,const(SDL_FRect)*,const(SDL_FRect)*); + int SDL_RenderCopyExF(SDL_Renderer*,SDL_Texture*,const(SDL_FRect)*,const(SDL_FRect)*,const(double),const(SDL_FPoint)*,const(SDL_RendererFlip)); + int SDL_RenderFlush(SDL_Renderer*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetNumRenderDrivers = int function(); + alias pSDL_GetRenderDriverInfo = int function(int,SDL_RendererInfo*); + alias pSDL_CreateWindowAndRenderer = int function(int,int,uint,SDL_Window**,SDL_Renderer**); + alias pSDL_CreateRenderer = SDL_Renderer* function(SDL_Window*,int,SDL_RendererFlags); + alias pSDL_CreateSoftwareRenderer = SDL_Renderer* function(SDL_Surface*); + alias pSDL_GetRenderer = SDL_Renderer* function(SDL_Window*); + alias pSDL_GetRendererInfo = int function(SDL_Renderer*,SDL_RendererInfo*); + alias pSDL_GetRendererOutputSize = int function(SDL_Renderer*,int*,int*); + alias pSDL_CreateTexture = SDL_Texture* function(SDL_Renderer*,uint,SDL_TextureAccess,int,int); + alias pSDL_CreateTextureFromSurface = SDL_Texture* function(SDL_Renderer*,SDL_Surface*); + alias pSDL_QueryTexture = int function(SDL_Texture*,uint*,int*,int*,int*); + alias pSDL_SetTextureColorMod = int function(SDL_Texture*,ubyte,ubyte,ubyte); + alias pSDL_GetTextureColorMod = int function(SDL_Texture*,ubyte*,ubyte*,ubyte*); + alias pSDL_SetTextureAlphaMod = int function(SDL_Texture*,ubyte); + alias pSDL_GetTextureAlphaMod = int function(SDL_Texture*,ubyte*); + alias pSDL_SetTextureBlendMode = int function(SDL_Texture*,SDL_BlendMode); + alias pSDL_GetTextureBlendMode = int function(SDL_Texture*,SDL_BlendMode*); + alias pSDL_UpdateTexture = int function(SDL_Texture*,const(SDL_Rect)*,const(void)*,int); + alias pSDL_LockTexture = int function(SDL_Texture*,const(SDL_Rect)*,void**,int*); + alias pSDL_UnlockTexture = void function(SDL_Texture*); + alias pSDL_RenderTargetSupported = SDL_bool function(SDL_Renderer*); + alias pSDL_SetRenderTarget = int function(SDL_Renderer*,SDL_Texture*); + alias pSDL_GetRenderTarget = SDL_Texture* function(SDL_Renderer*); + alias pSDL_RenderSetClipRect = int function(SDL_Renderer*,const(SDL_Rect)*); + alias pSDL_RenderGetClipRect = void function(SDL_Renderer* renderer,SDL_Rect*); + alias pSDL_RenderSetLogicalSize = int function(SDL_Renderer*,int,int); + alias pSDL_RenderGetLogicalSize = void function(SDL_Renderer*,int*,int*); + alias pSDL_RenderSetViewport = int function(SDL_Renderer*,const(SDL_Rect)*); + alias pSDL_RenderGetViewport = void function(SDL_Renderer*,SDL_Rect*); + alias pSDL_RenderSetScale = int function(SDL_Renderer*,float,float); + alias pSDL_RenderGetScale = int function(SDL_Renderer*,float*,float*); + alias pSDL_SetRenderDrawColor = int function(SDL_Renderer*,ubyte,ubyte,ubyte,ubyte); + alias pSDL_GetRenderDrawColor = int function(SDL_Renderer*,ubyte*,ubyte*,ubyte*,ubyte*); + alias pSDL_SetRenderDrawBlendMode = int function(SDL_Renderer*,SDL_BlendMode); + alias pSDL_GetRenderDrawBlendMode = int function(SDL_Renderer*,SDL_BlendMode*); + alias pSDL_RenderClear = int function(SDL_Renderer*); + alias pSDL_RenderDrawPoint = int function(SDL_Renderer*,int,int); + alias pSDL_RenderDrawPoints = int function(SDL_Renderer*,const(SDL_Point)*,int); + alias pSDL_RenderDrawLine = int function(SDL_Renderer*,int,int,int,int); + alias pSDL_RenderDrawLines = int function(SDL_Renderer*,const(SDL_Point)*,int); + alias pSDL_RenderDrawRect = int function(SDL_Renderer*,const(SDL_Rect)*); + alias pSDL_RenderDrawRects = int function(SDL_Renderer*,const(SDL_Rect)*,int); + alias pSDL_RenderFillRect = int function(SDL_Renderer*,const(SDL_Rect)*); + alias pSDL_RenderFillRects = int function(SDL_Renderer*,const(SDL_Rect)*,int); + alias pSDL_RenderCopy = int function(SDL_Renderer*,SDL_Texture*,const(SDL_Rect)*,const(SDL_Rect*)); + alias pSDL_RenderCopyEx = int function(SDL_Renderer*,SDL_Texture*,const(SDL_Rect)*,const(SDL_Rect)*,const(double),const(SDL_Point)*,const(SDL_RendererFlip)); + alias pSDL_RenderReadPixels = int function(SDL_Renderer*,const(SDL_Rect)*,uint,void*,int); + alias pSDL_RenderPresent = void function(SDL_Renderer*); + alias pSDL_DestroyTexture = void function(SDL_Texture*); + alias pSDL_DestroyRenderer = void function(SDL_Renderer*); + alias pSDL_GL_BindTexture = int function(SDL_Texture*,float*,float*); + alias pSDL_GL_UnbindTexture = int function(SDL_Texture*); + } + + __gshared { + pSDL_GetNumRenderDrivers SDL_GetNumRenderDrivers; + pSDL_GetRenderDriverInfo SDL_GetRenderDriverInfo; + pSDL_CreateWindowAndRenderer SDL_CreateWindowAndRenderer; + pSDL_CreateRenderer SDL_CreateRenderer; + pSDL_CreateSoftwareRenderer SDL_CreateSoftwareRenderer; + pSDL_GetRenderer SDL_GetRenderer; + pSDL_GetRendererInfo SDL_GetRendererInfo; + pSDL_GetRendererOutputSize SDL_GetRendererOutputSize; + pSDL_CreateTexture SDL_CreateTexture; + pSDL_CreateTextureFromSurface SDL_CreateTextureFromSurface; + pSDL_QueryTexture SDL_QueryTexture; + pSDL_SetTextureColorMod SDL_SetTextureColorMod; + pSDL_GetTextureColorMod SDL_GetTextureColorMod; + pSDL_SetTextureAlphaMod SDL_SetTextureAlphaMod; + pSDL_GetTextureAlphaMod SDL_GetTextureAlphaMod; + pSDL_SetTextureBlendMode SDL_SetTextureBlendMode; + pSDL_GetTextureBlendMode SDL_GetTextureBlendMode; + pSDL_UpdateTexture SDL_UpdateTexture; + pSDL_LockTexture SDL_LockTexture; + pSDL_UnlockTexture SDL_UnlockTexture; + pSDL_RenderTargetSupported SDL_RenderTargetSupported; + pSDL_SetRenderTarget SDL_SetRenderTarget; + pSDL_GetRenderTarget SDL_GetRenderTarget; + pSDL_RenderSetClipRect SDL_RenderSetClipRect; + pSDL_RenderGetClipRect SDL_RenderGetClipRect; + pSDL_RenderSetLogicalSize SDL_RenderSetLogicalSize; + pSDL_RenderGetLogicalSize SDL_RenderGetLogicalSize; + pSDL_RenderSetViewport SDL_RenderSetViewport; + pSDL_RenderGetViewport SDL_RenderGetViewport; + pSDL_RenderSetScale SDL_RenderSetScale; + pSDL_RenderGetScale SDL_RenderGetScale; + pSDL_SetRenderDrawColor SDL_SetRenderDrawColor; + pSDL_GetRenderDrawColor SDL_GetRenderDrawColor; + pSDL_SetRenderDrawBlendMode SDL_SetRenderDrawBlendMode; + pSDL_GetRenderDrawBlendMode SDL_GetRenderDrawBlendMode; + pSDL_RenderClear SDL_RenderClear; + pSDL_RenderDrawPoint SDL_RenderDrawPoint; + pSDL_RenderDrawPoints SDL_RenderDrawPoints; + pSDL_RenderDrawLine SDL_RenderDrawLine; + pSDL_RenderDrawLines SDL_RenderDrawLines; + pSDL_RenderDrawRect SDL_RenderDrawRect; + pSDL_RenderDrawRects SDL_RenderDrawRects; + pSDL_RenderFillRect SDL_RenderFillRect; + pSDL_RenderFillRects SDL_RenderFillRects; + pSDL_RenderCopy SDL_RenderCopy; + pSDL_RenderCopyEx SDL_RenderCopyEx; + pSDL_RenderReadPixels SDL_RenderReadPixels; + pSDL_RenderPresent SDL_RenderPresent; + pSDL_DestroyTexture SDL_DestroyTexture; + pSDL_DestroyRenderer SDL_DestroyRenderer; + pSDL_GL_BindTexture SDL_GL_BindTexture; + pSDL_GL_UnbindTexture SDL_GL_UnbindTexture; + } + static if(sdlSupport >= SDLSupport.sdl201) { + extern(C) @nogc nothrow { + alias pSDL_UpdateYUVTexture = int function(SDL_Texture*,const(SDL_Rect)*,const(ubyte)*,int,const(ubyte)*,int,const(ubyte)*,int); + } + __gshared { + pSDL_UpdateYUVTexture SDL_UpdateYUVTexture; + } + } + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_RenderIsClipEnabled = SDL_bool function(SDL_Renderer*); + } + __gshared { + pSDL_RenderIsClipEnabled SDL_RenderIsClipEnabled; + } + } + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_RenderGetIntegerScale = SDL_bool function(SDL_Renderer*); + alias pSDL_RenderSetIntegerScale = int function(SDL_Renderer*,SDL_bool); + } + __gshared { + pSDL_RenderGetIntegerScale SDL_RenderGetIntegerScale; + pSDL_RenderSetIntegerScale SDL_RenderSetIntegerScale; + } + } + static if(sdlSupport >= SDLSupport.sdl208) { + extern(C) @nogc nothrow { + alias pSDL_RenderGetMetalLayer = void* function(SDL_Renderer*); + alias pSDL_RenderGetMetalCommandEncoder = void* function(SDL_Renderer*); + } + __gshared { + pSDL_RenderGetMetalLayer SDL_RenderGetMetalLayer; + pSDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder; + } + } + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_RenderDrawPointF = int function(SDL_Renderer*,float,float); + alias pSDL_RenderDrawPointsF = int function(SDL_Renderer*,const(SDL_FPoint)*,int); + alias pSDL_RenderDrawLineF = int function(SDL_Renderer*,float,float,float,float); + alias pSDL_RenderDrawLinesF = int function(SDL_Renderer*,const(SDL_FPoint)*,int); + alias pSDL_RenderDrawRectF = int function(SDL_Renderer*,const(SDL_FRect)*); + alias pSDL_RenderDrawRectsF = int function(SDL_Renderer*,const(SDL_FRect)*,int); + alias pSDL_RenderFillRectF = int function(SDL_Renderer*,const(SDL_FRect)*); + alias pSDL_RenderFillRectsF = int function(SDL_Renderer*,const(SDL_FRect)*,int); + alias pSDL_RenderCopyF = int function(SDL_Renderer*,SDL_Texture*,const(SDL_FRect)*,const(SDL_FRect)*); + alias pSDL_RenderCopyExF = int function(SDL_Renderer*,SDL_Texture*,const(SDL_FRect)*,const(SDL_FRect)*,const(double),const(SDL_FPoint)*,const(SDL_RendererFlip)); + alias pSDL_RenderFlush = int function(SDL_Renderer*); + } + __gshared { + pSDL_RenderDrawPointF SDL_RenderDrawPointF; + pSDL_RenderDrawPointsF SDL_RenderDrawPointsF; + pSDL_RenderDrawLineF SDL_RenderDrawLineF; + pSDL_RenderDrawLinesF SDL_RenderDrawLinesF; + pSDL_RenderDrawRectF SDL_RenderDrawRectF; + pSDL_RenderDrawRectsF SDL_RenderDrawRectsF; + pSDL_RenderFillRectF SDL_RenderFillRectF; + pSDL_RenderFillRectsF SDL_RenderFillRectsF; + pSDL_RenderCopyF SDL_RenderCopyF; + pSDL_RenderCopyExF SDL_RenderCopyExF; + pSDL_RenderFlush SDL_RenderFlush; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlrwops.d b/demos/external/imports/bindbc/sdl/bind/sdlrwops.d new file mode 100644 index 0000000..47ddd20 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlrwops.d @@ -0,0 +1,208 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlrwops; + +//import core.stdc.stdio : FILE; + +struct FILE +{ +} + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +enum : uint { + SDL_RWOPS_UNKNOWN = 0, + SDL_RWOPS_WINFILE = 1, + SDL_RWOPS_STDFILE = 2, + SDL_RWOPS_JNIFILE = 3, + SDL_RWOPS_MEMORY = 4, + SDL_RWOPS_MEMORY_RO = 5, +} + +struct SDL_RWops { + extern(C) @nogc nothrow { + long function(SDL_RWops*) size; + long function(SDL_RWops*, long, int) seek; + size_t function(SDL_RWops*, void*, size_t, size_t) read; + size_t function(SDL_RWops*, const(void)*, size_t, size_t) write; + int function(SDL_RWops*) close; + } + + uint type; + + union Hidden { + // version(Android) + version(Windows) { + struct Windowsio { + int append; + void* h; + struct Buffer { + void* data; + size_t size; + size_t left; + } + Buffer buffer; + } + Windowsio windowsio; + } + + struct Stdio { + int autoclose; + FILE* fp; + } + Stdio stdio; + + struct Mem { + ubyte* base; + ubyte* here; + ubyte* stop; + } + Mem mem; + + struct Unknown { + void* data1; + void* data2; + } + Unknown unknown; + } + Hidden hidden; +} + +enum { + RW_SEEK_SET = 0, + RW_SEEK_CUR = 1, + RW_SEEK_END = 2, +} + +static if(sdlSupport < SDLSupport.sdl2010) { + @nogc nothrow { + long SDL_RWsize(SDL_RWops* ctx) { return ctx.size(ctx); } + long SDL_RWseek(SDL_RWops* ctx, long offset, int whence) { return ctx.seek(ctx, offset, whence); } + long SDL_RWtell(SDL_RWops* ctx) { return ctx.seek(ctx, 0, RW_SEEK_CUR); } + size_t SDL_RWread(SDL_RWops* ctx, void* ptr, size_t size, size_t n) { return ctx.read(ctx, ptr, size, n); } + size_t SDL_RWwrite(SDL_RWops* ctx, const(void)* ptr, size_t size, size_t n) { return ctx.write(ctx, ptr, size, n); } + int SDL_RWclose(SDL_RWops* ctx) { return ctx.close(ctx); } + } +} + +static if(sdlSupport >= SDLSupport.sdl206) { + @nogc nothrow + void* SDL_LoadFile(const(char)* filename, size_t datasize) { + pragma(inline, true); + return SDL_LoadFile_RW(SDL_RWFromFile(filename, "rb"), datasize, 1); + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_RWops* SDL_RWFromFile(const(char)*,const(char)*); + SDL_RWops* SDL_RWFromFP(FILE*,SDL_bool); + SDL_RWops* SDL_RWFromMem(void*,int); + SDL_RWops* SDL_RWFromConstMem(const(void)*,int); + SDL_RWops* SDL_AllocRW(); + void SDL_FreeRW(SDL_RWops*); + ubyte SDL_ReadU8(SDL_RWops*); + ushort SDL_ReadLE16(SDL_RWops*); + ushort SDL_ReadBE16(SDL_RWops*); + uint SDL_ReadLE32(SDL_RWops*); + uint SDL_ReadBE32(SDL_RWops*); + ulong SDL_ReadLE64(SDL_RWops*); + ulong SDL_ReadBE64(SDL_RWops*); + size_t SDL_WriteU8(SDL_RWops*,ubyte); + size_t SDL_WriteLE16(SDL_RWops*,ushort); + size_t SDL_WriteBE16(SDL_RWops*,ushort); + size_t SDL_WriteLE32(SDL_RWops*,uint); + size_t SDL_WriteBE32(SDL_RWops*,uint); + size_t SDL_WriteLE64(SDL_RWops*,ulong); + size_t SDL_WriteBE64(SDL_RWops*,ulong); + + static if(sdlSupport >= SDLSupport.sdl206) { + void* SDL_LoadFile_RW(SDL_RWops*,size_t,int); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + long SDL_RWsize(SDL_RWops*); + long SDL_RWseek(SDL_RWops*,long,int); + long SDL_RWtell(SDL_RWops*); + size_t SDL_RWread(SDL_RWops*,void*,size_t,size_t); + size_t SDL_RWwrite(SDL_RWops*,const(void)*,size_t,size_t); + int SDL_RWclose(SDL_RWops*); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_RWFromFile = SDL_RWops* function(const(char)*,const(char)*); + alias pSDL_RWFromFP = SDL_RWops* function(FILE*,SDL_bool); + alias pSDL_RWFromMem = SDL_RWops* function(void*,int); + alias pSDL_RWFromConstMem = SDL_RWops* function(const(void)*,int); + alias pSDL_AllocRW = SDL_RWops* function(); + alias pSDL_FreeRW = void function(SDL_RWops*); + alias pSDL_ReadU8 = ubyte function(SDL_RWops*); + alias pSDL_ReadLE16 = ushort function(SDL_RWops*); + alias pSDL_ReadBE16 = ushort function(SDL_RWops*); + alias pSDL_ReadLE32 = uint function(SDL_RWops*); + alias pSDL_ReadBE32 = uint function(SDL_RWops*); + alias pSDL_ReadLE64 = ulong function(SDL_RWops*); + alias pSDL_ReadBE64 = ulong function(SDL_RWops*); + alias pSDL_WriteU8 = size_t function(SDL_RWops*,ubyte); + alias pSDL_WriteLE16 = size_t function(SDL_RWops*,ushort); + alias pSDL_WriteBE16 = size_t function(SDL_RWops*,ushort); + alias pSDL_WriteLE32 = size_t function(SDL_RWops*,uint); + alias pSDL_WriteBE32 = size_t function(SDL_RWops*,uint); + alias pSDL_WriteLE64 = size_t function(SDL_RWops*,ulong); + alias pSDL_WriteBE64 = size_t function(SDL_RWops*,ulong); + } + __gshared { + pSDL_RWFromFile SDL_RWFromFile; + pSDL_RWFromFP SDL_RWFromFP; + pSDL_RWFromMem SDL_RWFromMem; + pSDL_RWFromConstMem SDL_RWFromConstMem; + pSDL_AllocRW SDL_AllocRW; + pSDL_FreeRW SDL_FreeRW; + pSDL_ReadU8 SDL_ReadU8; + pSDL_ReadLE16 SDL_ReadLE16; + pSDL_ReadBE16 SDL_ReadBE16; + pSDL_ReadLE32 SDL_ReadLE32; + pSDL_ReadBE32 SDL_ReadBE32; + pSDL_ReadLE64 SDL_ReadLE64; + pSDL_ReadBE64 SDL_ReadBE64; + pSDL_WriteU8 SDL_WriteU8; + pSDL_WriteLE16 SDL_WriteLE16; + pSDL_WriteBE16 SDL_WriteBE16; + pSDL_WriteLE32 SDL_WriteLE32; + pSDL_WriteBE32 SDL_WriteBE32; + pSDL_WriteLE64 SDL_WriteLE64; + pSDL_WriteBE64 SDL_WriteBE64; + } + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_LoadFile_RW = void* function(SDL_RWops*,size_t,int); + } + __gshared { + pSDL_LoadFile_RW SDL_LoadFile_RW; + } + } + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_RWsize = long function(SDL_RWops*); + alias pSDL_RWseek = long function(SDL_RWops*,long,int); + alias pSDL_RWtell = long function(SDL_RWops*); + alias pSDL_RWread = size_t function(SDL_RWops*,void*,size_t,size_t); + alias pSDL_RWwrite = size_t function(SDL_RWops*,const(void)*,size_t,size_t); + alias pSDL_RWclose = int function(SDL_RWops*); + } + __gshared { + pSDL_RWsize SDL_RWsize; + pSDL_RWseek SDL_RWseek; + pSDL_RWtell SDL_RWtell; + pSDL_RWread SDL_RWread; + pSDL_RWwrite SDL_RWwrite; + pSDL_RWclose SDL_RWclose; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlscancode.d b/demos/external/imports/bindbc/sdl/bind/sdlscancode.d new file mode 100644 index 0000000..fc188dd --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlscancode.d @@ -0,0 +1,542 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlscancode; + +import bindbc.sdl.config; + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_Scancode { + SDL_SCANCODE_UNKNOWN = 0, + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, + SDL_SCANCODE_NONUSHASH = 50, + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, + SDL_SCANCODE_APPLICATION = 101, + SDL_SCANCODE_POWER = 102, + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, + SDL_SCANCODE_LANG2 = 145, + SDL_SCANCODE_LANG3 = 146, + SDL_SCANCODE_LANG4 = 147, + SDL_SCANCODE_LANG5 = 148, + SDL_SCANCODE_LANG6 = 149, + SDL_SCANCODE_LANG7 = 150, + SDL_SCANCODE_LANG8 = 151, + SDL_SCANCODE_LANG9 = 152, + + SDL_SCANCODE_ALTERASE = 153, + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, + SDL_SCANCODE_LGUI = 227, + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, + SDL_SCANCODE_RGUI = 231, + + SDL_SCANCODE_MODE = 257, + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + SDL_SCANCODE_AUDIOREWIND = 285, + SDL_SCANCODE_AUDIOFASTFORWARD = 286, + + SDL_NUM_SCANCODES = 512 + } +} +else { + enum SDL_Scancode { + SDL_SCANCODE_UNKNOWN = 0, + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, + SDL_SCANCODE_NONUSHASH = 50, + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, + SDL_SCANCODE_APPLICATION = 101, + SDL_SCANCODE_POWER = 102, + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, + SDL_SCANCODE_LANG2 = 145, + SDL_SCANCODE_LANG3 = 146, + SDL_SCANCODE_LANG4 = 147, + SDL_SCANCODE_LANG5 = 148, + SDL_SCANCODE_LANG6 = 149, + SDL_SCANCODE_LANG7 = 150, + SDL_SCANCODE_LANG8 = 151, + SDL_SCANCODE_LANG9 = 152, + + SDL_SCANCODE_ALTERASE = 153, + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, + SDL_SCANCODE_LGUI = 227, + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, + SDL_SCANCODE_RGUI = 231, + + SDL_SCANCODE_MODE = 257, + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + SDL_NUM_SCANCODES = 512 + } +} +mixin(expandEnum!SDL_Scancode); \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlshape.d b/demos/external/imports/bindbc/sdl/bind/sdlshape.d new file mode 100644 index 0000000..aed3410 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlshape.d @@ -0,0 +1,63 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlshape; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlpixels : SDL_Color; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +enum { + SDL_NONSHAPEABLE_WINDOW = -1, + SDL_INVALID_SHAPE_ARGUMENT = -2, + SDL_WINDOW_LACKS_SHAPE = -3, +} + +enum WindowShapeMode { + ShapeModeDefault, + ShapeModeBinarizeAlpha, + ShapeModeReverseBinarizeAlpha, + ShapeModeColorKey +} +mixin(expandEnum!WindowShapeMode); + +enum SDL_SHAPEMODEALPHA(WindowShapeMode mode) = (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha); + +union SDL_WindowShapeParams { + ubyte binarizationCutoff; + SDL_Color colorKey; +} + +struct SDL_WindowShapeMode { + WindowShapeMode mode; + SDL_WindowShapeParams parameters; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_Window* SDL_CreateShapedWindow(const(char)*,uint,uint,uint,uint,uint); + SDL_bool SDL_IsShapedWindow(const(SDL_Window)*); + int SDL_SetWindowShape(SDL_Window*,SDL_Surface*,SDL_WindowShapeMode*); + int SDL_GetShapedWindowMode(SDL_Window*,SDL_WindowShapeMode*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_CreateShapedWindow = SDL_Window* function(const(char)*,uint,uint,uint,uint,uint); + alias pSDL_IsShapedWindow = SDL_bool function(const(SDL_Window)*); + alias pSDL_SetWindowShape = int function(SDL_Window*,SDL_Surface*,SDL_WindowShapeMode*); + alias pSDL_GetShapedWindowMode = int function(SDL_Window*,SDL_WindowShapeMode*); + } + + __gshared { + pSDL_CreateShapedWindow SDL_CreateShapedWindow; + pSDL_IsShapedWindow SDL_IsShapedWindow; + pSDL_SetWindowShape SDL_SetWindowShape; + pSDL_GetShapedWindowMode SDL_GetShapedWindowMode; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlstdinc.d b/demos/external/imports/bindbc/sdl/bind/sdlstdinc.d new file mode 100644 index 0000000..68d77d8 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlstdinc.d @@ -0,0 +1,42 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlstdinc; + +import bindbc.sdl.config; + +enum SDL_bool { + SDL_FALSE = 0, + SDL_TRUE = 1 +} + +mixin(expandEnum!SDL_bool); + +alias Sint8 = byte; +alias Uint8 = ubyte; +alias Sint16 = short; +alias Uint16 = ushort; +alias Sint32 = int; +alias Uint32 = uint; +alias Sint64 = long; +alias Uint64 = ulong; + +enum SDL_FOURCC(char A, char B, char C, char D) = ((A << 0) | (B << 8) | (C << 16) | (D << 24)); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_free(void* mem); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_free = void function(void* mem); + } + + __gshared { + pSDL_free SDL_free; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlsurface.d b/demos/external/imports/bindbc/sdl/bind/sdlsurface.d new file mode 100644 index 0000000..1b5cc5a --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlsurface.d @@ -0,0 +1,230 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlsurface; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlblendmode : SDL_BlendMode; +import bindbc.sdl.bind.sdlrect : SDL_Rect; +import bindbc.sdl.bind.sdlrwops; +import bindbc.sdl.bind.sdlpixels : SDL_Palette, SDL_PixelFormat; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +enum { + SDL_SWSURFACE = 0, + SDL_PREALLOC = 0x00000001, + SDL_RLEACCEL = 0x00000002, + SDL_DONTFREE = 0x00000004, +} + +@nogc nothrow pure +bool SDL_MUSTLOCK(const(SDL_Surface)* S) +{ + pragma(inline, true); + return (S.flags & SDL_RLEACCEL) != 0; +} + +struct SDL_BlitMap; +struct SDL_Surface { + int flags; + SDL_PixelFormat* format; + int w, h; + int pitch; + void* pixels; + void* userdata; + int locked; + void* lock_data; + SDL_Rect clip_rect; + SDL_BlitMap* map; + int refcount; +} + +extern(C) nothrow alias SDL_blit = int function(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect); + +@nogc nothrow { + SDL_Surface* SDL_LoadBMP(const(char)* file) { + pragma(inline, true); + return SDL_LoadBMP_RW(SDL_RWFromFile(file,"rb"),1); + } + + int SDL_SaveBMP(SDL_Surface* surface,const(char)* file) { + pragma(inline, true); + return SDL_SaveBMP_RW(surface,SDL_RWFromFile(file,"wb"),1); + } +} + +alias SDL_BlitSurface = SDL_UpperBlit; +alias SDL_BlitScaled = SDL_UpperBlitScaled; + +static if(sdlSupport >= SDLSupport.sdl208) { + enum SDL_YUV_CONVERSION_MODE { + SDL_YUV_CONVERSION_JPEG, + SDL_YUV_CONVERSION_BT601, + SDL_YUV_CONVERSION_BT709, + SDL_YUV_CONVERSION_AUTOMATIC, + } + mixin(expandEnum!SDL_YUV_CONVERSION_MODE); +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_Surface* SDL_CreateRGBSurface(uint,int,int,int,uint,uint,uint,uint); + SDL_Surface* SDL_CreateRGBSurfaceFrom(void*,int,int,int,int,uint,uint,uint,uint); + void SDL_FreeSurface(SDL_Surface*); + int SDL_SetSurfacePalette(SDL_Surface*,SDL_Palette*); + int SDL_LockSurface(SDL_Surface*); + int SDL_UnlockSurface(SDL_Surface*); + SDL_Surface* SDL_LoadBMP_RW(SDL_RWops*,int); + int SDL_SaveBMP_RW(SDL_Surface*,SDL_RWops*,int); + int SDL_SetSurfaceRLE(SDL_Surface*,int); + int SDL_SetColorKey(SDL_Surface*,int,uint); + int SDL_GetColorKey(SDL_Surface*,uint*); + int SDL_SetSurfaceColorMod(SDL_Surface*,ubyte,ubyte,ubyte); + int SDL_GetSurfaceColorMod(SDL_Surface*,ubyte*,ubyte*,ubyte*); + int SDL_SetSurfaceAlphaMod(SDL_Surface*,ubyte); + int SDL_GetSurfaceAlphaMod(SDL_Surface*,ubyte*); + int SDL_SetSurfaceBlendMode(SDL_Surface*,SDL_BlendMode); + int SDL_GetSurfaceBlendMode(SDL_Surface*,SDL_BlendMode*); + SDL_bool SDL_SetClipRect(SDL_Surface*,const(SDL_Rect)*); + void SDL_GetClipRect(SDL_Surface*,SDL_Rect*); + SDL_Surface* SDL_ConvertSurface(SDL_Surface*,const(SDL_PixelFormat)*,uint); + SDL_Surface* SDL_ConvertSurfaceFormat(SDL_Surface*,uint,uint); + int SDL_ConvertPixels(int,int,uint,const(void)*,int,uint,void*,int); + int SDL_FillRect(SDL_Surface*,const(SDL_Rect)*,uint); + int SDL_FillRects(SDL_Surface*,const(SDL_Rect)*,int,uint); + int SDL_UpperBlit(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,SDL_Rect*); + int SDL_LowerBlit(SDL_Surface*,SDL_Rect*,SDL_Surface*,SDL_Rect*); + int SDL_SoftStretch(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,const(SDL_Rect)*); + int SDL_UpperBlitScaled(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,SDL_Rect*); + int SDL_LowerBlitScaled(SDL_Surface*,SDL_Rect*,SDL_Surface*,SDL_Rect*); + + static if(sdlSupport >= SDLSupport.sdl205) { + SDL_Surface* SDL_CreateRGBSurfaceWithFormat(uint,int,int,int,uint); + SDL_Surface* SDL_CreateRGBSurfaceWithFormatFrom(void*,int,int,int,int,uint); + } + static if(sdlSupport >= SDLSupport.sdl205) { + SDL_Surface* SDL_DuplicateSurface(SDL_Surface*); + } + static if(sdlSupport >= SDLSupport.sdl208) { + void SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE); + SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode(); + SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionModeForResolution(int,int); + } + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_bool SDL_HasColorKey(SDL_Surface*); + } + } +} +else { + extern(C) @nogc nothrow {alias pSDL_CreateRGBSurface = SDL_Surface* function(uint,int,int,int,uint,uint,uint,uint); + alias pSDL_CreateRGBSurfaceFrom = SDL_Surface* function(void*,int,int,int,int,uint,uint,uint,uint); + alias pSDL_FreeSurface = void function(SDL_Surface*); + alias pSDL_SetSurfacePalette = int function(SDL_Surface*,SDL_Palette*); + alias pSDL_LockSurface = int function(SDL_Surface*); + alias pSDL_UnlockSurface = int function(SDL_Surface*); + alias pSDL_LoadBMP_RW = SDL_Surface* function(SDL_RWops*,int); + alias pSDL_SaveBMP_RW = int function(SDL_Surface*,SDL_RWops*,int); + alias pSDL_SetSurfaceRLE = int function(SDL_Surface*,int); + alias pSDL_SetColorKey = int function(SDL_Surface*,int,uint); + alias pSDL_GetColorKey = int function(SDL_Surface*,uint*); + alias pSDL_SetSurfaceColorMod = int function(SDL_Surface*,ubyte,ubyte,ubyte); + alias pSDL_GetSurfaceColorMod = int function(SDL_Surface*,ubyte*,ubyte*,ubyte*); + alias pSDL_SetSurfaceAlphaMod = int function(SDL_Surface*,ubyte); + alias pSDL_GetSurfaceAlphaMod = int function(SDL_Surface*,ubyte*); + alias pSDL_SetSurfaceBlendMode = int function(SDL_Surface*,SDL_BlendMode); + alias pSDL_GetSurfaceBlendMode = int function(SDL_Surface*,SDL_BlendMode*); + alias pSDL_SetClipRect = SDL_bool function(SDL_Surface*,const(SDL_Rect)*); + alias pSDL_GetClipRect = void function(SDL_Surface*,SDL_Rect*); + alias pSDL_ConvertSurface = SDL_Surface* function(SDL_Surface*,const(SDL_PixelFormat)*,uint); + alias pSDL_ConvertSurfaceFormat = SDL_Surface* function(SDL_Surface*,uint,uint); + alias pSDL_ConvertPixels = int function(int,int,uint,const(void)*,int,uint,void*,int); + alias pSDL_FillRect = int function(SDL_Surface*,const(SDL_Rect)*,uint); + alias pSDL_FillRects = int function(SDL_Surface*,const(SDL_Rect)*,int,uint); + alias pSDL_UpperBlit = int function(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,SDL_Rect*); + alias pSDL_LowerBlit = int function(SDL_Surface*,SDL_Rect*,SDL_Surface*,SDL_Rect*); + alias pSDL_SoftStretch = int function(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,const(SDL_Rect)*); + alias pSDL_UpperBlitScaled = int function(SDL_Surface*,const(SDL_Rect)*,SDL_Surface*,SDL_Rect*); + alias pSDL_LowerBlitScaled = int function(SDL_Surface*,SDL_Rect*,SDL_Surface*,SDL_Rect*); + } + + __gshared { + pSDL_CreateRGBSurface SDL_CreateRGBSurface; + pSDL_CreateRGBSurfaceFrom SDL_CreateRGBSurfaceFrom; + pSDL_FreeSurface SDL_FreeSurface; + pSDL_SetSurfacePalette SDL_SetSurfacePalette; + pSDL_LockSurface SDL_LockSurface; + pSDL_UnlockSurface SDL_UnlockSurface; + pSDL_LoadBMP_RW SDL_LoadBMP_RW; + pSDL_SaveBMP_RW SDL_SaveBMP_RW; + pSDL_SetSurfaceRLE SDL_SetSurfaceRLE; + pSDL_SetColorKey SDL_SetColorKey; + pSDL_GetColorKey SDL_GetColorKey; + pSDL_SetSurfaceColorMod SDL_SetSurfaceColorMod; + pSDL_GetSurfaceColorMod SDL_GetSurfaceColorMod; + pSDL_SetSurfaceAlphaMod SDL_SetSurfaceAlphaMod; + pSDL_GetSurfaceAlphaMod SDL_GetSurfaceAlphaMod; + pSDL_SetSurfaceBlendMode SDL_SetSurfaceBlendMode; + pSDL_GetSurfaceBlendMode SDL_GetSurfaceBlendMode; + pSDL_SetClipRect SDL_SetClipRect; + pSDL_GetClipRect SDL_GetClipRect; + pSDL_ConvertSurface SDL_ConvertSurface; + pSDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat; + pSDL_ConvertPixels SDL_ConvertPixels; + pSDL_FillRect SDL_FillRect; + pSDL_FillRects SDL_FillRects; + pSDL_UpperBlit SDL_UpperBlit; + pSDL_LowerBlit SDL_LowerBlit; + pSDL_SoftStretch SDL_SoftStretch; + pSDL_UpperBlitScaled SDL_UpperBlitScaled; + pSDL_LowerBlitScaled SDL_LowerBlitScaled; + } + + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_CreateRGBSurfaceWithFormat = SDL_Surface* function(uint,int,int,int,uint); + alias pSDL_CreateRGBSurfaceWithFormatFrom = SDL_Surface* function(void*,int,int,int,int,uint); + } + + __gshared { + pSDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat; + pSDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom; + } + } + + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_DuplicateSurface = SDL_Surface* function(SDL_Surface*); + } + + __gshared { + pSDL_DuplicateSurface SDL_DuplicateSurface; + } + } + + static if(sdlSupport >= SDLSupport.sdl208) { + extern(C) @nogc nothrow { + alias pSDL_SetYUVConversionMode = void function(SDL_YUV_CONVERSION_MODE); + alias pSDL_GetYUVConversionMode = SDL_YUV_CONVERSION_MODE function(); + alias pSDL_GetYUVConversionModeForResolution = SDL_YUV_CONVERSION_MODE function(int,int); + } + + __gshared { + pSDL_SetYUVConversionMode SDL_SetYUVConversionMode; + pSDL_GetYUVConversionMode SDL_GetYUVConversionMode; + pSDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution; + } + } + + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_HasColorKey = SDL_bool function(SDL_Surface*); + } + + __gshared { + pSDL_HasColorKey SDL_HasColorKey; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlsystem.d b/demos/external/imports/bindbc/sdl/bind/sdlsystem.d new file mode 100644 index 0000000..39eb0b3 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlsystem.d @@ -0,0 +1,152 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlsystem; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlrender : SDL_Renderer; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +version(Android) { + enum int SDL_ANDROID_EXTERNAL_STORAGE_READ = 0x01; + enum int SDL_ANDROID_EXTERNAL_STORAGE_WRITE = 0x02; +} + +static if(sdlSupport >= SDLSupport.sdl201) { + version(Windows) struct IDirect3DDevice9; +} + +static if(sdlSupport >= SDLSupport.sdl204) { + version(Windows) { + extern(C) nothrow alias SDL_WindowsMessageHook = void function(void*,void*,uint,ulong,long); + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + version(Android) { + void* SDL_AndroidGetJNIEnv(); + void* SDL_AndroidGetActivity(); + const(char)* SDL_AndroidGetInternalStoragePath(); + int SDL_AndroidGetInternalStorageState(); + const(char)* SDL_AndroidGetExternalStoragePath(); + + static if(sdlSupport >= SDLSupport.sdl208) { + SDL_bool SDL_IsAndroidTV(); + } + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_bool SDL_IsChromebook(); + SDL_bool SDL_IsDeXMode(); + void SDL_AndroidBackButton(); + } + } + else version(Windows) { + static if(sdlSupport >= SDLSupport.sdl201) { + int SDL_Direct3D9GetAdapterIndex(int); + IDirect3DDevice9* SDL_RenderGetD3D9Device(SDL_Renderer*); + } + static if(sdlSupport >= SDLSupport.sdl202) { + SDL_bool SDL_DXGIGetOutputInfo(int,int*,int*); + } + static if(sdlSupport >= SDLSupport.sdl204) { + void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook,void*); + } + } + else version(linux) { + static if(sdlSupport >= SDLSupport.sdl209) { + int SDL_LinuxSetThreadPriority(long,int); + } + } + } +} +else { + version(Android) { + extern(C) @nogc nothrow { + alias pSDL_AndroidGetJNIEnv = void* function(); + alias pSDL_AndroidGetActivity = void* function(); + alias pSDL_AndroidGetInternalStoragePath = const(char)* function(); + alias pSDL_AndroidGetInternalStorageState = int function(); + alias pSDL_AndroidGetExternalStoragePath = const(char)* function(); + } + + __gshared { + pSDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv; + pSDL_AndroidGetActivity SDL_AndroidGetActivity; + + pSDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath; + pSDL_AndroidGetInternalStorageState SDL_AndroidGetInternalStorageState; + pSDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath; + } + + static if(sdlSupport >= SDLSupport.sdl208) { + extern(C) @nogc nothrow { + alias pSDL_IsAndroidTV = SDL_bool function(); + } + + __gshared { + pSDL_IsAndroidTV SDL_IsAndroidTV; + } + } + + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_IsChromebook = SDL_bool function(); + alias pSDL_IsDeXMode = SDL_bool function(); + alias pSDL_AndroidBackButton = void function(); + } + + __gshared { + pSDL_IsChromebook SDL_IsChromebook; + pSDL_IsDeXMode SDL_IsDeXMode; + pSDL_AndroidBackButton SDL_AndroidBackButton; + } + } + } + else version(Windows) { + static if(sdlSupport >= SDLSupport.sdl201) { + extern(C) @nogc nothrow { + alias pSDL_Direct3D9GetAdapterIndex = int function(int); + alias pSDL_RenderGetD3D9Device = IDirect3DDevice9* function(SDL_Renderer*); + } + + __gshared { + pSDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex ; + pSDL_RenderGetD3D9Device SDL_RenderGetD3D9Device; + } + } + + static if(sdlSupport >= SDLSupport.sdl202) { + extern(C) @nogc nothrow { + alias pSDL_DXGIGetOutputInfo = SDL_bool function(int,int*,int*); + } + + __gshared { + pSDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo; + } + } + + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_SetWindowsMessageHook = void function(SDL_WindowsMessageHook,void*); + } + + __gshared { + pSDL_SetWindowsMessageHook SDL_SetWindowsMessageHook; + } + } + } + else version(linux) { + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_LinuxSetThreadPriority = int function(long,int); + } + + __gshared { + pSDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority; + } + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlsyswm.d b/demos/external/imports/bindbc/sdl/bind/sdlsyswm.d new file mode 100644 index 0000000..02951c8 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlsyswm.d @@ -0,0 +1,240 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlsyswm; + +//import core.stdc.config : c_long; +alias int c_long; +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlversion : SDL_version; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID, + SDL_SYSWM_VIVANTE, + SDL_SYSWM_OS2, + } +} +else static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID, + SDL_SYSWM_VIVANTE, + } +} +else static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID, + } +} +else static if(sdlSupport >= SDLSupport.sdl203) { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + } +} +else static if(sdlSupport >= SDLSupport.sdl202) { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + } +} +else { + enum SDL_SYSWM_TYPE { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + } +} +mixin(expandEnum!SDL_SYSWM_TYPE); + +version(Windows) { + // I don't want to import core.sys.windows.windows just for these + version(Win64) { + alias wparam = ulong; + alias lparam = long; + }else { + alias wparam = uint; + alias lparam = int; + } +} + +struct SDL_SysWMmsg { + SDL_version version_; + SDL_SYSWM_TYPE subsystem; + union msg_ { + version(Windows) { + struct win_ { + void* hwnd; + uint msg; + wparam wParam; + lparam lParam; + } + win_ win; + } + else version(OSX) { + struct cocoa_ { + int dummy; + } + cocoa_ cocoa; + } + else version(linux) { + struct dfb_ { + void* event; + } + dfb_ dfb; + } + + version(Posix) { + struct x11_ { + c_long[24] pad; // sufficient size for any X11 event + } + x11_ x11; + } + + static if(sdlSupport >= SDLSupport.sdl205) { + struct vivante_ { + int dummy; + } + vivante_ vivante; + } + + int dummy; + } + msg_ msg; +} + +struct SDL_SysWMinfo { + SDL_version version_; + SDL_SYSWM_TYPE subsystem; + + union info_ { + version(Windows) { + struct win_ { + void* window; + static if(sdlSupport >= SDLSupport.sdl204) void* hdc; + static if(sdlSupport >= SDLSupport.sdl206) void* hinstance; + } + win_ win; + } + else version(OSX) { + struct cocoa_ { + void* window; + } + cocoa_ cocoa; + + struct uikit_ { + void *window; + } + uikit_ uikit; + + } + else version(linux) { + struct dfb_ { + void *dfb; + void *window; + void *surface; + } + dfb_ dfb; + + static if(sdlSupport >= SDLSupport.sdl202) { + struct wl_ { + void *display; + void *surface; + void *shell_surface; + } + wl_ wl; + + struct mir_ { + void *connection; + void *surface; + } + mir_ mir; + } + } + + version(Posix) { + struct x11_ { + void* display; + uint window; + } + x11_ x11; + } + + static if(sdlSupport >= SDLSupport.sdl204) { + version(Android) { + struct android_ { + void* window; + void* surface; + } + android_ android; + } + } + + static if(sdlSupport >= SDLSupport.sdl206) ubyte[64] dummy; + else int dummy; + } + info_ info; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_bool SDL_GetWindowWMInfo(SDL_Window*,SDL_SysWMinfo*); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetWindowWMInfo = SDL_bool function(SDL_Window*,SDL_SysWMinfo*); + } + + __gshared { + pSDL_GetWindowWMInfo SDL_GetWindowWMInfo; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdltimer.d b/demos/external/imports/bindbc/sdl/bind/sdltimer.d new file mode 100644 index 0000000..1661a41 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdltimer.d @@ -0,0 +1,51 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdltimer; + +import bindbc.sdl.bind.sdlstdinc : SDL_bool; + +extern(C) nothrow alias SDL_TimerCallback = uint function(uint interval, void* param); +alias SDL_TimerID = int; + +// This was added to SDL 2.0.1 as a macro, but it's +// useful & has no dependency on the library version, +// so it's here for 2.0.0 as well. +@nogc nothrow pure +bool SDL_TICKS_PASSED(uint A, uint B) { + pragma(inline, true); + return cast(int)(B - A) <= 0; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + uint SDL_GetTicks(); + ulong SDL_GetPerformanceCounter(); + ulong SDL_GetPerformanceFrequency(); + void SDL_Delay(uint); + SDL_TimerID SDL_AddTimer(uint,SDL_TimerCallback,void*); + SDL_bool SDL_RemoveTimer(SDL_TimerID); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetTicks = uint function(); + alias pSDL_GetPerformanceCounter = ulong function(); + alias pSDL_GetPerformanceFrequency = ulong function(); + alias pSDL_Delay = void function(uint); + alias pSDL_AddTimer = SDL_TimerID function(uint,SDL_TimerCallback,void*); + alias pSDL_RemoveTimer = SDL_bool function(SDL_TimerID); + } + + __gshared { + pSDL_GetTicks SDL_GetTicks; + pSDL_GetPerformanceCounter SDL_GetPerformanceCounter; + pSDL_GetPerformanceFrequency SDL_GetPerformanceFrequency; + pSDL_Delay SDL_Delay; + pSDL_AddTimer SDL_AddTimer; + pSDL_RemoveTimer SDL_RemoveTimer; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdltouch.d b/demos/external/imports/bindbc/sdl/bind/sdltouch.d new file mode 100644 index 0000000..182e08f --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdltouch.d @@ -0,0 +1,67 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdltouch; + +import bindbc.sdl.config; + +alias SDL_TouchID = long; +alias SDL_FingerID = long; + +struct SDL_Finger { + SDL_FingerID id; + float x; + float y; + float pressure; +} + +enum DL_TOUCH_MOUSEID = cast(uint)-1; + +static if(sdlSupport >= SDLSupport.sdl2010) { + enum SDL_TouchDeviceType { + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE, + } + mixin(expandEnum!SDL_TouchDeviceType); + + enum SDL_MOUSE_TOUCHID = -1L; +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GetNumTouchDevices(); + SDL_TouchID SDL_GetTouchDevice(int); + int SDL_GetNumTouchFingers(SDL_TouchID); + SDL_Finger* SDL_GetTouchFinger(SDL_TouchID,int); + } + static if(sdlSupport >= SDLSupport.sdl2010) { + SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetNumTouchDevices = int function(); + alias pSDL_GetTouchDevice = SDL_TouchID function(int); + alias pSDL_GetNumTouchFingers = int function(SDL_TouchID); + alias pSDL_GetTouchFinger = SDL_Finger* function(SDL_TouchID,int); + } + __gshared { + pSDL_GetNumTouchDevices SDL_GetNumTouchDevices; + pSDL_GetTouchDevice SDL_GetTouchDevice; + pSDL_GetNumTouchFingers SDL_GetNumTouchFingers; + pSDL_GetTouchFinger SDL_GetTouchFinger; + } + static if(sdlSupport >= SDLSupport.sdl2010) { + extern(C) @nogc nothrow { + alias pSDL_GetTouchDeviceType = SDL_TouchDeviceType function(SDL_TouchID); + } + __gshared { + pSDL_GetTouchDeviceType SDL_GetTouchDeviceType; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlversion.d b/demos/external/imports/bindbc/sdl/bind/sdlversion.d new file mode 100644 index 0000000..dd05628 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlversion.d @@ -0,0 +1,83 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlversion; + +struct SDL_version { + ubyte major; + ubyte minor; + ubyte patch; +} + +enum SDL_MAJOR_VERSION = 2; +enum SDL_MINOR_VERSION = 0; + +version(SDL_201) { + enum ubyte SDL_PATCHLEVEL = 1; +} +else version(SDL_202) { + enum ubyte SDL_PATCHLEVEL = 2; +} +else version(SDL_203) { + enum ubyte SDL_PATCHLEVEL = 3; +} +else version(SDL_204) { + enum ubyte SDL_PATCHLEVEL = 4; +} +else version(SDL_205) { + enum ubyte SDL_PATCHLEVEL = 5; +} +else version(SDL_206) { + enum ubyte SDL_PATCHLEVEL = 6; +} +else version(SDL_207) { + enum ubyte SDL_PATCHLEVEL = 7; +} +else version(SDL_208) { + enum ubyte SDL_PATCHLEVEL = 8; +} +else version(SDL_209) { + enum ubyte SDL_PATCHLEVEL = 9; +} +else version(SDL_2010) { + enum ubyte SDL_PATCHLEVEL = 10; +} +else { + enum ubyte SDL_PATCHLEVEL = 0; +} + +@nogc nothrow pure +void SDL_VERSION(SDL_version* x) { + pragma(inline, true); + x.major = SDL_MAJOR_VERSION; + x.minor = SDL_MINOR_VERSION; + x.patch = SDL_PATCHLEVEL; +} + +enum SDL_VERSIONNUM(ubyte X, ubyte Y, ubyte Z) = X*1000 + Y*100 + Z; +enum SDL_COMPILEDVERSION = SDL_VERSIONNUM!(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); +enum SDL_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_COMPILEDVERSION >= SDL_VERSIONNUM!(X, Y, Z); + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + void SDL_GetVersion(SDL_version*); + const(char)* SDL_GetRevision(); + int SDL_GetRevisionNumber(); + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetVersion = void function(SDL_version*); + alias pSDL_GetRevision = const(char)* function(); + alias pSDL_GetRevisionNumber = int function(); + } + + __gshared { + pSDL_GetVersion SDL_GetVersion; + pSDL_GetRevision SDL_GetRevision; + pSDL_GetRevisionNumber SDL_GetRevisionNumber; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlvideo.d b/demos/external/imports/bindbc/sdl/bind/sdlvideo.d new file mode 100644 index 0000000..3384d8e --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlvideo.d @@ -0,0 +1,677 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlvideo; + +import bindbc.sdl.config; + +import bindbc.sdl.bind.sdlrect : SDL_Rect; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; + +struct SDL_DisplayMode { + uint format; + int w; + int h; + int refresh_rate; + void* driverdata; +} + +struct SDL_Window; + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_WindowFlags { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000, + SDL_WINDOW_FOREIGN = 0x00000800, + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, + SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, + SDL_WINDOW_SKIP_TASKBAR = 0x00010000, + SDL_WINDOW_UTILITY = 0x00020000, + SDL_WINDOW_TOOLTIP = 0x00040000, + SDL_WINDOW_POPUP_MENU = 0x00080000, + SDL_WINDOW_VULKAN = 0x10000000, + } +} +else static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_WindowFlags { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000, + SDL_WINDOW_FOREIGN = 0x00000800, + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, + SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, + SDL_WINDOW_SKIP_TASKBAR = 0x00010000, + SDL_WINDOW_UTILITY = 0x00020000, + SDL_WINDOW_TOOLTIP = 0x00040000, + SDL_WINDOW_POPUP_MENU = 0x00080000, + } +} +else static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_WindowFlags { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000, + SDL_WINDOW_FOREIGN = 0x00000800, + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, + } +} +else static if(sdlSupport >= SDLSupport.sdl201) { + enum SDL_WindowFlags { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000, + SDL_WINDOW_FOREIGN = 0x00000800, + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, + } +} +else { + enum SDL_WindowFlags { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN | 0x00001000, + SDL_WINDOW_FOREIGN = 0x00000800, + } +} +mixin(expandEnum!SDL_WindowFlags); + +enum uint SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; +enum uint SDL_WINDOWPOS_UNDEFINED_DISPLAY(uint x) = SDL_WINDOWPOS_UNDEFINED_MASK | x; +enum uint SDL_WINDOWPOS_UNDEFINED = SDL_WINDOWPOS_UNDEFINED_DISPLAY!(0); +enum uint SDL_WINDOWPOS_ISUNDEFINED(uint x) = (x & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK; + +enum uint SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000; +enum uint SDL_WINDOWPOS_CENTERED_DISPLAY(uint x) = SDL_WINDOWPOS_CENTERED_MASK | x; +enum uint SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_DISPLAY!(0); +enum uint SDL_WINDOWPOS_ISCENTERED(uint x) = (x & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK; + +static if(sdlSupport >= SDLSupport.sdl205) { + enum SDL_WindowEventID : ubyte { + SDL_WINDOWEVENT_NONE, + SDL_WINDOWEVENT_SHOWN, + SDL_WINDOWEVENT_HIDDEN, + SDL_WINDOWEVENT_EXPOSED, + SDL_WINDOWEVENT_MOVED, + SDL_WINDOWEVENT_RESIZED, + SDL_WINDOWEVENT_SIZE_CHANGED, + SDL_WINDOWEVENT_MINIMIZED, + SDL_WINDOWEVENT_MAXIMIZED, + SDL_WINDOWEVENT_RESTORED, + SDL_WINDOWEVENT_ENTER, + SDL_WINDOWEVENT_LEAVE, + SDL_WINDOWEVENT_FOCUS_GAINED, + SDL_WINDOWEVENT_FOCUS_LOST, + SDL_WINDOWEVENT_CLOSE, + SDL_WINDOWEVENT_TAKE_FOCUS, + SDL_WINDOWEVENT_HIT_TEST, + } + +} +else { + enum SDL_WindowEventID : ubyte { + SDL_WINDOWEVENT_NONE, + SDL_WINDOWEVENT_SHOWN, + SDL_WINDOWEVENT_HIDDEN, + SDL_WINDOWEVENT_EXPOSED, + SDL_WINDOWEVENT_MOVED, + SDL_WINDOWEVENT_RESIZED, + SDL_WINDOWEVENT_SIZE_CHANGED, + SDL_WINDOWEVENT_MINIMIZED, + SDL_WINDOWEVENT_MAXIMIZED, + SDL_WINDOWEVENT_RESTORED, + SDL_WINDOWEVENT_ENTER, + SDL_WINDOWEVENT_LEAVE, + SDL_WINDOWEVENT_FOCUS_GAINED, + SDL_WINDOWEVENT_FOCUS_LOST, + SDL_WINDOWEVENT_CLOSE, + } +} +mixin(expandEnum!SDL_WindowEventID); + +static if(sdlSupport >= SDLSupport.sdl209) { + enum SDL_DisplayEventID { + SDL_DISPLAYEVENT_NONE, + SDL_DISPLAYEVENT_ORIENTATION, + } + mixin(expandEnum!SDL_DisplayEventID); + + enum SDL_DisplayOrientation { + SDL_ORIENTATION_UNKNOWN, + SDL_ORIENTATION_LANDSCAPE, + SDL_ORIENTATION_LANDSCAPE_FLIPPED, + SDL_ORIENTATION_PORTRAIT, + SDL_ORIENTATION_PORTRAIT_FLIPPED, + } + mixin(expandEnum!SDL_DisplayOrientation); +} + +alias SDL_GLContext = void*; + +static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_GLattr { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_RELEASE_BEHAVIOR, + SDL_GL_CONTEXT_RESET_NOTIFICATION, + SDL_GL_CONTEXT_NO_ERROR, + } +} +else static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_GLattr { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_RELEASE_BEHAVIOR, + } +} +else static if(sdlSupport >= SDLSupport.sdl201) { + enum SDL_GLattr { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + } +} +else { + enum SDL_GLattr { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + } +} +mixin(expandEnum!SDL_GLattr); + +enum SDL_GLprofile { + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004, +} +mixin(expandEnum!SDL_GLprofile); + +enum SDL_GLcontextFlag { + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008, +} +mixin(expandEnum!SDL_GLcontextFlag); + +static if(sdlSupport >= SDLSupport.sdl204) { + enum SDL_GLcontextReleaseFlag { + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001, + } + mixin(expandEnum!SDL_GLcontextReleaseFlag); + + enum SDL_HitTestResult { + SDL_HITTEST_NORMAL, + SDL_HITTEST_DRAGGABLE, + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT, + } + mixin(expandEnum!SDL_HitTestResult); + + import bindbc.sdl.bind.sdlrect : SDL_Point; + extern(C) nothrow alias SDL_HitTest = SDL_HitTestResult function(SDL_Window*,const(SDL_Point)*,void*); +} + + static if(sdlSupport >= SDLSupport.sdl206) { + enum SDL_GLContextResetNotification { + SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000, + SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001, + } + mixin(expandEnum!SDL_GLContextResetNotification); +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int SDL_GetNumVideoDrivers(); + const(char)* SDL_GetVideoDriver(int); + int SDL_VideoInit(const(char)*); + void SDL_VideoQuit(); + const(char)* SDL_GetCurrentVideoDriver(); + int SDL_GetNumVideoDisplays(); + const(char)* SDL_GetDisplayName(int); + int SDL_GetDisplayBounds(int,SDL_Rect*); + int SDL_GetNumDisplayModes(int); + int SDL_GetDisplayMode(int,int,SDL_DisplayMode*); + int SDL_GetDesktopDisplayMode(int,SDL_DisplayMode*); + int SDL_GetCurrentDisplayMode(int,SDL_DisplayMode*); + SDL_DisplayMode* SDL_GetClosestDisplayMode(int,const(SDL_DisplayMode)*,SDL_DisplayMode*); + int SDL_GetWindowDisplayIndex(SDL_Window*); + int SDL_SetWindowDisplayMode(SDL_Window*,const(SDL_DisplayMode)*); + int SDL_GetWindowDisplayMode(SDL_Window*,SDL_DisplayMode*); + uint SDL_GetWindowPixelFormat(SDL_Window*); + SDL_Window* SDL_CreateWindow(const(char)*,int,int,int,int,SDL_WindowFlags); + SDL_Window* SDL_CreateWindowFrom(const(void)*); + uint SDL_GetWindowID(SDL_Window*); + SDL_Window* SDL_GetWindowFromID(uint); + SDL_WindowFlags SDL_GetWindowFlags(SDL_Window*); + void SDL_SetWindowTitle(SDL_Window*,const(char)*); + const(char)* SDL_GetWindowTitle(SDL_Window*); + void SDL_SetWindowIcon(SDL_Window*,SDL_Surface*); + void* SDL_SetWindowData(SDL_Window*,const(char)*,void*); + void* SDL_GetWindowData(SDL_Window*,const(char)*); + void SDL_SetWindowPosition(SDL_Window*,int,int); + void SDL_GetWindowPosition(SDL_Window*,int*,int*); + void SDL_SetWindowSize(SDL_Window*,int,int); + void SDL_GetWindowSize(SDL_Window*,int*,int*); + void SDL_SetWindowMinimumSize(SDL_Window*,int,int); + void SDL_GetWindowMinimumSize(SDL_Window*,int*,int*); + void SDL_SetWindowMaximumSize(SDL_Window*,int,int); + void SDL_GetWindowMaximumSize(SDL_Window*,int*,int*); + void SDL_SetWindowBordered(SDL_Window*,SDL_bool); + void SDL_ShowWindow(SDL_Window*); + void SDL_HideWindow(SDL_Window*); + void SDL_RaiseWindow(SDL_Window*); + void SDL_MaximizeWindow(SDL_Window*); + void SDL_MinimizeWindow(SDL_Window*); + void SDL_RestoreWindow(SDL_Window*); + int SDL_SetWindowFullscreen(SDL_Window*,uint); + SDL_Surface* SDL_GetWindowSurface(SDL_Window*); + int SDL_UpdateWindowSurface(SDL_Window*); + int SDL_UpdateWindowSurfaceRects(SDL_Window*,SDL_Rect*,int); + void SDL_SetWindowGrab(SDL_Window*,SDL_bool); + SDL_bool SDL_GetWindowGrab(SDL_Window*); + int SDL_SetWindowBrightness(SDL_Window*,float); + float SDL_GetWindowBrightness(SDL_Window*); + int SDL_SetWindowGammaRamp(SDL_Window*,const(ushort)*,const(ushort)*,const(ushort)*); + int SDL_GetWindowGammaRamp(SDL_Window*,ushort*,ushort*,ushort*); + void SDL_DestroyWindow(SDL_Window*); + SDL_bool SDL_IsScreenSaverEnabled(); + void SDL_EnableScreenSaver(); + void SDL_DisableScreenSaver(); + int SDL_GL_LoadLibrary(const(char)*); + void* SDL_GL_GetProcAddress(const(char)*); + void SDL_GL_UnloadLibrary(); + SDL_bool SDL_GL_ExtensionSupported(const(char)*); + int SDL_GL_SetAttribute(SDL_GLattr,int); + int SDL_GL_GetAttribute(SDL_GLattr,int*); + SDL_GLContext SDL_GL_CreateContext(SDL_Window*); + int SDL_GL_MakeCurrent(SDL_Window*,SDL_GLContext); + SDL_Window* SDL_GL_GetCurrentWindow(); + SDL_GLContext SDL_GL_GetCurrentContext(); + int SDL_GL_SetSwapInterval(int); + int SDL_GL_GetSwapInterval(); + void SDL_GL_SwapWindow(SDL_Window*); + void SDL_GL_DeleteContext(SDL_GLContext); + + static if(sdlSupport >= SDLSupport.sdl201) { + void SDL_GL_GetDrawableSize(SDL_Window*,int*,int*); + } + static if(sdlSupport >= SDLSupport.sdl202) { + void SDL_GL_ResetAttributes(); + } + static if(sdlSupport >= SDLSupport.sdl204) { + int SDL_GetDisplayDPI(int,float*,float*,float*); + SDL_Window* SDL_GetGrabbedWindow(); + int SDL_SetWindowHitTest(SDL_Window*,SDL_HitTest,void*); + } + static if(sdlSupport >= SDLSupport.sdl205) { + int SDL_GetDisplayUsableBounds(int,SDL_Rect*); + int SDL_GetWindowBordersSize(SDL_Window*,int*,int*,int*,int*); + int SDL_GetWindowOpacity(SDL_Window*,float*); + int SDL_SetWindowInputFocus(SDL_Window*); + int SDL_SetWindowModalFor(SDL_Window*,SDL_Window*); + int SDL_SetWindowOpacity(SDL_Window*,float); + void SDL_SetWindowResizable(SDL_Window*,SDL_bool); + } + static if(sdlSupport >= SDLSupport.sdl209) { + SDL_DisplayOrientation SDL_GetDisplayOrientation(int); + } + } +} +else { + extern(C) @nogc nothrow { + alias pSDL_GetNumVideoDrivers = int function(); + alias pSDL_GetVideoDriver = const(char)* function(int); + alias pSDL_VideoInit = int function(const(char)*); + alias pSDL_VideoQuit = void function(); + alias pSDL_GetCurrentVideoDriver = const(char)* function(); + alias pSDL_GetNumVideoDisplays = int function(); + alias pSDL_GetDisplayName = const(char)* function(int); + alias pSDL_GetDisplayBounds = int function(int,SDL_Rect*); + alias pSDL_GetNumDisplayModes = int function(int); + alias pSDL_GetDisplayMode = int function(int,int,SDL_DisplayMode*); + alias pSDL_GetDesktopDisplayMode = int function(int,SDL_DisplayMode*); + alias pSDL_GetCurrentDisplayMode = int function(int,SDL_DisplayMode*); + alias pSDL_GetClosestDisplayMode = SDL_DisplayMode* function(int,const(SDL_DisplayMode)*,SDL_DisplayMode*); + alias pSDL_GetWindowDisplayIndex = int function(SDL_Window*); + alias pSDL_SetWindowDisplayMode = int function(SDL_Window*,const(SDL_DisplayMode)*); + alias pSDL_GetWindowDisplayMode = int function(SDL_Window*,SDL_DisplayMode*); + alias pSDL_GetWindowPixelFormat = uint function(SDL_Window*); + alias pSDL_CreateWindow = SDL_Window* function(const(char)*,int,int,int,int,SDL_WindowFlags); + alias pSDL_CreateWindowFrom = SDL_Window* function(const(void)*); + alias pSDL_GetWindowID = uint function(SDL_Window*); + alias pSDL_GetWindowFromID = SDL_Window* function(uint); + alias pSDL_GetWindowFlags = SDL_WindowFlags function(SDL_Window*); + alias pSDL_SetWindowTitle = void function(SDL_Window*,const(char)*); + alias pSDL_GetWindowTitle = const(char)* function(SDL_Window*); + alias pSDL_SetWindowIcon = void function(SDL_Window*,SDL_Surface*); + alias pSDL_SetWindowData = void* function(SDL_Window*,const(char)*,void*); + alias pSDL_GetWindowData = void* function(SDL_Window*,const(char)*); + alias pSDL_SetWindowPosition = void function(SDL_Window*,int,int); + alias pSDL_GetWindowPosition = void function(SDL_Window*,int*,int*); + alias pSDL_SetWindowSize = void function(SDL_Window*,int,int); + alias pSDL_GetWindowSize = void function(SDL_Window*,int*,int*); + alias pSDL_SetWindowMinimumSize = void function(SDL_Window*,int,int); + alias pSDL_GetWindowMinimumSize = void function(SDL_Window*,int*,int*); + alias pSDL_SetWindowMaximumSize = void function(SDL_Window*,int,int); + alias pSDL_GetWindowMaximumSize = void function(SDL_Window*,int*,int*); + alias pSDL_SetWindowBordered = void function(SDL_Window*,SDL_bool); + alias pSDL_ShowWindow = void function(SDL_Window*); + alias pSDL_HideWindow = void function(SDL_Window*); + alias pSDL_RaiseWindow = void function(SDL_Window*); + alias pSDL_MaximizeWindow = void function(SDL_Window*); + alias pSDL_MinimizeWindow = void function(SDL_Window*); + alias pSDL_RestoreWindow = void function(SDL_Window*); + alias pSDL_SetWindowFullscreen = int function(SDL_Window*,uint); + alias pSDL_GetWindowSurface = SDL_Surface* function(SDL_Window*); + alias pSDL_UpdateWindowSurface = int function(SDL_Window*); + alias pSDL_UpdateWindowSurfaceRects = int function(SDL_Window*,SDL_Rect*,int); + alias pSDL_SetWindowGrab = void function(SDL_Window*,SDL_bool); + alias pSDL_GetWindowGrab = SDL_bool function(SDL_Window*); + alias pSDL_SetWindowBrightness = int function(SDL_Window*,float); + alias pSDL_GetWindowBrightness = float function(SDL_Window*); + alias pSDL_SetWindowGammaRamp = int function(SDL_Window*,const(ushort)*,const(ushort)*,const(ushort)*); + alias pSDL_GetWindowGammaRamp = int function(SDL_Window*,ushort*,ushort*,ushort*); + alias pSDL_DestroyWindow = void function(SDL_Window*); + alias pSDL_IsScreenSaverEnabled = SDL_bool function(); + alias pSDL_EnableScreenSaver = void function(); + alias pSDL_DisableScreenSaver = void function(); + alias pSDL_GL_LoadLibrary = int function(const(char)*); + alias pSDL_GL_GetProcAddress = void* function(const(char)*); + alias pSDL_GL_UnloadLibrary = void function(); + alias pSDL_GL_ExtensionSupported = SDL_bool function(const(char)*); + alias pSDL_GL_SetAttribute = int function(SDL_GLattr,int); + alias pSDL_GL_GetAttribute = int function(SDL_GLattr,int*); + alias pSDL_GL_CreateContext = SDL_GLContext function(SDL_Window*); + alias pSDL_GL_MakeCurrent = int function(SDL_Window*,SDL_GLContext); + alias pSDL_GL_GetCurrentWindow = SDL_Window* function(); + alias pSDL_GL_GetCurrentContext = SDL_GLContext function(); + alias pSDL_GL_SetSwapInterval = int function(int); + alias pSDL_GL_GetSwapInterval = int function(); + alias pSDL_GL_SwapWindow = void function(SDL_Window*); + alias pSDL_GL_DeleteContext = void function(SDL_GLContext); + } + + __gshared { + pSDL_GetNumVideoDrivers SDL_GetNumVideoDrivers; + pSDL_GetVideoDriver SDL_GetVideoDriver; + pSDL_VideoInit SDL_VideoInit; + pSDL_VideoQuit SDL_VideoQuit; + pSDL_GetCurrentVideoDriver SDL_GetCurrentVideoDriver; + pSDL_GetNumVideoDisplays SDL_GetNumVideoDisplays; + pSDL_GetDisplayName SDL_GetDisplayName; + pSDL_GetDisplayBounds SDL_GetDisplayBounds; + pSDL_GetNumDisplayModes SDL_GetNumDisplayModes; + pSDL_GetDisplayMode SDL_GetDisplayMode; + pSDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode; + pSDL_GetCurrentDisplayMode SDL_GetCurrentDisplayMode; + pSDL_GetClosestDisplayMode SDL_GetClosestDisplayMode; + pSDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex; + pSDL_SetWindowDisplayMode SDL_SetWindowDisplayMode; + pSDL_GetWindowDisplayMode SDL_GetWindowDisplayMode; + pSDL_GetWindowPixelFormat SDL_GetWindowPixelFormat; + pSDL_CreateWindow SDL_CreateWindow; + pSDL_CreateWindowFrom SDL_CreateWindowFrom; + pSDL_GetWindowID SDL_GetWindowID; + pSDL_GetWindowFromID SDL_GetWindowFromID; + pSDL_GetWindowFlags SDL_GetWindowFlags; + pSDL_SetWindowTitle SDL_SetWindowTitle; + pSDL_GetWindowTitle SDL_GetWindowTitle; + pSDL_SetWindowIcon SDL_SetWindowIcon; + pSDL_SetWindowData SDL_SetWindowData; + pSDL_GetWindowData SDL_GetWindowData; + pSDL_SetWindowPosition SDL_SetWindowPosition; + pSDL_GetWindowPosition SDL_GetWindowPosition; + pSDL_SetWindowSize SDL_SetWindowSize; + pSDL_GetWindowSize SDL_GetWindowSize; + pSDL_SetWindowMinimumSize SDL_SetWindowMinimumSize; + pSDL_GetWindowMinimumSize SDL_GetWindowMinimumSize; + pSDL_SetWindowMaximumSize SDL_SetWindowMaximumSize; + pSDL_GetWindowMaximumSize SDL_GetWindowMaximumSize; + pSDL_SetWindowBordered SDL_SetWindowBordered; + pSDL_ShowWindow SDL_ShowWindow; + pSDL_HideWindow SDL_HideWindow; + pSDL_RaiseWindow SDL_RaiseWindow; + pSDL_MaximizeWindow SDL_MaximizeWindow; + pSDL_MinimizeWindow SDL_MinimizeWindow; + pSDL_RestoreWindow SDL_RestoreWindow; + pSDL_SetWindowFullscreen SDL_SetWindowFullscreen; + pSDL_GetWindowSurface SDL_GetWindowSurface; + pSDL_UpdateWindowSurface SDL_UpdateWindowSurface; + pSDL_UpdateWindowSurfaceRects SDL_UpdateWindowSurfaceRects; + pSDL_SetWindowGrab SDL_SetWindowGrab; + pSDL_GetWindowGrab SDL_GetWindowGrab; + pSDL_SetWindowBrightness SDL_SetWindowBrightness; + pSDL_GetWindowBrightness SDL_GetWindowBrightness; + pSDL_SetWindowGammaRamp SDL_SetWindowGammaRamp; + pSDL_GetWindowGammaRamp SDL_GetWindowGammaRamp; + pSDL_DestroyWindow SDL_DestroyWindow; + pSDL_IsScreenSaverEnabled SDL_IsScreenSaverEnabled; + pSDL_EnableScreenSaver SDL_EnableScreenSaver; + pSDL_DisableScreenSaver SDL_DisableScreenSaver; + pSDL_GL_LoadLibrary SDL_GL_LoadLibrary; + pSDL_GL_GetProcAddress SDL_GL_GetProcAddress; + pSDL_GL_UnloadLibrary SDL_GL_UnloadLibrary; + pSDL_GL_ExtensionSupported SDL_GL_ExtensionSupported; + pSDL_GL_SetAttribute SDL_GL_SetAttribute; + pSDL_GL_GetAttribute SDL_GL_GetAttribute; + pSDL_GL_CreateContext SDL_GL_CreateContext; + pSDL_GL_MakeCurrent SDL_GL_MakeCurrent; + pSDL_GL_GetCurrentWindow SDL_GL_GetCurrentWindow; + pSDL_GL_GetCurrentContext SDL_GL_GetCurrentContext; + pSDL_GL_SetSwapInterval SDL_GL_SetSwapInterval; + pSDL_GL_GetSwapInterval SDL_GL_GetSwapInterval; + pSDL_GL_SwapWindow SDL_GL_SwapWindow; + pSDL_GL_DeleteContext SDL_GL_DeleteContext; + } + + static if(sdlSupport >= SDLSupport.sdl201) { + extern(C) @nogc nothrow { + alias pSDL_GL_GetDrawableSize = void function(SDL_Window*,int*,int*); + } + + __gshared { + pSDL_GL_GetDrawableSize SDL_GL_GetDrawableSize; + } + } + + static if(sdlSupport >= SDLSupport.sdl202) { + extern(C) @nogc nothrow { + alias pSDL_GL_ResetAttributes = void function(); + } + + __gshared { + pSDL_GL_ResetAttributes SDL_GL_ResetAttributes; + } + } + + static if(sdlSupport >= SDLSupport.sdl204) { + extern(C) @nogc nothrow { + alias pSDL_GetDisplayDPI = int function(int,float*,float*,float*); + alias pSDL_GetGrabbedWindow = SDL_Window* function(); + alias pSDL_SetWindowHitTest = int function(SDL_Window*,SDL_HitTest,void*); + } + + __gshared { + pSDL_GetDisplayDPI SDL_GetDisplayDPI; + pSDL_GetGrabbedWindow SDL_GetGrabbedWindow; + pSDL_SetWindowHitTest SDL_SetWindowHitTest; + } + } + + static if(sdlSupport >= SDLSupport.sdl205) { + extern(C) @nogc nothrow { + alias pSDL_GetDisplayUsableBounds = int function(int,SDL_Rect*); + alias pSDL_GetWindowBordersSize = int function(SDL_Window*,int*,int*,int*,int*); + alias pSDL_GetWindowOpacity = int function(SDL_Window*,float*); + alias pSDL_SetWindowInputFocus = int function(SDL_Window*); + alias pSDL_SetWindowModalFor = int function(SDL_Window*,SDL_Window*); + alias pSDL_SetWindowOpacity = int function(SDL_Window*,float); + alias pSDL_SetWindowResizable = void function(SDL_Window*,SDL_bool); + } + + __gshared { + pSDL_GetDisplayUsableBounds SDL_GetDisplayUsableBounds; + pSDL_GetWindowBordersSize SDL_GetWindowBordersSize; + pSDL_GetWindowOpacity SDL_GetWindowOpacity; + pSDL_SetWindowInputFocus SDL_SetWindowInputFocus; + pSDL_SetWindowModalFor SDL_SetWindowModalFor; + pSDL_SetWindowOpacity SDL_SetWindowOpacity; + pSDL_SetWindowResizable SDL_SetWindowResizable; + } + } + + static if(sdlSupport >= SDLSupport.sdl209) { + extern(C) @nogc nothrow { + alias pSDL_GetDisplayOrientation = SDL_DisplayOrientation function(int); + } + + __gshared { + pSDL_GetDisplayOrientation SDL_GetDisplayOrientation; + } + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/bind/sdlvulkan.d b/demos/external/imports/bindbc/sdl/bind/sdlvulkan.d new file mode 100644 index 0000000..0dc287d --- /dev/null +++ b/demos/external/imports/bindbc/sdl/bind/sdlvulkan.d @@ -0,0 +1,45 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.bind.sdlvulkan; + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlvideo : SDL_Window; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + static if(sdlSupport >= SDLSupport.sdl206) { + SDL_bool SDL_Vulkan_CreateSurface(SDL_Window*,void*,void*); + void SDL_Vulkan_GetDrawableSize(SDL_Window*,int*,int*); + SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window*,uint*,const(char)**); + void* SDL_Vulkan_GetVkGetInstanceProcAddr(); + int SDL_Vulkan_LoadLibrary(const(char)*); + void SDL_Vulkan_UnloadLibrary(); + } + } +} +else { + static if(sdlSupport >= SDLSupport.sdl206) { + extern(C) @nogc nothrow { + alias pSDL_Vulkan_CreateSurface = SDL_bool function(SDL_Window*,void*,void*); + alias pSDL_Vulkan_GetDrawableSize = void function(SDL_Window*,int*,int*); + alias pSDL_Vulkan_GetInstanceExtensions = SDL_bool function(SDL_Window*,uint*,const(char)**); + alias pSDL_Vulkan_GetVkGetInstanceProcAddr = void* function(); + alias pSDL_Vulkan_LoadLibrary = int function(const(char)*); + alias pSDL_Vulkan_UnloadLibrary = void function(); + } + + __gshared { + pSDL_Vulkan_CreateSurface SDL_Vulkan_CreateSurface; + pSDL_Vulkan_GetDrawableSize SDL_Vulkan_GetDrawableSize; + pSDL_Vulkan_GetInstanceExtensions SDL_Vulkan_GetInstanceExtensions; + pSDL_Vulkan_GetVkGetInstanceProcAddr SDL_Vulkan_GetVkGetInstanceProcAddr; + pSDL_Vulkan_LoadLibrary SDL_Vulkan_LoadLibrary; + pSDL_Vulkan_UnloadLibrary SDL_Vulkan_UnloadLibrary; + } + } +} diff --git a/demos/external/imports/bindbc/sdl/config.d b/demos/external/imports/bindbc/sdl/config.d new file mode 100644 index 0000000..1a76433 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/config.d @@ -0,0 +1,44 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.config; + +enum SDLSupport { + noLibrary, + badLibrary, + sdl200 = 200, + sdl201 = 201, + sdl202 = 202, + sdl203 = 203, + sdl204 = 204, + sdl205 = 205, + sdl206 = 206, + sdl207 = 207, + sdl208 = 208, + sdl209 = 209, + sdl2010 = 2010, +} + +version(SDL_2010) enum sdlSupport = SDLSupport.sdl2010; +else version(SDL_209) enum sdlSupport = SDLSupport.sdl209; +else version(SDL_208) enum sdlSupport = SDLSupport.sdl208; +else version(SDL_207) enum sdlSupport = SDLSupport.sdl207; +else version(SDL_206) enum sdlSupport = SDLSupport.sdl206; +else version(SDL_205) enum sdlSupport = SDLSupport.sdl205; +else version(SDL_204) enum sdlSupport = SDLSupport.sdl204; +else version(SDL_203) enum sdlSupport = SDLSupport.sdl203; +else version(SDL_202) enum sdlSupport = SDLSupport.sdl202; +else version(SDL_201) enum sdlSupport = SDLSupport.sdl201; +else enum sdlSupport = SDLSupport.sdl200; + +enum expandEnum(EnumType, string fqnEnumType = EnumType.stringof) = (){ + string expandEnum = "enum {"; + foreach(m;__traits(allMembers, EnumType)) { + expandEnum ~= m ~ " = " ~ fqnEnumType ~ "." ~ m ~ ","; + } + expandEnum ~= "}"; + return expandEnum; +}(); \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/dynload.d b/demos/external/imports/bindbc/sdl/dynload.d new file mode 100644 index 0000000..0aa3b84 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/dynload.d @@ -0,0 +1,712 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.dynload; + +version(BindSDL_Static) {} +else: + +import bindbc.loader; +import bindbc.sdl.config, + bindbc.sdl.bind; + +private { + SharedLib lib; + SDLSupport loadedVersion; +} + +void unloadSDL() +{ + if(lib != invalidHandle) { + lib.unload(); + } +} + +SDLSupport loadedSDLVersion() { return loadedVersion; } + +bool isSDLLoaded() +{ + return lib != invalidHandle; +} + +SDLSupport loadSDL() +{ + // #1778 prevents me from using static arrays here :( + version(Windows) { + const(char)[][1] libNames = ["SDL2.dll"]; + } + else version(OSX) { + const(char)[][7] libNames = [ + "libSDL2.dylib", + "/usr/local/lib/libSDL2.dylib", + "/usr/local/lib/libSDL2/libSDL2.dylib", + "../Frameworks/SDL2.framework/SDL2", + "/Library/Frameworks/SDL2.framework/SDL2", + "/System/Library/Frameworks/SDL2.framework/SDL2", + "/opt/local/lib/libSDL2.dylib" + ]; + } + else version(Posix) { + const(char)[][6] libNames = [ + "libSDL2.so", + "/usr/local/lib/libSDL2.so", + "libSDL2-2.0.so", + "/usr/local/lib/libSDL2-2.0.so", + "libSDL2-2.0.so.0", + "/usr/local/lib/libSDL2-2.0.so.0" + ]; + } + else static assert(0, "bindbc-sdl is not yet supported on this platform."); + + SDLSupport ret; + foreach(name; libNames) { + ret = loadSDL(name.ptr); + if(ret != SDLSupport.noLibrary) break; + } + return ret; +} + +SDLSupport loadSDL(const(char)* libName) +{ + lib = load(libName); + if(lib == invalidHandle) { + return SDLSupport.noLibrary; + } + + auto errCount = errorCount(); + loadedVersion = SDLSupport.badLibrary; + + lib.bindSymbol(cast(void**)&SDL_Init, "SDL_Init"); + lib.bindSymbol(cast(void**)&SDL_InitSubSystem, "SDL_InitSubSystem"); + lib.bindSymbol(cast(void**)&SDL_QuitSubSystem, "SDL_QuitSubSystem"); + lib.bindSymbol(cast(void**)&SDL_WasInit, "SDL_WasInit"); + lib.bindSymbol(cast(void**)&SDL_Quit, "SDL_Quit"); + lib.bindSymbol(cast(void**)&SDL_SetAssertionHandler, "SDL_SetAssertionHandler"); + lib.bindSymbol(cast(void**)&SDL_GetAssertionReport, "SDL_GetAssertionReport"); + lib.bindSymbol(cast(void**)&SDL_ResetAssertionReport, "SDL_ResetAssertionReport"); + lib.bindSymbol(cast(void**)&SDL_GetNumAudioDrivers, "SDL_GetNumAudioDrivers"); + lib.bindSymbol(cast(void**)&SDL_GetAudioDriver, "SDL_GetAudioDriver"); + lib.bindSymbol(cast(void**)&SDL_AudioInit, "SDL_AudioInit"); + lib.bindSymbol(cast(void**)&SDL_AudioQuit, "SDL_AudioQuit"); + lib.bindSymbol(cast(void**)&SDL_GetCurrentAudioDriver, "SDL_GetCurrentAudioDriver"); + lib.bindSymbol(cast(void**)&SDL_OpenAudio, "SDL_OpenAudio"); + lib.bindSymbol(cast(void**)&SDL_GetNumAudioDevices, "SDL_GetNumAudioDevices"); + lib.bindSymbol(cast(void**)&SDL_GetAudioDeviceName, "SDL_GetAudioDeviceName"); + lib.bindSymbol(cast(void**)&SDL_OpenAudioDevice, "SDL_OpenAudioDevice"); + lib.bindSymbol(cast(void**)&SDL_GetAudioStatus, "SDL_GetAudioStatus"); + lib.bindSymbol(cast(void**)&SDL_GetAudioDeviceStatus, "SDL_GetAudioDeviceStatus"); + lib.bindSymbol(cast(void**)&SDL_PauseAudio, "SDL_PauseAudio"); + lib.bindSymbol(cast(void**)&SDL_PauseAudioDevice, "SDL_PauseAudioDevice"); + lib.bindSymbol(cast(void**)&SDL_LoadWAV_RW, "SDL_LoadWAV_RW"); + lib.bindSymbol(cast(void**)&SDL_FreeWAV, "SDL_FreeWAV"); + lib.bindSymbol(cast(void**)&SDL_BuildAudioCVT, "SDL_BuildAudioCVT"); + lib.bindSymbol(cast(void**)&SDL_ConvertAudio, "SDL_ConvertAudio"); + lib.bindSymbol(cast(void**)&SDL_MixAudio, "SDL_MixAudio"); + lib.bindSymbol(cast(void**)&SDL_MixAudioFormat, "SDL_MixAudioFormat"); + lib.bindSymbol(cast(void**)&SDL_LockAudio, "SDL_LockAudio"); + lib.bindSymbol(cast(void**)&SDL_LockAudioDevice, "SDL_LockAudioDevice"); + lib.bindSymbol(cast(void**)&SDL_UnlockAudio, "SDL_UnlockAudio"); + lib.bindSymbol(cast(void**)&SDL_UnlockAudioDevice, "SDL_UnlockAudioDevice"); + lib.bindSymbol(cast(void**)&SDL_CloseAudio, "SDL_CloseAudio"); + lib.bindSymbol(cast(void**)&SDL_CloseAudioDevice, "SDL_CloseAudioDevice"); + lib.bindSymbol(cast(void**)&SDL_SetClipboardText, "SDL_SetClipboardText"); + lib.bindSymbol(cast(void**)&SDL_GetClipboardText, "SDL_GetClipboardText"); + lib.bindSymbol(cast(void**)&SDL_HasClipboardText, "SDL_HasClipboardText"); + lib.bindSymbol(cast(void**)&SDL_GetCPUCount, "SDL_GetCPUCount"); + lib.bindSymbol(cast(void**)&SDL_GetCPUCacheLineSize, "SDL_GetCPUCacheLineSize"); + lib.bindSymbol(cast(void**)&SDL_HasRDTSC, "SDL_HasRDTSC"); + lib.bindSymbol(cast(void**)&SDL_HasAltiVec, "SDL_HasAltiVec"); + lib.bindSymbol(cast(void**)&SDL_HasMMX, "SDL_HasMMX"); + lib.bindSymbol(cast(void**)&SDL_Has3DNow, "SDL_Has3DNow"); + lib.bindSymbol(cast(void**)&SDL_HasSSE, "SDL_HasSSE"); + lib.bindSymbol(cast(void**)&SDL_HasSSE2, "SDL_HasSSE2"); + lib.bindSymbol(cast(void**)&SDL_HasSSE3, "SDL_HasSSE3"); + lib.bindSymbol(cast(void**)&SDL_HasSSE41, "SDL_HasSSE41"); + lib.bindSymbol(cast(void**)&SDL_HasSSE42, "SDL_HasSSE42"); + lib.bindSymbol(cast(void**)&SDL_SetError, "SDL_SetError"); + lib.bindSymbol(cast(void**)&SDL_GetError, "SDL_GetError"); + lib.bindSymbol(cast(void**)&SDL_ClearError, "SDL_ClearError"); + lib.bindSymbol(cast(void**)&SDL_PumpEvents, "SDL_PumpEvents"); + lib.bindSymbol(cast(void**)&SDL_PeepEvents, "SDL_PeepEvents"); + lib.bindSymbol(cast(void**)&SDL_HasEvent, "SDL_HasEvent"); + lib.bindSymbol(cast(void**)&SDL_HasEvents, "SDL_HasEvents"); + lib.bindSymbol(cast(void**)&SDL_FlushEvent, "SDL_FlushEvent"); + lib.bindSymbol(cast(void**)&SDL_FlushEvents, "SDL_FlushEvents"); + lib.bindSymbol(cast(void**)&SDL_PollEvent, "SDL_PollEvent"); + lib.bindSymbol(cast(void**)&SDL_WaitEvent, "SDL_WaitEvent"); + lib.bindSymbol(cast(void**)&SDL_WaitEventTimeout, "SDL_WaitEventTimeout"); + lib.bindSymbol(cast(void**)&SDL_PushEvent, "SDL_PushEvent"); + lib.bindSymbol(cast(void**)&SDL_SetEventFilter, "SDL_SetEventFilter"); + lib.bindSymbol(cast(void**)&SDL_GetEventFilter, "SDL_GetEventFilter"); + lib.bindSymbol(cast(void**)&SDL_AddEventWatch, "SDL_AddEventWatch"); + lib.bindSymbol(cast(void**)&SDL_DelEventWatch, "SDL_DelEventWatch"); + lib.bindSymbol(cast(void**)&SDL_FilterEvents, "SDL_FilterEvents"); + lib.bindSymbol(cast(void**)&SDL_EventState, "SDL_EventState"); + lib.bindSymbol(cast(void**)&SDL_RegisterEvents, "SDL_RegisterEvents"); + lib.bindSymbol(cast(void**)&SDL_GameControllerAddMapping, "SDL_GameControllerAddMapping"); + lib.bindSymbol(cast(void**)&SDL_GameControllerMappingForGUID, "SDL_GameControllerMappingForGUID"); + lib.bindSymbol(cast(void**)&SDL_GameControllerMapping, "SDL_GameControllerMapping"); + lib.bindSymbol(cast(void**)&SDL_IsGameController, "SDL_IsGameController"); + lib.bindSymbol(cast(void**)&SDL_GameControllerNameForIndex, "SDL_GameControllerNameForIndex"); + lib.bindSymbol(cast(void**)&SDL_GameControllerOpen, "SDL_GameControllerOpen"); + lib.bindSymbol(cast(void**)&SDL_GameControllerName, "SDL_GameControllerName"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetAttached, "SDL_GameControllerGetAttached"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetJoystick, "SDL_GameControllerGetJoystick"); + lib.bindSymbol(cast(void**)&SDL_GameControllerEventState, "SDL_GameControllerEventState"); + lib.bindSymbol(cast(void**)&SDL_GameControllerUpdate, "SDL_GameControllerUpdate"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetAxisFromString, "SDL_GameControllerGetAxisFromString"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetStringForAxis, "SDL_GameControllerGetStringForAxis"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetBindForAxis, "SDL_GameControllerGetBindForAxis"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetButtonFromString, "SDL_GameControllerGetButtonFromString"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetStringForButton, "SDL_GameControllerGetStringForButton"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetBindForButton, "SDL_GameControllerGetBindForButton"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetButton, "SDL_GameControllerGetButton"); + lib.bindSymbol(cast(void**)&SDL_GameControllerClose, "SDL_GameControllerClose"); + lib.bindSymbol(cast(void**)&SDL_RecordGesture, "SDL_RecordGesture"); + lib.bindSymbol(cast(void**)&SDL_SaveAllDollarTemplates, "SDL_SaveAllDollarTemplates"); + lib.bindSymbol(cast(void**)&SDL_SaveDollarTemplate, "SDL_SaveDollarTemplate"); + lib.bindSymbol(cast(void**)&SDL_LoadDollarTemplates, "SDL_LoadDollarTemplates"); + lib.bindSymbol(cast(void**)&SDL_NumHaptics, "SDL_NumHaptics"); + lib.bindSymbol(cast(void**)&SDL_HapticName, "SDL_HapticName"); + lib.bindSymbol(cast(void**)&SDL_HapticOpen, "SDL_HapticOpen"); + lib.bindSymbol(cast(void**)&SDL_HapticOpened, "SDL_HapticOpened"); + lib.bindSymbol(cast(void**)&SDL_HapticIndex, "SDL_HapticIndex"); + lib.bindSymbol(cast(void**)&SDL_MouseIsHaptic, "SDL_MouseIsHaptic"); + lib.bindSymbol(cast(void**)&SDL_HapticOpenFromMouse, "SDL_HapticOpenFromMouse"); + lib.bindSymbol(cast(void**)&SDL_JoystickIsHaptic, "SDL_JoystickIsHaptic"); + lib.bindSymbol(cast(void**)&SDL_HapticOpenFromJoystick, "SDL_HapticOpenFromJoystick"); + lib.bindSymbol(cast(void**)&SDL_HapticClose, "SDL_HapticClose"); + lib.bindSymbol(cast(void**)&SDL_HapticNumEffects, "SDL_HapticNumEffects"); + lib.bindSymbol(cast(void**)&SDL_HapticNumEffectsPlaying, "SDL_HapticNumEffectsPlaying"); + lib.bindSymbol(cast(void**)&SDL_HapticQuery, "SDL_HapticQuery"); + lib.bindSymbol(cast(void**)&SDL_HapticNumAxes, "SDL_HapticNumAxes"); + lib.bindSymbol(cast(void**)&SDL_HapticEffectSupported, "SDL_HapticEffectSupported"); + lib.bindSymbol(cast(void**)&SDL_HapticNewEffect, "SDL_HapticNewEffect"); + lib.bindSymbol(cast(void**)&SDL_HapticUpdateEffect, "SDL_HapticUpdateEffect"); + lib.bindSymbol(cast(void**)&SDL_HapticRunEffect, "SDL_HapticRunEffect"); + lib.bindSymbol(cast(void**)&SDL_HapticStopEffect, "SDL_HapticStopEffect"); + lib.bindSymbol(cast(void**)&SDL_HapticDestroyEffect, "SDL_HapticDestroyEffect"); + lib.bindSymbol(cast(void**)&SDL_HapticGetEffectStatus, "SDL_HapticGetEffectStatus"); + lib.bindSymbol(cast(void**)&SDL_HapticSetGain, "SDL_HapticSetGain"); + lib.bindSymbol(cast(void**)&SDL_HapticSetAutocenter, "SDL_HapticSetAutocenter"); + lib.bindSymbol(cast(void**)&SDL_HapticPause, "SDL_HapticPause"); + lib.bindSymbol(cast(void**)&SDL_HapticUnpause, "SDL_HapticUnpause"); + lib.bindSymbol(cast(void**)&SDL_HapticStopAll, "SDL_HapticStopAll"); + lib.bindSymbol(cast(void**)&SDL_HapticRumbleSupported, "SDL_HapticRumbleSupported"); + lib.bindSymbol(cast(void**)&SDL_HapticRumbleInit, "SDL_HapticRumbleInit"); + lib.bindSymbol(cast(void**)&SDL_HapticRumblePlay, "SDL_HapticRumblePlay"); + lib.bindSymbol(cast(void**)&SDL_HapticRumbleStop, "SDL_HapticRumbleStop"); + lib.bindSymbol(cast(void**)&SDL_SetHintWithPriority, "SDL_SetHintWithPriority"); + lib.bindSymbol(cast(void**)&SDL_SetHint, "SDL_SetHint"); + lib.bindSymbol(cast(void**)&SDL_GetHint, "SDL_GetHint"); + lib.bindSymbol(cast(void**)&SDL_AddHintCallback, "SDL_AddHintCallback"); + lib.bindSymbol(cast(void**)&SDL_DelHintCallback, "SDL_DelHintCallback"); + lib.bindSymbol(cast(void**)&SDL_ClearHints, "SDL_ClearHints"); + lib.bindSymbol(cast(void**)&SDL_NumJoysticks, "SDL_NumJoysticks"); + lib.bindSymbol(cast(void**)&SDL_JoystickNameForIndex, "SDL_JoystickNameForIndex"); + lib.bindSymbol(cast(void**)&SDL_JoystickOpen, "SDL_JoystickOpen"); + lib.bindSymbol(cast(void**)&SDL_JoystickName, "SDL_JoystickName"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceGUID, "SDL_JoystickGetDeviceGUID"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetGUID, "SDL_JoystickGetGUID"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetGUIDString, "SDL_JoystickGetGUIDString"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetGUIDFromString, "SDL_JoystickGetGUIDFromString"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetAttached, "SDL_JoystickGetAttached"); + lib.bindSymbol(cast(void**)&SDL_JoystickInstanceID, "SDL_JoystickInstanceID"); + lib.bindSymbol(cast(void**)&SDL_JoystickNumAxes, "SDL_JoystickNumAxes"); + lib.bindSymbol(cast(void**)&SDL_JoystickNumBalls, "SDL_JoystickNumBalls"); + lib.bindSymbol(cast(void**)&SDL_JoystickNumHats, "SDL_JoystickNumHats"); + lib.bindSymbol(cast(void**)&SDL_JoystickNumButtons, "SDL_JoystickNumButtons"); + lib.bindSymbol(cast(void**)&SDL_JoystickUpdate, "SDL_JoystickUpdate"); + lib.bindSymbol(cast(void**)&SDL_JoystickEventState, "SDL_JoystickEventState"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetAxis, "SDL_JoystickGetAxis"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetHat, "SDL_JoystickGetHat"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetBall, "SDL_JoystickGetBall"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetButton, "SDL_JoystickGetButton"); + lib.bindSymbol(cast(void**)&SDL_JoystickClose, "SDL_JoystickClose"); + lib.bindSymbol(cast(void**)&SDL_GetKeyboardFocus, "SDL_GetKeyboardFocus"); + lib.bindSymbol(cast(void**)&SDL_GetKeyboardState, "SDL_GetKeyboardState"); + lib.bindSymbol(cast(void**)&SDL_GetModState, "SDL_GetModState"); + lib.bindSymbol(cast(void**)&SDL_SetModState, "SDL_SetModState"); + lib.bindSymbol(cast(void**)&SDL_GetKeyFromScancode, "SDL_GetKeyFromScancode"); + lib.bindSymbol(cast(void**)&SDL_GetScancodeFromKey, "SDL_GetScancodeFromKey"); + lib.bindSymbol(cast(void**)&SDL_GetScancodeName, "SDL_GetScancodeName"); + lib.bindSymbol(cast(void**)&SDL_GetScancodeFromName, "SDL_GetScancodeFromName"); + lib.bindSymbol(cast(void**)&SDL_GetKeyName, "SDL_GetKeyName"); + lib.bindSymbol(cast(void**)&SDL_GetKeyFromName, "SDL_GetKeyFromName"); + lib.bindSymbol(cast(void**)&SDL_StartTextInput, "SDL_StartTextInput"); + lib.bindSymbol(cast(void**)&SDL_IsTextInputActive, "SDL_IsTextInputActive"); + lib.bindSymbol(cast(void**)&SDL_StopTextInput, "SDL_StopTextInput"); + lib.bindSymbol(cast(void**)&SDL_SetTextInputRect, "SDL_SetTextInputRect"); + lib.bindSymbol(cast(void**)&SDL_HasScreenKeyboardSupport, "SDL_HasScreenKeyboardSupport"); + lib.bindSymbol(cast(void**)&SDL_IsScreenKeyboardShown, "SDL_IsScreenKeyboardShown"); + lib.bindSymbol(cast(void**)&SDL_LoadObject, "SDL_LoadObject"); + lib.bindSymbol(cast(void**)&SDL_LoadFunction, "SDL_LoadFunction"); + lib.bindSymbol(cast(void**)&SDL_UnloadObject, "SDL_UnloadObject"); + lib.bindSymbol(cast(void**)&SDL_LogSetAllPriority, "SDL_LogSetAllPriority"); + lib.bindSymbol(cast(void**)&SDL_LogSetPriority, "SDL_LogSetPriority"); + lib.bindSymbol(cast(void**)&SDL_LogGetPriority, "SDL_LogGetPriority"); + lib.bindSymbol(cast(void**)&SDL_LogResetPriorities, "SDL_LogResetPriorities"); + lib.bindSymbol(cast(void**)&SDL_Log, "SDL_Log"); + lib.bindSymbol(cast(void**)&SDL_LogVerbose, "SDL_LogVerbose"); + lib.bindSymbol(cast(void**)&SDL_LogDebug, "SDL_LogDebug"); + lib.bindSymbol(cast(void**)&SDL_LogInfo, "SDL_LogInfo"); + lib.bindSymbol(cast(void**)&SDL_LogWarn, "SDL_LogWarn"); + lib.bindSymbol(cast(void**)&SDL_LogError, "SDL_LogError"); + lib.bindSymbol(cast(void**)&SDL_LogCritical, "SDL_LogCritical"); + lib.bindSymbol(cast(void**)&SDL_LogMessage, "SDL_LogMessage"); + lib.bindSymbol(cast(void**)&SDL_LogMessageV, "SDL_LogMessageV"); + lib.bindSymbol(cast(void**)&SDL_LogGetOutputFunction, "SDL_LogGetOutputFunction"); + lib.bindSymbol(cast(void**)&SDL_LogSetOutputFunction, "SDL_LogSetOutputFunction"); + lib.bindSymbol(cast(void**)&SDL_ShowMessageBox, "SDL_ShowMessageBox"); + lib.bindSymbol(cast(void**)&SDL_ShowSimpleMessageBox, "SDL_ShowSimpleMessageBox"); + lib.bindSymbol(cast(void**)&SDL_GetMouseFocus, "SDL_GetMouseFocus"); + lib.bindSymbol(cast(void**)&SDL_GetMouseState, "SDL_GetMouseState"); + lib.bindSymbol(cast(void**)&SDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"); + lib.bindSymbol(cast(void**)&SDL_WarpMouseInWindow, "SDL_WarpMouseInWindow"); + lib.bindSymbol(cast(void**)&SDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"); + lib.bindSymbol(cast(void**)&SDL_GetRelativeMouseMode, "SDL_GetRelativeMouseMode"); + lib.bindSymbol(cast(void**)&SDL_CreateCursor, "SDL_CreateCursor"); + lib.bindSymbol(cast(void**)&SDL_CreateColorCursor, "SDL_CreateColorCursor"); + lib.bindSymbol(cast(void**)&SDL_CreateSystemCursor, "SDL_CreateSystemCursor"); + lib.bindSymbol(cast(void**)&SDL_SetCursor, "SDL_SetCursor"); + lib.bindSymbol(cast(void**)&SDL_GetCursor, "SDL_GetCursor"); + lib.bindSymbol(cast(void**)&SDL_GetDefaultCursor, "SDL_GetDefaultCursor"); + lib.bindSymbol(cast(void**)&SDL_FreeCursor, "SDL_FreeCursor"); + lib.bindSymbol(cast(void**)&SDL_ShowCursor, "SDL_ShowCursor"); + lib.bindSymbol(cast(void**)&SDL_GetPixelFormatName, "SDL_GetPixelFormatName"); + lib.bindSymbol(cast(void**)&SDL_PixelFormatEnumToMasks, "SDL_PixelFormatEnumToMasks"); + lib.bindSymbol(cast(void**)&SDL_MasksToPixelFormatEnum, "SDL_MasksToPixelFormatEnum"); + lib.bindSymbol(cast(void**)&SDL_AllocFormat, "SDL_AllocFormat"); + lib.bindSymbol(cast(void**)&SDL_FreeFormat, "SDL_FreeFormat"); + lib.bindSymbol(cast(void**)&SDL_AllocPalette, "SDL_AllocPalette"); + lib.bindSymbol(cast(void**)&SDL_SetPixelFormatPalette, "SDL_SetPixelFormatPalette"); + lib.bindSymbol(cast(void**)&SDL_SetPaletteColors, "SDL_SetPaletteColors"); + lib.bindSymbol(cast(void**)&SDL_FreePalette, "SDL_FreePalette"); + lib.bindSymbol(cast(void**)&SDL_MapRGB, "SDL_MapRGB"); + lib.bindSymbol(cast(void**)&SDL_MapRGBA, "SDL_MapRGBA"); + lib.bindSymbol(cast(void**)&SDL_GetRGB, "SDL_GetRGB"); + lib.bindSymbol(cast(void**)&SDL_GetRGBA, "SDL_GetRGBA"); + lib.bindSymbol(cast(void**)&SDL_CalculateGammaRamp, "SDL_CalculateGammaRamp"); + lib.bindSymbol(cast(void**)&SDL_GetPlatform, "SDL_GetPlatform"); + lib.bindSymbol(cast(void**)&SDL_GetPowerInfo, "SDL_GetPowerInfo"); + lib.bindSymbol(cast(void**)&SDL_HasIntersection, "SDL_HasIntersection"); + lib.bindSymbol(cast(void**)&SDL_IntersectRect, "SDL_IntersectRect"); + lib.bindSymbol(cast(void**)&SDL_UnionRect, "SDL_UnionRect"); + lib.bindSymbol(cast(void**)&SDL_EnclosePoints, "SDL_EnclosePoints"); + lib.bindSymbol(cast(void**)&SDL_IntersectRectAndLine, "SDL_IntersectRectAndLine"); + lib.bindSymbol(cast(void**)&SDL_GetNumRenderDrivers, "SDL_GetNumRenderDrivers"); + lib.bindSymbol(cast(void**)&SDL_GetRenderDriverInfo, "SDL_GetRenderDriverInfo"); + lib.bindSymbol(cast(void**)&SDL_CreateWindowAndRenderer, "SDL_CreateWindowAndRenderer"); + lib.bindSymbol(cast(void**)&SDL_CreateRenderer, "SDL_CreateRenderer"); + lib.bindSymbol(cast(void**)&SDL_CreateSoftwareRenderer, "SDL_CreateSoftwareRenderer"); + lib.bindSymbol(cast(void**)&SDL_GetRenderer, "SDL_GetRenderer"); + lib.bindSymbol(cast(void**)&SDL_GetRendererInfo, "SDL_GetRendererInfo"); + lib.bindSymbol(cast(void**)&SDL_GetRendererOutputSize, "SDL_GetRendererOutputSize"); + lib.bindSymbol(cast(void**)&SDL_CreateTexture, "SDL_CreateTexture"); + lib.bindSymbol(cast(void**)&SDL_CreateTextureFromSurface, "SDL_CreateTextureFromSurface"); + lib.bindSymbol(cast(void**)&SDL_QueryTexture, "SDL_QueryTexture"); + lib.bindSymbol(cast(void**)&SDL_SetTextureColorMod, "SDL_SetTextureColorMod"); + lib.bindSymbol(cast(void**)&SDL_GetTextureColorMod, "SDL_GetTextureColorMod"); + lib.bindSymbol(cast(void**)&SDL_SetTextureAlphaMod, "SDL_SetTextureAlphaMod"); + lib.bindSymbol(cast(void**)&SDL_GetTextureAlphaMod, "SDL_GetTextureAlphaMod"); + lib.bindSymbol(cast(void**)&SDL_SetTextureBlendMode, "SDL_SetTextureBlendMode"); + lib.bindSymbol(cast(void**)&SDL_GetTextureBlendMode, "SDL_GetTextureBlendMode"); + lib.bindSymbol(cast(void**)&SDL_UpdateTexture, "SDL_UpdateTexture"); + lib.bindSymbol(cast(void**)&SDL_LockTexture, "SDL_LockTexture"); + lib.bindSymbol(cast(void**)&SDL_UnlockTexture, "SDL_UnlockTexture"); + lib.bindSymbol(cast(void**)&SDL_RenderTargetSupported, "SDL_RenderTargetSupported"); + lib.bindSymbol(cast(void**)&SDL_SetRenderTarget, "SDL_SetRenderTarget"); + lib.bindSymbol(cast(void**)&SDL_GetRenderTarget, "SDL_GetRenderTarget"); + lib.bindSymbol(cast(void**)&SDL_RenderSetClipRect, "SDL_RenderSetClipRect"); + lib.bindSymbol(cast(void**)&SDL_RenderGetClipRect, "SDL_RenderGetClipRect"); + lib.bindSymbol(cast(void**)&SDL_RenderSetLogicalSize, "SDL_RenderSetLogicalSize"); + lib.bindSymbol(cast(void**)&SDL_RenderGetLogicalSize, "SDL_RenderGetLogicalSize"); + lib.bindSymbol(cast(void**)&SDL_RenderSetViewport, "SDL_RenderSetViewport"); + lib.bindSymbol(cast(void**)&SDL_RenderGetViewport, "SDL_RenderGetViewport"); + lib.bindSymbol(cast(void**)&SDL_RenderSetScale, "SDL_RenderSetScale"); + lib.bindSymbol(cast(void**)&SDL_RenderGetScale, "SDL_RenderGetScale"); + lib.bindSymbol(cast(void**)&SDL_SetRenderDrawColor, "SDL_SetRenderDrawColor"); + lib.bindSymbol(cast(void**)&SDL_GetRenderDrawColor, "SDL_GetRenderDrawColor"); + lib.bindSymbol(cast(void**)&SDL_SetRenderDrawBlendMode, "SDL_SetRenderDrawBlendMode"); + lib.bindSymbol(cast(void**)&SDL_GetRenderDrawBlendMode, "SDL_GetRenderDrawBlendMode"); + lib.bindSymbol(cast(void**)&SDL_RenderClear, "SDL_RenderClear"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawPoint, "SDL_RenderDrawPoint"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawPoints, "SDL_RenderDrawPoints"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawLine, "SDL_RenderDrawLine"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawLines, "SDL_RenderDrawLines"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawRect, "SDL_RenderDrawRect"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawRects, "SDL_RenderDrawRects"); + lib.bindSymbol(cast(void**)&SDL_RenderFillRect, "SDL_RenderFillRect"); + lib.bindSymbol(cast(void**)&SDL_RenderFillRects, "SDL_RenderFillRects"); + lib.bindSymbol(cast(void**)&SDL_RenderCopy, "SDL_RenderCopy"); + lib.bindSymbol(cast(void**)&SDL_RenderCopyEx, "SDL_RenderCopyEx"); + lib.bindSymbol(cast(void**)&SDL_RenderReadPixels, "SDL_RenderReadPixels"); + lib.bindSymbol(cast(void**)&SDL_RenderPresent, "SDL_RenderPresent"); + lib.bindSymbol(cast(void**)&SDL_DestroyTexture, "SDL_DestroyTexture"); + lib.bindSymbol(cast(void**)&SDL_DestroyRenderer, "SDL_DestroyRenderer"); + lib.bindSymbol(cast(void**)&SDL_GL_BindTexture, "SDL_GL_BindTexture"); + lib.bindSymbol(cast(void**)&SDL_GL_UnbindTexture, "SDL_GL_UnbindTexture"); + lib.bindSymbol(cast(void**)&SDL_RWFromFile, "SDL_RWFromFile"); + lib.bindSymbol(cast(void**)&SDL_RWFromFP, "SDL_RWFromFP"); + lib.bindSymbol(cast(void**)&SDL_RWFromMem, "SDL_RWFromMem"); + lib.bindSymbol(cast(void**)&SDL_RWFromConstMem, "SDL_RWFromConstMem"); + lib.bindSymbol(cast(void**)&SDL_AllocRW, "SDL_AllocRW"); + lib.bindSymbol(cast(void**)&SDL_FreeRW, "SDL_FreeRW"); + lib.bindSymbol(cast(void**)&SDL_ReadU8, "SDL_ReadU8"); + lib.bindSymbol(cast(void**)&SDL_ReadLE16, "SDL_ReadLE16"); + lib.bindSymbol(cast(void**)&SDL_ReadBE16, "SDL_ReadBE16"); + lib.bindSymbol(cast(void**)&SDL_ReadLE32, "SDL_ReadLE32"); + lib.bindSymbol(cast(void**)&SDL_ReadBE32, "SDL_ReadBE32"); + lib.bindSymbol(cast(void**)&SDL_ReadLE64, "SDL_ReadLE64"); + lib.bindSymbol(cast(void**)&SDL_ReadBE64, "SDL_ReadBE64"); + lib.bindSymbol(cast(void**)&SDL_WriteU8, "SDL_WriteU8"); + lib.bindSymbol(cast(void**)&SDL_WriteLE16, "SDL_WriteLE16"); + lib.bindSymbol(cast(void**)&SDL_WriteBE16, "SDL_WriteBE16"); + lib.bindSymbol(cast(void**)&SDL_WriteLE32, "SDL_WriteLE32"); + lib.bindSymbol(cast(void**)&SDL_WriteBE32, "SDL_WriteBE32"); + lib.bindSymbol(cast(void**)&SDL_WriteLE64, "SDL_WriteLE64"); + lib.bindSymbol(cast(void**)&SDL_WriteBE64, "SDL_WriteBE64"); + lib.bindSymbol(cast(void**)&SDL_CreateShapedWindow, "SDL_CreateShapedWindow"); + lib.bindSymbol(cast(void**)&SDL_IsShapedWindow, "SDL_IsShapedWindow"); + lib.bindSymbol(cast(void**)&SDL_SetWindowShape, "SDL_SetWindowShape"); + lib.bindSymbol(cast(void**)&SDL_GetShapedWindowMode, "SDL_GetShapedWindowMode"); + lib.bindSymbol(cast(void**)&SDL_free, "SDL_free"); + lib.bindSymbol(cast(void**)&SDL_CreateRGBSurface, "SDL_CreateRGBSurface"); + lib.bindSymbol(cast(void**)&SDL_CreateRGBSurfaceFrom, "SDL_CreateRGBSurfaceFrom"); + lib.bindSymbol(cast(void**)&SDL_FreeSurface, "SDL_FreeSurface"); + lib.bindSymbol(cast(void**)&SDL_SetSurfacePalette, "SDL_SetSurfacePalette"); + lib.bindSymbol(cast(void**)&SDL_LockSurface, "SDL_LockSurface"); + lib.bindSymbol(cast(void**)&SDL_UnlockSurface, "SDL_UnlockSurface"); + lib.bindSymbol(cast(void**)&SDL_LoadBMP_RW, "SDL_LoadBMP_RW"); + lib.bindSymbol(cast(void**)&SDL_SaveBMP_RW, "SDL_SaveBMP_RW"); + lib.bindSymbol(cast(void**)&SDL_SetSurfaceRLE, "SDL_SetSurfaceRLE"); + lib.bindSymbol(cast(void**)&SDL_SetColorKey, "SDL_SetColorKey"); + lib.bindSymbol(cast(void**)&SDL_GetColorKey, "SDL_GetColorKey"); + lib.bindSymbol(cast(void**)&SDL_SetSurfaceColorMod, "SDL_SetSurfaceColorMod"); + lib.bindSymbol(cast(void**)&SDL_GetSurfaceColorMod, "SDL_GetSurfaceColorMod"); + lib.bindSymbol(cast(void**)&SDL_SetSurfaceAlphaMod, "SDL_SetSurfaceAlphaMod"); + lib.bindSymbol(cast(void**)&SDL_GetSurfaceAlphaMod, "SDL_GetSurfaceAlphaMod"); + lib.bindSymbol(cast(void**)&SDL_SetSurfaceBlendMode, "SDL_SetSurfaceBlendMode"); + lib.bindSymbol(cast(void**)&SDL_GetSurfaceBlendMode, "SDL_GetSurfaceBlendMode"); + lib.bindSymbol(cast(void**)&SDL_SetClipRect, "SDL_SetClipRect"); + lib.bindSymbol(cast(void**)&SDL_GetClipRect, "SDL_GetClipRect"); + lib.bindSymbol(cast(void**)&SDL_ConvertSurface, "SDL_ConvertSurface"); + lib.bindSymbol(cast(void**)&SDL_ConvertSurfaceFormat, "SDL_ConvertSurfaceFormat"); + lib.bindSymbol(cast(void**)&SDL_ConvertPixels, "SDL_ConvertPixels"); + lib.bindSymbol(cast(void**)&SDL_FillRect, "SDL_FillRect"); + lib.bindSymbol(cast(void**)&SDL_FillRects, "SDL_FillRects"); + lib.bindSymbol(cast(void**)&SDL_UpperBlit, "SDL_UpperBlit"); + lib.bindSymbol(cast(void**)&SDL_LowerBlit, "SDL_LowerBlit"); + lib.bindSymbol(cast(void**)&SDL_SoftStretch, "SDL_SoftStretch"); + lib.bindSymbol(cast(void**)&SDL_UpperBlitScaled, "SDL_UpperBlitScaled"); + lib.bindSymbol(cast(void**)&SDL_LowerBlitScaled, "SDL_LowerBlitScaled"); + version(Android) { + lib.bindSymbol(cast(void**)&SDL_AndroidGetJNIEnv, "SDL_AndroidGetJNIEnv"); + lib.bindSymbol(cast(void**)&SDL_AndroidGetActivity, "SDL_AndroidGetActivity"); + + lib.bindSymbol(cast(void**)&SDL_AndroidGetInternalStoragePath, "SDL_AndroidGetInternalStoragePath"); + lib.bindSymbol(cast(void**)&SDL_AndroidGetInternalStorageState, "SDL_AndroidGetInternalStorageState"); + lib.bindSymbol(cast(void**)&SDL_AndroidGetExternalStoragePath, "SDL_AndroidGetExternalStoragePath"); + } + + lib.bindSymbol(cast(void**)&SDL_GetWindowWMInfo, "SDL_GetWindowWMInfo"); + lib.bindSymbol(cast(void**)&SDL_GetTicks, "SDL_GetTicks"); + lib.bindSymbol(cast(void**)&SDL_GetPerformanceCounter, "SDL_GetPerformanceCounter"); + lib.bindSymbol(cast(void**)&SDL_GetPerformanceFrequency, "SDL_GetPerformanceFrequency"); + lib.bindSymbol(cast(void**)&SDL_Delay, "SDL_Delay"); + lib.bindSymbol(cast(void**)&SDL_AddTimer, "SDL_AddTimer"); + lib.bindSymbol(cast(void**)&SDL_RemoveTimer, "SDL_RemoveTimer"); + lib.bindSymbol(cast(void**)&SDL_GetNumTouchDevices, "SDL_GetNumTouchDevices"); + lib.bindSymbol(cast(void**)&SDL_GetTouchDevice, "SDL_GetTouchDevice"); + lib.bindSymbol(cast(void**)&SDL_GetNumTouchFingers, "SDL_GetNumTouchFingers"); + lib.bindSymbol(cast(void**)&SDL_GetTouchFinger, "SDL_GetTouchFinger"); + lib.bindSymbol(cast(void**)&SDL_GetVersion, "SDL_GetVersion"); + lib.bindSymbol(cast(void**)&SDL_GetRevision, "SDL_GetRevision"); + lib.bindSymbol(cast(void**)&SDL_GetRevisionNumber, "SDL_GetRevisionNumber"); + lib.bindSymbol(cast(void**)&SDL_GetNumVideoDrivers, "SDL_GetNumVideoDrivers"); + lib.bindSymbol(cast(void**)&SDL_GetVideoDriver, "SDL_GetVideoDriver"); + lib.bindSymbol(cast(void**)&SDL_VideoInit, "SDL_VideoInit"); + lib.bindSymbol(cast(void**)&SDL_VideoQuit, "SDL_VideoQuit"); + lib.bindSymbol(cast(void**)&SDL_GetCurrentVideoDriver, "SDL_GetCurrentVideoDriver"); + lib.bindSymbol(cast(void**)&SDL_GetNumVideoDisplays, "SDL_GetNumVideoDisplays"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayName, "SDL_GetDisplayName"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayBounds, "SDL_GetDisplayBounds"); + lib.bindSymbol(cast(void**)&SDL_GetNumDisplayModes, "SDL_GetNumDisplayModes"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayMode, "SDL_GetDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetDesktopDisplayMode, "SDL_GetDesktopDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetCurrentDisplayMode, "SDL_GetCurrentDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetClosestDisplayMode, "SDL_GetClosestDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetWindowDisplayIndex, "SDL_GetWindowDisplayIndex"); + lib.bindSymbol(cast(void**)&SDL_SetWindowDisplayMode, "SDL_SetWindowDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetWindowDisplayMode, "SDL_GetWindowDisplayMode"); + lib.bindSymbol(cast(void**)&SDL_GetWindowPixelFormat, "SDL_GetWindowPixelFormat"); + lib.bindSymbol(cast(void**)&SDL_CreateWindow, "SDL_CreateWindow"); + lib.bindSymbol(cast(void**)&SDL_CreateWindowFrom, "SDL_CreateWindowFrom"); + lib.bindSymbol(cast(void**)&SDL_GetWindowID, "SDL_GetWindowID"); + lib.bindSymbol(cast(void**)&SDL_GetWindowFromID, "SDL_GetWindowFromID"); + lib.bindSymbol(cast(void**)&SDL_GetWindowFlags, "SDL_GetWindowFlags"); + lib.bindSymbol(cast(void**)&SDL_SetWindowTitle, "SDL_SetWindowTitle"); + lib.bindSymbol(cast(void**)&SDL_GetWindowTitle, "SDL_GetWindowTitle"); + lib.bindSymbol(cast(void**)&SDL_SetWindowIcon, "SDL_SetWindowIcon"); + lib.bindSymbol(cast(void**)&SDL_SetWindowData, "SDL_SetWindowData"); + lib.bindSymbol(cast(void**)&SDL_GetWindowData, "SDL_GetWindowData"); + lib.bindSymbol(cast(void**)&SDL_SetWindowPosition, "SDL_SetWindowPosition"); + lib.bindSymbol(cast(void**)&SDL_GetWindowPosition, "SDL_GetWindowPosition"); + lib.bindSymbol(cast(void**)&SDL_SetWindowSize, "SDL_SetWindowSize"); + lib.bindSymbol(cast(void**)&SDL_GetWindowSize, "SDL_GetWindowSize"); + lib.bindSymbol(cast(void**)&SDL_SetWindowMinimumSize, "SDL_SetWindowMinimumSize"); + lib.bindSymbol(cast(void**)&SDL_GetWindowMinimumSize, "SDL_GetWindowMinimumSize"); + lib.bindSymbol(cast(void**)&SDL_SetWindowMaximumSize, "SDL_SetWindowMaximumSize"); + lib.bindSymbol(cast(void**)&SDL_GetWindowMaximumSize, "SDL_GetWindowMaximumSize"); + lib.bindSymbol(cast(void**)&SDL_SetWindowBordered, "SDL_SetWindowBordered"); + lib.bindSymbol(cast(void**)&SDL_ShowWindow, "SDL_ShowWindow"); + lib.bindSymbol(cast(void**)&SDL_HideWindow, "SDL_HideWindow"); + lib.bindSymbol(cast(void**)&SDL_RaiseWindow, "SDL_RaiseWindow"); + lib.bindSymbol(cast(void**)&SDL_MaximizeWindow, "SDL_MaximizeWindow"); + lib.bindSymbol(cast(void**)&SDL_MinimizeWindow, "SDL_MinimizeWindow"); + lib.bindSymbol(cast(void**)&SDL_RestoreWindow, "SDL_RestoreWindow"); + lib.bindSymbol(cast(void**)&SDL_SetWindowFullscreen, "SDL_SetWindowFullscreen"); + lib.bindSymbol(cast(void**)&SDL_GetWindowSurface, "SDL_GetWindowSurface"); + lib.bindSymbol(cast(void**)&SDL_UpdateWindowSurface, "SDL_UpdateWindowSurface"); + lib.bindSymbol(cast(void**)&SDL_UpdateWindowSurfaceRects, "SDL_UpdateWindowSurfaceRects"); + lib.bindSymbol(cast(void**)&SDL_SetWindowGrab, "SDL_SetWindowGrab"); + lib.bindSymbol(cast(void**)&SDL_GetWindowGrab, "SDL_GetWindowGrab"); + lib.bindSymbol(cast(void**)&SDL_SetWindowBrightness, "SDL_SetWindowBrightness"); + lib.bindSymbol(cast(void**)&SDL_GetWindowBrightness, "SDL_GetWindowBrightness"); + lib.bindSymbol(cast(void**)&SDL_SetWindowGammaRamp, "SDL_SetWindowGammaRamp"); + lib.bindSymbol(cast(void**)&SDL_GetWindowGammaRamp, "SDL_GetWindowGammaRamp"); + lib.bindSymbol(cast(void**)&SDL_DestroyWindow, "SDL_DestroyWindow"); + lib.bindSymbol(cast(void**)&SDL_IsScreenSaverEnabled, "SDL_IsScreenSaverEnabled"); + lib.bindSymbol(cast(void**)&SDL_EnableScreenSaver, "SDL_EnableScreenSaver"); + lib.bindSymbol(cast(void**)&SDL_DisableScreenSaver, "SDL_DisableScreenSaver"); + lib.bindSymbol(cast(void**)&SDL_GL_LoadLibrary, "SDL_GL_LoadLibrary"); + lib.bindSymbol(cast(void**)&SDL_GL_GetProcAddress, "SDL_GL_GetProcAddress"); + lib.bindSymbol(cast(void**)&SDL_GL_UnloadLibrary, "SDL_GL_UnloadLibrary"); + lib.bindSymbol(cast(void**)&SDL_GL_ExtensionSupported, "SDL_GL_ExtensionSupported"); + lib.bindSymbol(cast(void**)&SDL_GL_SetAttribute, "SDL_GL_SetAttribute"); + lib.bindSymbol(cast(void**)&SDL_GL_GetAttribute, "SDL_GL_GetAttribute"); + lib.bindSymbol(cast(void**)&SDL_GL_CreateContext, "SDL_GL_CreateContext"); + lib.bindSymbol(cast(void**)&SDL_GL_MakeCurrent, "SDL_GL_MakeCurrent"); + lib.bindSymbol(cast(void**)&SDL_GL_GetCurrentWindow, "SDL_GL_GetCurrentWindow"); + lib.bindSymbol(cast(void**)&SDL_GL_GetCurrentContext, "SDL_GL_GetCurrentContext"); + lib.bindSymbol(cast(void**)&SDL_GL_SetSwapInterval, "SDL_GL_SetSwapInterval"); + lib.bindSymbol(cast(void**)&SDL_GL_GetSwapInterval, "SDL_GL_GetSwapInterval"); + lib.bindSymbol(cast(void**)&SDL_GL_SwapWindow, "SDL_GL_SwapWindow"); + lib.bindSymbol(cast(void**)&SDL_GL_DeleteContext, "SDL_GL_DeleteContext"); + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl200; + + static if(sdlSupport >= SDLSupport.sdl201) { + lib.bindSymbol(cast(void**)&SDL_GetSystemRAM, "SDL_GetSystemRAM"); + lib.bindSymbol(cast(void**)&SDL_GetBasePath, "SDL_GetBasePath"); + lib.bindSymbol(cast(void**)&SDL_GetPrefPath, "SDL_GetPrefPath"); + lib.bindSymbol(cast(void**)&SDL_UpdateYUVTexture, "SDL_UpdateYUVTexture"); + lib.bindSymbol(cast(void**)&SDL_GL_GetDrawableSize, "SDL_GL_GetDrawableSize"); + + version(Windows) { + lib.bindSymbol(cast(void**)&SDL_Direct3D9GetAdapterIndex, "SDL_Direct3D9GetAdapterIndex") ; + lib.bindSymbol(cast(void**)&SDL_RenderGetD3D9Device, "SDL_RenderGetD3D9Device"); + } + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl201; + } + + static if(sdlSupport >= SDLSupport.sdl202) { + lib.bindSymbol(cast(void**)&SDL_GetDefaultAssertionHandler, "SDL_GetDefaultAssertionHandler"); + lib.bindSymbol(cast(void**)&SDL_GetAssertionHandler, "SDL_GetAssertionHandler"); + lib.bindSymbol(cast(void**)&SDL_HasAVX, "SDL_HasAVX"); + lib.bindSymbol(cast(void**)&SDL_GameControllerAddMappingsFromRW, "SDL_GameControllerAddMappingsFromRW"); + lib.bindSymbol(cast(void**)&SDL_GL_ResetAttributes, "SDL_GL_ResetAttributes"); + + version(Windows) { + lib.bindSymbol(cast(void**)&SDL_DXGIGetOutputInfo, "SDL_DXGIGetOutputInfo"); + } + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl202; + } + + static if(sdlSupport >= SDLSupport.sdl203) { + loadedVersion = SDLSupport.sdl203; + } + + static if(sdlSupport >= SDLSupport.sdl204) { + lib.bindSymbol(cast(void**)&SDL_ClearQueuedAudio, "SDL_ClearQueuedAudio"); + lib.bindSymbol(cast(void**)&SDL_GetQueuedAudioSize, "SDL_GetQueuedAudioSize"); + lib.bindSymbol(cast(void**)&SDL_QueueAudio, "SDL_QueueAudio"); + lib.bindSymbol(cast(void**)&SDL_HasAVX2, "SDL_HasAVX2"); + lib.bindSymbol(cast(void**)&SDL_GameControllerFromInstanceID, "SDL_GameControllerFromInstanceID"); + lib.bindSymbol(cast(void**)&SDL_JoystickCurrentPowerLevel, "SDL_JoystickCurrentPowerLevel"); + lib.bindSymbol(cast(void**)&SDL_JoystickFromInstanceID, "SDL_JoystickFromInstanceID"); + lib.bindSymbol(cast(void**)&SDL_CaptureMouse, "SDL_CaptureMouse"); + lib.bindSymbol(cast(void**)&SDL_GetGlobalMouseState, "SDL_GetGlobalMouseState"); + lib.bindSymbol(cast(void**)&SDL_WarpMouseGlobal, "SDL_WarpMouseGlobal"); + lib.bindSymbol(cast(void**)&SDL_RenderIsClipEnabled, "SDL_RenderIsClipEnabled"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayDPI, "SDL_GetDisplayDPI"); + lib.bindSymbol(cast(void**)&SDL_GetGrabbedWindow, "SDL_GetGrabbedWindow"); + lib.bindSymbol(cast(void**)&SDL_SetWindowHitTest, "SDL_SetWindowHitTest"); + + version(Windows) { + lib.bindSymbol(cast(void**)&SDL_SetWindowsMessageHook, "SDL_SetWindowsMessageHook"); + } + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl204; + } + + static if(sdlSupport >= SDLSupport.sdl205) { + lib.bindSymbol(cast(void**)&SDL_DequeueAudio, "SDL_DequeueAudio"); + lib.bindSymbol(cast(void**)&SDL_GetHintBoolean, "SDL_GetHintBoolean"); + lib.bindSymbol(cast(void**)&SDL_RenderGetIntegerScale, "SDL_RenderGetIntegerScale"); + lib.bindSymbol(cast(void**)&SDL_RenderSetIntegerScale, "SDL_RenderSetIntegerScale"); + lib.bindSymbol(cast(void**)&SDL_CreateRGBSurfaceWithFormat, "SDL_CreateRGBSurfaceWithFormat"); + lib.bindSymbol(cast(void**)&SDL_CreateRGBSurfaceWithFormatFrom, "SDL_CreateRGBSurfaceWithFormatFrom"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayUsableBounds, "SDL_GetDisplayUsableBounds"); + lib.bindSymbol(cast(void**)&SDL_GetWindowBordersSize, "SDL_GetWindowBordersSize"); + lib.bindSymbol(cast(void**)&SDL_GetWindowOpacity, "SDL_GetWindowOpacity"); + lib.bindSymbol(cast(void**)&SDL_SetWindowInputFocus, "SDL_SetWindowInputFocus"); + lib.bindSymbol(cast(void**)&SDL_SetWindowModalFor, "SDL_SetWindowModalFor"); + lib.bindSymbol(cast(void**)&SDL_SetWindowOpacity, "SDL_SetWindowOpacity"); + lib.bindSymbol(cast(void**)&SDL_SetWindowResizable, "SDL_SetWindowResizable"); + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl205; + } + + static if(sdlSupport >= SDLSupport.sdl206) { + lib.bindSymbol(cast(void**)&SDL_ComposeCustomBlendMode, "SDL_ComposeCustomBlendMode"); + lib.bindSymbol(cast(void**)&SDL_HasNEON, "SDL_HasNEON"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetVendor, "SDL_GameControllerGetVendor"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetProduct, "SDL_GameControllerGetProduct"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetProductVersion, "SDL_GameControllerGetProductVersion"); + lib.bindSymbol(cast(void**)&SDL_GameControllerMappingForIndex, "SDL_GameControllerMappingForIndex"); + lib.bindSymbol(cast(void**)&SDL_GameControllerNumMappings, "SDL_GameControllerNumMappings"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetAxisInitialState, "SDL_JoystickGetAxisInitialState"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceVendor, "SDL_JoystickGetDeviceVendor"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceProduct, "SDL_JoystickGetDeviceProduct"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceProductVersion, "SDL_JoystickGetDeviceProductVersion"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceInstanceID, "SDL_JoystickGetDeviceInstanceID"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceType, "SDL_JoystickGetDeviceType"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetProduct, "SDL_JoystickGetProduct"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetProductVersion, "SDL_JoystickGetProductVersion"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetType, "SDL_JoystickGetType"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetVendor, "SDL_JoystickGetVendor"); + lib.bindSymbol(cast(void**)&SDL_LoadFile_RW, "SDL_LoadFile_RW"); + lib.bindSymbol(cast(void**)&SDL_DuplicateSurface, "SDL_DuplicateSurface"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_CreateSurface, "SDL_Vulkan_CreateSurface"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetDrawableSize, "SDL_Vulkan_GetDrawableSize"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetInstanceExtensions, "SDL_Vulkan_GetInstanceExtensions"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetVkGetInstanceProcAddr, "SDL_Vulkan_GetVkGetInstanceProcAddr"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_LoadLibrary, "SDL_Vulkan_LoadLibrary"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_UnloadLibrary, "SDL_Vulkan_UnloadLibrary"); + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl206; + } + + static if(sdlSupport >= SDLSupport.sdl207) { + lib.bindSymbol(cast(void**)&SDL_NewAudioStream, "SDL_NewAudioStream"); + lib.bindSymbol(cast(void**)&SDL_AudioStreamPut, "SDL_AudioStreamPut"); + lib.bindSymbol(cast(void**)&SDL_AudioStreamGet, "SDL_AudioStreamGet"); + lib.bindSymbol(cast(void**)&SDL_AudioStreamAvailable, "SDL_AudioStreamAvailable"); + lib.bindSymbol(cast(void**)&SDL_AudioStreamFlush, "SDL_AudioStreamFlush"); + lib.bindSymbol(cast(void**)&SDL_AudioStreamClear, "SDL_AudioStreamClear"); + lib.bindSymbol(cast(void**)&SDL_FreeAudioStream, "SDL_FreeAudioStream"); + lib.bindSymbol(cast(void**)&SDL_LockJoysticks, "SDL_LockJoysticks"); + lib.bindSymbol(cast(void**)&SDL_UnlockJoysticks, "SDL_UnlockJoysticks"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceProduct, "SDL_JoystickGetDeviceProduct"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceProductVersion, "SDL_JoystickGetDeviceProductVersion"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceInstanceID, "SDL_JoystickGetDeviceInstanceID"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDeviceType, "SDL_JoystickGetDeviceType"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetProduct, "SDL_JoystickGetProduct"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetProductVersion, "SDL_JoystickGetProductVersion"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetType, "SDL_JoystickGetType"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetVendor, "SDL_JoystickGetVendor"); + lib.bindSymbol(cast(void**)&SDL_LoadFile_RW, "SDL_LoadFile_RW"); + lib.bindSymbol(cast(void**)&SDL_DuplicateSurface, "SDL_DuplicateSurface"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_CreateSurface, "SDL_Vulkan_CreateSurface"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetDrawableSize, "SDL_Vulkan_GetDrawableSize"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetInstanceExtensions, "SDL_Vulkan_GetInstanceExtensions"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_GetVkGetInstanceProcAddr, "SDL_Vulkan_GetVkGetInstanceProcAddr"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_LoadLibrary, "SDL_Vulkan_LoadLibrary"); + lib.bindSymbol(cast(void**)&SDL_Vulkan_UnloadLibrary, "SDL_Vulkan_UnloadLibrary"); + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl207; + } + + static if(sdlSupport >= SDLSupport.sdl208) { + lib.bindSymbol(cast(void**)&SDL_RenderGetMetalLayer, "SDL_RenderGetMetalLayer"); + lib.bindSymbol(cast(void**)&SDL_RenderGetMetalCommandEncoder, "SDL_RenderGetMetalCommandEncoder"); + lib.bindSymbol(cast(void**)&SDL_SetYUVConversionMode, "SDL_SetYUVConversionMode"); + lib.bindSymbol(cast(void**)&SDL_GetYUVConversionMode, "SDL_GetYUVConversionMode"); + lib.bindSymbol(cast(void**)&SDL_GetYUVConversionModeForResolution, "SDL_GetYUVConversionModeForResolution"); + + version(Android) { + lib.bindSymbol(cast(void**)&SDL_IsAndroidTV, "SDL_IsAndroidTV"); + } + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl208; + } + + static if(sdlSupport >= SDLSupport.sdl209) { + lib.bindSymbol(cast(void**)&SDL_HasAVX512F, "SDL_HasAVX512F"); + lib.bindSymbol(cast(void**)&SDL_GameControllerMappingForDeviceIndex, "SDL_GameControllerMappingForDeviceIndex"); + lib.bindSymbol(cast(void**)&SDL_GameControllerRumble, "SDL_GameControllerRumble"); + lib.bindSymbol(cast(void**)&SDL_JoystickRumble, "SDL_JoystickRumble"); + lib.bindSymbol(cast(void**)&SDL_HasColorKey, "SDL_HasColorKey"); + lib.bindSymbol(cast(void**)&SDL_GetDisplayOrientation, "SDL_GetDisplayOrientation"); + + version(linux) { + lib.bindSymbol(cast(void**)&SDL_LinuxSetThreadPriority, "SDL_LinuxSetThreadPriority"); + } + else version(Android) { + lib.bindSymbol(cast(void**)&SDL_IsChromebook, "SDL_IsChromebook"); + lib.bindSymbol(cast(void**)&SDL_IsDeXMode, "SDL_IsDeXMode"); + lib.bindSymbol(cast(void**)&SDL_AndroidBackButton, "SDL_AndroidBackButton"); + } + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl209; + } + + static if(sdlSupport >= SDLSupport.sdl2010) { + lib.bindSymbol(cast(void**)&SDL_SIMDGetAlignment, "SDL_SIMDGetAlignment"); + lib.bindSymbol(cast(void**)&SDL_SIMDAlloc, "SDL_SIMDAlloc"); + lib.bindSymbol(cast(void**)&SDL_SIMDFree, "SDL_SIMDFree"); + lib.bindSymbol(cast(void**)&SDL_GameControllerGetPlayerIndex, "SDL_GameControllerGetPlayerIndex"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetDevicePlayerIndex, "SDL_JoystickGetDevicePlayerIndex"); + lib.bindSymbol(cast(void**)&SDL_JoystickGetPlayerIndex, "SDL_JoystickGetPlayerIndex"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawPointF, "SDL_RenderDrawPointF"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawPointsF, "SDL_RenderDrawPointsF"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawLineF, "SDL_RenderDrawLineF"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawLinesF, "SDL_RenderDrawLinesF"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawRectF, "SDL_RenderDrawRectF"); + lib.bindSymbol(cast(void**)&SDL_RenderDrawRectsF, "SDL_RenderDrawRectsF"); + lib.bindSymbol(cast(void**)&SDL_RenderFillRectF, "SDL_RenderFillRectF"); + lib.bindSymbol(cast(void**)&SDL_RenderFillRectsF, "SDL_RenderFillRectsF"); + lib.bindSymbol(cast(void**)&SDL_RenderCopyF, "SDL_RenderCopyF"); + lib.bindSymbol(cast(void**)&SDL_RenderCopyExF, "SDL_RenderCopyExF"); + lib.bindSymbol(cast(void**)&SDL_RenderFlush, "SDL_RenderFlush");lib.bindSymbol(cast(void**)&SDL_Vulkan_CreateSurface, "SDL_Vulkan_CreateSurface"); + lib.bindSymbol(cast(void**)&SDL_RWsize, "SDL_RWsize"); + lib.bindSymbol(cast(void**)&SDL_RWseek, "SDL_RWseek"); + lib.bindSymbol(cast(void**)&SDL_RWtell, "SDL_RWtell"); + lib.bindSymbol(cast(void**)&SDL_RWread, "SDL_RWread"); + lib.bindSymbol(cast(void**)&SDL_RWwrite, "SDL_RWwrite"); + lib.bindSymbol(cast(void**)&SDL_RWclose, "SDL_RWclose"); + lib.bindSymbol(cast(void**)&SDL_GetTouchDeviceType, "SDL_GetTouchDeviceType"); + + + if(errorCount() != errCount) return SDLSupport.badLibrary; + else loadedVersion = SDLSupport.sdl2010; + } + + return loadedVersion; +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/image.d b/demos/external/imports/bindbc/sdl/image.d new file mode 100644 index 0000000..8cf160e --- /dev/null +++ b/demos/external/imports/bindbc/sdl/image.d @@ -0,0 +1,353 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.image; + +version(BindSDL_Image): + +import bindbc.sdl.bind.sdlerror : SDL_GetError, SDL_SetError; +import bindbc.sdl.bind.sdlrender : SDL_Renderer, SDL_Texture; +import bindbc.sdl.bind.sdlrwops : SDL_RWops; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; +import bindbc.sdl.bind.sdlversion : SDL_version, SDL_VERSIONNUM; + +alias IMG_SetError = SDL_SetError; +alias IMG_GetError = SDL_GetError; + +enum SDLImageSupport { + noLibrary, + badLibrary, + sdlImage200 = 200, + sdlImage201, + sdlImage202, +} + +enum ubyte SDL_IMAGE_MAJOR_VERSION = 2; +enum ubyte SDL_IMAGE_MINOR_VERSION = 0; + +version(SDL_Image_202) { + enum sdlImageSupport = SDLImageSupport.sdlImage202; + enum ubyte SDL_IMAGE_PATCHLEVEL = 2; +} +else version(SDL_Image_201) { + enum sdlImageSupport = SDLImageSupport.sdlImage201; + enum ubyte SDL_IMAGE_PATCHLEVEL = 1; +} +else { + enum sdlImageSupport = SDLImageSupport.sdlImage200; + enum ubyte SDL_IMAGE_PATCHLEVEL = 0; +} + +@nogc nothrow void SDL_IMAGE_VERSION(SDL_version* X) +{ + X.major = SDL_IMAGE_MAJOR_VERSION; + X.minor = SDL_IMAGE_MINOR_VERSION; + X.patch = SDL_IMAGE_PATCHLEVEL; +} + +// These were implemented in SDL_image 2.0.2, but are fine for all versions. +enum SDL_IMAGE_COMPILEDVERSION = SDL_VERSIONNUM!(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL); +enum SDL_IMAGE_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_IMAGE_COMPILEDVERSION >= SDL_VERSIONNUM!(X, Y, Z); + +enum { + IMG_INIT_JPG = 0x00000001, + IMG_INIT_PNG = 0x00000002, + IMG_INIT_TIF = 0x00000004, + IMG_INIT_WEBP = 0x00000008, +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + int IMG_Init(int); + int IMG_Quit(); + const(SDL_version)* IMG_Linked_Version(); + SDL_Surface* IMG_LoadTyped_RW(SDL_RWops*,int,const(char)*); + SDL_Surface* IMG_Load(const(char)*); + SDL_Surface* IMG_Load_RW(SDL_RWops*,int); + + SDL_Texture* IMG_LoadTexture(SDL_Renderer*,const(char)*); + SDL_Texture* IMG_LoadTexture_RW(SDL_Renderer*,SDL_RWops*,int); + SDL_Texture* IMG_LoadTextureTyped_RW(SDL_Renderer*,SDL_RWops*,int,const(char)*); + + int IMG_isICO(SDL_RWops*); + int IMG_isCUR(SDL_RWops*); + int IMG_isBMP(SDL_RWops*); + int IMG_isGIF(SDL_RWops*); + int IMG_isJPG(SDL_RWops*); + int IMG_isLBM(SDL_RWops*); + int IMG_isPCX(SDL_RWops*); + int IMG_isPNG(SDL_RWops*); + int IMG_isPNM(SDL_RWops*); + int IMG_isTIF(SDL_RWops*); + int IMG_isXCF(SDL_RWops*); + int IMG_isXPM(SDL_RWops*); + int IMG_isXV(SDL_RWops*); + int IMG_isWEBP(SDL_RWops*); + + SDL_Surface* IMG_LoadICO_RW(SDL_RWops*); + SDL_Surface* IMG_LoadCUR_RW(SDL_RWops*); + SDL_Surface* IMG_LoadBMP_RW(SDL_RWops*); + SDL_Surface* IMG_LoadGIF_RW(SDL_RWops*); + SDL_Surface* IMG_LoadJPG_RW(SDL_RWops*); + SDL_Surface* IMG_LoadLBM_RW(SDL_RWops*); + SDL_Surface* IMG_LoadPCX_RW(SDL_RWops*); + SDL_Surface* IMG_LoadPNG_RW(SDL_RWops*); + SDL_Surface* IMG_LoadPNM_RW(SDL_RWops*); + SDL_Surface* IMG_LoadTGA_RW(SDL_RWops*); + SDL_Surface* IMG_LoadTIF_RW(SDL_RWops*); + SDL_Surface* IMG_LoadXCF_RW(SDL_RWops*); + SDL_Surface* IMG_LoadXPM_RW(SDL_RWops*); + SDL_Surface* IMG_LoadXV_RW(SDL_RWops*); + SDL_Surface* IMG_LoadWEBP_RW(SDL_RWops*); + + SDL_Surface* IMG_ReadXPMFromArray(char**); + + int IMG_SavePNG(SDL_Surface*,const(char)*); + int IMG_SavePNG_RW(SDL_Surface*,SDL_RWops*,int); + + static if(sdlImageSupport >= SDLImageSupport.sdlImage202) { + int IMG_isSVG(SDL_RWops*); + SDL_Surface* IMG_LoadSVG(SDL_RWops*); + int IMG_SaveJPG(SDL_Surface*,const(char)*,int); + int IMG_SaveJPG_RW(SDL_Surface*,SDL_RWops*,int,int); + } + } +} +else { + import bindbc.loader; + + extern(C) @nogc nothrow { + alias pIMG_Init = int function(int); + alias pIMG_Quit = int function(); + alias pIMG_Linked_Version = const(SDL_version)* function(); + alias pIMG_LoadTyped_RW = SDL_Surface* function(SDL_RWops*,int,const(char)*); + alias pIMG_Load = SDL_Surface* function(const(char)*); + alias pIMG_Load_RW = SDL_Surface* function(SDL_RWops*,int); + + alias pIMG_LoadTexture = SDL_Texture* function(SDL_Renderer*,const(char)*); + alias pIMG_LoadTexture_RW = SDL_Texture* function(SDL_Renderer*,SDL_RWops*,int); + alias pIMG_LoadTextureTyped_RW = SDL_Texture* function(SDL_Renderer*,SDL_RWops*,int,const(char)*); + + alias pIMG_isICO = int function(SDL_RWops*); + alias pIMG_isCUR = int function(SDL_RWops*); + alias pIMG_isBMP = int function(SDL_RWops*); + alias pIMG_isGIF = int function(SDL_RWops*); + alias pIMG_isJPG = int function(SDL_RWops*); + alias pIMG_isLBM = int function(SDL_RWops*); + alias pIMG_isPCX = int function(SDL_RWops*); + alias pIMG_isPNG = int function(SDL_RWops*); + alias pIMG_isPNM = int function(SDL_RWops*); + alias pIMG_isTIF = int function(SDL_RWops*); + alias pIMG_isXCF = int function(SDL_RWops*); + alias pIMG_isXPM = int function(SDL_RWops*); + alias pIMG_isXV = int function(SDL_RWops*); + alias pIMG_isWEBP = int function(SDL_RWops*); + + alias pIMG_LoadICO_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadCUR_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadBMP_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadGIF_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadJPG_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadLBM_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadPCX_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadPNG_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadPNM_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadTGA_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadTIF_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadXCF_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadXPM_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadXV_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_LoadWEBP_RW = SDL_Surface* function(SDL_RWops*); + + alias pIMG_ReadXPMFromArray = SDL_Surface* function(char**); + + alias pIMG_SavePNG = int function(SDL_Surface*,const(char)*); + alias pIMG_SavePNG_RW = int function(SDL_Surface*,SDL_RWops*,int); + } + + __gshared { + pIMG_Init IMG_Init; + pIMG_Quit IMG_Quit; + pIMG_Linked_Version IMG_Linked_Version; + pIMG_LoadTyped_RW IMG_LoadTyped_RW; + pIMG_Load IMG_Load; + pIMG_Load_RW IMG_Load_RW; + pIMG_LoadTexture IMG_LoadTexture; + pIMG_LoadTexture_RW IMG_LoadTexture_RW; + pIMG_LoadTextureTyped_RW IMG_LoadTextureTyped_RW; + pIMG_isICO IMG_isICO; + pIMG_isCUR IMG_isCUR; + pIMG_isBMP IMG_isBMP; + pIMG_isGIF IMG_isGIF; + pIMG_isJPG IMG_isJPG; + pIMG_isLBM IMG_isLBM; + pIMG_isPCX IMG_isPCX; + pIMG_isPNG IMG_isPNG; + pIMG_isPNM IMG_isPNM; + pIMG_isTIF IMG_isTIF; + pIMG_isXCF IMG_isXCF; + pIMG_isXPM IMG_isXPM; + pIMG_isXV IMG_isXV; + pIMG_isWEBP IMG_isWEBP; + pIMG_LoadICO_RW IMG_LoadICO_RW; + pIMG_LoadCUR_RW IMG_LoadCUR_RW; + pIMG_LoadBMP_RW IMG_LoadBMP_RW; + pIMG_LoadGIF_RW IMG_LoadGIF_RW; + pIMG_LoadJPG_RW IMG_LoadJPG_RW; + pIMG_LoadLBM_RW IMG_LoadLBM_RW; + pIMG_LoadPCX_RW IMG_LoadPCX_RW; + pIMG_LoadPNG_RW IMG_LoadPNG_RW; + pIMG_LoadPNM_RW IMG_LoadPNM_RW; + pIMG_LoadTGA_RW IMG_LoadTGA_RW; + pIMG_LoadTIF_RW IMG_LoadTIF_RW; + pIMG_LoadXCF_RW IMG_LoadXCF_RW; + pIMG_LoadXPM_RW IMG_LoadXPM_RW; + pIMG_LoadXV_RW IMG_LoadXV_RW; + pIMG_LoadWEBP_RW IMG_LoadWEBP_RW; + pIMG_ReadXPMFromArray IMG_ReadXPMFromArray; + pIMG_SavePNG IMG_SavePNG; + pIMG_SavePNG_RW IMG_SavePNG_RW; + } + + static if(sdlImageSupport >= SDLImageSupport.sdlImage202) { + extern(C) @nogc nothrow { + alias pIMG_isSVG = int function(SDL_RWops*); + alias pIMG_LoadSVG_RW = SDL_Surface* function(SDL_RWops*); + alias pIMG_SaveJPG = int function(SDL_Surface*,const(char)*,int); + alias pIMG_SaveJPG_RW = int function(SDL_Surface*,SDL_RWops*,int,int); + } + + __gshared { + pIMG_isSVG IMG_isSVG; + pIMG_LoadSVG_RW IMG_LoadSVG; + pIMG_SaveJPG IMG_SaveJPG; + pIMG_SaveJPG_RW IMG_SaveJPG_RW; + } + } + + private { + SharedLib lib; + SDLImageSupport loadedVersion; + } + + void unloadSDLImage() + { + if(lib != invalidHandle) { + lib.unload(); + } + } + + SDLImageSupport loadedSDLImageVersion() { return loadedVersion; } + + bool isSDLImageLoaded() + { + return lib != invalidHandle; + } + + + SDLImageSupport loadSDLImage() + { + version(Windows) { + const(char)[][1] libNames = ["SDL2_image.dll"]; + } + else version(OSX) { + const(char)[][6] libNames = [ + "libSDL2_image.dylib", + "/usr/local/lib/libSDL2_image.dylib", + "../Frameworks/SDL2_image.framework/SDL2_image", + "/Library/Frameworks/SDL2_image.framework/SDL2_image", + "/System/Library/Frameworks/SDL2_image.framework/SDL2_image", + "/opt/local/lib/libSDL2_image.dylib" + ]; + } + else version(Posix) { + const(char)[][6] libNames = [ + "libSDL2_image.so", + "/usr/local/lib/libSDL2_image.so", + "libSDL2_image-2.0.so", + "/usr/local/lib/libSDL2_image-2.0.so", + "libSDL2_image-2.0.so.0", + "/usr/local/lib/libSDL2_image-2.0.so.0" + ]; + } + else static assert(0, "bindbc-sdl is not yet supported on this platform."); + + SDLImageSupport ret; + foreach(name; libNames) { + ret = loadSDLImage(name.ptr); + if(ret != SDLImageSupport.noLibrary) break; + } + return ret; + } + + SDLImageSupport loadSDLImage(const(char)* libName) + { + lib = load(libName); + if(lib == invalidHandle) { + return SDLImageSupport.noLibrary; + } + + auto errCount = errorCount(); + loadedVersion = SDLImageSupport.badLibrary; + + lib.bindSymbol(cast(void**)&IMG_Init,"IMG_Init"); + lib.bindSymbol(cast(void**)&IMG_Quit,"IMG_Quit"); + lib.bindSymbol(cast(void**)&IMG_Linked_Version,"IMG_Linked_Version"); + lib.bindSymbol(cast(void**)&IMG_LoadTyped_RW,"IMG_LoadTyped_RW"); + lib.bindSymbol(cast(void**)&IMG_Load,"IMG_Load"); + lib.bindSymbol(cast(void**)&IMG_Load_RW,"IMG_Load_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadTexture,"IMG_LoadTexture"); + lib.bindSymbol(cast(void**)&IMG_LoadTexture_RW,"IMG_LoadTexture_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadTextureTyped_RW,"IMG_LoadTextureTyped_RW"); + lib.bindSymbol(cast(void**)&IMG_isICO,"IMG_isICO"); + lib.bindSymbol(cast(void**)&IMG_isCUR,"IMG_isCUR"); + lib.bindSymbol(cast(void**)&IMG_isBMP,"IMG_isBMP"); + lib.bindSymbol(cast(void**)&IMG_isGIF,"IMG_isGIF"); + lib.bindSymbol(cast(void**)&IMG_isJPG,"IMG_isJPG"); + lib.bindSymbol(cast(void**)&IMG_isLBM,"IMG_isLBM"); + lib.bindSymbol(cast(void**)&IMG_isPCX,"IMG_isPCX"); + lib.bindSymbol(cast(void**)&IMG_isPNG,"IMG_isPNG"); + lib.bindSymbol(cast(void**)&IMG_isPNM,"IMG_isPNM"); + lib.bindSymbol(cast(void**)&IMG_isTIF,"IMG_isTIF"); + lib.bindSymbol(cast(void**)&IMG_isXCF,"IMG_isXCF"); + lib.bindSymbol(cast(void**)&IMG_isXPM,"IMG_isXPM"); + lib.bindSymbol(cast(void**)&IMG_isXV,"IMG_isXV"); + lib.bindSymbol(cast(void**)&IMG_isWEBP,"IMG_isWEBP"); + lib.bindSymbol(cast(void**)&IMG_LoadICO_RW,"IMG_LoadICO_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadCUR_RW,"IMG_LoadCUR_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadBMP_RW,"IMG_LoadBMP_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadGIF_RW,"IMG_LoadGIF_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadJPG_RW,"IMG_LoadJPG_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadLBM_RW,"IMG_LoadLBM_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadPCX_RW,"IMG_LoadPCX_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadPNG_RW,"IMG_LoadPNG_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadPNM_RW,"IMG_LoadPNM_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadTGA_RW,"IMG_LoadTGA_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadTIF_RW,"IMG_LoadTIF_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadXCF_RW,"IMG_LoadXCF_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadXPM_RW,"IMG_LoadXPM_RW"); + lib.bindSymbol(cast(void**)&IMG_LoadXV_RW,"IMG_LoadXV_RW"); + lib.bindSymbol(cast(void**)&IMG_isXV,"IMG_isXV"); + lib.bindSymbol(cast(void**)&IMG_LoadWEBP_RW,"IMG_LoadWEBP_RW"); + lib.bindSymbol(cast(void**)&IMG_SavePNG,"IMG_SavePNG"); + lib.bindSymbol(cast(void**)&IMG_SavePNG_RW,"IMG_SavePNG_RW"); + + if(errorCount() != errCount) return SDLImageSupport.badLibrary; + else loadedVersion = SDLImageSupport.sdlImage200; + + static if(sdlImageSupport >= SDLImageSupport.sdlImage202) { + lib.bindSymbol(cast(void**)&IMG_isSVG,"IMG_isSVG"); + lib.bindSymbol(cast(void**)&IMG_LoadSVG,"IMG_LoadSVG_RW"); + lib.bindSymbol(cast(void**)&IMG_SaveJPG,"IMG_SaveJPG"); + lib.bindSymbol(cast(void**)&IMG_SaveJPG_RW,"IMG_SaveJPG_RW"); + + if(errorCount() != errCount) return SDLImageSupport.badLibrary; + else loadedVersion = SDLImageSupport.sdlImage202; + } + + return loadedVersion; + } +} diff --git a/demos/external/imports/bindbc/sdl/mixer.d b/demos/external/imports/bindbc/sdl/mixer.d new file mode 100644 index 0000000..ed531b5 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/mixer.d @@ -0,0 +1,569 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.mixer; + +version(BindSDL_Mixer): + +import bindbc.sdl.config; +import bindbc.sdl.bind.sdlaudio : AUDIO_S16LSB, SDL_MIX_MAXVOLUME; +import bindbc.sdl.bind.sdlerror : SDL_GetError, SDL_SetError, SDL_ClearError; +import bindbc.sdl.bind.sdlrwops : SDL_RWops, SDL_RWFromFile; +import bindbc.sdl.bind.sdlstdinc : SDL_bool; +import bindbc.sdl.bind.sdlversion : SDL_version, SDL_VERSIONNUM; + +alias Mix_SetError = SDL_SetError; +alias Mix_GetError = SDL_GetError; +alias Mix_ClearError = SDL_ClearError; + +enum SDLMixerSupport { + noLibrary, + badLibrary, + sdlMixer200 = 200, + sdlMixer201 = 201, + sdlMixer202 = 202, +} + +enum ubyte SDL_MIXER_MAJOR_VERSION = 2; +enum ubyte SDL_MIXER_MINOR_VERSION = 0; + +version(SDL_Mixer_202) { + enum sdlMixerSupport = SDLMixerSupport.sdlMixer202; + enum ubyte SDL_MIXER_PATCHLEVEL = 2; +} +else version(SDL_Mixer_201) { + enum sdlMixerSupport = SDLMixerSupport.sdlMixer201; + enum ubyte SDL_MIXER_PATCHLEVEL = 1; +} +else { + enum sdlMixerSupport = SDLMixerSupport.sdlMixer200; + enum ubyte SDL_MIXER_PATCHLEVEL = 0; +} + +alias MIX_MAJOR_VERSION = SDL_MIXER_MAJOR_VERSION; +alias MIX_MINOR_VERSION = SDL_MIXER_MINOR_VERSION; +alias MIX_PATCH_LEVEL = SDL_MIXER_PATCHLEVEL; + +@nogc nothrow void SDL_MIXER_VERSION(SDL_version* X) +{ + X.major = SDL_MIXER_MAJOR_VERSION; + X.minor = SDL_MIXER_MINOR_VERSION; + X.patch = SDL_MIXER_PATCHLEVEL; +} +alias SDL_MIX_VERSION = SDL_MIX_MAXVOLUME; + +// These were implemented in SDL_mixer 2.0.2, but are fine for all versions. +enum SDL_MIXER_COMPILEDVERSION = SDL_VERSIONNUM!(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL); +enum SDL_MIXER_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM!(X, Y, Z); + +static if(sdlMixerSupport >= SDLMixerSupport.sdlMixer202) { + enum Mix_InitFlags { + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020, + } +} +else { + enum Mix_InitFlags { + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MODPLUG = 0x00000004, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_FLUIDSYNTH = 0x00000020, + } +} +mixin(expandEnum!Mix_InitFlags); + +enum { + MIX_CHANNELS = 8, + MIX_DEFAULT_FREQUENCY = 22050, + MIX_DEFAULT_CHANNELS = 2, + MIX_MAX_VOLUME = 128, + MIX_CHANNEL_POST = -2, +} + +version(LittleEndian) { + enum MIX_DEFAULT_FORMAT = AUDIO_S16LSB; +} else { + enum MIX_DEFAULT_FORMAT = AUDIO_S16MSB; +} + +struct Mix_Chunk { + int allocated; + ubyte* abuf; + uint alen; + ubyte volume; +} + +enum Mix_Fading { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} +mixin(expandEnum!Mix_Fading); + +static if(sdlMixerSupport >= SDLMixerSupport.sdlMixer202) { + enum Mix_MusicType { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD_UNUSED, + MUS_FLAC, + MUS_MODPLUG_UNUSED, + } +} +else { + enum Mix_MusicType { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD, + MUS_FLAC, + MUS_MODPLUG, + } +} +mixin(expandEnum!Mix_MusicType); + +struct Mix_Music; +enum MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"; + +extern(C) nothrow { + alias Mix_EffectFunc_t = void function(int,void*,int,void*); + alias Mix_EffectDone_t = void function(int,void*); + + // These aren't in SDL_mixer.h and are just here as a convenient and + // visible means to add the proper attributes these callbacks. + alias callbackI = void function(int); + alias callbackVUi8I = void function(void*,ubyte*,int); + alias callbackN = void function(); +} + +@nogc nothrow { + Mix_Chunk* Mix_LoadWAV(const(char)* file) { + pragma(inline, true); + return Mix_LoadWAV_RW(SDL_RWFromFile(file,"rb"),1); + } + + int Mix_PlayChannel(int channel,Mix_Chunk* chunk,int loops) { + pragma(inline, true); + return Mix_PlayChannelTimed(channel,chunk,loops,-1); + } + + int Mix_FadeInChannel(int channel,Mix_Chunk* chunk,int loops,int ms) { + pragma(inline, true); + return Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1); + } +} + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + const(SDL_version)* Mix_Linked_Version(); + int Mix_Init(int); + void Mix_Quit(); + int Mix_OpenAudio(int,ushort,int,int); + int Mix_AllocateChannels(int); + int Mix_QuerySpec(int*,ushort*,int*); + Mix_Chunk* Mix_LoadWAV_RW(SDL_RWops*,int); + Mix_Music* Mix_LoadMUS(const(char)*); + Mix_Music* Mix_LoadMUS_RW(SDL_RWops*,int); + Mix_Music* Mix_LoadMUSType_RW(SDL_RWops*,Mix_MusicType,int); + Mix_Chunk* Mix_QuickLoad_WAV(ubyte*); + Mix_Chunk* Mix_QuickLoad_RAW(ubyte*,uint); + void Mix_FreeChunk(Mix_Chunk*); + void Mix_FreeMusic(Mix_Music*); + int Mix_GetNumChunkDecoders(); + const(char)* Mix_GetChunkDecoder(int); + int Mix_GetNumMusicDecoders(); + const(char)* Mix_GetMusicDecoder(int); + Mix_MusicType Mix_GetMusicType(const(Mix_Music)*); + void Mix_SetPostMix(callbackVUi8I,void*); + void Mix_HookMusic(callbackVUi8I,void*); + void Mix_HookMusicFinished(callbackN); + void* Mix_GetMusicHookData(); + void Mix_ChannelFinished(callbackI); + int Mix_RegisterEffect(int,Mix_EffectFunc_t,Mix_EffectDone_t,void*); + int Mix_UnregisterEffect(int,Mix_EffectFunc_t); + int Mix_UnregisterAllEffects(int); + int Mix_SetPanning(int,ubyte,ubyte); + int Mix_SetPosition(int,short,ubyte); + int Mix_SetDistance(int,ubyte); + int Mix_SetReverseStereo(int,int); + int Mix_ReserveChannels(int); + int Mix_GroupChannel(int,int); + int Mix_GroupChannels(int,int,int); + int Mix_GroupAvailable(int); + int Mix_GroupCount(int); + int Mix_GroupOldest(int); + int Mix_GroupNewer(int); + int Mix_PlayChannelTimed(int,Mix_Chunk*,int,int); + int Mix_PlayMusic(Mix_Music*,int); + int Mix_FadeInMusic(Mix_Music*,int,int); + int Mix_FadeInMusicPos(Mix_Music*,int,int,double); + int Mix_FadeInChannelTimed(int,Mix_Chunk*,int,int,int); + int Mix_Volume(int,int); + int Mix_VolumeChunk(Mix_Chunk*,int); + int Mix_VolumeMusic(int); + int Mix_HaltChannel(int); + int Mix_HaltGroup(int); + int Mix_HaltMusic(); + int Mix_ExpireChannel(int,int); + int Mix_FadeOutChannel(int,int); + int Mix_FadeOutGroup(int,int); + int Mix_FadeOutMusic(int); + Mix_Fading Mix_FadingMusic(); + Mix_Fading Mix_FadingChannel(int); + void Mix_Pause(int); + void Mix_Resume(int); + int Mix_Paused(int); + void Mix_PauseMusic(); + void Mix_ResumeMusic(); + void Mix_RewindMusic(); + int Mix_PausedMusic(); + int Mix_SetMusicPosition(double); + int Mix_Playing(int); + int Mix_PlayingMusic(); + int Mix_SetMusicCMD(in char*); + int Mix_SetSynchroValue(int); + int Mix_GetSynchroValue(); + Mix_Chunk* Mix_GetChunk(int); + void Mix_CloseAudio(); + + static if(sdlMixerSupport >= SDLMixerSupport.sdlMixer202) { + int Mix_OpenAudioDevice(int,ushort,int,int,const(char)*,int); + SDL_bool Mix_HasChunkDecoder(const(char)*); + + // Declared in SDL_mixer.h, but not implemented + // SDL_bool Mix_HasMusicDecoder(const(char)*); + } + } +} +else { + import bindbc.loader; + + extern(C) @nogc nothrow { + alias pMix_Linked_Version = const(SDL_version)* function(); + alias pMix_Init = int function(int); + alias pMix_Quit = void function(); + alias pMix_OpenAudio = int function(int,ushort,int,int); + alias pMix_AllocateChannels = int function(int); + alias pMix_QuerySpec = int function(int*,ushort*,int*); + alias pMix_LoadWAV_RW = Mix_Chunk* function(SDL_RWops*,int); + alias pMix_LoadMUS = Mix_Music* function(const(char)*); + alias pMix_LoadMUS_RW = Mix_Music* function(SDL_RWops*,int); + alias pMix_LoadMUSType_RW = Mix_Music* function(SDL_RWops*,Mix_MusicType,int); + alias pMix_QuickLoad_WAV = Mix_Chunk* function(ubyte*); + alias pMix_QuickLoad_RAW = Mix_Chunk* function(ubyte*,uint); + alias pMix_FreeChunk = void function(Mix_Chunk*); + alias pMix_FreeMusic = void function(Mix_Music*); + alias pMix_GetNumChunkDecoders = int function(); + alias pMix_GetChunkDecoder = const(char)* function(int); + alias pMix_GetNumMusicDecoders = int function(); + alias pMix_GetMusicDecoder = const(char)* function(int); + alias pMix_GetMusicType = Mix_MusicType function(const(Mix_Music)*); + alias pMix_SetPostMix = void function(callbackVUi8I,void*); + alias pMix_HookMusic = void function(callbackVUi8I,void*); + alias pMix_HookMusicFinished = void function(callbackN); + alias pMix_GetMusicHookData = void* function(); + alias pMix_ChannelFinished = void function(callbackI); + alias pMix_RegisterEffect = int function(int,Mix_EffectFunc_t,Mix_EffectDone_t,void*); + alias pMix_UnregisterEffect = int function(int,Mix_EffectFunc_t); + alias pMix_UnregisterAllEffects = int function(int); + alias pMix_SetPanning = int function(int,ubyte,ubyte); + alias pMix_SetPosition = int function(int,short,ubyte); + alias pMix_SetDistance = int function(int,ubyte); + alias pMix_SetReverseStereo = int function(int,int); + alias pMix_ReserveChannels = int function(int); + alias pMix_GroupChannel = int function(int,int); + alias pMix_GroupChannels = int function(int,int,int); + alias pMix_GroupAvailable = int function(int); + alias pMix_GroupCount = int function(int); + alias pMix_GroupOldest = int function(int); + alias pMix_GroupNewer = int function(int); + alias pMix_PlayChannelTimed = int function(int,Mix_Chunk*,int,int); + alias pMix_PlayMusic = int function(Mix_Music*,int); + alias pMix_FadeInMusic = int function(Mix_Music*,int,int); + alias pMix_FadeInMusicPos = int function(Mix_Music*,int,int,double); + alias pMix_FadeInChannelTimed = int function(int,Mix_Chunk*,int,int,int); + alias pMix_Volume = int function(int,int); + alias pMix_VolumeChunk = int function(Mix_Chunk*,int); + alias pMix_VolumeMusic = int function(int); + alias pMix_HaltChannel = int function(int); + alias pMix_HaltGroup = int function(int); + alias pMix_HaltMusic = int function(); + alias pMix_ExpireChannel = int function(int,int); + alias pMix_FadeOutChannel = int function(int,int); + alias pMix_FadeOutGroup = int function(int,int); + alias pMix_FadeOutMusic = int function(int); + alias pMix_FadingMusic = Mix_Fading function(); + alias pMix_FadingChannel = Mix_Fading function(int); + alias pMix_Pause = void function(int); + alias pMix_Resume = void function(int); + alias pMix_Paused = int function(int); + alias pMix_PauseMusic = void function(); + alias pMix_ResumeMusic = void function(); + alias pMix_RewindMusic = void function(); + alias pMix_PausedMusic = int function(); + alias pMix_SetMusicPosition = int function(double); + alias pMix_Playing = int function(int); + alias pMix_PlayingMusic = int function(); + alias pMix_SetMusicCMD = int function(in char*); + alias pMix_SetSynchroValue = int function(int); + alias pMix_GetSynchroValue = int function(); + alias pMix_GetChunk = Mix_Chunk* function(int); + alias pMix_CloseAudio = void function(); + } + + __gshared { + pMix_Linked_Version Mix_Linked_Version; + pMix_Init Mix_Init; + pMix_Quit Mix_Quit; + pMix_OpenAudio Mix_OpenAudio; + pMix_AllocateChannels Mix_AllocateChannels; + pMix_QuerySpec Mix_QuerySpec; + pMix_LoadWAV_RW Mix_LoadWAV_RW; + pMix_LoadMUS Mix_LoadMUS; + pMix_LoadMUS_RW Mix_LoadMUS_RW; + pMix_LoadMUSType_RW Mix_LoadMUSType_RW; + pMix_QuickLoad_WAV Mix_QuickLoad_WAV; + pMix_QuickLoad_RAW Mix_QuickLoad_RAW; + pMix_FreeChunk Mix_FreeChunk; + pMix_FreeMusic Mix_FreeMusic; + pMix_GetNumChunkDecoders Mix_GetNumChunkDecoders; + pMix_GetChunkDecoder Mix_GetChunkDecoder; + pMix_GetNumMusicDecoders Mix_GetNumMusicDecoders; + pMix_GetMusicDecoder Mix_GetMusicDecoder; + pMix_GetMusicType Mix_GetMusicType; + pMix_SetPostMix Mix_SetPostMix; + pMix_HookMusic Mix_HookMusic; + pMix_HookMusicFinished Mix_HookMusicFinished; + pMix_GetMusicHookData Mix_GetMusicHookData; + pMix_ChannelFinished Mix_ChannelFinished; + pMix_RegisterEffect Mix_RegisterEffect; + pMix_UnregisterEffect Mix_UnregisterEffect; + pMix_UnregisterAllEffects Mix_UnregisterAllEffects; + pMix_SetPanning Mix_SetPanning; + pMix_SetPosition Mix_SetPosition; + pMix_SetDistance Mix_SetDistance; + pMix_SetReverseStereo Mix_SetReverseStereo; + pMix_ReserveChannels Mix_ReserveChannels; + pMix_GroupChannel Mix_GroupChannel; + pMix_GroupChannels Mix_GroupChannels; + pMix_GroupAvailable Mix_GroupAvailable; + pMix_GroupCount Mix_GroupCount; + pMix_GroupOldest Mix_GroupOldest; + pMix_GroupNewer Mix_GroupNewer; + pMix_PlayChannelTimed Mix_PlayChannelTimed; + pMix_PlayMusic Mix_PlayMusic; + pMix_FadeInMusic Mix_FadeInMusic; + pMix_FadeInMusicPos Mix_FadeInMusicPos; + pMix_FadeInChannelTimed Mix_FadeInChannelTimed; + pMix_Volume Mix_Volume; + pMix_VolumeChunk Mix_VolumeChunk; + pMix_VolumeMusic Mix_VolumeMusic; + pMix_HaltChannel Mix_HaltChannel; + pMix_HaltGroup Mix_HaltGroup; + pMix_HaltMusic Mix_HaltMusic; + pMix_ExpireChannel Mix_ExpireChannel; + pMix_FadeOutChannel Mix_FadeOutChannel; + pMix_FadeOutGroup Mix_FadeOutGroup; + pMix_FadeOutMusic Mix_FadeOutMusic; + pMix_FadingMusic Mix_FadingMusic; + pMix_FadingChannel Mix_FadingChannel; + pMix_Pause Mix_Pause; + pMix_Resume Mix_Resume; + pMix_Paused Mix_Paused; + pMix_PauseMusic Mix_PauseMusic; + pMix_ResumeMusic Mix_ResumeMusic; + pMix_RewindMusic Mix_RewindMusic; + pMix_PausedMusic Mix_PausedMusic; + pMix_SetMusicPosition Mix_SetMusicPosition; + pMix_Playing Mix_Playing; + pMix_PlayingMusic Mix_PlayingMusic; + pMix_SetMusicCMD Mix_SetMusicCMD; + pMix_SetSynchroValue Mix_SetSynchroValue; + pMix_GetSynchroValue Mix_GetSynchroValue; + pMix_GetChunk Mix_GetChunk; + pMix_CloseAudio Mix_CloseAudio; + } + + + static if(sdlMixerSupport >= SDLMixerSupport.sdlMixer202) { + extern(C) @nogc nothrow { + alias pMix_OpenAudioDevice = int function(int,ushort,int,int,const(char)*,int); + alias pMix_HasChunkDecoder = SDL_bool function(const(char)*); + + // Declared in SDL_mixer.h, but not implemented + //alias pMix_HasMusicDecoder = SDL_bool function(const(char)*); + } + + __gshared { + pMix_OpenAudioDevice Mix_OpenAudioDevice; + pMix_HasChunkDecoder Mix_HasChunkDecoder; + //pMix_HasMusicDecoder Mix_HasMusicDecoder; + } + } + + private { + SharedLib lib; + SDLMixerSupport loadedVersion; + } + + void unloadSDLMixer() + { + if(lib != invalidHandle) { + lib.unload(); + } + } + + SDLMixerSupport loadedSDLMixerVersion() { return loadedVersion; } + + bool isSDLMixerLoaded() + { + return lib != invalidHandle; + } + + + SDLMixerSupport loadSDLMixer() + { + version(Windows) { + const(char)[][1] libNames = ["SDL2_mixer.dll"]; + } + else version(OSX) { + const(char)[][6] libNames = [ + "libSDL2_mixer.dylib", + "/usr/local/lib/libSDL2_mixer.dylib", + "../Frameworks/SDL2_mixer.framework/SDL2_mixer", + "/Library/Frameworks/SDL2_mixer.framework/SDL2_mixer", + "/System/Library/Frameworks/SDL2_mixer.framework/SDL2_mixer", + "/opt/local/lib/libSDL2_mixer.dylib" + ]; + } + else version(Posix) { + const(char)[][6] libNames = [ + "libSDL2_mixer.so", + "/usr/local/lib/libSDL2_mixer.so", + "libSDL2-2.0_mixer.so", + "/usr/local/lib/libSDL2-2.0_mixer.so", + "libSDL2-2.0_mixer.so.0", + "/usr/local/lib/libSDL2-2.0_mixer.so.0" + ]; + } + else static assert(0, "bindbc-sdl is not yet supported on this platform."); + + SDLMixerSupport ret; + foreach(name; libNames) { + ret = loadSDLMixer(name.ptr); + if(ret != SDLMixerSupport.noLibrary) break; + } + return ret; + } + + SDLMixerSupport loadSDLMixer(const(char)* libName) + { + lib = load(libName); + if(lib == invalidHandle) { + return SDLMixerSupport.noLibrary; + } + + auto errCount = errorCount(); + loadedVersion = SDLMixerSupport.badLibrary; + + lib.bindSymbol(cast(void**)&Mix_Linked_Version,"Mix_Linked_Version"); + lib.bindSymbol(cast(void**)&Mix_Init,"Mix_Init"); + lib.bindSymbol(cast(void**)&Mix_Quit,"Mix_Quit"); + lib.bindSymbol(cast(void**)&Mix_OpenAudio,"Mix_OpenAudio"); + lib.bindSymbol(cast(void**)&Mix_AllocateChannels,"Mix_AllocateChannels"); + lib.bindSymbol(cast(void**)&Mix_QuerySpec,"Mix_QuerySpec"); + lib.bindSymbol(cast(void**)&Mix_LoadWAV_RW,"Mix_LoadWAV_RW"); + lib.bindSymbol(cast(void**)&Mix_LoadMUS,"Mix_LoadMUS"); + lib.bindSymbol(cast(void**)&Mix_LoadMUS_RW,"Mix_LoadMUS_RW"); + lib.bindSymbol(cast(void**)&Mix_LoadMUSType_RW,"Mix_LoadMUSType_RW"); + lib.bindSymbol(cast(void**)&Mix_QuickLoad_WAV,"Mix_QuickLoad_WAV"); + lib.bindSymbol(cast(void**)&Mix_QuickLoad_RAW,"Mix_QuickLoad_RAW"); + lib.bindSymbol(cast(void**)&Mix_FreeChunk,"Mix_FreeChunk"); + lib.bindSymbol(cast(void**)&Mix_FreeMusic,"Mix_FreeMusic"); + lib.bindSymbol(cast(void**)&Mix_GetNumChunkDecoders,"Mix_GetNumChunkDecoders"); + lib.bindSymbol(cast(void**)&Mix_GetChunkDecoder,"Mix_GetChunkDecoder"); + lib.bindSymbol(cast(void**)&Mix_GetNumMusicDecoders,"Mix_GetNumMusicDecoders"); + lib.bindSymbol(cast(void**)&Mix_GetMusicDecoder,"Mix_GetMusicDecoder"); + lib.bindSymbol(cast(void**)&Mix_GetMusicType,"Mix_GetMusicType"); + lib.bindSymbol(cast(void**)&Mix_SetPostMix,"Mix_SetPostMix"); + lib.bindSymbol(cast(void**)&Mix_HookMusic,"Mix_HookMusic"); + lib.bindSymbol(cast(void**)&Mix_HookMusicFinished,"Mix_HookMusicFinished"); + lib.bindSymbol(cast(void**)&Mix_GetMusicHookData,"Mix_GetMusicHookData"); + lib.bindSymbol(cast(void**)&Mix_ChannelFinished,"Mix_ChannelFinished"); + lib.bindSymbol(cast(void**)&Mix_RegisterEffect,"Mix_RegisterEffect"); + lib.bindSymbol(cast(void**)&Mix_UnregisterEffect,"Mix_UnregisterEffect"); + lib.bindSymbol(cast(void**)&Mix_UnregisterAllEffects,"Mix_UnregisterAllEffects"); + lib.bindSymbol(cast(void**)&Mix_SetPanning,"Mix_SetPanning"); + lib.bindSymbol(cast(void**)&Mix_SetPosition,"Mix_SetPosition"); + lib.bindSymbol(cast(void**)&Mix_SetDistance,"Mix_SetDistance"); + lib.bindSymbol(cast(void**)&Mix_SetReverseStereo,"Mix_SetReverseStereo"); + lib.bindSymbol(cast(void**)&Mix_ReserveChannels,"Mix_ReserveChannels"); + lib.bindSymbol(cast(void**)&Mix_GroupChannel,"Mix_GroupChannel"); + lib.bindSymbol(cast(void**)&Mix_GroupChannels,"Mix_GroupChannels"); + lib.bindSymbol(cast(void**)&Mix_GroupAvailable,"Mix_GroupAvailable"); + lib.bindSymbol(cast(void**)&Mix_GroupCount,"Mix_GroupCount"); + lib.bindSymbol(cast(void**)&Mix_GroupOldest,"Mix_GroupOldest"); + lib.bindSymbol(cast(void**)&Mix_GroupNewer,"Mix_GroupNewer"); + lib.bindSymbol(cast(void**)&Mix_PlayChannelTimed,"Mix_PlayChannelTimed"); + lib.bindSymbol(cast(void**)&Mix_PlayMusic,"Mix_PlayMusic"); + lib.bindSymbol(cast(void**)&Mix_FadeInMusic,"Mix_FadeInMusic"); + lib.bindSymbol(cast(void**)&Mix_FadeInMusicPos,"Mix_FadeInMusicPos"); + lib.bindSymbol(cast(void**)&Mix_FadeInChannelTimed,"Mix_FadeInChannelTimed"); + lib.bindSymbol(cast(void**)&Mix_Volume,"Mix_Volume"); + lib.bindSymbol(cast(void**)&Mix_VolumeChunk,"Mix_VolumeChunk"); + lib.bindSymbol(cast(void**)&Mix_VolumeMusic,"Mix_VolumeMusic"); + lib.bindSymbol(cast(void**)&Mix_HaltChannel,"Mix_HaltChannel"); + lib.bindSymbol(cast(void**)&Mix_HaltGroup,"Mix_HaltGroup"); + lib.bindSymbol(cast(void**)&Mix_HaltMusic,"Mix_HaltMusic"); + lib.bindSymbol(cast(void**)&Mix_ExpireChannel,"Mix_ExpireChannel"); + lib.bindSymbol(cast(void**)&Mix_FadeOutChannel,"Mix_FadeOutChannel"); + lib.bindSymbol(cast(void**)&Mix_FadeOutGroup,"Mix_FadeOutGroup"); + lib.bindSymbol(cast(void**)&Mix_FadeOutMusic,"Mix_FadeOutMusic"); + lib.bindSymbol(cast(void**)&Mix_FadingMusic,"Mix_FadingMusic"); + lib.bindSymbol(cast(void**)&Mix_FadingChannel,"Mix_FadingChannel"); + lib.bindSymbol(cast(void**)&Mix_Pause,"Mix_Pause"); + lib.bindSymbol(cast(void**)&Mix_Resume,"Mix_Resume"); + lib.bindSymbol(cast(void**)&Mix_Paused,"Mix_Paused"); + lib.bindSymbol(cast(void**)&Mix_PauseMusic,"Mix_PauseMusic"); + lib.bindSymbol(cast(void**)&Mix_ResumeMusic,"Mix_ResumeMusic"); + lib.bindSymbol(cast(void**)&Mix_RewindMusic,"Mix_RewindMusic"); + lib.bindSymbol(cast(void**)&Mix_PausedMusic,"Mix_PausedMusic"); + lib.bindSymbol(cast(void**)&Mix_SetMusicPosition,"Mix_SetMusicPosition"); + lib.bindSymbol(cast(void**)&Mix_Playing,"Mix_Playing"); + lib.bindSymbol(cast(void**)&Mix_PlayingMusic,"Mix_PlayingMusic"); + lib.bindSymbol(cast(void**)&Mix_SetMusicCMD,"Mix_SetMusicCMD"); + lib.bindSymbol(cast(void**)&Mix_SetSynchroValue,"Mix_SetSynchroValue"); + lib.bindSymbol(cast(void**)&Mix_GetSynchroValue,"Mix_GetSynchroValue"); + lib.bindSymbol(cast(void**)&Mix_GetChunk,"Mix_GetChunk"); + lib.bindSymbol(cast(void**)&Mix_CloseAudio,"Mix_CloseAudio"); + + if(errorCount() != errCount) return SDLMixerSupport.badLibrary; + else loadedVersion = SDLMixerSupport.sdlMixer200; + + static if(sdlMixerSupport >= SDLMixerSupport.sdlMixer202) { + lib.bindSymbol(cast(void**)&Mix_OpenAudioDevice,"Mix_OpenAudioDevice"); + lib.bindSymbol(cast(void**)&Mix_HasChunkDecoder,"Mix_HasChunkDecoder"); + + if(errorCount() != errCount) return SDLMixerSupport.badLibrary; + else loadedVersion = SDLMixerSupport.sdlMixer202; + } + + return loadedVersion; + } +} \ No newline at end of file diff --git a/demos/external/imports/bindbc/sdl/package.d b/demos/external/imports/bindbc/sdl/package.d new file mode 100644 index 0000000..6bba9ad --- /dev/null +++ b/demos/external/imports/bindbc/sdl/package.d @@ -0,0 +1,18 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl; + +public import bindbc.sdl.config, + bindbc.sdl.bind; + +version(BindSDL_Static) {} +else public import bindbc.sdl.dynload; + +version(BindSDL_Image) public import bindbc.sdl.image; +version(BindSDL_Mixer) public import bindbc.sdl.mixer; +version(BindSDL_TTF) public import bindbc.sdl.ttf; + diff --git a/demos/external/imports/bindbc/sdl/ttf.d b/demos/external/imports/bindbc/sdl/ttf.d new file mode 100644 index 0000000..bd63ff3 --- /dev/null +++ b/demos/external/imports/bindbc/sdl/ttf.d @@ -0,0 +1,368 @@ + +// Copyright Michael D. Parker 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module bindbc.sdl.ttf; + +version(BindSDL_TTF): + +import core.stdc.config; +import bindbc.sdl.bind.sdlerror : SDL_GetError, SDL_SetError; +import bindbc.sdl.bind.sdlpixels : SDL_Color; +import bindbc.sdl.bind.sdlrwops : SDL_RWops; +import bindbc.sdl.bind.sdlsurface : SDL_Surface; +import bindbc.sdl.bind.sdlversion : SDL_version; + +alias TTF_SetError = SDL_SetError; +alias TTF_GetError = SDL_GetError; + +enum SDLTTFSupport { + noLibrary, + badLibrary, + sdlTTF2012 = 2012, + sdlTTF2013 = 2013, + sdlTTF2014 = 2014, +} + +enum ubyte SDL_TTF_MAJOR_VERSION = 2; +enum ubyte SDL_TTF_MINOR_VERSION = 0; + +version(SDL_TTF_2014) { + enum sdlTTFSupport = SDLTTFSupport.sdlTTF2014; + enum ubyte SDL_TTF_PATCHLEVEL = 14; +} +else version(SDL_TTF_2013) { + enum sdlTTFSupport = SDLTTFSupport.sdlTTF2013; + enum ubyte SDL_TTF_PATCHLEVEL = 13; +} +else { + enum sdlTTFSupport = SDLTTFSupport.sdlTTF2012; + enum ubyte SDL_TTF_PATCHLEVEL = 12; +} + +alias TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION; +alias TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION; +alias TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL; + +@nogc nothrow +void SDL_TTF_VERSION(SDL_version* X) { + X.major = SDL_TTF_MAJOR_VERSION; + X.minor = SDL_TTF_MINOR_VERSION; + X.patch = SDL_TTF_PATCHLEVEL; +} +alias TTF_VERSION = SDL_TTF_VERSION; + +enum { + UNICODE_BOM_NATIVE = 0xFEFF, + UNICODE_BOM_SWAPPED = 0xFFFE, + TTF_STYLE_NORMAL = 0x00, + TTF_STYLE_BOLD = 0x01, + TTF_STYLE_ITALIC = 0x02, + TTF_STYLE_UNDERLINE = 0x04, + TTF_STYLE_STRIKETHROUGH = 0x08, +} + +enum { + TTF_HINTING_NORMAL = 0, + TTF_HINTING_LIGHT = 1, + TTF_HINTING_MONO = 2, + TTF_HINTING_NONE = 3, +} + +struct TTF_Font; + +version(BindSDL_Static) { + extern(C) @nogc nothrow { + SDL_version* TTF_Linked_Version(); + void TTF_ByteSwappedUNICODE(int); + int TTF_Init(); + TTF_Font * TTF_OpenFont(const(char)*,int); + TTF_Font * TTF_OpenFontIndex(const(char)*,int,c_long ); + TTF_Font * TTF_OpenFontRW(SDL_RWops*,int,int); + TTF_Font * TTF_OpenFontIndexRW(SDL_RWops*,int,int,c_long); + int TTF_GetFontStyle(const(TTF_Font)*); + void TTF_SetFontStyle(const(TTF_Font)*,int style); + int TTF_GetFontOutline(const(TTF_Font)*); + void TTF_SetFontOutline(TTF_Font*,int); + int TTF_GetFontHinting(const(TTF_Font)*); + void TTF_SetFontHinting(TTF_Font*,int); + int TTF_FontHeight(const(TTF_Font)*); + int TTF_FontAscent(const(TTF_Font)*); + int TTF_FontDescent(const(TTF_Font)*); + int TTF_FontLineSkip(const(TTF_Font)*); + int TTF_GetFontKerning(const(TTF_Font)*); + void TTF_SetFontKerning(TTF_Font*,int); + int TTF_FontFaces(const(TTF_Font)*); + int TTF_FontFaceIsFixedWidth(const(TTF_Font)*); + char* TTF_FontFaceFamilyName(const(TTF_Font)*); + char* TTF_FontFaceStyleName(const(TTF_Font)*); + int TTF_GlyphIsProvided(const(TTF_Font)*,ushort); + int TTF_GlyphMetrics(TTF_Font*,ushort,int*,int*,int*,int*,int*); + int TTF_SizeText(TTF_Font*,const(char)*,int*,int*); + int TTF_SizeUTF8(TTF_Font*,const(char)*,int*,int*); + int TTF_SizeUNICODE(TTF_Font*,ushort*,int*,int*); + SDL_Surface* TTF_RenderText_Solid(TTF_Font*,const(char)*,SDL_Color); + SDL_Surface* TTF_RenderUTF8_Solid(TTF_Font*,const(char)*,SDL_Color); + SDL_Surface* TTF_RenderUNICODE_Solid(TTF_Font*,const(ushort)*,SDL_Color); + SDL_Surface* TTF_RenderGlyph_Solid(TTF_Font*,ushort,SDL_Color); + SDL_Surface* TTF_RenderText_Shaded(TTF_Font*,const(char)*,SDL_Color,SDL_Color); + SDL_Surface* TTF_RenderUTF8_Shaded(TTF_Font*,const(char)*,SDL_Color,SDL_Color); + SDL_Surface* TTF_RenderUNICODE_Shaded(TTF_Font*,const(ushort)*,SDL_Color,SDL_Color); + SDL_Surface* TTF_RenderGlyph_Shaded(TTF_Font*,ushort,SDL_Color,SDL_Color); + SDL_Surface* TTF_RenderText_Blended(TTF_Font*,const(char)*,SDL_Color); + SDL_Surface* TTF_RenderUTF8_Blended(TTF_Font*,const(char)*,SDL_Color); + SDL_Surface* TTF_RenderUNICODE_Blended(TTF_Font*,const(ushort)*,SDL_Color); + SDL_Surface* TTF_RenderText_Blended_Wrapped(TTF_Font*,const(char)*,SDL_Color,uint); + SDL_Surface* TTF_RenderUTF8_Blended_Wrapped(TTF_Font*,const(char)*,SDL_Color,uint); + SDL_Surface* TTF_RenderUNICODE_Blended_Wrapped(TTF_Font*,const(ushort)*,SDL_Color,uint); + SDL_Surface* TTF_RenderGlyph_Blended(TTF_Font*,ushort,SDL_Color); + void TTF_CloseFont(TTF_Font*); + void TTF_Quit(); + int TTF_WasInit(); + int TTF_GetFontKerningSize(TTF_Font*,int,int); + + static if(sdlTTFSupport >= SDLTTFSupport.sdlTTF2014) { + int TTF_GetFontKerningSizeGlyphs(TTF_Font*,ushort,ushort); + } + } +} +else { + import bindbc.loader; + + extern(C) @nogc nothrow { + alias pTTF_Linked_Version = SDL_version* function(); + alias pTTF_ByteSwappedUNICODE = void function(int); + alias pTTF_Init = int function(); + alias pTTF_OpenFont = TTF_Font * function(const(char)*,int); + alias pTTF_OpenFontIndex = TTF_Font * function(const(char)*,int,c_long ); + alias pTTF_OpenFontRW = TTF_Font * function(SDL_RWops*,int,int); + alias pTTF_OpenFontIndexRW = TTF_Font * function(SDL_RWops*,int,int,c_long); + alias pTTF_GetFontStyle = int function(const(TTF_Font)*); + alias pTTF_SetFontStyle = void function(const(TTF_Font)*,int style); + alias pTTF_GetFontOutline = int function(const(TTF_Font)*); + alias pTTF_SetFontOutline = void function(TTF_Font*,int); + alias pTTF_GetFontHinting = int function(const(TTF_Font)*); + alias pTTF_SetFontHinting = void function(TTF_Font*,int); + alias pTTF_FontHeight = int function(const(TTF_Font)*); + alias pTTF_FontAscent = int function(const(TTF_Font)*); + alias pTTF_FontDescent = int function(const(TTF_Font)*); + alias pTTF_FontLineSkip = int function(const(TTF_Font)*); + alias pTTF_GetFontKerning = int function(const(TTF_Font)*); + alias pTTF_SetFontKerning = void function(TTF_Font*,int); + alias pTTF_FontFaces = int function(const(TTF_Font)*); + alias pTTF_FontFaceIsFixedWidth = int function(const(TTF_Font)*); + alias pTTF_FontFaceFamilyName = char* function(const(TTF_Font)*); + alias pTTF_FontFaceStyleName = char* function(const(TTF_Font)*); + alias pTTF_GlyphIsProvided = int function(const(TTF_Font)*,ushort); + alias pTTF_GlyphMetrics = int function(TTF_Font*,ushort,int*,int*,int*,int*,int*); + alias pTTF_SizeText = int function(TTF_Font*,const(char)*,int*,int*); + alias pTTF_SizeUTF8 = int function(TTF_Font*,const(char)*,int*,int*); + alias pTTF_SizeUNICODE = int function(TTF_Font*,ushort*,int*,int*); + alias pTTF_RenderText_Solid = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color); + alias pTTF_RenderUTF8_Solid = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color); + alias pTTF_RenderUNICODE_Solid = SDL_Surface* function(TTF_Font*,const(ushort)*,SDL_Color); + alias pTTF_RenderGlyph_Solid = SDL_Surface* function(TTF_Font*,ushort,SDL_Color); + alias pTTF_RenderText_Shaded = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,SDL_Color); + alias pTTF_RenderUTF8_Shaded = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,SDL_Color); + alias pTTF_RenderUNICODE_Shaded = SDL_Surface* function(TTF_Font*,const(ushort)*,SDL_Color,SDL_Color); + alias pTTF_RenderGlyph_Shaded = SDL_Surface* function(TTF_Font*,ushort,SDL_Color,SDL_Color); + alias pTTF_RenderText_Blended = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color); + alias pTTF_RenderUTF8_Blended = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color); + alias pTTF_RenderUNICODE_Blended = SDL_Surface* function(TTF_Font*,const(ushort)*,SDL_Color); + alias pTTF_RenderText_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,uint); + alias pTTF_RenderUTF8_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(char)*,SDL_Color,uint); + alias pTTF_RenderUNICODE_Blended_Wrapped = SDL_Surface* function(TTF_Font*,const(ushort)*,SDL_Color,uint); + alias pTTF_RenderGlyph_Blended = SDL_Surface* function(TTF_Font*,ushort,SDL_Color); + alias pTTF_CloseFont = void function(TTF_Font*); + alias pTTF_Quit = void function(); + alias pTTF_WasInit = int function(); + alias pTTF_GetFontKerningSize = int function(TTF_Font*,int,int); + } + + __gshared { + pTTF_Linked_Version TTF_Linked_Version; + pTTF_ByteSwappedUNICODE TTF_ByteSwappedUNICODE; + pTTF_Init TTF_Init; + pTTF_OpenFont TTF_OpenFont; + pTTF_OpenFontIndex TTF_OpenFontIndex; + pTTF_OpenFontRW TTF_OpenFontRW; + pTTF_OpenFontIndexRW TTF_OpenFontIndexRW; + pTTF_GetFontStyle TTF_GetFontStyle; + pTTF_SetFontStyle TTF_SetFontStyle; + pTTF_GetFontOutline TTF_GetFontOutline; + pTTF_SetFontOutline TTF_SetFontOutline; + pTTF_GetFontHinting TTF_GetFontHinting; + pTTF_SetFontHinting TTF_SetFontHinting; + pTTF_FontHeight TTF_FontHeight; + pTTF_FontAscent TTF_FontAscent; + pTTF_FontDescent TTF_FontDescent; + pTTF_FontLineSkip TTF_FontLineSkip; + pTTF_GetFontKerning TTF_GetFontKerning; + pTTF_SetFontKerning TTF_SetFontKerning; + pTTF_FontFaces TTF_FontFaces; + pTTF_FontFaceIsFixedWidth TTF_FontFaceIsFixedWidth; + pTTF_FontFaceFamilyName TTF_FontFaceFamilyName; + pTTF_FontFaceStyleName TTF_FontFaceStyleName; + pTTF_GlyphIsProvided TTF_GlyphIsProvided; + pTTF_GlyphMetrics TTF_GlyphMetrics; + pTTF_SizeText TTF_SizeText; + pTTF_SizeUTF8 TTF_SizeUTF8; + pTTF_SizeUNICODE TTF_SizeUNICODE; + pTTF_RenderText_Solid TTF_RenderText_Solid; + pTTF_RenderUTF8_Solid TTF_RenderUTF8_Solid; + pTTF_RenderUNICODE_Solid TTF_RenderUNICODE_Solid; + pTTF_RenderGlyph_Solid TTF_RenderGlyph_Solid; + pTTF_RenderText_Shaded TTF_RenderText_Shaded; + pTTF_RenderUTF8_Shaded TTF_RenderUTF8_Shaded; + pTTF_RenderUNICODE_Shaded TTF_RenderUNICODE_Shaded; + pTTF_RenderGlyph_Shaded TTF_RenderGlyph_Shaded; + pTTF_RenderText_Blended TTF_RenderText_Blended; + pTTF_RenderUTF8_Blended TTF_RenderUTF8_Blended; + pTTF_RenderUNICODE_Blended TTF_RenderUNICODE_Blended; + pTTF_RenderText_Blended_Wrapped TTF_RenderText_Blended_Wrapped; + pTTF_RenderUTF8_Blended_Wrapped TTF_RenderUTF8_Blended_Wrapped; + pTTF_RenderUNICODE_Blended_Wrapped TTF_RenderUNICODE_Blended_Wrapped; + pTTF_RenderGlyph_Blended TTF_RenderGlyph_Blended; + pTTF_CloseFont TTF_CloseFont; + pTTF_Quit TTF_Quit; + pTTF_WasInit TTF_WasInit; + pTTF_GetFontKerningSize TTF_GetFontKerningSize; + } + + static if(sdlTTFSupport >= SDLTTFSupport.sdlTTF2014) { + extern(C) @nogc nothrow { + alias pTTF_GetFontKerningSizeGlyphs = int function(TTF_Font*,ushort,ushort); + } + + __gshared { + pTTF_GetFontKerningSizeGlyphs TTF_GetFontKerningSizeGlyphs; + } + } + + private { + SharedLib lib; + SDLTTFSupport loadedVersion; + } + + void unloadSDLTTF() + { + if(lib != invalidHandle) { + lib.unload(); + } + } + + SDLTTFSupport loadedSDLTTFVersion() { return loadedVersion; } + + bool isSDLTTFLoaded() + { + return lib != invalidHandle; + } + + SDLTTFSupport loadSDLTTF() + { + version(Windows) { + const(char)[][1] libNames = ["SDL2_ttf.dll"]; + } + else version(OSX) { + const(char)[][6] libNames = [ + "libSDL2_ttf.dylib", + "/usr/local/lib/libSDL2_ttf.dylib", + "../Frameworks/SDL2_ttf.framework/SDL2_ttf", + "/Library/Frameworks/SDL2_ttf.framework/SDL2_ttf", + "/System/Library/Frameworks/SDL2_ttf.framework/SDL2_ttf", + "/opt/local/lib/libSDL2_ttf.dylib" + ]; + } + else version(Posix) { + const(char)[][6] libNames = [ + "libSDL2_ttf.so", + "/usr/local/lib/libSDL2_ttf.so", + "libSDL2-2.0_ttf.so", + "/usr/local/lib/libSDL2-2.0_ttf.so", + "libSDL2-2.0_ttf.so.0", + "/usr/local/lib/libSDL2-2.0_ttf.so.0" + ]; + } + else static assert(0, "bindbc-sdl is not yet supported on this platform."); + + SDLTTFSupport ret; + foreach(name; libNames) { + ret = loadSDLTTF(name.ptr); + if(ret != SDLTTFSupport.noLibrary) break; + } + return ret; + } + + SDLTTFSupport loadSDLTTF(const(char)* libName) + { + lib = load(libName); + if(lib == invalidHandle) { + return SDLTTFSupport.noLibrary; + } + + auto errCount = errorCount(); + loadedVersion = SDLTTFSupport.badLibrary; + + lib.bindSymbol(cast(void**)&TTF_Linked_Version,"TTF_Linked_Version"); + lib.bindSymbol(cast(void**)&TTF_ByteSwappedUNICODE,"TTF_ByteSwappedUNICODE"); + lib.bindSymbol(cast(void**)&TTF_Init,"TTF_Init"); + lib.bindSymbol(cast(void**)&TTF_OpenFont,"TTF_OpenFont"); + lib.bindSymbol(cast(void**)&TTF_OpenFontIndex,"TTF_OpenFontIndex"); + lib.bindSymbol(cast(void**)&TTF_OpenFontRW,"TTF_OpenFontRW"); + lib.bindSymbol(cast(void**)&TTF_OpenFontIndexRW,"TTF_OpenFontIndexRW"); + lib.bindSymbol(cast(void**)&TTF_GetFontStyle,"TTF_GetFontStyle"); + lib.bindSymbol(cast(void**)&TTF_SetFontStyle,"TTF_SetFontStyle"); + lib.bindSymbol(cast(void**)&TTF_GetFontOutline,"TTF_GetFontOutline"); + lib.bindSymbol(cast(void**)&TTF_SetFontOutline,"TTF_SetFontOutline"); + lib.bindSymbol(cast(void**)&TTF_GetFontHinting,"TTF_GetFontHinting"); + lib.bindSymbol(cast(void**)&TTF_SetFontHinting,"TTF_SetFontHinting"); + lib.bindSymbol(cast(void**)&TTF_FontHeight,"TTF_FontHeight"); + lib.bindSymbol(cast(void**)&TTF_FontAscent,"TTF_FontAscent"); + lib.bindSymbol(cast(void**)&TTF_FontDescent,"TTF_FontDescent"); + lib.bindSymbol(cast(void**)&TTF_FontLineSkip,"TTF_FontLineSkip"); + lib.bindSymbol(cast(void**)&TTF_GetFontKerning,"TTF_GetFontKerning"); + lib.bindSymbol(cast(void**)&TTF_SetFontKerning,"TTF_SetFontKerning"); + lib.bindSymbol(cast(void**)&TTF_FontFaces,"TTF_FontFaces"); + lib.bindSymbol(cast(void**)&TTF_FontFaceIsFixedWidth,"TTF_FontFaceIsFixedWidth"); + lib.bindSymbol(cast(void**)&TTF_FontFaceFamilyName,"TTF_FontFaceFamilyName"); + lib.bindSymbol(cast(void**)&TTF_FontFaceStyleName,"TTF_FontFaceStyleName"); + lib.bindSymbol(cast(void**)&TTF_GlyphIsProvided,"TTF_GlyphIsProvided"); + lib.bindSymbol(cast(void**)&TTF_GlyphMetrics,"TTF_GlyphMetrics"); + lib.bindSymbol(cast(void**)&TTF_SizeText,"TTF_SizeText"); + lib.bindSymbol(cast(void**)&TTF_SizeUTF8,"TTF_SizeUTF8"); + lib.bindSymbol(cast(void**)&TTF_SizeUNICODE,"TTF_SizeUNICODE"); + lib.bindSymbol(cast(void**)&TTF_RenderText_Solid,"TTF_RenderText_Solid"); + lib.bindSymbol(cast(void**)&TTF_RenderUTF8_Solid,"TTF_RenderUTF8_Solid"); + lib.bindSymbol(cast(void**)&TTF_RenderUNICODE_Solid,"TTF_RenderUNICODE_Solid"); + lib.bindSymbol(cast(void**)&TTF_RenderGlyph_Solid,"TTF_RenderGlyph_Solid"); + lib.bindSymbol(cast(void**)&TTF_RenderText_Shaded,"TTF_RenderText_Shaded"); + lib.bindSymbol(cast(void**)&TTF_RenderUTF8_Shaded,"TTF_RenderUTF8_Shaded"); + lib.bindSymbol(cast(void**)&TTF_RenderUNICODE_Shaded,"TTF_RenderUNICODE_Shaded"); + lib.bindSymbol(cast(void**)&TTF_RenderGlyph_Shaded,"TTF_RenderGlyph_Shaded"); + lib.bindSymbol(cast(void**)&TTF_RenderText_Blended,"TTF_RenderText_Blended"); + lib.bindSymbol(cast(void**)&TTF_RenderUTF8_Blended,"TTF_RenderUTF8_Blended"); + lib.bindSymbol(cast(void**)&TTF_RenderUNICODE_Blended,"TTF_RenderUNICODE_Blended"); + lib.bindSymbol(cast(void**)&TTF_RenderText_Blended_Wrapped,"TTF_RenderText_Blended_Wrapped"); + lib.bindSymbol(cast(void**)&TTF_RenderUTF8_Blended_Wrapped,"TTF_RenderUTF8_Blended_Wrapped"); + lib.bindSymbol(cast(void**)&TTF_RenderUNICODE_Blended_Wrapped,"TTF_RenderUNICODE_Blended_Wrapped"); + lib.bindSymbol(cast(void**)&TTF_RenderGlyph_Blended,"TTF_RenderGlyph_Blended"); + lib.bindSymbol(cast(void**)&TTF_CloseFont,"TTF_CloseFont"); + lib.bindSymbol(cast(void**)&TTF_Quit,"TTF_Quit"); + lib.bindSymbol(cast(void**)&TTF_WasInit,"TTF_WasInit"); + lib.bindSymbol(cast(void**)&TTF_GetFontKerningSize,"TTF_GetFontKerningSize"); + + if(errorCount() != errCount) return SDLTTFSupport.badLibrary; + else loadedVersion = SDLTTFSupport.sdlTTF2012; + + static if(sdlTTFSupport >= SDLTTFSupport.sdlTTF2014) { + lib.bindSymbol(cast(void**)&TTF_GetFontKerningSizeGlyphs,"TTF_GetFontKerningSizeGlyphs"); + + if(errorCount() != errCount) return SDLTTFSupport.badLibrary; + else loadedVersion = SDLTTFSupport.sdlTTF2014; + } + + return loadedVersion; + } +} \ No newline at end of file diff --git a/demos/libpng16-16.dll b/demos/libpng16-16.dll new file mode 100644 index 0000000..709f724 Binary files /dev/null and b/demos/libpng16-16.dll differ diff --git a/demos/simple/dub.json b/demos/simple/dub.json new file mode 100644 index 0000000..393840f --- /dev/null +++ b/demos/simple/dub.json @@ -0,0 +1,50 @@ +{ + "name": "simple", + "authors": [ + "Michał Masiukiewicz", "Dawid Masiukiewicz" + ], + "targetPath": "..", + "description": "Dynamic Entity Component System simple example", + "copyright": "Copyright © 2018-2019, Michał Masiukiewicz, Dawid Masiukiewicz", + "license": "BSD 3-clause", + "sourcePaths" : ["source\/"], + "dflags-posix-ldc": [ + "-defaultlib=phobos2-ldc,druntime-ldc" + ], + "libs-windows-x86_64": ["../libs/windows/x64/SDL2","../libs/windows/x64/SDL2main","../libs/windows/x64/SDL2_Image"], + "dflagss": [ + "-betterC" + ], + "dependencies": { + "bindbc-sdl":"0.13.0", + "ecs":{"path":"../../"}, + "ecs_utils":{"path":"../utils/"} + }, + "versions": [ + "SDL_2010", + "BindSDL_Image" + ], + "configurations" : [ + { + "name" : "default", + "targetType" : "executable", + "subConfigurations": + { + "ecs":"library" + } + }, + { + "name" : "betterC", + "targetType" : "executable", + "dflags": [ + "-betterC" + ], + "subConfigurations": + { + "bindbc-sdl": "staticBC", + "ecs_utils":"betterC", + "ecs":"library-betterC" + } + } + ] +} \ No newline at end of file diff --git a/demos/simple/source/app.d b/demos/simple/source/app.d new file mode 100644 index 0000000..d8d61f5 --- /dev/null +++ b/demos/simple/source/app.d @@ -0,0 +1,216 @@ +module source.app; + +import ecs.std; +import ecs.core; +import ecs.manager; +import ecs.attributes; +import ecs.entity; + +import bindbc.sdl; + +import utils.utils; +import utils.texture; + +import ecs_utils.math.vector; + +version (WebAssembly) +{ + extern (C) void _start() + { + } +} + +SDL_Renderer *renderer; +SDL_Window* window; +Texture texture; +EntityManager* manager; + +struct CLocation +{ + mixin ECS.Component; + + alias location this; + + vec2 location; +} + +struct CTexture +{ + mixin ECS.Component; + + Texture tex; +} + +struct DrawSystem +{ + mixin ECS.System; + + struct EntitiesData + { + uint length; + @readonly CTexture[] textures; + @readonly CLocation[] locations; + } + + void onUpdate(EntitiesData data) + { + foreach(i; 0..data.length) + { + draw(renderer, data.textures[i].tex, data.locations[i], vec2(32,32), vec4(0,0,1,1)); + } + } +} + +struct MoveSystem +{ + mixin ECS.System; + + struct EntitiesData + { + uint length; + CLocation[] locations; + } + + void onUpdate(EntitiesData data) + { + foreach(i; 0..data.length) + { + data.locations[i].location.y = data.locations[i].location.y + 1; + if(data.locations[i].location.y > 400)data.locations[i].location.y = 0; + } + } +} + +extern (C) int main(int argc, char** argv) +{ + fps = 0; + time = 0; + + if (SDL_Init(SDL_INIT_VIDEO) < 0) + { + printf("SDL could not initialize! SDL_Error: %s", SDL_GetError()); + return -1; + } + + SDL_version sdl_version; + SDL_GetVersion(&sdl_version); + printf("SDL version: %u.%u.%u\n",cast(uint)sdl_version.major,cast(uint)sdl_version.minor,cast(uint)sdl_version.patch); + + SDL_Window* window = SDL_CreateWindow("Simple", SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, 600, 400, SDL_WINDOW_SHOWN); + //SDL_CreateWindowAndRenderer(600, 400, SDL_RENDERER_ACCELERATED, &window, &renderer); + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + SDL_SetRenderDrawColor(renderer, 1, 255, 255, 255); + + texture.create(); + texture.load(renderer, "assets/textures/buckler.png"); + + EntityManager.initialize(8); + manager = EntityManager.instance; + + manager.beginRegister(); + + manager.registerComponent!CLocation; + manager.registerComponent!CTexture; + + manager.registerSystem!MoveSystem(64); + manager.registerSystem!DrawSystem(64); + + manager.endRegister(); + + ushort[2] components = [CLocation.component_id, CTexture.component_id]; + EntityTemplate* tmpl = manager.allocateTemplate(components); + CTexture* tex_comp = tmpl.getComponent!CTexture; + tex_comp.tex = texture; + CLocation* loc_comp = tmpl.getComponent!CLocation; + // loc_comp.location = vec2(64,64); + + foreach(i; 0..10) + foreach(j; 0..10) + { + loc_comp.location = vec2(i*32+64,j*32+64); + manager.addEntity(tmpl); + } + + + manager.freeTemplate(tmpl); + + /*image = IMG_Load("assets/owl.png"); + tex = SDL_CreateTextureFromSurface(renderer, image);*/ + + version(WebAssembly) + { + emscripten_set_main_loop_arg(&loop, null, -1, 1); + } + + bool arg = true; + while(arg == true) + { + loop(&arg); + } + + if (window !is null) { + SDL_DestroyWindow(window); + } + + end(); + + return 0; +} + +long time; +uint fps; + +extern(C) void loop(void *arg = null) +{ + static float fps_time = 0; + float delta_time = cast(float)(Time.getUSecTime() - time); + if(delta_time > 1000_000)delta_time = 1000; + time = Time.getUSecTime(); + + if(fps_time < 0)fps_time = 0; + + fps++; + fps_time += delta_time; + if(fps_time > 1000_000) + { + + printf("FPS: %u\n",fps); + fps = 0; + fps_time -= 1000_000; + } + + SDL_Event event; + while (SDL_PollEvent(&event)) + { + if (event.type == SDL_QUIT) { + version(WebAssembly)emscripten_cancel_main_loop(); + *cast(bool*)arg = false; + //return false; + } + + if (event.type == SDL_KEYDOWN) { + version(WebAssembly)emscripten_cancel_main_loop(); + *cast(bool*)arg = false; + //return false; + } + } + + SDL_RenderClear(renderer); + + manager.begin(); + manager.update(); + manager.end(); + + draw(renderer,texture,vec2(32,32),vec2(32,32),vec4(0,0,1,1)); + //SDL_RenderCopy(ctx->renderer, ctx->owl_tex, NULL, &ctx->dest); + SDL_RenderPresent(renderer); + + //return true; +} + +void end() +{ + EntityManager.destroy(); + SDL_Quit(); +} \ No newline at end of file diff --git a/demos/simple/source/utils/texture.d b/demos/simple/source/utils/texture.d new file mode 100644 index 0000000..5b49390 --- /dev/null +++ b/demos/simple/source/utils/texture.d @@ -0,0 +1,49 @@ +module utils.texture; + +import ecs.std; + +import bindbc.sdl; +import bindbc.sdl.image; + +import ecs_utils.math.vector; + +struct Texture +{ + + void create() + { + data = Mallocator.make!Data; + } + + bool load(SDL_Renderer* renderer, const char[] path) + { + char[] cpath = (cast(char*)alloca(path.length+1))[0..path.length+1]; + //cpath[0..$-1] = path[0..$]; + memcpy(cpath.ptr, path.ptr, path.length); + cpath[$-1] = 0; + + SDL_Surface* surf = IMG_Load(cpath.ptr); + if(!surf)return false; + + data.size = ivec2(surf.w,surf.h); + + data.texture = SDL_CreateTextureFromSurface(renderer,surf); + SDL_FreeSurface(surf); + + if(!data.texture)return false; + + return true; + } + + struct Data + { + ubyte[] data; + + ivec2 size; + uint bpp; + + SDL_Texture* texture; + } + + Data* data; +} \ No newline at end of file diff --git a/demos/simple/source/utils/utils.d b/demos/simple/source/utils/utils.d new file mode 100644 index 0000000..c7d3e9d --- /dev/null +++ b/demos/simple/source/utils/utils.d @@ -0,0 +1,110 @@ +module utils.utils; + +extern(C) int printf(scope const char* format, ...) @nogc nothrow @system; + +version(WebAssembly) +{ + + extern (C) alias em_callback_func = void function(); + extern (C) alias em_arg_callback_func = void function(void*); + extern (C) void emscripten_set_main_loop(em_callback_func func, int fps, int simulate_infinite_loop); + extern (C) void emscripten_set_main_loop_arg(em_arg_callback_func func, void *arg, int fps, int simulate_infinite_loop); + extern (C) int emscripten_set_main_loop_timing(int mode, int value); + extern (C) void emscripten_cancel_main_loop(); + + alias int time_t; + alias int clockid_t; + enum CLOCK_REALTIME = 0; + + struct timespec + { + time_t tv_sec; + int tv_nsec; + } + + extern(C) int clock_gettime(clockid_t, timespec*) @nogc nothrow @system; + + struct Time + { + + + static long getUSecTime() + { + time_t time; + timespec spec; + + clock_gettime(CLOCK_REALTIME, &spec); + + //time = spec.tv_sec; + return spec.tv_sec * 1000_000 + spec.tv_nsec / 1000;//time / 1000_000; + + /*LARGE_INTEGER time, freq; + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&time); + return time.QuadPart / (freq.QuadPart / 1000_000);*/ + } + } +} +else version(Windows) +{ + import core.stdc.stdio : printf; + import core.sys.windows.windows; + struct Time + { + static long getUSecTime() + { + LARGE_INTEGER time, freq; + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&time); + return time.QuadPart / (freq.QuadPart / 1000_000); + } + } +} +else version(Posix) +{ + import core.stdc.stdio : printf; + import core.sys.posix.time; + struct Time + { + static long getUSecTime() + { + time_t time; + timespec spec; + + clock_gettime(CLOCK_REALTIME, &spec); + + //time = spec.tv_sec; + return spec.tv_sec * 1000_000 + spec.tv_nsec / 1000;//time / 1000_000; + + /*LARGE_INTEGER time, freq; + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&time); + return time.QuadPart / (freq.QuadPart / 1000_000);*/ + } + } +} + +import bindbc.sdl; +import utils.texture; +import ecs_utils.math.vector; + +ivec2 resolution = ivec2(600, 400); + +void draw(SDL_Renderer* renderer, Texture tex, vec2 pos, vec2 size, vec4 coords, float angle = 0) +{ + + SDL_Rect rect = SDL_Rect(cast(int)(coords.x*tex.data.size.x),cast(int)(coords.y*tex.data.size.y),cast(int)(coords.z*tex.data.size.x),cast(int)(coords.w*tex.data.size.y)); + SDL_Rect rect2 = SDL_Rect(cast(int)((pos.x-size.x*0.5)), + cast(int)(resolution.y - pos.y - size.y*0.5), + cast(int)(size.x), + cast(int)(size.y)); + + SDL_RenderCopyEx(renderer, + tex.data.texture, + &rect, + &rect2, + angle*360, + null, + SDL_FLIP_NONE); + +} \ No newline at end of file diff --git a/demos/utils/dub.json b/demos/utils/dub.json new file mode 100644 index 0000000..14298cb --- /dev/null +++ b/demos/utils/dub.json @@ -0,0 +1,50 @@ +{ + "name": "ecs_utils", + "authors": [ + "Michał Masiukiewicz", "Dawid Masiukiewicz" + ], + "description": "Dynamic Entity Component System examples utils", + "copyright": "Copyright © 2018-2019, Michał Masiukiewicz, Dawid Masiukiewicz", + "license": "BSD", + "sourcePaths" : [ + "source\/" + ], + "importPaths": [ + "source" + ], + "dflags-posix-ldc": [ + "-defaultlib=phobos2-ldc,druntime-ldc" + ], + "dflagss": [ + "-betterC" + ], + "dependencies": { + "bindbc-sdl":"0.10.1" + }, + "versions": [ + "BindSDL_Image", + "SDL_2010" + ], + + "configurations" : [ + { + "name" : "default", + "targetType" : "library", + "subConfigurations": + { + "bindbc-sdl": "static" + } + }, + { + "name" : "betterC", + "targetType" : "library", + "dflags": [ + "-betterC" + ], + "subConfigurations": + { + "bindbc-sdl": "staticBC" + } + } + ] +} \ No newline at end of file diff --git a/demos/utils/source/ecs_utils/math/matrix.d b/demos/utils/source/ecs_utils/math/matrix.d new file mode 100644 index 0000000..8a8e13b --- /dev/null +++ b/demos/utils/source/ecs_utils/math/matrix.d @@ -0,0 +1,6 @@ +module ecs_utils.math.matrix; + +struct mat3 +{ + float[9] data; +} \ No newline at end of file diff --git a/demos/utils/source/ecs_utils/math/vector.d b/demos/utils/source/ecs_utils/math/vector.d new file mode 100644 index 0000000..10b4de5 --- /dev/null +++ b/demos/utils/source/ecs_utils/math/vector.d @@ -0,0 +1,100 @@ +module ecs_utils.math.vector; + +struct vec2 +{ + union + { + struct + { + float x; + float y; + } + float[2] data; + } + + vec2 opBinary(string op)(vec2 v) + { + static if (op == "+") return vec2(x + v.x, y + v.y); + else static if (op == "-") return vec2(x - v.x, y - v.y); + else static if (op == "*") return vec2(x * v.x, y * v.y); + else static if (op == "/") return vec2(x / v.x, y / v.y); + else static assert(0, "Operator "~op~" not implemented"); + } + + vec2 opBinary(string op)(float v) + { + static if (op == "+") return vec2(x + v, y + v); + else static if (op == "-") return vec2(x - v, y - v); + else static if (op == "*") return vec2(x * v, y * v); + else static if (op == "/") return vec2(x / v, y / v); + else static assert(0, "Operator "~op~" not implemented"); + } + + void opOpAssign(string op)(vec2 v) + { + static if (op == "+") + { + x += v.x; + y += v.y; + } + else static if (op == "-") + { + x -= v.x; + y -= v.y; + } + else static if (op == "*") + { + x *= v.x; + y *= v.y; + } + else static if (op == "/") + { + x /= v.x; + y /= v.y; + } + else static assert(0, "Operator "~op~" not implemented"); + } +} + +struct vec4 +{ + union + { + struct + { + float x; + float y; + float z; + float w; + } + float[4] data; + } +} + +struct ivec2 +{ + union + { + struct + { + int x; + int y; + } + int[2] data; + } +} + +struct ivec4 +{ + union + { + struct + { + int x; + int y; + int z; + int w; + } + int[4] data; + } +} \ No newline at end of file diff --git a/demos/zlib1.dll b/demos/zlib1.dll new file mode 100644 index 0000000..e7493de Binary files /dev/null and b/demos/zlib1.dll differ diff --git a/source/ecs/std.d b/source/ecs/std.d index c52d3af..c8b7ecd 100644 --- a/source/ecs/std.d +++ b/source/ecs/std.d @@ -56,7 +56,7 @@ version(D_betterC) private const uint max_alloca = 10000; private char[max_alloca] alloca_array; private uint alloca_pos = 0; - void* alloca(size_t length) @nogc nothrow + export extern(C) void* alloca(size_t length) @nogc nothrow { if(alloca_pos + length > max_alloca)alloca_pos = 0; void* ret = &alloca_array[alloca_pos]; @@ -69,7 +69,7 @@ else version(WebAssembly) private const uint max_alloca = 10000; private char[max_alloca] alloca_array; private uint alloca_pos = 0; - void* alloca(size_t length) @nogc nothrow + export extern(C) void* alloca(size_t length) @nogc nothrow { if(alloca_pos + length > max_alloca)alloca_pos = 0; void* ret = &alloca_array[alloca_pos];