├── .gitignore ├── 3x6-bw.png ├── README.md ├── SDL2 ├── SDL.h ├── SDL_assert.h ├── SDL_atomic.h ├── SDL_audio.h ├── SDL_bits.h ├── SDL_blendmode.h ├── SDL_clipboard.h ├── SDL_config.h ├── SDL_config_android.h ├── SDL_config_iphoneos.h ├── SDL_config_macosx.h ├── SDL_config_minimal.h ├── SDL_config_pandora.h ├── SDL_config_psp.h ├── SDL_config_windows.h ├── SDL_config_winrt.h ├── SDL_config_wiz.h ├── SDL_copying.h ├── SDL_cpuinfo.h ├── SDL_egl.h ├── SDL_endian.h ├── SDL_error.h ├── SDL_events.h ├── SDL_filesystem.h ├── SDL_gamecontroller.h ├── SDL_gesture.h ├── SDL_haptic.h ├── SDL_hints.h ├── SDL_joystick.h ├── SDL_keyboard.h ├── SDL_keycode.h ├── SDL_loadso.h ├── SDL_log.h ├── SDL_main.h ├── SDL_messagebox.h ├── SDL_mouse.h ├── SDL_mutex.h ├── SDL_name.h ├── SDL_opengl.h ├── SDL_opengl_glext.h ├── SDL_opengles.h ├── SDL_opengles2.h ├── SDL_opengles2_gl2.h ├── SDL_opengles2_gl2ext.h ├── SDL_opengles2_gl2platform.h ├── SDL_opengles2_khrplatform.h ├── SDL_pixels.h ├── SDL_platform.h ├── SDL_power.h ├── SDL_quit.h ├── SDL_rect.h ├── SDL_render.h ├── SDL_revision.h ├── SDL_rwops.h ├── SDL_scancode.h ├── SDL_shape.h ├── SDL_stdinc.h ├── SDL_surface.h ├── SDL_system.h ├── SDL_syswm.h ├── SDL_test.h ├── SDL_test_assert.h ├── SDL_test_common.h ├── SDL_test_compare.h ├── SDL_test_crc32.h ├── SDL_test_font.h ├── SDL_test_fuzzer.h ├── SDL_test_harness.h ├── SDL_test_images.h ├── SDL_test_log.h ├── SDL_test_md5.h ├── SDL_test_memory.h ├── SDL_test_random.h ├── SDL_thread.h ├── SDL_timer.h ├── SDL_touch.h ├── SDL_types.h ├── SDL_version.h ├── SDL_video.h ├── SDL_vulkan.h ├── begin_code.h └── close_code.h ├── base.ninja ├── bob ├── bob.cpp └── build.sh ├── build.bat ├── build.sh ├── lib ├── FileBuffer.hpp ├── List.hpp ├── common.hpp ├── math.hpp ├── stb_image.cpp └── stb_image.h ├── link ├── README-SDL.txt └── SDL2.dll ├── mac-build.sh ├── notes.txt ├── old-code ├── avx2-test.cpp ├── sse2.cpp └── sse2.hpp ├── ply ├── build.sh ├── ply.cpp └── sword7.ply ├── res ├── build.sh ├── cobblestone1_c.png ├── cobblestone1_n.png ├── metal1_c.png ├── metal1_n.png ├── sword7.diw ├── sword7_c.png ├── sword7_n.png ├── sword9.diw ├── sword9_c.png ├── sword9_n.png ├── tiles1_c.png ├── tiles1_n.png ├── tomato.diw ├── tomato_c.png └── tomato_n.png ├── src ├── blit.cpp ├── blit.hpp ├── build.sh ├── gif.cpp ├── gif.hpp └── main.cpp ├── timings.txt └── win-build.bat /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | asset/ 3 | bob/bob 4 | bob/out.ninja 5 | build/ 6 | ply/ply 7 | ply/*.diw 8 | res/src/ 9 | *.xcodeproj 10 | game 11 | game.exe 12 | *.gif 13 | -------------------------------------------------------------------------------- /3x6-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/3x6-bw.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DIWide 2 | ## Features 3 | - perspective-correct vertex attribute interpolation 4 | - correct near-plane clipping 5 | - viewport and backface culling 6 | - fully gamma-correct pipeline 7 | - bilinear texture filtering 8 | - diffuse, normal, and roughness textures 9 | - high-resolution shadow mapping 10 | - simplified physically-based lighting model 11 | - post-processing bit-depth reduction 12 | - built-in custom GIF exporter 13 | 14 | ## How to build 15 | - **macOS**: First install GCC 8.x and alias it to `gcc-8`. This alias will be created automatically if you install GCC via [Homebrew](https://brew.sh/) (`brew install gcc`). SDL2 must also be installed (`brew install sdl2`). After that, run `mac-build.sh`. 16 | - **Windows**: Visual Studio command line tools must be installed. If you don't have Visual Studio installed already, you can get an installer for the standalone build tools [here](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017). After that, run `win-build.bat` from the 64-bit developer command prompt. 17 | - **Advanced build (macOS only for now)**: In addition to GCC and SDL2, you will need to install ninja (`brew install ninja`). First, build bob via `bob/buid.sh`. This only needs to happen once. Then, run `build.sh` in the root of the repository for subsequent builds. 18 | 19 | Currently, only x86-64 CPUs are supported. GCC is used instead of clang on macOS because it produces slightly (around 10-20%) faster code than clang. Right now the renderer runs significantly (around 2x) slower on Windows, because MSVC does a poorer job of optimizing our particular code. I'll add an option for building with GCC on Windows soon. I will also try to get the advanced build working on Windows. 20 | 21 | ## Screenshots 22 | ![](https://i.imgur.com/lATL7sO.gif) 23 | ![](https://i.imgur.com/aFhFUMK.gif) 24 | ![](https://i.imgur.com/9QAmmLm.png) 25 | ![](https://i.imgur.com/p627VsA.png) 26 | -------------------------------------------------------------------------------- /SDL2/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL.h 24 | * 25 | * Main include header for the SDL library 26 | */ 27 | 28 | 29 | #ifndef SDL_h_ 30 | #define SDL_h_ 31 | 32 | #include "SDL_main.h" 33 | #include "SDL_stdinc.h" 34 | #include "SDL_assert.h" 35 | #include "SDL_atomic.h" 36 | #include "SDL_audio.h" 37 | #include "SDL_clipboard.h" 38 | #include "SDL_cpuinfo.h" 39 | #include "SDL_endian.h" 40 | #include "SDL_error.h" 41 | #include "SDL_events.h" 42 | #include "SDL_filesystem.h" 43 | #include "SDL_gamecontroller.h" 44 | #include "SDL_haptic.h" 45 | #include "SDL_hints.h" 46 | #include "SDL_joystick.h" 47 | #include "SDL_loadso.h" 48 | #include "SDL_log.h" 49 | #include "SDL_messagebox.h" 50 | #include "SDL_mutex.h" 51 | #include "SDL_power.h" 52 | #include "SDL_render.h" 53 | #include "SDL_rwops.h" 54 | #include "SDL_shape.h" 55 | #include "SDL_system.h" 56 | #include "SDL_thread.h" 57 | #include "SDL_timer.h" 58 | #include "SDL_version.h" 59 | #include "SDL_video.h" 60 | 61 | #include "begin_code.h" 62 | /* Set up for C function definitions, even when using C++ */ 63 | #ifdef __cplusplus 64 | extern "C" { 65 | #endif 66 | 67 | /* As of version 0.5, SDL is loaded dynamically into the application */ 68 | 69 | /** 70 | * \name SDL_INIT_* 71 | * 72 | * These are the flags which may be passed to SDL_Init(). You should 73 | * specify the subsystems which you will be using in your application. 74 | */ 75 | /* @{ */ 76 | #define SDL_INIT_TIMER 0x00000001u 77 | #define SDL_INIT_AUDIO 0x00000010u 78 | #define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ 79 | #define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ 80 | #define SDL_INIT_HAPTIC 0x00001000u 81 | #define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ 82 | #define SDL_INIT_EVENTS 0x00004000u 83 | #define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */ 84 | #define SDL_INIT_EVERYTHING ( \ 85 | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ 86 | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ 87 | ) 88 | /* @} */ 89 | 90 | /** 91 | * This function initializes the subsystems specified by \c flags 92 | */ 93 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 94 | 95 | /** 96 | * This function initializes specific SDL subsystems 97 | * 98 | * Subsystem initialization is ref-counted, you must call 99 | * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly 100 | * shutdown a subsystem manually (or call SDL_Quit() to force shutdown). 101 | * If a subsystem is already loaded then this call will 102 | * increase the ref-count and return. 103 | */ 104 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 105 | 106 | /** 107 | * This function cleans up specific SDL subsystems 108 | */ 109 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 110 | 111 | /** 112 | * This function returns a mask of the specified subsystems which have 113 | * previously been initialized. 114 | * 115 | * If \c flags is 0, it returns a mask of all initialized subsystems. 116 | */ 117 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 118 | 119 | /** 120 | * This function cleans up all initialized subsystems. You should 121 | * call it upon all exit conditions. 122 | */ 123 | extern DECLSPEC void SDLCALL SDL_Quit(void); 124 | 125 | /* Ends C function definitions when using C++ */ 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | #include "close_code.h" 130 | 131 | #endif /* SDL_h_ */ 132 | 133 | /* vi: set ts=4 sw=4 expandtab: */ 134 | -------------------------------------------------------------------------------- /SDL2/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef SDL_bits_h_ 29 | #define SDL_bits_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return Index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | #if defined(__WATCOMC__) && defined(__386__) 51 | extern _inline int _SDL_clz_watcom (Uint32); 52 | #pragma aux _SDL_clz_watcom = \ 53 | "bsr eax, eax" \ 54 | "xor eax, 31" \ 55 | parm [eax] nomemory \ 56 | value [eax] \ 57 | modify exact [eax] nomemory; 58 | #endif 59 | 60 | SDL_FORCE_INLINE int 61 | SDL_MostSignificantBitIndex32(Uint32 x) 62 | { 63 | #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 64 | /* Count Leading Zeroes builtin in GCC. 65 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 66 | */ 67 | if (x == 0) { 68 | return -1; 69 | } 70 | return 31 - __builtin_clz(x); 71 | #elif defined(__WATCOMC__) && defined(__386__) 72 | if (x == 0) { 73 | return -1; 74 | } 75 | return 31 - _SDL_clz_watcom(x); 76 | #else 77 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 78 | * , released in the public domain. 79 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 80 | */ 81 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 82 | const int S[] = {1, 2, 4, 8, 16}; 83 | 84 | int msbIndex = 0; 85 | int i; 86 | 87 | if (x == 0) { 88 | return -1; 89 | } 90 | 91 | for (i = 4; i >= 0; i--) 92 | { 93 | if (x & b[i]) 94 | { 95 | x >>= S[i]; 96 | msbIndex |= S[i]; 97 | } 98 | } 99 | 100 | return msbIndex; 101 | #endif 102 | } 103 | 104 | /* Ends C function definitions when using C++ */ 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | #include "close_code.h" 109 | 110 | #endif /* SDL_bits_h_ */ 111 | 112 | /* vi: set ts=4 sw=4 expandtab: */ 113 | -------------------------------------------------------------------------------- /SDL2/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef SDL_blendmode_h_ 29 | #define SDL_blendmode_h_ 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 39 | */ 40 | typedef enum 41 | { 42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending 43 | dstRGBA = srcRGBA */ 44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending 45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 46 | dstA = srcA + (dstA * (1-srcA)) */ 47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending 48 | dstRGB = (srcRGB * srcA) + dstRGB 49 | dstA = dstA */ 50 | SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate 51 | dstRGB = srcRGB * dstRGB 52 | dstA = dstA */ 53 | SDL_BLENDMODE_INVALID = 0x7FFFFFFF 54 | 55 | /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ 56 | 57 | } SDL_BlendMode; 58 | 59 | /** 60 | * \brief The blend operation used when combining source and destination pixel components 61 | */ 62 | typedef enum 63 | { 64 | SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ 65 | SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ 66 | SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ 67 | SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ 68 | SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ 69 | 70 | } SDL_BlendOperation; 71 | 72 | /** 73 | * \brief The normalized factor used to multiply pixel components 74 | */ 75 | typedef enum 76 | { 77 | SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ 78 | SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ 79 | SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ 80 | SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ 81 | SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ 82 | SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ 83 | SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ 84 | SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ 85 | SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ 86 | SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ 87 | 88 | } SDL_BlendFactor; 89 | 90 | /** 91 | * \brief Create a custom blend mode, which may or may not be supported by a given renderer 92 | * 93 | * \param srcColorFactor 94 | * \param dstColorFactor 95 | * \param colorOperation 96 | * \param srcAlphaFactor 97 | * \param dstAlphaFactor 98 | * \param alphaOperation 99 | * 100 | * The result of the blend mode operation will be: 101 | * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor 102 | * and 103 | * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor 104 | */ 105 | extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, 106 | SDL_BlendFactor dstColorFactor, 107 | SDL_BlendOperation colorOperation, 108 | SDL_BlendFactor srcAlphaFactor, 109 | SDL_BlendFactor dstAlphaFactor, 110 | SDL_BlendOperation alphaOperation); 111 | 112 | /* Ends C function definitions when using C++ */ 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | #include "close_code.h" 117 | 118 | #endif /* SDL_blendmode_h_ */ 119 | 120 | /* vi: set ts=4 sw=4 expandtab: */ 121 | -------------------------------------------------------------------------------- /SDL2/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef SDL_clipboard_h_ 29 | #define SDL_clipboard_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * \brief Put UTF-8 text into the clipboard 43 | * 44 | * \sa SDL_GetClipboardText() 45 | */ 46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 47 | 48 | /** 49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 50 | * 51 | * \sa SDL_SetClipboardText() 52 | */ 53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 54 | 55 | /** 56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty 57 | * 58 | * \sa SDL_GetClipboardText() 59 | */ 60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 61 | 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* SDL_clipboard_h_ */ 70 | 71 | /* vi: set ts=4 sw=4 expandtab: */ 72 | -------------------------------------------------------------------------------- /SDL2/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_h_ 23 | #define SDL_config_h_ 24 | 25 | #include "SDL_platform.h" 26 | 27 | /** 28 | * \file SDL_config.h 29 | */ 30 | 31 | /* Add any platform that doesn't build using the configure system. */ 32 | #if defined(__WIN32__) 33 | #include "SDL_config_windows.h" 34 | #elif defined(__WINRT__) 35 | #include "SDL_config_winrt.h" 36 | #elif defined(__MACOSX__) 37 | #include "SDL_config_macosx.h" 38 | #elif defined(__IPHONEOS__) 39 | #include "SDL_config_iphoneos.h" 40 | #elif defined(__ANDROID__) 41 | #include "SDL_config_android.h" 42 | #elif defined(__PSP__) 43 | #include "SDL_config_psp.h" 44 | #else 45 | /* This is a minimal configuration just to get SDL running on new platforms */ 46 | #include "SDL_config_minimal.h" 47 | #endif /* platform config */ 48 | 49 | #ifdef USING_GENERATED_CONFIG_H 50 | #error Wrong SDL_config.h, check your include path? 51 | #endif 52 | 53 | #endif /* SDL_config_h_ */ 54 | -------------------------------------------------------------------------------- /SDL2/SDL_config_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_android_h_ 23 | #define SDL_config_android_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /** 29 | * \file SDL_config_android.h 30 | * 31 | * This is a configuration that can be used to build SDL for Android 32 | */ 33 | 34 | #include 35 | 36 | #define HAVE_GCC_ATOMICS 1 37 | 38 | #define STDC_HEADERS 1 39 | #define HAVE_ALLOCA_H 1 40 | #define HAVE_CTYPE_H 1 41 | #define HAVE_INTTYPES_H 1 42 | #define HAVE_LIMITS_H 1 43 | #define HAVE_MATH_H 1 44 | #define HAVE_SIGNAL_H 1 45 | #define HAVE_STDINT_H 1 46 | #define HAVE_STDIO_H 1 47 | #define HAVE_STRING_H 1 48 | #define HAVE_SYS_TYPES_H 1 49 | 50 | /* C library functions */ 51 | #define HAVE_MALLOC 1 52 | #define HAVE_CALLOC 1 53 | #define HAVE_REALLOC 1 54 | #define HAVE_FREE 1 55 | #define HAVE_ALLOCA 1 56 | #define HAVE_GETENV 1 57 | #define HAVE_SETENV 1 58 | #define HAVE_PUTENV 1 59 | #define HAVE_SETENV 1 60 | #define HAVE_UNSETENV 1 61 | #define HAVE_QSORT 1 62 | #define HAVE_ABS 1 63 | #define HAVE_BCOPY 1 64 | #define HAVE_MEMSET 1 65 | #define HAVE_MEMCPY 1 66 | #define HAVE_MEMMOVE 1 67 | #define HAVE_MEMCMP 1 68 | #define HAVE_STRLEN 1 69 | #define HAVE_STRLCPY 1 70 | #define HAVE_STRLCAT 1 71 | #define HAVE_STRCHR 1 72 | #define HAVE_STRRCHR 1 73 | #define HAVE_STRSTR 1 74 | #define HAVE_STRTOL 1 75 | #define HAVE_STRTOUL 1 76 | #define HAVE_STRTOLL 1 77 | #define HAVE_STRTOULL 1 78 | #define HAVE_STRTOD 1 79 | #define HAVE_ATOI 1 80 | #define HAVE_ATOF 1 81 | #define HAVE_STRCMP 1 82 | #define HAVE_STRNCMP 1 83 | #define HAVE_STRCASECMP 1 84 | #define HAVE_STRNCASECMP 1 85 | #define HAVE_VSSCANF 1 86 | #define HAVE_VSNPRINTF 1 87 | #define HAVE_M_PI 1 88 | #define HAVE_ATAN 1 89 | #define HAVE_ATAN2 1 90 | #define HAVE_ACOS 1 91 | #define HAVE_ASIN 1 92 | #define HAVE_CEIL 1 93 | #define HAVE_COPYSIGN 1 94 | #define HAVE_COS 1 95 | #define HAVE_COSF 1 96 | #define HAVE_FABS 1 97 | #define HAVE_FLOOR 1 98 | #define HAVE_LOG 1 99 | #define HAVE_POW 1 100 | #define HAVE_SCALBN 1 101 | #define HAVE_SIN 1 102 | #define HAVE_SINF 1 103 | #define HAVE_SQRT 1 104 | #define HAVE_SQRTF 1 105 | #define HAVE_TAN 1 106 | #define HAVE_TANF 1 107 | #define HAVE_SIGACTION 1 108 | #define HAVE_SETJMP 1 109 | #define HAVE_NANOSLEEP 1 110 | #define HAVE_SYSCONF 1 111 | #define HAVE_CLOCK_GETTIME 1 112 | 113 | #define SIZEOF_VOIDP 4 114 | 115 | /* Enable various audio drivers */ 116 | #define SDL_AUDIO_DRIVER_ANDROID 1 117 | #define SDL_AUDIO_DRIVER_DUMMY 1 118 | 119 | /* Enable various input drivers */ 120 | #define SDL_JOYSTICK_ANDROID 1 121 | #define SDL_HAPTIC_ANDROID 1 122 | 123 | /* Enable various shared object loading systems */ 124 | #define SDL_LOADSO_DLOPEN 1 125 | 126 | /* Enable various threading systems */ 127 | #define SDL_THREAD_PTHREAD 1 128 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 129 | 130 | /* Enable various timer systems */ 131 | #define SDL_TIMER_UNIX 1 132 | 133 | /* Enable various video drivers */ 134 | #define SDL_VIDEO_DRIVER_ANDROID 1 135 | 136 | /* Enable OpenGL ES */ 137 | #define SDL_VIDEO_OPENGL_ES 1 138 | #define SDL_VIDEO_OPENGL_ES2 1 139 | #define SDL_VIDEO_OPENGL_EGL 1 140 | #define SDL_VIDEO_RENDER_OGL_ES 1 141 | #define SDL_VIDEO_RENDER_OGL_ES2 1 142 | 143 | /* Enable Vulkan support */ 144 | /* Android does not support Vulkan in native code using the "armeabi" ABI. */ 145 | #if defined(__ARM_ARCH) && __ARM_ARCH < 7 146 | #define SDL_VIDEO_VULKAN 0 147 | #else 148 | #define SDL_VIDEO_VULKAN 1 149 | #endif 150 | 151 | /* Enable system power support */ 152 | #define SDL_POWER_ANDROID 1 153 | 154 | /* Enable the filesystem driver */ 155 | #define SDL_FILESYSTEM_ANDROID 1 156 | 157 | #endif /* SDL_config_android_h_ */ 158 | -------------------------------------------------------------------------------- /SDL2/SDL_config_iphoneos.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_iphoneos_h_ 23 | #define SDL_config_iphoneos_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | #ifdef __LP64__ 29 | #define SIZEOF_VOIDP 8 30 | #else 31 | #define SIZEOF_VOIDP 4 32 | #endif 33 | 34 | #define HAVE_GCC_ATOMICS 1 35 | 36 | #define STDC_HEADERS 1 37 | #define HAVE_ALLOCA_H 1 38 | #define HAVE_CTYPE_H 1 39 | #define HAVE_INTTYPES_H 1 40 | #define HAVE_LIMITS_H 1 41 | #define HAVE_MATH_H 1 42 | #define HAVE_SIGNAL_H 1 43 | #define HAVE_STDINT_H 1 44 | #define HAVE_STDIO_H 1 45 | #define HAVE_STRING_H 1 46 | #define HAVE_SYS_TYPES_H 1 47 | #define HAVE_LIBUNWIND_H 1 48 | 49 | /* C library functions */ 50 | #define HAVE_MALLOC 1 51 | #define HAVE_CALLOC 1 52 | #define HAVE_REALLOC 1 53 | #define HAVE_FREE 1 54 | #define HAVE_ALLOCA 1 55 | #define HAVE_GETENV 1 56 | #define HAVE_SETENV 1 57 | #define HAVE_PUTENV 1 58 | #define HAVE_SETENV 1 59 | #define HAVE_UNSETENV 1 60 | #define HAVE_QSORT 1 61 | #define HAVE_ABS 1 62 | #define HAVE_BCOPY 1 63 | #define HAVE_MEMSET 1 64 | #define HAVE_MEMCPY 1 65 | #define HAVE_MEMMOVE 1 66 | #define HAVE_MEMCMP 1 67 | #define HAVE_STRLEN 1 68 | #define HAVE_STRLCPY 1 69 | #define HAVE_STRLCAT 1 70 | #define HAVE_STRCHR 1 71 | #define HAVE_STRRCHR 1 72 | #define HAVE_STRSTR 1 73 | #define HAVE_STRTOL 1 74 | #define HAVE_STRTOUL 1 75 | #define HAVE_STRTOLL 1 76 | #define HAVE_STRTOULL 1 77 | #define HAVE_STRTOD 1 78 | #define HAVE_ATOI 1 79 | #define HAVE_ATOF 1 80 | #define HAVE_STRCMP 1 81 | #define HAVE_STRNCMP 1 82 | #define HAVE_STRCASECMP 1 83 | #define HAVE_STRNCASECMP 1 84 | #define HAVE_VSSCANF 1 85 | #define HAVE_VSNPRINTF 1 86 | #define HAVE_M_PI 1 87 | #define HAVE_ATAN 1 88 | #define HAVE_ATAN2 1 89 | #define HAVE_ACOS 1 90 | #define HAVE_ASIN 1 91 | #define HAVE_CEIL 1 92 | #define HAVE_COPYSIGN 1 93 | #define HAVE_COS 1 94 | #define HAVE_COSF 1 95 | #define HAVE_FABS 1 96 | #define HAVE_FLOOR 1 97 | #define HAVE_LOG 1 98 | #define HAVE_POW 1 99 | #define HAVE_SCALBN 1 100 | #define HAVE_SIN 1 101 | #define HAVE_SINF 1 102 | #define HAVE_SQRT 1 103 | #define HAVE_SQRTF 1 104 | #define HAVE_TAN 1 105 | #define HAVE_TANF 1 106 | #define HAVE_SIGACTION 1 107 | #define HAVE_SETJMP 1 108 | #define HAVE_NANOSLEEP 1 109 | #define HAVE_SYSCONF 1 110 | #define HAVE_SYSCTLBYNAME 1 111 | 112 | /* enable iPhone version of Core Audio driver */ 113 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 114 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 115 | #define SDL_AUDIO_DRIVER_DUMMY 1 116 | 117 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 118 | #define SDL_HAPTIC_DUMMY 1 119 | 120 | /* Enable MFi joystick support */ 121 | #define SDL_JOYSTICK_MFI 1 122 | 123 | /* Enable Unix style SO loading */ 124 | #define SDL_LOADSO_DLOPEN 1 125 | 126 | /* Enable various threading systems */ 127 | #define SDL_THREAD_PTHREAD 1 128 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 129 | 130 | /* Enable various timer systems */ 131 | #define SDL_TIMER_UNIX 1 132 | 133 | /* Supported video drivers */ 134 | #define SDL_VIDEO_DRIVER_UIKIT 1 135 | #define SDL_VIDEO_DRIVER_DUMMY 1 136 | 137 | /* enable OpenGL ES */ 138 | #define SDL_VIDEO_OPENGL_ES2 1 139 | #define SDL_VIDEO_OPENGL_ES 1 140 | #define SDL_VIDEO_RENDER_OGL_ES 1 141 | #define SDL_VIDEO_RENDER_OGL_ES2 1 142 | 143 | /* Enable Vulkan support on 64-bit devices when an iOS 8+ SDK is used. */ 144 | #if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && defined(__IPHONE_8_0) 145 | #define SDL_VIDEO_VULKAN 1 146 | #else 147 | #define SDL_VIDEO_VULKAN 0 148 | #endif 149 | 150 | /* Enable system power support */ 151 | #define SDL_POWER_UIKIT 1 152 | 153 | /* enable iPhone keyboard support */ 154 | #define SDL_IPHONE_KEYBOARD 1 155 | 156 | /* enable iOS extended launch screen */ 157 | #define SDL_IPHONE_LAUNCHSCREEN 1 158 | 159 | /* Set max recognized G-force from accelerometer 160 | See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed 161 | */ 162 | #define SDL_IPHONE_MAX_GFORCE 5.0 163 | 164 | /* enable filesystem support */ 165 | #define SDL_FILESYSTEM_COCOA 1 166 | 167 | #endif /* SDL_config_iphoneos_h_ */ 168 | -------------------------------------------------------------------------------- /SDL2/SDL_config_macosx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_macosx_h_ 23 | #define SDL_config_macosx_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ 29 | #include 30 | 31 | /* This is a set of defines to configure the SDL features */ 32 | 33 | #ifdef __LP64__ 34 | #define SIZEOF_VOIDP 8 35 | #else 36 | #define SIZEOF_VOIDP 4 37 | #endif 38 | 39 | /* Useful headers */ 40 | #define STDC_HEADERS 1 41 | #define HAVE_ALLOCA_H 1 42 | #define HAVE_CTYPE_H 1 43 | #define HAVE_FLOAT_H 1 44 | #define HAVE_INTTYPES_H 1 45 | #define HAVE_LIMITS_H 1 46 | #define HAVE_MATH_H 1 47 | #define HAVE_SIGNAL_H 1 48 | #define HAVE_STDINT_H 1 49 | #define HAVE_STDIO_H 1 50 | #define HAVE_STRING_H 1 51 | #define HAVE_SYS_TYPES_H 1 52 | #define HAVE_LIBUNWIND_H 1 53 | 54 | /* C library functions */ 55 | #define HAVE_MALLOC 1 56 | #define HAVE_CALLOC 1 57 | #define HAVE_REALLOC 1 58 | #define HAVE_FREE 1 59 | #define HAVE_ALLOCA 1 60 | #define HAVE_GETENV 1 61 | #define HAVE_SETENV 1 62 | #define HAVE_PUTENV 1 63 | #define HAVE_UNSETENV 1 64 | #define HAVE_QSORT 1 65 | #define HAVE_ABS 1 66 | #define HAVE_BCOPY 1 67 | #define HAVE_MEMSET 1 68 | #define HAVE_MEMCPY 1 69 | #define HAVE_MEMMOVE 1 70 | #define HAVE_MEMCMP 1 71 | #define HAVE_STRLEN 1 72 | #define HAVE_STRLCPY 1 73 | #define HAVE_STRLCAT 1 74 | #define HAVE_STRCHR 1 75 | #define HAVE_STRRCHR 1 76 | #define HAVE_STRSTR 1 77 | #define HAVE_STRTOL 1 78 | #define HAVE_STRTOUL 1 79 | #define HAVE_STRTOLL 1 80 | #define HAVE_STRTOULL 1 81 | #define HAVE_STRTOD 1 82 | #define HAVE_ATOI 1 83 | #define HAVE_ATOF 1 84 | #define HAVE_STRCMP 1 85 | #define HAVE_STRNCMP 1 86 | #define HAVE_STRCASECMP 1 87 | #define HAVE_STRNCASECMP 1 88 | #define HAVE_VSSCANF 1 89 | #define HAVE_VSNPRINTF 1 90 | #define HAVE_CEIL 1 91 | #define HAVE_COPYSIGN 1 92 | #define HAVE_COS 1 93 | #define HAVE_COSF 1 94 | #define HAVE_FABS 1 95 | #define HAVE_FLOOR 1 96 | #define HAVE_LOG 1 97 | #define HAVE_POW 1 98 | #define HAVE_SCALBN 1 99 | #define HAVE_SIN 1 100 | #define HAVE_SINF 1 101 | #define HAVE_SQRT 1 102 | #define HAVE_SQRTF 1 103 | #define HAVE_TAN 1 104 | #define HAVE_TANF 1 105 | #define HAVE_SIGACTION 1 106 | #define HAVE_SETJMP 1 107 | #define HAVE_NANOSLEEP 1 108 | #define HAVE_SYSCONF 1 109 | #define HAVE_SYSCTLBYNAME 1 110 | #define HAVE_ATAN 1 111 | #define HAVE_ATAN2 1 112 | #define HAVE_ACOS 1 113 | #define HAVE_ASIN 1 114 | 115 | /* Enable various audio drivers */ 116 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 117 | #define SDL_AUDIO_DRIVER_DISK 1 118 | #define SDL_AUDIO_DRIVER_DUMMY 1 119 | 120 | /* Enable various input drivers */ 121 | #define SDL_JOYSTICK_IOKIT 1 122 | #define SDL_HAPTIC_IOKIT 1 123 | 124 | /* Enable various shared object loading systems */ 125 | #define SDL_LOADSO_DLOPEN 1 126 | 127 | /* Enable various threading systems */ 128 | #define SDL_THREAD_PTHREAD 1 129 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 130 | 131 | /* Enable various timer systems */ 132 | #define SDL_TIMER_UNIX 1 133 | 134 | /* Enable various video drivers */ 135 | #define SDL_VIDEO_DRIVER_COCOA 1 136 | #define SDL_VIDEO_DRIVER_DUMMY 1 137 | #undef SDL_VIDEO_DRIVER_X11 138 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" 139 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" 140 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" 141 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" 142 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" 143 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" 144 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" 145 | #define SDL_VIDEO_DRIVER_X11_XDBE 1 146 | #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 147 | #define SDL_VIDEO_DRIVER_X11_XRANDR 1 148 | #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 149 | #define SDL_VIDEO_DRIVER_X11_XSHAPE 1 150 | #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 151 | #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 152 | 153 | #ifdef MAC_OS_X_VERSION_10_8 154 | /* 155 | * No matter the versions targeted, this is the 10.8 or later SDK, so you have 156 | * to use the external Xquartz, which is a more modern Xlib. Previous SDKs 157 | * used an older Xlib. 158 | */ 159 | #define SDL_VIDEO_DRIVER_X11_XINPUT2 1 160 | #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 161 | #define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 162 | #endif 163 | 164 | #ifndef SDL_VIDEO_RENDER_OGL 165 | #define SDL_VIDEO_RENDER_OGL 1 166 | #endif 167 | 168 | /* Enable OpenGL support */ 169 | #ifndef SDL_VIDEO_OPENGL 170 | #define SDL_VIDEO_OPENGL 1 171 | #endif 172 | #ifndef SDL_VIDEO_OPENGL_CGL 173 | #define SDL_VIDEO_OPENGL_CGL 1 174 | #endif 175 | #ifndef SDL_VIDEO_OPENGL_GLX 176 | #define SDL_VIDEO_OPENGL_GLX 1 177 | #endif 178 | 179 | /* Enable Vulkan support */ 180 | /* Metal/MoltenVK/Vulkan only supported on 64-bit architectures with 10.11+ */ 181 | #if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) 182 | #define SDL_VIDEO_VULKAN 1 183 | #else 184 | #define SDL_VIDEO_VULKAN 0 185 | #endif 186 | 187 | /* Enable system power support */ 188 | #define SDL_POWER_MACOSX 1 189 | 190 | /* enable filesystem support */ 191 | #define SDL_FILESYSTEM_COCOA 1 192 | 193 | /* Enable assembly routines */ 194 | #define SDL_ASSEMBLY_ROUTINES 1 195 | #ifdef __ppc__ 196 | #define SDL_ALTIVEC_BLITTERS 1 197 | #endif 198 | 199 | #endif /* SDL_config_macosx_h_ */ 200 | -------------------------------------------------------------------------------- /SDL2/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_minimal_h_ 23 | #define SDL_config_minimal_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /** 29 | * \file SDL_config_minimal.h 30 | * 31 | * This is the minimal configuration that can be used to build SDL. 32 | */ 33 | 34 | #define HAVE_STDARG_H 1 35 | #define HAVE_STDDEF_H 1 36 | 37 | /* Most everything except Visual Studio 2008 and earlier has stdint.h now */ 38 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 39 | /* Here are some reasonable defaults */ 40 | typedef unsigned int size_t; 41 | typedef signed char int8_t; 42 | typedef unsigned char uint8_t; 43 | typedef signed short int16_t; 44 | typedef unsigned short uint16_t; 45 | typedef signed int int32_t; 46 | typedef unsigned int uint32_t; 47 | typedef signed long long int64_t; 48 | typedef unsigned long long uint64_t; 49 | typedef unsigned long uintptr_t; 50 | #else 51 | #define HAVE_STDINT_H 1 52 | #endif /* Visual Studio 2008 */ 53 | 54 | #ifdef __GNUC__ 55 | #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 56 | #endif 57 | 58 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 59 | #define SDL_AUDIO_DRIVER_DUMMY 1 60 | 61 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 62 | #define SDL_JOYSTICK_DISABLED 1 63 | 64 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 65 | #define SDL_HAPTIC_DISABLED 1 66 | 67 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 68 | #define SDL_LOADSO_DISABLED 1 69 | 70 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 71 | #define SDL_THREADS_DISABLED 1 72 | 73 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 74 | #define SDL_TIMERS_DISABLED 1 75 | 76 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 77 | #define SDL_VIDEO_DRIVER_DUMMY 1 78 | 79 | /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ 80 | #define SDL_FILESYSTEM_DUMMY 1 81 | 82 | #endif /* SDL_config_minimal_h_ */ 83 | -------------------------------------------------------------------------------- /SDL2/SDL_config_pandora.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_pandora_h_ 23 | #define SDL_config_pandora_h_ 24 | #define SDL_config_h_ 25 | 26 | /* This is a set of defines to configure the SDL features */ 27 | 28 | /* General platform specific identifiers */ 29 | #include "SDL_platform.h" 30 | 31 | #ifdef __LP64__ 32 | #define SIZEOF_VOIDP 8 33 | #else 34 | #define SIZEOF_VOIDP 4 35 | #endif 36 | 37 | #define SDL_BYTEORDER 1234 38 | 39 | #define STDC_HEADERS 1 40 | #define HAVE_ALLOCA_H 1 41 | #define HAVE_CTYPE_H 1 42 | #define HAVE_ICONV_H 1 43 | #define HAVE_INTTYPES_H 1 44 | #define HAVE_LIMITS_H 1 45 | #define HAVE_MALLOC_H 1 46 | #define HAVE_MATH_H 1 47 | #define HAVE_MEMORY_H 1 48 | #define HAVE_SIGNAL_H 1 49 | #define HAVE_STDARG_H 1 50 | #define HAVE_STDINT_H 1 51 | #define HAVE_STDIO_H 1 52 | #define HAVE_STDLIB_H 1 53 | #define HAVE_STRINGS_H 1 54 | #define HAVE_STRING_H 1 55 | #define HAVE_SYS_TYPES_H 1 56 | 57 | #define HAVE_MALLOC 1 58 | #define HAVE_CALLOC 1 59 | #define HAVE_REALLOC 1 60 | #define HAVE_FREE 1 61 | #define HAVE_ALLOCA 1 62 | #define HAVE_GETENV 1 63 | #define HAVE_SETENV 1 64 | #define HAVE_PUTENV 1 65 | #define HAVE_UNSETENV 1 66 | #define HAVE_QSORT 1 67 | #define HAVE_ABS 1 68 | #define HAVE_BCOPY 1 69 | #define HAVE_MEMSET 1 70 | #define HAVE_MEMCPY 1 71 | #define HAVE_MEMMOVE 1 72 | #define HAVE_STRLEN 1 73 | #define HAVE_STRCHR 1 74 | #define HAVE_STRRCHR 1 75 | #define HAVE_STRSTR 1 76 | #define HAVE_STRTOL 1 77 | #define HAVE_STRTOUL 1 78 | #define HAVE_STRTOLL 1 79 | #define HAVE_STRTOULL 1 80 | #define HAVE_ATOI 1 81 | #define HAVE_ATOF 1 82 | #define HAVE_STRCMP 1 83 | #define HAVE_STRNCMP 1 84 | #define HAVE_STRCASECMP 1 85 | #define HAVE_STRNCASECMP 1 86 | #define HAVE_VSSCANF 1 87 | #define HAVE_VSNPRINTF 1 88 | #define HAVE_M_PI 1 89 | #define HAVE_CEIL 1 90 | #define HAVE_COPYSIGN 1 91 | #define HAVE_COS 1 92 | #define HAVE_COSF 1 93 | #define HAVE_FABS 1 94 | #define HAVE_FLOOR 1 95 | #define HAVE_LOG 1 96 | #define HAVE_SCALBN 1 97 | #define HAVE_SIN 1 98 | #define HAVE_SINF 1 99 | #define HAVE_SQRT 1 100 | #define HAVE_SQRTF 1 101 | #define HAVE_TAN 1 102 | #define HAVE_TANF 1 103 | #define HAVE_SIGACTION 1 104 | #define HAVE_SETJMP 1 105 | #define HAVE_NANOSLEEP 1 106 | 107 | #define SDL_AUDIO_DRIVER_DUMMY 1 108 | #define SDL_AUDIO_DRIVER_OSS 1 109 | 110 | #define SDL_INPUT_LINUXEV 1 111 | #define SDL_INPUT_TSLIB 1 112 | #define SDL_JOYSTICK_LINUX 1 113 | #define SDL_HAPTIC_LINUX 1 114 | 115 | #define SDL_LOADSO_DLOPEN 1 116 | 117 | #define SDL_THREAD_PTHREAD 1 118 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 119 | 120 | #define SDL_TIMER_UNIX 1 121 | #define SDL_FILESYSTEM_UNIX 1 122 | 123 | #define SDL_VIDEO_DRIVER_DUMMY 1 124 | #define SDL_VIDEO_DRIVER_X11 1 125 | #define SDL_VIDEO_DRIVER_PANDORA 1 126 | #define SDL_VIDEO_RENDER_OGL_ES 1 127 | #define SDL_VIDEO_OPENGL_ES 1 128 | 129 | #endif /* SDL_config_pandora_h_ */ 130 | -------------------------------------------------------------------------------- /SDL2/SDL_config_psp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_psp_h_ 23 | #define SDL_config_psp_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | 29 | 30 | #ifdef __GNUC__ 31 | #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 32 | #endif 33 | 34 | #define HAVE_GCC_ATOMICS 1 35 | 36 | #define STDC_HEADERS 1 37 | #define HAVE_ALLOCA_H 1 38 | #define HAVE_CTYPE_H 1 39 | #define HAVE_INTTYPES_H 1 40 | #define HAVE_LIMITS_H 1 41 | #define HAVE_MATH_H 1 42 | #define HAVE_SIGNAL_H 1 43 | #define HAVE_STDINT_H 1 44 | #define HAVE_STDIO_H 1 45 | #define HAVE_STRING_H 1 46 | #define HAVE_SYS_TYPES_H 1 47 | 48 | /* C library functions */ 49 | #define HAVE_MALLOC 1 50 | #define HAVE_CALLOC 1 51 | #define HAVE_REALLOC 1 52 | #define HAVE_FREE 1 53 | #define HAVE_ALLOCA 1 54 | #define HAVE_GETENV 1 55 | #define HAVE_SETENV 1 56 | #define HAVE_PUTENV 1 57 | #define HAVE_SETENV 1 58 | #define HAVE_UNSETENV 1 59 | #define HAVE_QSORT 1 60 | #define HAVE_ABS 1 61 | #define HAVE_BCOPY 1 62 | #define HAVE_MEMSET 1 63 | #define HAVE_MEMCPY 1 64 | #define HAVE_MEMMOVE 1 65 | #define HAVE_MEMCMP 1 66 | #define HAVE_STRLEN 1 67 | #define HAVE_STRLCPY 1 68 | #define HAVE_STRLCAT 1 69 | #define HAVE_STRCHR 1 70 | #define HAVE_STRRCHR 1 71 | #define HAVE_STRSTR 1 72 | #define HAVE_STRTOL 1 73 | #define HAVE_STRTOUL 1 74 | #define HAVE_STRTOLL 1 75 | #define HAVE_STRTOULL 1 76 | #define HAVE_STRTOD 1 77 | #define HAVE_ATOI 1 78 | #define HAVE_ATOF 1 79 | #define HAVE_STRCMP 1 80 | #define HAVE_STRNCMP 1 81 | #define HAVE_STRCASECMP 1 82 | #define HAVE_STRNCASECMP 1 83 | #define HAVE_VSSCANF 1 84 | #define HAVE_VSNPRINTF 1 85 | #define HAVE_M_PI 1 86 | #define HAVE_ATAN 1 87 | #define HAVE_ATAN2 1 88 | #define HAVE_ACOS 1 89 | #define HAVE_ASIN 1 90 | #define HAVE_CEIL 1 91 | #define HAVE_COPYSIGN 1 92 | #define HAVE_COS 1 93 | #define HAVE_COSF 1 94 | #define HAVE_FABS 1 95 | #define HAVE_FLOOR 1 96 | #define HAVE_LOG 1 97 | #define HAVE_POW 1 98 | #define HAVE_SCALBN 1 99 | #define HAVE_SIN 1 100 | #define HAVE_SINF 1 101 | #define HAVE_SQRT 1 102 | #define HAVE_SQRTF 1 103 | #define HAVE_TAN 1 104 | #define HAVE_TANF 1 105 | #define HAVE_SETJMP 1 106 | #define HAVE_NANOSLEEP 1 107 | /* #define HAVE_SYSCONF 1 */ 108 | /* #define HAVE_SIGACTION 1 */ 109 | 110 | 111 | /* PSP isn't that sophisticated */ 112 | #define LACKS_SYS_MMAN_H 1 113 | 114 | /* Enable the stub thread support (src/thread/psp/\*.c) */ 115 | #define SDL_THREAD_PSP 1 116 | 117 | /* Enable the stub timer support (src/timer/psp/\*.c) */ 118 | #define SDL_TIMERS_PSP 1 119 | 120 | /* Enable the stub joystick driver (src/joystick/psp/\*.c) */ 121 | #define SDL_JOYSTICK_PSP 1 122 | 123 | /* Enable the stub audio driver (src/audio/psp/\*.c) */ 124 | #define SDL_AUDIO_DRIVER_PSP 1 125 | 126 | /* PSP video dirver */ 127 | #define SDL_VIDEO_DRIVER_PSP 1 128 | 129 | /* PSP render dirver */ 130 | #define SDL_VIDEO_RENDER_PSP 1 131 | 132 | #define SDL_POWER_PSP 1 133 | 134 | /* !!! FIXME: what does PSP do for filesystem stuff? */ 135 | #define SDL_FILESYSTEM_DUMMY 1 136 | 137 | /* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ 138 | #define SDL_HAPTIC_DISABLED 1 139 | 140 | /* PSP can't load shared object (src/loadso/dummy/\*.c) */ 141 | #define SDL_LOADSO_DISABLED 1 142 | 143 | 144 | #endif /* SDL_config_psp_h_ */ 145 | -------------------------------------------------------------------------------- /SDL2/SDL_config_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_windows_h_ 23 | #define SDL_config_windows_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 31 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 32 | #define HAVE_STDINT_H 1 33 | #elif defined(_MSC_VER) 34 | typedef signed __int8 int8_t; 35 | typedef unsigned __int8 uint8_t; 36 | typedef signed __int16 int16_t; 37 | typedef unsigned __int16 uint16_t; 38 | typedef signed __int32 int32_t; 39 | typedef unsigned __int32 uint32_t; 40 | typedef signed __int64 int64_t; 41 | typedef unsigned __int64 uint64_t; 42 | #ifndef _UINTPTR_T_DEFINED 43 | #ifdef _WIN64 44 | typedef unsigned __int64 uintptr_t; 45 | #else 46 | typedef unsigned int uintptr_t; 47 | #endif 48 | #define _UINTPTR_T_DEFINED 49 | #endif 50 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 51 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 52 | #define DWORD_PTR DWORD 53 | #endif 54 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 55 | #define LONG_PTR LONG 56 | #endif 57 | #else /* !__GNUC__ && !_MSC_VER */ 58 | typedef signed char int8_t; 59 | typedef unsigned char uint8_t; 60 | typedef signed short int16_t; 61 | typedef unsigned short uint16_t; 62 | typedef signed int int32_t; 63 | typedef unsigned int uint32_t; 64 | typedef signed long long int64_t; 65 | typedef unsigned long long uint64_t; 66 | #ifndef _SIZE_T_DEFINED_ 67 | #define _SIZE_T_DEFINED_ 68 | typedef unsigned int size_t; 69 | #endif 70 | typedef unsigned int uintptr_t; 71 | #endif /* __GNUC__ || _MSC_VER */ 72 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 73 | 74 | #ifdef _WIN64 75 | # define SIZEOF_VOIDP 8 76 | #else 77 | # define SIZEOF_VOIDP 4 78 | #endif 79 | 80 | #define HAVE_DDRAW_H 1 81 | #define HAVE_DINPUT_H 1 82 | #define HAVE_DSOUND_H 1 83 | #define HAVE_DXGI_H 1 84 | #define HAVE_XINPUT_H 1 85 | 86 | /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ 87 | #ifdef HAVE_LIBC 88 | /* Useful headers */ 89 | #define STDC_HEADERS 1 90 | #define HAVE_CTYPE_H 1 91 | #define HAVE_FLOAT_H 1 92 | #define HAVE_LIMITS_H 1 93 | #define HAVE_MATH_H 1 94 | #define HAVE_SIGNAL_H 1 95 | #define HAVE_STDIO_H 1 96 | #define HAVE_STRING_H 1 97 | 98 | /* C library functions */ 99 | #define HAVE_MALLOC 1 100 | #define HAVE_CALLOC 1 101 | #define HAVE_REALLOC 1 102 | #define HAVE_FREE 1 103 | #define HAVE_ALLOCA 1 104 | #define HAVE_QSORT 1 105 | #define HAVE_ABS 1 106 | #define HAVE_MEMSET 1 107 | #define HAVE_MEMCPY 1 108 | #define HAVE_MEMMOVE 1 109 | #define HAVE_MEMCMP 1 110 | #define HAVE_STRLEN 1 111 | #define HAVE__STRREV 1 112 | #define HAVE__STRUPR 1 113 | #define HAVE__STRLWR 1 114 | #define HAVE_STRCHR 1 115 | #define HAVE_STRRCHR 1 116 | #define HAVE_STRSTR 1 117 | #define HAVE__LTOA 1 118 | #define HAVE__ULTOA 1 119 | #define HAVE_STRTOL 1 120 | #define HAVE_STRTOUL 1 121 | #define HAVE_STRTOD 1 122 | #define HAVE_ATOI 1 123 | #define HAVE_ATOF 1 124 | #define HAVE_STRCMP 1 125 | #define HAVE_STRNCMP 1 126 | #define HAVE__STRICMP 1 127 | #define HAVE__STRNICMP 1 128 | #define HAVE_ATAN 1 129 | #define HAVE_ATAN2 1 130 | #define HAVE_ACOS 1 131 | #define HAVE_ASIN 1 132 | #define HAVE_CEIL 1 133 | #define HAVE_COS 1 134 | #define HAVE_COSF 1 135 | #define HAVE_FABS 1 136 | #define HAVE_FLOOR 1 137 | #define HAVE_LOG 1 138 | #define HAVE_POW 1 139 | #define HAVE_SIN 1 140 | #define HAVE_SINF 1 141 | #define HAVE_SQRT 1 142 | #define HAVE_SQRTF 1 143 | #define HAVE_TAN 1 144 | #define HAVE_TANF 1 145 | #define HAVE__COPYSIGN 1 146 | #if defined(_MSC_VER) 147 | /* These functions were added with the VC++ 2013 C runtime library */ 148 | #if _MSC_VER >= 1800 149 | #define HAVE_STRTOLL 1 150 | #define HAVE_VSSCANF 1 151 | #define HAVE_SCALBN 1 152 | #endif 153 | /* This function is available with at least the VC++ 2008 C runtime library */ 154 | #if _MSC_VER >= 1400 155 | #define HAVE__FSEEKI64 1 156 | #endif 157 | #endif 158 | #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) 159 | #define HAVE_M_PI 1 160 | #endif 161 | #else 162 | #define HAVE_STDARG_H 1 163 | #define HAVE_STDDEF_H 1 164 | #endif 165 | 166 | /* Enable various audio drivers */ 167 | #define SDL_AUDIO_DRIVER_WASAPI 1 168 | #define SDL_AUDIO_DRIVER_DSOUND 1 169 | #define SDL_AUDIO_DRIVER_XAUDIO2 0 170 | #define SDL_AUDIO_DRIVER_WINMM 1 171 | #define SDL_AUDIO_DRIVER_DISK 1 172 | #define SDL_AUDIO_DRIVER_DUMMY 1 173 | 174 | /* Enable various input drivers */ 175 | #define SDL_JOYSTICK_DINPUT 1 176 | #define SDL_JOYSTICK_XINPUT 1 177 | #define SDL_HAPTIC_DINPUT 1 178 | #define SDL_HAPTIC_XINPUT 1 179 | 180 | /* Enable various shared object loading systems */ 181 | #define SDL_LOADSO_WINDOWS 1 182 | 183 | /* Enable various threading systems */ 184 | #define SDL_THREAD_WINDOWS 1 185 | 186 | /* Enable various timer systems */ 187 | #define SDL_TIMER_WINDOWS 1 188 | 189 | /* Enable various video drivers */ 190 | #define SDL_VIDEO_DRIVER_DUMMY 1 191 | #define SDL_VIDEO_DRIVER_WINDOWS 1 192 | 193 | #ifndef SDL_VIDEO_RENDER_D3D 194 | #define SDL_VIDEO_RENDER_D3D 1 195 | #endif 196 | #ifndef SDL_VIDEO_RENDER_D3D11 197 | #define SDL_VIDEO_RENDER_D3D11 0 198 | #endif 199 | 200 | /* Enable OpenGL support */ 201 | #ifndef SDL_VIDEO_OPENGL 202 | #define SDL_VIDEO_OPENGL 1 203 | #endif 204 | #ifndef SDL_VIDEO_OPENGL_WGL 205 | #define SDL_VIDEO_OPENGL_WGL 1 206 | #endif 207 | #ifndef SDL_VIDEO_RENDER_OGL 208 | #define SDL_VIDEO_RENDER_OGL 1 209 | #endif 210 | #ifndef SDL_VIDEO_RENDER_OGL_ES2 211 | #define SDL_VIDEO_RENDER_OGL_ES2 1 212 | #endif 213 | #ifndef SDL_VIDEO_OPENGL_ES2 214 | #define SDL_VIDEO_OPENGL_ES2 1 215 | #endif 216 | #ifndef SDL_VIDEO_OPENGL_EGL 217 | #define SDL_VIDEO_OPENGL_EGL 1 218 | #endif 219 | 220 | /* Enable Vulkan support */ 221 | #define SDL_VIDEO_VULKAN 1 222 | 223 | /* Enable system power support */ 224 | #define SDL_POWER_WINDOWS 1 225 | 226 | /* Enable filesystem support */ 227 | #define SDL_FILESYSTEM_WINDOWS 1 228 | 229 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 230 | #ifndef _WIN64 231 | #define SDL_ASSEMBLY_ROUTINES 1 232 | #endif 233 | 234 | #endif /* SDL_config_windows_h_ */ 235 | -------------------------------------------------------------------------------- /SDL2/SDL_config_winrt.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_winrt_h_ 23 | #define SDL_config_winrt_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* Make sure the Windows SDK's NTDDI_VERSION macro gets defined. This is used 29 | by SDL to determine which version of the Windows SDK is being used. 30 | */ 31 | #include 32 | 33 | /* Define possibly-undefined NTDDI values (used when compiling SDL against 34 | older versions of the Windows SDK. 35 | */ 36 | #ifndef NTDDI_WINBLUE 37 | #define NTDDI_WINBLUE 0x06030000 38 | #endif 39 | #ifndef NTDDI_WIN10 40 | #define NTDDI_WIN10 0x0A000000 41 | #endif 42 | 43 | /* This is a set of defines to configure the SDL features */ 44 | 45 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 46 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 47 | #define HAVE_STDINT_H 1 48 | #elif defined(_MSC_VER) 49 | typedef signed __int8 int8_t; 50 | typedef unsigned __int8 uint8_t; 51 | typedef signed __int16 int16_t; 52 | typedef unsigned __int16 uint16_t; 53 | typedef signed __int32 int32_t; 54 | typedef unsigned __int32 uint32_t; 55 | typedef signed __int64 int64_t; 56 | typedef unsigned __int64 uint64_t; 57 | #ifndef _UINTPTR_T_DEFINED 58 | #ifdef _WIN64 59 | typedef unsigned __int64 uintptr_t; 60 | #else 61 | typedef unsigned int uintptr_t; 62 | #endif 63 | #define _UINTPTR_T_DEFINED 64 | #endif 65 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 66 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 67 | #define DWORD_PTR DWORD 68 | #endif 69 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 70 | #define LONG_PTR LONG 71 | #endif 72 | #else /* !__GNUC__ && !_MSC_VER */ 73 | typedef signed char int8_t; 74 | typedef unsigned char uint8_t; 75 | typedef signed short int16_t; 76 | typedef unsigned short uint16_t; 77 | typedef signed int int32_t; 78 | typedef unsigned int uint32_t; 79 | typedef signed long long int64_t; 80 | typedef unsigned long long uint64_t; 81 | #ifndef _SIZE_T_DEFINED_ 82 | #define _SIZE_T_DEFINED_ 83 | typedef unsigned int size_t; 84 | #endif 85 | typedef unsigned int uintptr_t; 86 | #endif /* __GNUC__ || _MSC_VER */ 87 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 88 | 89 | #ifdef _WIN64 90 | # define SIZEOF_VOIDP 8 91 | #else 92 | # define SIZEOF_VOIDP 4 93 | #endif 94 | 95 | /* Useful headers */ 96 | #define HAVE_DXGI_H 1 97 | #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP 98 | #define HAVE_XINPUT_H 1 99 | #endif 100 | #define HAVE_LIBC 1 101 | #define STDC_HEADERS 1 102 | #define HAVE_CTYPE_H 1 103 | #define HAVE_FLOAT_H 1 104 | #define HAVE_LIMITS_H 1 105 | #define HAVE_MATH_H 1 106 | #define HAVE_SIGNAL_H 1 107 | #define HAVE_STDIO_H 1 108 | #define HAVE_STRING_H 1 109 | 110 | /* C library functions */ 111 | #define HAVE_MALLOC 1 112 | #define HAVE_CALLOC 1 113 | #define HAVE_REALLOC 1 114 | #define HAVE_FREE 1 115 | #define HAVE_ALLOCA 1 116 | #define HAVE_QSORT 1 117 | #define HAVE_ABS 1 118 | #define HAVE_MEMSET 1 119 | #define HAVE_MEMCPY 1 120 | #define HAVE_MEMMOVE 1 121 | #define HAVE_MEMCMP 1 122 | #define HAVE_STRLEN 1 123 | #define HAVE__STRREV 1 124 | #define HAVE__STRUPR 1 125 | //#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead 126 | #define HAVE_STRCHR 1 127 | #define HAVE_STRRCHR 1 128 | #define HAVE_STRSTR 1 129 | //#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead 130 | //#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead 131 | //#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead 132 | #define HAVE_STRTOL 1 133 | #define HAVE_STRTOUL 1 134 | //#define HAVE_STRTOLL 1 135 | #define HAVE_STRTOD 1 136 | #define HAVE_ATOI 1 137 | #define HAVE_ATOF 1 138 | #define HAVE_STRCMP 1 139 | #define HAVE_STRNCMP 1 140 | #define HAVE__STRICMP 1 141 | #define HAVE__STRNICMP 1 142 | #define HAVE_VSNPRINTF 1 143 | //#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead 144 | #define HAVE_M_PI 1 145 | #define HAVE_ATAN 1 146 | #define HAVE_ATAN2 1 147 | #define HAVE_CEIL 1 148 | #define HAVE__COPYSIGN 1 149 | #define HAVE_COS 1 150 | #define HAVE_COSF 1 151 | #define HAVE_FABS 1 152 | #define HAVE_FLOOR 1 153 | #define HAVE_LOG 1 154 | #define HAVE_POW 1 155 | //#define HAVE_SCALBN 1 156 | #define HAVE__SCALB 1 157 | #define HAVE_SIN 1 158 | #define HAVE_SINF 1 159 | #define HAVE_SQRT 1 160 | #define HAVE_SQRTF 1 161 | #define HAVE_TAN 1 162 | #define HAVE_TANF 1 163 | #define HAVE__FSEEKI64 1 164 | 165 | /* Enable various audio drivers */ 166 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 167 | #define SDL_AUDIO_DRIVER_DISK 1 168 | #define SDL_AUDIO_DRIVER_DUMMY 1 169 | 170 | /* Enable various input drivers */ 171 | #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 172 | #define SDL_JOYSTICK_DISABLED 1 173 | #define SDL_HAPTIC_DISABLED 1 174 | #else 175 | #define SDL_JOYSTICK_XINPUT 1 176 | #define SDL_HAPTIC_XINPUT 1 177 | #endif 178 | 179 | /* Enable various shared object loading systems */ 180 | #define SDL_LOADSO_WINDOWS 1 181 | 182 | /* Enable various threading systems */ 183 | #if (NTDDI_VERSION >= NTDDI_WINBLUE) 184 | #define SDL_THREAD_WINDOWS 1 185 | #else 186 | /* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */ 187 | #define SDL_THREAD_STDCPP 1 188 | #endif 189 | 190 | /* Enable various timer systems */ 191 | #define SDL_TIMER_WINDOWS 1 192 | 193 | /* Enable various video drivers */ 194 | #define SDL_VIDEO_DRIVER_WINRT 1 195 | #define SDL_VIDEO_DRIVER_DUMMY 1 196 | 197 | /* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ 198 | #define SDL_VIDEO_OPENGL_ES2 1 199 | #define SDL_VIDEO_OPENGL_EGL 1 200 | 201 | /* Enable appropriate renderer(s) */ 202 | #define SDL_VIDEO_RENDER_D3D11 1 203 | 204 | #if SDL_VIDEO_OPENGL_ES2 205 | #define SDL_VIDEO_RENDER_OGL_ES2 1 206 | #endif 207 | 208 | /* Enable system power support */ 209 | #define SDL_POWER_WINRT 1 210 | 211 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 212 | #ifndef _WIN64 213 | #define SDL_ASSEMBLY_ROUTINES 1 214 | #endif 215 | 216 | #endif /* SDL_config_winrt_h_ */ 217 | -------------------------------------------------------------------------------- /SDL2/SDL_config_wiz.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_wiz_h_ 23 | #define SDL_config_wiz_h_ 24 | #define SDL_config_h_ 25 | 26 | /* This is a set of defines to configure the SDL features */ 27 | 28 | /* General platform specific identifiers */ 29 | #include "SDL_platform.h" 30 | 31 | #define SDL_BYTEORDER 1234 32 | 33 | #define STDC_HEADERS 1 34 | #define HAVE_ALLOCA_H 1 35 | #define HAVE_CTYPE_H 1 36 | #define HAVE_ICONV_H 1 37 | #define HAVE_INTTYPES_H 1 38 | #define HAVE_LIMITS_H 1 39 | #define HAVE_MALLOC_H 1 40 | #define HAVE_MATH_H 1 41 | #define HAVE_MEMORY_H 1 42 | #define HAVE_SIGNAL_H 1 43 | #define HAVE_STDARG_H 1 44 | #define HAVE_STDINT_H 1 45 | #define HAVE_STDIO_H 1 46 | #define HAVE_STDLIB_H 1 47 | #define HAVE_STRINGS_H 1 48 | #define HAVE_STRING_H 1 49 | #define HAVE_SYS_TYPES_H 1 50 | 51 | #define HAVE_MALLOC 1 52 | #define HAVE_CALLOC 1 53 | #define HAVE_REALLOC 1 54 | #define HAVE_FREE 1 55 | #define HAVE_ALLOCA 1 56 | #define HAVE_GETENV 1 57 | #define HAVE_SETENV 1 58 | #define HAVE_PUTENV 1 59 | #define HAVE_UNSETENV 1 60 | #define HAVE_QSORT 1 61 | #define HAVE_ABS 1 62 | #define HAVE_BCOPY 1 63 | #define HAVE_MEMSET 1 64 | #define HAVE_MEMCPY 1 65 | #define HAVE_MEMMOVE 1 66 | #define HAVE_STRLEN 1 67 | #define HAVE_STRCHR 1 68 | #define HAVE_STRRCHR 1 69 | #define HAVE_STRSTR 1 70 | #define HAVE_STRTOL 1 71 | #define HAVE_STRTOUL 1 72 | #define HAVE_STRTOLL 1 73 | #define HAVE_STRTOULL 1 74 | #define HAVE_ATOI 1 75 | #define HAVE_ATOF 1 76 | #define HAVE_STRCMP 1 77 | #define HAVE_STRNCMP 1 78 | #define HAVE_STRCASECMP 1 79 | #define HAVE_STRNCASECMP 1 80 | #define HAVE_VSSCANF 1 81 | #define HAVE_VSNPRINTF 1 82 | #define HAVE_M_PI 1 83 | #define HAVE_CEIL 1 84 | #define HAVE_COPYSIGN 1 85 | #define HAVE_COS 1 86 | #define HAVE_COSF 1 87 | #define HAVE_FABS 1 88 | #define HAVE_FLOOR 1 89 | #define HAVE_LOG 1 90 | #define HAVE_SCALBN 1 91 | #define HAVE_SIN 1 92 | #define HAVE_SINF 1 93 | #define HAVE_SQRT 1 94 | #define HAVE_SQRTF 1 95 | #define HAVE_TAN 1 96 | #define HAVE_TANF 1 97 | #define HAVE_SIGACTION 1 98 | #define HAVE_SETJMP 1 99 | #define HAVE_NANOSLEEP 1 100 | #define HAVE_POW 1 101 | 102 | #define SDL_AUDIO_DRIVER_DUMMY 1 103 | #define SDL_AUDIO_DRIVER_OSS 1 104 | 105 | #define SDL_INPUT_LINUXEV 1 106 | #define SDL_INPUT_TSLIB 1 107 | #define SDL_JOYSTICK_LINUX 1 108 | #define SDL_HAPTIC_LINUX 1 109 | 110 | #define SDL_LOADSO_DLOPEN 1 111 | 112 | #define SDL_THREAD_PTHREAD 1 113 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 114 | 115 | #define SDL_TIMER_UNIX 1 116 | 117 | #define SDL_VIDEO_DRIVER_DUMMY 1 118 | #define SDL_VIDEO_DRIVER_PANDORA 1 119 | #define SDL_VIDEO_RENDER_OGL_ES 1 120 | #define SDL_VIDEO_OPENGL_ES 1 121 | 122 | #endif /* SDL_config_wiz_h_ */ 123 | -------------------------------------------------------------------------------- /SDL2/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /SDL2/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_cpuinfo.h 24 | * 25 | * CPU feature detection for SDL. 26 | */ 27 | 28 | #ifndef SDL_cpuinfo_h_ 29 | #define SDL_cpuinfo_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /* Need to do this here because intrin.h has C++ code in it */ 34 | /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ 35 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) 36 | #ifdef __clang__ 37 | /* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ 38 | #undef __MMX__ 39 | #undef __SSE__ 40 | #undef __SSE2__ 41 | #else 42 | #include 43 | #ifndef _WIN64 44 | #define __MMX__ 45 | #define __3dNOW__ 46 | #endif 47 | #define __SSE__ 48 | #define __SSE2__ 49 | #endif /* __clang__ */ 50 | #elif defined(__MINGW64_VERSION_MAJOR) 51 | #include 52 | #else 53 | #ifdef __ALTIVEC__ 54 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 55 | #include 56 | #undef pixel 57 | #endif 58 | #endif 59 | #ifdef __MMX__ 60 | #include 61 | #endif 62 | #ifdef __3dNOW__ 63 | #include 64 | #endif 65 | #ifdef __SSE__ 66 | #include 67 | #endif 68 | #ifdef __SSE2__ 69 | #include 70 | #endif 71 | #ifdef __SSE3__ 72 | #include 73 | #endif 74 | #endif 75 | 76 | #include "begin_code.h" 77 | /* Set up for C function definitions, even when using C++ */ 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | 82 | /* This is a guess for the cacheline size used for padding. 83 | * Most x86 processors have a 64 byte cache line. 84 | * The 64-bit PowerPC processors have a 128 byte cache line. 85 | * We'll use the larger value to be generally safe. 86 | */ 87 | #define SDL_CACHELINE_SIZE 128 88 | 89 | /** 90 | * This function returns the number of CPU cores available. 91 | */ 92 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 93 | 94 | /** 95 | * This function returns the L1 cache line size of the CPU 96 | * 97 | * This is useful for determining multi-threaded structure padding 98 | * or SIMD prefetch sizes. 99 | */ 100 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 101 | 102 | /** 103 | * This function returns true if the CPU has the RDTSC instruction. 104 | */ 105 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 106 | 107 | /** 108 | * This function returns true if the CPU has AltiVec features. 109 | */ 110 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 111 | 112 | /** 113 | * This function returns true if the CPU has MMX features. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 116 | 117 | /** 118 | * This function returns true if the CPU has 3DNow! features. 119 | */ 120 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 121 | 122 | /** 123 | * This function returns true if the CPU has SSE features. 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 126 | 127 | /** 128 | * This function returns true if the CPU has SSE2 features. 129 | */ 130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 131 | 132 | /** 133 | * This function returns true if the CPU has SSE3 features. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 136 | 137 | /** 138 | * This function returns true if the CPU has SSE4.1 features. 139 | */ 140 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 141 | 142 | /** 143 | * This function returns true if the CPU has SSE4.2 features. 144 | */ 145 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 146 | 147 | /** 148 | * This function returns true if the CPU has AVX features. 149 | */ 150 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); 151 | 152 | /** 153 | * This function returns true if the CPU has AVX2 features. 154 | */ 155 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); 156 | 157 | /** 158 | * This function returns true if the CPU has NEON (ARM SIMD) features. 159 | */ 160 | extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); 161 | 162 | /** 163 | * This function returns the amount of RAM configured in the system, in MB. 164 | */ 165 | extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); 166 | 167 | 168 | /* Ends C function definitions when using C++ */ 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | #include "close_code.h" 173 | 174 | #endif /* SDL_cpuinfo_h_ */ 175 | 176 | /* vi: set ts=4 sw=4 expandtab: */ 177 | -------------------------------------------------------------------------------- /SDL2/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef SDL_error_h_ 29 | #define SDL_error_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Public functions */ 40 | /* SDL_SetError() unconditionally returns -1. */ 41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 43 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 44 | 45 | /** 46 | * \name Internal error functions 47 | * 48 | * \internal 49 | * Private error reporting function - used internally. 50 | */ 51 | /* @{ */ 52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | /* SDL_Error() unconditionally returns -1. */ 65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 66 | /* @} *//* Internal error functions */ 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* SDL_error_h_ */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /SDL2/SDL_filesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_filesystem.h 24 | * 25 | * \brief Include file for filesystem SDL API functions 26 | */ 27 | 28 | #ifndef SDL_filesystem_h_ 29 | #define SDL_filesystem_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief Get the path where the application resides. 42 | * 43 | * Get the "base path". This is the directory where the application was run 44 | * from, which is probably the installation directory, and may or may not 45 | * be the process's current working directory. 46 | * 47 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to 48 | * end with a path separator ('\\' on Windows, '/' most other places). 49 | * 50 | * The pointer returned by this function is owned by you. Please call 51 | * SDL_free() on the pointer when you are done with it, or it will be a 52 | * memory leak. This is not necessarily a fast call, though, so you should 53 | * call this once near startup and save the string if you need it. 54 | * 55 | * Some platforms can't determine the application's path, and on other 56 | * platforms, this might be meaningless. In such cases, this function will 57 | * return NULL. 58 | * 59 | * \return String of base dir in UTF-8 encoding, or NULL on error. 60 | * 61 | * \sa SDL_GetPrefPath 62 | */ 63 | extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); 64 | 65 | /** 66 | * \brief Get the user-and-app-specific path where files can be written. 67 | * 68 | * Get the "pref dir". This is meant to be where users can write personal 69 | * files (preferences and save games, etc) that are specific to your 70 | * application. This directory is unique per user, per application. 71 | * 72 | * This function will decide the appropriate location in the native filesystem, 73 | * create the directory if necessary, and return a string of the absolute 74 | * path to the directory in UTF-8 encoding. 75 | * 76 | * On Windows, the string might look like: 77 | * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" 78 | * 79 | * On Linux, the string might look like: 80 | * "/home/bob/.local/share/My Program Name/" 81 | * 82 | * On Mac OS X, the string might look like: 83 | * "/Users/bob/Library/Application Support/My Program Name/" 84 | * 85 | * (etc.) 86 | * 87 | * You specify the name of your organization (if it's not a real organization, 88 | * your name or an Internet domain you own might do) and the name of your 89 | * application. These should be untranslated proper names. 90 | * 91 | * Both the org and app strings may become part of a directory name, so 92 | * please follow these rules: 93 | * 94 | * - Try to use the same org string (including case-sensitivity) for 95 | * all your applications that use this function. 96 | * - Always use a unique app string for each one, and make sure it never 97 | * changes for an app once you've decided on it. 98 | * - Unicode characters are legal, as long as it's UTF-8 encoded, but... 99 | * - ...only use letters, numbers, and spaces. Avoid punctuation like 100 | * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. 101 | * 102 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to 103 | * end with a path separator ('\\' on Windows, '/' most other places). 104 | * 105 | * The pointer returned by this function is owned by you. Please call 106 | * SDL_free() on the pointer when you are done with it, or it will be a 107 | * memory leak. This is not necessarily a fast call, though, so you should 108 | * call this once near startup and save the string if you need it. 109 | * 110 | * You should assume the path returned by this function is the only safe 111 | * place to write files (and that SDL_GetBasePath(), while it might be 112 | * writable, or even the parent of the returned path, aren't where you 113 | * should be writing things). 114 | * 115 | * Some platforms can't determine the pref path, and on other 116 | * platforms, this might be meaningless. In such cases, this function will 117 | * return NULL. 118 | * 119 | * \param org The name of your organization. 120 | * \param app The name of your application. 121 | * \return UTF-8 string of user dir in platform-dependent notation. NULL 122 | * if there's a problem (creating directory failed, etc). 123 | * 124 | * \sa SDL_GetBasePath 125 | */ 126 | extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); 127 | 128 | /* Ends C function definitions when using C++ */ 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #include "close_code.h" 133 | 134 | #endif /* SDL_filesystem_h_ */ 135 | 136 | /* vi: set ts=4 sw=4 expandtab: */ 137 | -------------------------------------------------------------------------------- /SDL2/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef SDL_gesture_h_ 29 | #define SDL_gesture_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 50 | * 51 | * 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 54 | 55 | 56 | /** 57 | * \brief Save all currently loaded Dollar Gesture templates 58 | * 59 | * 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 62 | 63 | /** 64 | * \brief Save a currently loaded Dollar Gesture template 65 | * 66 | * 67 | */ 68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 69 | 70 | 71 | /** 72 | * \brief Load Dollar Gesture templates from a file 73 | * 74 | * 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 77 | 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* SDL_gesture_h_ */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /SDL2/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_loadso.h 24 | * 25 | * System dependent library loading routines 26 | * 27 | * Some things to keep in mind: 28 | * \li These functions only work on C function names. Other languages may 29 | * have name mangling and intrinsic language support that varies from 30 | * compiler to compiler. 31 | * \li Make sure you declare your function pointers with the same calling 32 | * convention as the actual library function. Your code will crash 33 | * mysteriously if you do not do this. 34 | * \li Avoid namespace collisions. If you load a symbol from the library, 35 | * it is not defined whether or not it goes into the global symbol 36 | * namespace for the application. If it does and it conflicts with 37 | * symbols in your code or other shared libraries, you will not get 38 | * the results you expect. :) 39 | */ 40 | 41 | #ifndef SDL_loadso_h_ 42 | #define SDL_loadso_h_ 43 | 44 | #include "SDL_stdinc.h" 45 | #include "SDL_error.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** 54 | * This function dynamically loads a shared object and returns a pointer 55 | * to the object handle (or NULL if there was an error). 56 | * The 'sofile' parameter is a system dependent name of the object file. 57 | */ 58 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 59 | 60 | /** 61 | * Given an object handle, this function looks up the address of the 62 | * named function in the shared object and returns it. This address 63 | * is no longer valid after calling SDL_UnloadObject(). 64 | */ 65 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 66 | const char *name); 67 | 68 | /** 69 | * Unload a shared object from memory. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 72 | 73 | /* Ends C function definitions when using C++ */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #include "close_code.h" 78 | 79 | #endif /* SDL_loadso_h_ */ 80 | 81 | /* vi: set ts=4 sw=4 expandtab: */ 82 | -------------------------------------------------------------------------------- /SDL2/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_main_h_ 23 | #define SDL_main_h_ 24 | 25 | #include "SDL_stdinc.h" 26 | 27 | /** 28 | * \file SDL_main.h 29 | * 30 | * Redefine main() on some platforms so that it is called by SDL. 31 | */ 32 | 33 | #ifndef SDL_MAIN_HANDLED 34 | #if defined(__WIN32__) 35 | /* On Windows SDL provides WinMain(), which parses the command line and passes 36 | the arguments to your main function. 37 | 38 | If you provide your own WinMain(), you may define SDL_MAIN_HANDLED 39 | */ 40 | #define SDL_MAIN_AVAILABLE 41 | 42 | #elif defined(__WINRT__) 43 | /* On WinRT, SDL provides a main function that initializes CoreApplication, 44 | creating an instance of IFrameworkView in the process. 45 | 46 | Please note that #include'ing SDL_main.h is not enough to get a main() 47 | function working. In non-XAML apps, the file, 48 | src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled 49 | into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be 50 | called, with a pointer to the Direct3D-hosted XAML control passed in. 51 | */ 52 | #define SDL_MAIN_NEEDED 53 | 54 | #elif defined(__IPHONEOS__) 55 | /* On iOS SDL provides a main function that creates an application delegate 56 | and starts the iOS application run loop. 57 | 58 | See src/video/uikit/SDL_uikitappdelegate.m for more details. 59 | */ 60 | #define SDL_MAIN_NEEDED 61 | 62 | #elif defined(__ANDROID__) 63 | /* On Android SDL provides a Java class in SDLActivity.java that is the 64 | main activity entry point. 65 | 66 | See README-android.md for more details on extending that class. 67 | */ 68 | #define SDL_MAIN_NEEDED 69 | 70 | #elif defined(__NACL__) 71 | /* On NACL we use ppapi_simple to set up the application helper code, 72 | then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before 73 | starting the user main function. 74 | All user code is run in a separate thread by ppapi_simple, thus 75 | allowing for blocking io to take place via nacl_io 76 | */ 77 | #define SDL_MAIN_NEEDED 78 | 79 | #endif 80 | #endif /* SDL_MAIN_HANDLED */ 81 | 82 | #ifdef __cplusplus 83 | #define C_LINKAGE "C" 84 | #else 85 | #define C_LINKAGE 86 | #endif /* __cplusplus */ 87 | 88 | /** 89 | * \file SDL_main.h 90 | * 91 | * The application's main() function must be called with C linkage, 92 | * and should be declared like this: 93 | * \code 94 | * #ifdef __cplusplus 95 | * extern "C" 96 | * #endif 97 | * int main(int argc, char *argv[]) 98 | * { 99 | * } 100 | * \endcode 101 | */ 102 | 103 | #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) 104 | #define main SDL_main 105 | #endif 106 | 107 | /** 108 | * The prototype for the application's main() function 109 | */ 110 | extern C_LINKAGE DECLSPEC int SDL_main(int argc, char *argv[]); 111 | 112 | 113 | #include "begin_code.h" 114 | #ifdef __cplusplus 115 | extern "C" { 116 | #endif 117 | 118 | /** 119 | * This is called by the real SDL main function to let the rest of the 120 | * library know that initialization was done properly. 121 | * 122 | * Calling this yourself without knowing what you're doing can cause 123 | * crashes and hard to diagnose problems with your application. 124 | */ 125 | extern DECLSPEC void SDLCALL SDL_SetMainReady(void); 126 | 127 | #ifdef __WIN32__ 128 | 129 | /** 130 | * This can be called to set the application class at startup 131 | */ 132 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, 133 | void *hInst); 134 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 135 | 136 | #endif /* __WIN32__ */ 137 | 138 | 139 | #ifdef __WINRT__ 140 | 141 | /** 142 | * \brief Initializes and launches an SDL/WinRT application. 143 | * 144 | * \param mainFunction The SDL app's C-style main(). 145 | * \param reserved Reserved for future use; should be NULL 146 | * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more 147 | * information on the failure. 148 | */ 149 | extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); 150 | 151 | #endif /* __WINRT__ */ 152 | 153 | 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | #include "close_code.h" 158 | 159 | #endif /* SDL_main_h_ */ 160 | 161 | /* vi: set ts=4 sw=4 expandtab: */ 162 | -------------------------------------------------------------------------------- /SDL2/SDL_messagebox.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_messagebox_h_ 23 | #define SDL_messagebox_h_ 24 | 25 | #include "SDL_stdinc.h" 26 | #include "SDL_video.h" /* For SDL_Window */ 27 | 28 | #include "begin_code.h" 29 | /* Set up for C function definitions, even when using C++ */ 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * \brief SDL_MessageBox flags. If supported will display warning icon, etc. 36 | */ 37 | typedef enum 38 | { 39 | SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ 40 | SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ 41 | SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ 42 | } SDL_MessageBoxFlags; 43 | 44 | /** 45 | * \brief Flags for SDL_MessageBoxButtonData. 46 | */ 47 | typedef enum 48 | { 49 | SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ 50 | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ 51 | } SDL_MessageBoxButtonFlags; 52 | 53 | /** 54 | * \brief Individual button data. 55 | */ 56 | typedef struct 57 | { 58 | Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ 59 | int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ 60 | const char * text; /**< The UTF-8 button text */ 61 | } SDL_MessageBoxButtonData; 62 | 63 | /** 64 | * \brief RGB value used in a message box color scheme 65 | */ 66 | typedef struct 67 | { 68 | Uint8 r, g, b; 69 | } SDL_MessageBoxColor; 70 | 71 | typedef enum 72 | { 73 | SDL_MESSAGEBOX_COLOR_BACKGROUND, 74 | SDL_MESSAGEBOX_COLOR_TEXT, 75 | SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, 76 | SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, 77 | SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, 78 | SDL_MESSAGEBOX_COLOR_MAX 79 | } SDL_MessageBoxColorType; 80 | 81 | /** 82 | * \brief A set of colors to use for message box dialogs 83 | */ 84 | typedef struct 85 | { 86 | SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; 87 | } SDL_MessageBoxColorScheme; 88 | 89 | /** 90 | * \brief MessageBox structure containing title, text, window, etc. 91 | */ 92 | typedef struct 93 | { 94 | Uint32 flags; /**< ::SDL_MessageBoxFlags */ 95 | SDL_Window *window; /**< Parent window, can be NULL */ 96 | const char *title; /**< UTF-8 title */ 97 | const char *message; /**< UTF-8 message text */ 98 | 99 | int numbuttons; 100 | const SDL_MessageBoxButtonData *buttons; 101 | 102 | const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ 103 | } SDL_MessageBoxData; 104 | 105 | /** 106 | * \brief Create a modal message box. 107 | * 108 | * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. 109 | * \param buttonid The pointer to which user id of hit button should be copied. 110 | * 111 | * \return -1 on error, otherwise 0 and buttonid contains user id of button 112 | * hit or -1 if dialog was closed. 113 | * 114 | * \note This function should be called on the thread that created the parent 115 | * window, or on the main thread if the messagebox has no parent. It will 116 | * block execution of that thread until the user clicks a button or 117 | * closes the messagebox. 118 | */ 119 | extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); 120 | 121 | /** 122 | * \brief Create a simple modal message box 123 | * 124 | * \param flags ::SDL_MessageBoxFlags 125 | * \param title UTF-8 title text 126 | * \param message UTF-8 message text 127 | * \param window The parent window, or NULL for no parent 128 | * 129 | * \return 0 on success, -1 on error 130 | * 131 | * \sa SDL_ShowMessageBox 132 | */ 133 | extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); 134 | 135 | 136 | /* Ends C function definitions when using C++ */ 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | #include "close_code.h" 141 | 142 | #endif /* SDL_messagebox_h_ */ 143 | 144 | /* vi: set ts=4 sw=4 expandtab: */ 145 | -------------------------------------------------------------------------------- /SDL2/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDLname_h_ 23 | #define SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /SDL2/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #ifndef APIENTRY 38 | #define APIENTRY 39 | #endif 40 | -------------------------------------------------------------------------------- /SDL2/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #ifndef _MSC_VER 30 | 31 | #ifdef __IPHONEOS__ 32 | #include 33 | #include 34 | #else 35 | #include 36 | #include 37 | #include 38 | #endif 39 | 40 | #else /* _MSC_VER */ 41 | 42 | /* OpenGL ES2 headers for Visual Studio */ 43 | #include "SDL_opengles2_khrplatform.h" 44 | #include "SDL_opengles2_gl2platform.h" 45 | #include "SDL_opengles2_gl2.h" 46 | #include "SDL_opengles2_gl2ext.h" 47 | 48 | #endif /* _MSC_VER */ 49 | 50 | #ifndef APIENTRY 51 | #define APIENTRY GL_APIENTRY 52 | #endif 53 | -------------------------------------------------------------------------------- /SDL2/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /SDL2/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_platform.h 24 | * 25 | * Try to get a standard set of platform defines. 26 | */ 27 | 28 | #ifndef SDL_platform_h_ 29 | #define SDL_platform_h_ 30 | 31 | #if defined(_AIX) 32 | #undef __AIX__ 33 | #define __AIX__ 1 34 | #endif 35 | #if defined(__HAIKU__) 36 | #undef __HAIKU__ 37 | #define __HAIKU__ 1 38 | #endif 39 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 40 | #undef __BSDI__ 41 | #define __BSDI__ 1 42 | #endif 43 | #if defined(_arch_dreamcast) 44 | #undef __DREAMCAST__ 45 | #define __DREAMCAST__ 1 46 | #endif 47 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 48 | #undef __FREEBSD__ 49 | #define __FREEBSD__ 1 50 | #endif 51 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 52 | #undef __HPUX__ 53 | #define __HPUX__ 1 54 | #endif 55 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 56 | #undef __IRIX__ 57 | #define __IRIX__ 1 58 | #endif 59 | #if (defined(linux) || defined(__linux) || defined(__linux__)) 60 | #undef __LINUX__ 61 | #define __LINUX__ 1 62 | #endif 63 | #if defined(ANDROID) || defined(__ANDROID__) 64 | #undef __ANDROID__ 65 | #undef __LINUX__ /* do we need to do this? */ 66 | #define __ANDROID__ 1 67 | #endif 68 | 69 | #if defined(__APPLE__) 70 | /* lets us know what version of Mac OS X we're compiling on */ 71 | #include "AvailabilityMacros.h" 72 | #include "TargetConditionals.h" 73 | #if TARGET_OS_TV 74 | #undef __TVOS__ 75 | #define __TVOS__ 1 76 | #endif 77 | #if TARGET_OS_IPHONE 78 | /* if compiling for iOS */ 79 | #undef __IPHONEOS__ 80 | #define __IPHONEOS__ 1 81 | #undef __MACOSX__ 82 | #else 83 | /* if not compiling for iOS */ 84 | #undef __MACOSX__ 85 | #define __MACOSX__ 1 86 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 87 | # error SDL for Mac OS X only supports deploying on 10.6 and above. 88 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ 89 | #endif /* TARGET_OS_IPHONE */ 90 | #endif /* defined(__APPLE__) */ 91 | 92 | #if defined(__NetBSD__) 93 | #undef __NETBSD__ 94 | #define __NETBSD__ 1 95 | #endif 96 | #if defined(__OpenBSD__) 97 | #undef __OPENBSD__ 98 | #define __OPENBSD__ 1 99 | #endif 100 | #if defined(__OS2__) || defined(__EMX__) 101 | #undef __OS2__ 102 | #define __OS2__ 1 103 | #endif 104 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 105 | #undef __OSF__ 106 | #define __OSF__ 1 107 | #endif 108 | #if defined(__QNXNTO__) 109 | #undef __QNXNTO__ 110 | #define __QNXNTO__ 1 111 | #endif 112 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 113 | #undef __RISCOS__ 114 | #define __RISCOS__ 1 115 | #endif 116 | #if defined(__sun) && defined(__SVR4) 117 | #undef __SOLARIS__ 118 | #define __SOLARIS__ 1 119 | #endif 120 | 121 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 122 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 123 | #if defined(_MSC_VER) && defined(__has_include) 124 | #define HAVE_WINAPIFAMILY_H __has_include() 125 | /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ 126 | #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ 127 | #define HAVE_WINAPIFAMILY_H 1 128 | #else 129 | #define HAVE_WINAPIFAMILY_H 0 130 | #endif 131 | 132 | #if HAVE_WINAPIFAMILY_H 133 | #include 134 | #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) 135 | #else 136 | #define WINAPI_FAMILY_WINRT 0 137 | #endif /* HAVE_WINAPIFAMILY_H */ 138 | 139 | #if WINAPI_FAMILY_WINRT 140 | #undef __WINRT__ 141 | #define __WINRT__ 1 142 | #else 143 | #undef __WINDOWS__ 144 | #define __WINDOWS__ 1 145 | #endif 146 | #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ 147 | 148 | #if defined(__WINDOWS__) 149 | #undef __WIN32__ 150 | #define __WIN32__ 1 151 | #endif 152 | #if defined(__PSP__) 153 | #undef __PSP__ 154 | #define __PSP__ 1 155 | #endif 156 | 157 | /* The NACL compiler defines __native_client__ and __pnacl__ 158 | * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi 159 | */ 160 | #if defined(__native_client__) 161 | #undef __LINUX__ 162 | #undef __NACL__ 163 | #define __NACL__ 1 164 | #endif 165 | #if defined(__pnacl__) 166 | #undef __LINUX__ 167 | #undef __PNACL__ 168 | #define __PNACL__ 1 169 | /* PNACL with newlib supports static linking only */ 170 | #define __SDL_NOGETPROCADDR__ 171 | #endif 172 | 173 | 174 | #include "begin_code.h" 175 | /* Set up for C function definitions, even when using C++ */ 176 | #ifdef __cplusplus 177 | extern "C" { 178 | #endif 179 | 180 | /** 181 | * \brief Gets the name of the platform. 182 | */ 183 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); 184 | 185 | /* Ends C function definitions when using C++ */ 186 | #ifdef __cplusplus 187 | } 188 | #endif 189 | #include "close_code.h" 190 | 191 | #endif /* SDL_platform_h_ */ 192 | 193 | /* vi: set ts=4 sw=4 expandtab: */ 194 | -------------------------------------------------------------------------------- /SDL2/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_power_h_ 23 | #define SDL_power_h_ 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * \brief Get the current power supply details. 54 | * 55 | * \param secs Seconds of battery life left. You can pass a NULL here if 56 | * you don't care. Will return -1 if we can't determine a 57 | * value, or we're not running on a battery. 58 | * 59 | * \param pct Percentage of battery life left, between 0 and 100. You can 60 | * pass a NULL here if you don't care. Will return -1 if we 61 | * can't determine a value, or we're not running on a battery. 62 | * 63 | * \return The state of the battery (if any). 64 | */ 65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* SDL_power_h_ */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /SDL2/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef SDL_quit_h_ 29 | #define SDL_quit_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* SDL_quit_h_ */ 59 | -------------------------------------------------------------------------------- /SDL2/SDL_rect.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_rect.h 24 | * 25 | * Header file for SDL_rect definition and management functions. 26 | */ 27 | 28 | #ifndef SDL_rect_h_ 29 | #define SDL_rect_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_pixels.h" 34 | #include "SDL_rwops.h" 35 | 36 | #include "begin_code.h" 37 | /* Set up for C function definitions, even when using C++ */ 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * \brief The structure that defines a point 44 | * 45 | * \sa SDL_EnclosePoints 46 | * \sa SDL_PointInRect 47 | */ 48 | typedef struct SDL_Point 49 | { 50 | int x; 51 | int y; 52 | } SDL_Point; 53 | 54 | /** 55 | * \brief A rectangle, with the origin at the upper left. 56 | * 57 | * \sa SDL_RectEmpty 58 | * \sa SDL_RectEquals 59 | * \sa SDL_HasIntersection 60 | * \sa SDL_IntersectRect 61 | * \sa SDL_UnionRect 62 | * \sa SDL_EnclosePoints 63 | */ 64 | typedef struct SDL_Rect 65 | { 66 | int x, y; 67 | int w, h; 68 | } SDL_Rect; 69 | 70 | /** 71 | * \brief Returns true if point resides inside a rectangle. 72 | */ 73 | SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) 74 | { 75 | return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && 76 | (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; 77 | } 78 | 79 | /** 80 | * \brief Returns true if the rectangle has no area. 81 | */ 82 | SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) 83 | { 84 | return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; 85 | } 86 | 87 | /** 88 | * \brief Returns true if the two rectangles are equal. 89 | */ 90 | SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) 91 | { 92 | return (a && b && (a->x == b->x) && (a->y == b->y) && 93 | (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; 94 | } 95 | 96 | /** 97 | * \brief Determine whether two rectangles intersect. 98 | * 99 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 100 | */ 101 | extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, 102 | const SDL_Rect * B); 103 | 104 | /** 105 | * \brief Calculate the intersection of two rectangles. 106 | * 107 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 108 | */ 109 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, 110 | const SDL_Rect * B, 111 | SDL_Rect * result); 112 | 113 | /** 114 | * \brief Calculate the union of two rectangles. 115 | */ 116 | extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, 117 | const SDL_Rect * B, 118 | SDL_Rect * result); 119 | 120 | /** 121 | * \brief Calculate a minimal rectangle enclosing a set of points 122 | * 123 | * \return SDL_TRUE if any points were within the clipping rect 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, 126 | int count, 127 | const SDL_Rect * clip, 128 | SDL_Rect * result); 129 | 130 | /** 131 | * \brief Calculate the intersection of a rectangle and line segment. 132 | * 133 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * 136 | rect, int *X1, 137 | int *Y1, int *X2, 138 | int *Y2); 139 | 140 | /* Ends C function definitions when using C++ */ 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | #include "close_code.h" 145 | 146 | #endif /* SDL_rect_h_ */ 147 | 148 | /* vi: set ts=4 sw=4 expandtab: */ 149 | -------------------------------------------------------------------------------- /SDL2/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-11645:2088cd828335" 2 | #define SDL_REVISION_NUMBER 11645 3 | -------------------------------------------------------------------------------- /SDL2/SDL_shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_shape_h_ 23 | #define SDL_shape_h_ 24 | 25 | #include "SDL_stdinc.h" 26 | #include "SDL_pixels.h" 27 | #include "SDL_rect.h" 28 | #include "SDL_surface.h" 29 | #include "SDL_video.h" 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** \file SDL_shape.h 38 | * 39 | * Header file for the shaped window API. 40 | */ 41 | 42 | #define SDL_NONSHAPEABLE_WINDOW -1 43 | #define SDL_INVALID_SHAPE_ARGUMENT -2 44 | #define SDL_WINDOW_LACKS_SHAPE -3 45 | 46 | /** 47 | * \brief Create a window that can be shaped with the specified position, dimensions, and flags. 48 | * 49 | * \param title The title of the window, in UTF-8 encoding. 50 | * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 51 | * ::SDL_WINDOWPOS_UNDEFINED. 52 | * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 53 | * ::SDL_WINDOWPOS_UNDEFINED. 54 | * \param w The width of the window. 55 | * \param h The height of the window. 56 | * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 57 | * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, 58 | * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, 59 | * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, 60 | * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. 61 | * 62 | * \return The window created, or NULL if window creation failed. 63 | * 64 | * \sa SDL_DestroyWindow() 65 | */ 66 | extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); 67 | 68 | /** 69 | * \brief Return whether the given window is a shaped window. 70 | * 71 | * \param window The window to query for being shaped. 72 | * 73 | * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. 74 | * 75 | * \sa SDL_CreateShapedWindow 76 | */ 77 | extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); 78 | 79 | /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ 80 | typedef enum { 81 | /** \brief The default mode, a binarized alpha cutoff of 1. */ 82 | ShapeModeDefault, 83 | /** \brief A binarized alpha cutoff with a given integer value. */ 84 | ShapeModeBinarizeAlpha, 85 | /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ 86 | ShapeModeReverseBinarizeAlpha, 87 | /** \brief A color key is applied. */ 88 | ShapeModeColorKey 89 | } WindowShapeMode; 90 | 91 | #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) 92 | 93 | /** \brief A union containing parameters for shaped windows. */ 94 | typedef union { 95 | /** \brief A cutoff alpha value for binarization of the window shape's alpha channel. */ 96 | Uint8 binarizationCutoff; 97 | SDL_Color colorKey; 98 | } SDL_WindowShapeParams; 99 | 100 | /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ 101 | typedef struct SDL_WindowShapeMode { 102 | /** \brief The mode of these window-shape parameters. */ 103 | WindowShapeMode mode; 104 | /** \brief Window-shape parameters. */ 105 | SDL_WindowShapeParams parameters; 106 | } SDL_WindowShapeMode; 107 | 108 | /** 109 | * \brief Set the shape and parameters of a shaped window. 110 | * 111 | * \param window The shaped window whose parameters should be set. 112 | * \param shape A surface encoding the desired shape for the window. 113 | * \param shape_mode The parameters to set for the shaped window. 114 | * 115 | * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW 116 | * if the SDL_Window given does not reference a valid shaped window. 117 | * 118 | * \sa SDL_WindowShapeMode 119 | * \sa SDL_GetShapedWindowMode. 120 | */ 121 | extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); 122 | 123 | /** 124 | * \brief Get the shape parameters of a shaped window. 125 | * 126 | * \param window The shaped window whose parameters should be retrieved. 127 | * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. 128 | * 129 | * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode 130 | * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if 131 | * the SDL_Window given is a shapeable window currently lacking a shape. 132 | * 133 | * \sa SDL_WindowShapeMode 134 | * \sa SDL_SetWindowShape 135 | */ 136 | extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); 137 | 138 | /* Ends C function definitions when using C++ */ 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | #include "close_code.h" 143 | 144 | #endif /* SDL_shape_h_ */ 145 | -------------------------------------------------------------------------------- /SDL2/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_h_ 31 | #define SDL_test_h_ 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_assert.h" 35 | #include "SDL_test_common.h" 36 | #include "SDL_test_compare.h" 37 | #include "SDL_test_crc32.h" 38 | #include "SDL_test_font.h" 39 | #include "SDL_test_fuzzer.h" 40 | #include "SDL_test_harness.h" 41 | #include "SDL_test_images.h" 42 | #include "SDL_test_log.h" 43 | #include "SDL_test_md5.h" 44 | #include "SDL_test_memory.h" 45 | #include "SDL_test_random.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /* Global definitions */ 54 | 55 | /* 56 | * Note: Maximum size of SDLTest log message is less than SDL's limit 57 | * to ensure we can fit additional information such as the timestamp. 58 | */ 59 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /SDL2/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_assert.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Assert API for test code and test cases 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_assert_h_ 37 | #define SDL_test_assert_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Fails the assert. 47 | */ 48 | #define ASSERT_FAIL 0 49 | 50 | /** 51 | * \brief Passes the assert. 52 | */ 53 | #define ASSERT_PASS 1 54 | 55 | /** 56 | * \brief Assert that logs and break execution flow on failures. 57 | * 58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 59 | * \param assertDescription Message to log with the assert describing it. 60 | */ 61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 62 | 63 | /** 64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. 65 | * 66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 67 | * \param assertDescription Message to log with the assert describing it. 68 | * 69 | * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. 70 | */ 71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 72 | 73 | /** 74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. 75 | * 76 | * \param assertDescription Message to log with the assert describing it. 77 | */ 78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); 79 | 80 | /** 81 | * \brief Resets the assert summary counters to zero. 82 | */ 83 | void SDLTest_ResetAssertSummary(void); 84 | 85 | /** 86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. 87 | */ 88 | void SDLTest_LogAssertSummary(void); 89 | 90 | 91 | /** 92 | * \brief Converts the current assert summary state to a test result. 93 | * 94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT 95 | */ 96 | int SDLTest_AssertSummaryToTestResult(void); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | #include "close_code.h" 102 | 103 | #endif /* SDL_test_assert_h_ */ 104 | 105 | /* vi: set ts=4 sw=4 expandtab: */ 106 | -------------------------------------------------------------------------------- /SDL2/SDL_test_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_common.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* Ported from original test\common.h file. */ 31 | 32 | #ifndef SDL_test_common_h_ 33 | #define SDL_test_common_h_ 34 | 35 | #include "SDL.h" 36 | 37 | #if defined(__PSP__) 38 | #define DEFAULT_WINDOW_WIDTH 480 39 | #define DEFAULT_WINDOW_HEIGHT 272 40 | #else 41 | #define DEFAULT_WINDOW_WIDTH 640 42 | #define DEFAULT_WINDOW_HEIGHT 480 43 | #endif 44 | 45 | #define VERBOSE_VIDEO 0x00000001 46 | #define VERBOSE_MODES 0x00000002 47 | #define VERBOSE_RENDER 0x00000004 48 | #define VERBOSE_EVENT 0x00000008 49 | #define VERBOSE_AUDIO 0x00000010 50 | 51 | typedef struct 52 | { 53 | /* SDL init flags */ 54 | char **argv; 55 | Uint32 flags; 56 | Uint32 verbose; 57 | 58 | /* Video info */ 59 | const char *videodriver; 60 | int display; 61 | const char *window_title; 62 | const char *window_icon; 63 | Uint32 window_flags; 64 | int window_x; 65 | int window_y; 66 | int window_w; 67 | int window_h; 68 | int window_minW; 69 | int window_minH; 70 | int window_maxW; 71 | int window_maxH; 72 | int logical_w; 73 | int logical_h; 74 | float scale; 75 | int depth; 76 | int refresh_rate; 77 | int num_windows; 78 | SDL_Window **windows; 79 | 80 | /* Renderer info */ 81 | const char *renderdriver; 82 | Uint32 render_flags; 83 | SDL_bool skip_renderer; 84 | SDL_Renderer **renderers; 85 | SDL_Texture **targets; 86 | 87 | /* Audio info */ 88 | const char *audiodriver; 89 | SDL_AudioSpec audiospec; 90 | 91 | /* GL settings */ 92 | int gl_red_size; 93 | int gl_green_size; 94 | int gl_blue_size; 95 | int gl_alpha_size; 96 | int gl_buffer_size; 97 | int gl_depth_size; 98 | int gl_stencil_size; 99 | int gl_double_buffer; 100 | int gl_accum_red_size; 101 | int gl_accum_green_size; 102 | int gl_accum_blue_size; 103 | int gl_accum_alpha_size; 104 | int gl_stereo; 105 | int gl_multisamplebuffers; 106 | int gl_multisamplesamples; 107 | int gl_retained_backing; 108 | int gl_accelerated; 109 | int gl_major_version; 110 | int gl_minor_version; 111 | int gl_debug; 112 | int gl_profile_mask; 113 | } SDLTest_CommonState; 114 | 115 | #include "begin_code.h" 116 | /* Set up for C function definitions, even when using C++ */ 117 | #ifdef __cplusplus 118 | extern "C" { 119 | #endif 120 | 121 | /* Function prototypes */ 122 | 123 | /** 124 | * \brief Parse command line parameters and create common state. 125 | * 126 | * \param argv Array of command line parameters 127 | * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) 128 | * 129 | * \returns Returns a newly allocated common state object. 130 | */ 131 | SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); 132 | 133 | /** 134 | * \brief Process one common argument. 135 | * 136 | * \param state The common state describing the test window to create. 137 | * \param index The index of the argument to process in argv[]. 138 | * 139 | * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. 140 | */ 141 | int SDLTest_CommonArg(SDLTest_CommonState * state, int index); 142 | 143 | /** 144 | * \brief Returns common usage information 145 | * 146 | * \param state The common state describing the test window to create. 147 | * 148 | * \returns String with usage information 149 | */ 150 | const char *SDLTest_CommonUsage(SDLTest_CommonState * state); 151 | 152 | /** 153 | * \brief Open test window. 154 | * 155 | * \param state The common state describing the test window to create. 156 | * 157 | * \returns True if initialization succeeded, false otherwise 158 | */ 159 | SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); 160 | 161 | /** 162 | * \brief Common event handler for test windows. 163 | * 164 | * \param state The common state used to create test window. 165 | * \param event The event to handle. 166 | * \param done Flag indicating we are done. 167 | * 168 | */ 169 | void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); 170 | 171 | /** 172 | * \brief Close test window. 173 | * 174 | * \param state The common state used to create test window. 175 | * 176 | */ 177 | void SDLTest_CommonQuit(SDLTest_CommonState * state); 178 | 179 | 180 | /* Ends C function definitions when using C++ */ 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | #include "close_code.h" 185 | 186 | #endif /* SDL_test_common_h_ */ 187 | 188 | /* vi: set ts=4 sw=4 expandtab: */ 189 | -------------------------------------------------------------------------------- /SDL2/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_compare_h_ 37 | #define SDL_test_compare_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_compare_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /SDL2/SDL_test_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_crc32.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Implements CRC32 calculations (default output is Perl String::CRC32 compatible). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_crc32_h_ 37 | #define SDL_test_crc32_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ------------ Definitions --------- */ 47 | 48 | /* Definition shared by all CRC routines */ 49 | 50 | #ifndef CrcUint32 51 | #define CrcUint32 unsigned int 52 | #endif 53 | #ifndef CrcUint8 54 | #define CrcUint8 unsigned char 55 | #endif 56 | 57 | #ifdef ORIGINAL_METHOD 58 | #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ 59 | #else 60 | #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ 61 | #endif 62 | 63 | /** 64 | * Data structure for CRC32 (checksum) computation 65 | */ 66 | typedef struct { 67 | CrcUint32 crc32_table[256]; /* CRC table */ 68 | } SDLTest_Crc32Context; 69 | 70 | /* ---------- Function Prototypes ------------- */ 71 | 72 | /** 73 | * \brief Initialize the CRC context 74 | * 75 | * Note: The function initializes the crc table required for all crc calculations. 76 | * 77 | * \param crcContext pointer to context variable 78 | * 79 | * \returns 0 for OK, -1 on error 80 | * 81 | */ 82 | int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); 83 | 84 | 85 | /** 86 | * \brief calculate a crc32 from a data block 87 | * 88 | * \param crcContext pointer to context variable 89 | * \param inBuf input buffer to checksum 90 | * \param inLen length of input buffer 91 | * \param crc32 pointer to Uint32 to store the final CRC into 92 | * 93 | * \returns 0 for OK, -1 on error 94 | * 95 | */ 96 | int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 97 | 98 | /* Same routine broken down into three steps */ 99 | int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 100 | int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 101 | int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 102 | 103 | 104 | /** 105 | * \brief clean up CRC context 106 | * 107 | * \param crcContext pointer to context variable 108 | * 109 | * \returns 0 for OK, -1 on error 110 | * 111 | */ 112 | 113 | int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); 114 | 115 | 116 | /* Ends C function definitions when using C++ */ 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | #include "close_code.h" 121 | 122 | #endif /* SDL_test_crc32_h_ */ 123 | 124 | /* vi: set ts=4 sw=4 expandtab: */ 125 | -------------------------------------------------------------------------------- /SDL2/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_font.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_font_h_ 31 | #define SDL_test_font_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | #define FONT_CHARACTER_SIZE 8 42 | 43 | /** 44 | * \brief Draw a string in the currently set font. 45 | * 46 | * \param renderer The renderer to draw on. 47 | * \param x The X coordinate of the upper left corner of the character. 48 | * \param y The Y coordinate of the upper left corner of the character. 49 | * \param c The character to draw. 50 | * 51 | * \returns Returns 0 on success, -1 on failure. 52 | */ 53 | int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c); 54 | 55 | /** 56 | * \brief Draw a string in the currently set font. 57 | * 58 | * \param renderer The renderer to draw on. 59 | * \param x The X coordinate of the upper left corner of the string. 60 | * \param y The Y coordinate of the upper left corner of the string. 61 | * \param s The string to draw. 62 | * 63 | * \returns Returns 0 on success, -1 on failure. 64 | */ 65 | int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s); 66 | 67 | 68 | /** 69 | * \brief Cleanup textures used by font drawing functions. 70 | */ 71 | void SDLTest_CleanupTextDrawing(void); 72 | 73 | /* Ends C function definitions when using C++ */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #include "close_code.h" 78 | 79 | #endif /* SDL_test_font_h_ */ 80 | 81 | /* vi: set ts=4 sw=4 expandtab: */ 82 | -------------------------------------------------------------------------------- /SDL2/SDL_test_harness.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_harness.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | Defines types for test case definitions and the test execution harness API. 32 | 33 | Based on original GSOC code by Markus Kauppila 34 | */ 35 | 36 | #ifndef SDL_test_h_arness_h 37 | #define SDL_test_h_arness_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ! Definitions for test case structures */ 47 | #define TEST_ENABLED 1 48 | #define TEST_DISABLED 0 49 | 50 | /* ! Definition of all the possible test return values of the test case method */ 51 | #define TEST_ABORTED -1 52 | #define TEST_STARTED 0 53 | #define TEST_COMPLETED 1 54 | #define TEST_SKIPPED 2 55 | 56 | /* ! Definition of all the possible test results for the harness */ 57 | #define TEST_RESULT_PASSED 0 58 | #define TEST_RESULT_FAILED 1 59 | #define TEST_RESULT_NO_ASSERT 2 60 | #define TEST_RESULT_SKIPPED 3 61 | #define TEST_RESULT_SETUP_FAILURE 4 62 | 63 | /* !< Function pointer to a test case setup function (run before every test) */ 64 | typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); 65 | 66 | /* !< Function pointer to a test case function */ 67 | typedef int (*SDLTest_TestCaseFp)(void *arg); 68 | 69 | /* !< Function pointer to a test case teardown function (run after every test) */ 70 | typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); 71 | 72 | /** 73 | * Holds information about a single test case. 74 | */ 75 | typedef struct SDLTest_TestCaseReference { 76 | /* !< Func2Stress */ 77 | SDLTest_TestCaseFp testCase; 78 | /* !< Short name (or function name) "Func2Stress" */ 79 | char *name; 80 | /* !< Long name or full description "This test pushes func2() to the limit." */ 81 | char *description; 82 | /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ 83 | int enabled; 84 | } SDLTest_TestCaseReference; 85 | 86 | /** 87 | * Holds information about a test suite (multiple test cases). 88 | */ 89 | typedef struct SDLTest_TestSuiteReference { 90 | /* !< "PlatformSuite" */ 91 | char *name; 92 | /* !< The function that is run before each test. NULL skips. */ 93 | SDLTest_TestCaseSetUpFp testSetUp; 94 | /* !< The test cases that are run as part of the suite. Last item should be NULL. */ 95 | const SDLTest_TestCaseReference **testCases; 96 | /* !< The function that is run after each test. NULL skips. */ 97 | SDLTest_TestCaseTearDownFp testTearDown; 98 | } SDLTest_TestSuiteReference; 99 | 100 | 101 | /** 102 | * \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z). 103 | * 104 | * Note: The returned string needs to be deallocated by the caller. 105 | * 106 | * \param length The length of the seed string to generate 107 | * 108 | * \returns The generated seed string 109 | */ 110 | char *SDLTest_GenerateRunSeed(const int length); 111 | 112 | /** 113 | * \brief Execute a test suite using the given run seed and execution key. 114 | * 115 | * \param testSuites Suites containing the test case. 116 | * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. 117 | * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. 118 | * \param filter Filter specification. NULL disables. Case sensitive. 119 | * \param testIterations Number of iterations to run each test case. 120 | * 121 | * \returns Test run result; 0 when all tests passed, 1 if any tests failed. 122 | */ 123 | int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); 124 | 125 | 126 | /* Ends C function definitions when using C++ */ 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | #include "close_code.h" 131 | 132 | #endif /* SDL_test_h_arness_h */ 133 | 134 | /* vi: set ts=4 sw=4 expandtab: */ 135 | -------------------------------------------------------------------------------- /SDL2/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef SDL_test_images_h_ 37 | #define SDL_test_images_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(void); 59 | SDL_Surface *SDLTest_ImageBlitColor(void); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(void); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(void); 62 | SDL_Surface *SDLTest_ImageBlitBlend(void); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(void); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(void); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(void); 66 | SDL_Surface *SDLTest_ImageFace(void); 67 | SDL_Surface *SDLTest_ImagePrimitives(void); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(void); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* SDL_test_images_h_ */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /SDL2/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_log_h_ 37 | #define SDL_test_log_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* SDL_test_log_h_ */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /SDL2/SDL_test_md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_md5.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | *********************************************************************** 32 | ** Header file for implementation of MD5 ** 33 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 34 | ** Created: 2/17/90 RLR ** 35 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 36 | ** Revised (for MD5): RLR 4/27/91 ** 37 | ** -- G modified to have y&~z instead of y&z ** 38 | ** -- FF, GG, HH modified to add in last register done ** 39 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 40 | ** -- distinct additive constant for each step ** 41 | ** -- round 4 added, working mod 7 ** 42 | *********************************************************************** 43 | */ 44 | 45 | /* 46 | *********************************************************************** 47 | ** Message-digest routines: ** 48 | ** To form the message digest for a message M ** 49 | ** (1) Initialize a context buffer mdContext using MD5Init ** 50 | ** (2) Call MD5Update on mdContext and M ** 51 | ** (3) Call MD5Final on mdContext ** 52 | ** The message digest is now in mdContext->digest[0...15] ** 53 | *********************************************************************** 54 | */ 55 | 56 | #ifndef SDL_test_md5_h_ 57 | #define SDL_test_md5_h_ 58 | 59 | #include "begin_code.h" 60 | /* Set up for C function definitions, even when using C++ */ 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /* ------------ Definitions --------- */ 66 | 67 | /* typedef a 32-bit type */ 68 | typedef unsigned long int MD5UINT4; 69 | 70 | /* Data structure for MD5 (Message-Digest) computation */ 71 | typedef struct { 72 | MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ 73 | MD5UINT4 buf[4]; /* scratch buffer */ 74 | unsigned char in[64]; /* input buffer */ 75 | unsigned char digest[16]; /* actual digest after Md5Final call */ 76 | } SDLTest_Md5Context; 77 | 78 | /* ---------- Function Prototypes ------------- */ 79 | 80 | /** 81 | * \brief initialize the context 82 | * 83 | * \param mdContext pointer to context variable 84 | * 85 | * Note: The function initializes the message-digest context 86 | * mdContext. Call before each new use of the context - 87 | * all fields are set to zero. 88 | */ 89 | void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); 90 | 91 | 92 | /** 93 | * \brief update digest from variable length data 94 | * 95 | * \param mdContext pointer to context variable 96 | * \param inBuf pointer to data array/string 97 | * \param inLen length of data array/string 98 | * 99 | * Note: The function updates the message-digest context to account 100 | * for the presence of each of the characters inBuf[0..inLen-1] 101 | * in the message whose digest is being computed. 102 | */ 103 | 104 | void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, 105 | unsigned int inLen); 106 | 107 | 108 | /** 109 | * \brief complete digest computation 110 | * 111 | * \param mdContext pointer to context variable 112 | * 113 | * Note: The function terminates the message-digest computation and 114 | * ends with the desired message digest in mdContext.digest[0..15]. 115 | * Always call before using the digest[] variable. 116 | */ 117 | 118 | void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); 119 | 120 | 121 | /* Ends C function definitions when using C++ */ 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | #include "close_code.h" 126 | 127 | #endif /* SDL_test_md5_h_ */ 128 | 129 | /* vi: set ts=4 sw=4 expandtab: */ 130 | -------------------------------------------------------------------------------- /SDL2/SDL_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_memory.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_memory_h_ 31 | #define SDL_test_memory_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | 40 | /** 41 | * \brief Start tracking SDL memory allocations 42 | * 43 | * \note This should be called before any other SDL functions for complete tracking coverage 44 | */ 45 | int SDLTest_TrackAllocations(); 46 | 47 | /** 48 | * \brief Print a log of any outstanding allocations 49 | * 50 | * \note This can be called after SDL_Quit() 51 | */ 52 | void SDLTest_LogAllocations(); 53 | 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* SDL_test_memory_h_ */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /SDL2/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_random.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | A "32-bit Multiply with carry random number generator. Very fast. 33 | Includes a list of recommended multipliers. 34 | 35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. 36 | period: (a*2^31)-1 37 | 38 | */ 39 | 40 | #ifndef SDL_test_random_h_ 41 | #define SDL_test_random_h_ 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* --- Definitions */ 50 | 51 | /* 52 | * Macros that return a random number in a specific format. 53 | */ 54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) 55 | 56 | /* 57 | * Context structure for the random number generator state. 58 | */ 59 | typedef struct { 60 | unsigned int a; 61 | unsigned int x; 62 | unsigned int c; 63 | unsigned int ah; 64 | unsigned int al; 65 | } SDLTest_RandomContext; 66 | 67 | 68 | /* --- Function prototypes */ 69 | 70 | /** 71 | * \brief Initialize random number generator with two integers. 72 | * 73 | * Note: The random sequence of numbers returned by ...Random() is the 74 | * same for the same two integers and has a period of 2^31. 75 | * 76 | * \param rndContext pointer to context structure 77 | * \param xi integer that defines the random sequence 78 | * \param ci integer that defines the random sequence 79 | * 80 | */ 81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, 82 | unsigned int ci); 83 | 84 | /** 85 | * \brief Initialize random number generator based on current system time. 86 | * 87 | * \param rndContext pointer to context structure 88 | * 89 | */ 90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); 91 | 92 | 93 | /** 94 | * \brief Initialize random number generator based on current system time. 95 | * 96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called 97 | * before using this function. 98 | * 99 | * \param rndContext pointer to context structure 100 | * 101 | * \returns A random number (32bit unsigned integer) 102 | * 103 | */ 104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_test_random_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /SDL2/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_timer_h_ 23 | #define SDL_timer_h_ 24 | 25 | /** 26 | * \file SDL_timer.h 27 | * 28 | * Header for the SDL time management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief Get the number of milliseconds since the SDL library initialization. 42 | * 43 | * \note This value wraps if the program runs for more than ~49 days. 44 | */ 45 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 46 | 47 | /** 48 | * \brief Compare SDL ticks values, and return true if A has passed B 49 | * 50 | * e.g. if you want to wait 100 ms, you could do this: 51 | * Uint32 timeout = SDL_GetTicks() + 100; 52 | * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { 53 | * ... do work until timeout has elapsed 54 | * } 55 | */ 56 | #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) 57 | 58 | /** 59 | * \brief Get the current value of the high resolution counter 60 | */ 61 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); 62 | 63 | /** 64 | * \brief Get the count per second of the high resolution counter 65 | */ 66 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); 67 | 68 | /** 69 | * \brief Wait a specified number of milliseconds before returning. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 72 | 73 | /** 74 | * Function prototype for the timer callback function. 75 | * 76 | * The callback function is passed the current timer interval and returns 77 | * the next timer interval. If the returned value is the same as the one 78 | * passed in, the periodic alarm continues, otherwise a new alarm is 79 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 80 | */ 81 | typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); 82 | 83 | /** 84 | * Definition of the timer ID type. 85 | */ 86 | typedef int SDL_TimerID; 87 | 88 | /** 89 | * \brief Add a new timer to the pool of timers already running. 90 | * 91 | * \return A timer ID, or 0 when an error occurs. 92 | */ 93 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, 94 | SDL_TimerCallback callback, 95 | void *param); 96 | 97 | /** 98 | * \brief Remove a timer knowing its ID. 99 | * 100 | * \return A boolean value indicating success or failure. 101 | * 102 | * \warning It is not safe to remove a timer multiple times. 103 | */ 104 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_timer_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /SDL2/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef SDL_touch_h_ 29 | #define SDL_touch_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef struct SDL_Finger 45 | { 46 | SDL_FingerID id; 47 | float x; 48 | float y; 49 | float pressure; 50 | } SDL_Finger; 51 | 52 | /* Used as the device ID for mouse events simulated with touch input */ 53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 54 | 55 | 56 | /* Function prototypes */ 57 | 58 | /** 59 | * \brief Get the number of registered touch devices. 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 62 | 63 | /** 64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 65 | */ 66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 67 | 68 | /** 69 | * \brief Get the number of active fingers for a given touch device. 70 | */ 71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 72 | 73 | /** 74 | * \brief Get the finger object of the given touch, with the given index. 75 | */ 76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 77 | 78 | /* Ends C function definitions when using C++ */ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #include "close_code.h" 83 | 84 | #endif /* SDL_touch_h_ */ 85 | 86 | /* vi: set ts=4 sw=4 expandtab: */ 87 | -------------------------------------------------------------------------------- /SDL2/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /SDL2/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_version.h 24 | * 25 | * This header defines the current SDL version. 26 | */ 27 | 28 | #ifndef SDL_version_h_ 29 | #define SDL_version_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief Information the version of SDL in use. 41 | * 42 | * Represents the library's version as three levels: major revision 43 | * (increments with massive changes, additions, and enhancements), 44 | * minor revision (increments with backwards-compatible changes to the 45 | * major revision), and patchlevel (increments with fixes to the minor 46 | * revision). 47 | * 48 | * \sa SDL_VERSION 49 | * \sa SDL_GetVersion 50 | */ 51 | typedef struct SDL_version 52 | { 53 | Uint8 major; /**< major version */ 54 | Uint8 minor; /**< minor version */ 55 | Uint8 patch; /**< update version */ 56 | } SDL_version; 57 | 58 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 59 | */ 60 | #define SDL_MAJOR_VERSION 2 61 | #define SDL_MINOR_VERSION 0 62 | #define SDL_PATCHLEVEL 7 63 | 64 | /** 65 | * \brief Macro to determine SDL version program was compiled against. 66 | * 67 | * This macro fills in a SDL_version structure with the version of the 68 | * library you compiled against. This is determined by what header the 69 | * compiler uses. Note that if you dynamically linked the library, you might 70 | * have a slightly newer or older version at runtime. That version can be 71 | * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), 72 | * is not a macro. 73 | * 74 | * \param x A pointer to a SDL_version struct to initialize. 75 | * 76 | * \sa SDL_version 77 | * \sa SDL_GetVersion 78 | */ 79 | #define SDL_VERSION(x) \ 80 | { \ 81 | (x)->major = SDL_MAJOR_VERSION; \ 82 | (x)->minor = SDL_MINOR_VERSION; \ 83 | (x)->patch = SDL_PATCHLEVEL; \ 84 | } 85 | 86 | /** 87 | * This macro turns the version numbers into a numeric value: 88 | * \verbatim 89 | (1,2,3) -> (1203) 90 | \endverbatim 91 | * 92 | * This assumes that there will never be more than 100 patchlevels. 93 | */ 94 | #define SDL_VERSIONNUM(X, Y, Z) \ 95 | ((X)*1000 + (Y)*100 + (Z)) 96 | 97 | /** 98 | * This is the version number macro for the current SDL version. 99 | */ 100 | #define SDL_COMPILEDVERSION \ 101 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 102 | 103 | /** 104 | * This macro will evaluate to true if compiled with SDL at least X.Y.Z. 105 | */ 106 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 107 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 108 | 109 | /** 110 | * \brief Get the version of SDL that is linked against your program. 111 | * 112 | * If you are linking to SDL dynamically, then it is possible that the 113 | * current version will be different than the version you compiled against. 114 | * This function returns the current version, while SDL_VERSION() is a 115 | * macro that tells you what version you compiled with. 116 | * 117 | * \code 118 | * SDL_version compiled; 119 | * SDL_version linked; 120 | * 121 | * SDL_VERSION(&compiled); 122 | * SDL_GetVersion(&linked); 123 | * printf("We compiled against SDL version %d.%d.%d ...\n", 124 | * compiled.major, compiled.minor, compiled.patch); 125 | * printf("But we linked against SDL version %d.%d.%d.\n", 126 | * linked.major, linked.minor, linked.patch); 127 | * \endcode 128 | * 129 | * This function may be called safely at any time, even before SDL_Init(). 130 | * 131 | * \sa SDL_VERSION 132 | */ 133 | extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); 134 | 135 | /** 136 | * \brief Get the code revision of SDL that is linked against your program. 137 | * 138 | * Returns an arbitrary string (a hash value) uniquely identifying the 139 | * exact revision of the SDL library in use, and is only useful in comparing 140 | * against other revisions. It is NOT an incrementing number. 141 | */ 142 | extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); 143 | 144 | /** 145 | * \brief Get the revision number of SDL that is linked against your program. 146 | * 147 | * Returns a number uniquely identifying the exact revision of the SDL 148 | * library in use. It is an incrementing number based on commits to 149 | * hg.libsdl.org. 150 | */ 151 | extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); 152 | 153 | 154 | /* Ends C function definitions when using C++ */ 155 | #ifdef __cplusplus 156 | } 157 | #endif 158 | #include "close_code.h" 159 | 160 | #endif /* SDL_version_h_ */ 161 | 162 | /* vi: set ts=4 sw=4 expandtab: */ 163 | -------------------------------------------------------------------------------- /SDL2/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file begin_code.h 24 | * 25 | * This file sets things up for C dynamic library function definitions, 26 | * static inlined functions, and structures aligned at 4-byte alignment. 27 | * If you don't like ugly C preprocessor code, don't look at this file. :) 28 | */ 29 | 30 | /* This shouldn't be nested -- included it around code only. */ 31 | #ifdef _begin_code_h 32 | #error Nested inclusion of begin_code.h 33 | #endif 34 | #define _begin_code_h 35 | 36 | #ifndef SDL_DEPRECATED 37 | # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ 38 | # define SDL_DEPRECATED __attribute__((deprecated)) 39 | # else 40 | # define SDL_DEPRECATED 41 | # endif 42 | #endif 43 | 44 | #ifndef SDL_UNUSED 45 | # ifdef __GNUC__ 46 | # define SDL_UNUSED __attribute__((unused)) 47 | # else 48 | # define SDL_UNUSED 49 | # endif 50 | #endif 51 | 52 | /* Some compilers use a special export keyword */ 53 | #ifndef DECLSPEC 54 | # if defined(__WIN32__) || defined(__WINRT__) 55 | # ifdef __BORLANDC__ 56 | # ifdef BUILD_SDL 57 | # define DECLSPEC 58 | # else 59 | # define DECLSPEC __declspec(dllimport) 60 | # endif 61 | # else 62 | # define DECLSPEC __declspec(dllexport) 63 | # endif 64 | # elif defined(__OS2__) 65 | # ifdef BUILD_SDL 66 | # define DECLSPEC __declspec(dllexport) 67 | # else 68 | # define DECLSPEC 69 | # endif 70 | # else 71 | # if defined(__GNUC__) && __GNUC__ >= 4 72 | # define DECLSPEC __attribute__ ((visibility("default"))) 73 | # else 74 | # define DECLSPEC 75 | # endif 76 | # endif 77 | #endif 78 | 79 | /* By default SDL uses the C calling convention */ 80 | #ifndef SDLCALL 81 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) 82 | #define SDLCALL __cdecl 83 | #elif defined(__OS2__) || defined(__EMX__) 84 | #define SDLCALL _System 85 | # if defined (__GNUC__) && !defined(_System) 86 | # define _System /* for old EMX/GCC compat. */ 87 | # endif 88 | #else 89 | #define SDLCALL 90 | #endif 91 | #endif /* SDLCALL */ 92 | 93 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 94 | #ifdef __SYMBIAN32__ 95 | #undef DECLSPEC 96 | #define DECLSPEC 97 | #endif /* __SYMBIAN32__ */ 98 | 99 | /* Force structure packing at 4 byte alignment. 100 | This is necessary if the header is included in code which has structure 101 | packing set to an alternate value, say for loading structures from disk. 102 | The packing is reset to the previous value in close_code.h 103 | */ 104 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 105 | #ifdef _MSC_VER 106 | #pragma warning(disable: 4103) 107 | #endif 108 | #ifdef __BORLANDC__ 109 | #pragma nopackwarning 110 | #endif 111 | #ifdef _M_X64 112 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ 113 | #pragma pack(push,8) 114 | #else 115 | #pragma pack(push,4) 116 | #endif 117 | #endif /* Compiler needs structure packing set */ 118 | 119 | #ifndef SDL_INLINE 120 | #if defined(__GNUC__) 121 | #define SDL_INLINE __inline__ 122 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ 123 | defined(__DMC__) || defined(__SC__) || \ 124 | defined(__WATCOMC__) || defined(__LCC__) || \ 125 | defined(__DECC) || defined(__CC_ARM) 126 | #define SDL_INLINE __inline 127 | #ifndef __inline__ 128 | #define __inline__ __inline 129 | #endif 130 | #else 131 | #define SDL_INLINE inline 132 | #ifndef __inline__ 133 | #define __inline__ inline 134 | #endif 135 | #endif 136 | #endif /* SDL_INLINE not defined */ 137 | 138 | #ifndef SDL_FORCE_INLINE 139 | #if defined(_MSC_VER) 140 | #define SDL_FORCE_INLINE __forceinline 141 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) 142 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ 143 | #else 144 | #define SDL_FORCE_INLINE static SDL_INLINE 145 | #endif 146 | #endif /* SDL_FORCE_INLINE not defined */ 147 | 148 | #ifndef SDL_NORETURN 149 | #if defined(__GNUC__) 150 | #define SDL_NORETURN __attribute__((noreturn)) 151 | #elif defined(_MSC_VER) 152 | #define SDL_NORETURN __declspec(noreturn) 153 | #else 154 | #define SDL_NORETURN 155 | #endif 156 | #endif /* SDL_NORETURN not defined */ 157 | 158 | /* Apparently this is needed by several Windows compilers */ 159 | #if !defined(__MACH__) 160 | #ifndef NULL 161 | #ifdef __cplusplus 162 | #define NULL 0 163 | #else 164 | #define NULL ((void *)0) 165 | #endif 166 | #endif /* NULL */ 167 | #endif /* ! Mac OS X - breaks precompiled headers */ 168 | -------------------------------------------------------------------------------- /SDL2/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2017 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /base.ninja: -------------------------------------------------------------------------------- 1 | ninja_required_version = 1.3 2 | 3 | builddir = build 4 | 5 | #partial option sets 6 | common = -I. -ISDL2 -Ilib -mmacosx-version-min=10.10.0 7 | cppflags = -std=c++14 8 | cflags = -std=c11 9 | 10 | opt = -Ofast -march=native 11 | 12 | libflags = $common $opt 13 | srcflags = $common -Wall -Wno-unused-variable $opt 14 | linkflags = -lSDL2 -headerpad_max_install_names 15 | 16 | #compiler = /usr/local/opt/llvm/bin/clang 17 | compiler = gcc-8 18 | 19 | img_size = 512 20 | 21 | rule img 22 | command = convert $in -resize $img_size $out 23 | description = Resizing image $in 24 | 25 | rule img_lin 26 | command = convert $in -gamma 1 -resize $img_size -gamma 1 $out 27 | description = Resizing texture $in 28 | 29 | rule ply 30 | command = ply/ply -i $in -o $out 31 | description = Converting model $in 32 | 33 | rule lib 34 | command = $compiler -MMD -MF $out.d $libflags $cppflags -c $in -o $out 35 | description = Building library $in 36 | depfile = $out.d 37 | 38 | rule clib 39 | command = $compiler -MMD -MF $out.d $libflags $cflags -c $in -o $out 40 | description = Building library $in 41 | depfile = $out.d 42 | 43 | rule src 44 | # command = $compiler -MD -MF $out.d $srcflags $cppflags -c $in -o $out && $compiler $srcflags $cppflags -c $in -E > $out.cpp 45 | command = $compiler -MMD -MF $out.d $srcflags $cppflags -c $in -o $out 46 | description = Building source $in 47 | depfile = $out.d 48 | 49 | rule link 50 | command = $compiler $linkflags -mmacosx-version-min=10.10.0 $in -o $out 51 | description = Linking executable $out 52 | 53 | rule img_pack 54 | command = res/build.sh 55 | description = Packing images 56 | 57 | build res/tomato_c.png: img_pack res/src/BrokenTiles_01_BC.png res/src/Sword9_diffuse.png res/src/CobbleStone_01_BC.png res/src/Tomato_diffuse.png res/src/Sword7_diffuse.png res/src/Sword9_normal.png res/src/CobbleStone_01_N.png res/src/Sword7_roughness.png res/src/Tomato_MetalSmooth.png res/src/BrokenTiles_01_N.png res/src/Sword9_roughness.png res/src/Tomato_normal.png res/src/BrokenTiles_01_R.png res/src/CobbleStone_01_R.png res/src/Sword7_normal.png 58 | -------------------------------------------------------------------------------- /bob/bob.cpp: -------------------------------------------------------------------------------- 1 | //this program walks various directories of the project to generate a .ninja file 2 | //yes this is a pun on "bob the builder" don't @ me 3 | 4 | //bob/build.sh builds bob. 5 | //you only need to build bob once before you can build the rest of the project 6 | 7 | //TODO: walk folder structures recursively 8 | //TODO: generate .app bundles for macOS 9 | //TODO: test and make sure this works with symlinks 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "common.hpp" 22 | #include "List.hpp" 23 | 24 | bool verbose; 25 | 26 | enum FileType { 27 | FILE_NONE, 28 | FILE_TEXTURE, 29 | FILE_TEX_LINEAR, 30 | FILE_MODEL, 31 | FILE_CPPLIB, 32 | FILE_CLIB, 33 | FILE_SRC, 34 | }; 35 | 36 | struct File { 37 | FileType type; 38 | char * dir; 39 | char * name; 40 | char * ext; 41 | }; 42 | 43 | List add_files(List files, FileType type, const char * dir, const char * ext) { 44 | //open directory 45 | DIR * dp = opendir(dir); 46 | if (!dp) { 47 | if (verbose) { 48 | printf("WARNING: Could not open directory %s, assuming empty\n", dir); 49 | } 50 | return files; 51 | } 52 | 53 | //scan for source files 54 | dirent * ep = readdir(dp); 55 | while (ep) { 56 | char * dot = strrchr(ep->d_name, '.'); 57 | if (dot && !strcmp(dot + 1, ext)) { 58 | files.add({ type, dup(dir), dup(ep->d_name, dot), dup(ext) }); 59 | } 60 | ep = readdir(dp); 61 | } 62 | 63 | closedir(dp); 64 | 65 | return files; 66 | } 67 | 68 | enum ArgType { 69 | ARG_NONE, 70 | ARG_ROOT, 71 | ARG_TEMP, 72 | ARG_OUTPUT, 73 | }; 74 | 75 | //allocates a buffer large enough to fit resulting string, an `sprintf`s to it 76 | //NOTE: this is no longer necessary here, but may be useful in a future project... 77 | // should I maybe include it in common.hpp? 78 | char * dsprintf(char * buf, const char * fmt, ...) { 79 | size_t len = buf? strlen(buf) : 0; 80 | va_list args1, args2; 81 | va_start(args1, fmt); 82 | va_copy(args2, args1); 83 | buf = (char *) realloc(buf, len + vsnprintf(nullptr, 0, fmt, args1) + 1); 84 | vsprintf(buf + len, fmt, args2); 85 | va_end(args1); 86 | va_end(args2); 87 | return buf; 88 | } 89 | 90 | int main(int argc, char ** argv) { 91 | const char * root = "."; 92 | const char * temp = "template.ninja"; 93 | const char * output = "build.ninja"; 94 | 95 | //parse command line arguments 96 | ArgType type = ARG_NONE; 97 | for (int i = 1; i < argc; ++i) { 98 | if (!strcmp(argv[i], "-v")) { 99 | verbose = true; 100 | } else if (!strcmp(argv[i], "-r")) { 101 | type = ARG_ROOT; 102 | } else if (!strcmp(argv[i], "-t")) { 103 | type = ARG_TEMP; 104 | } else if (!strcmp(argv[i], "-o")) { 105 | type = ARG_OUTPUT; 106 | } else if (type == ARG_ROOT) { 107 | root = argv[i]; 108 | type = ARG_NONE; 109 | } else if (type == ARG_TEMP) { 110 | temp = argv[i]; 111 | type = ARG_NONE; 112 | } else if (type == ARG_OUTPUT) { 113 | output = argv[i]; 114 | type = ARG_NONE; 115 | } 116 | } 117 | 118 | //change directory 119 | chdir(root); 120 | 121 | //read template ninja file 122 | char * part = read_entire_file(temp); 123 | if (!part) { 124 | printf("Error while reading file %s\n", temp); 125 | return 1; 126 | } 127 | 128 | //gather and classify files 129 | List files = create_list(1); 130 | files = add_files(files, FILE_TEXTURE, "asset", "png"); 131 | files = add_files(files, FILE_TEXTURE, "asset", "tga"); 132 | files = add_files(files, FILE_TEX_LINEAR, "asset/linear", "png"); 133 | files = add_files(files, FILE_TEX_LINEAR, "asset/linear", "tga"); 134 | files = add_files(files, FILE_MODEL, "asset", "ply"); 135 | files = add_files(files, FILE_CPPLIB, "lib", "cpp"); 136 | files = add_files(files, FILE_CLIB, "lib", "c"); 137 | files = add_files(files, FILE_SRC, ".", "cpp"); 138 | files = add_files(files, FILE_SRC, "src", "cpp"); 139 | 140 | //write ninja build file 141 | //paste template into output file 142 | FILE * out = fopen(output, "w"); 143 | fprintf(out, "%s\n", part); 144 | free(part); 145 | 146 | //write asset conversion commands 147 | for (File f : files) { 148 | if (f.type == FILE_TEXTURE) { 149 | fprintf(out, "build res/src/%s.png: img %s/%s.%s\n", f.name, f.dir, f.name, f.ext); 150 | } else if (f.type == FILE_TEX_LINEAR) { 151 | fprintf(out, "build res/src/%s.png: img_lin %s/%s.%s\n", f.name, f.dir, f.name, f.ext); 152 | } else if (f.type == FILE_MODEL) { 153 | fprintf(out, "build res/%s.diw: ply %s/%s.%s\n", f.name, f.dir, f.name, f.ext); 154 | } 155 | } 156 | fprintf(out, "\n"); 157 | 158 | //write compile commands 159 | for (File f : files) { 160 | auto rule = match_pair({ 161 | { "lib", FILE_CPPLIB }, 162 | { "clib", FILE_CLIB }, 163 | { "src", FILE_SRC }, 164 | }, f.type, nullptr); 165 | 166 | if (rule) { 167 | fprintf(out, "build $builddir/%s.o: %s %s/%s.%s\n", 168 | f.name, rule, f.dir, f.name, f.ext); 169 | } 170 | } 171 | 172 | //write link command 173 | fprintf(out, "\nbuild game: link"); 174 | for (File f : files) { 175 | if (one_of({ FILE_CPPLIB, FILE_CLIB, FILE_SRC }, f.type)) { 176 | fprintf(out, " $builddir/%s.o", f.name); 177 | } 178 | } 179 | fprintf(out, "\n"); 180 | 181 | fclose(out); 182 | 183 | //windows build 184 | //NOTE: https://msdn.microsoft.com/en-us/library/19z1t1wy.aspx 185 | //TODO: specify windows build script location (and whether to generate it at all?) 186 | FILE * win = fopen("win-build.bat", "w"); 187 | fprintf(win, "cl /std:c++14 /MP /Ox /ISDL2 /Ilib"); // /arch:AVX2 /favor:INTEL64 188 | for (File f : files) { 189 | if (one_of({ FILE_CPPLIB, FILE_CLIB, FILE_SRC }, f.type)) { 190 | fprintf(win, " %s/%s.%s", f.dir, f.name, f.ext); 191 | } 192 | } 193 | fprintf(win, " /link /out:game.exe /SUBSYSTEM:CONSOLE || exit /b\r\ndel *.obj\r\ngame.exe\r\n"); 194 | fclose(win); 195 | 196 | //mac simple build (no ninja required) 197 | FILE * mac = fopen("mac-build.sh", "w"); 198 | assert(mac); 199 | // fprintf(mac, "clang -std=c++11 -stdlib=libc++ -Ilib -ISDL2 -Ofast -o game"); 200 | fprintf(mac, "gcc-8 -std=c++14 -Ilib -ISDL2 -Ofast -o game -lSDL2"); 201 | for (File f : files) { 202 | if (one_of({ FILE_CPPLIB, FILE_CLIB, FILE_SRC }, f.type)) { 203 | fprintf(win, " %s/%s.%s", f.dir, f.name, f.ext); 204 | } 205 | } 206 | fprintf(mac, " || exit\n./game\n"); 207 | fclose(mac); 208 | chmod("mac-build.sh", //ALL THE PERMISSIONS :D :D :D :D :D :D 209 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IXUSR | S_IROTH | S_IWOTH | S_IXGRP | S_IXOTH); 210 | 211 | return 0; 212 | } 213 | -------------------------------------------------------------------------------- /bob/build.sh: -------------------------------------------------------------------------------- 1 | clang -std=c++11 -stdlib=libc++ -I../lib -Wall -Ofast -o bob bob.cpp -lc++ || exit 2 | ./bob -r .. -t base.ninja -o bob/out.ninja -v 3 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | cl /Ox /ISDL2 /Ilib lib/stb_image.cpp src/blit.cpp src/main.cpp /link /out:game.exe /SUBSYSTEM:CONSOLE 2 | del *.obj 3 | game.exe 4 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | cd "$(dirname "$0")" 2 | 3 | bob/bob -t base.ninja -o build.ninja 4 | export NINJA_STATUS='[%t/%f] %es ' 5 | ninja || exit 6 | rm build.ninja 7 | 8 | # ./game 9 | nice -n 10 ./game 10 | -------------------------------------------------------------------------------- /lib/FileBuffer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEBUFFER_HPP 2 | #define FILEBUFFER_HPP 3 | 4 | #include 5 | 6 | //TODO: add method to re-align "head" pointer 7 | 8 | //NOTE: this struct zero-initializes to a valid state! 9 | // FileBuffer buf = {}; //this is valid 10 | struct FileBuffer { 11 | uint8_t * block; 12 | uint8_t * head; 13 | uint8_t * end; 14 | 15 | void init(size_t bytes = 1024) { 16 | assert(bytes > 0); 17 | block = (uint8_t *) malloc(bytes); 18 | head = block; 19 | end = block + bytes; 20 | } 21 | 22 | void check(size_t bytes) { 23 | if (head + bytes < end) 24 | return; 25 | 26 | size_t byte = head - block; 27 | size_t size = end - block; 28 | 29 | //done in a loop so adding payloads larger than the current buffer size will work 30 | while (byte + bytes >= size) { 31 | size = size * 2 + 1; 32 | } 33 | 34 | block = (uint8_t *) realloc(block, size); 35 | head = block + byte; 36 | end = block + size; 37 | } 38 | 39 | template 40 | size_t write(TYPE t) { 41 | check(sizeof(t)); 42 | *((TYPE *)head) = t; 43 | size_t pos = head - block; 44 | head += sizeof(t); 45 | return pos; 46 | } 47 | 48 | template 49 | size_t write_unsafe(TYPE t) { 50 | *((TYPE *)head) = t; 51 | size_t pos = head - block; 52 | head += sizeof(t); 53 | return pos; 54 | } 55 | 56 | template 57 | size_t write_block(TYPE * t, size_t count) { 58 | check(count * sizeof(TYPE)); 59 | size_t pos = head - block; 60 | memcpy(head, t, count * sizeof(TYPE)); 61 | head += count * sizeof(TYPE); 62 | return pos; 63 | } 64 | 65 | template 66 | size_t write_block_unsafe(TYPE * t, size_t count) { 67 | size_t pos = head - block; 68 | memcpy(head, t, count * sizeof(TYPE)); 69 | head += count * sizeof(TYPE); 70 | return pos; 71 | } 72 | 73 | template 74 | size_t update(size_t pos, TYPE t) { 75 | uint8_t * ptr = block + pos; 76 | *((TYPE *)ptr) = t; 77 | return pos; 78 | } 79 | 80 | size_t size() { 81 | return head - block; 82 | } 83 | 84 | void finalize() { 85 | free(block); 86 | *this = {}; 87 | } 88 | }; 89 | 90 | //convenience function for same-line declaration+initialization 91 | inline FileBuffer create_file_buffer(size_t bytes = 1024) { 92 | FileBuffer buf; 93 | buf.init(bytes); 94 | return buf; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /lib/List.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ARRAYLIST_HPP 2 | #define ARRAYLIST_HPP 3 | 4 | #include 5 | #include 6 | 7 | //NOTE: this struct zero-initializes to a valid state! 8 | // List list = {}; //this is valid 9 | template 10 | struct List { 11 | TYPE * data; 12 | size_t len; 13 | size_t max; 14 | 15 | void init(size_t reserve = 1024 / sizeof(TYPE) + 1) { 16 | assert(reserve > 0); 17 | data = (TYPE *) malloc(reserve * sizeof(TYPE)); 18 | max = reserve; 19 | len = 0; 20 | } 21 | 22 | void add(TYPE t) { 23 | if (len == max) { 24 | max = max * 2 + 1; 25 | data = (TYPE *) realloc(data, max * sizeof(TYPE)); 26 | } 27 | 28 | data[len] = t; 29 | ++len; 30 | } 31 | 32 | void remove(size_t index) { 33 | assert(index < len); 34 | --len; 35 | for (int i = index; i < len; ++i) { 36 | data[i] = data[i + 1]; 37 | } 38 | } 39 | 40 | //removes elements in range [first, last) 41 | void remove(size_t first, size_t last) { 42 | assert(first < last); 43 | assert(last < len); 44 | size_t range = last - first; 45 | len -= range; 46 | for (int i = first; i < len; ++i) { 47 | data[i] = data[i + range]; 48 | } 49 | } 50 | 51 | void shrink_to_fit() { 52 | data = (TYPE *) realloc(data, len * sizeof(TYPE)); 53 | } 54 | 55 | void finalize() { 56 | free(data); 57 | *this = {}; 58 | } 59 | 60 | TYPE & operator[](size_t index) { 61 | return data[index]; 62 | } 63 | 64 | //no need to define an iterator class, because range-for will work with raw pointers 65 | TYPE * begin() { return { data }; } 66 | TYPE * end() { return { data + len }; } 67 | }; 68 | 69 | //convenience function for same-line declaration+initialization 70 | template 71 | List create_list(size_t reserve = 1024 / sizeof(TYPE) + 1) { 72 | List list; 73 | list.init(reserve); 74 | return list; 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/common.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_HPP 2 | #define COMMON_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | //////////////////////////////////////////////////////////////////////////////// 13 | /// TYPES /// 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | typedef uint8_t u8; 17 | typedef uint16_t u16; 18 | typedef uint32_t u32; 19 | typedef uint64_t u64; 20 | 21 | typedef int8_t i8; 22 | typedef int16_t i16; 23 | typedef int32_t i32; 24 | typedef int64_t i64; 25 | 26 | typedef int8_t s8; 27 | typedef int16_t s16; 28 | typedef int32_t s32; 29 | typedef int64_t s64; 30 | 31 | typedef uint8_t b8; 32 | typedef uint16_t b16; 33 | typedef uint32_t b32; 34 | typedef uint64_t b64; 35 | 36 | typedef float f32; 37 | typedef double f64; 38 | typedef long double f80; 39 | 40 | typedef unsigned int uint; 41 | 42 | template 43 | struct Pair { 44 | T1 first; 45 | T2 second; 46 | }; 47 | 48 | //////////////////////////////////////////////////////////////////////////////// 49 | /// RANGES /// 50 | //////////////////////////////////////////////////////////////////////////////// 51 | 52 | struct _range { 53 | int first; 54 | int last; 55 | int step; 56 | struct iterator { 57 | int value; 58 | int step; 59 | int operator*() { return value; } 60 | bool operator!=(iterator & other) { return value != other.value; } 61 | iterator& operator++() { value += step; return *this; } 62 | }; 63 | iterator begin() { return { first, step }; } 64 | iterator end() { return { last, step }; } 65 | }; 66 | inline _range range(int last) { return { 0, last, 1 }; } 67 | inline _range range(int first, int last) { return { first, last, first > last? -1 : 1 }; } 68 | 69 | //this uses a bogus comparison operator to iterate a null-terminated string 70 | //in a range for loop without needing to call strlen() first 71 | struct _strange { 72 | char * str; 73 | struct iterator { 74 | char * ch; 75 | char & operator*() { return *ch; } 76 | bool operator!=(iterator & other) { return *ch != '\0' && *other.ch != '\0'; } 77 | iterator& operator++() { ++ch; return *this; } 78 | }; 79 | iterator begin() { return { str }; } 80 | iterator end() { return { str }; } 81 | }; 82 | struct _const_strange { 83 | const char * str; 84 | struct iterator { 85 | const char * ch; 86 | const char & operator*() { return *ch; } 87 | bool operator!=(iterator & other) { return *ch != '\0' && *other.ch != '\0'; } 88 | iterator& operator++() { ++ch; return *this; } 89 | }; 90 | iterator begin() { return { str }; } 91 | iterator end() { return { str }; } 92 | }; 93 | inline _strange range(char * str) { return { str }; } 94 | inline _const_strange range(const char * str) { return { str }; } 95 | 96 | //////////////////////////////////////////////////////////////////////////////// 97 | /// STRING UTILS /// 98 | //////////////////////////////////////////////////////////////////////////////// 99 | 100 | inline char * dup(const char * src, int len) { 101 | char * ret = (char *) malloc(len + 1); 102 | strncpy(ret, src, len); 103 | ret[len] = '\0'; 104 | return ret; 105 | } 106 | 107 | inline char * dup(const char * src, char * end) { 108 | return dup(src, end - src); 109 | } 110 | 111 | inline char * dup(const char * src) { 112 | return dup(src, strlen(src)); 113 | } 114 | 115 | inline bool same(const char * first, const char * second) { 116 | return !strcmp(first, second); 117 | } 118 | 119 | //////////////////////////////////////////////////////////////////////////////// 120 | /// DEFER /// 121 | //////////////////////////////////////////////////////////////////////////////// 122 | 123 | //a simplified version of https://gist.github.com/p2004a/045726d70a490d12ad62 124 | template 125 | struct _defer { 126 | F f; 127 | _defer(F f) : f(f) {} 128 | ~_defer() { f(); } 129 | }; 130 | 131 | static struct { 132 | template 133 | _defer operator<<(F f) { return _defer(f); }; 134 | } _deferrer; 135 | 136 | #define TOKENPASTE2(x, y) x ## y 137 | #define TOKENPASTE(x, y) TOKENPASTE2(x, y) 138 | #define defer auto TOKENPASTE(__deferred_lambda_call, __COUNTER__) = _deferrer << [&] 139 | 140 | //////////////////////////////////////////////////////////////////////////////// 141 | /// ??? /// 142 | //////////////////////////////////////////////////////////////////////////////// 143 | 144 | //NOTE: the correct behavior of this function is unfortunately not guaranteed by the standard 145 | inline char * read_entire_file(const char * filepath) { 146 | FILE * f = fopen(filepath, "rb"); 147 | assert(f); 148 | fseek(f, 0, SEEK_END); 149 | long fsize = ftell(f); 150 | fseek(f, 0, SEEK_SET); //same as rewind(f); 151 | 152 | char * string = (char *) malloc(fsize + 1); 153 | fread(string, fsize, 1, f); 154 | fclose(f); 155 | 156 | string[fsize] = 0; 157 | 158 | return string; 159 | } 160 | 161 | template 162 | VAL match_pair(std::initializer_list> pairs, KEY key, VAL defaultVal) { 163 | for (auto it = pairs.begin(); it != pairs.end(); ++it) { 164 | if (it->second == key) { 165 | return it->first; 166 | } 167 | } 168 | return defaultVal; 169 | } 170 | 171 | template 172 | bool one_of(std::initializer_list list, TYPE key) { 173 | for (auto it = list.begin(); it != list.end(); ++it) { 174 | if (*it == key) { 175 | return true; 176 | } 177 | } 178 | return false; 179 | } 180 | 181 | template 182 | inline void swap(TYPE & a, TYPE & b) { 183 | TYPE temp = a; 184 | a = b; 185 | b = temp; 186 | } 187 | 188 | #define ARR_SIZE(x) (sizeof(x) / sizeof((x)[0])) 189 | 190 | #if defined(__GNUC__) 191 | # define UNUSED __attribute__ ((unused)) 192 | #elif defined(_MSC_VER) 193 | # define UNUSED __pragma(warning(suppress:4100)) 194 | #else 195 | # define UNUSED 196 | #endif 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /lib/stb_image.cpp: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_IMPLEMENTATION 2 | #define STBI_NO_JPEG 3 | // #define STBI_NO_PNG 4 | #define STBI_NO_BMP 5 | #define STBI_NO_PSD 6 | #define STBI_NO_TGA 7 | #define STBI_NO_GIF 8 | #define STBI_NO_HDR 9 | #define STBI_NO_PIC 10 | #define STBI_NO_PNM 11 | #include "stb_image.h" 12 | -------------------------------------------------------------------------------- /link/README-SDL.txt: -------------------------------------------------------------------------------- 1 | 2 | Please distribute this file with the SDL runtime environment: 3 | 4 | The Simple DirectMedia Layer (SDL for short) is a cross-platform library 5 | designed to make it easy to write multi-media software, such as games 6 | and emulators. 7 | 8 | The Simple DirectMedia Layer library source code is available from: 9 | https://www.libsdl.org/ 10 | 11 | This library is distributed under the terms of the zlib license: 12 | http://www.zlib.net/zlib_license.html 13 | 14 | -------------------------------------------------------------------------------- /link/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/link/SDL2.dll -------------------------------------------------------------------------------- /mac-build.sh: -------------------------------------------------------------------------------- 1 | gcc-8 -std=c++14 -Ilib -ISDL2 -Ofast -o game -lSDL2 lib/stb_image.cpp src/blit.cpp src/gif.cpp src/main.cpp || exit 2 | ./game 3 | -------------------------------------------------------------------------------- /notes.txt: -------------------------------------------------------------------------------- 1 | 2 | R = roughness [0, 1] 3 | M = metalness [0, 1] 4 | C = angle to camera 5 | L = angle to light 6 | S = angle of reflected light vector to camera 7 | I = IOR of material 8 | 9 | F = fresnel at C=0 10 | F = sq((1 - I) / (1 + I)) 11 | 12 | fresnel = F + (1 - R) * (1 - F) * sq(sq(1 - C)) * (1 - C) 13 | 14 | E = phong "exponent" 15 | E = 1 / (R + 0.01f) 16 | 17 | M = specular multiplier 18 | M = 1 / (R + 0.1f) 19 | 20 | specular = M * S / (E - E * S + S) 21 | 22 | 23 | 24 | //TODO: figure out how to derive phong exponent from roughness 25 | //TODO: figure out how to derive specular multiplier from phong exponent 26 | (maybe integrate phong curve over [0, 1]?) 27 | //TODO: figure out how metalness factors into all of this! 28 | 29 | 30 | -------------------------------------------------------------------------------- /old-code/sse2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SSE2_HPP 2 | #define SSE2_HPP 3 | 4 | void draw_triangle_sse2_plain(Canvas * canvas, ZBuffer * shadow, Tex * tex, Vert tri[3]); 5 | void draw_triangle_sse2(Canvas * canvas, ZBuffer * shadow, Tex * tex, Vert tri[3]); 6 | void draw_triangle_sse2_struct(Canvas * canvas, ZBuffer * shadow, Tex * tex, Vert tri[3]); 7 | 8 | #endif // SSE2_HPP 9 | -------------------------------------------------------------------------------- /ply/build.sh: -------------------------------------------------------------------------------- 1 | clang -std=c++1z -stdlib=libc++ -I../lib -Wall -Ofast -o ply ply.cpp -lc++ || exit 2 | ./ply -i sword7.ply -o sword7.diw -------------------------------------------------------------------------------- /res/build.sh: -------------------------------------------------------------------------------- 1 | cd "$(dirname "$0")" 2 | 3 | convert "src/CobbleStone_01_BC.png" -separate -delete 3 -swap 0,2 \( "src/CobbleStone_01_R.png" -separate \) -combine -flip "cobblestone1_c.png" 4 | convert "src/CobbleStone_01_N.png" -separate -delete 3 -swap 0,2 \( "src/CobbleStone_01_M.png" -separate \) -combine -flip "cobblestone1_n.png" 5 | 6 | convert "src/BrokenTiles_01_BC.png" -separate -delete 3 -swap 0,2 \( "src/BrokenTiles_01_R.png" -separate \) -combine -flip "tiles1_c.png" 7 | convert "src/BrokenTiles_01_N.png" -separate -delete 3 -swap 0,2 \( "src/BrokenTiles_01_M.png" -separate \) -combine -flip "tiles1_n.png" 8 | 9 | convert "src/Sword7_diffuse.png" -separate -delete 3 -swap 0,2 \( "src/Sword7_roughness.png" -separate \) -combine -flip "sword7_c.png" 10 | convert "src/Sword7_normal.png" -separate -delete 3 -swap 0,2 \( "src/Sword7_metallic.png" -separate \) -combine -flip "sword7_n.png" 11 | 12 | convert "src/Sword9_diffuse.png" -separate -delete 3 -swap 0,2 \( "src/Sword9_roughness.png" -separate \) -combine -flip "sword9_c.png" 13 | convert "src/Sword9_normal.png" -separate -delete 3 -swap 0,2 \( "src/Sword9_metallic.png" -separate \) -combine -flip "sword9_n.png" 14 | 15 | convert "src/Tomato_diffuse.png" -separate -delete 3 -swap 0,2 \( "src/Tomato_MetalSmooth.png" -separate -delete 0 -negate \) -combine -flip "tomato_c.png" 16 | convert "src/Tomato_normal.png" -separate -delete 3 -swap 0,2 \( "src/Tomato_MetalSmooth.png" -separate \) -combine -flip "tomato_n.png" 17 | 18 | convert "src/MetalSheets_01_BC.png" -separate -delete 3 -swap 0,2 \( "src/MetalSheets_01_R.png" -separate \) -combine -flip "metal1_c.png" 19 | convert "src/MetalSheets_01_N.png" -separate -delete 3 -swap 0,2 \( "src/MetalSheets_01_M.png" -separate \) -combine -flip "metal1_n.png" 20 | -------------------------------------------------------------------------------- /res/cobblestone1_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/cobblestone1_c.png -------------------------------------------------------------------------------- /res/cobblestone1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/cobblestone1_n.png -------------------------------------------------------------------------------- /res/metal1_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/metal1_c.png -------------------------------------------------------------------------------- /res/metal1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/metal1_n.png -------------------------------------------------------------------------------- /res/sword7.diw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword7.diw -------------------------------------------------------------------------------- /res/sword7_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword7_c.png -------------------------------------------------------------------------------- /res/sword7_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword7_n.png -------------------------------------------------------------------------------- /res/sword9.diw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword9.diw -------------------------------------------------------------------------------- /res/sword9_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword9_c.png -------------------------------------------------------------------------------- /res/sword9_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/sword9_n.png -------------------------------------------------------------------------------- /res/tiles1_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/tiles1_c.png -------------------------------------------------------------------------------- /res/tiles1_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/tiles1_n.png -------------------------------------------------------------------------------- /res/tomato.diw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/tomato.diw -------------------------------------------------------------------------------- /res/tomato_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/tomato_c.png -------------------------------------------------------------------------------- /res/tomato_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/notnullnotvoid/DIWide/1b476700f21f38a777ba42656a4e69aa85d970ed/res/tomato_n.png -------------------------------------------------------------------------------- /src/blit.hpp: -------------------------------------------------------------------------------- 1 | // HEAVYWEIGHT CANVAS OPERATIONS DEFINED HERE 2 | 3 | #ifndef BLIT_HPP 4 | #define BLIT_HPP 5 | 6 | #include "common.hpp" 7 | 8 | #include 9 | 10 | //match window surface's byte order for faster blit 11 | typedef struct Pixel { 12 | u8 b, g, r, a; 13 | } Color; 14 | 15 | struct Canvas { 16 | Pixel * base; //without the base address, we can't free the memory 17 | Pixel * pixels; 18 | size_t pixelBytes; 19 | float * depth; 20 | int width, height; 21 | int pitch, zpitch; //number of pixels, NOT number of bytes! 22 | }; 23 | 24 | struct ZBuffer { 25 | float * depth; 26 | float scale, inv; 27 | int width, height; 28 | u32 wmask, hmask; 29 | }; 30 | 31 | Canvas create_canvas(int width, int height, int margin); 32 | ZBuffer create_depth_buffer(int width, int height); 33 | void debug_depth_blit(SDL_Surface * canvas, ZBuffer * depth); 34 | void fast_scaled_blit(SDL_Surface * surface, Canvas * canvas, int scale); 35 | 36 | #endif // BLIT_HPP 37 | -------------------------------------------------------------------------------- /src/build.sh: -------------------------------------------------------------------------------- 1 | ../build.sh 2 | -------------------------------------------------------------------------------- /src/gif.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GIF_HPP 2 | #define GIF_HPP 3 | 4 | #include "List.hpp" 5 | #include "blit.hpp" //TODO: get rid of this dependency so it will be easy to drop into new projects 6 | 7 | struct RawFrame { 8 | Pixel * base; 9 | Pixel * pixels; 10 | int pitch; 11 | }; 12 | 13 | void save_gif(int width, int height, List rawFrames, int centiSeconds); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /timings.txt: -------------------------------------------------------------------------------- 1 | comparison of compilers for scalar and SIMD code using my software renderer as a guinea pig. 2 | code being compared can be found here: 3 | https://github.com/notnullnotvoid/DIWide/tree/c4fa0b297b1f30794fe01e796e6ca595d106abc3 4 | 5 | 6 | 7 | speed: 8 | 9 | cycle counts for core rasterization loop 10 | data is very noisy, so only 3 significant digits were measured 11 | 12 | NOTE: arch for all compilers is base x64 ISA (max instruction set = SSE2) 13 | 14 | clang O0 scalar 201000k+ 15 | clang O1 scalar 47100k+ 16 | clang O2 scalar 23000k+ 17 | clang O3 scalar 22900k+ 18 | clang Of scalar 22000k+ 19 | clang Os scalar 23000k+ 20 | 21 | clang O0 sse2 1 43400k+ 22 | clang O1 sse2 1 12800k+ 23 | clang O2 sse2 1 12600k+ 24 | clang O3 sse2 1 12500k+ 25 | clang Of sse2 1 12400k+ 26 | clang Os sse2 1 12000k+ 27 | 28 | clang O0 sse2 2 107000k+ 29 | clang O1 sse2 2 56400k+ 30 | clang O2 sse2 2 12500k+ 31 | clang O3 sse2 2 12500k+ 32 | clang Of sse2 2 12400k+ 33 | clang Os sse2 2 11900k+ 34 | 35 | clang O0 sse2 3 257000k+ 36 | clang O1 sse2 3 55100k+ 37 | clang O2 sse2 3 12300k+ 38 | clang O3 sse2 3 12300k+ 39 | clang Of sse2 3 12200k+ 40 | clang Os sse2 3 12100k+ 41 | 42 | 43 | 44 | clang-6 O0 scalar 207000k+ 45 | clang-6 O1 scalar 48600k+ 46 | clang-6 O2 scalar 24000k+ 47 | clang-6 O3 scalar 24100k+ 48 | clang-6 Of scalar 24000k+ 49 | clang-6 Os scalar 24100k+ 50 | 51 | clang-6 O0 sse2 1 51100k+ 52 | clang-6 O1 sse2 1 13000k+ 53 | clang-6 O2 sse2 1 12100k+ 54 | clang-6 O3 sse2 1 12000k+ 55 | clang-6 Of sse2 1 11800k+ 56 | clang-6 Os sse2 1 11800k+ 57 | 58 | clang-6 O0 sse2 2 161000k+ 59 | clang-6 O1 sse2 2 62900k+ 60 | clang-6 O2 sse2 2 11900k+ 61 | clang-6 O3 sse2 2 12500k+ 62 | clang-6 Of sse2 2 12100k+ 63 | clang-6 Os sse2 2 11800k+ 64 | 65 | clang-6 O0 sse2 3 319000k+ 66 | clang-6 O1 sse2 3 54900k+ 67 | clang-6 O2 sse2 3 11600k+ 68 | clang-6 O3 sse2 3 11900k+ 69 | clang-6 Of sse2 3 11900k+ 70 | clang-6 Os sse2 3 11900k+ 71 | 72 | 73 | 74 | gcc-8 O0 scalar 174000k+ 75 | gcc-8 O1 scalar 30400k+ 76 | gcc-8 O2 scalar 28900k+ 77 | gcc-8 O3 scalar 28800k+ 78 | gcc-8 Of scalar 22000k+ 79 | gcc-8 Os scalar 88300k+ 80 | 81 | gcc-8 O0 sse2 1 48800k+ 82 | gcc-8 O1 sse2 1 12600k+ 83 | gcc-8 O2 sse2 1 12500k+ 84 | gcc-8 O3 sse2 1 10100k+ 85 | gcc-8 Of sse2 1 9950k+ new = 34400k+ 56fps 86 | gcc-8 Os sse2 1 13500k+ 87 | 88 | gcc-8 O0 sse2 2 101000k+ 89 | gcc-8 O1 sse2 2 12400k+ 90 | gcc-8 O2 sse2 2 12400k+ 91 | gcc-8 O3 sse2 2 10200k+ 92 | gcc-8 Of sse2 2 10200k+ 93 | gcc-8 Os sse2 2 13600k+ 94 | 95 | gcc-8 O0 sse2 3 98900k+ 96 | gcc-8 O1 sse2 3 12500k+ 97 | gcc-8 O2 sse2 3 12400k+ 98 | gcc-8 O3 sse2 3 10000k+ 99 | gcc-8 Of sse2 3 9980k+ 100 | gcc-8 Os sse2 3 13000k+ 101 | 102 | 103 | 104 | factor = ~3.5 [3.45 ~ 3.55] 105 | NOTE: all msvc cycle timings are ~3.5x what they should be, for reasons beyond my understanding 106 | so to compare results against other compilers, you should divide these numbers by 3.5 107 | 108 | msvc Od scalar 2380000k+ !!!??? 109 | msvc O1 scalar 177000k+ 110 | msvc O2 scalar 166000k+ 111 | msvc Ox scalar 168000k+ 112 | msvc Os scalar 1980000k+ 113 | 114 | msvc Od sse2 1 139000k+ 115 | msvc O1 sse2 1 43700k+ 116 | msvc O2 sse2 1 42800k+ 117 | msvc Ox sse2 1 42100k+ fps = 47 118 | msvc Os sse2 1 138000k+ 119 | 120 | msvc Od sse2 2 443000k+ 121 | msvc O1 sse2 2 43900k+ 122 | msvc O2 sse2 2 43300k+ 123 | msvc Ox sse2 2 42900k+ 124 | msvc Os sse2 2 438000k+ 125 | 126 | msvc Od sse2 3 726000k+ 127 | msvc O1 sse2 3 44100k+ 128 | msvc O2 sse2 3 43000k+ 129 | msvc Ox sse2 3 43200k+ 130 | msvc Os sse2 3 739000k+ 131 | 132 | 133 | 134 | size: 135 | 136 | clang O0 207kb 137 | clang O1 121kb 138 | clang O2 139kb 139 | clang O3 139kb 140 | clang Of 139kb 141 | clang Os 107kb 142 | clang O0 -flto 70kb 143 | clang O1 -flto 78kb 144 | clang O2 -flto 86kb 145 | clang O3 -flto 86kb 146 | clang Of -flto 86kb 147 | clang Os -flto 61kb 148 | 149 | clang-6 O0 215kb 150 | clang-6 O1 121kb 151 | clang-6 O2 139kb 152 | clang-6 O3 147kb 153 | clang-6 Of 147kb 154 | clang-6 Os 107kb 155 | clang-6 O0 -flto 104kb 156 | clang-6 O1 -flto 78kb 157 | clang-6 O2 -flto 82kb 158 | clang-6 O3 -flto 94kb 159 | clang-6 Of -flto 94kb 160 | clang-6 Os -flto 61kb 161 | 162 | gcc-8 O0 198kb 163 | gcc-8 O1 125kb 164 | gcc-8 O2 129kb 165 | gcc-8 O3 194kb 166 | gcc-8 Of 185kb 167 | gcc-8 Os 114kb 168 | gcc-8 O0 -flto 189kb 169 | gcc-8 O1 -flto 125kb 170 | gcc-8 O2 -flto 137kb 171 | gcc-8 O3 -flto 194kb 172 | gcc-8 Of -flto 190kb 173 | gcc-8 Os -flto 97kb 174 | 175 | msvc Od 377kb 176 | msvc O1 227kb 177 | msvc O2 232kb 178 | msvc Ox 276kb 179 | msvc Os 374kb 180 | 181 | 182 | 183 | compile: 184 | 185 | full rebuild (all code + assets) 512x textures gcc-8 -Ofast -flto = 7.4s 186 | 187 | NOTE: all timings are multi-threaded compilation (4 cores) + single-threaded linker 188 | 189 | clang -O0 0.483s 190 | clang -O1 0.736s 191 | clang -O2 1.558s 192 | clang -O3 1.619s 193 | clang -Of 1.618s 194 | clang -Os 1.102s 195 | clang -O0 -flto 1.139s 196 | clang -O1 -flto 1.334s 197 | clang -O2 -flto 1.854s 198 | clang -O3 -flto 1.896s 199 | clang -Of -flto 1.890s 200 | clang -Os -flto 1.255s 201 | 202 | clang-6 -O0 0.712s 203 | clang-6 -O1 0.992s 204 | clang-6 -O2 1.483s 205 | clang-6 -O3 1.608s 206 | clang-6 -Of 1.607s 207 | clang-6 -Os 1.342s 208 | clang-6 -O0 -flto 0.936s 209 | clang-6 -O1 -flto 1.895s 210 | clang-6 -O2 -flto 1.854s 211 | clang-6 -O3 -flto 2.125s 212 | clang-6 -Of -flto 2.354s 213 | clang-6 -Os -flto 1.830s 214 | 215 | gcc-8 -O0 0.869s 216 | gcc-8 -O1 1.422s 217 | gcc-8 -O2 1.415s 218 | gcc-8 -O3 2.206s 219 | gcc-8 -Of 2.207s 220 | gcc-8 -Os 1.316s 221 | gcc-8 -O0 -flto 1.618s 222 | gcc-8 -O1 -flto 2.895s 223 | gcc-8 -O2 -flto 3.401s 224 | gcc-8 -O3 -flto 5.798s 225 | gcc-8 -Of -flto 5.707s 226 | gcc-8 -Os -flto 2.808s 227 | 228 | msvc -Od 0.92s 229 | msvc -O1 1.29s 230 | msvc -O2 1.34s 231 | msvc -Ox 1.32s 232 | msvc -Os 0.84s 233 | -------------------------------------------------------------------------------- /win-build.bat: -------------------------------------------------------------------------------- 1 | cl /std:c++14 /MP /Ox /ISDL2 /Ilib lib/stb_image.cpp src/blit.cpp src/gif.cpp src/main.cpp /link /out:game.exe /SUBSYSTEM:CONSOLE || exit /b 2 | del *.obj 3 | game.exe 4 | --------------------------------------------------------------------------------