├── CMakeLists.txt ├── README.md ├── assets ├── explosion.png ├── spaceship.png ├── torpedo.png └── ufo.png ├── cmake ├── AssetUtilities.cmake ├── BoilerPlate.cmake └── UtilityFunctions.cmake ├── lib ├── SDL2 │ ├── SDL2Config.cmake │ ├── SDL2ConfigVersion.cmake │ ├── emscripten │ │ └── libSDL2.a │ ├── include │ │ └── 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_emscripten.h │ │ │ ├── SDL_config_linux.h │ │ │ ├── SDL_config_macosx.h │ │ │ ├── SDL_config_windows.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_rwops.h │ │ │ ├── SDL_scancode.h │ │ │ ├── SDL_shape.h │ │ │ ├── SDL_stdinc.h │ │ │ ├── SDL_surface.h │ │ │ ├── SDL_system.h │ │ │ ├── SDL_syswm.h │ │ │ ├── SDL_thread.h │ │ │ ├── SDL_timer.h │ │ │ ├── SDL_touch.h │ │ │ ├── SDL_types.h │ │ │ ├── SDL_version.h │ │ │ ├── SDL_video.h │ │ │ ├── begin_code.h │ │ │ └── close_code.h │ ├── linux │ │ ├── lib │ │ │ ├── libSDL2-2.0.so.0 │ │ │ ├── libSDL2-2.0.so.0.4.0 │ │ │ └── libSDL2.so │ │ └── lib64 │ │ │ ├── libSDL2-2.0.so.0 │ │ │ ├── libSDL2-2.0.so.0.4.0 │ │ │ └── libSDL2.so │ ├── osx │ │ └── libSDL2.dylib │ └── win32 │ │ ├── SDL2.dll │ │ ├── SDL2.lib │ │ └── SDL2main.lib ├── humble │ ├── humble_api.h │ ├── library_cloudfs.jslib │ └── library_humble.jslib └── lodepng │ ├── CMakeLists.txt │ ├── SDL_LodePNG.c │ ├── SDL_LodePNG.h │ ├── lodepng.cpp │ └── lodepng.h ├── shell.html └── src ├── AssetManager.cpp ├── AssetManager.h ├── Color.h ├── Enemy.cpp ├── Enemy.h ├── Entity.cpp ├── Entity.h ├── Explosion.cpp ├── Explosion.h ├── FileSystem.cpp ├── FileSystem.h ├── Game.cpp ├── Game.h ├── Player.cpp ├── Player.h ├── Projectile.cpp ├── Projectile.h ├── Rect.h ├── Renderable.h ├── Renderer.cpp ├── Renderer.h ├── Renderer_SDL2.cpp ├── Renderer_SDL2.h ├── Sprite.cpp ├── Sprite.h ├── Texture.cpp ├── Texture.h ├── Texture_SDL2.cpp ├── Texture_SDL2.h ├── Updatable.h ├── Vector2.h └── main.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | Project(HumbleASMJSDemo) 3 | 4 | if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 5 | message(FATAL_ERROR "You must set your binary directory different from your source") 6 | endif() 7 | 8 | ### pull in boilerplate cmake 9 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 10 | include(BoilerPlate) 11 | include(UtilityFunctions) 12 | include(AssetUtilities) 13 | 14 | # this sets the paths that cmake will use to locate libs (via the FindXXX.cmake or XXConfig.cmake scripts) 15 | LIST(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL2) 16 | 17 | ### Find Libraries 18 | find_package(OpenGL) 19 | find_package(SDL2 NO_CMAKE_FIND_ROOT_PATH) 20 | add_subdirectory(lib/lodepng lodepng) 21 | 22 | if(EMSCRIPTEN) 23 | set(OPENGL_gl_LIBRARY "") 24 | 25 | EmscriptenCreatePackage(${PROJECT_NAME} DATA_FILE 26 | PRELOAD ${CMAKE_CURRENT_SOURCE_DIR}/assets@assets 27 | ) 28 | endif() 29 | 30 | CreateProgram(${PROJECT_NAME} 31 | DIRS 32 | src 33 | INCLUDES 34 | src 35 | ${SDL2_INCLUDE_DIRS} 36 | lib/humble 37 | DEFINES 38 | $<$:USE_HUMBLE_API> 39 | LINK 40 | ${SDL2_LIBRARIES} 41 | ${OPENGL_gl_LIBRARY} 42 | lodepng 43 | FLAGS 44 | $<$:-std=c++0x> 45 | $<$:-std=c++0x> 46 | $<$:-std=c++0x> 47 | PRE_JS 48 | ${DATA_FILE} 49 | JS_LIBS 50 | lib/humble/library_cloudfs.jslib 51 | lib/humble/library_humble.jslib 52 | PROPERTIES 53 | FOLDER Executables 54 | MACOSX_BUNDLE_BUNDLE_NAME "Humble asm.js Demo" 55 | MACOSX_BUNDLE_BUNDLE_VERSION "1.0" 56 | MACOSX_BUNDLE_GUI_IDENTIFIER "com.humblebundle.HumbleAsmjsDemo" 57 | MACOSX_BUNDLE_COPYRIGHT "© 2015 Humble Bundle, Inc. " 58 | ) 59 | source_group("Source" REGULAR_EXPRESSION "\\.(cpp|h)$") 60 | 61 | 62 | if(EMSCRIPTEN) 63 | set(EM_TARGET_JS ${PROJECT_NAME}.js) 64 | configure_file(shell.html index.html @ONLY) 65 | endif() 66 | 67 | ## this auto copies the needed libraries / frameworks over 68 | CopyDependentLibs(${PROJECT_NAME}) 69 | 70 | if(NOT EMSCRIPTEN) 71 | CreateFolderMarkerFile(${PROJECT_NAME} asset_path.txt ${CMAKE_CURRENT_SOURCE_DIR}/assets) 72 | endif() 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ASMJSDemo 2 | Simple SDL2/C++ asm.js demo 3 | 4 | Check out the below blog post at the Humble Bundle developer blog to get set up your development environment for this demo: 5 | 6 | http://developer.humblebundle.com/post/112252930481/developing-for-asm-js-using-sdl2 7 | 8 | Keep an eye on the developer blog for more asm.js posts and development resources! 9 | 10 | http://developer.humblebundle.com/ 11 | 12 | - Team Humble Developer 13 | -------------------------------------------------------------------------------- /assets/explosion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/assets/explosion.png -------------------------------------------------------------------------------- /assets/spaceship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/assets/spaceship.png -------------------------------------------------------------------------------- /assets/torpedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/assets/torpedo.png -------------------------------------------------------------------------------- /assets/ufo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/assets/ufo.png -------------------------------------------------------------------------------- /cmake/AssetUtilities.cmake: -------------------------------------------------------------------------------- 1 | function(CreateFolderMarkerFile target marker_file_name folder) 2 | set(_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}_marker_file.cmake") 3 | 4 | file(WRITE ${_SCRIPT_FILE} 5 | "# Generated Script file 6 | if(APPLE) 7 | include(BundleUtilities) 8 | get_bundle_and_executable(\"\${APP_PATH}\" bundle executable valid) 9 | if(valid) 10 | set(dest \"\${bundle}/Contents/Resources\") 11 | else() 12 | message(FATAL_ERROR \"App not found? \${APP_PATH}\") 13 | endif() 14 | else() 15 | get_filename_component(dest \"\${APP_PATH}\" DIRECTORY) 16 | endif() 17 | message(STATUS \"Dest: \${dest}\") 18 | message(STATUS \"Folder: ${folder}\") 19 | file(MAKE_DIRECTORY \"\${dest}\") 20 | file(RELATIVE_PATH relpath \"\${dest}\" \"${folder}\") 21 | file(WRITE \"\${dest}/${marker_file_name}\" \"\${relpath}\") 22 | " 23 | ) 24 | 25 | ADD_CUSTOM_COMMAND(TARGET ${target} 26 | POST_BUILD 27 | COMMAND ${CMAKE_COMMAND} -DAPP_PATH="$" -P "${_SCRIPT_FILE}" 28 | ) 29 | endfunction() -------------------------------------------------------------------------------- /cmake/BoilerPlate.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | 3 | ### setup options 4 | ## Include guard 5 | if(NOT BOILERPLATE_LOADED) 6 | set(BOILERPLATE_LOADED ON) 7 | 8 | option(FULL_WARNINGS "Enable full warnings" OFF) 9 | option(ENABLE_SSE4 "Enable SSE 4" ${DEFAULT_ENABLE_SSE4}) 10 | option(FORCE32 "Force a 32bit compile on 64bit" OFF) 11 | 12 | if("${CMAKE_SYSTEM}" MATCHES "Linux") 13 | set(LINUX ON) 14 | endif() 15 | 16 | if(EMSCRIPTEN) 17 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-warn-absolute-paths") 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths") 19 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g4 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") 20 | endif() 21 | 22 | if(FORCE32) 23 | if(LINUX AND NOT EMSCRIPTEN) 24 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") 25 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") 26 | elseif(APPLE) 27 | set(CMAKE_OSX_ARCHITECTURES "i386") 28 | endif() 29 | endif() 30 | 31 | if(FULL_WARNINGS) 32 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 33 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 34 | endif() 35 | 36 | if(NOT WIN32 AND NOT EMSCRIPTEN) 37 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing") 38 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") 39 | endif() 40 | 41 | if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) 42 | set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6") 43 | endif() 44 | 45 | if(EMSCRIPTEN) 46 | set(PLATFORM_PREFIX "emscripten") 47 | set(CMAKE_EXECUTABLE_SUFFIX ".js") 48 | elseif(LINUX) 49 | set(PLATFORM_PREFIX "linux") 50 | if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE32) ) 51 | set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86_64") 52 | set(LIB_RPATH_DIR "lib64") 53 | set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) 54 | else() 55 | set(LINUX_X86 ON) 56 | set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86") 57 | set(LIB_RPATH_DIR "lib") 58 | set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) 59 | 60 | ### Ensure LargeFileSupport on 32bit linux 61 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64") 62 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64") 63 | 64 | ### Enable SSE instructions 65 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3") 66 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3") 67 | ### Enable SSE4 instructions 68 | if(ENABLE_SSE4) 69 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4") 70 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4") 71 | endif() 72 | endif() 73 | 74 | set_property(GLOBAL PROPERTY LIBRARY_RPATH_DIRECTORY ${LIB_RPATH_DIR}) 75 | 76 | set(CMAKE_SKIP_BUILD_RPATH TRUE) 77 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 78 | set(CMAKE_INSTALL_RPATH "\$ORIGIN/${LIB_RPATH_DIR}") 79 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) 80 | elseif(APPLE) 81 | set(PLATFORM_PREFIX "macosx") 82 | 83 | set(BIN_RPATH "@executable_path/../Frameworks") 84 | 85 | set(CMAKE_SKIP_BUILD_RPATH TRUE) 86 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 87 | set(CMAKE_INSTALL_RPATH ${BIN_RPATH}) 88 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) 89 | 90 | ### Enable SSE4 instructions 91 | if(ENABLE_SSE4) 92 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4") 93 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4") 94 | endif() 95 | elseif(WIN32) 96 | set(PLATFORM_PREFIX "win32") 97 | else() 98 | MESSAGE(FATAL_ERROR "Unhandled Platform") 99 | endif() 100 | 101 | ### Export parent scope 102 | if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) 103 | message(STATUS "Exporting variables to parent scope") 104 | 105 | set(LINUX ${LINUX} PARENT_SCOPE) 106 | set(LINUX_X86 ${LINUX_X86} PARENT_SCOPE) 107 | set(FORCE32 ${FORCE32} PARENT_SCOPE) 108 | set(PLATFORM_PREFIX ${PLATFORM_PREFIX} PARENT_SCOPE) 109 | 110 | set(CMAKE_INCLUDE_CURRENT_DIR ${CMAKE_INCLUDE_CURRENT_DIR} PARENT_SCOPE) 111 | 112 | if(APPLE) 113 | set(CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES} PARENT_SCOPE) 114 | set(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE) 115 | endif() 116 | 117 | set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} PARENT_SCOPE) 118 | set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} PARENT_SCOPE) 119 | 120 | set(CMAKE_SKIP_BUILD_RPATH ${CMAKE_SKIP_BUILD_RPATH} PARENT_SCOPE) 121 | set(CMAKE_BUILD_WITH_INSTALL_RPATH ${CMAKE_BUILD_WITH_INSTALL_RPATH} PARENT_SCOPE) 122 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} PARENT_SCOPE) 123 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ${CMAKE_INSTALL_RPATH_USE_LINK_PATH} PARENT_SCOPE) 124 | set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX} PARENT_SCOPE) 125 | endif() 126 | 127 | ## include guard 128 | endif() 129 | -------------------------------------------------------------------------------- /lib/SDL2/SDL2Config.cmake: -------------------------------------------------------------------------------- 1 | if(APPLE) 2 | set(suffix "osx") 3 | elseif(EMSCRIPTEN) 4 | set(suffix "emscripten") 5 | elseif(WIN32) 6 | set(suffix "win32") 7 | elseif(CMAKE_SYSTEM MATCHES "Linux") 8 | set(suffix "linux") 9 | endif() 10 | 11 | find_library(SDL2_LIBRARY 12 | NAMES SDL2 13 | PATHS "${CMAKE_CURRENT_LIST_DIR}/${suffix}/lib" "${CMAKE_CURRENT_LIST_DIR}/${suffix}" 14 | NO_DEFAULT_PATH 15 | NO_CMAKE_FIND_ROOT_PATH 16 | ) 17 | find_library(SDL2_main_LIBRARY 18 | NAMES SDL2main 19 | PATHS "${CMAKE_CURRENT_LIST_DIR}/${suffix}/lib" "${CMAKE_CURRENT_LIST_DIR}/${suffix}" 20 | NO_DEFAULT_PATH 21 | NO_CMAKE_FIND_ROOT_PATH 22 | ) 23 | find_path(SDL2_INCLUDE_DIR 24 | NAMES SDL.h 25 | PATHS "${CMAKE_CURRENT_LIST_DIR}/include" 26 | PATH_SUFFIXES SDL2 27 | NO_DEFAULT_PATH 28 | NO_CMAKE_FIND_ROOT_PATH 29 | ) 30 | set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) 31 | set(SDL2_LIBRARIES ${SDL2_LIBRARY}) 32 | if(SDL2_main_LIBRARY) 33 | list(APPEND SDL2_LIBRARIES 34 | ${SDL2_main_LIBRARY} 35 | ) 36 | endif() 37 | 38 | mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY SDL2_main_LIBRARY) 39 | -------------------------------------------------------------------------------- /lib/SDL2/SDL2ConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "2.0.4") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() -------------------------------------------------------------------------------- /lib/SDL2/emscripten/libSDL2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/emscripten/libSDL2.a -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_joystick.h" 44 | #include "SDL_gamecontroller.h" 45 | #include "SDL_haptic.h" 46 | #include "SDL_hints.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_system.h" 55 | #include "SDL_thread.h" 56 | #include "SDL_timer.h" 57 | #include "SDL_version.h" 58 | #include "SDL_video.h" 59 | 60 | #include "begin_code.h" 61 | /* Set up for C function definitions, even when using C++ */ 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* As of version 0.5, SDL is loaded dynamically into the application */ 67 | 68 | /** 69 | * \name SDL_INIT_* 70 | * 71 | * These are the flags which may be passed to SDL_Init(). You should 72 | * specify the subsystems which you will be using in your application. 73 | */ 74 | /* @{ */ 75 | #define SDL_INIT_TIMER 0x00000001 76 | #define SDL_INIT_AUDIO 0x00000010 77 | #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ 78 | #define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ 79 | #define SDL_INIT_HAPTIC 0x00001000 80 | #define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ 81 | #define SDL_INIT_EVENTS 0x00004000 82 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */ 83 | #define SDL_INIT_EVERYTHING ( \ 84 | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ 85 | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ 86 | ) 87 | /* @} */ 88 | 89 | /** 90 | * This function initializes the subsystems specified by \c flags 91 | */ 92 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 93 | 94 | /** 95 | * This function initializes specific SDL subsystems 96 | * 97 | * Subsystem initialization is ref-counted, you must call 98 | * SDL_QuitSubSystem for each SDL_InitSubSystem to correctly 99 | * shutdown a subsystem manually (or call SDL_Quit to force shutdown). 100 | * If a subsystem is already loaded then this call will 101 | * increase the ref-count and return. 102 | */ 103 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 104 | 105 | /** 106 | * This function cleans up specific SDL subsystems 107 | */ 108 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 109 | 110 | /** 111 | * This function returns a mask of the specified subsystems which have 112 | * previously been initialized. 113 | * 114 | * If \c flags is 0, it returns a mask of all initialized subsystems. 115 | */ 116 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 117 | 118 | /** 119 | * This function cleans up all initialized subsystems. You should 120 | * call it upon all exit conditions. 121 | */ 122 | extern DECLSPEC void SDLCALL SDL_Quit(void); 123 | 124 | /* Ends C function definitions when using C++ */ 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | #include "close_code.h" 129 | 130 | #endif /* _SDL_H */ 131 | 132 | /* vi: set ts=4 sw=4 expandtab: */ 133 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | SDL_FORCE_INLINE int 51 | SDL_MostSignificantBitIndex32(Uint32 x) 52 | { 53 | #if defined(__GNUC__) && __GNUC__ >= 4 54 | /* Count Leading Zeroes builtin in GCC. 55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 56 | */ 57 | if (x == 0) { 58 | return -1; 59 | } 60 | return 31 - __builtin_clz(x); 61 | #else 62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 63 | * , released in the public domain. 64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 65 | */ 66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 67 | const int S[] = {1, 2, 4, 8, 16}; 68 | 69 | int msbIndex = 0; 70 | int i; 71 | 72 | if (x == 0) { 73 | return -1; 74 | } 75 | 76 | for (i = 4; i >= 0; i--) 77 | { 78 | if (x & b[i]) 79 | { 80 | x >>= S[i]; 81 | msbIndex |= S[i]; 82 | } 83 | } 84 | 85 | return msbIndex; 86 | #endif 87 | } 88 | 89 | /* Ends C function definitions when using C++ */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #include "close_code.h" 94 | 95 | #endif /* _SDL_bits_h */ 96 | 97 | /* vi: set ts=4 sw=4 expandtab: */ 98 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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; 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* _SDL_blendmode_h */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | #ifdef USING_PREMAKE_CONFIG_H 33 | #include "SDL_config_premake.h" 34 | #elif defined(__WIN32__) 35 | #include "SDL_config_windows.h" 36 | #elif defined(__WINRT__) 37 | #include "SDL_config_winrt.h" 38 | #elif defined(__MACOSX__) 39 | #include "SDL_config_macosx.h" 40 | #elif defined(__IPHONEOS__) 41 | #include "SDL_config_iphoneos.h" 42 | #elif defined(__ANDROID__) 43 | #include "SDL_config_android.h" 44 | #elif defined(__PSP__) 45 | #include "SDL_config_psp.h" 46 | #elif defined(__linux__) 47 | #include "SDL_config_linux.h" 48 | #elif defined(EMSCRIPTEN) 49 | #include "SDL_config_emscripten.h" 50 | #else 51 | /* This is a minimal configuration just to get SDL running on new platforms */ 52 | #include "SDL_config_minimal.h" 53 | #endif /* platform config */ 54 | 55 | #ifdef USING_GENERATED_CONFIG_H 56 | #error Wrong SDL_config.h, check your include path? 57 | #endif 58 | 59 | #endif /* _SDL_config_h */ 60 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_config_macosx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | 25 | #include "SDL_platform.h" 26 | 27 | /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ 28 | #include 29 | 30 | /* This is a set of defines to configure the SDL features */ 31 | 32 | #ifdef __LP64__ 33 | #define SIZEOF_VOIDP 8 34 | #else 35 | #define SIZEOF_VOIDP 4 36 | #endif 37 | 38 | /* Useful headers */ 39 | #define HAVE_ALLOCA_H 1 40 | #define HAVE_SYS_TYPES_H 1 41 | #define HAVE_STDIO_H 1 42 | #define STDC_HEADERS 1 43 | #define HAVE_STRING_H 1 44 | #define HAVE_INTTYPES_H 1 45 | #define HAVE_STDINT_H 1 46 | #define HAVE_CTYPE_H 1 47 | #define HAVE_MATH_H 1 48 | #define HAVE_SIGNAL_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_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_STRDUP 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_CEIL 1 88 | #define HAVE_COPYSIGN 1 89 | #define HAVE_COS 1 90 | #define HAVE_COSF 1 91 | #define HAVE_FABS 1 92 | #define HAVE_FLOOR 1 93 | #define HAVE_LOG 1 94 | #define HAVE_POW 1 95 | #define HAVE_SCALBN 1 96 | #define HAVE_SIN 1 97 | #define HAVE_SINF 1 98 | #define HAVE_SQRT 1 99 | #define HAVE_SIGACTION 1 100 | #define HAVE_SETJMP 1 101 | #define HAVE_NANOSLEEP 1 102 | #define HAVE_SYSCONF 1 103 | #define HAVE_SYSCTLBYNAME 1 104 | #define HAVE_ATAN 1 105 | #define HAVE_ATAN2 1 106 | #define HAVE_ACOS 1 107 | #define HAVE_ASIN 1 108 | 109 | /* Enable various audio drivers */ 110 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 111 | #define SDL_AUDIO_DRIVER_DISK 1 112 | #define SDL_AUDIO_DRIVER_DUMMY 1 113 | 114 | /* Enable various input drivers */ 115 | #define SDL_JOYSTICK_IOKIT 1 116 | #define SDL_HAPTIC_IOKIT 1 117 | 118 | /* Enable various shared object loading systems */ 119 | #define SDL_LOADSO_DLOPEN 1 120 | 121 | /* Enable various threading systems */ 122 | #define SDL_THREAD_PTHREAD 1 123 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 124 | 125 | /* Enable various timer systems */ 126 | #define SDL_TIMER_UNIX 1 127 | 128 | /* Enable various video drivers */ 129 | #define SDL_VIDEO_DRIVER_COCOA 1 130 | #define SDL_VIDEO_DRIVER_DUMMY 1 131 | #undef SDL_VIDEO_DRIVER_X11 132 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" 133 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" 134 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" 135 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" 136 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" 137 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" 138 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" 139 | #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 140 | #define SDL_VIDEO_DRIVER_X11_XRANDR 1 141 | #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 142 | #define SDL_VIDEO_DRIVER_X11_XSHAPE 1 143 | #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 144 | #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 145 | 146 | #ifdef MAC_OS_X_VERSION_10_8 147 | /* 148 | * No matter the versions targeted, this is the 10.8 or later SDK, so you have 149 | * to use the external Xquartz, which is a more modern Xlib. Previous SDKs 150 | * used an older Xlib. 151 | */ 152 | #define SDL_VIDEO_DRIVER_X11_XINPUT2 1 153 | #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 154 | #define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 155 | #endif 156 | 157 | #ifndef SDL_VIDEO_RENDER_OGL 158 | #define SDL_VIDEO_RENDER_OGL 1 159 | #endif 160 | 161 | /* Enable OpenGL support */ 162 | #ifndef SDL_VIDEO_OPENGL 163 | #define SDL_VIDEO_OPENGL 1 164 | #endif 165 | #ifndef SDL_VIDEO_OPENGL_CGL 166 | #define SDL_VIDEO_OPENGL_CGL 1 167 | #endif 168 | #ifndef SDL_VIDEO_OPENGL_GLX 169 | #define SDL_VIDEO_OPENGL_GLX 1 170 | #endif 171 | 172 | /* Enable system power support */ 173 | #define SDL_POWER_MACOSX 1 174 | 175 | /* enable filesystem support */ 176 | #define SDL_FILESYSTEM_COCOA 1 177 | 178 | /* Enable assembly routines */ 179 | #define SDL_ASSEMBLY_ROUTINES 1 180 | #ifdef __ppc__ 181 | #define SDL_ALTIVEC_BLITTERS 1 182 | #endif 183 | 184 | #endif /* _SDL_config_macosx_h */ 185 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_config_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 72 | 73 | #ifdef _WIN64 74 | # define SIZEOF_VOIDP 8 75 | #else 76 | # define SIZEOF_VOIDP 4 77 | #endif 78 | 79 | #define HAVE_DDRAW_H 1 80 | #define HAVE_DINPUT_H 1 81 | #define HAVE_DSOUND_H 1 82 | #define HAVE_DXGI_H 1 83 | #define HAVE_XINPUT_H 1 84 | 85 | /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ 86 | #ifdef HAVE_LIBC 87 | /* Useful headers */ 88 | #define HAVE_STDIO_H 1 89 | #define STDC_HEADERS 1 90 | #define HAVE_STRING_H 1 91 | #define HAVE_CTYPE_H 1 92 | #define HAVE_MATH_H 1 93 | #define HAVE_SIGNAL_H 1 94 | 95 | /* C library functions */ 96 | #define HAVE_MALLOC 1 97 | #define HAVE_CALLOC 1 98 | #define HAVE_REALLOC 1 99 | #define HAVE_FREE 1 100 | #define HAVE_ALLOCA 1 101 | #define HAVE_QSORT 1 102 | #define HAVE_ABS 1 103 | #define HAVE_MEMSET 1 104 | #define HAVE_MEMCPY 1 105 | #define HAVE_MEMMOVE 1 106 | #define HAVE_MEMCMP 1 107 | #define HAVE_STRLEN 1 108 | #define HAVE__STRREV 1 109 | #define HAVE__STRUPR 1 110 | #define HAVE__STRLWR 1 111 | #define HAVE_STRCHR 1 112 | #define HAVE_STRRCHR 1 113 | #define HAVE_STRSTR 1 114 | #define HAVE__LTOA 1 115 | #define HAVE__ULTOA 1 116 | #define HAVE_STRTOL 1 117 | #define HAVE_STRTOUL 1 118 | #define HAVE_STRTOD 1 119 | #define HAVE_ATOI 1 120 | #define HAVE_ATOF 1 121 | #define HAVE_STRCMP 1 122 | #define HAVE_STRNCMP 1 123 | #define HAVE__STRICMP 1 124 | #define HAVE__STRNICMP 1 125 | #define HAVE_ATAN 1 126 | #define HAVE_ATAN2 1 127 | #define HAVE_ACOS 1 128 | #define HAVE_ASIN 1 129 | #define HAVE_CEIL 1 130 | #define HAVE_COS 1 131 | #define HAVE_COSF 1 132 | #define HAVE_FABS 1 133 | #define HAVE_FLOOR 1 134 | #define HAVE_LOG 1 135 | #define HAVE_POW 1 136 | #define HAVE_SIN 1 137 | #define HAVE_SINF 1 138 | #define HAVE_SQRT 1 139 | #define HAVE_SQRTF 1 140 | #define HAVE_TAN 1 141 | #define HAVE_TANF 1 142 | #if _MSC_VER >= 1800 143 | #define HAVE_STRTOLL 1 144 | #define HAVE_VSSCANF 1 145 | #define HAVE_COPYSIGN 1 146 | #define HAVE_SCALBN 1 147 | #endif 148 | #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) 149 | #define HAVE_M_PI 1 150 | #endif 151 | #else 152 | #define HAVE_STDARG_H 1 153 | #define HAVE_STDDEF_H 1 154 | #endif 155 | 156 | /* Enable various audio drivers */ 157 | #define SDL_AUDIO_DRIVER_DSOUND 1 158 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 159 | #define SDL_AUDIO_DRIVER_WINMM 1 160 | #define SDL_AUDIO_DRIVER_DISK 1 161 | #define SDL_AUDIO_DRIVER_DUMMY 1 162 | 163 | /* Enable various input drivers */ 164 | #define SDL_JOYSTICK_DINPUT 1 165 | #define SDL_JOYSTICK_XINPUT 1 166 | #define SDL_HAPTIC_DINPUT 1 167 | #define SDL_HAPTIC_XINPUT 1 168 | 169 | /* Enable various shared object loading systems */ 170 | #define SDL_LOADSO_WINDOWS 1 171 | 172 | /* Enable various threading systems */ 173 | #define SDL_THREAD_WINDOWS 1 174 | 175 | /* Enable various timer systems */ 176 | #define SDL_TIMER_WINDOWS 1 177 | 178 | /* Enable various video drivers */ 179 | #define SDL_VIDEO_DRIVER_DUMMY 1 180 | #define SDL_VIDEO_DRIVER_WINDOWS 1 181 | 182 | #ifndef SDL_VIDEO_RENDER_D3D 183 | #define SDL_VIDEO_RENDER_D3D 1 184 | #endif 185 | #ifndef SDL_VIDEO_RENDER_D3D11 186 | #define SDL_VIDEO_RENDER_D3D11 0 187 | #endif 188 | 189 | /* Enable OpenGL support */ 190 | #ifndef SDL_VIDEO_OPENGL 191 | #define SDL_VIDEO_OPENGL 1 192 | #endif 193 | #ifndef SDL_VIDEO_OPENGL_WGL 194 | #define SDL_VIDEO_OPENGL_WGL 1 195 | #endif 196 | #ifndef SDL_VIDEO_RENDER_OGL 197 | #define SDL_VIDEO_RENDER_OGL 1 198 | #endif 199 | #ifndef SDL_VIDEO_RENDER_OGL_ES2 200 | #define SDL_VIDEO_RENDER_OGL_ES2 1 201 | #endif 202 | #ifndef SDL_VIDEO_OPENGL_ES2 203 | #define SDL_VIDEO_OPENGL_ES2 1 204 | #endif 205 | #ifndef SDL_VIDEO_OPENGL_EGL 206 | #define SDL_VIDEO_OPENGL_EGL 1 207 | #endif 208 | 209 | 210 | /* Enable system power support */ 211 | #define SDL_POWER_WINDOWS 1 212 | 213 | /* Enable filesystem support */ 214 | #define SDL_FILESYSTEM_WINDOWS 1 215 | 216 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 217 | #ifndef _WIN64 218 | #define SDL_ASSEMBLY_ROUTINES 1 219 | #endif 220 | 221 | #endif /* _SDL_config_windows_h */ 222 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | #include 37 | #ifndef _WIN64 38 | #define __MMX__ 39 | #define __3dNOW__ 40 | #endif 41 | #define __SSE__ 42 | #define __SSE2__ 43 | #elif defined(__MINGW64_VERSION_MAJOR) 44 | #include 45 | #else 46 | #ifdef __ALTIVEC__ 47 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 48 | #include 49 | #undef pixel 50 | #endif 51 | #endif 52 | #ifdef __MMX__ 53 | #include 54 | #endif 55 | #ifdef __3dNOW__ 56 | #include 57 | #endif 58 | #ifdef __SSE__ 59 | #include 60 | #endif 61 | #ifdef __SSE2__ 62 | #include 63 | #endif 64 | #endif 65 | 66 | #include "begin_code.h" 67 | /* Set up for C function definitions, even when using C++ */ 68 | #ifdef __cplusplus 69 | extern "C" { 70 | #endif 71 | 72 | /* This is a guess for the cacheline size used for padding. 73 | * Most x86 processors have a 64 byte cache line. 74 | * The 64-bit PowerPC processors have a 128 byte cache line. 75 | * We'll use the larger value to be generally safe. 76 | */ 77 | #define SDL_CACHELINE_SIZE 128 78 | 79 | /** 80 | * This function returns the number of CPU cores available. 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 83 | 84 | /** 85 | * This function returns the L1 cache line size of the CPU 86 | * 87 | * This is useful for determining multi-threaded structure padding 88 | * or SIMD prefetch sizes. 89 | */ 90 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 91 | 92 | /** 93 | * This function returns true if the CPU has the RDTSC instruction. 94 | */ 95 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 96 | 97 | /** 98 | * This function returns true if the CPU has AltiVec features. 99 | */ 100 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 101 | 102 | /** 103 | * This function returns true if the CPU has MMX features. 104 | */ 105 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 106 | 107 | /** 108 | * This function returns true if the CPU has 3DNow! features. 109 | */ 110 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 111 | 112 | /** 113 | * This function returns true if the CPU has SSE features. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 116 | 117 | /** 118 | * This function returns true if the CPU has SSE2 features. 119 | */ 120 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 121 | 122 | /** 123 | * This function returns true if the CPU has SSE3 features. 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 126 | 127 | /** 128 | * This function returns true if the CPU has SSE4.1 features. 129 | */ 130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 131 | 132 | /** 133 | * This function returns true if the CPU has SSE4.2 features. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 136 | 137 | /** 138 | * This function returns true if the CPU has AVX features. 139 | */ 140 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); 141 | 142 | /** 143 | * This function returns true if the CPU has AVX2 features. 144 | */ 145 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); 146 | 147 | /** 148 | * This function returns the amount of RAM configured in the system, in MB. 149 | */ 150 | extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); 151 | 152 | 153 | /* Ends C function definitions when using C++ */ 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | #include "close_code.h" 158 | 159 | #endif /* _SDL_cpuinfo_h */ 160 | 161 | /* vi: set ts=4 sw=4 expandtab: */ 162 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_endian.h 24 | * 25 | * Functions for reading and writing endian-specific values 26 | */ 27 | 28 | #ifndef _SDL_endian_h 29 | #define _SDL_endian_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /** 34 | * \name The two types of endianness 35 | */ 36 | /* @{ */ 37 | #define SDL_LIL_ENDIAN 1234 38 | #define SDL_BIG_ENDIAN 4321 39 | /* @} */ 40 | 41 | #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 42 | #ifdef __linux__ 43 | #include 44 | #define SDL_BYTEORDER __BYTE_ORDER 45 | #else /* __linux __ */ 46 | #if defined(__hppa__) || \ 47 | defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 48 | (defined(__MIPS__) && defined(__MISPEB__)) || \ 49 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 50 | defined(__sparc__) 51 | #define SDL_BYTEORDER SDL_BIG_ENDIAN 52 | #else 53 | #define SDL_BYTEORDER SDL_LIL_ENDIAN 54 | #endif 55 | #endif /* __linux __ */ 56 | #endif /* !SDL_BYTEORDER */ 57 | 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 | /** 66 | * \file SDL_endian.h 67 | */ 68 | #if defined(__GNUC__) && defined(__i386__) && \ 69 | !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) 70 | SDL_FORCE_INLINE Uint16 71 | SDL_Swap16(Uint16 x) 72 | { 73 | __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); 74 | return x; 75 | } 76 | #elif defined(__GNUC__) && defined(__x86_64__) 77 | SDL_FORCE_INLINE Uint16 78 | SDL_Swap16(Uint16 x) 79 | { 80 | __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); 81 | return x; 82 | } 83 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 84 | SDL_FORCE_INLINE Uint16 85 | SDL_Swap16(Uint16 x) 86 | { 87 | int result; 88 | 89 | __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); 90 | return (Uint16)result; 91 | } 92 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 93 | SDL_FORCE_INLINE Uint16 94 | SDL_Swap16(Uint16 x) 95 | { 96 | __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); 97 | return x; 98 | } 99 | #else 100 | SDL_FORCE_INLINE Uint16 101 | SDL_Swap16(Uint16 x) 102 | { 103 | return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); 104 | } 105 | #endif 106 | 107 | #if defined(__GNUC__) && defined(__i386__) 108 | SDL_FORCE_INLINE Uint32 109 | SDL_Swap32(Uint32 x) 110 | { 111 | __asm__("bswap %0": "=r"(x):"0"(x)); 112 | return x; 113 | } 114 | #elif defined(__GNUC__) && defined(__x86_64__) 115 | SDL_FORCE_INLINE Uint32 116 | SDL_Swap32(Uint32 x) 117 | { 118 | __asm__("bswapl %0": "=r"(x):"0"(x)); 119 | return x; 120 | } 121 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 122 | SDL_FORCE_INLINE Uint32 123 | SDL_Swap32(Uint32 x) 124 | { 125 | Uint32 result; 126 | 127 | __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); 128 | __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); 129 | __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); 130 | return result; 131 | } 132 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 133 | SDL_FORCE_INLINE Uint32 134 | SDL_Swap32(Uint32 x) 135 | { 136 | __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); 137 | return x; 138 | } 139 | #else 140 | SDL_FORCE_INLINE Uint32 141 | SDL_Swap32(Uint32 x) 142 | { 143 | return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | 144 | ((x >> 8) & 0x0000FF00) | (x >> 24))); 145 | } 146 | #endif 147 | 148 | #if defined(__GNUC__) && defined(__i386__) 149 | SDL_FORCE_INLINE Uint64 150 | SDL_Swap64(Uint64 x) 151 | { 152 | union 153 | { 154 | struct 155 | { 156 | Uint32 a, b; 157 | } s; 158 | Uint64 u; 159 | } v; 160 | v.u = x; 161 | __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), 162 | "1"(v.s. 163 | b)); 164 | return v.u; 165 | } 166 | #elif defined(__GNUC__) && defined(__x86_64__) 167 | SDL_FORCE_INLINE Uint64 168 | SDL_Swap64(Uint64 x) 169 | { 170 | __asm__("bswapq %0": "=r"(x):"0"(x)); 171 | return x; 172 | } 173 | #else 174 | SDL_FORCE_INLINE Uint64 175 | SDL_Swap64(Uint64 x) 176 | { 177 | Uint32 hi, lo; 178 | 179 | /* Separate into high and low 32-bit values and swap them */ 180 | lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 181 | x >>= 32; 182 | hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 183 | x = SDL_Swap32(lo); 184 | x <<= 32; 185 | x |= SDL_Swap32(hi); 186 | return (x); 187 | } 188 | #endif 189 | 190 | 191 | SDL_FORCE_INLINE float 192 | SDL_SwapFloat(float x) 193 | { 194 | union 195 | { 196 | float f; 197 | Uint32 ui32; 198 | } swapper; 199 | swapper.f = x; 200 | swapper.ui32 = SDL_Swap32(swapper.ui32); 201 | return swapper.f; 202 | } 203 | 204 | 205 | /** 206 | * \name Swap to native 207 | * Byteswap item from the specified endianness to the native endianness. 208 | */ 209 | /* @{ */ 210 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN 211 | #define SDL_SwapLE16(X) (X) 212 | #define SDL_SwapLE32(X) (X) 213 | #define SDL_SwapLE64(X) (X) 214 | #define SDL_SwapFloatLE(X) (X) 215 | #define SDL_SwapBE16(X) SDL_Swap16(X) 216 | #define SDL_SwapBE32(X) SDL_Swap32(X) 217 | #define SDL_SwapBE64(X) SDL_Swap64(X) 218 | #define SDL_SwapFloatBE(X) SDL_SwapFloat(X) 219 | #else 220 | #define SDL_SwapLE16(X) SDL_Swap16(X) 221 | #define SDL_SwapLE32(X) SDL_Swap32(X) 222 | #define SDL_SwapLE64(X) SDL_Swap64(X) 223 | #define SDL_SwapFloatLE(X) SDL_SwapFloat(X) 224 | #define SDL_SwapBE16(X) (X) 225 | #define SDL_SwapBE32(X) (X) 226 | #define SDL_SwapBE64(X) (X) 227 | #define SDL_SwapFloatBE(X) (X) 228 | #endif 229 | /* @} *//* Swap to native */ 230 | 231 | /* Ends C function definitions when using C++ */ 232 | #ifdef __cplusplus 233 | } 234 | #endif 235 | #include "close_code.h" 236 | 237 | #endif /* _SDL_endian_h */ 238 | 239 | /* vi: set ts=4 sw=4 expandtab: */ 240 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_filesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_joystick.h 24 | * 25 | * Include file for SDL joystick event handling 26 | * 27 | * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick 28 | * behind a device_index changing as joysticks are plugged and unplugged. 29 | * 30 | * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted 31 | * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. 32 | * 33 | * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of 34 | * the device (a X360 wired controller for example). This identifier is platform dependent. 35 | * 36 | * 37 | */ 38 | 39 | #ifndef _SDL_joystick_h 40 | #define _SDL_joystick_h 41 | 42 | #include "SDL_stdinc.h" 43 | #include "SDL_error.h" 44 | 45 | #include "begin_code.h" 46 | /* Set up for C function definitions, even when using C++ */ 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** 52 | * \file SDL_joystick.h 53 | * 54 | * In order to use these functions, SDL_Init() must have been called 55 | * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system 56 | * for joysticks, and load appropriate drivers. 57 | * 58 | * If you would like to receive joystick updates while the application 59 | * is in the background, you should set the following hint before calling 60 | * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS 61 | */ 62 | 63 | /* The joystick structure used to identify an SDL joystick */ 64 | struct _SDL_Joystick; 65 | typedef struct _SDL_Joystick SDL_Joystick; 66 | 67 | /* A structure that encodes the stable unique id for a joystick device */ 68 | typedef struct { 69 | Uint8 data[16]; 70 | } SDL_JoystickGUID; 71 | 72 | typedef Sint32 SDL_JoystickID; 73 | 74 | 75 | /* Function prototypes */ 76 | /** 77 | * Count the number of joysticks attached to the system right now 78 | */ 79 | extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); 80 | 81 | /** 82 | * Get the implementation dependent name of a joystick. 83 | * This can be called before any joysticks are opened. 84 | * If no name can be found, this function returns NULL. 85 | */ 86 | extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); 87 | 88 | /** 89 | * Open a joystick for use. 90 | * The index passed as an argument refers to the N'th joystick on the system. 91 | * This index is the value which will identify this joystick in future joystick 92 | * events. 93 | * 94 | * \return A joystick identifier, or NULL if an error occurred. 95 | */ 96 | extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); 97 | 98 | /** 99 | * Return the name for this currently opened joystick. 100 | * If no name can be found, this function returns NULL. 101 | */ 102 | extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); 103 | 104 | /** 105 | * Return the GUID for the joystick at this index 106 | */ 107 | extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); 108 | 109 | /** 110 | * Return the GUID for this opened joystick 111 | */ 112 | extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); 113 | 114 | /** 115 | * Return a string representation for this guid. pszGUID must point to at least 33 bytes 116 | * (32 for the string plus a NULL terminator). 117 | */ 118 | extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); 119 | 120 | /** 121 | * convert a string into a joystick formatted guid 122 | */ 123 | extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); 124 | 125 | /** 126 | * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. 127 | */ 128 | extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); 129 | 130 | /** 131 | * Get the instance ID of an opened joystick or -1 if the joystick is invalid. 132 | */ 133 | extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); 134 | 135 | /** 136 | * Get the number of general axis controls on a joystick. 137 | */ 138 | extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); 139 | 140 | /** 141 | * Get the number of trackballs on a joystick. 142 | * 143 | * Joystick trackballs have only relative motion events associated 144 | * with them and their state cannot be polled. 145 | */ 146 | extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); 147 | 148 | /** 149 | * Get the number of POV hats on a joystick. 150 | */ 151 | extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); 152 | 153 | /** 154 | * Get the number of buttons on a joystick. 155 | */ 156 | extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); 157 | 158 | /** 159 | * Update the current state of the open joysticks. 160 | * 161 | * This is called automatically by the event loop if any joystick 162 | * events are enabled. 163 | */ 164 | extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); 165 | 166 | /** 167 | * Enable/disable joystick event polling. 168 | * 169 | * If joystick events are disabled, you must call SDL_JoystickUpdate() 170 | * yourself and check the state of the joystick when you want joystick 171 | * information. 172 | * 173 | * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. 174 | */ 175 | extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); 176 | 177 | /** 178 | * Get the current state of an axis control on a joystick. 179 | * 180 | * The state is a value ranging from -32768 to 32767. 181 | * 182 | * The axis indices start at index 0. 183 | */ 184 | extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, 185 | int axis); 186 | 187 | /** 188 | * \name Hat positions 189 | */ 190 | /* @{ */ 191 | #define SDL_HAT_CENTERED 0x00 192 | #define SDL_HAT_UP 0x01 193 | #define SDL_HAT_RIGHT 0x02 194 | #define SDL_HAT_DOWN 0x04 195 | #define SDL_HAT_LEFT 0x08 196 | #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) 197 | #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) 198 | #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) 199 | #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) 200 | /* @} */ 201 | 202 | /** 203 | * Get the current state of a POV hat on a joystick. 204 | * 205 | * The hat indices start at index 0. 206 | * 207 | * \return The return value is one of the following positions: 208 | * - ::SDL_HAT_CENTERED 209 | * - ::SDL_HAT_UP 210 | * - ::SDL_HAT_RIGHT 211 | * - ::SDL_HAT_DOWN 212 | * - ::SDL_HAT_LEFT 213 | * - ::SDL_HAT_RIGHTUP 214 | * - ::SDL_HAT_RIGHTDOWN 215 | * - ::SDL_HAT_LEFTUP 216 | * - ::SDL_HAT_LEFTDOWN 217 | */ 218 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, 219 | int hat); 220 | 221 | /** 222 | * Get the ball axis change since the last poll. 223 | * 224 | * \return 0, or -1 if you passed it invalid parameters. 225 | * 226 | * The ball indices start at index 0. 227 | */ 228 | extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, 229 | int ball, int *dx, int *dy); 230 | 231 | /** 232 | * Get the current state of a button on a joystick. 233 | * 234 | * The button indices start at index 0. 235 | */ 236 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, 237 | int button); 238 | 239 | /** 240 | * Close a joystick previously opened with SDL_JoystickOpen(). 241 | */ 242 | extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); 243 | 244 | 245 | /* Ends C function definitions when using C++ */ 246 | #ifdef __cplusplus 247 | } 248 | #endif 249 | #include "close_code.h" 250 | 251 | #endif /* _SDL_joystick_h */ 252 | 253 | /* vi: set ts=4 sw=4 expandtab: */ 254 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_keyboard.h 24 | * 25 | * Include file for SDL keyboard event handling 26 | */ 27 | 28 | #ifndef _SDL_keyboard_h 29 | #define _SDL_keyboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_keycode.h" 34 | #include "SDL_video.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 SDL keysym structure, used in key events. 44 | * 45 | * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. 46 | */ 47 | typedef struct SDL_Keysym 48 | { 49 | SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ 50 | SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ 51 | Uint16 mod; /**< current key modifiers */ 52 | Uint32 unused; 53 | } SDL_Keysym; 54 | 55 | /* Function prototypes */ 56 | 57 | /** 58 | * \brief Get the window which currently has keyboard focus. 59 | */ 60 | extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); 61 | 62 | /** 63 | * \brief Get a snapshot of the current state of the keyboard. 64 | * 65 | * \param numkeys if non-NULL, receives the length of the returned array. 66 | * 67 | * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. 68 | * 69 | * \b Example: 70 | * \code 71 | * const Uint8 *state = SDL_GetKeyboardState(NULL); 72 | * if ( state[SDL_SCANCODE_RETURN] ) { 73 | * printf(" is pressed.\n"); 74 | * } 75 | * \endcode 76 | */ 77 | extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); 78 | 79 | /** 80 | * \brief Get the current key modifier state for the keyboard. 81 | */ 82 | extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); 83 | 84 | /** 85 | * \brief Set the current key modifier state for the keyboard. 86 | * 87 | * \note This does not change the keyboard state, only the key modifier flags. 88 | */ 89 | extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); 90 | 91 | /** 92 | * \brief Get the key code corresponding to the given scancode according 93 | * to the current keyboard layout. 94 | * 95 | * See ::SDL_Keycode for details. 96 | * 97 | * \sa SDL_GetKeyName() 98 | */ 99 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); 100 | 101 | /** 102 | * \brief Get the scancode corresponding to the given key code according to the 103 | * current keyboard layout. 104 | * 105 | * See ::SDL_Scancode for details. 106 | * 107 | * \sa SDL_GetScancodeName() 108 | */ 109 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); 110 | 111 | /** 112 | * \brief Get a human-readable name for a scancode. 113 | * 114 | * \return A pointer to the name for the scancode. 115 | * If the scancode doesn't have a name, this function returns 116 | * an empty string (""). 117 | * 118 | * \sa SDL_Scancode 119 | */ 120 | extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); 121 | 122 | /** 123 | * \brief Get a scancode from a human-readable name 124 | * 125 | * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized 126 | * 127 | * \sa SDL_Scancode 128 | */ 129 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); 130 | 131 | /** 132 | * \brief Get a human-readable name for a key. 133 | * 134 | * \return A pointer to a UTF-8 string that stays valid at least until the next 135 | * call to this function. If you need it around any longer, you must 136 | * copy it. If the key doesn't have a name, this function returns an 137 | * empty string (""). 138 | * 139 | * \sa SDL_Key 140 | */ 141 | extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); 142 | 143 | /** 144 | * \brief Get a key code from a human-readable name 145 | * 146 | * \return key code, or SDLK_UNKNOWN if the name wasn't recognized 147 | * 148 | * \sa SDL_Keycode 149 | */ 150 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); 151 | 152 | /** 153 | * \brief Start accepting Unicode text input events. 154 | * This function will show the on-screen keyboard if supported. 155 | * 156 | * \sa SDL_StopTextInput() 157 | * \sa SDL_SetTextInputRect() 158 | * \sa SDL_HasScreenKeyboardSupport() 159 | */ 160 | extern DECLSPEC void SDLCALL SDL_StartTextInput(void); 161 | 162 | /** 163 | * \brief Return whether or not Unicode text input events are enabled. 164 | * 165 | * \sa SDL_StartTextInput() 166 | * \sa SDL_StopTextInput() 167 | */ 168 | extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); 169 | 170 | /** 171 | * \brief Stop receiving any text input events. 172 | * This function will hide the on-screen keyboard if supported. 173 | * 174 | * \sa SDL_StartTextInput() 175 | * \sa SDL_HasScreenKeyboardSupport() 176 | */ 177 | extern DECLSPEC void SDLCALL SDL_StopTextInput(void); 178 | 179 | /** 180 | * \brief Set the rectangle used to type Unicode text inputs. 181 | * This is used as a hint for IME and on-screen keyboard placement. 182 | * 183 | * \sa SDL_StartTextInput() 184 | */ 185 | extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); 186 | 187 | /** 188 | * \brief Returns whether the platform has some screen keyboard support. 189 | * 190 | * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. 191 | * 192 | * \note Not all screen keyboard functions are supported on all platforms. 193 | * 194 | * \sa SDL_IsScreenKeyboardShown() 195 | */ 196 | extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); 197 | 198 | /** 199 | * \brief Returns whether the screen keyboard is shown for given window. 200 | * 201 | * \param window The window for which screen keyboard should be queried. 202 | * 203 | * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. 204 | * 205 | * \sa SDL_HasScreenKeyboardSupport() 206 | */ 207 | extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); 208 | 209 | /* Ends C function definitions when using C++ */ 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | #include "close_code.h" 214 | 215 | #endif /* _SDL_keyboard_h */ 216 | 217 | /* vi: set ts=4 sw=4 expandtab: */ 218 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_log.h 24 | * 25 | * Simple log messages with categories and priorities. 26 | * 27 | * By default logs are quiet, but if you're debugging SDL you might want: 28 | * 29 | * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); 30 | * 31 | * Here's where the messages go on different platforms: 32 | * Windows: debug output stream 33 | * Android: log output 34 | * Others: standard error output (stderr) 35 | */ 36 | 37 | #ifndef _SDL_log_h 38 | #define _SDL_log_h 39 | 40 | #include "SDL_stdinc.h" 41 | 42 | #include "begin_code.h" 43 | /* Set up for C function definitions, even when using C++ */ 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /** 50 | * \brief The maximum size of a log message 51 | * 52 | * Messages longer than the maximum size will be truncated 53 | */ 54 | #define SDL_MAX_LOG_MESSAGE 4096 55 | 56 | /** 57 | * \brief The predefined log categories 58 | * 59 | * By default the application category is enabled at the INFO level, 60 | * the assert category is enabled at the WARN level, test is enabled 61 | * at the VERBOSE level and all other categories are enabled at the 62 | * CRITICAL level. 63 | */ 64 | enum 65 | { 66 | SDL_LOG_CATEGORY_APPLICATION, 67 | SDL_LOG_CATEGORY_ERROR, 68 | SDL_LOG_CATEGORY_ASSERT, 69 | SDL_LOG_CATEGORY_SYSTEM, 70 | SDL_LOG_CATEGORY_AUDIO, 71 | SDL_LOG_CATEGORY_VIDEO, 72 | SDL_LOG_CATEGORY_RENDER, 73 | SDL_LOG_CATEGORY_INPUT, 74 | SDL_LOG_CATEGORY_TEST, 75 | 76 | /* Reserved for future SDL library use */ 77 | SDL_LOG_CATEGORY_RESERVED1, 78 | SDL_LOG_CATEGORY_RESERVED2, 79 | SDL_LOG_CATEGORY_RESERVED3, 80 | SDL_LOG_CATEGORY_RESERVED4, 81 | SDL_LOG_CATEGORY_RESERVED5, 82 | SDL_LOG_CATEGORY_RESERVED6, 83 | SDL_LOG_CATEGORY_RESERVED7, 84 | SDL_LOG_CATEGORY_RESERVED8, 85 | SDL_LOG_CATEGORY_RESERVED9, 86 | SDL_LOG_CATEGORY_RESERVED10, 87 | 88 | /* Beyond this point is reserved for application use, e.g. 89 | enum { 90 | MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, 91 | MYAPP_CATEGORY_AWESOME2, 92 | MYAPP_CATEGORY_AWESOME3, 93 | ... 94 | }; 95 | */ 96 | SDL_LOG_CATEGORY_CUSTOM 97 | }; 98 | 99 | /** 100 | * \brief The predefined log priorities 101 | */ 102 | typedef enum 103 | { 104 | SDL_LOG_PRIORITY_VERBOSE = 1, 105 | SDL_LOG_PRIORITY_DEBUG, 106 | SDL_LOG_PRIORITY_INFO, 107 | SDL_LOG_PRIORITY_WARN, 108 | SDL_LOG_PRIORITY_ERROR, 109 | SDL_LOG_PRIORITY_CRITICAL, 110 | SDL_NUM_LOG_PRIORITIES 111 | } SDL_LogPriority; 112 | 113 | 114 | /** 115 | * \brief Set the priority of all log categories 116 | */ 117 | extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); 118 | 119 | /** 120 | * \brief Set the priority of a particular log category 121 | */ 122 | extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, 123 | SDL_LogPriority priority); 124 | 125 | /** 126 | * \brief Get the priority of a particular log category 127 | */ 128 | extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); 129 | 130 | /** 131 | * \brief Reset all priorities to default. 132 | * 133 | * \note This is called in SDL_Quit(). 134 | */ 135 | extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); 136 | 137 | /** 138 | * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO 139 | */ 140 | extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 141 | 142 | /** 143 | * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE 144 | */ 145 | extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 146 | 147 | /** 148 | * \brief Log a message with SDL_LOG_PRIORITY_DEBUG 149 | */ 150 | extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 151 | 152 | /** 153 | * \brief Log a message with SDL_LOG_PRIORITY_INFO 154 | */ 155 | extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 156 | 157 | /** 158 | * \brief Log a message with SDL_LOG_PRIORITY_WARN 159 | */ 160 | extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 161 | 162 | /** 163 | * \brief Log a message with SDL_LOG_PRIORITY_ERROR 164 | */ 165 | extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 166 | 167 | /** 168 | * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL 169 | */ 170 | extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); 171 | 172 | /** 173 | * \brief Log a message with the specified category and priority. 174 | */ 175 | extern DECLSPEC void SDLCALL SDL_LogMessage(int category, 176 | SDL_LogPriority priority, 177 | SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); 178 | 179 | /** 180 | * \brief Log a message with the specified category and priority. 181 | */ 182 | extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, 183 | SDL_LogPriority priority, 184 | const char *fmt, va_list ap); 185 | 186 | /** 187 | * \brief The prototype for the log output function 188 | */ 189 | typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); 190 | 191 | /** 192 | * \brief Get the current log output function. 193 | */ 194 | extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); 195 | 196 | /** 197 | * \brief This function allows you to replace the default log output 198 | * function with one of your own. 199 | */ 200 | extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); 201 | 202 | 203 | /* Ends C function definitions when using C++ */ 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | #include "close_code.h" 208 | 209 | #endif /* _SDL_log_h */ 210 | 211 | /* vi: set ts=4 sw=4 expandtab: */ 212 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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.txt 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 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 | * \ret 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_messagebox.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_mutex_h 23 | #define _SDL_mutex_h 24 | 25 | /** 26 | * \file SDL_mutex.h 27 | * 28 | * Functions to provide thread synchronization primitives. 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 | * Synchronization functions which can time out return this value 42 | * if they time out. 43 | */ 44 | #define SDL_MUTEX_TIMEDOUT 1 45 | 46 | /** 47 | * This is the timeout value which corresponds to never time out. 48 | */ 49 | #define SDL_MUTEX_MAXWAIT (~(Uint32)0) 50 | 51 | 52 | /** 53 | * \name Mutex functions 54 | */ 55 | /* @{ */ 56 | 57 | /* The SDL mutex structure, defined in SDL_sysmutex.c */ 58 | struct SDL_mutex; 59 | typedef struct SDL_mutex SDL_mutex; 60 | 61 | /** 62 | * Create a mutex, initialized unlocked. 63 | */ 64 | extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); 65 | 66 | /** 67 | * Lock the mutex. 68 | * 69 | * \return 0, or -1 on error. 70 | */ 71 | #define SDL_mutexP(m) SDL_LockMutex(m) 72 | extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); 73 | 74 | /** 75 | * Try to lock the mutex 76 | * 77 | * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error 78 | */ 79 | extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); 80 | 81 | /** 82 | * Unlock the mutex. 83 | * 84 | * \return 0, or -1 on error. 85 | * 86 | * \warning It is an error to unlock a mutex that has not been locked by 87 | * the current thread, and doing so results in undefined behavior. 88 | */ 89 | #define SDL_mutexV(m) SDL_UnlockMutex(m) 90 | extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); 91 | 92 | /** 93 | * Destroy a mutex. 94 | */ 95 | extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); 96 | 97 | /* @} *//* Mutex functions */ 98 | 99 | 100 | /** 101 | * \name Semaphore functions 102 | */ 103 | /* @{ */ 104 | 105 | /* The SDL semaphore structure, defined in SDL_syssem.c */ 106 | struct SDL_semaphore; 107 | typedef struct SDL_semaphore SDL_sem; 108 | 109 | /** 110 | * Create a semaphore, initialized with value, returns NULL on failure. 111 | */ 112 | extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); 113 | 114 | /** 115 | * Destroy a semaphore. 116 | */ 117 | extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); 118 | 119 | /** 120 | * This function suspends the calling thread until the semaphore pointed 121 | * to by \c sem has a positive count. It then atomically decreases the 122 | * semaphore count. 123 | */ 124 | extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); 125 | 126 | /** 127 | * Non-blocking variant of SDL_SemWait(). 128 | * 129 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would 130 | * block, and -1 on error. 131 | */ 132 | extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); 133 | 134 | /** 135 | * Variant of SDL_SemWait() with a timeout in milliseconds. 136 | * 137 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not 138 | * succeed in the allotted time, and -1 on error. 139 | * 140 | * \warning On some platforms this function is implemented by looping with a 141 | * delay of 1 ms, and so should be avoided if possible. 142 | */ 143 | extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); 144 | 145 | /** 146 | * Atomically increases the semaphore's count (not blocking). 147 | * 148 | * \return 0, or -1 on error. 149 | */ 150 | extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); 151 | 152 | /** 153 | * Returns the current count of the semaphore. 154 | */ 155 | extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); 156 | 157 | /* @} *//* Semaphore functions */ 158 | 159 | 160 | /** 161 | * \name Condition variable functions 162 | */ 163 | /* @{ */ 164 | 165 | /* The SDL condition variable structure, defined in SDL_syscond.c */ 166 | struct SDL_cond; 167 | typedef struct SDL_cond SDL_cond; 168 | 169 | /** 170 | * Create a condition variable. 171 | * 172 | * Typical use of condition variables: 173 | * 174 | * Thread A: 175 | * SDL_LockMutex(lock); 176 | * while ( ! condition ) { 177 | * SDL_CondWait(cond, lock); 178 | * } 179 | * SDL_UnlockMutex(lock); 180 | * 181 | * Thread B: 182 | * SDL_LockMutex(lock); 183 | * ... 184 | * condition = true; 185 | * ... 186 | * SDL_CondSignal(cond); 187 | * SDL_UnlockMutex(lock); 188 | * 189 | * There is some discussion whether to signal the condition variable 190 | * with the mutex locked or not. There is some potential performance 191 | * benefit to unlocking first on some platforms, but there are some 192 | * potential race conditions depending on how your code is structured. 193 | * 194 | * In general it's safer to signal the condition variable while the 195 | * mutex is locked. 196 | */ 197 | extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); 198 | 199 | /** 200 | * Destroy a condition variable. 201 | */ 202 | extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); 203 | 204 | /** 205 | * Restart one of the threads that are waiting on the condition variable. 206 | * 207 | * \return 0 or -1 on error. 208 | */ 209 | extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); 210 | 211 | /** 212 | * Restart all threads that are waiting on the condition variable. 213 | * 214 | * \return 0 or -1 on error. 215 | */ 216 | extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); 217 | 218 | /** 219 | * Wait on the condition variable, unlocking the provided mutex. 220 | * 221 | * \warning The mutex must be locked before entering this function! 222 | * 223 | * The mutex is re-locked once the condition variable is signaled. 224 | * 225 | * \return 0 when it is signaled, or -1 on error. 226 | */ 227 | extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); 228 | 229 | /** 230 | * Waits for at most \c ms milliseconds, and returns 0 if the condition 231 | * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not 232 | * signaled in the allotted time, and -1 on error. 233 | * 234 | * \warning On some platforms this function is implemented by looping with a 235 | * delay of 1 ms, and so should be avoided if possible. 236 | */ 237 | extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, 238 | SDL_mutex * mutex, Uint32 ms); 239 | 240 | /* @} *//* Condition variable functions */ 241 | 242 | 243 | /* Ends C function definitions when using C++ */ 244 | #ifdef __cplusplus 245 | } 246 | #endif 247 | #include "close_code.h" 248 | 249 | #endif /* _SDL_mutex_h */ 250 | 251 | /* vi: set ts=4 sw=4 expandtab: */ 252 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | #ifndef _MSC_VER 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #else /* _MSC_VER */ 39 | 40 | /* OpenGL ES2 headers for Visual Studio */ 41 | #include "SDL_opengles2_khrplatform.h" 42 | #include "SDL_opengles2_gl2platform.h" 43 | #include "SDL_opengles2_gl2.h" 44 | #include "SDL_opengles2_gl2ext.h" 45 | 46 | #endif /* _MSC_VER */ 47 | 48 | #ifndef APIENTRY 49 | #define APIENTRY GL_APIENTRY 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/SDL2/include/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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_IPHONE 74 | /* if compiling for iPhone */ 75 | #undef __IPHONEOS__ 76 | #define __IPHONEOS__ 1 77 | #undef __MACOSX__ 78 | #else 79 | /* if not compiling for iPhone */ 80 | #undef __MACOSX__ 81 | #define __MACOSX__ 1 82 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 83 | # error SDL for Mac OS X only supports deploying on 10.5 and above. 84 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ 85 | #endif /* TARGET_OS_IPHONE */ 86 | #endif /* defined(__APPLE__) */ 87 | 88 | #if defined(__NetBSD__) 89 | #undef __NETBSD__ 90 | #define __NETBSD__ 1 91 | #endif 92 | #if defined(__OpenBSD__) 93 | #undef __OPENBSD__ 94 | #define __OPENBSD__ 1 95 | #endif 96 | #if defined(__OS2__) 97 | #undef __OS2__ 98 | #define __OS2__ 1 99 | #endif 100 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 101 | #undef __OSF__ 102 | #define __OSF__ 1 103 | #endif 104 | #if defined(__QNXNTO__) 105 | #undef __QNXNTO__ 106 | #define __QNXNTO__ 1 107 | #endif 108 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 109 | #undef __RISCOS__ 110 | #define __RISCOS__ 1 111 | #endif 112 | #if defined(__sun) && defined(__SVR4) 113 | #undef __SOLARIS__ 114 | #define __SOLARIS__ 1 115 | #endif 116 | 117 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 118 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 119 | /* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ 120 | #if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ 121 | #include 122 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 123 | #undef __WINDOWS__ 124 | #define __WINDOWS__ 1 125 | /* See if we're compiling for WinRT: */ 126 | #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 127 | #undef __WINRT__ 128 | #define __WINRT__ 1 129 | #endif 130 | #else 131 | #undef __WINDOWS__ 132 | #define __WINDOWS__ 1 133 | #endif /* _MSC_VER < 1700 */ 134 | #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ 135 | 136 | #if defined(__WINDOWS__) 137 | #undef __WIN32__ 138 | #define __WIN32__ 1 139 | #endif 140 | #if defined(__PSP__) 141 | #undef __PSP__ 142 | #define __PSP__ 1 143 | #endif 144 | 145 | /* The NACL compiler defines __native_client__ and __pnacl__ 146 | * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi 147 | */ 148 | #if defined(__native_client__) 149 | #undef __LINUX__ 150 | #undef __NACL__ 151 | #define __NACL__ 1 152 | #endif 153 | #if defined(__pnacl__) 154 | #undef __LINUX__ 155 | #undef __PNACL__ 156 | #define __PNACL__ 1 157 | /* PNACL with newlib supports static linking only */ 158 | #define __SDL_NOGETPROCADDR__ 159 | #endif 160 | 161 | 162 | #include "begin_code.h" 163 | /* Set up for C function definitions, even when using C++ */ 164 | #ifdef __cplusplus 165 | extern "C" { 166 | #endif 167 | 168 | /** 169 | * \brief Gets the name of the platform. 170 | */ 171 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); 172 | 173 | /* Ends C function definitions when using C++ */ 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | #include "close_code.h" 178 | 179 | #endif /* _SDL_platform_h */ 180 | 181 | /* vi: set ts=4 sw=4 expandtab: */ 182 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_rect.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_rwops.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_rwops.h 24 | * 25 | * This file provides a general interface for SDL to read and write 26 | * data streams. It can easily be extended to files, memory, etc. 27 | */ 28 | 29 | #ifndef _SDL_rwops_h 30 | #define _SDL_rwops_h 31 | 32 | #include "SDL_stdinc.h" 33 | #include "SDL_error.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 | /* RWops Types */ 42 | #define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ 43 | #define SDL_RWOPS_WINFILE 1 /* Win32 file */ 44 | #define SDL_RWOPS_STDFILE 2 /* Stdio file */ 45 | #define SDL_RWOPS_JNIFILE 3 /* Android asset */ 46 | #define SDL_RWOPS_MEMORY 4 /* Memory stream */ 47 | #define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ 48 | 49 | /** 50 | * This is the read/write operation structure -- very basic. 51 | */ 52 | typedef struct SDL_RWops 53 | { 54 | /** 55 | * Return the size of the file in this rwops, or -1 if unknown 56 | */ 57 | Sint64 (SDLCALL * size) (struct SDL_RWops * context); 58 | 59 | /** 60 | * Seek to \c offset relative to \c whence, one of stdio's whence values: 61 | * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END 62 | * 63 | * \return the final offset in the data stream, or -1 on error. 64 | */ 65 | Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, 66 | int whence); 67 | 68 | /** 69 | * Read up to \c maxnum objects each of size \c size from the data 70 | * stream to the area pointed at by \c ptr. 71 | * 72 | * \return the number of objects read, or 0 at error or end of file. 73 | */ 74 | size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, 75 | size_t size, size_t maxnum); 76 | 77 | /** 78 | * Write exactly \c num objects each of size \c size from the area 79 | * pointed at by \c ptr to data stream. 80 | * 81 | * \return the number of objects written, or 0 at error or end of file. 82 | */ 83 | size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, 84 | size_t size, size_t num); 85 | 86 | /** 87 | * Close and free an allocated SDL_RWops structure. 88 | * 89 | * \return 0 if successful or -1 on write error when flushing data. 90 | */ 91 | int (SDLCALL * close) (struct SDL_RWops * context); 92 | 93 | Uint32 type; 94 | union 95 | { 96 | #if defined(__ANDROID__) 97 | struct 98 | { 99 | void *fileNameRef; 100 | void *inputStreamRef; 101 | void *readableByteChannelRef; 102 | void *readMethod; 103 | void *assetFileDescriptorRef; 104 | long position; 105 | long size; 106 | long offset; 107 | int fd; 108 | } androidio; 109 | #elif defined(__WIN32__) 110 | struct 111 | { 112 | SDL_bool append; 113 | void *h; 114 | struct 115 | { 116 | void *data; 117 | size_t size; 118 | size_t left; 119 | } buffer; 120 | } windowsio; 121 | #endif 122 | 123 | #ifdef HAVE_STDIO_H 124 | struct 125 | { 126 | SDL_bool autoclose; 127 | FILE *fp; 128 | } stdio; 129 | #endif 130 | struct 131 | { 132 | Uint8 *base; 133 | Uint8 *here; 134 | Uint8 *stop; 135 | } mem; 136 | struct 137 | { 138 | void *data1; 139 | void *data2; 140 | } unknown; 141 | } hidden; 142 | 143 | } SDL_RWops; 144 | 145 | 146 | /** 147 | * \name RWFrom functions 148 | * 149 | * Functions to create SDL_RWops structures from various data streams. 150 | */ 151 | /* @{ */ 152 | 153 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, 154 | const char *mode); 155 | 156 | #ifdef HAVE_STDIO_H 157 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, 158 | SDL_bool autoclose); 159 | #else 160 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, 161 | SDL_bool autoclose); 162 | #endif 163 | 164 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); 165 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, 166 | int size); 167 | 168 | /* @} *//* RWFrom functions */ 169 | 170 | 171 | extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); 172 | extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); 173 | 174 | #define RW_SEEK_SET 0 /**< Seek from the beginning of data */ 175 | #define RW_SEEK_CUR 1 /**< Seek relative to current read point */ 176 | #define RW_SEEK_END 2 /**< Seek relative to the end of data */ 177 | 178 | /** 179 | * \name Read/write macros 180 | * 181 | * Macros to easily read and write from an SDL_RWops structure. 182 | */ 183 | /* @{ */ 184 | #define SDL_RWsize(ctx) (ctx)->size(ctx) 185 | #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) 186 | #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) 187 | #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) 188 | #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) 189 | #define SDL_RWclose(ctx) (ctx)->close(ctx) 190 | /* @} *//* Read/write macros */ 191 | 192 | 193 | /** 194 | * \name Read endian functions 195 | * 196 | * Read an item of the specified endianness and return in native format. 197 | */ 198 | /* @{ */ 199 | extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); 200 | extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); 201 | extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); 202 | extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); 203 | extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); 204 | extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); 205 | extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); 206 | /* @} *//* Read endian functions */ 207 | 208 | /** 209 | * \name Write endian functions 210 | * 211 | * Write an item of native format to the specified endianness. 212 | */ 213 | /* @{ */ 214 | extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); 215 | extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); 216 | extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); 217 | extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); 218 | extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); 219 | extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); 220 | extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); 221 | /* @} *//* Write endian functions */ 222 | 223 | /* Ends C function definitions when using C++ */ 224 | #ifdef __cplusplus 225 | } 226 | #endif 227 | #include "close_code.h" 228 | 229 | #endif /* _SDL_rwops_h */ 230 | 231 | /* vi: set ts=4 sw=4 expandtab: */ 232 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | * \sa SDL_CreateShapedWindow 75 | */ 76 | extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); 77 | 78 | /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ 79 | typedef enum { 80 | /** \brief The default mode, a binarized alpha cutoff of 1. */ 81 | ShapeModeDefault, 82 | /** \brief A binarized alpha cutoff with a given integer value. */ 83 | ShapeModeBinarizeAlpha, 84 | /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ 85 | ShapeModeReverseBinarizeAlpha, 86 | /** \brief A color key is applied. */ 87 | ShapeModeColorKey 88 | } WindowShapeMode; 89 | 90 | #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) 91 | 92 | /** \brief A union containing parameters for shaped windows. */ 93 | typedef union { 94 | /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ 95 | Uint8 binarizationCutoff; 96 | SDL_Color colorKey; 97 | } SDL_WindowShapeParams; 98 | 99 | /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ 100 | typedef struct SDL_WindowShapeMode { 101 | /** \brief The mode of these window-shape parameters. */ 102 | WindowShapeMode mode; 103 | /** \brief Window-shape parameters. */ 104 | SDL_WindowShapeParams parameters; 105 | } SDL_WindowShapeMode; 106 | 107 | /** 108 | * \brief Set the shape and parameters of a shaped window. 109 | * 110 | * \param window The shaped window whose parameters should be set. 111 | * \param shape A surface encoding the desired shape for the window. 112 | * \param shape_mode The parameters to set for the shaped window. 113 | * 114 | * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW 115 | * if the SDL_Window* given does not reference a valid shaped window. 116 | * 117 | * \sa SDL_WindowShapeMode 118 | * \sa SDL_GetShapedWindowMode. 119 | */ 120 | extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); 121 | 122 | /** 123 | * \brief Get the shape parameters of a shaped window. 124 | * 125 | * \param window The shaped window whose parameters should be retrieved. 126 | * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. 127 | * 128 | * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode 129 | * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if 130 | * the SDL_Window* given is a shapeable window currently lacking a shape. 131 | * 132 | * \sa SDL_WindowShapeMode 133 | * \sa SDL_SetWindowShape 134 | */ 135 | extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); 136 | 137 | /* Ends C function definitions when using C++ */ 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | #include "close_code.h" 142 | 143 | #endif /* _SDL_shape_h */ 144 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_system.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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_system.h 24 | * 25 | * Include file for platform specific SDL API functions 26 | */ 27 | 28 | #ifndef _SDL_system_h 29 | #define _SDL_system_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_keyboard.h" 33 | #include "SDL_render.h" 34 | #include "SDL_video.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 | /* Platform specific functions for Windows */ 44 | #ifdef __WIN32__ 45 | 46 | /** 47 | \brief Returns the D3D9 adapter index that matches the specified display index. 48 | 49 | This adapter index can be passed to IDirect3D9::CreateDevice and controls 50 | on which monitor a full screen application will appear. 51 | */ 52 | extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); 53 | 54 | typedef struct IDirect3DDevice9 IDirect3DDevice9; 55 | /** 56 | \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. 57 | 58 | Once you are done using the device, you should release it to avoid a resource leak. 59 | */ 60 | extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); 61 | 62 | /** 63 | \brief Returns the DXGI Adapter and Output indices for the specified display index. 64 | 65 | These can be passed to EnumAdapters and EnumOutputs respectively to get the objects 66 | required to create a DX10 or DX11 device and swap chain. 67 | */ 68 | extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); 69 | 70 | #endif /* __WIN32__ */ 71 | 72 | 73 | /* Platform specific functions for iOS */ 74 | #if defined(__IPHONEOS__) && __IPHONEOS__ 75 | 76 | extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); 77 | extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); 78 | 79 | #endif /* __IPHONEOS__ */ 80 | 81 | 82 | /* Platform specific functions for Android */ 83 | #if defined(__ANDROID__) && __ANDROID__ 84 | 85 | /** 86 | \brief Get the JNI environment for the current thread 87 | 88 | This returns JNIEnv*, but the prototype is void* so we don't need jni.h 89 | */ 90 | extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); 91 | 92 | /** 93 | \brief Get the SDL Activity object for the application 94 | 95 | This returns jobject, but the prototype is void* so we don't need jni.h 96 | The jobject returned by SDL_AndroidGetActivity is a local reference. 97 | It is the caller's responsibility to properly release it 98 | (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) 99 | */ 100 | extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); 101 | 102 | /** 103 | See the official Android developer guide for more information: 104 | http://developer.android.com/guide/topics/data/data-storage.html 105 | */ 106 | #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 107 | #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 108 | 109 | /** 110 | \brief Get the path used for internal storage for this application. 111 | 112 | This path is unique to your application and cannot be written to 113 | by other applications. 114 | */ 115 | extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(); 116 | 117 | /** 118 | \brief Get the current state of external storage, a bitmask of these values: 119 | SDL_ANDROID_EXTERNAL_STORAGE_READ 120 | SDL_ANDROID_EXTERNAL_STORAGE_WRITE 121 | 122 | If external storage is currently unavailable, this will return 0. 123 | */ 124 | extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(); 125 | 126 | /** 127 | \brief Get the path used for external storage for this application. 128 | 129 | This path is unique to your application, but is public and can be 130 | written to by other applications. 131 | */ 132 | extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); 133 | 134 | #endif /* __ANDROID__ */ 135 | 136 | /* Platform specific functions for WinRT */ 137 | #if defined(__WINRT__) && __WINRT__ 138 | 139 | /** 140 | * \brief WinRT / Windows Phone path types 141 | */ 142 | typedef enum 143 | { 144 | /** \brief The installed app's root directory. 145 | Files here are likely to be read-only. */ 146 | SDL_WINRT_PATH_INSTALLED_LOCATION, 147 | 148 | /** \brief The app's local data store. Files may be written here */ 149 | SDL_WINRT_PATH_LOCAL_FOLDER, 150 | 151 | /** \brief The app's roaming data store. Unsupported on Windows Phone. 152 | Files written here may be copied to other machines via a network 153 | connection. 154 | */ 155 | SDL_WINRT_PATH_ROAMING_FOLDER, 156 | 157 | /** \brief The app's temporary data store. Unsupported on Windows Phone. 158 | Files written here may be deleted at any time. */ 159 | SDL_WINRT_PATH_TEMP_FOLDER 160 | } SDL_WinRT_Path; 161 | 162 | 163 | /** 164 | * \brief Retrieves a WinRT defined path on the local file system 165 | * 166 | * \note Documentation on most app-specific path types on WinRT 167 | * can be found on MSDN, at the URL: 168 | * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx 169 | * 170 | * \param pathType The type of path to retrieve. 171 | * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL 172 | * if the path is not available for any reason. Not all paths are 173 | * available on all versions of Windows. This is especially true on 174 | * Windows Phone. Check the documentation for the given 175 | * SDL_WinRT_Path for more information on which path types are 176 | * supported where. 177 | */ 178 | extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); 179 | 180 | /** 181 | * \brief Retrieves a WinRT defined path on the local file system 182 | * 183 | * \note Documentation on most app-specific path types on WinRT 184 | * can be found on MSDN, at the URL: 185 | * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx 186 | * 187 | * \param pathType The type of path to retrieve. 188 | * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL 189 | * if the path is not available for any reason. Not all paths are 190 | * available on all versions of Windows. This is especially true on 191 | * Windows Phone. Check the documentation for the given 192 | * SDL_WinRT_Path for more information on which path types are 193 | * supported where. 194 | */ 195 | extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); 196 | 197 | #endif /* __WINRT__ */ 198 | 199 | /* Ends C function definitions when using C++ */ 200 | #ifdef __cplusplus 201 | } 202 | #endif 203 | #include "close_code.h" 204 | 205 | #endif /* _SDL_system_h */ 206 | 207 | /* vi: set ts=4 sw=4 expandtab: */ 208 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 NULL 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 4 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 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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 | # else 65 | # if defined(__GNUC__) && __GNUC__ >= 4 66 | # define DECLSPEC __attribute__ ((visibility("default"))) 67 | # elif defined(__GNUC__) && __GNUC__ >= 2 68 | # define DECLSPEC __declspec(dllexport) 69 | # else 70 | # define DECLSPEC 71 | # endif 72 | # endif 73 | #endif 74 | 75 | /* By default SDL uses the C calling convention */ 76 | #ifndef SDLCALL 77 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) 78 | #define SDLCALL __cdecl 79 | #else 80 | #define SDLCALL 81 | #endif 82 | #endif /* SDLCALL */ 83 | 84 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 85 | #ifdef __SYMBIAN32__ 86 | #undef DECLSPEC 87 | #define DECLSPEC 88 | #endif /* __SYMBIAN32__ */ 89 | 90 | /* Force structure packing at 4 byte alignment. 91 | This is necessary if the header is included in code which has structure 92 | packing set to an alternate value, say for loading structures from disk. 93 | The packing is reset to the previous value in close_code.h 94 | */ 95 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 96 | #ifdef _MSC_VER 97 | #pragma warning(disable: 4103) 98 | #endif 99 | #ifdef __BORLANDC__ 100 | #pragma nopackwarning 101 | #endif 102 | #ifdef _M_X64 103 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ 104 | #pragma pack(push,8) 105 | #else 106 | #pragma pack(push,4) 107 | #endif 108 | #endif /* Compiler needs structure packing set */ 109 | 110 | #ifndef SDL_INLINE 111 | #if defined(__GNUC__) 112 | #define SDL_INLINE __inline__ 113 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ 114 | defined(__DMC__) || defined(__SC__) || \ 115 | defined(__WATCOMC__) || defined(__LCC__) || \ 116 | defined(__DECC) 117 | #define SDL_INLINE __inline 118 | #ifndef __inline__ 119 | #define __inline__ __inline 120 | #endif 121 | #else 122 | #define SDL_INLINE inline 123 | #ifndef __inline__ 124 | #define __inline__ inline 125 | #endif 126 | #endif 127 | #endif /* SDL_INLINE not defined */ 128 | 129 | #ifndef SDL_FORCE_INLINE 130 | #if defined(_MSC_VER) 131 | #define SDL_FORCE_INLINE __forceinline 132 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) 133 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ 134 | #else 135 | #define SDL_FORCE_INLINE static SDL_INLINE 136 | #endif 137 | #endif /* SDL_FORCE_INLINE not defined */ 138 | 139 | /* Apparently this is needed by several Windows compilers */ 140 | #if !defined(__MACH__) 141 | #ifndef NULL 142 | #ifdef __cplusplus 143 | #define NULL 0 144 | #else 145 | #define NULL ((void *)0) 146 | #endif 147 | #endif /* NULL */ 148 | #endif /* ! Mac OS X - breaks precompiled headers */ 149 | -------------------------------------------------------------------------------- /lib/SDL2/include/SDL2/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 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(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /lib/SDL2/linux/lib/libSDL2-2.0.so.0: -------------------------------------------------------------------------------- 1 | libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/linux/lib/libSDL2-2.0.so.0.4.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/linux/lib/libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/linux/lib/libSDL2.so: -------------------------------------------------------------------------------- 1 | libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/linux/lib64/libSDL2-2.0.so.0: -------------------------------------------------------------------------------- 1 | libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/linux/lib64/libSDL2-2.0.so.0.4.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/linux/lib64/libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/linux/lib64/libSDL2.so: -------------------------------------------------------------------------------- 1 | libSDL2-2.0.so.0.4.0 -------------------------------------------------------------------------------- /lib/SDL2/osx/libSDL2.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/osx/libSDL2.dylib -------------------------------------------------------------------------------- /lib/SDL2/win32/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/win32/SDL2.dll -------------------------------------------------------------------------------- /lib/SDL2/win32/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/win32/SDL2.lib -------------------------------------------------------------------------------- /lib/SDL2/win32/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HumbleDeveloper/ASMJSDemo/a8a19f0c8860af7698462bead863fc681a60d662/lib/SDL2/win32/SDL2main.lib -------------------------------------------------------------------------------- /lib/humble/humble_api.h: -------------------------------------------------------------------------------- 1 | #ifndef __HUMBLE_CLOUD_H__ 2 | #define __HUMBLE_CLOUD_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | int humble_init(); 11 | 12 | /** 13 | * Trigger a FS.syncfs call on the emscripten Filesystem 14 | */ 15 | void humble_syncfs(); 16 | 17 | /** 18 | * This method is 100% compatible to emscripten_async_wget_data. 19 | * Except that it can cache the fetched files into IndexedDB and it has 2 extension points 20 | * one to map the URL/path (e.g. to handle pre-signed GETs against CDNs) 21 | * another to map the URL path to a cache KEY. (e.g. if using relative allow it to be prefixed by something else 22 | */ 23 | void humble_fetch_asset_data(const char* url, void *arg, em_async_wget_onload_func onload, em_arg_callback_func onerror); 24 | 25 | /** 26 | * Gets the allowable player size of the humble player. Use this to restrict the size of the game in windowed mode. 27 | * returns 1 if the restriction should be enforced.. 0 otherwise 28 | */ 29 | int humble_get_player_size(int *width, int *height); 30 | 31 | /** 32 | * Called to let the humble player know the demo has ended. 33 | */ 34 | void humble_demo_ended(); 35 | 36 | #ifdef __cplusplus 37 | }; 38 | #endif 39 | 40 | #endif // __HUMBLE_CLOUD_H__ -------------------------------------------------------------------------------- /lib/lodepng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) 2 | PROJECT(lodepng) 3 | 4 | CreateLibrary(${PROJECT_NAME} 5 | DIRS 6 | . 7 | INCLUDES 8 | PUBLIC 9 | . 10 | PRIVATE 11 | ${SDL2_INCLUDE_DIR} 12 | PROPERTIES 13 | FOLDER "3rd Party" 14 | 15 | ) 16 | 17 | SET(LODEPNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) 18 | -------------------------------------------------------------------------------- /lib/lodepng/SDL_LodePNG.c: -------------------------------------------------------------------------------- 1 | #include "SDL_LodePNG.h" 2 | 3 | #include "lodepng.h" 4 | 5 | SDL_Surface *SDL_LodePNG(const char* filename) 6 | { 7 | SDL_Surface *temp = NULL; 8 | unsigned char *data = NULL; 9 | unsigned int w, h; 10 | 11 | unsigned ret = lodepng_decode32_file(&data, &w, &h, filename); 12 | if (ret == 0) 13 | { 14 | temp = SDL_CreateRGBSurfaceFrom((void*)data, w, h, 32, 4 * w, 15 | 0x000000ff, 16 | 0x0000ff00, 17 | 0x00ff0000, 18 | 0xff000000); 19 | if (temp) { 20 | SDL_Surface *t2 = SDL_ConvertSurface(temp, temp->format, 0); 21 | SDL_FreeSurface(temp); 22 | temp = t2; 23 | } 24 | free(data); 25 | } 26 | 27 | return temp; 28 | } 29 | -------------------------------------------------------------------------------- /lib/lodepng/SDL_LodePNG.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDL_LODEPNG_ 2 | #define _SDL_LODEPNG_ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | SDL_Surface *SDL_LodePNG(const char* filename); 11 | 12 | #ifndef NO_LOADPNG 13 | #define SDL_LoadPNG SDL_LodePNG 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/AssetManager.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // AssetManager.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "AssetManager.h" 10 | #include "FileSystem.h" 11 | 12 | #include 13 | 14 | AssetManager* AssetManager::m_defaultManager = 0; 15 | 16 | AssetManager& AssetManager::DefaultManager() 17 | { 18 | if(m_defaultManager) { 19 | return *m_defaultManager; 20 | } else { 21 | throw std::runtime_error("No Default Manager Configured!"); 22 | } 23 | } 24 | 25 | AssetManager::AssetManager() 26 | { 27 | } 28 | 29 | void AssetManager::add_path(const std::string &path) 30 | { 31 | m_searchpaths.push_back(path); 32 | } 33 | 34 | std::string AssetManager::find_resource(const std::string &name, const std::string& type) 35 | { 36 | std::string filename = name + "." + type; 37 | for (auto it = m_searchpaths.begin(); it != m_searchpaths.end(); ++it) { 38 | std::string full_path = FileSystem::join_path(*it, filename); 39 | if (FileSystem::exists(full_path)) 40 | { 41 | return full_path; 42 | } 43 | } 44 | return ""; 45 | } -------------------------------------------------------------------------------- /src/AssetManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AssetManager.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | class AssetManager { 15 | static AssetManager* m_defaultManager; 16 | 17 | std::vector m_searchpaths; 18 | public: 19 | static AssetManager& DefaultManager(); 20 | static void setDefaultManager(AssetManager* manager) { m_defaultManager = manager; } 21 | 22 | AssetManager(); 23 | 24 | void add_path(const std::string& path); 25 | 26 | std::string find_resource(const std::string& name, const std::string& type); 27 | }; -------------------------------------------------------------------------------- /src/Color.h: -------------------------------------------------------------------------------- 1 | // 2 | // Color.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | struct Color { 12 | unsigned char r,g,b,a; 13 | 14 | Color() : r(0), g(0), b(0), a(255) {} 15 | Color(char _r, char _g, char _b, char _a = 0) : r(_r), g(_g), b(_b), a(_a) {} 16 | }; -------------------------------------------------------------------------------- /src/Enemy.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Enemy.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/27/15. 6 | // 7 | // 8 | 9 | #include "Enemy.h" 10 | 11 | Enemy::Enemy(TextureRef texture, const Vector2f& velocity, const Rectf& bounds, float rotate_speed) 12 | : Entity(texture, velocity, bounds), 13 | m_rotate_speed(rotate_speed) 14 | { 15 | set_center(size() / 2); 16 | } 17 | 18 | bool Enemy::update(float delta) 19 | { 20 | rotate_by(m_rotate_speed * delta); 21 | return Entity::update(delta); 22 | } -------------------------------------------------------------------------------- /src/Enemy.h: -------------------------------------------------------------------------------- 1 | // 2 | // Enemy.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/27/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Entity.h" 12 | 13 | class Enemy : public Entity { 14 | float m_rotate_speed; 15 | public: 16 | Enemy(TextureRef texture, const Vector2f& vector, const Rectf& bounds, float rotate_speed); 17 | 18 | virtual bool update(float delta); 19 | }; 20 | -------------------------------------------------------------------------------- /src/Entity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Entity.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 3/3/15. 6 | // 7 | // 8 | 9 | #include "Entity.h" 10 | 11 | Entity::Entity(TextureRef texture, const Vector2f& vector, const Rectf& bounds) 12 | : Sprite(texture), 13 | m_active(false), 14 | m_velocity(vector), 15 | m_bounds(bounds) 16 | { 17 | set_center(size() / 2); 18 | } 19 | 20 | bool Entity::update(float delta) 21 | { 22 | move_position_by(m_velocity * delta); 23 | 24 | if (!m_bounds.intersects(Rectf(position() - center(), size()))) 25 | { 26 | m_active = false; 27 | } 28 | 29 | return m_active; 30 | } 31 | 32 | bool Entity::collides_with(const Entity &other) 33 | { 34 | return bounds().intersects(other.bounds()); 35 | } 36 | -------------------------------------------------------------------------------- /src/Entity.h: -------------------------------------------------------------------------------- 1 | // 2 | // Entity.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 3/3/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Sprite.h" 12 | #include "Updatable.h" 13 | #include "Rect.h" 14 | 15 | class Entity : public Sprite, public Updatable { 16 | bool m_active; 17 | Vector2f m_velocity; 18 | Rectf m_bounds; 19 | public: 20 | Entity(TextureRef texture, const Vector2f& vector, const Rectf& bounds); 21 | 22 | bool active() const { return m_active; } 23 | void activate() { m_active = true; } 24 | void deactivate() { m_active = false; } 25 | 26 | Vector2f velocity() const { return m_velocity; } 27 | void set_velocity(const Vector2f& velocity) { m_velocity = velocity; } 28 | 29 | virtual bool update(float delta); 30 | 31 | bool collides_with(const Entity& other); 32 | }; -------------------------------------------------------------------------------- /src/Explosion.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Explosion.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 3/4/15. 6 | // 7 | // 8 | 9 | #include "Explosion.h" 10 | 11 | Explosion::Explosion(TextureRef texture, const Rectf& bounds) 12 | : Entity(texture, Vector2f(), bounds), m_duration(0.0f) 13 | { 14 | } 15 | 16 | bool Explosion::update(float delta) 17 | { 18 | m_duration -= delta; 19 | 20 | if (m_duration <= 0.0f) { 21 | deactivate(); 22 | } 23 | 24 | return Entity::update(delta); 25 | } -------------------------------------------------------------------------------- /src/Explosion.h: -------------------------------------------------------------------------------- 1 | // 2 | // Explosion.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 3/4/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Entity.h" 12 | 13 | class Explosion : public Entity { 14 | float m_duration; 15 | public: 16 | Explosion(TextureRef texture, const Rectf& bounds); 17 | 18 | float duration() { return m_duration; } 19 | void set_duration(float duration) { m_duration = duration; } 20 | 21 | virtual bool update(float delta); 22 | }; -------------------------------------------------------------------------------- /src/FileSystem.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // FileSystem.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "FileSystem.h" 10 | 11 | #ifndef WIN32 12 | #define PATH_SEPARATOR "/" 13 | 14 | #include 15 | 16 | FILE* FileSystem::open(const std::string &path, const std::string& mode) 17 | { 18 | FILE* fp = fopen(path.c_str(), mode.c_str()); 19 | return fp; 20 | } 21 | 22 | bool FileSystem::exists(const std::string &path) 23 | { 24 | return access(path.c_str(), F_OK) == 0; 25 | } 26 | #else // the windows code-path 27 | #define PATH_SEPARATOR "\\" 28 | 29 | #include 30 | 31 | bool FileSystem::exists(const std::string &path) 32 | { 33 | return _access(path.c_str(), 0) == 0; 34 | } 35 | 36 | 37 | FILE* FileSystem::open(const std::string &path, const std::string& mode) 38 | { 39 | FILE* fp = 0; 40 | fopen_s(&fp, path.c_str(), mode.c_str()); 41 | return fp; 42 | } 43 | #endif 44 | 45 | 46 | std::string FileSystem::join_path(const std::string &dir, const std::string &file) 47 | { 48 | std::string ret = dir; 49 | char last_c = ret[ret.length() - 1]; 50 | if (last_c != '/' && last_c != '\\') { 51 | ret += PATH_SEPARATOR; 52 | } 53 | if (file[0] == '/' || file[0] == '\\') { 54 | ret += file.substr(1); 55 | } else { 56 | ret += file; 57 | } 58 | return ret; 59 | } -------------------------------------------------------------------------------- /src/FileSystem.h: -------------------------------------------------------------------------------- 1 | // 2 | // FileSystem.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | namespace FileSystem { 14 | FILE* open(const std::string& path, const std::string& mode = "r"); 15 | 16 | bool exists(const std::string& path); 17 | 18 | std::string join_path(const std::string& dir, const std::string& file); 19 | } -------------------------------------------------------------------------------- /src/Game.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Game.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #include "Game.h" 10 | 11 | #ifdef WIN32 12 | #define _USE_MATH_DEFINES 13 | #include 14 | #endif 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #define PLAYER_X_SPEED 384.0f 22 | #define TORPEDO_SPEED 448.0f 23 | #define TORPEDO_RELOAD_TIME 0.4f 24 | 25 | #define ENEMY_MAX 3 26 | #define ENEMY_PROBABILITY 5 27 | #define ENEMY_ROTATION 45.0f 28 | #define ENEMY_SPEED 64.0f 29 | #define ENEMY_START_BASE 80.0f 30 | #define ENEMY_START_RANGE 50.0f 31 | 32 | 33 | Game::Game(Renderer& r) : m_renderer(r), m_Player(r.load_texture("spaceship"), TORPEDO_RELOAD_TIME) 34 | { 35 | m_renderer.set_swap_interval(1); 36 | 37 | add_renderable(&m_Player); 38 | 39 | m_renderer.set_logical_size(Vector2i(640, 400)); 40 | 41 | float ypos = m_renderer.logical_size().y - m_Player.size().y / 2; 42 | 43 | m_Player.set_move_range(Vector2f(m_Player.center().x, ypos), Vector2f(m_renderer.logical_size().x - m_Player.center().x, ypos)); 44 | m_Player.set_position(Vector2f(m_renderer.logical_size().x / 2.0f, ypos)); 45 | 46 | for (int i = 0; i < InputForce_MAX; ++i) { 47 | inputValues[i] = 0; 48 | } 49 | 50 | std::srand((unsigned int)std::time(0)); 51 | } 52 | 53 | void Game::apply_input(Game::InputForce force, float value) 54 | { 55 | if (force >= 0 && force < InputForce_MAX) { 56 | inputValues[force] = value; 57 | } 58 | } 59 | 60 | void Game::update(float delta) 61 | { 62 | for (auto it = m_updatables.begin(); it != m_updatables.end(); ) { 63 | bool keep = (*it)->update( delta ); 64 | if (!keep) { 65 | Renderable *o = dynamic_cast(*it); 66 | ++it; 67 | remove_renderable(o); 68 | } else { 69 | ++it; 70 | } 71 | } 72 | 73 | if (inputValues[InputForce_X_AXIS]) { 74 | float distance = inputValues[InputForce_X_AXIS] * delta * PLAYER_X_SPEED; 75 | m_Player.move_position_by(Vector2f(distance, 0.0f)); 76 | } 77 | if (inputValues[InputForce_SHOOT]) { 78 | fire_torpedo(m_Player); 79 | } 80 | check_enemies(); 81 | check_collisions(); 82 | } 83 | 84 | void Game::add_renderable(Renderable *renderable, int layer) 85 | { 86 | if (!renderable) return; 87 | 88 | Updatable* updatable = dynamic_cast(renderable); 89 | if (updatable) { 90 | m_updatables.push_back(updatable); 91 | } 92 | m_renderables[layer].push_back(renderable); 93 | } 94 | 95 | void Game::remove_renderable(Renderable *renderable, bool updatable_also) 96 | { 97 | if (renderable == 0) return; 98 | 99 | for (int i = 0; i < MAX_LAYERS; ++i) { 100 | m_renderables[i].remove(renderable); 101 | } 102 | if (updatable_also) { 103 | Updatable *updatable = dynamic_cast(renderable); 104 | if (updatable) { 105 | m_updatables.remove(updatable); 106 | } 107 | } 108 | } 109 | 110 | void Game::render() 111 | { 112 | m_renderer.clear(); 113 | 114 | // m_renderer.draw_rect_fill(Rect(Vector2i(), m_renderer.logical_size()), Color(100, 50, 20)); 115 | 116 | for (int l = MAX_LAYERS - 1; l >= 0; --l) { 117 | for( auto it = m_renderables[l].begin(); it != m_renderables[l].end(); ++it) { 118 | (*it)->render( m_renderer ); 119 | } 120 | } 121 | 122 | m_renderer.present(); 123 | } 124 | 125 | static float random(float range) 126 | { 127 | int r = std::rand(); 128 | return float(r) / RAND_MAX * range; 129 | } 130 | 131 | // This would be easier with C++11 variadic templates 132 | template 133 | static typename std::list::iterator find_or_create(std::list& list, const T1& a1, const T2& a2) 134 | { 135 | auto it = list.begin(); 136 | for (; it != list.end(); ++it) { 137 | if (!it->active()) break; 138 | } 139 | if (it == list.end()) { 140 | list.push_back(T(a1, a2)); 141 | it = --list.end(); 142 | } 143 | return it; 144 | } 145 | template 146 | static typename std::list::iterator find_or_create(std::list& list, const T1& a1, const T2& a2, const T3& a3) 147 | { 148 | auto it = list.begin(); 149 | for (; it != list.end(); ++it) { 150 | if (!it->active()) break; 151 | } 152 | if (it == list.end()) { 153 | list.push_back(T(a1, a2, a3)); 154 | it = --list.end(); 155 | } 156 | return it; 157 | } 158 | template 159 | static typename std::list::iterator find_or_create(std::list& list, const T1& a1, const T2& a2, const T3& a3, const T4& a4) 160 | { 161 | auto it = list.begin(); 162 | for (; it != list.end(); ++it) { 163 | if (!it->active()) break; 164 | } 165 | if (it == list.end()) { 166 | list.push_back(T(a1, a2, a3, a4)); 167 | it = --list.end(); 168 | } 169 | return it; 170 | } 171 | 172 | void Game::fire_torpedo(Player &player) 173 | { 174 | if (!player.can_shoot() || !player.fire_torpedo()) { 175 | return; 176 | } 177 | 178 | auto it = find_or_create(m_projectiles, m_renderer.load_texture("torpedo"), Vector2f(0, -TORPEDO_SPEED), Recti(m_renderer.logical_size()).as()); 179 | 180 | it->set_position(player.position()); 181 | it->activate(); 182 | 183 | add_renderable(&(*it), 1); 184 | } 185 | 186 | template 187 | bool isActive(const T& o) { 188 | return o.active(); 189 | } 190 | 191 | void Game::check_collisions() 192 | { 193 | for (auto it_p = m_projectiles.begin(); it_p != m_projectiles.end(); ++it_p) { 194 | if (!it_p->active()) continue; 195 | for (auto it_e = m_enemies.begin(); it_e != m_enemies.end(); ++it_e) { 196 | if (!it_e->active()) continue; 197 | 198 | if (it_p->collides_with(*it_e)) { 199 | it_p->deactivate(); 200 | it_e->deactivate(); 201 | 202 | Rectf bounds = Recti(m_renderer.logical_size()).as(); 203 | 204 | auto it = find_or_create(m_explosions, m_renderer.load_texture("explosion"), bounds); 205 | it->set_duration(0.35f); 206 | it->set_velocity(it_e->velocity() * 0.75f); 207 | it->set_position(it_e->position()); 208 | it->activate(); 209 | add_renderable(&(*it), 0); 210 | } 211 | } 212 | if (!it_p->active()) { 213 | Rectf bounds = Recti(m_renderer.logical_size()).as(); 214 | 215 | auto it = find_or_create(m_explosions, m_renderer.load_texture("explosion"), bounds); 216 | it->set_duration(0.2f); 217 | it->set_velocity(it_p->velocity() / 2); 218 | it->set_position(it_p->position()); 219 | it->activate(); 220 | add_renderable(&(*it), 0); 221 | } 222 | } 223 | } 224 | 225 | void Game::check_enemies() 226 | { 227 | if (std::count_if(m_enemies.begin(), m_enemies.end(), isActive) < ENEMY_MAX) { 228 | if (random(100.0f) < ENEMY_PROBABILITY) { 229 | float angle = random(90.0f); 230 | angle -= 45.0f; 231 | if (random(100.0f) >= 50.0f) { 232 | angle += 180.0f; 233 | } 234 | angle *= M_PI / 180.0f; 235 | 236 | Vector2f velocity(std::cos(angle), std::sin(angle)); 237 | 238 | auto it = find_or_create(m_enemies, m_renderer.load_texture("ufo"), velocity * ENEMY_SPEED, Recti(m_renderer.logical_size()).as(), ENEMY_ROTATION); 239 | 240 | Vector2f position(-it->size().x / 2, ENEMY_START_BASE + random(ENEMY_START_RANGE)); 241 | if (velocity.x < 0) { 242 | position.x = m_renderer.logical_size().x + it->size().x / 2; 243 | } 244 | it->set_position(position); 245 | it->activate(); 246 | add_renderable(&(*it), 0); 247 | } 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /src/Game.h: -------------------------------------------------------------------------------- 1 | // 2 | // Game.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Renderer.h" 12 | #include "Player.h" 13 | #include "Renderable.h" 14 | #include "Enemy.h" 15 | #include "Explosion.h" 16 | 17 | #include 18 | 19 | class Game { 20 | public: 21 | enum InputForce { 22 | InputForce_X_AXIS, 23 | InputForce_Y_AXIS, 24 | InputForce_SHOOT, 25 | InputForce_START, 26 | InputForce_MAX, 27 | }; 28 | private: 29 | Renderer& m_renderer; 30 | Player m_Player; 31 | 32 | float inputValues[InputForce_MAX]; 33 | 34 | std::list m_projectiles; 35 | std::list m_enemies; 36 | std::list m_explosions; 37 | 38 | static const int MAX_LAYERS = 2; 39 | 40 | std::list m_renderables[MAX_LAYERS]; 41 | std::list m_updatables; 42 | public: 43 | Game(Renderer& r); 44 | 45 | void apply_input(InputForce force, float value); 46 | 47 | void update(float delta); 48 | void render(); 49 | 50 | void add_renderable(Renderable* renderable, int layer = 0); 51 | void remove_renderable(Renderable *renderable, bool updatable_also = true); 52 | private: 53 | void fire_torpedo(Player& player); 54 | void check_enemies(); 55 | void check_collisions(); 56 | }; -------------------------------------------------------------------------------- /src/Player.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Player.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #include "Player.h" 10 | 11 | Player::Player(TextureRef texture, float torpedo_reload_time) : 12 | Sprite(texture), 13 | m_torpedo_delay(0.0f), 14 | m_torpedo_reload_time(torpedo_reload_time), 15 | m_normalized_position(0.0f) 16 | { 17 | set_center(size() / 2); 18 | } 19 | 20 | void Player::set_move_range(const Vector2f& min, const Vector2f& max) 21 | { 22 | m_min = min; 23 | m_max = max; 24 | move_position_by(Vector2f()); 25 | } 26 | 27 | void Player::move_position_by(const Vector2f& adjust_position) 28 | { 29 | Sprite::move_position_by(adjust_position); 30 | if (position().x < m_min.x) { 31 | set_position(m_min); 32 | } else if (position().x > m_max.x) { 33 | set_position(m_max); 34 | } else { 35 | update_normalized_position(); 36 | } 37 | } 38 | 39 | void Player::set_position(const Vector2f &position) 40 | { 41 | Sprite::set_position(position); 42 | update_normalized_position(); 43 | } 44 | 45 | void Player::update_normalized_position() 46 | { 47 | Vector2f range = (m_max - m_min) / 2; 48 | Vector2f mid = position() - m_min - range; 49 | m_normalized_position = mid / range; 50 | } 51 | 52 | bool Player::update(float delta) 53 | { 54 | m_torpedo_delay -= delta; 55 | if (m_torpedo_delay < 0.0f) m_torpedo_delay = 0.0f; 56 | 57 | return true; 58 | } 59 | 60 | bool Player::can_shoot() const 61 | { 62 | return m_torpedo_delay == 0.0f; 63 | } 64 | 65 | bool Player::fire_torpedo() 66 | { 67 | m_torpedo_delay = m_torpedo_reload_time; 68 | 69 | return true; 70 | } 71 | -------------------------------------------------------------------------------- /src/Player.h: -------------------------------------------------------------------------------- 1 | // 2 | // Player.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Sprite.h" 12 | #include "Projectile.h" 13 | 14 | #include 15 | 16 | class Player : public Sprite, public Updatable { 17 | Vector2f m_min, m_max; 18 | 19 | float m_torpedo_delay; 20 | float m_torpedo_reload_time; 21 | 22 | Vector2f m_normalized_position; 23 | void update_normalized_position(); 24 | public: 25 | Player(TextureRef texture, float torpedo_reload_time); 26 | 27 | void set_move_range(const Vector2f& min, const Vector2f& max); 28 | void move_position_by(const Vector2f& adjust_position); 29 | void set_position(const Vector2f& position); 30 | 31 | Vector2f normalized_position() { return m_normalized_position; } 32 | 33 | bool can_shoot() const; 34 | bool fire_torpedo(); 35 | 36 | bool update(float delta); 37 | }; -------------------------------------------------------------------------------- /src/Projectile.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Projectile.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "Projectile.h" 10 | 11 | Projectile::Projectile(TextureRef texture, const Vector2f& velocity, const Rectf& bounds) : Entity(texture, velocity, bounds) { 12 | set_center(size() / 2); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/Projectile.h: -------------------------------------------------------------------------------- 1 | // 2 | // Projectile.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Entity.h" 12 | 13 | class Projectile : public Entity { 14 | public: 15 | Projectile(TextureRef texture, const Vector2f& vector, const Rectf& bounds); 16 | }; -------------------------------------------------------------------------------- /src/Rect.h: -------------------------------------------------------------------------------- 1 | // 2 | // Rect.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Vector2.h" 12 | 13 | template 14 | struct Rect { 15 | T x, y; 16 | T w, h; 17 | 18 | Rect() : x(T()), y(T()), w(T()), h(T()) {} 19 | Rect(T _x, T _y, T _w, T _h) : x(_x), y(_y), w(_w), h(_h) {} 20 | Rect(const Vector2& size) : x(T()), y(T()), w(size.x), h(size.y) {} 21 | Rect(const Vector2& position, const Vector2& size) : x(position.x), y(position.y), w(size.x), h(size.y) {} 22 | 23 | template 24 | Rect as() const { 25 | return Rect(O(x), O(y), O(w), O(h)); 26 | } 27 | 28 | Vector2 bottom_right() const { return Vector2(x + w, y + h); } 29 | 30 | bool empty() const { 31 | return w == T() && h == T(); 32 | } 33 | 34 | bool contains(const Vector2& point) const { 35 | Vector2 br = bottom_right(); 36 | 37 | if (point.x >= x && point.y >= y 38 | && point.x < br.x && point.y < br.y) { 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | bool intersects(const Rect& r) { 45 | if (empty() || r.empty()) return false; 46 | 47 | if (r.x < x + w && x < r.x + r.w && r.y < y + h) 48 | return y < r.y + r.h; 49 | 50 | return false; 51 | } 52 | }; 53 | 54 | typedef Rect Recti; 55 | typedef Rect Rectf; 56 | -------------------------------------------------------------------------------- /src/Renderable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Renderable.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | class Renderer; 12 | 13 | struct Renderable { 14 | virtual void render(Renderer& rend) = 0; 15 | }; -------------------------------------------------------------------------------- /src/Renderer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #include "Renderer.h" 10 | 11 | void Renderer::draw_texture(TextureRef texture, const Vector2i &dst_pos, float angle) 12 | { 13 | const Vector2i& size = texture->size(); 14 | Recti src(size); 15 | Recti dst(dst_pos, size); 16 | 17 | draw_texture(texture, src, dst, angle); 18 | } -------------------------------------------------------------------------------- /src/Renderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Color.h" 12 | #include "Rect.h" 13 | #include "Texture.h" 14 | 15 | #include 16 | 17 | class Renderer { 18 | protected: 19 | Vector2i m_size, m_logical_size; 20 | bool m_logical_set; 21 | public: 22 | Renderer() : m_logical_set(false) {} 23 | virtual ~Renderer() {} 24 | 25 | virtual void set_logical_size(Vector2i size, bool keepAspect = true) = 0; 26 | 27 | virtual void set_swap_interval(int swap) = 0; 28 | virtual void update_window_size() = 0; 29 | virtual void clear(const Color& c = Color()) = 0; 30 | virtual void present() = 0; 31 | virtual void draw_rect_fill(const Recti& r, const Color& c) = 0; 32 | 33 | virtual TextureRef load_texture(const std::string& name) = 0; 34 | virtual void draw_texture(TextureRef texture, const Vector2i& dst, float angle = 0.0f); 35 | virtual void draw_texture(TextureRef texture, const Recti& src, const Recti& dst, float angle = 0.0f) = 0; 36 | 37 | const Vector2i& size() const { return m_size; } 38 | int width() const { return m_size.x; } 39 | int height() const { return m_size.y; } 40 | 41 | const Vector2i& logical_size() const { return m_logical_size; } 42 | }; -------------------------------------------------------------------------------- /src/Renderer_SDL2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer_SDL2.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #include "Renderer_SDL2.h" 10 | 11 | #include "AssetManager.h" 12 | #include "Texture_SDL2.h" 13 | 14 | Renderer_SDL2::Renderer_SDL2(SDL_Window* win, SDL_Renderer* rend) : m_win(win), m_rend(rend) 15 | { 16 | update_window_size(); 17 | } 18 | 19 | Renderer_SDL2::~Renderer_SDL2() 20 | { 21 | for (auto it = m_textureCache.begin(); it != m_textureCache.end(); ++it) { 22 | delete it->second; 23 | } 24 | m_textureCache.clear(); 25 | } 26 | 27 | void Renderer_SDL2::update_window_size() 28 | { 29 | SDL_GetWindowSize(m_win, &m_size.x, &m_size.y); 30 | if (!m_logical_set) { 31 | m_logical_size = m_size; 32 | } 33 | } 34 | 35 | void Renderer_SDL2::set_logical_size(Vector2i size, bool keepAspect) 36 | { 37 | m_logical_set = true; 38 | m_logical_size = size; 39 | SDL_RenderSetLogicalSize(m_rend, size.x, size.y); 40 | } 41 | 42 | void Renderer_SDL2::set_swap_interval(int swap) 43 | { 44 | #ifndef EMSCRIPTEN 45 | int ret = SDL_GL_SetSwapInterval(swap); 46 | if (swap == -1 && ret != 0) { 47 | SDL_GL_SetSwapInterval(1); 48 | } 49 | #endif 50 | } 51 | 52 | TextureRef Renderer_SDL2::load_texture(const std::string &name) 53 | { 54 | auto it = m_textureCache.find(name); 55 | if (it != m_textureCache.end()) { 56 | return it->second; 57 | } 58 | std::string asset_file = AssetManager::DefaultManager().find_resource(name, "png"); 59 | if (!asset_file.empty()) { 60 | TextureRef tex = new Texture_SDL2(*this, asset_file); 61 | m_textureCache.insert(std::make_pair(name, tex)); 62 | return tex; 63 | } 64 | return Texture::NullTexture; 65 | } 66 | 67 | void Renderer_SDL2::draw_texture(TextureRef texture, const Recti& src, const Recti& dst, float angle) 68 | { 69 | Texture_SDL2* tex = dynamic_cast(texture); 70 | if (tex) { 71 | SDL_Texture *stex = tex->m_texture; 72 | SDL_RenderCopyEx(m_rend, stex, (const SDL_Rect*)&src, (const SDL_Rect*)&dst, angle, NULL, SDL_FLIP_NONE); 73 | } 74 | } 75 | 76 | void Renderer_SDL2::clear(const Color& color) 77 | { 78 | set_draw_color(color); 79 | SDL_RenderClear(m_rend); 80 | } 81 | 82 | void Renderer_SDL2::draw_rect_fill(const Recti& r, const Color& c) 83 | { 84 | set_draw_color(c); 85 | SDL_RenderFillRect(m_rend, (const SDL_Rect*)&r); 86 | } 87 | 88 | void Renderer_SDL2::present() 89 | { 90 | SDL_RenderPresent(m_rend); 91 | } 92 | 93 | void Renderer_SDL2::set_draw_color(const Color& c) 94 | { 95 | SDL_SetRenderDrawColor(m_rend, c.r, c.g, c.b, c.a); 96 | } 97 | -------------------------------------------------------------------------------- /src/Renderer_SDL2.h: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer_SDL2.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Renderer.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | class Renderer_SDL2 : public Renderer { 18 | friend class Texture_SDL2; 19 | 20 | SDL_Window* m_win; 21 | SDL_Renderer* m_rend; 22 | std::map m_textureCache; 23 | public: 24 | Renderer_SDL2(SDL_Window* win, SDL_Renderer* rend); 25 | ~Renderer_SDL2(); 26 | 27 | void set_logical_size(Vector2i size, bool keepAspect = true); 28 | 29 | void set_swap_interval(int swap); 30 | void update_window_size(); 31 | void clear(const Color& c = Color()); 32 | void draw_rect_fill(const Recti& r, const Color& c); 33 | void present(); 34 | 35 | TextureRef load_texture(const std::string& name); 36 | void draw_texture(TextureRef texture, const Recti& src, const Recti& dst, float angle = 0.0f); 37 | private: 38 | void set_draw_color(const Color& c); 39 | }; 40 | -------------------------------------------------------------------------------- /src/Sprite.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Sprite.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "Sprite.h" 10 | #include "Renderer.h" 11 | 12 | Sprite::Sprite(TextureRef texture) 13 | : m_texture(texture), 14 | m_size(m_texture->size().as()), 15 | m_angle(0.0f), 16 | m_frame(0), 17 | m_has_frames(false) 18 | { 19 | } 20 | 21 | void Sprite::set_size(const Vector2f& size) 22 | { 23 | // TODO validate that m_size is cleanly divisible into texture size? 24 | m_has_frames = (m_size != size); 25 | m_size = size; 26 | } 27 | 28 | void Sprite::render(Renderer& rend) 29 | { 30 | if (m_has_frames) { 31 | Recti src = frame_rect(m_frame); 32 | Recti dst = Rectf((m_position - m_center), m_size).as(); 33 | rend.draw_texture(m_texture, src, dst, m_angle); 34 | } else { 35 | rend.draw_texture(m_texture, (m_position - m_center).as(), m_angle); 36 | } 37 | } 38 | 39 | Recti Sprite::frame_rect(int frame) 40 | { 41 | int pos_x, pos_y, frame_y; 42 | pos_x = frame * m_size.x; 43 | frame_y = pos_x / m_texture->width(); 44 | pos_x %= m_texture->width(); 45 | pos_y = frame_y * m_size.y; 46 | if ((pos_y + m_size.y) > m_texture->height()) { 47 | return Recti(m_size.as()); 48 | } 49 | return Recti(pos_x, pos_y, m_size.x, m_size.y); 50 | } 51 | 52 | void Sprite::move_position_by(const Vector2f &adjust_position) 53 | { 54 | m_position += adjust_position; 55 | } -------------------------------------------------------------------------------- /src/Sprite.h: -------------------------------------------------------------------------------- 1 | // 2 | // Sprite.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Renderable.h" 12 | #include "Texture.h" 13 | 14 | #include "Vector2.h" 15 | #include "Rect.h" 16 | 17 | class Sprite : public Renderable { 18 | TextureRef m_texture; 19 | Vector2f m_position; 20 | Vector2f m_size; 21 | Vector2f m_center; 22 | float m_angle; 23 | int m_frame; 24 | bool m_has_frames; 25 | public: 26 | Sprite(TextureRef m_texture); 27 | virtual void render(Renderer& rend); 28 | 29 | void set_position(const Vector2f& position) { m_position = position; } 30 | const Vector2f& position() const { return m_position; } 31 | void move_position_by(const Vector2f& adjust_position); 32 | 33 | void set_angle(float angle) { m_angle = angle; } 34 | float angle() { return m_angle; } 35 | void rotate_by(float angle) { m_angle += angle; } 36 | 37 | void set_center(const Vector2f& center) { m_center = center; } 38 | const Vector2f& center() const { return m_center; } 39 | 40 | void set_size(const Vector2f& size); 41 | const Vector2f& size() const { return m_size; } 42 | 43 | void set_frame(int frame) { m_frame = frame; } 44 | int frame() { return m_frame; } 45 | Recti frame_rect(int frame); 46 | 47 | Rectf bounds() const { 48 | return Rectf(m_position - m_center, m_size); 49 | } 50 | }; -------------------------------------------------------------------------------- /src/Texture.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Texture.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "Texture.h" 10 | 11 | class NullTexture : public Texture { 12 | public: 13 | NullTexture() {} 14 | }; 15 | 16 | static NullTexture nullTexture; 17 | 18 | TextureRef Texture::NullTexture = &nullTexture; 19 | -------------------------------------------------------------------------------- /src/Texture.h: -------------------------------------------------------------------------------- 1 | // 2 | // Texture.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Vector2.h" 12 | 13 | class Texture; 14 | typedef Texture* TextureRef; 15 | 16 | class Texture { 17 | protected: 18 | Vector2i m_size; 19 | 20 | Texture() {} 21 | public: 22 | virtual ~Texture() {} 23 | 24 | int width() { return m_size.x; } 25 | int height() { return m_size.y; } 26 | const Vector2i& size() { return m_size; } 27 | 28 | static TextureRef NullTexture; 29 | }; 30 | -------------------------------------------------------------------------------- /src/Texture_SDL2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Texture_SDL2.cpp 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #include "Texture_SDL2.h" 10 | 11 | #include 12 | 13 | Texture_SDL2::Texture_SDL2(Renderer_SDL2& rend, const std::string& filename) : m_texture(0) 14 | { 15 | SDL_Surface *surface = SDL_LoadPNG(filename.c_str()); 16 | if (surface) { 17 | m_texture = SDL_CreateTextureFromSurface(rend.m_rend, surface); 18 | if (m_texture) { 19 | m_size.x = surface->w; 20 | m_size.y = surface->h; 21 | } 22 | SDL_FreeSurface(surface); 23 | } 24 | } 25 | 26 | Texture_SDL2::~Texture_SDL2() 27 | { 28 | if (m_texture) { 29 | SDL_DestroyTexture(m_texture); 30 | } 31 | } -------------------------------------------------------------------------------- /src/Texture_SDL2.h: -------------------------------------------------------------------------------- 1 | // 2 | // Texture_SDL2.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "Renderer_SDL2.h" 12 | 13 | #include 14 | 15 | class Texture_SDL2 : public Texture { 16 | friend class Renderer_SDL2; 17 | SDL_Texture *m_texture; 18 | public: 19 | Texture_SDL2(Renderer_SDL2& rend, const std::string& filename); 20 | ~Texture_SDL2(); 21 | }; -------------------------------------------------------------------------------- /src/Updatable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Updatable.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/25/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | struct Updatable { 12 | virtual bool update(float delta) = 0; 13 | }; 14 | -------------------------------------------------------------------------------- /src/Vector2.h: -------------------------------------------------------------------------------- 1 | // 2 | // Vector2.h 3 | // HumbleASMJSDemo 4 | // 5 | // Created by Edward Rudd on 2/20/15. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | template 12 | struct Vector2 { 13 | T x, y; 14 | 15 | Vector2() : x(T()), y(T()) {} 16 | Vector2(T _v) : x(_v), y(_v) {} 17 | Vector2(T _x, T _y) : x(_x), y(_y) {} 18 | 19 | template 20 | const Vector2 as() const { 21 | return Vector2(T2(x), T2(y)); 22 | } 23 | 24 | Vector2& operator -=(const Vector2& o) { 25 | this->x -= o.x; 26 | this->y -= o.y; 27 | 28 | return *this; 29 | } 30 | 31 | Vector2& operator +=(const Vector2& o) { 32 | this->x += o.x; 33 | this->y += o.y; 34 | 35 | return *this; 36 | } 37 | 38 | const Vector2 operator -(const Vector2& o) const { 39 | return Vector2(x - o.x, y - o.y); 40 | } 41 | 42 | const Vector2 operator +(const Vector2& o) const { 43 | return Vector2(x + o.x, y + o.y); 44 | } 45 | 46 | const Vector2 operator /(const Vector2& o) const { 47 | return Vector2(x / o.x, y / o.y); 48 | } 49 | 50 | const Vector2 operator /(T o) const { 51 | return Vector2(x / o, y / o); 52 | } 53 | 54 | const Vector2 operator *(const Vector2& o) const { 55 | return Vector2(x * o.x, y * o.y); 56 | } 57 | 58 | const Vector2 operator *(T o) const { 59 | return Vector2(x * o, y * o); 60 | } 61 | 62 | bool operator ==(const Vector2& o) const { 63 | return x == o.x && y == o.y; 64 | } 65 | 66 | bool operator !=(const Vector2& o) const { 67 | return x != o.x || y != o.y; 68 | } 69 | }; 70 | 71 | typedef Vector2 Vector2f; 72 | typedef Vector2 Vector2i; -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef EMSCRIPTEN 4 | #include 5 | #endif 6 | 7 | #include "AssetManager.h" 8 | #include "FileSystem.h" 9 | #include "Game.h" 10 | #include "Renderer_SDL2.h" 11 | 12 | #ifdef USE_HUMBLE_API 13 | #include "humble_api.h" 14 | #endif 15 | 16 | bool done = false; 17 | 18 | static SDL_Window *win = NULL; 19 | static SDL_Renderer *renderer = NULL; 20 | 21 | static Uint32 last_time = 0; 22 | 23 | void loop_iteration(Game* game) 24 | { 25 | SDL_Event e; 26 | while (SDL_PollEvent(&e)) { 27 | switch (e.type) { 28 | case SDL_KEYDOWN: 29 | case SDL_KEYUP: 30 | switch (e.key.keysym.scancode) { 31 | case SDL_SCANCODE_LEFT: 32 | case SDL_SCANCODE_RIGHT: { 33 | const Uint8* keys = SDL_GetKeyboardState(0); 34 | Sint16 xpos = 0; 35 | 36 | if (keys[SDL_SCANCODE_LEFT] && keys[SDL_SCANCODE_RIGHT]) { 37 | xpos = 0; 38 | } else if (keys[SDL_SCANCODE_LEFT]) { 39 | xpos = -1.0f; 40 | } else if (keys[SDL_SCANCODE_RIGHT]) { 41 | xpos = 1.0f; 42 | } 43 | 44 | game->apply_input(Game::InputForce_X_AXIS, xpos); 45 | } 46 | break; 47 | case SDL_SCANCODE_UP: 48 | game->apply_input(Game::InputForce_SHOOT, e.key.state == SDL_PRESSED ? 1 : 0); 49 | break; 50 | case SDL_SCANCODE_ESCAPE: 51 | game->apply_input(Game::InputForce_START, e.key.state == SDL_PRESSED ? 1 : 0); 52 | default: 53 | break; 54 | } 55 | break; 56 | case SDL_QUIT: 57 | done = true; 58 | return; 59 | break; 60 | 61 | default: 62 | break; 63 | } 64 | } 65 | 66 | Uint32 cur_time = SDL_GetTicks(); 67 | float delta = float(cur_time - last_time) / 1000.0f; 68 | last_time = cur_time; 69 | 70 | game->update(delta); 71 | game->render(); 72 | } 73 | 74 | 75 | int main(int argc, char* argv[]) 76 | { 77 | #ifdef USE_HUMBLE_API 78 | humble_init(); 79 | #endif 80 | 81 | SDL_Init(SDL_INIT_VIDEO); 82 | 83 | int width = 640, height = 480; 84 | #ifdef USE_HUMBLE_API 85 | if (humble_get_player_size(&width, &height) == 0) { 86 | width = 640; 87 | height = 480; 88 | } 89 | #endif 90 | 91 | SDL_CreateWindowAndRenderer(width, height, SDL_WINDOW_OPENGL, &win, &renderer); 92 | 93 | int w,h; 94 | SDL_GetWindowSize(win, &w, &h); 95 | 96 | char *base = SDL_GetBasePath(); 97 | std::string base_path(base); 98 | SDL_free(base); 99 | 100 | std::string asset_path_marker = FileSystem::join_path(base_path, "asset_path.txt"); 101 | if (FileSystem::exists(asset_path_marker)) { 102 | FILE* fp = FileSystem::open(asset_path_marker); 103 | if (fp) { 104 | char buff[1024]; 105 | fgets(buff, sizeof(buff), fp); 106 | base_path = FileSystem::join_path(base_path, buff); 107 | fclose(fp); 108 | } 109 | } 110 | #ifdef EMSCRIPTEN 111 | else { 112 | base_path = FileSystem::join_path(base_path, "assets"); 113 | } 114 | #endif 115 | 116 | AssetManager *asset_manager = new AssetManager(); 117 | asset_manager->add_path(base_path); 118 | AssetManager::setDefaultManager(asset_manager); 119 | 120 | Renderer* game_renderer = new Renderer_SDL2(win, renderer); 121 | 122 | Game* game = new Game(*game_renderer); 123 | 124 | last_time = SDL_GetTicks(); 125 | 126 | #ifdef EMSCRIPTEN 127 | emscripten_set_main_loop_arg((em_arg_callback_func)loop_iteration, game, 0, 1); 128 | #else 129 | while (!done) { 130 | loop_iteration(game); 131 | } 132 | #endif 133 | 134 | delete game; 135 | delete game_renderer; 136 | 137 | SDL_Quit(); 138 | 139 | return 0; 140 | } --------------------------------------------------------------------------------