├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── deps ├── CMakeLists.txt ├── glad │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ └── src │ │ └── glad.c └── glfw-3.2 │ ├── CMake │ ├── MacOSXBundleInfo.plist.in │ ├── amd64-mingw32msvc.cmake │ ├── i586-mingw32msvc.cmake │ ├── i686-pc-mingw32.cmake │ ├── i686-w64-mingw32.cmake │ ├── modules │ │ ├── FindMir.cmake │ │ ├── FindVulkan.cmake │ │ ├── FindWaylandProtocols.cmake │ │ └── FindXKBCommon.cmake │ └── x86_64-w64-mingw32.cmake │ ├── CMakeLists.txt │ ├── COPYING.txt │ ├── README.md │ ├── cmake_uninstall.cmake.in │ ├── deps │ ├── KHR │ │ └── khrplatform.h │ ├── getopt.c │ ├── getopt.h │ ├── glad.c │ ├── glad │ │ └── glad.h │ ├── linmath.h │ ├── mingw │ │ ├── _mingw_dxhelper.h │ │ ├── dinput.h │ │ └── xinput.h │ ├── tinycthread.c │ ├── tinycthread.h │ └── vulkan │ │ ├── vk_platform.h │ │ └── vulkan.h │ ├── examples │ ├── CMakeLists.txt │ ├── boing.c │ ├── gears.c │ ├── glfw.icns │ ├── glfw.ico │ ├── glfw.rc │ ├── heightmap.c │ ├── particles.c │ ├── simple.c │ ├── splitview.c │ └── wave.c │ ├── include │ └── GLFW │ │ ├── glfw3.h │ │ └── glfw3native.h │ ├── src │ ├── CMakeLists.txt │ ├── cocoa_init.m │ ├── cocoa_joystick.h │ ├── cocoa_joystick.m │ ├── cocoa_monitor.m │ ├── cocoa_platform.h │ ├── cocoa_time.c │ ├── cocoa_window.m │ ├── context.c │ ├── egl_context.c │ ├── egl_context.h │ ├── glfw3.pc.in │ ├── glfw3Config.cmake.in │ ├── glfw_config.h.in │ ├── glx_context.c │ ├── glx_context.h │ ├── init.c │ ├── input.c │ ├── internal.h │ ├── linux_joystick.c │ ├── linux_joystick.h │ ├── mir_init.c │ ├── mir_monitor.c │ ├── mir_platform.h │ ├── mir_window.c │ ├── monitor.c │ ├── nsgl_context.h │ ├── nsgl_context.m │ ├── posix_time.c │ ├── posix_time.h │ ├── posix_tls.c │ ├── posix_tls.h │ ├── vulkan.c │ ├── wgl_context.c │ ├── wgl_context.h │ ├── win32_init.c │ ├── win32_joystick.c │ ├── win32_joystick.h │ ├── win32_monitor.c │ ├── win32_platform.h │ ├── win32_time.c │ ├── win32_tls.c │ ├── win32_window.c │ ├── window.c │ ├── wl_init.c │ ├── wl_monitor.c │ ├── wl_platform.h │ ├── wl_window.c │ ├── x11_init.c │ ├── x11_monitor.c │ ├── x11_platform.h │ ├── x11_window.c │ ├── xkb_unicode.c │ └── xkb_unicode.h │ └── tests │ ├── CMakeLists.txt │ ├── clipboard.c │ ├── cursor.c │ ├── empty.c │ ├── events.c │ ├── gamma.c │ ├── glfwinfo.c │ ├── icon.c │ ├── iconify.c │ ├── joysticks.c │ ├── monitors.c │ ├── msaa.c │ ├── reopen.c │ ├── sharing.c │ ├── tearing.c │ ├── threads.c │ ├── timeout.c │ ├── title.c │ ├── vulkan.c │ └── windows.c ├── img └── fractal.gif └── src └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | **.bak 2 | **.mtl 3 | **.orig 4 | **/*.dll 5 | **/*.exe 6 | *.pyc 7 | .DS_Store 8 | /CMakeLists.txt 9 | OpenGL-tutorial_v* 10 | Thumbs.db 11 | bin-*/* 12 | build/* 13 | distrib/build_*/* 14 | makefile 15 | screenshot.bmp 16 | models/ 17 | 18 | src/out.bin 19 | docs/ -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake entry point 2 | cmake_minimum_required (VERSION 3.1) 3 | project (image_load_store_demo) 4 | 5 | find_package(OpenGL REQUIRED) 6 | 7 | # Compile external dependencies 8 | add_subdirectory (deps) 9 | 10 | set (CMAKE_CXX_STANDARD 11) 11 | 12 | include_directories( 13 | deps/glfw-3.2/include/GLFW/ 14 | deps/glad/include 15 | ) 16 | 17 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 18 | set(OPENGL_LIBRARY 19 | ${OPENGL_LIBRARY} 20 | -lGL -lGLU -lXrandr -lXext -lX11 -lrt 21 | ${CMAKE_DL_LIBS} 22 | ${GLFW_LIBRARIES} 23 | ) 24 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 25 | set(OPENGL_LIBRARY 26 | ${OPENGL_LIBRARY} 27 | ${CMAKE_DL_LIBS} 28 | ${GLFW_LIBRARIES} 29 | ) 30 | endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 31 | 32 | set(ALL_LIBS 33 | ${OPENGL_LIBRARY} 34 | glfw 35 | ) 36 | 37 | add_executable(image_load_store_demo 38 | src/main.cpp 39 | 40 | deps/glad/src/glad.c 41 | ) 42 | 43 | target_link_libraries(image_load_store_demo ${ALL_LIBS}) 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2016 Eric Arnebäck 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenGL Image load/store demo 2 | 3 | This is a simple demo that demonstrates how to use the image load/store 4 | feature of OpenGL 4. The image load/store feature allows you to arbitrarily 5 | write and read from textures in a shader. You can't arbitrarily write to 6 | a texture without this feature. 7 | 8 | ![Animated](img/fractal.gif) 9 | 10 | # Demo 11 | 12 | Open the file src/main.cpp for the demo source. 13 | The demo first renders a fractal, and then writes that 14 | fractal to a texture with image store. Then, in a second pass, a box 15 | filter blur is applied to this same texture, using image load/store. 16 | Finally, we display the texture. 17 | 18 | Note that this demo can also easily be imlemented using Framebuffer Objects. 19 | But with Framebuffer Objects you cannot write to arbitrary locations in a 20 | texture, though. 21 | 22 | ## Building 23 | 24 | The project uses CMake, and all dependencies are included, so you 25 | should use CMake to generate a "Visual Studio Solution"/makefile, 26 | and then use that to compile the program. 27 | -------------------------------------------------------------------------------- /deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ### GLFW ### 2 | 3 | add_subdirectory (glfw-3.2) 4 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/MacOSXBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLongVersionString 18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 19 | CFBundleName 20 | ${MACOSX_BUNDLE_BUNDLE_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 29 | CSResourcesFileMapped 30 | 31 | LSRequiresCarbon 32 | 33 | NSHumanReadableCopyright 34 | ${MACOSX_BUNDLE_COPYRIGHT} 35 | NSHighResolutionCapable 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/amd64-mingw32msvc.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win64 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc") 5 | SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++") 6 | SET(CMAKE_RC_COMPILER "amd64-mingw32msvc-windres") 7 | SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/i586-mingw32msvc.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i586-mingw32msvc-gcc") 5 | SET(CMAKE_CXX_COMPILER "i586-mingw32msvc-g++") 6 | SET(CMAKE_RC_COMPILER "i586-mingw32msvc-windres") 7 | SET(CMAKE_RANLIB "i586-mingw32msvc-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i586-mingw32msvc") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/i686-pc-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-pc-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "i686-pc-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "i686-pc-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-pc-mingw32-ranlib") 8 | 9 | #Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/opt/mingw/usr/i686-pc-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/modules/FindMir.cmake: -------------------------------------------------------------------------------- 1 | # Try to find Mir on a Unix system 2 | # 3 | # This will define: 4 | # 5 | # MIR_LIBRARIES - Link these to use Wayland 6 | # MIR_INCLUDE_DIR - Include directory for Wayland 7 | # 8 | # Copyright (c) 2014 Brandon Schaefer 9 | 10 | if (NOT WIN32) 11 | 12 | find_package (PkgConfig) 13 | pkg_check_modules (PKG_MIR QUIET mirclient) 14 | 15 | set (MIR_INCLUDE_DIR ${PKG_MIR_INCLUDE_DIRS}) 16 | set (MIR_LIBRARIES ${PKG_MIR_LIBRARIES}) 17 | 18 | endif () 19 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/modules/FindVulkan.cmake: -------------------------------------------------------------------------------- 1 | # Find Vulkan 2 | # 3 | # VULKAN_INCLUDE_DIR 4 | # VULKAN_LIBRARY 5 | # VULKAN_FOUND 6 | 7 | if (WIN32) 8 | find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS 9 | "$ENV{VULKAN_SDK}/Include" 10 | "$ENV{VK_SDK_PATH}/Include") 11 | if (CMAKE_CL_64) 12 | find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS 13 | "$ENV{VULKAN_SDK}/Bin" 14 | "$ENV{VK_SDK_PATH}/Bin") 15 | else() 16 | find_library(VULKAN_LIBRARY NAMES vulkan-1 HINTS 17 | "$ENV{VULKAN_SDK}/Bin32" 18 | "$ENV{VK_SDK_PATH}/Bin32") 19 | endif() 20 | else() 21 | find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS 22 | "$ENV{VULKAN_SDK}/include") 23 | find_library(VULKAN_LIBRARY NAMES vulkan HINTS 24 | "$ENV{VULKAN_SDK}/lib") 25 | endif() 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR) 29 | 30 | mark_as_advanced(VULKAN_INCLUDE_DIR VULKAN_LIBRARY) 31 | 32 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/modules/FindWaylandProtocols.cmake: -------------------------------------------------------------------------------- 1 | find_package(PkgConfig) 2 | 3 | pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION}) 4 | 5 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols 6 | OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR 7 | RESULT_VARIABLE _pkgconfig_failed) 8 | if (_pkgconfig_failed) 9 | message(FATAL_ERROR "Missing wayland-protocols pkgdatadir") 10 | endif() 11 | 12 | string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}") 13 | 14 | find_package_handle_standard_args(WaylandProtocols 15 | FOUND_VAR 16 | WaylandProtocols_FOUND 17 | REQUIRED_VARS 18 | WaylandProtocols_PKGDATADIR 19 | VERSION_VAR 20 | WaylandProtocols_VERSION 21 | HANDLE_COMPONENTS 22 | ) 23 | 24 | set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND}) 25 | set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR}) 26 | set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION}) 27 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/modules/FindXKBCommon.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find XKBCommon 2 | # Once done, this will define 3 | # 4 | # XKBCOMMON_FOUND - System has XKBCommon 5 | # XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories 6 | # XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon 7 | # XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon 8 | 9 | find_package(PkgConfig) 10 | pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon) 11 | set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER}) 12 | 13 | find_path(XKBCOMMON_INCLUDE_DIR 14 | NAMES xkbcommon/xkbcommon.h 15 | HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS} 16 | ) 17 | 18 | find_library(XKBCOMMON_LIBRARY 19 | NAMES xkbcommon 20 | HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS} 21 | ) 22 | 23 | set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) 24 | set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS}) 25 | set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(XKBCommon DEFAULT_MSG 29 | XKBCOMMON_LIBRARY 30 | XKBCOMMON_INCLUDE_DIR 31 | ) 32 | 33 | mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR) 34 | 35 | -------------------------------------------------------------------------------- /deps/glfw-3.2/CMake/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2016 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /deps/glfw-3.2/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 4 | endif() 5 | 6 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 7 | string(REGEX REPLACE "\n" ";" files "${files}") 8 | 9 | foreach (file ${files}) 10 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 11 | if (EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 13 | OUTPUT_VARIABLE rm_out 14 | RETURN_VALUE rm_retval) 15 | if (NOT "${rm_retval}" STREQUAL 0) 16 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 17 | endif() 18 | elseif (IS_SYMLINK "$ENV{DESTDIR}${file}") 19 | EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 20 | OUTPUT_VARIABLE rm_out 21 | RETURN_VALUE rm_retval) 22 | if (NOT "${rm_retval}" STREQUAL 0) 23 | message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"") 24 | endif() 25 | else() 26 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 27 | endif() 28 | endforeach() 29 | 30 | -------------------------------------------------------------------------------- /deps/glfw-3.2/deps/getopt.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, Kim Gräsman 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright notice, 7 | * this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright notice, 9 | * this list of conditions and the following disclaimer in the documentation 10 | * and/or other materials provided with the distribution. 11 | * * Neither the name of Kim Gräsman nor the names of contributors may be used 12 | * to endorse or promote products derived from this software without specific 13 | * prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT, 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "getopt.h" 28 | 29 | #include 30 | #include 31 | 32 | const int no_argument = 0; 33 | const int required_argument = 1; 34 | const int optional_argument = 2; 35 | 36 | char* optarg; 37 | int optopt; 38 | /* The variable optind [...] shall be initialized to 1 by the system. */ 39 | int optind = 1; 40 | int opterr; 41 | 42 | static char* optcursor = NULL; 43 | 44 | /* Implemented based on [1] and [2] for optional arguments. 45 | optopt is handled FreeBSD-style, per [3]. 46 | Other GNU and FreeBSD extensions are purely accidental. 47 | 48 | [1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html 49 | [2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html 50 | [3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE 51 | */ 52 | int getopt(int argc, char* const argv[], const char* optstring) { 53 | int optchar = -1; 54 | const char* optdecl = NULL; 55 | 56 | optarg = NULL; 57 | opterr = 0; 58 | optopt = 0; 59 | 60 | /* Unspecified, but we need it to avoid overrunning the argv bounds. */ 61 | if (optind >= argc) 62 | goto no_more_optchars; 63 | 64 | /* If, when getopt() is called argv[optind] is a null pointer, getopt() 65 | shall return -1 without changing optind. */ 66 | if (argv[optind] == NULL) 67 | goto no_more_optchars; 68 | 69 | /* If, when getopt() is called *argv[optind] is not the character '-', 70 | getopt() shall return -1 without changing optind. */ 71 | if (*argv[optind] != '-') 72 | goto no_more_optchars; 73 | 74 | /* If, when getopt() is called argv[optind] points to the string "-", 75 | getopt() shall return -1 without changing optind. */ 76 | if (strcmp(argv[optind], "-") == 0) 77 | goto no_more_optchars; 78 | 79 | /* If, when getopt() is called argv[optind] points to the string "--", 80 | getopt() shall return -1 after incrementing optind. */ 81 | if (strcmp(argv[optind], "--") == 0) { 82 | ++optind; 83 | goto no_more_optchars; 84 | } 85 | 86 | if (optcursor == NULL || *optcursor == '\0') 87 | optcursor = argv[optind] + 1; 88 | 89 | optchar = *optcursor; 90 | 91 | /* FreeBSD: The variable optopt saves the last known option character 92 | returned by getopt(). */ 93 | optopt = optchar; 94 | 95 | /* The getopt() function shall return the next option character (if one is 96 | found) from argv that matches a character in optstring, if there is 97 | one that matches. */ 98 | optdecl = strchr(optstring, optchar); 99 | if (optdecl) { 100 | /* [I]f a character is followed by a colon, the option takes an 101 | argument. */ 102 | if (optdecl[1] == ':') { 103 | optarg = ++optcursor; 104 | if (*optarg == '\0') { 105 | /* GNU extension: Two colons mean an option takes an 106 | optional arg; if there is text in the current argv-element 107 | (i.e., in the same word as the option name itself, for example, 108 | "-oarg"), then it is returned in optarg, otherwise optarg is set 109 | to zero. */ 110 | if (optdecl[2] != ':') { 111 | /* If the option was the last character in the string pointed to by 112 | an element of argv, then optarg shall contain the next element 113 | of argv, and optind shall be incremented by 2. If the resulting 114 | value of optind is greater than argc, this indicates a missing 115 | option-argument, and getopt() shall return an error indication. 116 | 117 | Otherwise, optarg shall point to the string following the 118 | option character in that element of argv, and optind shall be 119 | incremented by 1. 120 | */ 121 | if (++optind < argc) { 122 | optarg = argv[optind]; 123 | } else { 124 | /* If it detects a missing option-argument, it shall return the 125 | colon character ( ':' ) if the first character of optstring 126 | was a colon, or a question-mark character ( '?' ) otherwise. 127 | */ 128 | optarg = NULL; 129 | optchar = (optstring[0] == ':') ? ':' : '?'; 130 | } 131 | } else { 132 | optarg = NULL; 133 | } 134 | } 135 | 136 | optcursor = NULL; 137 | } 138 | } else { 139 | /* If getopt() encounters an option character that is not contained in 140 | optstring, it shall return the question-mark ( '?' ) character. */ 141 | optchar = '?'; 142 | } 143 | 144 | if (optcursor == NULL || *++optcursor == '\0') 145 | ++optind; 146 | 147 | return optchar; 148 | 149 | no_more_optchars: 150 | optcursor = NULL; 151 | return -1; 152 | } 153 | 154 | /* Implementation based on [1]. 155 | 156 | [1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html 157 | */ 158 | int getopt_long(int argc, char* const argv[], const char* optstring, 159 | const struct option* longopts, int* longindex) { 160 | const struct option* o = longopts; 161 | const struct option* match = NULL; 162 | int num_matches = 0; 163 | size_t argument_name_length = 0; 164 | const char* current_argument = NULL; 165 | int retval = -1; 166 | 167 | optarg = NULL; 168 | optopt = 0; 169 | 170 | if (optind >= argc) 171 | return -1; 172 | 173 | if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0) 174 | return getopt(argc, argv, optstring); 175 | 176 | /* It's an option; starts with -- and is longer than two chars. */ 177 | current_argument = argv[optind] + 2; 178 | argument_name_length = strcspn(current_argument, "="); 179 | for (; o->name; ++o) { 180 | if (strncmp(o->name, current_argument, argument_name_length) == 0) { 181 | match = o; 182 | ++num_matches; 183 | } 184 | } 185 | 186 | if (num_matches == 1) { 187 | /* If longindex is not NULL, it points to a variable which is set to the 188 | index of the long option relative to longopts. */ 189 | if (longindex) 190 | *longindex = (int) (match - longopts); 191 | 192 | /* If flag is NULL, then getopt_long() shall return val. 193 | Otherwise, getopt_long() returns 0, and flag shall point to a variable 194 | which shall be set to val if the option is found, but left unchanged if 195 | the option is not found. */ 196 | if (match->flag) 197 | *(match->flag) = match->val; 198 | 199 | retval = match->flag ? 0 : match->val; 200 | 201 | if (match->has_arg != no_argument) { 202 | optarg = strchr(argv[optind], '='); 203 | if (optarg != NULL) 204 | ++optarg; 205 | 206 | if (match->has_arg == required_argument) { 207 | /* Only scan the next argv for required arguments. Behavior is not 208 | specified, but has been observed with Ubuntu and Mac OSX. */ 209 | if (optarg == NULL && ++optind < argc) { 210 | optarg = argv[optind]; 211 | } 212 | 213 | if (optarg == NULL) 214 | retval = ':'; 215 | } 216 | } else if (strchr(argv[optind], '=')) { 217 | /* An argument was provided to a non-argument option. 218 | I haven't seen this specified explicitly, but both GNU and BSD-based 219 | implementations show this behavior. 220 | */ 221 | retval = '?'; 222 | } 223 | } else { 224 | /* Unknown option or ambiguous match. */ 225 | retval = '?'; 226 | } 227 | 228 | ++optind; 229 | return retval; 230 | } 231 | -------------------------------------------------------------------------------- /deps/glfw-3.2/deps/getopt.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, Kim Gräsman 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright notice, 7 | * this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright notice, 9 | * this list of conditions and the following disclaimer in the documentation 10 | * and/or other materials provided with the distribution. 11 | * * Neither the name of Kim Gräsman nor the names of contributors may be used 12 | * to endorse or promote products derived from this software without specific 13 | * prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT, 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef INCLUDED_GETOPT_PORT_H 28 | #define INCLUDED_GETOPT_PORT_H 29 | 30 | #if defined(__cplusplus) 31 | extern "C" { 32 | #endif 33 | 34 | extern const int no_argument; 35 | extern const int required_argument; 36 | extern const int optional_argument; 37 | 38 | extern char* optarg; 39 | extern int optind, opterr, optopt; 40 | 41 | struct option { 42 | const char* name; 43 | int has_arg; 44 | int* flag; 45 | int val; 46 | }; 47 | 48 | int getopt(int argc, char* const argv[], const char* optstring); 49 | 50 | int getopt_long(int argc, char* const argv[], 51 | const char* optstring, const struct option* longopts, int* longindex); 52 | 53 | #if defined(__cplusplus) 54 | } 55 | #endif 56 | 57 | #endif // INCLUDED_GETOPT_PORT_H 58 | -------------------------------------------------------------------------------- /deps/glfw-3.2/deps/mingw/_mingw_dxhelper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the mingw-w64 runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) 8 | #define NONAMELESSUNION 1 9 | #endif 10 | #if defined(NONAMELESSSTRUCT) && \ 11 | !defined(NONAMELESSUNION) 12 | #define NONAMELESSUNION 1 13 | #endif 14 | #if defined(NONAMELESSUNION) && \ 15 | !defined(NONAMELESSSTRUCT) 16 | #define NONAMELESSSTRUCT 1 17 | #endif 18 | #if !defined(__GNU_EXTENSION) 19 | #if defined(__GNUC__) || defined(__GNUG__) 20 | #define __GNU_EXTENSION __extension__ 21 | #else 22 | #define __GNU_EXTENSION 23 | #endif 24 | #endif /* __extension__ */ 25 | 26 | #ifndef __ANONYMOUS_DEFINED 27 | #define __ANONYMOUS_DEFINED 28 | #if defined(__GNUC__) || defined(__GNUG__) 29 | #define _ANONYMOUS_UNION __extension__ 30 | #define _ANONYMOUS_STRUCT __extension__ 31 | #else 32 | #define _ANONYMOUS_UNION 33 | #define _ANONYMOUS_STRUCT 34 | #endif 35 | #ifndef NONAMELESSUNION 36 | #define _UNION_NAME(x) 37 | #define _STRUCT_NAME(x) 38 | #else /* NONAMELESSUNION */ 39 | #define _UNION_NAME(x) x 40 | #define _STRUCT_NAME(x) x 41 | #endif 42 | #endif /* __ANONYMOUS_DEFINED */ 43 | 44 | #ifndef DUMMYUNIONNAME 45 | # ifdef NONAMELESSUNION 46 | # define DUMMYUNIONNAME u 47 | # define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ 48 | # define DUMMYUNIONNAME2 u2 49 | # define DUMMYUNIONNAME3 u3 50 | # define DUMMYUNIONNAME4 u4 51 | # define DUMMYUNIONNAME5 u5 52 | # define DUMMYUNIONNAME6 u6 53 | # define DUMMYUNIONNAME7 u7 54 | # define DUMMYUNIONNAME8 u8 55 | # define DUMMYUNIONNAME9 u9 56 | # else /* NONAMELESSUNION */ 57 | # define DUMMYUNIONNAME 58 | # define DUMMYUNIONNAME1 /* Wine uses this variant */ 59 | # define DUMMYUNIONNAME2 60 | # define DUMMYUNIONNAME3 61 | # define DUMMYUNIONNAME4 62 | # define DUMMYUNIONNAME5 63 | # define DUMMYUNIONNAME6 64 | # define DUMMYUNIONNAME7 65 | # define DUMMYUNIONNAME8 66 | # define DUMMYUNIONNAME9 67 | # endif 68 | #endif /* DUMMYUNIONNAME */ 69 | 70 | #if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */ 71 | # ifdef NONAMELESSUNION 72 | # define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ 73 | # else 74 | # define DUMMYUNIONNAME1 /* Wine uses this variant */ 75 | # endif 76 | #endif /* DUMMYUNIONNAME1 */ 77 | 78 | #ifndef DUMMYSTRUCTNAME 79 | # ifdef NONAMELESSUNION 80 | # define DUMMYSTRUCTNAME s 81 | # define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */ 82 | # define DUMMYSTRUCTNAME2 s2 83 | # define DUMMYSTRUCTNAME3 s3 84 | # define DUMMYSTRUCTNAME4 s4 85 | # define DUMMYSTRUCTNAME5 s5 86 | # else 87 | # define DUMMYSTRUCTNAME 88 | # define DUMMYSTRUCTNAME1 /* Wine uses this variant */ 89 | # define DUMMYSTRUCTNAME2 90 | # define DUMMYSTRUCTNAME3 91 | # define DUMMYSTRUCTNAME4 92 | # define DUMMYSTRUCTNAME5 93 | # endif 94 | #endif /* DUMMYSTRUCTNAME */ 95 | 96 | /* These are for compatibility with the Wine source tree */ 97 | 98 | #ifndef WINELIB_NAME_AW 99 | # ifdef __MINGW_NAME_AW 100 | # define WINELIB_NAME_AW __MINGW_NAME_AW 101 | # else 102 | # ifdef UNICODE 103 | # define WINELIB_NAME_AW(func) func##W 104 | # else 105 | # define WINELIB_NAME_AW(func) func##A 106 | # endif 107 | # endif 108 | #endif /* WINELIB_NAME_AW */ 109 | 110 | #ifndef DECL_WINELIB_TYPE_AW 111 | # ifdef __MINGW_TYPEDEF_AW 112 | # define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW 113 | # else 114 | # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; 115 | # endif 116 | #endif /* DECL_WINELIB_TYPE_AW */ 117 | 118 | -------------------------------------------------------------------------------- /deps/glfw-3.2/deps/mingw/xinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The Wine project - Xinput Joystick Library 3 | * Copyright 2008 Andrew Fenn 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #ifndef __WINE_XINPUT_H 21 | #define __WINE_XINPUT_H 22 | 23 | #include 24 | 25 | /* 26 | * Bitmasks for the joysticks buttons, determines what has 27 | * been pressed on the joystick, these need to be mapped 28 | * to whatever device you're using instead of an xbox 360 29 | * joystick 30 | */ 31 | 32 | #define XINPUT_GAMEPAD_DPAD_UP 0x0001 33 | #define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 34 | #define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 35 | #define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 36 | #define XINPUT_GAMEPAD_START 0x0010 37 | #define XINPUT_GAMEPAD_BACK 0x0020 38 | #define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 39 | #define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 40 | #define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 41 | #define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 42 | #define XINPUT_GAMEPAD_A 0x1000 43 | #define XINPUT_GAMEPAD_B 0x2000 44 | #define XINPUT_GAMEPAD_X 0x4000 45 | #define XINPUT_GAMEPAD_Y 0x8000 46 | 47 | /* 48 | * Defines the flags used to determine if the user is pushing 49 | * down on a button, not holding a button, etc 50 | */ 51 | 52 | #define XINPUT_KEYSTROKE_KEYDOWN 0x0001 53 | #define XINPUT_KEYSTROKE_KEYUP 0x0002 54 | #define XINPUT_KEYSTROKE_REPEAT 0x0004 55 | 56 | /* 57 | * Defines the codes which are returned by XInputGetKeystroke 58 | */ 59 | 60 | #define VK_PAD_A 0x5800 61 | #define VK_PAD_B 0x5801 62 | #define VK_PAD_X 0x5802 63 | #define VK_PAD_Y 0x5803 64 | #define VK_PAD_RSHOULDER 0x5804 65 | #define VK_PAD_LSHOULDER 0x5805 66 | #define VK_PAD_LTRIGGER 0x5806 67 | #define VK_PAD_RTRIGGER 0x5807 68 | #define VK_PAD_DPAD_UP 0x5810 69 | #define VK_PAD_DPAD_DOWN 0x5811 70 | #define VK_PAD_DPAD_LEFT 0x5812 71 | #define VK_PAD_DPAD_RIGHT 0x5813 72 | #define VK_PAD_START 0x5814 73 | #define VK_PAD_BACK 0x5815 74 | #define VK_PAD_LTHUMB_PRESS 0x5816 75 | #define VK_PAD_RTHUMB_PRESS 0x5817 76 | #define VK_PAD_LTHUMB_UP 0x5820 77 | #define VK_PAD_LTHUMB_DOWN 0x5821 78 | #define VK_PAD_LTHUMB_RIGHT 0x5822 79 | #define VK_PAD_LTHUMB_LEFT 0x5823 80 | #define VK_PAD_LTHUMB_UPLEFT 0x5824 81 | #define VK_PAD_LTHUMB_UPRIGHT 0x5825 82 | #define VK_PAD_LTHUMB_DOWNRIGHT 0x5826 83 | #define VK_PAD_LTHUMB_DOWNLEFT 0x5827 84 | #define VK_PAD_RTHUMB_UP 0x5830 85 | #define VK_PAD_RTHUMB_DOWN 0x5831 86 | #define VK_PAD_RTHUMB_RIGHT 0x5832 87 | #define VK_PAD_RTHUMB_LEFT 0x5833 88 | #define VK_PAD_RTHUMB_UPLEFT 0x5834 89 | #define VK_PAD_RTHUMB_UPRIGHT 0x5835 90 | #define VK_PAD_RTHUMB_DOWNRIGHT 0x5836 91 | #define VK_PAD_RTHUMB_DOWNLEFT 0x5837 92 | 93 | /* 94 | * Deadzones are for analogue joystick controls on the joypad 95 | * which determine when input should be assumed to be in the 96 | * middle of the pad. This is a threshold to stop a joypad 97 | * controlling the game when the player isn't touching the 98 | * controls. 99 | */ 100 | 101 | #define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 102 | #define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 103 | #define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 104 | 105 | 106 | /* 107 | * Defines what type of abilities the type of joystick has 108 | * DEVTYPE_GAMEPAD is available for all joysticks, however 109 | * there may be more specific identifiers for other joysticks 110 | * which are being used. 111 | */ 112 | 113 | #define XINPUT_DEVTYPE_GAMEPAD 0x01 114 | #define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 115 | #define XINPUT_DEVSUBTYPE_WHEEL 0x02 116 | #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 117 | #define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04 118 | #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 119 | #define XINPUT_DEVSUBTYPE_GUITAR 0x06 120 | #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 121 | 122 | /* 123 | * These are used with the XInputGetCapabilities function to 124 | * determine the abilities to the joystick which has been 125 | * plugged in. 126 | */ 127 | 128 | #define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 129 | #define XINPUT_FLAG_GAMEPAD 0x00000001 130 | 131 | /* 132 | * Defines the status of the battery if one is used in the 133 | * attached joystick. The first two define if the joystick 134 | * supports a battery. Disconnected means that the joystick 135 | * isn't connected. Wired shows that the joystick is a wired 136 | * joystick. 137 | */ 138 | 139 | #define BATTERY_DEVTYPE_GAMEPAD 0x00 140 | #define BATTERY_DEVTYPE_HEADSET 0x01 141 | #define BATTERY_TYPE_DISCONNECTED 0x00 142 | #define BATTERY_TYPE_WIRED 0x01 143 | #define BATTERY_TYPE_ALKALINE 0x02 144 | #define BATTERY_TYPE_NIMH 0x03 145 | #define BATTERY_TYPE_UNKNOWN 0xFF 146 | #define BATTERY_LEVEL_EMPTY 0x00 147 | #define BATTERY_LEVEL_LOW 0x01 148 | #define BATTERY_LEVEL_MEDIUM 0x02 149 | #define BATTERY_LEVEL_FULL 0x03 150 | 151 | /* 152 | * How many joysticks can be used with this library. Games that 153 | * use the xinput library will not go over this number. 154 | */ 155 | 156 | #define XUSER_MAX_COUNT 4 157 | #define XUSER_INDEX_ANY 0x000000FF 158 | 159 | /* 160 | * Defines the structure of an xbox 360 joystick. 161 | */ 162 | 163 | typedef struct _XINPUT_GAMEPAD { 164 | WORD wButtons; 165 | BYTE bLeftTrigger; 166 | BYTE bRightTrigger; 167 | SHORT sThumbLX; 168 | SHORT sThumbLY; 169 | SHORT sThumbRX; 170 | SHORT sThumbRY; 171 | } XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; 172 | 173 | typedef struct _XINPUT_STATE { 174 | DWORD dwPacketNumber; 175 | XINPUT_GAMEPAD Gamepad; 176 | } XINPUT_STATE, *PXINPUT_STATE; 177 | 178 | /* 179 | * Defines the structure of how much vibration is set on both the 180 | * right and left motors in a joystick. If you're not using a 360 181 | * joystick you will have to map these to your device. 182 | */ 183 | 184 | typedef struct _XINPUT_VIBRATION { 185 | WORD wLeftMotorSpeed; 186 | WORD wRightMotorSpeed; 187 | } XINPUT_VIBRATION, *PXINPUT_VIBRATION; 188 | 189 | /* 190 | * Defines the structure for what kind of abilities the joystick has 191 | * such abilities are things such as if the joystick has the ability 192 | * to send and receive audio, if the joystick is in fact a driving 193 | * wheel or perhaps if the joystick is some kind of dance pad or 194 | * guitar. 195 | */ 196 | 197 | typedef struct _XINPUT_CAPABILITIES { 198 | BYTE Type; 199 | BYTE SubType; 200 | WORD Flags; 201 | XINPUT_GAMEPAD Gamepad; 202 | XINPUT_VIBRATION Vibration; 203 | } XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; 204 | 205 | /* 206 | * Defines the structure for a joystick input event which is 207 | * retrieved using the function XInputGetKeystroke 208 | */ 209 | typedef struct _XINPUT_KEYSTROKE { 210 | WORD VirtualKey; 211 | WCHAR Unicode; 212 | WORD Flags; 213 | BYTE UserIndex; 214 | BYTE HidCode; 215 | } XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE; 216 | 217 | typedef struct _XINPUT_BATTERY_INFORMATION 218 | { 219 | BYTE BatteryType; 220 | BYTE BatteryLevel; 221 | } XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION; 222 | 223 | #ifdef __cplusplus 224 | extern "C" { 225 | #endif 226 | 227 | void WINAPI XInputEnable(WINBOOL); 228 | DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*); 229 | DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*); 230 | DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE); 231 | DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*); 232 | DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*); 233 | DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*); 234 | 235 | #ifdef __cplusplus 236 | } 237 | #endif 238 | 239 | #endif /* __WINE_XINPUT_H */ 240 | -------------------------------------------------------------------------------- /deps/glfw-3.2/deps/vulkan/vk_platform.h: -------------------------------------------------------------------------------- 1 | // 2 | // File: vk_platform.h 3 | // 4 | /* 5 | ** Copyright (c) 2014-2015 The Khronos Group Inc. 6 | ** 7 | ** Licensed under the Apache License, Version 2.0 (the "License"); 8 | ** you may not use this file except in compliance with the License. 9 | ** You may obtain a copy of the License at 10 | ** 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** 13 | ** Unless required by applicable law or agreed to in writing, software 14 | ** distributed under the License is distributed on an "AS IS" BASIS, 15 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | ** See the License for the specific language governing permissions and 17 | ** limitations under the License. 18 | */ 19 | 20 | 21 | #ifndef VK_PLATFORM_H_ 22 | #define VK_PLATFORM_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif // __cplusplus 28 | 29 | /* 30 | *************************************************************************************************** 31 | * Platform-specific directives and type declarations 32 | *************************************************************************************************** 33 | */ 34 | 35 | /* Platform-specific calling convention macros. 36 | * 37 | * Platforms should define these so that Vulkan clients call Vulkan commands 38 | * with the same calling conventions that the Vulkan implementation expects. 39 | * 40 | * VKAPI_ATTR - Placed before the return type in function declarations. 41 | * Useful for C++11 and GCC/Clang-style function attribute syntax. 42 | * VKAPI_CALL - Placed after the return type in function declarations. 43 | * Useful for MSVC-style calling convention syntax. 44 | * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. 45 | * 46 | * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); 47 | * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); 48 | */ 49 | #if defined(_WIN32) 50 | // On Windows, Vulkan commands use the stdcall convention 51 | #define VKAPI_ATTR 52 | #define VKAPI_CALL __stdcall 53 | #define VKAPI_PTR VKAPI_CALL 54 | #elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) 55 | // Android does not support Vulkan in native code using the "armeabi" ABI. 56 | #error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs" 57 | #elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__) 58 | // On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling 59 | // convention, even if the application's native code is compiled with the 60 | // armeabi-v7a calling convention. 61 | #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) 62 | #define VKAPI_CALL 63 | #define VKAPI_PTR VKAPI_ATTR 64 | #else 65 | // On other platforms, use the default calling convention 66 | #define VKAPI_ATTR 67 | #define VKAPI_CALL 68 | #define VKAPI_PTR 69 | #endif 70 | 71 | #include 72 | 73 | #if !defined(VK_NO_STDINT_H) 74 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 75 | typedef signed __int8 int8_t; 76 | typedef unsigned __int8 uint8_t; 77 | typedef signed __int16 int16_t; 78 | typedef unsigned __int16 uint16_t; 79 | typedef signed __int32 int32_t; 80 | typedef unsigned __int32 uint32_t; 81 | typedef signed __int64 int64_t; 82 | typedef unsigned __int64 uint64_t; 83 | #else 84 | #include 85 | #endif 86 | #endif // !defined(VK_NO_STDINT_H) 87 | 88 | #ifdef __cplusplus 89 | } // extern "C" 90 | #endif // __cplusplus 91 | 92 | // Platform-specific headers required by platform window system extensions. 93 | // These are enabled prior to #including "vulkan.h". The same enable then 94 | // controls inclusion of the extension interfaces in vulkan.h. 95 | 96 | #ifdef VK_USE_PLATFORM_ANDROID_KHR 97 | #include 98 | #endif 99 | 100 | #ifdef VK_USE_PLATFORM_MIR_KHR 101 | #include 102 | #endif 103 | 104 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR 105 | #include 106 | #endif 107 | 108 | #ifdef VK_USE_PLATFORM_WIN32_KHR 109 | #include 110 | #endif 111 | 112 | #ifdef VK_USE_PLATFORM_XLIB_KHR 113 | #include 114 | #endif 115 | 116 | #ifdef VK_USE_PLATFORM_XCB_KHR 117 | #include 118 | #endif 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /deps/glfw-3.2/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw) 3 | 4 | include_directories(${glfw_INCLUDE_DIRS}) 5 | 6 | if (BUILD_SHARED_LIBS) 7 | link_libraries("${MATH_LIBRARY}") 8 | endif() 9 | 10 | if (MSVC) 11 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 12 | endif() 13 | 14 | include_directories("${GLFW_SOURCE_DIR}/deps") 15 | 16 | if (WIN32) 17 | set(ICON glfw.rc) 18 | elseif (APPLE) 19 | set(ICON glfw.icns) 20 | set_source_files_properties(glfw.icns PROPERTIES 21 | MAXOSX_PACKAGE_LOCATION "Resources") 22 | endif() 23 | 24 | set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h" 25 | "${GLFW_SOURCE_DIR}/deps/glad.c") 26 | set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" 27 | "${GLFW_SOURCE_DIR}/deps/getopt.c") 28 | set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" 29 | "${GLFW_SOURCE_DIR}/deps/tinycthread.c") 30 | 31 | add_executable(boing WIN32 MACOSX_BUNDLE boing.c ${ICON} ${GLAD}) 32 | add_executable(gears WIN32 MACOSX_BUNDLE gears.c ${ICON} ${GLAD}) 33 | add_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${ICON} ${GLAD}) 34 | add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD}) 35 | add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD}) 36 | add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD}) 37 | add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD}) 38 | 39 | target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") 40 | 41 | set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave) 42 | 43 | set_target_properties(${WINDOWS_BINARIES} PROPERTIES FOLDER "GLFW3/Examples") 44 | 45 | if (MSVC) 46 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 47 | set_target_properties(${WINDOWS_BINARIES} PROPERTIES 48 | LINK_FLAGS "/ENTRY:mainCRTStartup") 49 | endif() 50 | 51 | if (APPLE) 52 | set_target_properties(boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing") 53 | set_target_properties(gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears") 54 | set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap") 55 | set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") 56 | set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") 57 | set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") 58 | set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") 59 | 60 | set_target_properties(${WINDOWS_BINARIES} PROPERTIES 61 | RESOURCE glfw.icns 62 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 63 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} 64 | MACOSX_BUNDLE_ICON_FILE glfw.icns 65 | MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") 66 | endif() 67 | 68 | -------------------------------------------------------------------------------- /deps/glfw-3.2/examples/glfw.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erkaman/image-load-store-demo/ed20d40b6f9ec63aeb079e1524be3139a5930c71/deps/glfw-3.2/examples/glfw.icns -------------------------------------------------------------------------------- /deps/glfw-3.2/examples/glfw.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erkaman/image-load-store-demo/ed20d40b6f9ec63aeb079e1524be3139a5930c71/deps/glfw-3.2/examples/glfw.ico -------------------------------------------------------------------------------- /deps/glfw-3.2/examples/glfw.rc: -------------------------------------------------------------------------------- 1 | 2 | GLFW_ICON ICON "glfw.ico" 3 | 4 | -------------------------------------------------------------------------------- /deps/glfw-3.2/examples/simple.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Simple GLFW example 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | //! [code] 26 | 27 | #include 28 | #include 29 | 30 | #include "linmath.h" 31 | 32 | #include 33 | #include 34 | 35 | static const struct 36 | { 37 | float x, y; 38 | float r, g, b; 39 | } vertices[3] = 40 | { 41 | { -0.6f, -0.4f, 1.f, 0.f, 0.f }, 42 | { 0.6f, -0.4f, 0.f, 1.f, 0.f }, 43 | { 0.f, 0.6f, 0.f, 0.f, 1.f } 44 | }; 45 | 46 | static const char* vertex_shader_text = 47 | "uniform mat4 MVP;\n" 48 | "attribute vec3 vCol;\n" 49 | "attribute vec2 vPos;\n" 50 | "varying vec3 color;\n" 51 | "void main()\n" 52 | "{\n" 53 | " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" 54 | " color = vCol;\n" 55 | "}\n"; 56 | 57 | static const char* fragment_shader_text = 58 | "varying vec3 color;\n" 59 | "void main()\n" 60 | "{\n" 61 | " gl_FragColor = vec4(color, 1.0);\n" 62 | "}\n"; 63 | 64 | static void error_callback(int error, const char* description) 65 | { 66 | fprintf(stderr, "Error: %s\n", description); 67 | } 68 | 69 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 70 | { 71 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 72 | glfwSetWindowShouldClose(window, GLFW_TRUE); 73 | } 74 | 75 | int main(void) 76 | { 77 | GLFWwindow* window; 78 | GLuint vertex_buffer, vertex_shader, fragment_shader, program; 79 | GLint mvp_location, vpos_location, vcol_location; 80 | 81 | glfwSetErrorCallback(error_callback); 82 | 83 | if (!glfwInit()) 84 | exit(EXIT_FAILURE); 85 | 86 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); 87 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); 88 | 89 | window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); 90 | if (!window) 91 | { 92 | glfwTerminate(); 93 | exit(EXIT_FAILURE); 94 | } 95 | 96 | glfwSetKeyCallback(window, key_callback); 97 | 98 | glfwMakeContextCurrent(window); 99 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 100 | glfwSwapInterval(1); 101 | 102 | // NOTE: OpenGL error checks have been omitted for brevity 103 | 104 | glGenBuffers(1, &vertex_buffer); 105 | glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); 106 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); 107 | 108 | vertex_shader = glCreateShader(GL_VERTEX_SHADER); 109 | glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL); 110 | glCompileShader(vertex_shader); 111 | 112 | fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); 113 | glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL); 114 | glCompileShader(fragment_shader); 115 | 116 | program = glCreateProgram(); 117 | glAttachShader(program, vertex_shader); 118 | glAttachShader(program, fragment_shader); 119 | glLinkProgram(program); 120 | 121 | mvp_location = glGetUniformLocation(program, "MVP"); 122 | vpos_location = glGetAttribLocation(program, "vPos"); 123 | vcol_location = glGetAttribLocation(program, "vCol"); 124 | 125 | glEnableVertexAttribArray(vpos_location); 126 | glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, 127 | sizeof(float) * 5, (void*) 0); 128 | glEnableVertexAttribArray(vcol_location); 129 | glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE, 130 | sizeof(float) * 5, (void*) (sizeof(float) * 2)); 131 | 132 | while (!glfwWindowShouldClose(window)) 133 | { 134 | float ratio; 135 | int width, height; 136 | mat4x4 m, p, mvp; 137 | 138 | glfwGetFramebufferSize(window, &width, &height); 139 | ratio = width / (float) height; 140 | 141 | glViewport(0, 0, width, height); 142 | glClear(GL_COLOR_BUFFER_BIT); 143 | 144 | mat4x4_identity(m); 145 | mat4x4_rotate_Z(m, m, (float) glfwGetTime()); 146 | mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f); 147 | mat4x4_mul(mvp, p, m); 148 | 149 | glUseProgram(program); 150 | glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); 151 | glDrawArrays(GL_TRIANGLES, 0, 3); 152 | 153 | glfwSwapBuffers(window); 154 | glfwPollEvents(); 155 | } 156 | 157 | glfwDestroyWindow(window); 158 | 159 | glfwTerminate(); 160 | exit(EXIT_SUCCESS); 161 | } 162 | 163 | //! [code] 164 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(common_HEADERS internal.h 3 | "${GLFW_BINARY_DIR}/src/glfw_config.h" 4 | "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" 5 | "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h") 6 | set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c) 7 | 8 | if (_GLFW_COCOA) 9 | set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h 10 | posix_tls.h nsgl_context.h) 11 | set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m 12 | cocoa_monitor.m cocoa_window.m cocoa_time.c posix_tls.c 13 | nsgl_context.m) 14 | elseif (_GLFW_WIN32) 15 | set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h 16 | wgl_context.h egl_context.h) 17 | set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_joystick.c 18 | win32_monitor.c win32_time.c win32_tls.c win32_window.c 19 | wgl_context.c egl_context.c) 20 | elseif (_GLFW_X11) 21 | set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h 22 | linux_joystick.h posix_time.h posix_tls.h glx_context.h 23 | egl_context.h) 24 | set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c 25 | xkb_unicode.c linux_joystick.c posix_time.c posix_tls.c 26 | glx_context.c egl_context.c) 27 | elseif (_GLFW_WAYLAND) 28 | set(glfw_HEADERS ${common_HEADERS} wl_platform.h linux_joystick.h 29 | posix_time.h posix_tls.h xkb_unicode.h egl_context.h) 30 | set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c 31 | linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c 32 | egl_context.c) 33 | 34 | ecm_add_wayland_client_protocol(glfw_SOURCES 35 | PROTOCOL 36 | ${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml 37 | BASENAME relative-pointer-unstable-v1) 38 | ecm_add_wayland_client_protocol(glfw_SOURCES 39 | PROTOCOL 40 | ${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml 41 | BASENAME pointer-constraints-unstable-v1) 42 | elseif (_GLFW_MIR) 43 | set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h 44 | posix_time.h posix_tls.h xkb_unicode.h egl_context.h) 45 | set(glfw_SOURCES ${common_SOURCES} mir_init.c mir_monitor.c mir_window.c 46 | linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c 47 | egl_context.c) 48 | endif() 49 | 50 | if (APPLE) 51 | # For some reason, CMake doesn't know about .m 52 | set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) 53 | endif() 54 | 55 | add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) 56 | set_target_properties(glfw PROPERTIES 57 | OUTPUT_NAME ${GLFW_LIB_NAME} 58 | VERSION ${GLFW_VERSION} 59 | SOVERSION ${GLFW_VERSION_MAJOR} 60 | POSITION_INDEPENDENT_CODE ON 61 | FOLDER "GLFW3") 62 | 63 | target_compile_definitions(glfw PRIVATE -D_GLFW_USE_CONFIG_H) 64 | target_include_directories(glfw PUBLIC 65 | $ 66 | $/include>) 67 | target_include_directories(glfw PRIVATE 68 | "${GLFW_SOURCE_DIR}/src" 69 | "${GLFW_BINARY_DIR}/src" 70 | ${glfw_INCLUDE_DIRS}) 71 | 72 | # HACK: When building on MinGW, WINVER and UNICODE need to be defined before 73 | # the inclusion of stddef.h (by glfw3.h), which is itself included before 74 | # win32_platform.h. We define them here until a saner solution can be found 75 | # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. 76 | target_compile_definitions(glfw PRIVATE 77 | "$<$:UNICODE;WINVER=0x0501>") 78 | 79 | # Enable a reasonable set of warnings (no, -Wextra is not reasonable) 80 | target_compile_options(glfw PRIVATE 81 | "$<$:-Wall>" 82 | "$<$:-Wall>") 83 | 84 | if (BUILD_SHARED_LIBS) 85 | if (WIN32) 86 | if (MINGW) 87 | # Remove the lib prefix on the DLL (but not the import library 88 | set_target_properties(glfw PROPERTIES PREFIX "") 89 | 90 | # Add a suffix to the import library to avoid naming conflicts 91 | set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a") 92 | else() 93 | # Add a suffix to the import library to avoid naming conflicts 94 | set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") 95 | endif() 96 | elseif (APPLE) 97 | # Add -fno-common to work around a bug in Apple's GCC 98 | target_compile_options(glfw PRIVATE "-fno-common") 99 | 100 | set_target_properties(glfw PROPERTIES 101 | INSTALL_NAME_DIR "lib${LIB_SUFFIX}") 102 | elseif (UNIX) 103 | # Hide symbols not explicitly tagged for export from the shared library 104 | target_compile_options(glfw PRIVATE "-fvisibility=hidden") 105 | endif() 106 | 107 | target_compile_definitions(glfw INTERFACE -DGLFW_DLL) 108 | target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) 109 | else() 110 | target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) 111 | endif() 112 | 113 | if (MSVC) 114 | target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) 115 | endif() 116 | 117 | if (GLFW_INSTALL) 118 | install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}) 119 | endif() 120 | 121 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_cocoa_joystick_h_ 28 | #define _glfw3_cocoa_joystick_h_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWjoystickNS ns_js 36 | 37 | 38 | // Cocoa-specific per-joystick data 39 | // 40 | typedef struct _GLFWjoydeviceNS 41 | { 42 | GLFWbool present; 43 | char name[256]; 44 | 45 | IOHIDDeviceRef deviceRef; 46 | 47 | CFMutableArrayRef axisElements; 48 | CFMutableArrayRef buttonElements; 49 | CFMutableArrayRef hatElements; 50 | 51 | float* axes; 52 | unsigned char* buttons; 53 | } _GLFWjoydeviceNS; 54 | 55 | // Cocoa-specific joystick API data 56 | // 57 | typedef struct _GLFWjoystickNS 58 | { 59 | _GLFWjoydeviceNS js[GLFW_JOYSTICK_LAST + 1]; 60 | 61 | IOHIDManagerRef managerRef; 62 | } _GLFWjoystickNS; 63 | 64 | void _glfwInitJoysticksNS(void); 65 | void _glfwTerminateJoysticksNS(void); 66 | 67 | #endif // _glfw3_cocoa_joystick_h_ 68 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/cocoa_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_cocoa_platform_h_ 28 | #define _glfw3_cocoa_platform_h_ 29 | 30 | #include 31 | #include 32 | 33 | #if defined(__OBJC__) 34 | #import 35 | #import 36 | #else 37 | #include 38 | #include 39 | typedef void* id; 40 | #endif 41 | 42 | #include "posix_tls.h" 43 | #include "cocoa_joystick.h" 44 | #include "nsgl_context.h" 45 | 46 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 47 | #define _glfw_dlclose(handle) dlclose(handle) 48 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 49 | 50 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns 51 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns 52 | #define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimeNS ns_time 53 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns 54 | #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns 55 | 56 | #define _GLFW_EGL_CONTEXT_STATE 57 | #define _GLFW_EGL_LIBRARY_CONTEXT_STATE 58 | 59 | // HIToolbox.framework pointer typedefs 60 | #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData 61 | #define kTISNotifySelectedKeyboardInputSourceChanged _glfw.ns.tis.kNotifySelectedKeyboardInputSourceChanged 62 | typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); 63 | #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource 64 | typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); 65 | #define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty 66 | typedef UInt8 (*PFN_LMGetKbdType)(void); 67 | #define LMGetKbdType _glfw.ns.tis.GetKbdType 68 | 69 | 70 | // Cocoa-specific per-window data 71 | // 72 | typedef struct _GLFWwindowNS 73 | { 74 | id object; 75 | id delegate; 76 | id view; 77 | 78 | // The total sum of the distances the cursor has been warped 79 | // since the last cursor motion event was processed 80 | // This is kept to counteract Cocoa doing the same internally 81 | double cursorWarpDeltaX, cursorWarpDeltaY; 82 | 83 | } _GLFWwindowNS; 84 | 85 | 86 | // Cocoa-specific global data 87 | // 88 | typedef struct _GLFWlibraryNS 89 | { 90 | CGEventSourceRef eventSource; 91 | id delegate; 92 | id autoreleasePool; 93 | id cursor; 94 | TISInputSourceRef inputSource; 95 | id unicodeData; 96 | id listener; 97 | 98 | char keyName[64]; 99 | short int publicKeys[256]; 100 | short int nativeKeys[GLFW_KEY_LAST + 1]; 101 | char* clipboardString; 102 | // Where to place the cursor when re-enabled 103 | double restoreCursorPosX, restoreCursorPosY; 104 | // The window whose disabled cursor mode is active 105 | _GLFWwindow* disabledCursorWindow; 106 | 107 | struct { 108 | CFBundleRef bundle; 109 | PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource; 110 | PFN_TISGetInputSourceProperty GetInputSourceProperty; 111 | PFN_LMGetKbdType GetKbdType; 112 | CFStringRef kPropertyUnicodeKeyLayoutData; 113 | CFStringRef kNotifySelectedKeyboardInputSourceChanged; 114 | } tis; 115 | 116 | } _GLFWlibraryNS; 117 | 118 | 119 | // Cocoa-specific per-monitor data 120 | // 121 | typedef struct _GLFWmonitorNS 122 | { 123 | CGDirectDisplayID displayID; 124 | CGDisplayModeRef previousMode; 125 | uint32_t unitNumber; 126 | 127 | } _GLFWmonitorNS; 128 | 129 | 130 | // Cocoa-specific per-cursor data 131 | // 132 | typedef struct _GLFWcursorNS 133 | { 134 | id object; 135 | 136 | } _GLFWcursorNS; 137 | 138 | 139 | // Cocoa-specific global timer data 140 | // 141 | typedef struct _GLFWtimeNS 142 | { 143 | uint64_t frequency; 144 | 145 | } _GLFWtimeNS; 146 | 147 | 148 | void _glfwInitTimerNS(void); 149 | 150 | GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); 151 | void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); 152 | 153 | #endif // _glfw3_cocoa_platform_h_ 154 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW internal API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Initialise timer 37 | // 38 | void _glfwInitTimerNS(void) 39 | { 40 | mach_timebase_info_data_t info; 41 | mach_timebase_info(&info); 42 | 43 | _glfw.ns_time.frequency = (info.denom * 1e9) / info.numer; 44 | } 45 | 46 | 47 | ////////////////////////////////////////////////////////////////////////// 48 | ////// GLFW platform API ////// 49 | ////////////////////////////////////////////////////////////////////////// 50 | 51 | uint64_t _glfwPlatformGetTimerValue(void) 52 | { 53 | return mach_absolute_time(); 54 | } 55 | 56 | uint64_t _glfwPlatformGetTimerFrequency(void) 57 | { 58 | return _glfw.ns_time.frequency; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/glfw3.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/lib@LIB_SUFFIX@ 5 | 6 | Name: GLFW 7 | Description: A multi-platform library for OpenGL, window and input 8 | Version: @GLFW_VERSION_FULL@ 9 | URL: http://www.glfw.org/ 10 | Requires.private: @GLFW_PKG_DEPS@ 11 | Libs: -L${libdir} -l@GLFW_LIB_NAME@ 12 | Libs.private: @GLFW_PKG_LIBS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/glfw3Config.cmake.in: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake") 2 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // Define this to 1 if building GLFW for X11 38 | #cmakedefine _GLFW_X11 39 | // Define this to 1 if building GLFW for Win32 40 | #cmakedefine _GLFW_WIN32 41 | // Define this to 1 if building GLFW for Cocoa 42 | #cmakedefine _GLFW_COCOA 43 | // Define this to 1 if building GLFW for Wayland 44 | #cmakedefine _GLFW_WAYLAND 45 | // Define this to 1 if building GLFW for Mir 46 | #cmakedefine _GLFW_MIR 47 | 48 | // Define this to 1 if building as a shared library / dynamic library / DLL 49 | #cmakedefine _GLFW_BUILD_DLL 50 | 51 | // Define this to 1 to force use of high-performance GPU on hybrid systems 52 | #cmakedefine _GLFW_USE_HYBRID_HPG 53 | 54 | // Define this to 1 if the Xxf86vm X11 extension is available 55 | #cmakedefine _GLFW_HAS_XF86VM 56 | 57 | // Define this to 1 if glfwInit should change the current directory 58 | #cmakedefine _GLFW_USE_CHDIR 59 | // Define this to 1 if glfwCreateWindow should populate the menu bar 60 | #cmakedefine _GLFW_USE_MENUBAR 61 | // Define this to 1 if windows should use full resolution on Retina displays 62 | #cmakedefine _GLFW_USE_RETINA 63 | 64 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/glx_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 GLX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _glfw3_glx_context_h_ 29 | #define _glfw3_glx_context_h_ 30 | 31 | #define GLX_VENDOR 1 32 | #define GLX_RGBA_BIT 0x00000001 33 | #define GLX_WINDOW_BIT 0x00000001 34 | #define GLX_DRAWABLE_TYPE 0x8010 35 | #define GLX_RENDER_TYPE 0x8011 36 | #define GLX_RGBA_TYPE 0x8014 37 | #define GLX_DOUBLEBUFFER 5 38 | #define GLX_STEREO 6 39 | #define GLX_AUX_BUFFERS 7 40 | #define GLX_RED_SIZE 8 41 | #define GLX_GREEN_SIZE 9 42 | #define GLX_BLUE_SIZE 10 43 | #define GLX_ALPHA_SIZE 11 44 | #define GLX_DEPTH_SIZE 12 45 | #define GLX_STENCIL_SIZE 13 46 | #define GLX_ACCUM_RED_SIZE 14 47 | #define GLX_ACCUM_GREEN_SIZE 15 48 | #define GLX_ACCUM_BLUE_SIZE 16 49 | #define GLX_ACCUM_ALPHA_SIZE 17 50 | #define GLX_SAMPLES 0x186a1 51 | #define GLX_VISUAL_ID 0x800b 52 | 53 | #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 54 | #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 55 | #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 56 | #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 57 | #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 58 | #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 59 | #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 60 | #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 61 | #define GLX_CONTEXT_FLAGS_ARB 0x2094 62 | #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 63 | #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 64 | #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 65 | #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 66 | #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 67 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 68 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 69 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 70 | 71 | typedef XID GLXWindow; 72 | typedef XID GLXDrawable; 73 | typedef struct __GLXFBConfig* GLXFBConfig; 74 | typedef struct __GLXcontext* GLXContext; 75 | typedef void (*__GLXextproc)(void); 76 | 77 | typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*); 78 | typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int); 79 | typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*); 80 | typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*); 81 | typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext); 82 | typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext); 83 | typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable); 84 | typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int); 85 | typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*); 86 | typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool); 87 | typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); 88 | typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); 89 | typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int); 90 | typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int); 91 | typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*); 92 | typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig); 93 | typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*); 94 | typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); 95 | 96 | // libGL.so function pointer typedefs 97 | #define glXGetFBConfigs _glfw.glx.GetFBConfigs 98 | #define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib 99 | #define glXGetClientString _glfw.glx.GetClientString 100 | #define glXQueryExtension _glfw.glx.QueryExtension 101 | #define glXQueryVersion _glfw.glx.QueryVersion 102 | #define glXDestroyContext _glfw.glx.DestroyContext 103 | #define glXMakeCurrent _glfw.glx.MakeCurrent 104 | #define glXSwapBuffers _glfw.glx.SwapBuffers 105 | #define glXQueryExtensionsString _glfw.glx.QueryExtensionsString 106 | #define glXCreateNewContext _glfw.glx.CreateNewContext 107 | #define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig 108 | #define glXCreateWindow _glfw.glx.CreateWindow 109 | #define glXDestroyWindow _glfw.glx.DestroyWindow 110 | 111 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx 112 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx 113 | 114 | 115 | // GLX-specific per-context data 116 | // 117 | typedef struct _GLFWcontextGLX 118 | { 119 | GLXContext handle; 120 | GLXWindow window; 121 | 122 | } _GLFWcontextGLX; 123 | 124 | 125 | // GLX-specific global data 126 | // 127 | typedef struct _GLFWlibraryGLX 128 | { 129 | int major, minor; 130 | int eventBase; 131 | int errorBase; 132 | 133 | // dlopen handle for libGL.so.1 134 | void* handle; 135 | 136 | // GLX 1.3 functions 137 | PFNGLXGETFBCONFIGSPROC GetFBConfigs; 138 | PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib; 139 | PFNGLXGETCLIENTSTRINGPROC GetClientString; 140 | PFNGLXQUERYEXTENSIONPROC QueryExtension; 141 | PFNGLXQUERYVERSIONPROC QueryVersion; 142 | PFNGLXDESTROYCONTEXTPROC DestroyContext; 143 | PFNGLXMAKECURRENTPROC MakeCurrent; 144 | PFNGLXSWAPBUFFERSPROC SwapBuffers; 145 | PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString; 146 | PFNGLXCREATENEWCONTEXTPROC CreateNewContext; 147 | PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig; 148 | PFNGLXCREATEWINDOWPROC CreateWindow; 149 | PFNGLXDESTROYWINDOWPROC DestroyWindow; 150 | 151 | // GLX 1.4 and extension functions 152 | PFNGLXGETPROCADDRESSPROC GetProcAddress; 153 | PFNGLXGETPROCADDRESSPROC GetProcAddressARB; 154 | PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; 155 | PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; 156 | PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; 157 | PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 158 | GLFWbool SGI_swap_control; 159 | GLFWbool EXT_swap_control; 160 | GLFWbool MESA_swap_control; 161 | GLFWbool ARB_multisample; 162 | GLFWbool ARB_framebuffer_sRGB; 163 | GLFWbool EXT_framebuffer_sRGB; 164 | GLFWbool ARB_create_context; 165 | GLFWbool ARB_create_context_profile; 166 | GLFWbool ARB_create_context_robustness; 167 | GLFWbool EXT_create_context_es2_profile; 168 | GLFWbool ARB_context_flush_control; 169 | 170 | } _GLFWlibraryGLX; 171 | 172 | 173 | GLFWbool _glfwInitGLX(void); 174 | void _glfwTerminateGLX(void); 175 | GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, 176 | const _GLFWctxconfig* ctxconfig, 177 | const _GLFWfbconfig* fbconfig); 178 | void _glfwDestroyContextGLX(_GLFWwindow* window); 179 | GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig, 180 | const _GLFWfbconfig* fbconfig, 181 | Visual** visual, int* depth); 182 | 183 | #endif // _glfw3_glx_context_h_ 184 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | // The three global variables below comprise all global data in GLFW. 37 | // Any other global variable is a bug. 38 | 39 | // Global state shared between compilation units of GLFW 40 | // These are documented in internal.h 41 | // 42 | GLFWbool _glfwInitialized = GLFW_FALSE; 43 | _GLFWlibrary _glfw; 44 | 45 | // This is outside of _glfw so it can be initialized and usable before 46 | // glfwInit is called, which lets that function report errors 47 | // 48 | static GLFWerrorfun _glfwErrorCallback = NULL; 49 | 50 | 51 | // Returns a generic string representation of the specified error 52 | // 53 | static const char* getErrorString(int error) 54 | { 55 | switch (error) 56 | { 57 | case GLFW_NOT_INITIALIZED: 58 | return "The GLFW library is not initialized"; 59 | case GLFW_NO_CURRENT_CONTEXT: 60 | return "There is no current context"; 61 | case GLFW_INVALID_ENUM: 62 | return "Invalid argument for enum parameter"; 63 | case GLFW_INVALID_VALUE: 64 | return "Invalid value for parameter"; 65 | case GLFW_OUT_OF_MEMORY: 66 | return "Out of memory"; 67 | case GLFW_API_UNAVAILABLE: 68 | return "The requested client API is unavailable"; 69 | case GLFW_VERSION_UNAVAILABLE: 70 | return "The requested client API version is unavailable"; 71 | case GLFW_PLATFORM_ERROR: 72 | return "A platform-specific error occurred"; 73 | case GLFW_FORMAT_UNAVAILABLE: 74 | return "The requested format is unavailable"; 75 | case GLFW_NO_WINDOW_CONTEXT: 76 | return "The specified window has no context"; 77 | default: 78 | return "ERROR: UNKNOWN GLFW ERROR"; 79 | } 80 | } 81 | 82 | 83 | ////////////////////////////////////////////////////////////////////////// 84 | ////// GLFW event API ////// 85 | ////////////////////////////////////////////////////////////////////////// 86 | 87 | void _glfwInputError(int error, const char* format, ...) 88 | { 89 | if (_glfwErrorCallback) 90 | { 91 | char buffer[8192]; 92 | const char* description; 93 | 94 | if (format) 95 | { 96 | int count; 97 | va_list vl; 98 | 99 | va_start(vl, format); 100 | count = vsnprintf(buffer, sizeof(buffer), format, vl); 101 | va_end(vl); 102 | 103 | if (count < 0) 104 | buffer[sizeof(buffer) - 1] = '\0'; 105 | 106 | description = buffer; 107 | } 108 | else 109 | description = getErrorString(error); 110 | 111 | _glfwErrorCallback(error, description); 112 | } 113 | } 114 | 115 | 116 | ////////////////////////////////////////////////////////////////////////// 117 | ////// GLFW public API ////// 118 | ////////////////////////////////////////////////////////////////////////// 119 | 120 | GLFWAPI int glfwInit(void) 121 | { 122 | if (_glfwInitialized) 123 | return GLFW_TRUE; 124 | 125 | memset(&_glfw, 0, sizeof(_glfw)); 126 | 127 | if (!_glfwPlatformInit()) 128 | { 129 | _glfwPlatformTerminate(); 130 | return GLFW_FALSE; 131 | } 132 | 133 | _glfwInitVulkan(); 134 | 135 | _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount); 136 | _glfwInitialized = GLFW_TRUE; 137 | 138 | _glfw.timerOffset = _glfwPlatformGetTimerValue(); 139 | 140 | // Not all window hints have zero as their default value 141 | glfwDefaultWindowHints(); 142 | 143 | return GLFW_TRUE; 144 | } 145 | 146 | GLFWAPI void glfwTerminate(void) 147 | { 148 | int i; 149 | 150 | if (!_glfwInitialized) 151 | return; 152 | 153 | memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks)); 154 | 155 | while (_glfw.windowListHead) 156 | glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead); 157 | 158 | while (_glfw.cursorListHead) 159 | glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead); 160 | 161 | for (i = 0; i < _glfw.monitorCount; i++) 162 | { 163 | _GLFWmonitor* monitor = _glfw.monitors[i]; 164 | if (monitor->originalRamp.size) 165 | _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp); 166 | } 167 | 168 | _glfwTerminateVulkan(); 169 | 170 | _glfwFreeMonitors(_glfw.monitors, _glfw.monitorCount); 171 | _glfw.monitors = NULL; 172 | _glfw.monitorCount = 0; 173 | 174 | _glfwPlatformTerminate(); 175 | 176 | memset(&_glfw, 0, sizeof(_glfw)); 177 | _glfwInitialized = GLFW_FALSE; 178 | } 179 | 180 | GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) 181 | { 182 | if (major != NULL) 183 | *major = GLFW_VERSION_MAJOR; 184 | 185 | if (minor != NULL) 186 | *minor = GLFW_VERSION_MINOR; 187 | 188 | if (rev != NULL) 189 | *rev = GLFW_VERSION_REVISION; 190 | } 191 | 192 | GLFWAPI const char* glfwGetVersionString(void) 193 | { 194 | return _glfwPlatformGetVersionString(); 195 | } 196 | 197 | GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun) 198 | { 199 | _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun); 200 | return cbfun; 201 | } 202 | 203 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_linux_joystick_h_ 28 | #define _glfw3_linux_joystick_h_ 29 | 30 | #include 31 | 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWjoylistLinux linux_js 33 | 34 | 35 | // Linux-specific joystick data 36 | // 37 | typedef struct _GLFWjoystickLinux 38 | { 39 | GLFWbool present; 40 | int fd; 41 | float* axes; 42 | int axisCount; 43 | unsigned char* buttons; 44 | int buttonCount; 45 | char* name; 46 | char* path; 47 | } _GLFWjoystickLinux; 48 | 49 | 50 | // Linux-specific joystick API data 51 | // 52 | typedef struct _GLFWjoylistLinux 53 | { 54 | _GLFWjoystickLinux js[GLFW_JOYSTICK_LAST + 1]; 55 | 56 | #if defined(__linux__) 57 | int inotify; 58 | int watch; 59 | regex_t regex; 60 | #endif /*__linux__*/ 61 | } _GLFWjoylistLinux; 62 | 63 | 64 | GLFWbool _glfwInitJoysticksLinux(void); 65 | void _glfwTerminateJoysticksLinux(void); 66 | 67 | void _glfwPollJoystickEvents(void); 68 | 69 | #endif // _glfw3_linux_joystick_h_ 70 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/mir_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Mir - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014-2015 Brandon Schaefer 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | _GLFWmonitor** _glfwPlatformGetMonitors(int* count) 37 | { 38 | int i, found = 0; 39 | _GLFWmonitor** monitors = NULL; 40 | MirDisplayConfiguration* displayConfig = 41 | mir_connection_create_display_config(_glfw.mir.connection); 42 | 43 | *count = 0; 44 | 45 | for (i = 0; i < displayConfig->num_outputs; i++) 46 | { 47 | const MirDisplayOutput* out = displayConfig->outputs + i; 48 | 49 | if (out->used && 50 | out->connected && 51 | out->num_modes && 52 | out->current_mode < out->num_modes) 53 | { 54 | found++; 55 | monitors = realloc(monitors, sizeof(_GLFWmonitor*) * found); 56 | monitors[i] = _glfwAllocMonitor("Unknown", 57 | out->physical_width_mm, 58 | out->physical_height_mm); 59 | 60 | monitors[i]->mir.x = out->position_x; 61 | monitors[i]->mir.y = out->position_y; 62 | monitors[i]->mir.output_id = out->output_id; 63 | monitors[i]->mir.cur_mode = out->current_mode; 64 | 65 | monitors[i]->modes = _glfwPlatformGetVideoModes(monitors[i], 66 | &monitors[i]->modeCount); 67 | } 68 | } 69 | 70 | mir_display_config_destroy(displayConfig); 71 | 72 | *count = found; 73 | return monitors; 74 | } 75 | 76 | GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second) 77 | { 78 | return first->mir.output_id == second->mir.output_id; 79 | } 80 | 81 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 82 | { 83 | if (xpos) 84 | *xpos = monitor->mir.x; 85 | if (ypos) 86 | *ypos = monitor->mir.y; 87 | } 88 | 89 | void FillInRGBBitsFromPixelFormat(GLFWvidmode* mode, const MirPixelFormat pf) 90 | { 91 | switch (pf) 92 | { 93 | case mir_pixel_format_rgb_565: 94 | mode->redBits = 5; 95 | mode->greenBits = 6; 96 | mode->blueBits = 5; 97 | break; 98 | case mir_pixel_format_rgba_5551: 99 | mode->redBits = 5; 100 | mode->greenBits = 5; 101 | mode->blueBits = 5; 102 | break; 103 | case mir_pixel_format_rgba_4444: 104 | mode->redBits = 4; 105 | mode->greenBits = 4; 106 | mode->blueBits = 4; 107 | break; 108 | case mir_pixel_format_abgr_8888: 109 | case mir_pixel_format_xbgr_8888: 110 | case mir_pixel_format_argb_8888: 111 | case mir_pixel_format_xrgb_8888: 112 | case mir_pixel_format_bgr_888: 113 | case mir_pixel_format_rgb_888: 114 | default: 115 | mode->redBits = 8; 116 | mode->greenBits = 8; 117 | mode->blueBits = 8; 118 | break; 119 | } 120 | } 121 | 122 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 123 | { 124 | int i; 125 | GLFWvidmode* modes = NULL; 126 | MirDisplayConfiguration* displayConfig = 127 | mir_connection_create_display_config(_glfw.mir.connection); 128 | 129 | for (i = 0; i < displayConfig->num_outputs; i++) 130 | { 131 | const MirDisplayOutput* out = displayConfig->outputs + i; 132 | if (out->output_id != monitor->mir.output_id) 133 | continue; 134 | 135 | modes = calloc(out->num_modes, sizeof(GLFWvidmode)); 136 | 137 | for (*found = 0; *found < out->num_modes; (*found)++) 138 | { 139 | modes[*found].width = out->modes[*found].horizontal_resolution; 140 | modes[*found].height = out->modes[*found].vertical_resolution; 141 | modes[*found].refreshRate = out->modes[*found].refresh_rate; 142 | 143 | FillInRGBBitsFromPixelFormat(&modes[*found], out->output_formats[*found]); 144 | } 145 | 146 | break; 147 | } 148 | 149 | mir_display_config_destroy(displayConfig); 150 | 151 | return modes; 152 | } 153 | 154 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 155 | { 156 | *mode = monitor->modes[monitor->mir.cur_mode]; 157 | } 158 | 159 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 160 | { 161 | _glfwInputError(GLFW_PLATFORM_ERROR, 162 | "Mir: Unsupported function %s", __PRETTY_FUNCTION__); 163 | } 164 | 165 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 166 | { 167 | _glfwInputError(GLFW_PLATFORM_ERROR, 168 | "Mir: Unsupported function %s", __PRETTY_FUNCTION__); 169 | } 170 | 171 | 172 | ////////////////////////////////////////////////////////////////////////// 173 | ////// GLFW native API ////// 174 | ////////////////////////////////////////////////////////////////////////// 175 | 176 | GLFWAPI int glfwGetMirMonitor(GLFWmonitor* handle) 177 | { 178 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 179 | _GLFW_REQUIRE_INIT_OR_RETURN(0); 180 | return monitor->mir.output_id; 181 | } 182 | 183 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/mir_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Mir - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014-2015 Brandon Schaefer 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_mir_platform_h_ 28 | #define _glfw3_mir_platform_h_ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | typedef VkFlags VkMirSurfaceCreateFlagsKHR; 37 | 38 | typedef struct VkMirSurfaceCreateInfoKHR 39 | { 40 | VkStructureType sType; 41 | const void* pNext; 42 | VkMirSurfaceCreateFlagsKHR flags; 43 | MirConnection* connection; 44 | MirSurface* mirSurface; 45 | } VkMirSurfaceCreateInfoKHR; 46 | 47 | typedef VkResult (APIENTRY *PFN_vkCreateMirSurfaceKHR)(VkInstance,const VkMirSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); 48 | typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*); 49 | 50 | #include "posix_tls.h" 51 | #include "posix_time.h" 52 | #include "linux_joystick.h" 53 | #include "xkb_unicode.h" 54 | #include "egl_context.h" 55 | 56 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 57 | #define _glfw_dlclose(handle) dlclose(handle) 58 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 59 | 60 | #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->mir.window) 61 | #define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display) 62 | 63 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir 64 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorMir mir 65 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir 66 | #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorMir mir 67 | 68 | #define _GLFW_PLATFORM_CONTEXT_STATE 69 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE 70 | 71 | 72 | // Mir-specific Event Queue 73 | // 74 | typedef struct EventQueue 75 | { 76 | TAILQ_HEAD(, EventNode) head; 77 | } EventQueue; 78 | 79 | // Mir-specific per-window data 80 | // 81 | typedef struct _GLFWwindowMir 82 | { 83 | MirSurface* surface; 84 | int width; 85 | int height; 86 | MirEGLNativeWindowType window; 87 | 88 | } _GLFWwindowMir; 89 | 90 | 91 | // Mir-specific per-monitor data 92 | // 93 | typedef struct _GLFWmonitorMir 94 | { 95 | int cur_mode; 96 | int output_id; 97 | int x; 98 | int y; 99 | 100 | } _GLFWmonitorMir; 101 | 102 | 103 | // Mir-specific global data 104 | // 105 | typedef struct _GLFWlibraryMir 106 | { 107 | MirConnection* connection; 108 | MirEGLNativeDisplayType display; 109 | MirCursorConfiguration* default_conf; 110 | EventQueue* event_queue; 111 | 112 | short int publicKeys[256]; 113 | 114 | pthread_mutex_t event_mutex; 115 | pthread_cond_t event_cond; 116 | 117 | } _GLFWlibraryMir; 118 | 119 | 120 | // Mir-specific per-cursor data 121 | // TODO: Only system cursors are implemented in Mir atm. Need to wait for support. 122 | // 123 | typedef struct _GLFWcursorMir 124 | { 125 | MirCursorConfiguration* conf; 126 | MirBufferStream* custom_cursor; 127 | } _GLFWcursorMir; 128 | 129 | 130 | extern void _glfwInitEventQueueMir(EventQueue* queue); 131 | extern void _glfwDeleteEventQueueMir(EventQueue* queue); 132 | 133 | #endif // _glfw3_mir_platform_h_ 134 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_nsgl_context_h_ 28 | #define _glfw3_nsgl_context_h_ 29 | 30 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 31 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 32 | 33 | 34 | // NSGL-specific per-context data 35 | // 36 | typedef struct _GLFWcontextNSGL 37 | { 38 | id pixelFormat; 39 | id object; 40 | 41 | } _GLFWcontextNSGL; 42 | 43 | 44 | // NSGL-specific global data 45 | // 46 | typedef struct _GLFWlibraryNSGL 47 | { 48 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 49 | CFBundleRef framework; 50 | 51 | } _GLFWlibraryNSGL; 52 | 53 | 54 | GLFWbool _glfwInitNSGL(void); 55 | void _glfwTerminateNSGL(void); 56 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 57 | const _GLFWctxconfig* ctxconfig, 58 | const _GLFWfbconfig* fbconfig); 59 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 60 | 61 | #endif // _glfw3_nsgl_context_h_ 62 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerPOSIX(void) 41 | { 42 | #if defined(CLOCK_MONOTONIC) 43 | struct timespec ts; 44 | 45 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 46 | { 47 | _glfw.posix_time.monotonic = GLFW_TRUE; 48 | _glfw.posix_time.frequency = 1000000000; 49 | } 50 | else 51 | #endif 52 | { 53 | _glfw.posix_time.monotonic = GLFW_FALSE; 54 | _glfw.posix_time.frequency = 1000000; 55 | } 56 | } 57 | 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | ////// GLFW platform API ////// 61 | ////////////////////////////////////////////////////////////////////////// 62 | 63 | uint64_t _glfwPlatformGetTimerValue(void) 64 | { 65 | #if defined(CLOCK_MONOTONIC) 66 | if (_glfw.posix_time.monotonic) 67 | { 68 | struct timespec ts; 69 | clock_gettime(CLOCK_MONOTONIC, &ts); 70 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 71 | } 72 | else 73 | #endif 74 | { 75 | struct timeval tv; 76 | gettimeofday(&tv, NULL); 77 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 78 | } 79 | } 80 | 81 | uint64_t _glfwPlatformGetTimerFrequency(void) 82 | { 83 | return _glfw.posix_time.frequency; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _glfw3_posix_time_h_ 29 | #define _glfw3_posix_time_h_ 30 | 31 | #define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimePOSIX posix_time 32 | 33 | #include 34 | 35 | 36 | // POSIX-specific global timer data 37 | // 38 | typedef struct _GLFWtimePOSIX 39 | { 40 | GLFWbool monotonic; 41 | uint64_t frequency; 42 | 43 | } _GLFWtimePOSIX; 44 | 45 | 46 | void _glfwInitTimerPOSIX(void); 47 | 48 | #endif // _glfw3_posix_time_h_ 49 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/posix_tls.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | GLFWbool _glfwInitThreadLocalStoragePOSIX(void) 36 | { 37 | if (pthread_key_create(&_glfw.posix_tls.context, NULL) != 0) 38 | { 39 | _glfwInputError(GLFW_PLATFORM_ERROR, 40 | "POSIX: Failed to create context TLS"); 41 | return GLFW_FALSE; 42 | } 43 | 44 | _glfw.posix_tls.allocated = GLFW_TRUE; 45 | return GLFW_TRUE; 46 | } 47 | 48 | void _glfwTerminateThreadLocalStoragePOSIX(void) 49 | { 50 | if (_glfw.posix_tls.allocated) 51 | pthread_key_delete(_glfw.posix_tls.context); 52 | } 53 | 54 | 55 | ////////////////////////////////////////////////////////////////////////// 56 | ////// GLFW platform API ////// 57 | ////////////////////////////////////////////////////////////////////////// 58 | 59 | void _glfwPlatformSetCurrentContext(_GLFWwindow* context) 60 | { 61 | pthread_setspecific(_glfw.posix_tls.context, context); 62 | } 63 | 64 | _GLFWwindow* _glfwPlatformGetCurrentContext(void) 65 | { 66 | return pthread_getspecific(_glfw.posix_tls.context); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/posix_tls.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _glfw3_posix_tls_h_ 29 | #define _glfw3_posix_tls_h_ 30 | 31 | #include 32 | 33 | #define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsPOSIX posix_tls 34 | 35 | 36 | // POSIX-specific global TLS data 37 | // 38 | typedef struct _GLFWtlsPOSIX 39 | { 40 | GLFWbool allocated; 41 | pthread_key_t context; 42 | 43 | } _GLFWtlsPOSIX; 44 | 45 | 46 | GLFWbool _glfwInitThreadLocalStoragePOSIX(void); 47 | void _glfwTerminateThreadLocalStoragePOSIX(void); 48 | 49 | #endif // _glfw3_posix_tls_h_ 50 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/wgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 WGL - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _glfw3_wgl_context_h_ 29 | #define _glfw3_wgl_context_h_ 30 | 31 | 32 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 33 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 34 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 35 | #define WGL_PIXEL_TYPE_ARB 0x2013 36 | #define WGL_TYPE_RGBA_ARB 0x202b 37 | #define WGL_ACCELERATION_ARB 0x2003 38 | #define WGL_NO_ACCELERATION_ARB 0x2025 39 | #define WGL_RED_BITS_ARB 0x2015 40 | #define WGL_RED_SHIFT_ARB 0x2016 41 | #define WGL_GREEN_BITS_ARB 0x2017 42 | #define WGL_GREEN_SHIFT_ARB 0x2018 43 | #define WGL_BLUE_BITS_ARB 0x2019 44 | #define WGL_BLUE_SHIFT_ARB 0x201a 45 | #define WGL_ALPHA_BITS_ARB 0x201b 46 | #define WGL_ALPHA_SHIFT_ARB 0x201c 47 | #define WGL_ACCUM_BITS_ARB 0x201d 48 | #define WGL_ACCUM_RED_BITS_ARB 0x201e 49 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201f 50 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 51 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 52 | #define WGL_DEPTH_BITS_ARB 0x2022 53 | #define WGL_STENCIL_BITS_ARB 0x2023 54 | #define WGL_AUX_BUFFERS_ARB 0x2024 55 | #define WGL_STEREO_ARB 0x2012 56 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 57 | #define WGL_SAMPLES_ARB 0x2042 58 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9 59 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 60 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 61 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 62 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 63 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 64 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 65 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 66 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 67 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 68 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 69 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 70 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 71 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 72 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 73 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 74 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 75 | 76 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); 77 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); 78 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); 79 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); 80 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); 81 | 82 | typedef HGLRC (WINAPI * WGLCREATECONTEXT_T)(HDC); 83 | typedef BOOL (WINAPI * WGLDELETECONTEXT_T)(HGLRC); 84 | typedef PROC (WINAPI * WGLGETPROCADDRESS_T)(LPCSTR); 85 | typedef BOOL (WINAPI * WGLMAKECURRENT_T)(HDC,HGLRC); 86 | typedef BOOL (WINAPI * WGLSHARELISTS_T)(HGLRC,HGLRC); 87 | 88 | // opengl32.dll function pointer typedefs 89 | #define wglCreateContext _glfw.wgl.CreateContext 90 | #define wglDeleteContext _glfw.wgl.DeleteContext 91 | #define wglGetProcAddress _glfw.wgl.GetProcAddress 92 | #define wglMakeCurrent _glfw.wgl.MakeCurrent 93 | #define wglShareLists _glfw.wgl.ShareLists 94 | 95 | #define _GLFW_RECREATION_NOT_NEEDED 0 96 | #define _GLFW_RECREATION_REQUIRED 1 97 | #define _GLFW_RECREATION_IMPOSSIBLE 2 98 | 99 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl 100 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl 101 | 102 | 103 | // WGL-specific per-context data 104 | // 105 | typedef struct _GLFWcontextWGL 106 | { 107 | HDC dc; 108 | HGLRC handle; 109 | int interval; 110 | 111 | } _GLFWcontextWGL; 112 | 113 | 114 | // WGL-specific global data 115 | // 116 | typedef struct _GLFWlibraryWGL 117 | { 118 | HINSTANCE instance; 119 | WGLCREATECONTEXT_T CreateContext; 120 | WGLDELETECONTEXT_T DeleteContext; 121 | WGLGETPROCADDRESS_T GetProcAddress; 122 | WGLMAKECURRENT_T MakeCurrent; 123 | WGLSHARELISTS_T ShareLists; 124 | 125 | GLFWbool extensionsLoaded; 126 | 127 | PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; 128 | PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; 129 | PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; 130 | PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; 131 | PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 132 | GLFWbool EXT_swap_control; 133 | GLFWbool ARB_multisample; 134 | GLFWbool ARB_framebuffer_sRGB; 135 | GLFWbool EXT_framebuffer_sRGB; 136 | GLFWbool ARB_pixel_format; 137 | GLFWbool ARB_create_context; 138 | GLFWbool ARB_create_context_profile; 139 | GLFWbool EXT_create_context_es2_profile; 140 | GLFWbool ARB_create_context_robustness; 141 | GLFWbool ARB_context_flush_control; 142 | 143 | } _GLFWlibraryWGL; 144 | 145 | 146 | GLFWbool _glfwInitWGL(void); 147 | void _glfwTerminateWGL(void); 148 | GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, 149 | const _GLFWctxconfig* ctxconfig, 150 | const _GLFWfbconfig* fbconfig); 151 | int _glfwAnalyzeContextWGL(_GLFWwindow* window, 152 | const _GLFWctxconfig* ctxconfig, 153 | const _GLFWfbconfig* fbconfig); 154 | 155 | #endif // _glfw3_wgl_context_h_ 156 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_win32_joystick_h_ 28 | #define _glfw3_win32_joystick_h_ 29 | 30 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ 31 | _GLFWjoystickWin32 win32_js[GLFW_JOYSTICK_LAST + 1] 32 | 33 | // Spoo 34 | // 35 | typedef struct _GLFWjoyobjectWin32 36 | { 37 | int offset; 38 | int type; 39 | } _GLFWjoyobjectWin32; 40 | 41 | // Win32-specific per-joystick data 42 | // 43 | typedef struct _GLFWjoystickWin32 44 | { 45 | GLFWbool present; 46 | float* axes; 47 | int axisCount; 48 | unsigned char* buttons; 49 | int buttonCount; 50 | _GLFWjoyobjectWin32* objects; 51 | int objectCount; 52 | char* name; 53 | IDirectInputDevice8W* device; 54 | DWORD index; 55 | GUID guid; 56 | } _GLFWjoystickWin32; 57 | 58 | 59 | void _glfwInitJoysticksWin32(void); 60 | void _glfwTerminateJoysticksWin32(void); 61 | void _glfwDetectJoystickConnectionWin32(void); 62 | void _glfwDetectJoystickDisconnectionWin32(void); 63 | 64 | #endif // _glfw3_win32_joystick_h_ 65 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Initialise timer 36 | // 37 | void _glfwInitTimerWin32(void) 38 | { 39 | uint64_t frequency; 40 | 41 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 42 | { 43 | _glfw.win32_time.hasPC = GLFW_TRUE; 44 | _glfw.win32_time.frequency = frequency; 45 | } 46 | else 47 | { 48 | _glfw.win32_time.hasPC = GLFW_FALSE; 49 | _glfw.win32_time.frequency = 1000; 50 | } 51 | } 52 | 53 | 54 | ////////////////////////////////////////////////////////////////////////// 55 | ////// GLFW platform API ////// 56 | ////////////////////////////////////////////////////////////////////////// 57 | 58 | uint64_t _glfwPlatformGetTimerValue(void) 59 | { 60 | if (_glfw.win32_time.hasPC) 61 | { 62 | uint64_t value; 63 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 64 | return value; 65 | } 66 | else 67 | return (uint64_t) _glfw_timeGetTime(); 68 | } 69 | 70 | uint64_t _glfwPlatformGetTimerFrequency(void) 71 | { 72 | return _glfw.win32_time.frequency; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/win32_tls.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | GLFWbool _glfwInitThreadLocalStorageWin32(void) 36 | { 37 | _glfw.win32_tls.context = TlsAlloc(); 38 | if (_glfw.win32_tls.context == TLS_OUT_OF_INDEXES) 39 | { 40 | _glfwInputError(GLFW_PLATFORM_ERROR, 41 | "Win32: Failed to allocate TLS index"); 42 | return GLFW_FALSE; 43 | } 44 | 45 | _glfw.win32_tls.allocated = GLFW_TRUE; 46 | return GLFW_TRUE; 47 | } 48 | 49 | void _glfwTerminateThreadLocalStorageWin32(void) 50 | { 51 | if (_glfw.win32_tls.allocated) 52 | TlsFree(_glfw.win32_tls.context); 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | void _glfwPlatformSetCurrentContext(_GLFWwindow* context) 61 | { 62 | TlsSetValue(_glfw.win32_tls.context, context); 63 | } 64 | 65 | _GLFWwindow* _glfwPlatformGetCurrentContext(void) 66 | { 67 | return TlsGetValue(_glfw.win32_tls.context); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/wl_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Wayland - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | struct _GLFWvidmodeWayland 36 | { 37 | GLFWvidmode base; 38 | uint32_t flags; 39 | }; 40 | 41 | static void geometry(void* data, 42 | struct wl_output* output, 43 | int32_t x, 44 | int32_t y, 45 | int32_t physicalWidth, 46 | int32_t physicalHeight, 47 | int32_t subpixel, 48 | const char* make, 49 | const char* model, 50 | int32_t transform) 51 | { 52 | struct _GLFWmonitor *monitor = data; 53 | 54 | monitor->wl.x = x; 55 | monitor->wl.y = y; 56 | monitor->widthMM = physicalWidth; 57 | monitor->heightMM = physicalHeight; 58 | } 59 | 60 | static void mode(void* data, 61 | struct wl_output* output, 62 | uint32_t flags, 63 | int32_t width, 64 | int32_t height, 65 | int32_t refresh) 66 | { 67 | struct _GLFWmonitor *monitor = data; 68 | _GLFWvidmodeWayland mode = { { 0 }, }; 69 | 70 | mode.base.width = width; 71 | mode.base.height = height; 72 | mode.base.refreshRate = refresh / 1000; 73 | mode.flags = flags; 74 | 75 | if (monitor->wl.modesCount + 1 >= monitor->wl.modesSize) 76 | { 77 | int size = monitor->wl.modesSize * 2; 78 | _GLFWvidmodeWayland* modes = 79 | realloc(monitor->wl.modes, 80 | size * sizeof(_GLFWvidmodeWayland)); 81 | monitor->wl.modes = modes; 82 | monitor->wl.modesSize = size; 83 | } 84 | 85 | monitor->wl.modes[monitor->wl.modesCount++] = mode; 86 | } 87 | 88 | static void done(void* data, 89 | struct wl_output* output) 90 | { 91 | struct _GLFWmonitor *monitor = data; 92 | 93 | monitor->wl.done = GLFW_TRUE; 94 | } 95 | 96 | static void scale(void* data, 97 | struct wl_output* output, 98 | int32_t factor) 99 | { 100 | struct _GLFWmonitor *monitor = data; 101 | 102 | monitor->wl.scale = factor; 103 | } 104 | 105 | static const struct wl_output_listener output_listener = { 106 | geometry, 107 | mode, 108 | done, 109 | scale, 110 | }; 111 | 112 | 113 | ////////////////////////////////////////////////////////////////////////// 114 | ////// GLFW internal API ////// 115 | ////////////////////////////////////////////////////////////////////////// 116 | 117 | void _glfwAddOutputWayland(uint32_t name, uint32_t version) 118 | { 119 | _GLFWmonitor *monitor; 120 | struct wl_output *output; 121 | char name_str[80]; 122 | 123 | memset(name_str, 0, 80 * sizeof(char)); 124 | snprintf(name_str, 79, "wl_output@%u", name); 125 | 126 | if (version < 2) 127 | { 128 | _glfwInputError(GLFW_PLATFORM_ERROR, 129 | "Wayland: Unsupported output interface version"); 130 | return; 131 | } 132 | 133 | monitor = _glfwAllocMonitor(name_str, 0, 0); 134 | 135 | output = wl_registry_bind(_glfw.wl.registry, 136 | name, 137 | &wl_output_interface, 138 | 2); 139 | if (!output) 140 | { 141 | _glfwFreeMonitor(monitor); 142 | return; 143 | } 144 | 145 | monitor->wl.modes = calloc(4, sizeof(_GLFWvidmodeWayland)); 146 | monitor->wl.modesSize = 4; 147 | 148 | monitor->wl.scale = 1; 149 | 150 | monitor->wl.output = output; 151 | wl_output_add_listener(output, &output_listener, monitor); 152 | 153 | if (_glfw.wl.monitorsCount + 1 >= _glfw.wl.monitorsSize) 154 | { 155 | _GLFWmonitor** monitors = _glfw.wl.monitors; 156 | int size = _glfw.wl.monitorsSize * 2; 157 | 158 | monitors = realloc(monitors, size * sizeof(_GLFWmonitor*)); 159 | 160 | _glfw.wl.monitors = monitors; 161 | _glfw.wl.monitorsSize = size; 162 | } 163 | 164 | _glfw.wl.monitors[_glfw.wl.monitorsCount++] = monitor; 165 | } 166 | 167 | 168 | ////////////////////////////////////////////////////////////////////////// 169 | ////// GLFW platform API ////// 170 | ////////////////////////////////////////////////////////////////////////// 171 | 172 | _GLFWmonitor** _glfwPlatformGetMonitors(int* count) 173 | { 174 | _GLFWmonitor** monitors; 175 | _GLFWmonitor* monitor; 176 | int i, monitorsCount = _glfw.wl.monitorsCount; 177 | 178 | if (_glfw.wl.monitorsCount == 0) 179 | goto err; 180 | 181 | monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*)); 182 | 183 | for (i = 0; i < monitorsCount; i++) 184 | { 185 | _GLFWmonitor* origMonitor = _glfw.wl.monitors[i]; 186 | monitor = calloc(1, sizeof(_GLFWmonitor)); 187 | 188 | monitor->modes = 189 | _glfwPlatformGetVideoModes(origMonitor, 190 | &origMonitor->wl.modesCount); 191 | *monitor = *_glfw.wl.monitors[i]; 192 | monitors[i] = monitor; 193 | } 194 | 195 | *count = monitorsCount; 196 | return monitors; 197 | 198 | err: 199 | *count = 0; 200 | return NULL; 201 | } 202 | 203 | GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second) 204 | { 205 | return first->wl.output == second->wl.output; 206 | } 207 | 208 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 209 | { 210 | if (xpos) 211 | *xpos = monitor->wl.x; 212 | if (ypos) 213 | *ypos = monitor->wl.y; 214 | } 215 | 216 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 217 | { 218 | GLFWvidmode *modes; 219 | int i, modesCount = monitor->wl.modesCount; 220 | 221 | modes = calloc(modesCount, sizeof(GLFWvidmode)); 222 | 223 | for (i = 0; i < modesCount; i++) 224 | modes[i] = monitor->wl.modes[i].base; 225 | 226 | *found = modesCount; 227 | return modes; 228 | } 229 | 230 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 231 | { 232 | int i; 233 | 234 | for (i = 0; i < monitor->wl.modesCount; i++) 235 | { 236 | if (monitor->wl.modes[i].flags & WL_OUTPUT_MODE_CURRENT) 237 | { 238 | *mode = monitor->wl.modes[i].base; 239 | return; 240 | } 241 | } 242 | } 243 | 244 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 245 | { 246 | // TODO 247 | _glfwInputError(GLFW_PLATFORM_ERROR, 248 | "Wayland: Gamma ramp getting not supported yet"); 249 | } 250 | 251 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 252 | { 253 | // TODO 254 | _glfwInputError(GLFW_PLATFORM_ERROR, 255 | "Wayland: Gamma ramp setting not supported yet"); 256 | } 257 | 258 | 259 | ////////////////////////////////////////////////////////////////////////// 260 | ////// GLFW native API ////// 261 | ////////////////////////////////////////////////////////////////////////// 262 | 263 | GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) 264 | { 265 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 266 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 267 | return monitor->wl.output; 268 | } 269 | 270 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/wl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Wayland - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_wayland_platform_h_ 28 | #define _glfw3_wayland_platform_h_ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; 35 | 36 | typedef struct VkWaylandSurfaceCreateInfoKHR 37 | { 38 | VkStructureType sType; 39 | const void* pNext; 40 | VkWaylandSurfaceCreateFlagsKHR flags; 41 | struct wl_display* display; 42 | struct wl_surface* surface; 43 | } VkWaylandSurfaceCreateInfoKHR; 44 | 45 | typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); 46 | typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); 47 | 48 | #include "posix_tls.h" 49 | #include "posix_time.h" 50 | #include "linux_joystick.h" 51 | #include "xkb_unicode.h" 52 | #include "egl_context.h" 53 | 54 | #include "wayland-relative-pointer-unstable-v1-client-protocol.h" 55 | #include "wayland-pointer-constraints-unstable-v1-client-protocol.h" 56 | 57 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 58 | #define _glfw_dlclose(handle) dlclose(handle) 59 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 60 | 61 | #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native) 62 | #define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display) 63 | 64 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl 65 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl 66 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl 67 | #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl 68 | 69 | #define _GLFW_PLATFORM_CONTEXT_STATE 70 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE 71 | 72 | 73 | // Wayland-specific video mode data 74 | // 75 | typedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland; 76 | 77 | 78 | // Wayland-specific per-window data 79 | // 80 | typedef struct _GLFWwindowWayland 81 | { 82 | int width, height; 83 | GLFWbool visible; 84 | GLFWbool maximized; 85 | struct wl_surface* surface; 86 | struct wl_egl_window* native; 87 | struct wl_shell_surface* shell_surface; 88 | struct wl_callback* callback; 89 | 90 | _GLFWcursor* currentCursor; 91 | double cursorPosX, cursorPosY; 92 | 93 | char* title; 94 | 95 | // We need to track the monitors the window spans on to calculate the 96 | // optimal scaling factor. 97 | int scale; 98 | _GLFWmonitor** monitors; 99 | int monitorsCount; 100 | int monitorsSize; 101 | 102 | struct { 103 | struct zwp_relative_pointer_v1* relativePointer; 104 | struct zwp_locked_pointer_v1* lockedPointer; 105 | } pointerLock; 106 | } _GLFWwindowWayland; 107 | 108 | 109 | // Wayland-specific global data 110 | // 111 | typedef struct _GLFWlibraryWayland 112 | { 113 | struct wl_display* display; 114 | struct wl_registry* registry; 115 | struct wl_compositor* compositor; 116 | struct wl_shell* shell; 117 | struct wl_shm* shm; 118 | struct wl_seat* seat; 119 | struct wl_pointer* pointer; 120 | struct wl_keyboard* keyboard; 121 | struct zwp_relative_pointer_manager_v1* relativePointerManager; 122 | struct zwp_pointer_constraints_v1* pointerConstraints; 123 | 124 | int wl_compositor_version; 125 | 126 | struct wl_cursor_theme* cursorTheme; 127 | struct wl_surface* cursorSurface; 128 | uint32_t pointerSerial; 129 | 130 | _GLFWmonitor** monitors; 131 | int monitorsCount; 132 | int monitorsSize; 133 | 134 | short int publicKeys[256]; 135 | 136 | struct { 137 | struct xkb_context* context; 138 | struct xkb_keymap* keymap; 139 | struct xkb_state* state; 140 | xkb_mod_mask_t control_mask; 141 | xkb_mod_mask_t alt_mask; 142 | xkb_mod_mask_t shift_mask; 143 | xkb_mod_mask_t super_mask; 144 | unsigned int modifiers; 145 | } xkb; 146 | 147 | _GLFWwindow* pointerFocus; 148 | _GLFWwindow* keyboardFocus; 149 | 150 | } _GLFWlibraryWayland; 151 | 152 | 153 | // Wayland-specific per-monitor data 154 | // 155 | typedef struct _GLFWmonitorWayland 156 | { 157 | struct wl_output* output; 158 | 159 | _GLFWvidmodeWayland* modes; 160 | int modesCount; 161 | int modesSize; 162 | GLFWbool done; 163 | 164 | int x; 165 | int y; 166 | int scale; 167 | } _GLFWmonitorWayland; 168 | 169 | 170 | // Wayland-specific per-cursor data 171 | // 172 | typedef struct _GLFWcursorWayland 173 | { 174 | struct wl_cursor_image* image; 175 | struct wl_buffer* buffer; 176 | int width, height; 177 | int xhot, yhot; 178 | } _GLFWcursorWayland; 179 | 180 | 181 | void _glfwAddOutputWayland(uint32_t name, uint32_t version); 182 | 183 | #endif // _glfw3_wayland_platform_h_ 184 | -------------------------------------------------------------------------------- /deps/glfw-3.2/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_xkb_unicode_h_ 28 | #define _glfw3_xkb_unicode_h_ 29 | 30 | 31 | long _glfwKeySym2Unicode(unsigned int keysym); 32 | 33 | #endif // _glfw3_xkb_unicode_h_ 34 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw) 3 | 4 | if (BUILD_SHARED_LIBS) 5 | link_libraries("${MATH_LIBRARY}") 6 | endif() 7 | 8 | if (MSVC) 9 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 10 | endif() 11 | 12 | include_directories("${GLFW_SOURCE_DIR}/deps") 13 | 14 | set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h" 15 | "${GLFW_SOURCE_DIR}/deps/glad.c") 16 | set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" 17 | "${GLFW_SOURCE_DIR}/deps/getopt.c") 18 | set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" 19 | "${GLFW_SOURCE_DIR}/deps/tinycthread.c") 20 | 21 | add_executable(clipboard clipboard.c ${GETOPT} ${GLAD}) 22 | add_executable(events events.c ${GETOPT} ${GLAD}) 23 | add_executable(msaa msaa.c ${GETOPT} ${GLAD}) 24 | add_executable(gamma gamma.c ${GETOPT} ${GLAD}) 25 | add_executable(glfwinfo glfwinfo.c ${GETOPT} ${GLAD}) 26 | add_executable(iconify iconify.c ${GETOPT} ${GLAD}) 27 | add_executable(joysticks joysticks.c ${GLAD}) 28 | add_executable(monitors monitors.c ${GETOPT} ${GLAD}) 29 | add_executable(reopen reopen.c ${GLAD}) 30 | add_executable(cursor cursor.c ${GLAD}) 31 | 32 | add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD} ${GLAD}) 33 | add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD}) 34 | add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${GLAD}) 35 | add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD}) 36 | add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD}) 37 | add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD}) 38 | add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD}) 39 | add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD}) 40 | 41 | target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") 42 | target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}") 43 | 44 | set(WINDOWS_BINARIES empty icon sharing tearing threads timeout title windows) 45 | set(CONSOLE_BINARIES clipboard events msaa gamma glfwinfo 46 | iconify joysticks monitors reopen cursor) 47 | 48 | if (VULKAN_FOUND) 49 | add_executable(vulkan WIN32 vulkan.c ${ICON}) 50 | target_include_directories(vulkan PRIVATE "${VULKAN_INCLUDE_DIR}") 51 | target_link_libraries(vulkan "${VULKAN_LIBRARY}") 52 | list(APPEND WINDOWS_BINARIES vulkan) 53 | endif() 54 | 55 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 56 | FOLDER "GLFW3/Tests") 57 | 58 | if (MSVC) 59 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 60 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 61 | LINK_FLAGS "/ENTRY:mainCRTStartup") 62 | endif() 63 | 64 | if (APPLE) 65 | set_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Empty Event") 66 | set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") 67 | set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") 68 | set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") 69 | set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") 70 | set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") 71 | set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") 72 | 73 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 74 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 75 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} 76 | MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") 77 | endif() 78 | 79 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Clipboard test program 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the clipboard functionality. 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "getopt.h" 37 | 38 | #if defined(__APPLE__) 39 | #define MODIFIER GLFW_MOD_SUPER 40 | #else 41 | #define MODIFIER GLFW_MOD_CONTROL 42 | #endif 43 | 44 | static void usage(void) 45 | { 46 | printf("Usage: clipboard [-h]\n"); 47 | } 48 | 49 | static void error_callback(int error, const char* description) 50 | { 51 | fprintf(stderr, "Error: %s\n", description); 52 | } 53 | 54 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 55 | { 56 | if (action != GLFW_PRESS) 57 | return; 58 | 59 | switch (key) 60 | { 61 | case GLFW_KEY_ESCAPE: 62 | glfwSetWindowShouldClose(window, GLFW_TRUE); 63 | break; 64 | 65 | case GLFW_KEY_V: 66 | if (mods == MODIFIER) 67 | { 68 | const char* string; 69 | 70 | string = glfwGetClipboardString(window); 71 | if (string) 72 | printf("Clipboard contains \"%s\"\n", string); 73 | else 74 | printf("Clipboard does not contain a string\n"); 75 | } 76 | break; 77 | 78 | case GLFW_KEY_C: 79 | if (mods == MODIFIER) 80 | { 81 | const char* string = "Hello GLFW World!"; 82 | glfwSetClipboardString(window, string); 83 | printf("Setting clipboard to \"%s\"\n", string); 84 | } 85 | break; 86 | } 87 | } 88 | 89 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 90 | { 91 | glViewport(0, 0, width, height); 92 | } 93 | 94 | int main(int argc, char** argv) 95 | { 96 | int ch; 97 | GLFWwindow* window; 98 | 99 | while ((ch = getopt(argc, argv, "h")) != -1) 100 | { 101 | switch (ch) 102 | { 103 | case 'h': 104 | usage(); 105 | exit(EXIT_SUCCESS); 106 | 107 | default: 108 | usage(); 109 | exit(EXIT_FAILURE); 110 | } 111 | } 112 | 113 | glfwSetErrorCallback(error_callback); 114 | 115 | if (!glfwInit()) 116 | { 117 | fprintf(stderr, "Failed to initialize GLFW\n"); 118 | exit(EXIT_FAILURE); 119 | } 120 | 121 | window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL); 122 | if (!window) 123 | { 124 | glfwTerminate(); 125 | 126 | fprintf(stderr, "Failed to open GLFW window\n"); 127 | exit(EXIT_FAILURE); 128 | } 129 | 130 | glfwMakeContextCurrent(window); 131 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 132 | glfwSwapInterval(1); 133 | 134 | glfwSetKeyCallback(window, key_callback); 135 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 136 | 137 | glMatrixMode(GL_PROJECTION); 138 | glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); 139 | glMatrixMode(GL_MODELVIEW); 140 | 141 | glClearColor(0.5f, 0.5f, 0.5f, 0); 142 | 143 | while (!glfwWindowShouldClose(window)) 144 | { 145 | glClear(GL_COLOR_BUFFER_BIT); 146 | 147 | glColor3f(0.8f, 0.2f, 0.4f); 148 | glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 149 | 150 | glfwSwapBuffers(window); 151 | glfwWaitEvents(); 152 | } 153 | 154 | glfwTerminate(); 155 | exit(EXIT_SUCCESS); 156 | } 157 | 158 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/empty.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Empty event test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test is intended to verify that posting of empty events works 27 | // 28 | //======================================================================== 29 | 30 | #include "tinycthread.h" 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | static volatile int running = GLFW_TRUE; 40 | 41 | static void error_callback(int error, const char* description) 42 | { 43 | fprintf(stderr, "Error: %s\n", description); 44 | } 45 | 46 | static int thread_main(void* data) 47 | { 48 | struct timespec time; 49 | 50 | while (running) 51 | { 52 | clock_gettime(CLOCK_REALTIME, &time); 53 | time.tv_sec += 1; 54 | thrd_sleep(&time, NULL); 55 | 56 | glfwPostEmptyEvent(); 57 | } 58 | 59 | return 0; 60 | } 61 | 62 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 63 | { 64 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 65 | glfwSetWindowShouldClose(window, GLFW_TRUE); 66 | } 67 | 68 | static float nrand(void) 69 | { 70 | return (float) rand() / (float) RAND_MAX; 71 | } 72 | 73 | int main(void) 74 | { 75 | int result; 76 | thrd_t thread; 77 | GLFWwindow* window; 78 | 79 | srand((unsigned int) time(NULL)); 80 | 81 | glfwSetErrorCallback(error_callback); 82 | 83 | if (!glfwInit()) 84 | exit(EXIT_FAILURE); 85 | 86 | window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); 87 | if (!window) 88 | { 89 | glfwTerminate(); 90 | exit(EXIT_FAILURE); 91 | } 92 | 93 | glfwMakeContextCurrent(window); 94 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 95 | glfwSetKeyCallback(window, key_callback); 96 | 97 | if (thrd_create(&thread, thread_main, NULL) != thrd_success) 98 | { 99 | fprintf(stderr, "Failed to create secondary thread\n"); 100 | 101 | glfwTerminate(); 102 | exit(EXIT_FAILURE); 103 | } 104 | 105 | while (running) 106 | { 107 | int width, height; 108 | float r = nrand(), g = nrand(), b = nrand(); 109 | float l = (float) sqrt(r * r + g * g + b * b); 110 | 111 | glfwGetFramebufferSize(window, &width, &height); 112 | 113 | glViewport(0, 0, width, height); 114 | glClearColor(r / l, g / l, b / l, 1.f); 115 | glClear(GL_COLOR_BUFFER_BIT); 116 | glfwSwapBuffers(window); 117 | 118 | glfwWaitEvents(); 119 | 120 | if (glfwWindowShouldClose(window)) 121 | running = GLFW_FALSE; 122 | } 123 | 124 | glfwHideWindow(window); 125 | thrd_join(thread, &result); 126 | glfwDestroyWindow(window); 127 | 128 | glfwTerminate(); 129 | exit(EXIT_SUCCESS); 130 | } 131 | 132 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Gamma correction test program 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the gamma correction functionality for 27 | // both full screen and windowed mode windows 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #include "getopt.h" 38 | 39 | #define STEP_SIZE 0.1f 40 | 41 | static GLfloat gamma_value = 1.0f; 42 | 43 | static void usage(void) 44 | { 45 | printf("Usage: gamma [-h] [-f]\n"); 46 | } 47 | 48 | static void set_gamma(GLFWwindow* window, float value) 49 | { 50 | GLFWmonitor* monitor = glfwGetWindowMonitor(window); 51 | if (!monitor) 52 | monitor = glfwGetPrimaryMonitor(); 53 | 54 | gamma_value = value; 55 | printf("Gamma: %f\n", gamma_value); 56 | glfwSetGamma(monitor, gamma_value); 57 | } 58 | 59 | static void error_callback(int error, const char* description) 60 | { 61 | fprintf(stderr, "Error: %s\n", description); 62 | } 63 | 64 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 65 | { 66 | if (action != GLFW_PRESS) 67 | return; 68 | 69 | switch (key) 70 | { 71 | case GLFW_KEY_ESCAPE: 72 | { 73 | glfwSetWindowShouldClose(window, GLFW_TRUE); 74 | break; 75 | } 76 | 77 | case GLFW_KEY_KP_ADD: 78 | case GLFW_KEY_UP: 79 | case GLFW_KEY_Q: 80 | { 81 | set_gamma(window, gamma_value + STEP_SIZE); 82 | break; 83 | } 84 | 85 | case GLFW_KEY_KP_SUBTRACT: 86 | case GLFW_KEY_DOWN: 87 | case GLFW_KEY_W: 88 | { 89 | if (gamma_value - STEP_SIZE > 0.f) 90 | set_gamma(window, gamma_value - STEP_SIZE); 91 | 92 | break; 93 | } 94 | } 95 | } 96 | 97 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 98 | { 99 | glViewport(0, 0, width, height); 100 | } 101 | 102 | int main(int argc, char** argv) 103 | { 104 | int width, height, ch; 105 | GLFWmonitor* monitor = NULL; 106 | GLFWwindow* window; 107 | 108 | glfwSetErrorCallback(error_callback); 109 | 110 | if (!glfwInit()) 111 | exit(EXIT_FAILURE); 112 | 113 | while ((ch = getopt(argc, argv, "fh")) != -1) 114 | { 115 | switch (ch) 116 | { 117 | case 'h': 118 | usage(); 119 | exit(EXIT_SUCCESS); 120 | 121 | case 'f': 122 | monitor = glfwGetPrimaryMonitor(); 123 | break; 124 | 125 | default: 126 | usage(); 127 | exit(EXIT_FAILURE); 128 | } 129 | } 130 | 131 | if (monitor) 132 | { 133 | const GLFWvidmode* mode = glfwGetVideoMode(monitor); 134 | 135 | glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); 136 | glfwWindowHint(GLFW_RED_BITS, mode->redBits); 137 | glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); 138 | glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); 139 | 140 | width = mode->width; 141 | height = mode->height; 142 | } 143 | else 144 | { 145 | width = 200; 146 | height = 200; 147 | } 148 | 149 | window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL); 150 | if (!window) 151 | { 152 | glfwTerminate(); 153 | exit(EXIT_FAILURE); 154 | } 155 | 156 | set_gamma(window, 1.f); 157 | 158 | glfwMakeContextCurrent(window); 159 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 160 | glfwSwapInterval(1); 161 | 162 | glfwSetKeyCallback(window, key_callback); 163 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 164 | 165 | glMatrixMode(GL_PROJECTION); 166 | glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); 167 | glMatrixMode(GL_MODELVIEW); 168 | 169 | glClearColor(0.5f, 0.5f, 0.5f, 0); 170 | 171 | while (!glfwWindowShouldClose(window)) 172 | { 173 | glClear(GL_COLOR_BUFFER_BIT); 174 | 175 | glColor3f(0.8f, 0.2f, 0.4f); 176 | glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 177 | 178 | glfwSwapBuffers(window); 179 | glfwWaitEvents(); 180 | } 181 | 182 | glfwTerminate(); 183 | exit(EXIT_SUCCESS); 184 | } 185 | 186 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/icon.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Window icon test program 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the icon feature. 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | // a simple glfw logo 38 | const char* const logo[] = 39 | { 40 | "................", 41 | "................", 42 | "...0000..0......", 43 | "...0.....0......", 44 | "...0.00..0......", 45 | "...0..0..0......", 46 | "...0000..0000...", 47 | "................", 48 | "................", 49 | "...000..0...0...", 50 | "...0....0...0...", 51 | "...000..0.0.0...", 52 | "...0....0.0.0...", 53 | "...0....00000...", 54 | "................", 55 | "................" 56 | }; 57 | 58 | const unsigned char icon_colors[5][4] = 59 | { 60 | { 0, 0, 0, 255 }, // black 61 | { 255, 0, 0, 255 }, // red 62 | { 0, 255, 0, 255 }, // green 63 | { 0, 0, 255, 255 }, // blue 64 | { 255, 255, 255, 255 } // white 65 | }; 66 | 67 | static int cur_icon_color = 0; 68 | 69 | static void set_icon(GLFWwindow* window, int icon_color) 70 | { 71 | int x, y; 72 | unsigned char pixels[16 * 16 * 4]; 73 | unsigned char* target = pixels; 74 | GLFWimage img = { 16, 16, pixels }; 75 | 76 | for (y = 0; y < img.width; y++) 77 | { 78 | for (x = 0; x < img.height; x++) 79 | { 80 | if (logo[y][x] == '0') 81 | memcpy(target, icon_colors[icon_color], 4); 82 | else 83 | memset(target, 0, 4); 84 | 85 | target += 4; 86 | } 87 | } 88 | 89 | glfwSetWindowIcon(window, 1, &img); 90 | } 91 | 92 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 93 | { 94 | if (action != GLFW_PRESS) 95 | return; 96 | 97 | switch (key) 98 | { 99 | case GLFW_KEY_ESCAPE: 100 | glfwSetWindowShouldClose(window, GLFW_TRUE); 101 | break; 102 | case GLFW_KEY_SPACE: 103 | cur_icon_color = (cur_icon_color + 1) % 5; 104 | set_icon(window, cur_icon_color); 105 | break; 106 | case GLFW_KEY_X: 107 | glfwSetWindowIcon(window, 0, NULL); 108 | break; 109 | } 110 | } 111 | 112 | int main(int argc, char** argv) 113 | { 114 | GLFWwindow* window; 115 | 116 | if (!glfwInit()) 117 | { 118 | fprintf(stderr, "Failed to initialize GLFW\n"); 119 | exit(EXIT_FAILURE); 120 | } 121 | 122 | window = glfwCreateWindow(200, 200, "Window Icon", NULL, NULL); 123 | if (!window) 124 | { 125 | glfwTerminate(); 126 | 127 | fprintf(stderr, "Failed to open GLFW window\n"); 128 | exit(EXIT_FAILURE); 129 | } 130 | 131 | glfwMakeContextCurrent(window); 132 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 133 | 134 | glfwSetKeyCallback(window, key_callback); 135 | set_icon(window, cur_icon_color); 136 | 137 | while (!glfwWindowShouldClose(window)) 138 | { 139 | glClear(GL_COLOR_BUFFER_BIT); 140 | glfwSwapBuffers(window); 141 | glfwWaitEvents(); 142 | } 143 | 144 | glfwDestroyWindow(window); 145 | glfwTerminate(); 146 | exit(EXIT_SUCCESS); 147 | } 148 | 149 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/joysticks.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Joystick input test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test displays the state of every button and axis of every connected 27 | // joystick and/or gamepad 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #ifdef _MSC_VER 39 | #define strdup(x) _strdup(x) 40 | #endif 41 | 42 | static int joysticks[GLFW_JOYSTICK_LAST + 1]; 43 | static int joystick_count = 0; 44 | 45 | static void error_callback(int error, const char* description) 46 | { 47 | fprintf(stderr, "Error: %s\n", description); 48 | } 49 | 50 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 51 | { 52 | glViewport(0, 0, width, height); 53 | } 54 | 55 | static void draw_joystick(int index, int x, int y, int width, int height) 56 | { 57 | int i; 58 | int axis_count, button_count; 59 | const float* axes; 60 | const unsigned char* buttons; 61 | const int axis_height = 3 * height / 4; 62 | const int button_height = height / 4; 63 | 64 | axes = glfwGetJoystickAxes(joysticks[index], &axis_count); 65 | if (axis_count) 66 | { 67 | const int axis_width = width / axis_count; 68 | 69 | for (i = 0; i < axis_count; i++) 70 | { 71 | float value = axes[i] / 2.f + 0.5f; 72 | 73 | glColor3f(0.3f, 0.3f, 0.3f); 74 | glRecti(x + i * axis_width, 75 | y, 76 | x + (i + 1) * axis_width, 77 | y + axis_height); 78 | 79 | glColor3f(1.f, 1.f, 1.f); 80 | glRecti(x + i * axis_width, 81 | y + (int) (value * (axis_height - 5)), 82 | x + (i + 1) * axis_width, 83 | y + 5 + (int) (value * (axis_height - 5))); 84 | } 85 | } 86 | 87 | buttons = glfwGetJoystickButtons(joysticks[index], &button_count); 88 | if (button_count) 89 | { 90 | const int button_width = width / button_count; 91 | 92 | for (i = 0; i < button_count; i++) 93 | { 94 | if (buttons[i]) 95 | glColor3f(1.f, 1.f, 1.f); 96 | else 97 | glColor3f(0.3f, 0.3f, 0.3f); 98 | 99 | glRecti(x + i * button_width, 100 | y + axis_height, 101 | x + (i + 1) * button_width, 102 | y + axis_height + button_height); 103 | } 104 | } 105 | } 106 | 107 | static void draw_joysticks(GLFWwindow* window) 108 | { 109 | int i, width, height, offset = 0; 110 | 111 | glfwGetFramebufferSize(window, &width, &height); 112 | 113 | glMatrixMode(GL_PROJECTION); 114 | glLoadIdentity(); 115 | glOrtho(0.f, width, height, 0.f, 1.f, -1.f); 116 | glMatrixMode(GL_MODELVIEW); 117 | 118 | for (i = 0; i < joystick_count; i++) 119 | { 120 | draw_joystick(i, 121 | 0, offset * height / joystick_count, 122 | width, height / joystick_count); 123 | offset++; 124 | } 125 | } 126 | 127 | static void joystick_callback(int joy, int event) 128 | { 129 | if (event == GLFW_CONNECTED) 130 | { 131 | int axis_count, button_count; 132 | 133 | glfwGetJoystickAxes(joy, &axis_count); 134 | glfwGetJoystickButtons(joy, &button_count); 135 | 136 | printf("Found joystick %i named \'%s\' with %i axes, %i buttons\n", 137 | joy + 1, 138 | glfwGetJoystickName(joy), 139 | axis_count, 140 | button_count); 141 | 142 | joysticks[joystick_count++] = joy; 143 | } 144 | else if (event == GLFW_DISCONNECTED) 145 | { 146 | int i; 147 | 148 | for (i = 0; i < joystick_count; i++) 149 | { 150 | if (joysticks[i] == joy) 151 | break; 152 | } 153 | 154 | for (i = i + 1; i < joystick_count; i++) 155 | joysticks[i - 1] = joysticks[i]; 156 | 157 | printf("Lost joystick %i\n", joy + 1); 158 | joystick_count--; 159 | } 160 | } 161 | 162 | static void find_joysticks(void) 163 | { 164 | int joy; 165 | 166 | for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++) 167 | { 168 | if (glfwJoystickPresent(joy)) 169 | joystick_callback(joy, GLFW_CONNECTED); 170 | } 171 | } 172 | 173 | int main(void) 174 | { 175 | GLFWwindow* window; 176 | 177 | memset(joysticks, 0, sizeof(joysticks)); 178 | 179 | glfwSetErrorCallback(error_callback); 180 | 181 | if (!glfwInit()) 182 | exit(EXIT_FAILURE); 183 | 184 | find_joysticks(); 185 | glfwSetJoystickCallback(joystick_callback); 186 | 187 | window = glfwCreateWindow(640, 480, "Joystick Test", NULL, NULL); 188 | if (!window) 189 | { 190 | glfwTerminate(); 191 | exit(EXIT_FAILURE); 192 | } 193 | 194 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 195 | 196 | glfwMakeContextCurrent(window); 197 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 198 | glfwSwapInterval(1); 199 | 200 | while (!glfwWindowShouldClose(window)) 201 | { 202 | glClear(GL_COLOR_BUFFER_BIT); 203 | 204 | draw_joysticks(window); 205 | 206 | glfwSwapBuffers(window); 207 | glfwPollEvents(); 208 | 209 | // Workaround for an issue with msvcrt and mintty 210 | fflush(stdout); 211 | } 212 | 213 | glfwTerminate(); 214 | exit(EXIT_SUCCESS); 215 | } 216 | 217 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/monitors.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Monitor information tool 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test prints monitor and video mode information or verifies video 27 | // modes 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "getopt.h" 39 | 40 | enum Mode 41 | { 42 | LIST_MODE, 43 | TEST_MODE 44 | }; 45 | 46 | static void usage(void) 47 | { 48 | printf("Usage: monitors [-t]\n"); 49 | printf(" monitors -h\n"); 50 | } 51 | 52 | static const char* format_mode(const GLFWvidmode* mode) 53 | { 54 | static char buffer[512]; 55 | 56 | sprintf(buffer, 57 | "%i x %i x %i (%i %i %i) %i Hz", 58 | mode->width, mode->height, 59 | mode->redBits + mode->greenBits + mode->blueBits, 60 | mode->redBits, mode->greenBits, mode->blueBits, 61 | mode->refreshRate); 62 | 63 | buffer[sizeof(buffer) - 1] = '\0'; 64 | return buffer; 65 | } 66 | 67 | static void error_callback(int error, const char* description) 68 | { 69 | fprintf(stderr, "Error: %s\n", description); 70 | } 71 | 72 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 73 | { 74 | printf("Framebuffer resized to %ix%i\n", width, height); 75 | 76 | glViewport(0, 0, width, height); 77 | } 78 | 79 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 80 | { 81 | if (key == GLFW_KEY_ESCAPE) 82 | glfwSetWindowShouldClose(window, GLFW_TRUE); 83 | } 84 | 85 | static void list_modes(GLFWmonitor* monitor) 86 | { 87 | int count, x, y, widthMM, heightMM, i; 88 | const GLFWvidmode* mode = glfwGetVideoMode(monitor); 89 | const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); 90 | 91 | glfwGetMonitorPos(monitor, &x, &y); 92 | glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); 93 | 94 | printf("Name: %s (%s)\n", 95 | glfwGetMonitorName(monitor), 96 | glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary"); 97 | printf("Current mode: %s\n", format_mode(mode)); 98 | printf("Virtual position: %i %i\n", x, y); 99 | 100 | printf("Physical size: %i x %i mm (%0.2f dpi)\n", 101 | widthMM, heightMM, mode->width * 25.4f / widthMM); 102 | 103 | printf("Modes:\n"); 104 | 105 | for (i = 0; i < count; i++) 106 | { 107 | printf("%3u: %s", (unsigned int) i, format_mode(modes + i)); 108 | 109 | if (memcmp(mode, modes + i, sizeof(GLFWvidmode)) == 0) 110 | printf(" (current mode)"); 111 | 112 | putchar('\n'); 113 | } 114 | } 115 | 116 | static void test_modes(GLFWmonitor* monitor) 117 | { 118 | int i, count; 119 | GLFWwindow* window; 120 | const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); 121 | 122 | for (i = 0; i < count; i++) 123 | { 124 | const GLFWvidmode* mode = modes + i; 125 | GLFWvidmode current; 126 | 127 | glfwWindowHint(GLFW_RED_BITS, mode->redBits); 128 | glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); 129 | glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); 130 | glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); 131 | 132 | printf("Testing mode %u on monitor %s: %s\n", 133 | (unsigned int) i, 134 | glfwGetMonitorName(monitor), 135 | format_mode(mode)); 136 | 137 | window = glfwCreateWindow(mode->width, mode->height, 138 | "Video Mode Test", 139 | glfwGetPrimaryMonitor(), 140 | NULL); 141 | if (!window) 142 | { 143 | printf("Failed to enter mode %u: %s\n", 144 | (unsigned int) i, 145 | format_mode(mode)); 146 | continue; 147 | } 148 | 149 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 150 | glfwSetKeyCallback(window, key_callback); 151 | 152 | glfwMakeContextCurrent(window); 153 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 154 | glfwSwapInterval(1); 155 | 156 | glfwSetTime(0.0); 157 | 158 | while (glfwGetTime() < 5.0) 159 | { 160 | glClear(GL_COLOR_BUFFER_BIT); 161 | glfwSwapBuffers(window); 162 | glfwPollEvents(); 163 | 164 | if (glfwWindowShouldClose(window)) 165 | { 166 | printf("User terminated program\n"); 167 | 168 | glfwTerminate(); 169 | exit(EXIT_SUCCESS); 170 | } 171 | } 172 | 173 | glGetIntegerv(GL_RED_BITS, ¤t.redBits); 174 | glGetIntegerv(GL_GREEN_BITS, ¤t.greenBits); 175 | glGetIntegerv(GL_BLUE_BITS, ¤t.blueBits); 176 | 177 | glfwGetWindowSize(window, ¤t.width, ¤t.height); 178 | 179 | if (current.redBits != mode->redBits || 180 | current.greenBits != mode->greenBits || 181 | current.blueBits != mode->blueBits) 182 | { 183 | printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n", 184 | current.redBits, current.greenBits, current.blueBits, 185 | mode->redBits, mode->greenBits, mode->blueBits); 186 | } 187 | 188 | if (current.width != mode->width || current.height != mode->height) 189 | { 190 | printf("*** Size mismatch: %ix%i instead of %ix%i\n", 191 | current.width, current.height, 192 | mode->width, mode->height); 193 | } 194 | 195 | printf("Closing window\n"); 196 | 197 | glfwDestroyWindow(window); 198 | window = NULL; 199 | 200 | glfwPollEvents(); 201 | } 202 | } 203 | 204 | int main(int argc, char** argv) 205 | { 206 | int ch, i, count, mode = LIST_MODE; 207 | GLFWmonitor** monitors; 208 | 209 | while ((ch = getopt(argc, argv, "th")) != -1) 210 | { 211 | switch (ch) 212 | { 213 | case 'h': 214 | usage(); 215 | exit(EXIT_SUCCESS); 216 | case 't': 217 | mode = TEST_MODE; 218 | break; 219 | default: 220 | usage(); 221 | exit(EXIT_FAILURE); 222 | } 223 | } 224 | 225 | glfwSetErrorCallback(error_callback); 226 | 227 | if (!glfwInit()) 228 | exit(EXIT_FAILURE); 229 | 230 | monitors = glfwGetMonitors(&count); 231 | 232 | for (i = 0; i < count; i++) 233 | { 234 | if (mode == LIST_MODE) 235 | list_modes(monitors[i]); 236 | else if (mode == TEST_MODE) 237 | test_modes(monitors[i]); 238 | } 239 | 240 | glfwTerminate(); 241 | exit(EXIT_SUCCESS); 242 | } 243 | 244 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/msaa.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Multisample anti-aliasing test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test renders two high contrast, slowly rotating quads, one aliased 27 | // and one (hopefully) anti-aliased, thus allowing for visual verification 28 | // of whether MSAA is indeed enabled 29 | // 30 | //======================================================================== 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include "getopt.h" 39 | 40 | static void error_callback(int error, const char* description) 41 | { 42 | fprintf(stderr, "Error: %s\n", description); 43 | } 44 | 45 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 46 | { 47 | glViewport(0, 0, width, height); 48 | } 49 | 50 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 51 | { 52 | if (action != GLFW_PRESS) 53 | return; 54 | 55 | switch (key) 56 | { 57 | case GLFW_KEY_SPACE: 58 | glfwSetTime(0.0); 59 | break; 60 | } 61 | } 62 | 63 | static void usage(void) 64 | { 65 | printf("Usage: msaa [-h] [-s SAMPLES]\n"); 66 | } 67 | 68 | int main(int argc, char** argv) 69 | { 70 | int ch, samples = 4; 71 | GLFWwindow* window; 72 | 73 | while ((ch = getopt(argc, argv, "hs:")) != -1) 74 | { 75 | switch (ch) 76 | { 77 | case 'h': 78 | usage(); 79 | exit(EXIT_SUCCESS); 80 | case 's': 81 | samples = atoi(optarg); 82 | break; 83 | default: 84 | usage(); 85 | exit(EXIT_FAILURE); 86 | } 87 | } 88 | 89 | glfwSetErrorCallback(error_callback); 90 | 91 | if (!glfwInit()) 92 | exit(EXIT_FAILURE); 93 | 94 | if (samples) 95 | printf("Requesting MSAA with %i samples\n", samples); 96 | else 97 | printf("Requesting that MSAA not be available\n"); 98 | 99 | glfwWindowHint(GLFW_SAMPLES, samples); 100 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 101 | 102 | window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL); 103 | if (!window) 104 | { 105 | glfwTerminate(); 106 | exit(EXIT_FAILURE); 107 | } 108 | 109 | glfwSetKeyCallback(window, key_callback); 110 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 111 | 112 | glfwMakeContextCurrent(window); 113 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 114 | glfwSwapInterval(1); 115 | 116 | if (!GLAD_GL_ARB_multisample && !GLAD_GL_VERSION_1_3) 117 | { 118 | printf("Multisampling is not supported\n"); 119 | 120 | glfwTerminate(); 121 | exit(EXIT_FAILURE); 122 | } 123 | 124 | glfwShowWindow(window); 125 | 126 | glGetIntegerv(GL_SAMPLES, &samples); 127 | if (samples) 128 | printf("Context reports MSAA is available with %i samples\n", samples); 129 | else 130 | printf("Context reports MSAA is unavailable\n"); 131 | 132 | glMatrixMode(GL_PROJECTION); 133 | glOrtho(0.f, 1.f, 0.f, 0.5f, 0.f, 1.f); 134 | glMatrixMode(GL_MODELVIEW); 135 | 136 | while (!glfwWindowShouldClose(window)) 137 | { 138 | GLfloat time = (GLfloat) glfwGetTime(); 139 | 140 | glClear(GL_COLOR_BUFFER_BIT); 141 | 142 | glLoadIdentity(); 143 | glTranslatef(0.25f, 0.25f, 0.f); 144 | glRotatef(time, 0.f, 0.f, 1.f); 145 | 146 | glDisable(GL_MULTISAMPLE_ARB); 147 | glRectf(-0.15f, -0.15f, 0.15f, 0.15f); 148 | 149 | glLoadIdentity(); 150 | glTranslatef(0.75f, 0.25f, 0.f); 151 | glRotatef(time, 0.f, 0.f, 1.f); 152 | 153 | glEnable(GL_MULTISAMPLE_ARB); 154 | glRectf(-0.15f, -0.15f, 0.15f, 0.15f); 155 | 156 | glfwSwapBuffers(window); 157 | glfwPollEvents(); 158 | } 159 | 160 | glfwTerminate(); 161 | exit(EXIT_SUCCESS); 162 | } 163 | 164 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/reopen.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Window re-opener (open/close stress test) 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bug #1262773 27 | // 28 | // It closes and re-opens the GLFW window every five seconds, alternating 29 | // between windowed and full screen mode 30 | // 31 | // It also times and logs opening and closing actions and attempts to separate 32 | // user initiated window closing from its own 33 | // 34 | //======================================================================== 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | static void error_callback(int error, const char* description) 44 | { 45 | fprintf(stderr, "Error: %s\n", description); 46 | } 47 | 48 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 49 | { 50 | glViewport(0, 0, width, height); 51 | } 52 | 53 | static void window_close_callback(GLFWwindow* window) 54 | { 55 | printf("Close callback triggered\n"); 56 | } 57 | 58 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 59 | { 60 | if (action != GLFW_PRESS) 61 | return; 62 | 63 | switch (key) 64 | { 65 | case GLFW_KEY_Q: 66 | case GLFW_KEY_ESCAPE: 67 | glfwSetWindowShouldClose(window, GLFW_TRUE); 68 | break; 69 | } 70 | } 71 | 72 | static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor) 73 | { 74 | double base; 75 | GLFWwindow* window; 76 | 77 | base = glfwGetTime(); 78 | 79 | window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); 80 | if (!window) 81 | return NULL; 82 | 83 | glfwMakeContextCurrent(window); 84 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 85 | glfwSwapInterval(1); 86 | 87 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 88 | glfwSetWindowCloseCallback(window, window_close_callback); 89 | glfwSetKeyCallback(window, key_callback); 90 | 91 | if (monitor) 92 | { 93 | printf("Opening full screen window on monitor %s took %0.3f seconds\n", 94 | glfwGetMonitorName(monitor), 95 | glfwGetTime() - base); 96 | } 97 | else 98 | { 99 | printf("Opening regular window took %0.3f seconds\n", 100 | glfwGetTime() - base); 101 | } 102 | 103 | return window; 104 | } 105 | 106 | static void close_window(GLFWwindow* window) 107 | { 108 | double base = glfwGetTime(); 109 | glfwDestroyWindow(window); 110 | printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); 111 | } 112 | 113 | int main(int argc, char** argv) 114 | { 115 | int count = 0; 116 | GLFWwindow* window; 117 | 118 | srand((unsigned int) time(NULL)); 119 | 120 | glfwSetErrorCallback(error_callback); 121 | 122 | if (!glfwInit()) 123 | exit(EXIT_FAILURE); 124 | 125 | for (;;) 126 | { 127 | int width, height; 128 | GLFWmonitor* monitor = NULL; 129 | 130 | if (count % 2 == 0) 131 | { 132 | int monitorCount; 133 | GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); 134 | monitor = monitors[rand() % monitorCount]; 135 | } 136 | 137 | if (monitor) 138 | { 139 | const GLFWvidmode* mode = glfwGetVideoMode(monitor); 140 | width = mode->width; 141 | height = mode->height; 142 | } 143 | else 144 | { 145 | width = 640; 146 | height = 480; 147 | } 148 | 149 | window = open_window(width, height, monitor); 150 | if (!window) 151 | { 152 | glfwTerminate(); 153 | exit(EXIT_FAILURE); 154 | } 155 | 156 | glMatrixMode(GL_PROJECTION); 157 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 158 | glMatrixMode(GL_MODELVIEW); 159 | 160 | glfwSetTime(0.0); 161 | 162 | while (glfwGetTime() < 5.0) 163 | { 164 | glClear(GL_COLOR_BUFFER_BIT); 165 | 166 | glPushMatrix(); 167 | glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f); 168 | glRectf(-0.5f, -0.5f, 1.f, 1.f); 169 | glPopMatrix(); 170 | 171 | glfwSwapBuffers(window); 172 | glfwPollEvents(); 173 | 174 | if (glfwWindowShouldClose(window)) 175 | { 176 | close_window(window); 177 | printf("User closed window\n"); 178 | 179 | glfwTerminate(); 180 | exit(EXIT_SUCCESS); 181 | } 182 | } 183 | 184 | printf("Closing window\n"); 185 | close_window(window); 186 | 187 | count++; 188 | } 189 | 190 | glfwTerminate(); 191 | } 192 | 193 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/sharing.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Context sharing test program 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test sharing of objects between contexts 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #define WIDTH 400 37 | #define HEIGHT 400 38 | #define OFFSET 50 39 | 40 | static GLFWwindow* windows[2]; 41 | 42 | static void error_callback(int error, const char* description) 43 | { 44 | fprintf(stderr, "Error: %s\n", description); 45 | } 46 | 47 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 48 | { 49 | if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) 50 | glfwSetWindowShouldClose(window, GLFW_TRUE); 51 | } 52 | 53 | static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY) 54 | { 55 | GLFWwindow* window; 56 | 57 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 58 | window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share); 59 | if (!window) 60 | return NULL; 61 | 62 | glfwMakeContextCurrent(window); 63 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 64 | glfwSwapInterval(1); 65 | glfwSetWindowPos(window, posX, posY); 66 | glfwShowWindow(window); 67 | 68 | glfwSetKeyCallback(window, key_callback); 69 | 70 | return window; 71 | } 72 | 73 | static GLuint create_texture(void) 74 | { 75 | int x, y; 76 | char pixels[256 * 256]; 77 | GLuint texture; 78 | 79 | glGenTextures(1, &texture); 80 | glBindTexture(GL_TEXTURE_2D, texture); 81 | 82 | for (y = 0; y < 256; y++) 83 | { 84 | for (x = 0; x < 256; x++) 85 | pixels[y * 256 + x] = rand() % 256; 86 | } 87 | 88 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels); 89 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 90 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 91 | 92 | return texture; 93 | } 94 | 95 | static void draw_quad(GLuint texture) 96 | { 97 | int width, height; 98 | glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height); 99 | 100 | glViewport(0, 0, width, height); 101 | 102 | glMatrixMode(GL_PROJECTION); 103 | glLoadIdentity(); 104 | glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f); 105 | 106 | glEnable(GL_TEXTURE_2D); 107 | glBindTexture(GL_TEXTURE_2D, texture); 108 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 109 | 110 | glBegin(GL_QUADS); 111 | 112 | glTexCoord2f(0.f, 0.f); 113 | glVertex2f(0.f, 0.f); 114 | 115 | glTexCoord2f(1.f, 0.f); 116 | glVertex2f(1.f, 0.f); 117 | 118 | glTexCoord2f(1.f, 1.f); 119 | glVertex2f(1.f, 1.f); 120 | 121 | glTexCoord2f(0.f, 1.f); 122 | glVertex2f(0.f, 1.f); 123 | 124 | glEnd(); 125 | } 126 | 127 | int main(int argc, char** argv) 128 | { 129 | int x, y, width; 130 | GLuint texture; 131 | 132 | glfwSetErrorCallback(error_callback); 133 | 134 | if (!glfwInit()) 135 | exit(EXIT_FAILURE); 136 | 137 | windows[0] = open_window("First", NULL, OFFSET, OFFSET); 138 | if (!windows[0]) 139 | { 140 | glfwTerminate(); 141 | exit(EXIT_FAILURE); 142 | } 143 | 144 | // This is the one and only time we create a texture 145 | // It is created inside the first context, created above 146 | // It will then be shared with the second context, created below 147 | texture = create_texture(); 148 | 149 | glfwGetWindowPos(windows[0], &x, &y); 150 | glfwGetWindowSize(windows[0], &width, NULL); 151 | 152 | // Put the second window to the right of the first one 153 | windows[1] = open_window("Second", windows[0], x + width + OFFSET, y); 154 | if (!windows[1]) 155 | { 156 | glfwTerminate(); 157 | exit(EXIT_FAILURE); 158 | } 159 | 160 | // Set drawing color for both contexts 161 | glfwMakeContextCurrent(windows[0]); 162 | glColor3f(0.6f, 0.f, 0.6f); 163 | glfwMakeContextCurrent(windows[1]); 164 | glColor3f(0.6f, 0.6f, 0.f); 165 | 166 | glfwMakeContextCurrent(windows[0]); 167 | 168 | while (!glfwWindowShouldClose(windows[0]) && 169 | !glfwWindowShouldClose(windows[1])) 170 | { 171 | glfwMakeContextCurrent(windows[0]); 172 | draw_quad(texture); 173 | 174 | glfwMakeContextCurrent(windows[1]); 175 | draw_quad(texture); 176 | 177 | glfwSwapBuffers(windows[0]); 178 | glfwSwapBuffers(windows[1]); 179 | 180 | glfwWaitEvents(); 181 | } 182 | 183 | glfwTerminate(); 184 | exit(EXIT_SUCCESS); 185 | } 186 | 187 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/tearing.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Vsync enabling test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test renders a high contrast, horizontally moving bar, allowing for 27 | // visual verification of whether the set swap interval is indeed obeyed 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "getopt.h" 39 | 40 | static int swap_tear; 41 | static int swap_interval; 42 | static double frame_rate; 43 | 44 | static void usage(void) 45 | { 46 | printf("Usage: iconify [-h] [-f]\n"); 47 | printf("Options:\n"); 48 | printf(" -f create full screen window\n"); 49 | printf(" -h show this help\n"); 50 | } 51 | 52 | static void update_window_title(GLFWwindow* window) 53 | { 54 | char title[256]; 55 | 56 | sprintf(title, "Tearing detector (interval %i%s, %0.1f Hz)", 57 | swap_interval, 58 | (swap_tear && swap_interval < 0) ? " (swap tear)" : "", 59 | frame_rate); 60 | 61 | glfwSetWindowTitle(window, title); 62 | } 63 | 64 | static void set_swap_interval(GLFWwindow* window, int interval) 65 | { 66 | swap_interval = interval; 67 | glfwSwapInterval(swap_interval); 68 | update_window_title(window); 69 | } 70 | 71 | static void error_callback(int error, const char* description) 72 | { 73 | fprintf(stderr, "Error: %s\n", description); 74 | } 75 | 76 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 77 | { 78 | glViewport(0, 0, width, height); 79 | } 80 | 81 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 82 | { 83 | if (action != GLFW_PRESS) 84 | return; 85 | 86 | switch (key) 87 | { 88 | case GLFW_KEY_UP: 89 | { 90 | if (swap_interval + 1 > swap_interval) 91 | set_swap_interval(window, swap_interval + 1); 92 | break; 93 | } 94 | 95 | case GLFW_KEY_DOWN: 96 | { 97 | if (swap_tear) 98 | { 99 | if (swap_interval - 1 < swap_interval) 100 | set_swap_interval(window, swap_interval - 1); 101 | } 102 | else 103 | { 104 | if (swap_interval - 1 >= 0) 105 | set_swap_interval(window, swap_interval - 1); 106 | } 107 | break; 108 | } 109 | 110 | case GLFW_KEY_ESCAPE: 111 | glfwSetWindowShouldClose(window, 1); 112 | break; 113 | } 114 | } 115 | 116 | int main(int argc, char** argv) 117 | { 118 | int ch, width, height; 119 | float position; 120 | unsigned long frame_count = 0; 121 | double last_time, current_time; 122 | int fullscreen = GLFW_FALSE; 123 | GLFWmonitor* monitor = NULL; 124 | GLFWwindow* window; 125 | 126 | while ((ch = getopt(argc, argv, "fh")) != -1) 127 | { 128 | switch (ch) 129 | { 130 | case 'h': 131 | usage(); 132 | exit(EXIT_SUCCESS); 133 | 134 | case 'f': 135 | fullscreen = GLFW_TRUE; 136 | break; 137 | } 138 | } 139 | 140 | glfwSetErrorCallback(error_callback); 141 | 142 | if (!glfwInit()) 143 | exit(EXIT_FAILURE); 144 | 145 | if (fullscreen) 146 | { 147 | const GLFWvidmode* mode; 148 | 149 | monitor = glfwGetPrimaryMonitor(); 150 | mode = glfwGetVideoMode(monitor); 151 | 152 | glfwWindowHint(GLFW_RED_BITS, mode->redBits); 153 | glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); 154 | glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); 155 | glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); 156 | 157 | width = mode->width; 158 | height = mode->height; 159 | } 160 | else 161 | { 162 | width = 640; 163 | height = 480; 164 | } 165 | 166 | window = glfwCreateWindow(width, height, "", monitor, NULL); 167 | if (!window) 168 | { 169 | glfwTerminate(); 170 | exit(EXIT_FAILURE); 171 | } 172 | 173 | glfwMakeContextCurrent(window); 174 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 175 | set_swap_interval(window, 0); 176 | 177 | last_time = glfwGetTime(); 178 | frame_rate = 0.0; 179 | swap_tear = (glfwExtensionSupported("WGL_EXT_swap_control_tear") || 180 | glfwExtensionSupported("GLX_EXT_swap_control_tear")); 181 | 182 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 183 | glfwSetKeyCallback(window, key_callback); 184 | 185 | glMatrixMode(GL_PROJECTION); 186 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 187 | glMatrixMode(GL_MODELVIEW); 188 | 189 | while (!glfwWindowShouldClose(window)) 190 | { 191 | glClear(GL_COLOR_BUFFER_BIT); 192 | 193 | position = cosf((float) glfwGetTime() * 4.f) * 0.75f; 194 | glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); 195 | 196 | glfwSwapBuffers(window); 197 | glfwPollEvents(); 198 | 199 | frame_count++; 200 | 201 | current_time = glfwGetTime(); 202 | if (current_time - last_time > 1.0) 203 | { 204 | frame_rate = frame_count / (current_time - last_time); 205 | frame_count = 0; 206 | last_time = current_time; 207 | update_window_title(window); 208 | } 209 | } 210 | 211 | glfwTerminate(); 212 | exit(EXIT_SUCCESS); 213 | } 214 | 215 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/threads.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Multi-threading test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test is intended to verify whether the OpenGL context part of 27 | // the GLFW API is able to be used from multiple threads 28 | // 29 | //======================================================================== 30 | 31 | #include "tinycthread.h" 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | typedef struct 41 | { 42 | GLFWwindow* window; 43 | const char* title; 44 | float r, g, b; 45 | thrd_t id; 46 | } Thread; 47 | 48 | static volatile int running = GLFW_TRUE; 49 | 50 | static void error_callback(int error, const char* description) 51 | { 52 | fprintf(stderr, "Error: %s\n", description); 53 | } 54 | 55 | static int thread_main(void* data) 56 | { 57 | const Thread* thread = data; 58 | 59 | glfwMakeContextCurrent(thread->window); 60 | glfwSwapInterval(1); 61 | 62 | while (running) 63 | { 64 | const float v = (float) fabs(sin(glfwGetTime() * 2.f)); 65 | glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f); 66 | 67 | glClear(GL_COLOR_BUFFER_BIT); 68 | glfwSwapBuffers(thread->window); 69 | } 70 | 71 | glfwMakeContextCurrent(NULL); 72 | return 0; 73 | } 74 | 75 | int main(void) 76 | { 77 | int i, result; 78 | Thread threads[] = 79 | { 80 | { NULL, "Red", 1.f, 0.f, 0.f, 0 }, 81 | { NULL, "Green", 0.f, 1.f, 0.f, 0 }, 82 | { NULL, "Blue", 0.f, 0.f, 1.f, 0 } 83 | }; 84 | const int count = sizeof(threads) / sizeof(Thread); 85 | 86 | glfwSetErrorCallback(error_callback); 87 | 88 | if (!glfwInit()) 89 | exit(EXIT_FAILURE); 90 | 91 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 92 | 93 | for (i = 0; i < count; i++) 94 | { 95 | threads[i].window = glfwCreateWindow(200, 200, 96 | threads[i].title, 97 | NULL, NULL); 98 | if (!threads[i].window) 99 | { 100 | glfwTerminate(); 101 | exit(EXIT_FAILURE); 102 | } 103 | 104 | glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); 105 | glfwShowWindow(threads[i].window); 106 | } 107 | 108 | glfwMakeContextCurrent(threads[0].window); 109 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 110 | glfwMakeContextCurrent(NULL); 111 | 112 | for (i = 0; i < count; i++) 113 | { 114 | if (thrd_create(&threads[i].id, thread_main, threads + i) != 115 | thrd_success) 116 | { 117 | fprintf(stderr, "Failed to create secondary thread\n"); 118 | 119 | glfwTerminate(); 120 | exit(EXIT_FAILURE); 121 | } 122 | } 123 | 124 | while (running) 125 | { 126 | glfwWaitEvents(); 127 | 128 | for (i = 0; i < count; i++) 129 | { 130 | if (glfwWindowShouldClose(threads[i].window)) 131 | running = GLFW_FALSE; 132 | } 133 | } 134 | 135 | for (i = 0; i < count; i++) 136 | glfwHideWindow(threads[i].window); 137 | 138 | for (i = 0; i < count; i++) 139 | thrd_join(threads[i].id, &result); 140 | 141 | exit(EXIT_SUCCESS); 142 | } 143 | 144 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/timeout.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Event wait timeout test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test is intended to verify that waiting for events with timeout works 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | static void error_callback(int error, const char* description) 39 | { 40 | fprintf(stderr, "Error: %s\n", description); 41 | } 42 | 43 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 44 | { 45 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 46 | glfwSetWindowShouldClose(window, GLFW_TRUE); 47 | } 48 | 49 | static float nrand(void) 50 | { 51 | return (float) rand() / (float) RAND_MAX; 52 | } 53 | 54 | int main(void) 55 | { 56 | GLFWwindow* window; 57 | 58 | srand((unsigned int) time(NULL)); 59 | 60 | glfwSetErrorCallback(error_callback); 61 | 62 | if (!glfwInit()) 63 | exit(EXIT_FAILURE); 64 | 65 | window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL); 66 | if (!window) 67 | { 68 | glfwTerminate(); 69 | exit(EXIT_FAILURE); 70 | } 71 | 72 | glfwMakeContextCurrent(window); 73 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 74 | glfwSetKeyCallback(window, key_callback); 75 | 76 | while (!glfwWindowShouldClose(window)) 77 | { 78 | int width, height; 79 | float r = nrand(), g = nrand(), b = nrand(); 80 | float l = (float) sqrt(r * r + g * g + b * b); 81 | 82 | glfwGetFramebufferSize(window, &width, &height); 83 | 84 | glViewport(0, 0, width, height); 85 | glClearColor(r / l, g / l, b / l, 1.f); 86 | glClear(GL_COLOR_BUFFER_BIT); 87 | glfwSwapBuffers(window); 88 | 89 | glfwWaitEventsTimeout(1.0); 90 | } 91 | 92 | glfwDestroyWindow(window); 93 | 94 | glfwTerminate(); 95 | exit(EXIT_SUCCESS); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/title.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // UTF-8 window title test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test sets a UTF-8 window title 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | static void error_callback(int error, const char* description) 37 | { 38 | fprintf(stderr, "Error: %s\n", description); 39 | } 40 | 41 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 42 | { 43 | glViewport(0, 0, width, height); 44 | } 45 | 46 | int main(void) 47 | { 48 | GLFWwindow* window; 49 | 50 | glfwSetErrorCallback(error_callback); 51 | 52 | if (!glfwInit()) 53 | exit(EXIT_FAILURE); 54 | 55 | window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL); 56 | if (!window) 57 | { 58 | glfwTerminate(); 59 | exit(EXIT_FAILURE); 60 | } 61 | 62 | glfwMakeContextCurrent(window); 63 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 64 | glfwSwapInterval(1); 65 | 66 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 67 | 68 | while (!glfwWindowShouldClose(window)) 69 | { 70 | glClear(GL_COLOR_BUFFER_BIT); 71 | glfwSwapBuffers(window); 72 | glfwWaitEvents(); 73 | } 74 | 75 | glfwTerminate(); 76 | exit(EXIT_SUCCESS); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /deps/glfw-3.2/tests/windows.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Simple multi-window test 3 | // Copyright (c) Camilla Berglund 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 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test creates four windows and clears each in a different color 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "getopt.h" 37 | 38 | static const char* titles[] = 39 | { 40 | "Red", 41 | "Green", 42 | "Blue", 43 | "Yellow" 44 | }; 45 | 46 | static const struct 47 | { 48 | float r, g, b; 49 | } colors[] = 50 | { 51 | { 0.95f, 0.32f, 0.11f }, 52 | { 0.50f, 0.80f, 0.16f }, 53 | { 0.f, 0.68f, 0.94f }, 54 | { 0.98f, 0.74f, 0.04f } 55 | }; 56 | 57 | static void usage(void) 58 | { 59 | printf("Usage: windows [-h] [-b]\n"); 60 | printf("Options:\n"); 61 | printf(" -b create decorated windows\n"); 62 | printf(" -h show this help\n"); 63 | } 64 | 65 | static void error_callback(int error, const char* description) 66 | { 67 | fprintf(stderr, "Error: %s\n", description); 68 | } 69 | 70 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 71 | { 72 | if (action != GLFW_PRESS) 73 | return; 74 | 75 | switch (key) 76 | { 77 | case GLFW_KEY_SPACE: 78 | { 79 | int xpos, ypos; 80 | glfwGetWindowPos(window, &xpos, &ypos); 81 | glfwSetWindowPos(window, xpos, ypos); 82 | break; 83 | } 84 | 85 | case GLFW_KEY_ESCAPE: 86 | glfwSetWindowShouldClose(window, GLFW_TRUE); 87 | break; 88 | } 89 | } 90 | 91 | int main(int argc, char** argv) 92 | { 93 | int i, ch; 94 | int decorated = GLFW_FALSE; 95 | int running = GLFW_TRUE; 96 | GLFWwindow* windows[4]; 97 | 98 | while ((ch = getopt(argc, argv, "bh")) != -1) 99 | { 100 | switch (ch) 101 | { 102 | case 'b': 103 | decorated = GLFW_TRUE; 104 | break; 105 | case 'h': 106 | usage(); 107 | exit(EXIT_SUCCESS); 108 | default: 109 | usage(); 110 | exit(EXIT_FAILURE); 111 | } 112 | } 113 | 114 | glfwSetErrorCallback(error_callback); 115 | 116 | if (!glfwInit()) 117 | exit(EXIT_FAILURE); 118 | 119 | glfwWindowHint(GLFW_DECORATED, decorated); 120 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 121 | 122 | for (i = 0; i < 4; i++) 123 | { 124 | int left, top, right, bottom; 125 | 126 | windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); 127 | if (!windows[i]) 128 | { 129 | glfwTerminate(); 130 | exit(EXIT_FAILURE); 131 | } 132 | 133 | glfwSetKeyCallback(windows[i], key_callback); 134 | 135 | glfwMakeContextCurrent(windows[i]); 136 | gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 137 | glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f); 138 | 139 | glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); 140 | glfwSetWindowPos(windows[i], 141 | 100 + (i & 1) * (200 + left + right), 142 | 100 + (i >> 1) * (200 + top + bottom)); 143 | } 144 | 145 | for (i = 0; i < 4; i++) 146 | glfwShowWindow(windows[i]); 147 | 148 | while (running) 149 | { 150 | for (i = 0; i < 4; i++) 151 | { 152 | glfwMakeContextCurrent(windows[i]); 153 | glClear(GL_COLOR_BUFFER_BIT); 154 | glfwSwapBuffers(windows[i]); 155 | 156 | if (glfwWindowShouldClose(windows[i])) 157 | running = GLFW_FALSE; 158 | } 159 | 160 | glfwWaitEvents(); 161 | } 162 | 163 | glfwTerminate(); 164 | exit(EXIT_SUCCESS); 165 | } 166 | 167 | -------------------------------------------------------------------------------- /img/fractal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erkaman/image-load-store-demo/ed20d40b6f9ec63aeb079e1524be3139a5930c71/img/fractal.gif --------------------------------------------------------------------------------