├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── Samples.lua ├── dither.lua ├── external ├── glad │ ├── CMakeLists.txt │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ └── src │ │ └── glad.c ├── glfw │ ├── .mailmap │ ├── CMake │ │ ├── GenerateMappings.cmake │ │ ├── Info.plist.in │ │ ├── cmake_uninstall.cmake.in │ │ ├── i686-w64-mingw32-clang.cmake │ │ ├── i686-w64-mingw32.cmake │ │ ├── modules │ │ │ ├── FindEpollShim.cmake │ │ │ ├── FindOSMesa.cmake │ │ │ ├── FindWaylandProtocols.cmake │ │ │ └── FindXKBCommon.cmake │ │ ├── x86_64-w64-mingw32-clang.cmake │ │ └── x86_64-w64-mingw32.cmake │ ├── CMakeLists.txt │ ├── LICENSE.md │ ├── README.md │ ├── deps │ │ ├── getopt.c │ │ ├── getopt.h │ │ ├── glad │ │ │ ├── gl.h │ │ │ ├── khrplatform.h │ │ │ ├── vk_platform.h │ │ │ └── vulkan.h │ │ ├── glad_gl.c │ │ ├── glad_vulkan.c │ │ ├── linmath.h │ │ ├── mingw │ │ │ ├── _mingw_dxhelper.h │ │ │ ├── dinput.h │ │ │ └── xinput.h │ │ ├── nuklear.h │ │ ├── nuklear_glfw_gl2.h │ │ ├── stb_image_write.h │ │ ├── tinycthread.c │ │ ├── tinycthread.h │ │ └── vs2008 │ │ │ └── stdint.h │ ├── docs │ │ ├── CMakeLists.txt │ │ ├── CODEOWNERS │ │ ├── CONTRIBUTING.md │ │ ├── Doxyfile.in │ │ ├── DoxygenLayout.xml │ │ ├── SUPPORT.md │ │ ├── build.dox │ │ ├── compat.dox │ │ ├── compile.dox │ │ ├── context.dox │ │ ├── extra.css │ │ ├── extra.less │ │ ├── footer.html │ │ ├── header.html │ │ ├── input.dox │ │ ├── internal.dox │ │ ├── intro.dox │ │ ├── main.dox │ │ ├── monitor.dox │ │ ├── moving.dox │ │ ├── news.dox │ │ ├── quick.dox │ │ ├── spaces.svg │ │ ├── vulkan.dox │ │ └── window.dox │ ├── examples │ │ ├── CMakeLists.txt │ │ ├── boing.c │ │ ├── gears.c │ │ ├── glfw.icns │ │ ├── glfw.ico │ │ ├── glfw.rc │ │ ├── heightmap.c │ │ ├── offscreen.c │ │ ├── particles.c │ │ ├── sharing.c │ │ ├── splitview.c │ │ ├── triangle-opengl.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 │ │ ├── glfw.rc.in │ │ ├── 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 │ │ ├── mappings.h │ │ ├── mappings.h.in │ │ ├── monitor.c │ │ ├── nsgl_context.h │ │ ├── nsgl_context.m │ │ ├── null_init.c │ │ ├── null_joystick.c │ │ ├── null_joystick.h │ │ ├── null_monitor.c │ │ ├── null_platform.h │ │ ├── null_window.c │ │ ├── osmesa_context.c │ │ ├── osmesa_context.h │ │ ├── posix_thread.c │ │ ├── posix_thread.h │ │ ├── posix_time.c │ │ ├── posix_time.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_thread.c │ │ ├── win32_time.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 │ │ ├── inputlag.c │ │ ├── joysticks.c │ │ ├── monitors.c │ │ ├── msaa.c │ │ ├── opacity.c │ │ ├── reopen.c │ │ ├── tearing.c │ │ ├── threads.c │ │ ├── timeout.c │ │ ├── title.c │ │ ├── triangle-vulkan.c │ │ └── windows.c ├── imgui │ ├── include │ │ ├── imconfig.h │ │ ├── imgui.h │ │ ├── imgui_impl_glfw.h │ │ ├── imgui_impl_opengl3.h │ │ ├── imgui_internal.h │ │ ├── imstb_rectpack.h │ │ ├── imstb_textedit.h │ │ └── imstb_truetype.h │ └── src │ │ ├── imgui.cpp │ │ ├── imgui_draw.cpp │ │ ├── imgui_impl_glfw.cpp │ │ ├── imgui_impl_opengl3.cpp │ │ └── imgui_widgets.cpp ├── lua │ ├── CMakeLists.txt │ ├── include │ │ ├── lapi.h │ │ ├── lauxlib.h │ │ ├── lcode.h │ │ ├── lctype.h │ │ ├── ldebug.h │ │ ├── ldo.h │ │ ├── lfunc.h │ │ ├── lgc.h │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmem.h │ │ ├── lobject.h │ │ ├── lopcodes.h │ │ ├── lparser.h │ │ ├── lprefix.h │ │ ├── lstate.h │ │ ├── lstring.h │ │ ├── ltable.h │ │ ├── ltm.h │ │ ├── lua.h │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.h │ │ ├── lvm.h │ │ └── lzio.h │ └── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lauxlib.c │ │ ├── lbaselib.c │ │ ├── lbitlib.c │ │ ├── lcode.c │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldo.c │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lgc.c │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lopcodes.c │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lstate.c │ │ ├── lstring.c │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── lua.hpp │ │ ├── lundump.c │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ └── lzio.c └── serial │ ├── CMakeLists.txt │ ├── include │ └── serial │ │ ├── impl │ │ ├── unix.h │ │ └── win.h │ │ ├── serial.h │ │ └── v8stdint.h │ └── src │ ├── impl │ ├── list_ports │ │ ├── list_ports_linux.cc │ │ ├── list_ports_osx.cc │ │ └── list_ports_win.cc │ ├── unix.cc │ └── win.cc │ └── serial.cc ├── resources ├── fonts │ ├── input_mono_medium.ttf │ └── input_mono_regular.ttf └── scripts │ ├── complex.lua │ ├── dot_dither.lua │ ├── dot_math.lua │ ├── dot_perlin.lua │ └── matrix.lua └── src ├── RtMidi.cpp ├── RtMidi.h ├── common.h ├── controller.cpp ├── controller.h ├── dot.h ├── editor_view.cpp ├── editor_view.h ├── interpreter.cpp ├── interpreter.h ├── main.cpp ├── view.h ├── window.cpp └── window.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/glfw"] 2 | path = external/glfw 3 | url = https://github.com/glfw/glfw 4 | [submodule "external/glm"] 5 | path = external/glm 6 | url = https://github.com/g-truc/glm.git 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(Dot) 3 | 4 | # turn off compiler warnings 5 | if(MSVC) 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") 7 | else() 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=c++14") 9 | endif() 10 | 11 | add_subdirectory("${PROJECT_SOURCE_DIR}/external/glfw") 12 | add_subdirectory("${PROJECT_SOURCE_DIR}/external/glad") 13 | add_subdirectory("${PROJECT_SOURCE_DIR}/external/lua") 14 | add_subdirectory("${PROJECT_SOURCE_DIR}/external/serial") 15 | 16 | include_directories("${PROJECT_SOURCE_DIR}/external/glad/include") 17 | include_directories("${PROJECT_SOURCE_DIR}/external/lua/include") 18 | include_directories("${PROJECT_SOURCE_DIR}/external/imgui/include") 19 | include_directories("${PROJECT_SOURCE_DIR}/external/serial/include") 20 | 21 | file(GLOB PROJECT_FILES "src/*.h" "src/*.cpp") 22 | file(GLOB IMGUI_SOURCES "external/imgui/src/*.cpp") 23 | 24 | # create the executable 25 | source_group("external" FILES ${IMGUI_SOURCES}) 26 | add_executable(Dot ${PROJECT_FILES} ${IMGUI_SOURCES}) 27 | 28 | # add libraries 29 | target_link_libraries(Dot glfw ${GLFW_LIBRARIES} glad lua serial) 30 | 31 | if(MSVC) 32 | target_link_libraries(Dot glfw ${GLFW_LIBRARIES} Setupapi winmm) 33 | target_compile_definitions(Dot PRIVATE "-D__WINDOWS_MM__") 34 | else() 35 | target_link_libraries(Dot glfw ${GLFW_LIBRARIES} rt pthread asound ${GTK3_LIBRARIES}) 36 | target_compile_definitions(Dot PRIVATE "-D__LINUX_ALSA__") 37 | endif() 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Dot 2 | ========== 3 | 4 | ![screenshot](http://andbc.co/media/FlipDot-1.png) 5 | 6 | Software used to control a FlipDot Panel. 7 | 8 | Once the project is built, ensure that the "resources" folder is located in the same folder as the executable. 9 | 10 | Links 11 | ========== 12 | 13 | [http://andbc.co/flipping_the_dots/](https://www.andbc.co/work/flipping_the_dots) 14 | -------------------------------------------------------------------------------- /Samples.lua: -------------------------------------------------------------------------------- 1 | dmath = require "dot_math" 2 | matrix = require "matrix" 3 | 4 | -- Constants 5 | FILL = 0 6 | CLEAR = 1 7 | CIRCLES = 2 8 | DISTANCE_FIELD = 3 9 | QUADS_0 = 4 10 | QUADS_1 = 5 11 | 12 | cur_effect = DISTANCE_FIELD 13 | 14 | function on_midi_input(state, id) 15 | print(id) 16 | if state == 128 then 17 | return 18 | end 19 | 20 | if id == 40 then 21 | cur_effect = FILL 22 | elseif id == 41 then 23 | cur_effect = CLEAR 24 | elseif id == 42 then 25 | cur_effect = CIRCLES 26 | elseif id == 43 then 27 | cur_effect = DISTANCE_FIELD 28 | elseif id == 36 then 29 | cur_effect = QUADS_0 30 | elseif id == 37 then 31 | cur_effect = QUADS_1 32 | end 33 | end 34 | 35 | function fill() 36 | return 1 37 | end 38 | 39 | function clear() 40 | return 0 41 | end 42 | 43 | function distance_field(x,y,f) 44 | s0 = 0.05 45 | c_x = math.sin(23+f * s0) * 15 46 | c_y = math.cos(444+f * s0) * 14 47 | d = dmath.dist(x + c_x, y + c_y, 14, 14) 48 | 49 | c2_x = math.sin(f * s0) * 10 50 | c2_y = math.sin(f * s0) * 15 51 | d2= dmath.dist(x + c2_x, y + c2_y, 14, 14) 52 | 53 | s1 = 0.05 54 | c3_x = math.sin(12-f * s1) * 11 55 | c3_y = math.sin(222+-f * s1) * 20 56 | d3= dmath.dist(x + c3_x, y + c3_y, 14, 14) 57 | 58 | s2 = 0.09 59 | c4_x = math.sin(1442+f * s2) * 11 60 | c4_y = math.sin(25+f * s2 * 0.5) * 12 61 | d4= dmath.dist(x + c4_x, y + c4_y, 14, 14) 62 | 63 | d = dmath.smin(dmath.smin(dmath.smin(d, d2, 12), d3, 12), d4, 12) 64 | 65 | val = 0 66 | if(d < 4.5) then 67 | val = 1 68 | end 69 | return val 70 | end 71 | 72 | function circle(x, y, f) 73 | c_x = 0--math.sin(f * 0.01) * 15 74 | c_y = 0--math.cos(f * 0.01) * 15 75 | d = dmath.dist(x + c_x, y + c_y, 7, 14) 76 | d = d*20 77 | 78 | val = 1 79 | if(math.fmod(f * 6 - d, 120) > 60) then 80 | val = 0 81 | end 82 | return val 83 | end 84 | 85 | function sdBox( x,y, w,h ) 86 | dx = math.abs(x)-w; 87 | dy = math.abs(y)-h; 88 | if dx < 0 then 89 | dx = 0 90 | end 91 | if dy < 0 then 92 | dy = 0 93 | end 94 | 95 | m = math.max(dx, dy) 96 | lx = dx + math.min(m, 0.0) 97 | ly = dy + math.min(m, 0.0) 98 | return math.sqrt(lx*lx + ly*ly) 99 | end 100 | 101 | r = matrix(2,2) 102 | p = matrix {0,0} 103 | 104 | function draw_quad(px, py, f, x, y, w, h, d) 105 | c = math.cos(d) 106 | s = math.sin(d) 107 | 108 | -- rotation matrix 109 | matrix.setelement(r,1,1,c) 110 | matrix.setelement(r,1,2,-s) 111 | matrix.setelement(r,2,1,s) 112 | matrix.setelement(r,2,2,c) 113 | matrix.setelement(p,1,1,px-x) 114 | matrix.setelement(p,2,1,py-y) 115 | 116 | wp = matrix.invert(r) * p 117 | v = sdBox(wp[1][1], wp[2][1], w, h) 118 | if v < 0.5 then 119 | return 1 120 | end 121 | return 0 122 | end 123 | 124 | function quads2(x,y,f) 125 | q0 = draw_quad(x,y,f, 6.5, 14, 7, 14, f*0.1) 126 | --q1 = draw_quad(x,y,f, 6.5, 14, 1, 207, 90-f*0.1) 127 | --q2 = draw_quad(x,y,f, 6.5, 14, 0.7, 20, 75+f*0.05) 128 | return q0--math.max(q0, q1) 129 | end 130 | 131 | function quads(x,y,f) 132 | h = math.sin((x + 0.15) * 0.8 - f * 0.1) 133 | v = math.sin(y * 0.45 - f * 0.21) 134 | if h < 0 then 135 | h = 0 136 | else 137 | h = 1 138 | end 139 | if v < 0 then 140 | v = 0 141 | else 142 | v = 1 143 | end 144 | 145 | 146 | 147 | return math.max(h,v) 148 | end 149 | 150 | function main(x, y, frame) 151 | if cur_effect == FILL then 152 | return fill() 153 | elseif cur_effect == CLEAR then 154 | return clear() 155 | elseif cur_effect == CIRCLES then 156 | return circle(x,y,frame) 157 | elseif cur_effect == DISTANCE_FIELD then 158 | return distance_field(x,y,frame) 159 | elseif cur_effect == QUADS_0 then 160 | return quads(x,y,frame) 161 | elseif cur_effect == QUADS_1 then 162 | return quads2(x,y,frame) 163 | end 164 | end -------------------------------------------------------------------------------- /dither.lua: -------------------------------------------------------------------------------- 1 | dmath = require "dot_math" 2 | 3 | local bayer = {} 4 | bayer[0] = {} 5 | bayer[1] = {} 6 | bayer[2] = {} 7 | bayer[3] = {} 8 | 9 | bayer[0][0] = 0 10 | bayer[0][1] = 0.5 11 | bayer[0][2] = 0.125 12 | bayer[0][3] = 0.625 13 | bayer[1][0] = 0.75 14 | bayer[1][1] = 0.25 15 | bayer[1][2] = 0.875 16 | bayer[1][3] = 0.375 17 | bayer[2][0] = 0.1875 18 | bayer[2][1] = 0.6875 19 | bayer[2][2] = 0.0625 20 | bayer[2][3] = 0.5625 21 | bayer[3][0] = 0.9375 22 | bayer[3][1] = 0.4375 23 | bayer[3][2] = 0.8125 24 | bayer[3][3] = 0.3125 25 | 26 | function circle(x, y, cx, cy) 27 | d = dmath.dist(x, y, cx, cy) 28 | return d 29 | end 30 | 31 | function dither(x,y,b) 32 | mx = math.fmod(x,4) 33 | my = math.fmod(y,4) 34 | if(b < bayer[mx][my]) then 35 | return 1 36 | end 37 | return 0 38 | end 39 | 40 | function simple(x,y,f) 41 | b = (math.sin(((x / 24) + f * 0.075) * 5) + 1.0) / 2.0 42 | return dither(x,y,b) 43 | end 44 | 45 | function main(x, y, frame) 46 | return simple(x,y,frame) 47 | end -------------------------------------------------------------------------------- /external/glad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.0) 3 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/external) 4 | project(glad) 5 | include_directories("include") 6 | file(GLOB srcs "include/*.h" "src/*.c") 7 | add_library(glad ${srcs}) 8 | 9 | -------------------------------------------------------------------------------- /external/glfw/.mailmap: -------------------------------------------------------------------------------- 1 | Camilla Löwy 2 | Camilla Löwy 3 | Camilla Löwy 4 | 5 | Emmanuel Gil Peyrot 6 | 7 | Marcus Geelnard 8 | Marcus Geelnard 9 | Marcus Geelnard 10 | 11 | -------------------------------------------------------------------------------- /external/glfw/CMake/GenerateMappings.cmake: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # cmake -P GenerateMappings.cmake 3 | 4 | set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") 5 | set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") 6 | set(template_path "${CMAKE_ARGV3}") 7 | set(target_path "${CMAKE_ARGV4}") 8 | 9 | if (NOT EXISTS "${template_path}") 10 | message(FATAL_ERROR "Failed to find template file ${template_path}") 11 | endif() 12 | 13 | file(DOWNLOAD "${source_url}" "${source_path}" 14 | STATUS download_status 15 | TLS_VERIFY on) 16 | 17 | list(GET download_status 0 status_code) 18 | list(GET download_status 1 status_message) 19 | 20 | if (status_code) 21 | message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}") 22 | endif() 23 | 24 | file(STRINGS "${source_path}" lines) 25 | foreach(line ${lines}) 26 | if ("${line}" MATCHES "^[0-9a-fA-F].*$") 27 | set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n") 28 | endif() 29 | endforeach() 30 | 31 | configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX) 32 | file(REMOVE "${source_path}") 33 | 34 | -------------------------------------------------------------------------------- /external/glfw/CMake/Info.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 | -------------------------------------------------------------------------------- /external/glfw/CMake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt") 3 | message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"") 4 | endif() 5 | 6 | file(READ "@GLFW_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 | -------------------------------------------------------------------------------- /external/glfw/CMake/i686-w64-mingw32-clang.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 32-bit MinGW-w64 Clang 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-w64-mingw32-clang") 5 | SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-clang++") 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 | -------------------------------------------------------------------------------- /external/glfw/CMake/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 32-bit MinGW-w64 GCC 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 | -------------------------------------------------------------------------------- /external/glfw/CMake/modules/FindEpollShim.cmake: -------------------------------------------------------------------------------- 1 | # Find EpollShim 2 | # Once done, this will define 3 | # 4 | # EPOLLSHIM_FOUND - System has EpollShim 5 | # EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories 6 | # EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim 7 | 8 | find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim) 9 | find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib) 10 | 11 | if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES) 12 | set(EPOLLSHIM_FOUND TRUE) 13 | endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES) 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS) 17 | mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES) 18 | -------------------------------------------------------------------------------- /external/glfw/CMake/modules/FindOSMesa.cmake: -------------------------------------------------------------------------------- 1 | # Try to find OSMesa on a Unix system 2 | # 3 | # This will define: 4 | # 5 | # OSMESA_LIBRARIES - Link these to use OSMesa 6 | # OSMESA_INCLUDE_DIR - Include directory for OSMesa 7 | # 8 | # Copyright (c) 2014 Brandon Schaefer 9 | 10 | if (NOT WIN32) 11 | 12 | find_package (PkgConfig) 13 | pkg_check_modules (PKG_OSMESA QUIET osmesa) 14 | 15 | set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS}) 16 | set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES}) 17 | 18 | endif () 19 | -------------------------------------------------------------------------------- /external/glfw/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 | -------------------------------------------------------------------------------- /external/glfw/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 | -------------------------------------------------------------------------------- /external/glfw/CMake/x86_64-w64-mingw32-clang.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 64-bit MinGW-w64 Clang 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-clang") 5 | SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-clang++") 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 | -------------------------------------------------------------------------------- /external/glfw/CMake/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 64-bit MinGW-w64 GCC 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 | -------------------------------------------------------------------------------- /external/glfw/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 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 | -------------------------------------------------------------------------------- /external/glfw/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 | -------------------------------------------------------------------------------- /external/glfw/deps/glad/vk_platform.h: -------------------------------------------------------------------------------- 1 | /* */ 2 | /* File: vk_platform.h */ 3 | /* */ 4 | /* 5 | ** Copyright (c) 2014-2017 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_ARCH) && __ARM_ARCH < 7 55 | #error "Vulkan isn't supported for the 'armeabi' NDK ABI" 56 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) 57 | /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */ 58 | /* calling convention, i.e. float parameters are passed in registers. This */ 59 | /* is true even if the rest of the application passes floats on the stack, */ 60 | /* as it does by default when compiling for the armeabi-v7a NDK ABI. */ 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 | #endif 93 | -------------------------------------------------------------------------------- /external/glfw/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 | -------------------------------------------------------------------------------- /external/glfw/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # NOTE: The order of this list determines the order of items in the Guides 3 | # (i.e. Pages) list in the generated documentation 4 | set(GLFW_DOXYGEN_SOURCES 5 | "include/GLFW/glfw3.h" 6 | "include/GLFW/glfw3native.h" 7 | "docs/main.dox" 8 | "docs/news.dox" 9 | "docs/quick.dox" 10 | "docs/moving.dox" 11 | "docs/compile.dox" 12 | "docs/build.dox" 13 | "docs/intro.dox" 14 | "docs/context.dox" 15 | "docs/monitor.dox" 16 | "docs/window.dox" 17 | "docs/input.dox" 18 | "docs/vulkan.dox" 19 | "docs/compat.dox" 20 | "docs/internal.dox") 21 | 22 | # Format the source list into a Doxyfile INPUT value that Doxygen can parse 23 | foreach(path IN LISTS GLFW_DOXYGEN_SOURCES) 24 | set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"") 25 | endforeach() 26 | 27 | configure_file(Doxyfile.in Doxyfile @ONLY) 28 | 29 | add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}" 30 | WORKING_DIRECTORY "${GLFW_BINARY_DIR}/docs" 31 | COMMENT "Generating HTML documentation" VERBATIM) 32 | 33 | -------------------------------------------------------------------------------- /external/glfw/docs/CODEOWNERS: -------------------------------------------------------------------------------- 1 | 2 | * @elmindreda 3 | 4 | src/wl_* @linkmauve 5 | 6 | docs/*.css @glfw/webdev 7 | docs/*.less @glfw/webdev 8 | docs/*.html @glfw/webdev 9 | docs/*.xml @glfw/webdev 10 | 11 | -------------------------------------------------------------------------------- /external/glfw/docs/DoxygenLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /external/glfw/docs/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support resources 2 | 3 | See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials, 4 | guides and the API reference. 5 | 6 | If you have questions about using GLFW, we have a 7 | [forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on 8 | [Freenode](http://freenode.net/). 9 | 10 | Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). 11 | Please check the [contribution 12 | guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for 13 | information on what to include when reporting a bug. 14 | 15 | -------------------------------------------------------------------------------- /external/glfw/docs/footer.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /external/glfw/docs/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $projectname: $title 8 | $title 9 | 10 | 11 | 12 | $treeview 13 | $search 14 | $mathjax 15 | 16 | $extrastylesheet 17 | 18 | 19 |
20 | 21 | 22 |
23 |
24 | GLFW 25 | 30 |
31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /external/glfw/docs/internal.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @page internals_guide Internal structure 4 | 5 | @tableofcontents 6 | 7 | There are several interfaces inside GLFW. Each interface has its own area of 8 | responsibility and its own naming conventions. 9 | 10 | 11 | @section internals_public Public interface 12 | 13 | The most well-known is the public interface, described in the glfw3.h header 14 | file. This is implemented in source files shared by all platforms and these 15 | files contain no platform-specific code. This code usually ends up calling the 16 | platform and internal interfaces to do the actual work. 17 | 18 | The public interface uses the OpenGL naming conventions except with GLFW and 19 | glfw instead of GL and gl. For struct members, where OpenGL sets no precedent, 20 | it use headless camel case. 21 | 22 | Examples: `glfwCreateWindow`, `GLFWwindow`, `GLFW_RED_BITS` 23 | 24 | 25 | @section internals_native Native interface 26 | 27 | The [native interface](@ref native) is a small set of publicly available 28 | but platform-specific functions, described in the glfw3native.h header file and 29 | used to gain access to the underlying window, context and (on some platforms) 30 | display handles used by the platform interface. 31 | 32 | The function names of the native interface are similar to those of the public 33 | interface, but embeds the name of the interface that the returned handle is 34 | from. 35 | 36 | Examples: `glfwGetX11Window`, `glfwGetWGLContext` 37 | 38 | 39 | @section internals_internal Internal interface 40 | 41 | The internal interface consists of utility functions used by all other 42 | interfaces. It is shared code implemented in the same shared source files as 43 | the public and event interfaces. The internal interface is described in the 44 | internal.h header file. 45 | 46 | The internal interface is in charge of GLFW's global data, which it stores in 47 | a `_GLFWlibrary` struct named `_glfw`. 48 | 49 | The internal interface uses the same style as the public interface, except all 50 | global names have a leading underscore. 51 | 52 | Examples: `_glfwIsValidContextConfig`, `_GLFWwindow`, `_glfw.monitorCount` 53 | 54 | 55 | @section internals_platform Platform interface 56 | 57 | The platform interface implements all platform-specific operations as a service 58 | to the public interface. This includes event processing. The platform 59 | interface is never directly called by application code and never directly calls 60 | application-provided callbacks. It is also prohibited from modifying the 61 | platform-independent part of the internal structs. Instead, it calls the event 62 | interface when events interesting to GLFW are received. 63 | 64 | The platform interface mirrors those parts of the public interface that needs to 65 | perform platform-specific operations on some or all platforms. The are also 66 | named the same except that the glfw function prefix is replaced by 67 | _glfwPlatform. 68 | 69 | Examples: `_glfwPlatformCreateWindow` 70 | 71 | The platform interface also defines structs that contain platform-specific 72 | global and per-object state. Their names mirror those of the internal 73 | interface, except that an interface-specific suffix is added. 74 | 75 | Examples: `_GLFWwindowX11`, `_GLFWcontextWGL` 76 | 77 | These structs are incorporated as members into the internal interface structs 78 | using special macros that name them after the specific interface used. This 79 | prevents shared code from accidentally using these members. 80 | 81 | Examples: `window->win32.handle`, `_glfw.x11.display` 82 | 83 | 84 | @section internals_event Event interface 85 | 86 | The event interface is implemented in the same shared source files as the public 87 | interface and is responsible for delivering the events it receives to the 88 | application, either via callbacks, via window state changes or both. 89 | 90 | The function names of the event interface use a `_glfwInput` prefix and the 91 | ObjectEvent pattern. 92 | 93 | Examples: `_glfwInputWindowFocus`, `_glfwInputCursorPos` 94 | 95 | 96 | @section internals_static Static functions 97 | 98 | Static functions may be used by any interface and have no prefixes or suffixes. 99 | These use headless camel case. 100 | 101 | Examples: `isValidElementForJoystick` 102 | 103 | 104 | @section internals_config Configuration macros 105 | 106 | GLFW uses a number of configuration macros to select at compile time which 107 | interfaces and code paths to use. They are defined in the glfw_config.h header file, 108 | which is generated from the `glfw_config.h.in` file by CMake. 109 | 110 | Configuration macros the same style as tokens in the public interface, except 111 | with a leading underscore. 112 | 113 | Examples: `_GLFW_WIN32`, `_GLFW_BUILD_DLL` 114 | 115 | */ 116 | -------------------------------------------------------------------------------- /external/glfw/docs/main.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @mainpage notitle 4 | 5 | @section main_intro Introduction 6 | 7 | GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and 8 | Vulkan application development. It provides a simple, platform-independent API 9 | for creating windows, contexts and surfaces, reading input, handling events, etc. 10 | 11 | @ref news_34 list new features, caveats and deprecations. 12 | 13 | @ref quick_guide is a guide for users new to GLFW. It takes you through how to 14 | write a small but complete program. 15 | 16 | There are guides for each section of the API: 17 | 18 | - @ref intro_guide – initialization, error handling and high-level design 19 | - @ref window_guide – creating and working with windows and framebuffers 20 | - @ref context_guide – working with OpenGL and OpenGL ES contexts 21 | - @ref vulkan_guide - working with Vulkan objects and extensions 22 | - @ref monitor_guide – enumerating and working with monitors and video modes 23 | - @ref input_guide – receiving events, polling and processing input 24 | 25 | Once you have written a program, see @ref compile_guide and @ref build_guide. 26 | 27 | The [reference documentation](modules.html) provides more detailed information 28 | about specific functions. 29 | 30 | @ref moving_guide explains what has changed and how to update existing code to 31 | use the new API. 32 | 33 | There is a section on @ref guarantees_limitations for pointer lifetimes, 34 | reentrancy, thread safety, event order and backward and forward compatibility. 35 | 36 | The [FAQ](https://www.glfw.org/faq.html) answers many common questions about the 37 | design, implementation and use of GLFW. 38 | 39 | Finally, @ref compat_guide explains what APIs, standards and protocols GLFW uses 40 | and what happens when they are not present on a given machine. 41 | 42 | This documentation was generated with Doxygen. The sources for it are available 43 | in both the [source distribution](https://www.glfw.org/download.html) and 44 | [GitHub repository](https://github.com/glfw/glfw). 45 | 46 | */ 47 | -------------------------------------------------------------------------------- /external/glfw/docs/news.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @page news Release notes 4 | 5 | @tableofcontents 6 | 7 | 8 | @section news_34 Release notes for version 3.4 9 | 10 | @subsection features_34 New features in version 3.4 11 | 12 | @subsubsection standard_cursors_34 More standard cursors 13 | 14 | GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and 15 | @ref GLFW_RESIZE_NESW_CURSOR for diagonal resizing, @ref GLFW_RESIZE_ALL_CURSOR 16 | for omni-directional resizing and @ref GLFW_NOT_ALLOWED_CURSOR for showing an 17 | action is not allowed. 18 | 19 | Unlike the original set, these shapes may not be available everywhere and 20 | creation will then fail with the new @ref GLFW_CURSOR_UNAVAILABLE error. 21 | 22 | The cursors for horizontal and vertical resizing are now referred to as @ref 23 | GLFW_RESIZE_EW_CURSOR and @ref GLFW_RESIZE_NS_CURSOR, and the pointing hand 24 | cursor is now referred to as @ref GLFW_POINTING_HAND_CURSOR. The older names 25 | are still available. 26 | 27 | For more information see @ref cursor_standard. 28 | 29 | 30 | @subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu 31 | 32 | GLFW now provides the 33 | [GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for 34 | enabling keyboard access to the window menu via the Alt+Space and 35 | Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented 36 | applications. 37 | 38 | 39 | @subsection caveats_34 Caveats for version 3.4 40 | 41 | @subsubsection standalone_34 Tests and examples are disabled when built as a sub-project 42 | 43 | GLFW now does not build the tests and examples when it is added as 44 | a subdirectory of another CMake project. To enable these, set the @ref 45 | GLFW_BUILD_TESTS and @ref GLFW_BUILD_EXAMPLES cache variables before adding the 46 | GLFW subdirectory. 47 | 48 | @code{.cmake} 49 | set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) 50 | set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) 51 | add_subdirectory(path/to/glfw) 52 | @endcode 53 | 54 | 55 | @subsubsection corevideo_34 CoreVideo dependency has been removed 56 | 57 | GLFW no longer depends on the CoreVideo framework on macOS and it no longer 58 | needs to be specified during compilation or linking. 59 | 60 | 61 | @subsection deprecations_34 Deprecations in version 3.4 62 | 63 | @subsection removals_34 Removals in 3.4 64 | 65 | @subsection symbols_34 New symbols in version 3.4 66 | 67 | @subsubsection functions_34 New functions in version 3.4 68 | @subsubsection types_34 New types in version 3.4 69 | @subsubsection constants_34 New constants in version 3.4 70 | 71 | - @ref GLFW_POINTING_HAND_CURSOR 72 | - @ref GLFW_RESIZE_EW_CURSOR 73 | - @ref GLFW_RESIZE_NS_CURSOR 74 | - @ref GLFW_RESIZE_NWSE_CURSOR 75 | - @ref GLFW_RESIZE_NESW_CURSOR 76 | - @ref GLFW_RESIZE_ALL_CURSOR 77 | - @ref GLFW_NOT_ALLOWED_CURSOR 78 | - @ref GLFW_CURSOR_UNAVAILABLE 79 | - @ref GLFW_WIN32_KEYBOARD_MENU 80 | 81 | 82 | @section news_archive Release notes for earlier versions 83 | 84 | - [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html) 85 | - [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html) 86 | - [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html) 87 | - [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html) 88 | 89 | */ 90 | -------------------------------------------------------------------------------- /external/glfw/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw) 3 | 4 | include_directories("${GLFW_SOURCE_DIR}/deps") 5 | 6 | if (MATH_LIBRARY) 7 | link_libraries("${MATH_LIBRARY}") 8 | endif() 9 | 10 | if (MSVC) 11 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 12 | endif() 13 | 14 | if (WIN32) 15 | set(ICON glfw.rc) 16 | elseif (APPLE) 17 | set(ICON glfw.icns) 18 | endif() 19 | 20 | set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" 21 | "${GLFW_SOURCE_DIR}/deps/glad_gl.c") 22 | set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" 23 | "${GLFW_SOURCE_DIR}/deps/getopt.c") 24 | set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" 25 | "${GLFW_SOURCE_DIR}/deps/tinycthread.c") 26 | 27 | add_executable(boing WIN32 MACOSX_BUNDLE boing.c ${ICON} ${GLAD_GL}) 28 | add_executable(gears WIN32 MACOSX_BUNDLE gears.c ${ICON} ${GLAD_GL}) 29 | add_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${ICON} ${GLAD_GL}) 30 | add_executable(offscreen offscreen.c ${ICON} ${GLAD_GL}) 31 | add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD_GL}) 32 | add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL}) 33 | add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL}) 34 | add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL}) 35 | add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) 36 | 37 | target_link_libraries(particles Threads::Threads) 38 | if (RT_LIBRARY) 39 | target_link_libraries(particles "${RT_LIBRARY}") 40 | endif() 41 | 42 | set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview 43 | triangle-opengl wave) 44 | set(CONSOLE_BINARIES offscreen) 45 | 46 | set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 47 | C_STANDARD 99 48 | FOLDER "GLFW3/Examples") 49 | 50 | if (GLFW_USE_OSMESA) 51 | target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA) 52 | endif() 53 | 54 | if (MSVC) 55 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 56 | set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES 57 | LINK_FLAGS "/ENTRY:mainCRTStartup") 58 | endif() 59 | 60 | if (APPLE) 61 | set_target_properties(boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing") 62 | set_target_properties(gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears") 63 | set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap") 64 | set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") 65 | set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") 66 | set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle") 67 | set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") 68 | set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") 69 | 70 | set_source_files_properties(glfw.icns PROPERTIES 71 | MACOSX_PACKAGE_LOCATION "Resources") 72 | set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES 73 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 74 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} 75 | MACOSX_BUNDLE_ICON_FILE glfw.icns 76 | MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/Info.plist.in") 77 | endif() 78 | 79 | -------------------------------------------------------------------------------- /external/glfw/examples/glfw.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andydbc/Dot/b3d9f2c1a46c3dda3910f018a50b64e0f9754539/external/glfw/examples/glfw.icns -------------------------------------------------------------------------------- /external/glfw/examples/glfw.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andydbc/Dot/b3d9f2c1a46c3dda3910f018a50b64e0f9754539/external/glfw/examples/glfw.ico -------------------------------------------------------------------------------- /external/glfw/examples/glfw.rc: -------------------------------------------------------------------------------- 1 | 2 | GLFW_ICON ICON "glfw.ico" 3 | 4 | -------------------------------------------------------------------------------- /external/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 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 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | 48 | void _glfwInitJoysticksNS(void); 49 | void _glfwTerminateJoysticksNS(void); 50 | 51 | -------------------------------------------------------------------------------- /external/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerNS(void) 41 | { 42 | mach_timebase_info_data_t info; 43 | mach_timebase_info(&info); 44 | 45 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW platform API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | uint64_t _glfwPlatformGetTimerValue(void) 54 | { 55 | return mach_absolute_time(); 56 | } 57 | 58 | uint64_t _glfwPlatformGetTimerFrequency(void) 59 | { 60 | return _glfw.timer.ns.frequency; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /external/glfw/src/glfw.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 6 | PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 12 | { 13 | BLOCK "StringFileInfo" 14 | { 15 | BLOCK "040904B0" 16 | { 17 | VALUE "CompanyName", "GLFW" 18 | VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" 19 | VALUE "FileVersion", "@GLFW_VERSION@" 20 | VALUE "OriginalFilename", "glfw3.dll" 21 | VALUE "ProductName", "GLFW" 22 | VALUE "ProductVersion", "@GLFW_VERSION@" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x409, 1200 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /external/glfw/src/glfw3.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: GLFW 7 | Description: A multi-platform library for OpenGL, window and input 8 | Version: @GLFW_VERSION@ 9 | URL: https://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 | -------------------------------------------------------------------------------- /external/glfw/src/glfw3Config.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | find_dependency(Threads) 3 | include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake") 4 | -------------------------------------------------------------------------------- /external/glfw/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 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 OSMesa 46 | #cmakedefine _GLFW_OSMESA 47 | 48 | // Define this to 1 to use Vulkan loader linked statically into application 49 | #cmakedefine _GLFW_VULKAN_STATIC 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 xkbcommon supports the compose key 55 | #cmakedefine HAVE_XKBCOMMON_COMPOSE_H 56 | // Define this to 1 if the libc supports memfd_create() 57 | #cmakedefine HAVE_MEMFD_CREATE 58 | 59 | -------------------------------------------------------------------------------- /external/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 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 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | 59 | GLFWbool _glfwInitJoysticksLinux(void); 60 | void _glfwTerminateJoysticksLinux(void); 61 | void _glfwDetectJoystickConnectionLinux(void); 62 | 63 | -------------------------------------------------------------------------------- /external/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2019 Camilla Löwy 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 | // NOTE: Many Cocoa enum values have been renamed and we need to build across 28 | // SDK versions where one is unavailable or the other deprecated 29 | // We use the newer names in code and these macros to handle compatibility 30 | #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 31 | #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval 32 | #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity 33 | #endif 34 | 35 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 37 | 38 | #include 39 | 40 | 41 | // NSGL-specific per-context data 42 | // 43 | typedef struct _GLFWcontextNSGL 44 | { 45 | id pixelFormat; 46 | id object; 47 | 48 | } _GLFWcontextNSGL; 49 | 50 | // NSGL-specific global data 51 | // 52 | typedef struct _GLFWlibraryNSGL 53 | { 54 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 55 | CFBundleRef framework; 56 | 57 | } _GLFWlibraryNSGL; 58 | 59 | 60 | GLFWbool _glfwInitNSGL(void); 61 | void _glfwTerminateNSGL(void); 62 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 63 | const _GLFWctxconfig* ctxconfig, 64 | const _GLFWfbconfig* fbconfig); 65 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 66 | 67 | -------------------------------------------------------------------------------- /external/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW platform API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | int _glfwPlatformInit(void) 38 | { 39 | _glfwInitTimerPOSIX(); 40 | return GLFW_TRUE; 41 | } 42 | 43 | void _glfwPlatformTerminate(void) 44 | { 45 | _glfwTerminateOSMesa(); 46 | } 47 | 48 | const char* _glfwPlatformGetVersionString(void) 49 | { 50 | return _GLFW_VERSION_NUMBER " null OSMesa"; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /external/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016-2017 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 37 | { 38 | return GLFW_FALSE; 39 | } 40 | 41 | void _glfwPlatformUpdateGamepadGUID(char* guid) 42 | { 43 | } 44 | 45 | -------------------------------------------------------------------------------- /external/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 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 | #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /external/glfw/src/null_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2019 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW platform API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) 38 | { 39 | } 40 | 41 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 42 | { 43 | } 44 | 45 | void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, 46 | float* xscale, float* yscale) 47 | { 48 | if (xscale) 49 | *xscale = 1.f; 50 | if (yscale) 51 | *yscale = 1.f; 52 | } 53 | 54 | void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, 55 | int* xpos, int* ypos, 56 | int* width, int* height) 57 | { 58 | } 59 | 60 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 61 | { 62 | return NULL; 63 | } 64 | 65 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 66 | { 67 | } 68 | 69 | GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 70 | { 71 | return GLFW_FALSE; 72 | } 73 | 74 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 75 | { 76 | } 77 | 78 | -------------------------------------------------------------------------------- /external/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 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 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | 32 | #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } 33 | #define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; } 34 | #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } 35 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; } 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } 37 | #define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; } 38 | #define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; } 39 | 40 | #include "osmesa_context.h" 41 | #include "posix_time.h" 42 | #include "posix_thread.h" 43 | #include "null_joystick.h" 44 | 45 | #if defined(_GLFW_WIN32) 46 | #define _glfw_dlopen(name) LoadLibraryA(name) 47 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 48 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 49 | #else 50 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 51 | #define _glfw_dlclose(handle) dlclose(handle) 52 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 53 | #endif 54 | 55 | // Null-specific per-window data 56 | // 57 | typedef struct _GLFWwindowNull 58 | { 59 | int width; 60 | int height; 61 | } _GLFWwindowNull; 62 | 63 | -------------------------------------------------------------------------------- /external/glfw/src/osmesa_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 OSMesa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 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 | #define OSMESA_RGBA 0x1908 29 | #define OSMESA_FORMAT 0x22 30 | #define OSMESA_DEPTH_BITS 0x30 31 | #define OSMESA_STENCIL_BITS 0x31 32 | #define OSMESA_ACCUM_BITS 0x32 33 | #define OSMESA_PROFILE 0x33 34 | #define OSMESA_CORE_PROFILE 0x34 35 | #define OSMESA_COMPAT_PROFILE 0x35 36 | #define OSMESA_CONTEXT_MAJOR_VERSION 0x36 37 | #define OSMESA_CONTEXT_MINOR_VERSION 0x37 38 | 39 | typedef void* OSMesaContext; 40 | typedef void (*OSMESAproc)(void); 41 | 42 | typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); 43 | typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); 44 | typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); 45 | typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); 46 | typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); 47 | typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); 48 | typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); 49 | #define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt 50 | #define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs 51 | #define OSMesaDestroyContext _glfw.osmesa.DestroyContext 52 | #define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent 53 | #define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer 54 | #define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer 55 | #define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress 56 | 57 | #define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa 58 | #define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa 59 | 60 | 61 | // OSMesa-specific per-context data 62 | // 63 | typedef struct _GLFWcontextOSMesa 64 | { 65 | OSMesaContext handle; 66 | int width; 67 | int height; 68 | void* buffer; 69 | 70 | } _GLFWcontextOSMesa; 71 | 72 | // OSMesa-specific global data 73 | // 74 | typedef struct _GLFWlibraryOSMesa 75 | { 76 | void* handle; 77 | 78 | PFN_OSMesaCreateContextExt CreateContextExt; 79 | PFN_OSMesaCreateContextAttribs CreateContextAttribs; 80 | PFN_OSMesaDestroyContext DestroyContext; 81 | PFN_OSMesaMakeCurrent MakeCurrent; 82 | PFN_OSMesaGetColorBuffer GetColorBuffer; 83 | PFN_OSMesaGetDepthBuffer GetDepthBuffer; 84 | PFN_OSMesaGetProcAddress GetProcAddress; 85 | 86 | } _GLFWlibraryOSMesa; 87 | 88 | 89 | GLFWbool _glfwInitOSMesa(void); 90 | void _glfwTerminateOSMesa(void); 91 | GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, 92 | const _GLFWctxconfig* ctxconfig, 93 | const _GLFWfbconfig* fbconfig); 94 | 95 | -------------------------------------------------------------------------------- /external/glfw/src/posix_thread.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | 35 | 36 | ////////////////////////////////////////////////////////////////////////// 37 | ////// GLFW platform API ////// 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls) 41 | { 42 | assert(tls->posix.allocated == GLFW_FALSE); 43 | 44 | if (pthread_key_create(&tls->posix.key, NULL) != 0) 45 | { 46 | _glfwInputError(GLFW_PLATFORM_ERROR, 47 | "POSIX: Failed to create context TLS"); 48 | return GLFW_FALSE; 49 | } 50 | 51 | tls->posix.allocated = GLFW_TRUE; 52 | return GLFW_TRUE; 53 | } 54 | 55 | void _glfwPlatformDestroyTls(_GLFWtls* tls) 56 | { 57 | if (tls->posix.allocated) 58 | pthread_key_delete(tls->posix.key); 59 | memset(tls, 0, sizeof(_GLFWtls)); 60 | } 61 | 62 | void* _glfwPlatformGetTls(_GLFWtls* tls) 63 | { 64 | assert(tls->posix.allocated == GLFW_TRUE); 65 | return pthread_getspecific(tls->posix.key); 66 | } 67 | 68 | void _glfwPlatformSetTls(_GLFWtls* tls, void* value) 69 | { 70 | assert(tls->posix.allocated == GLFW_TRUE); 71 | pthread_setspecific(tls->posix.key, value); 72 | } 73 | 74 | GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex) 75 | { 76 | assert(mutex->posix.allocated == GLFW_FALSE); 77 | 78 | if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0) 79 | { 80 | _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex"); 81 | return GLFW_FALSE; 82 | } 83 | 84 | return mutex->posix.allocated = GLFW_TRUE; 85 | } 86 | 87 | void _glfwPlatformDestroyMutex(_GLFWmutex* mutex) 88 | { 89 | if (mutex->posix.allocated) 90 | pthread_mutex_destroy(&mutex->posix.handle); 91 | memset(mutex, 0, sizeof(_GLFWmutex)); 92 | } 93 | 94 | void _glfwPlatformLockMutex(_GLFWmutex* mutex) 95 | { 96 | assert(mutex->posix.allocated == GLFW_TRUE); 97 | pthread_mutex_lock(&mutex->posix.handle); 98 | } 99 | 100 | void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) 101 | { 102 | assert(mutex->posix.allocated == GLFW_TRUE); 103 | pthread_mutex_unlock(&mutex->posix.handle); 104 | } 105 | 106 | -------------------------------------------------------------------------------- /external/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /external/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #define _POSIX_C_SOURCE 199309L 31 | 32 | #include "internal.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | ////// GLFW internal API ////// 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | // Initialise timer 44 | // 45 | void _glfwInitTimerPOSIX(void) 46 | { 47 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 48 | struct timespec ts; 49 | 50 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 51 | { 52 | _glfw.timer.posix.monotonic = GLFW_TRUE; 53 | _glfw.timer.posix.frequency = 1000000000; 54 | } 55 | else 56 | #endif 57 | { 58 | _glfw.timer.posix.monotonic = GLFW_FALSE; 59 | _glfw.timer.posix.frequency = 1000000; 60 | } 61 | } 62 | 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | ////// GLFW platform API ////// 66 | ////////////////////////////////////////////////////////////////////////// 67 | 68 | uint64_t _glfwPlatformGetTimerValue(void) 69 | { 70 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 71 | if (_glfw.timer.posix.monotonic) 72 | { 73 | struct timespec ts; 74 | clock_gettime(CLOCK_MONOTONIC, &ts); 75 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 76 | } 77 | else 78 | #endif 79 | { 80 | struct timeval tv; 81 | gettimeofday(&tv, NULL); 82 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 83 | } 84 | } 85 | 86 | uint64_t _glfwPlatformGetTimerFrequency(void) 87 | { 88 | return _glfw.timer.posix.frequency; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /external/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /external/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 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 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | 52 | void _glfwInitJoysticksWin32(void); 53 | void _glfwTerminateJoysticksWin32(void); 54 | void _glfwDetectJoystickConnectionWin32(void); 55 | void _glfwDetectJoystickDisconnectionWin32(void); 56 | 57 | -------------------------------------------------------------------------------- /external/glfw/src/win32_thread.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 | // Please use C89 style variable declarations in this file because VS 2010 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls) 40 | { 41 | assert(tls->win32.allocated == GLFW_FALSE); 42 | 43 | tls->win32.index = TlsAlloc(); 44 | if (tls->win32.index == TLS_OUT_OF_INDEXES) 45 | { 46 | _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, 47 | "Win32: Failed to allocate TLS index"); 48 | return GLFW_FALSE; 49 | } 50 | 51 | tls->win32.allocated = GLFW_TRUE; 52 | return GLFW_TRUE; 53 | } 54 | 55 | void _glfwPlatformDestroyTls(_GLFWtls* tls) 56 | { 57 | if (tls->win32.allocated) 58 | TlsFree(tls->win32.index); 59 | memset(tls, 0, sizeof(_GLFWtls)); 60 | } 61 | 62 | void* _glfwPlatformGetTls(_GLFWtls* tls) 63 | { 64 | assert(tls->win32.allocated == GLFW_TRUE); 65 | return TlsGetValue(tls->win32.index); 66 | } 67 | 68 | void _glfwPlatformSetTls(_GLFWtls* tls, void* value) 69 | { 70 | assert(tls->win32.allocated == GLFW_TRUE); 71 | TlsSetValue(tls->win32.index, value); 72 | } 73 | 74 | GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex) 75 | { 76 | assert(mutex->win32.allocated == GLFW_FALSE); 77 | InitializeCriticalSection(&mutex->win32.section); 78 | return mutex->win32.allocated = GLFW_TRUE; 79 | } 80 | 81 | void _glfwPlatformDestroyMutex(_GLFWmutex* mutex) 82 | { 83 | if (mutex->win32.allocated) 84 | DeleteCriticalSection(&mutex->win32.section); 85 | memset(mutex, 0, sizeof(_GLFWmutex)); 86 | } 87 | 88 | void _glfwPlatformLockMutex(_GLFWmutex* mutex) 89 | { 90 | assert(mutex->win32.allocated == GLFW_TRUE); 91 | EnterCriticalSection(&mutex->win32.section); 92 | } 93 | 94 | void _glfwPlatformUnlockMutex(_GLFWmutex* mutex) 95 | { 96 | assert(mutex->win32.allocated == GLFW_TRUE); 97 | LeaveCriticalSection(&mutex->win32.section); 98 | } 99 | 100 | -------------------------------------------------------------------------------- /external/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 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 | // Please use C89 style variable declarations in this file because VS 2010 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Initialise timer 38 | // 39 | void _glfwInitTimerWin32(void) 40 | { 41 | uint64_t frequency; 42 | 43 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 44 | { 45 | _glfw.timer.win32.hasPC = GLFW_TRUE; 46 | _glfw.timer.win32.frequency = frequency; 47 | } 48 | else 49 | { 50 | _glfw.timer.win32.hasPC = GLFW_FALSE; 51 | _glfw.timer.win32.frequency = 1000; 52 | } 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | uint64_t _glfwPlatformGetTimerValue(void) 61 | { 62 | if (_glfw.timer.win32.hasPC) 63 | { 64 | uint64_t value; 65 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 66 | return value; 67 | } 68 | else 69 | return (uint64_t) timeGetTime(); 70 | } 71 | 72 | uint64_t _glfwPlatformGetTimerFrequency(void) 73 | { 74 | return _glfw.timer.win32.frequency; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /external/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 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 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /external/glfw/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw) 3 | 4 | include_directories("${GLFW_SOURCE_DIR}/deps") 5 | 6 | if (MATH_LIBRARY) 7 | link_libraries("${MATH_LIBRARY}") 8 | endif() 9 | 10 | if (MSVC) 11 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 12 | endif() 13 | 14 | set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" 15 | "${GLFW_SOURCE_DIR}/deps/glad_gl.c") 16 | set(GLAD_VULKAN "${GLFW_SOURCE_DIR}/deps/glad/vulkan.h" 17 | "${GLFW_SOURCE_DIR}/deps/glad_vulkan.c") 18 | set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" 19 | "${GLFW_SOURCE_DIR}/deps/getopt.c") 20 | set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" 21 | "${GLFW_SOURCE_DIR}/deps/tinycthread.c") 22 | 23 | add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL}) 24 | add_executable(events events.c ${GETOPT} ${GLAD_GL}) 25 | add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL}) 26 | add_executable(glfwinfo glfwinfo.c ${GETOPT} ${GLAD_GL} ${GLAD_VULKAN}) 27 | add_executable(iconify iconify.c ${GETOPT} ${GLAD_GL}) 28 | add_executable(monitors monitors.c ${GETOPT} ${GLAD_GL}) 29 | add_executable(reopen reopen.c ${GLAD_GL}) 30 | add_executable(cursor cursor.c ${GLAD_GL}) 31 | 32 | add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD} ${GLAD_GL}) 33 | add_executable(gamma WIN32 MACOSX_BUNDLE gamma.c ${GLAD_GL}) 34 | add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD_GL}) 35 | add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD_GL}) 36 | add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD_GL}) 37 | add_executable(opacity WIN32 MACOSX_BUNDLE opacity.c ${GLAD_GL}) 38 | add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL}) 39 | add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL}) 40 | add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL}) 41 | add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) 42 | add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN}) 43 | add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GLAD_GL}) 44 | 45 | target_link_libraries(empty Threads::Threads) 46 | target_link_libraries(threads Threads::Threads) 47 | if (RT_LIBRARY) 48 | target_link_libraries(empty "${RT_LIBRARY}") 49 | target_link_libraries(threads "${RT_LIBRARY}") 50 | endif() 51 | 52 | set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks opacity tearing 53 | threads timeout title triangle-vulkan windows) 54 | set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen 55 | cursor) 56 | 57 | set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 58 | C_STANDARD 99 59 | FOLDER "GLFW3/Tests") 60 | 61 | if (MSVC) 62 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 63 | set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES 64 | LINK_FLAGS "/ENTRY:mainCRTStartup") 65 | endif() 66 | 67 | if (APPLE) 68 | set_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Empty Event") 69 | set_target_properties(gamma PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gamma") 70 | set_target_properties(inputlag PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Input Lag") 71 | set_target_properties(joysticks PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Joysticks") 72 | set_target_properties(opacity PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Opacity") 73 | set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") 74 | set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") 75 | set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") 76 | set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") 77 | set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") 78 | 79 | set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES 80 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 81 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} 82 | MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/Info.plist.in") 83 | endif() 84 | 85 | -------------------------------------------------------------------------------- /external/glfw/tests/clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Clipboard test program 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #include "getopt.h" 38 | 39 | #if defined(__APPLE__) 40 | #define MODIFIER GLFW_MOD_SUPER 41 | #else 42 | #define MODIFIER GLFW_MOD_CONTROL 43 | #endif 44 | 45 | static void usage(void) 46 | { 47 | printf("Usage: clipboard [-h]\n"); 48 | } 49 | 50 | static void error_callback(int error, const char* description) 51 | { 52 | fprintf(stderr, "Error: %s\n", description); 53 | } 54 | 55 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 56 | { 57 | if (action != GLFW_PRESS) 58 | return; 59 | 60 | switch (key) 61 | { 62 | case GLFW_KEY_ESCAPE: 63 | glfwSetWindowShouldClose(window, GLFW_TRUE); 64 | break; 65 | 66 | case GLFW_KEY_V: 67 | if (mods == MODIFIER) 68 | { 69 | const char* string; 70 | 71 | string = glfwGetClipboardString(NULL); 72 | if (string) 73 | printf("Clipboard contains \"%s\"\n", string); 74 | else 75 | printf("Clipboard does not contain a string\n"); 76 | } 77 | break; 78 | 79 | case GLFW_KEY_C: 80 | if (mods == MODIFIER) 81 | { 82 | const char* string = "Hello GLFW World!"; 83 | glfwSetClipboardString(NULL, string); 84 | printf("Setting clipboard to \"%s\"\n", string); 85 | } 86 | break; 87 | } 88 | } 89 | 90 | int main(int argc, char** argv) 91 | { 92 | int ch; 93 | GLFWwindow* window; 94 | 95 | while ((ch = getopt(argc, argv, "h")) != -1) 96 | { 97 | switch (ch) 98 | { 99 | case 'h': 100 | usage(); 101 | exit(EXIT_SUCCESS); 102 | 103 | default: 104 | usage(); 105 | exit(EXIT_FAILURE); 106 | } 107 | } 108 | 109 | glfwSetErrorCallback(error_callback); 110 | 111 | if (!glfwInit()) 112 | { 113 | fprintf(stderr, "Failed to initialize GLFW\n"); 114 | exit(EXIT_FAILURE); 115 | } 116 | 117 | window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL); 118 | if (!window) 119 | { 120 | glfwTerminate(); 121 | 122 | fprintf(stderr, "Failed to open GLFW window\n"); 123 | exit(EXIT_FAILURE); 124 | } 125 | 126 | glfwMakeContextCurrent(window); 127 | gladLoadGL(glfwGetProcAddress); 128 | glfwSwapInterval(1); 129 | 130 | glfwSetKeyCallback(window, key_callback); 131 | 132 | glClearColor(0.5f, 0.5f, 0.5f, 0); 133 | 134 | while (!glfwWindowShouldClose(window)) 135 | { 136 | glClear(GL_COLOR_BUFFER_BIT); 137 | 138 | glfwSwapBuffers(window); 139 | glfwWaitEvents(); 140 | } 141 | 142 | glfwTerminate(); 143 | exit(EXIT_SUCCESS); 144 | } 145 | 146 | -------------------------------------------------------------------------------- /external/glfw/tests/empty.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Empty event test 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | static volatile int running = GLFW_TRUE; 41 | 42 | static void error_callback(int error, const char* description) 43 | { 44 | fprintf(stderr, "Error: %s\n", description); 45 | } 46 | 47 | static int thread_main(void* data) 48 | { 49 | struct timespec time; 50 | 51 | while (running) 52 | { 53 | clock_gettime(CLOCK_REALTIME, &time); 54 | time.tv_sec += 1; 55 | thrd_sleep(&time, NULL); 56 | 57 | glfwPostEmptyEvent(); 58 | } 59 | 60 | return 0; 61 | } 62 | 63 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 64 | { 65 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 66 | glfwSetWindowShouldClose(window, GLFW_TRUE); 67 | } 68 | 69 | static float nrand(void) 70 | { 71 | return (float) rand() / (float) RAND_MAX; 72 | } 73 | 74 | int main(void) 75 | { 76 | int result; 77 | thrd_t thread; 78 | GLFWwindow* window; 79 | 80 | srand((unsigned int) time(NULL)); 81 | 82 | glfwSetErrorCallback(error_callback); 83 | 84 | if (!glfwInit()) 85 | exit(EXIT_FAILURE); 86 | 87 | window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); 88 | if (!window) 89 | { 90 | glfwTerminate(); 91 | exit(EXIT_FAILURE); 92 | } 93 | 94 | glfwMakeContextCurrent(window); 95 | gladLoadGL(glfwGetProcAddress); 96 | glfwSetKeyCallback(window, key_callback); 97 | 98 | if (thrd_create(&thread, thread_main, NULL) != thrd_success) 99 | { 100 | fprintf(stderr, "Failed to create secondary thread\n"); 101 | 102 | glfwTerminate(); 103 | exit(EXIT_FAILURE); 104 | } 105 | 106 | while (running) 107 | { 108 | int width, height; 109 | float r = nrand(), g = nrand(), b = nrand(); 110 | float l = (float) sqrt(r * r + g * g + b * b); 111 | 112 | glfwGetFramebufferSize(window, &width, &height); 113 | 114 | glViewport(0, 0, width, height); 115 | glClearColor(r / l, g / l, b / l, 1.f); 116 | glClear(GL_COLOR_BUFFER_BIT); 117 | glfwSwapBuffers(window); 118 | 119 | glfwWaitEvents(); 120 | 121 | if (glfwWindowShouldClose(window)) 122 | running = GLFW_FALSE; 123 | } 124 | 125 | glfwHideWindow(window); 126 | thrd_join(thread, &result); 127 | glfwDestroyWindow(window); 128 | 129 | glfwTerminate(); 130 | exit(EXIT_SUCCESS); 131 | } 132 | 133 | -------------------------------------------------------------------------------- /external/glfw/tests/icon.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Window icon test program 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // a simple glfw logo 39 | const char* const logo[] = 40 | { 41 | "................", 42 | "................", 43 | "...0000..0......", 44 | "...0.....0......", 45 | "...0.00..0......", 46 | "...0..0..0......", 47 | "...0000..0000...", 48 | "................", 49 | "................", 50 | "...000..0...0...", 51 | "...0....0...0...", 52 | "...000..0.0.0...", 53 | "...0....0.0.0...", 54 | "...0....00000...", 55 | "................", 56 | "................" 57 | }; 58 | 59 | const unsigned char icon_colors[5][4] = 60 | { 61 | { 0, 0, 0, 255 }, // black 62 | { 255, 0, 0, 255 }, // red 63 | { 0, 255, 0, 255 }, // green 64 | { 0, 0, 255, 255 }, // blue 65 | { 255, 255, 255, 255 } // white 66 | }; 67 | 68 | static int cur_icon_color = 0; 69 | 70 | static void set_icon(GLFWwindow* window, int icon_color) 71 | { 72 | int x, y; 73 | unsigned char pixels[16 * 16 * 4]; 74 | unsigned char* target = pixels; 75 | GLFWimage img = { 16, 16, pixels }; 76 | 77 | for (y = 0; y < img.width; y++) 78 | { 79 | for (x = 0; x < img.height; x++) 80 | { 81 | if (logo[y][x] == '0') 82 | memcpy(target, icon_colors[icon_color], 4); 83 | else 84 | memset(target, 0, 4); 85 | 86 | target += 4; 87 | } 88 | } 89 | 90 | glfwSetWindowIcon(window, 1, &img); 91 | } 92 | 93 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 94 | { 95 | if (action != GLFW_PRESS) 96 | return; 97 | 98 | switch (key) 99 | { 100 | case GLFW_KEY_ESCAPE: 101 | glfwSetWindowShouldClose(window, GLFW_TRUE); 102 | break; 103 | case GLFW_KEY_SPACE: 104 | cur_icon_color = (cur_icon_color + 1) % 5; 105 | set_icon(window, cur_icon_color); 106 | break; 107 | case GLFW_KEY_X: 108 | glfwSetWindowIcon(window, 0, NULL); 109 | break; 110 | } 111 | } 112 | 113 | int main(int argc, char** argv) 114 | { 115 | GLFWwindow* window; 116 | 117 | if (!glfwInit()) 118 | { 119 | fprintf(stderr, "Failed to initialize GLFW\n"); 120 | exit(EXIT_FAILURE); 121 | } 122 | 123 | window = glfwCreateWindow(200, 200, "Window Icon", NULL, NULL); 124 | if (!window) 125 | { 126 | glfwTerminate(); 127 | 128 | fprintf(stderr, "Failed to open GLFW window\n"); 129 | exit(EXIT_FAILURE); 130 | } 131 | 132 | glfwMakeContextCurrent(window); 133 | gladLoadGL(glfwGetProcAddress); 134 | 135 | glfwSetKeyCallback(window, key_callback); 136 | set_icon(window, cur_icon_color); 137 | 138 | while (!glfwWindowShouldClose(window)) 139 | { 140 | glClear(GL_COLOR_BUFFER_BIT); 141 | glfwSwapBuffers(window); 142 | glfwWaitEvents(); 143 | } 144 | 145 | glfwDestroyWindow(window); 146 | glfwTerminate(); 147 | exit(EXIT_SUCCESS); 148 | } 149 | 150 | -------------------------------------------------------------------------------- /external/glfw/tests/opacity.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Window opacity test program 3 | // Copyright (c) Camilla Löwy 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 | #include 27 | #define GLFW_INCLUDE_NONE 28 | #include 29 | 30 | #define NK_IMPLEMENTATION 31 | #define NK_INCLUDE_FIXED_TYPES 32 | #define NK_INCLUDE_FONT_BAKING 33 | #define NK_INCLUDE_DEFAULT_FONT 34 | #define NK_INCLUDE_DEFAULT_ALLOCATOR 35 | #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT 36 | #define NK_INCLUDE_STANDARD_VARARGS 37 | #include 38 | 39 | #define NK_GLFW_GL2_IMPLEMENTATION 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | static void error_callback(int error, const char* description) 46 | { 47 | fprintf(stderr, "Error: %s\n", description); 48 | } 49 | 50 | int main(int argc, char** argv) 51 | { 52 | GLFWwindow* window; 53 | struct nk_context* nk; 54 | struct nk_font_atlas* atlas; 55 | 56 | glfwSetErrorCallback(error_callback); 57 | 58 | if (!glfwInit()) 59 | exit(EXIT_FAILURE); 60 | 61 | glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); 62 | glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); 63 | 64 | window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); 65 | if (!window) 66 | { 67 | glfwTerminate(); 68 | exit(EXIT_FAILURE); 69 | } 70 | 71 | glfwMakeContextCurrent(window); 72 | gladLoadGL(glfwGetProcAddress); 73 | glfwSwapInterval(1); 74 | 75 | nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS); 76 | nk_glfw3_font_stash_begin(&atlas); 77 | nk_glfw3_font_stash_end(); 78 | 79 | while (!glfwWindowShouldClose(window)) 80 | { 81 | int width, height; 82 | struct nk_rect area; 83 | 84 | glfwGetWindowSize(window, &width, &height); 85 | area = nk_rect(0.f, 0.f, (float) width, (float) height); 86 | 87 | glClear(GL_COLOR_BUFFER_BIT); 88 | nk_glfw3_new_frame(); 89 | if (nk_begin(nk, "", area, 0)) 90 | { 91 | float opacity = glfwGetWindowOpacity(window); 92 | nk_layout_row_dynamic(nk, 30, 2); 93 | if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f)) 94 | glfwSetWindowOpacity(window, opacity); 95 | nk_labelf(nk, NK_TEXT_LEFT, "%0.3f", opacity); 96 | } 97 | 98 | nk_end(nk); 99 | nk_glfw3_render(NK_ANTI_ALIASING_ON); 100 | 101 | glfwSwapBuffers(window); 102 | glfwWaitEventsTimeout(1.0); 103 | } 104 | 105 | nk_glfw3_shutdown(); 106 | glfwTerminate(); 107 | exit(EXIT_SUCCESS); 108 | } 109 | 110 | -------------------------------------------------------------------------------- /external/glfw/tests/threads.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Multi-threading test 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | typedef struct 42 | { 43 | GLFWwindow* window; 44 | const char* title; 45 | float r, g, b; 46 | thrd_t id; 47 | } Thread; 48 | 49 | static volatile int running = GLFW_TRUE; 50 | 51 | static void error_callback(int error, const char* description) 52 | { 53 | fprintf(stderr, "Error: %s\n", description); 54 | } 55 | 56 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 57 | { 58 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 59 | glfwSetWindowShouldClose(window, GLFW_TRUE); 60 | } 61 | 62 | static int thread_main(void* data) 63 | { 64 | const Thread* thread = data; 65 | 66 | glfwMakeContextCurrent(thread->window); 67 | glfwSwapInterval(1); 68 | 69 | while (running) 70 | { 71 | const float v = (float) fabs(sin(glfwGetTime() * 2.f)); 72 | glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f); 73 | 74 | glClear(GL_COLOR_BUFFER_BIT); 75 | glfwSwapBuffers(thread->window); 76 | } 77 | 78 | glfwMakeContextCurrent(NULL); 79 | return 0; 80 | } 81 | 82 | int main(void) 83 | { 84 | int i, result; 85 | Thread threads[] = 86 | { 87 | { NULL, "Red", 1.f, 0.f, 0.f, 0 }, 88 | { NULL, "Green", 0.f, 1.f, 0.f, 0 }, 89 | { NULL, "Blue", 0.f, 0.f, 1.f, 0 } 90 | }; 91 | const int count = sizeof(threads) / sizeof(Thread); 92 | 93 | glfwSetErrorCallback(error_callback); 94 | 95 | if (!glfwInit()) 96 | exit(EXIT_FAILURE); 97 | 98 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 99 | 100 | for (i = 0; i < count; i++) 101 | { 102 | threads[i].window = glfwCreateWindow(200, 200, 103 | threads[i].title, 104 | NULL, NULL); 105 | if (!threads[i].window) 106 | { 107 | glfwTerminate(); 108 | exit(EXIT_FAILURE); 109 | } 110 | 111 | glfwSetKeyCallback(threads[i].window, key_callback); 112 | 113 | glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); 114 | glfwShowWindow(threads[i].window); 115 | } 116 | 117 | glfwMakeContextCurrent(threads[0].window); 118 | gladLoadGL(glfwGetProcAddress); 119 | glfwMakeContextCurrent(NULL); 120 | 121 | for (i = 0; i < count; i++) 122 | { 123 | if (thrd_create(&threads[i].id, thread_main, threads + i) != 124 | thrd_success) 125 | { 126 | fprintf(stderr, "Failed to create secondary thread\n"); 127 | 128 | glfwTerminate(); 129 | exit(EXIT_FAILURE); 130 | } 131 | } 132 | 133 | while (running) 134 | { 135 | glfwWaitEvents(); 136 | 137 | for (i = 0; i < count; i++) 138 | { 139 | if (glfwWindowShouldClose(threads[i].window)) 140 | running = GLFW_FALSE; 141 | } 142 | } 143 | 144 | for (i = 0; i < count; i++) 145 | glfwHideWindow(threads[i].window); 146 | 147 | for (i = 0; i < count; i++) 148 | thrd_join(threads[i].id, &result); 149 | 150 | exit(EXIT_SUCCESS); 151 | } 152 | 153 | -------------------------------------------------------------------------------- /external/glfw/tests/timeout.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Event wait timeout test 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | static void error_callback(int error, const char* description) 40 | { 41 | fprintf(stderr, "Error: %s\n", description); 42 | } 43 | 44 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 45 | { 46 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 47 | glfwSetWindowShouldClose(window, GLFW_TRUE); 48 | } 49 | 50 | static float nrand(void) 51 | { 52 | return (float) rand() / (float) RAND_MAX; 53 | } 54 | 55 | int main(void) 56 | { 57 | GLFWwindow* window; 58 | 59 | srand((unsigned int) time(NULL)); 60 | 61 | glfwSetErrorCallback(error_callback); 62 | 63 | if (!glfwInit()) 64 | exit(EXIT_FAILURE); 65 | 66 | window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL); 67 | if (!window) 68 | { 69 | glfwTerminate(); 70 | exit(EXIT_FAILURE); 71 | } 72 | 73 | glfwMakeContextCurrent(window); 74 | gladLoadGL(glfwGetProcAddress); 75 | glfwSetKeyCallback(window, key_callback); 76 | 77 | while (!glfwWindowShouldClose(window)) 78 | { 79 | int width, height; 80 | float r = nrand(), g = nrand(), b = nrand(); 81 | float l = (float) sqrt(r * r + g * g + b * b); 82 | 83 | glfwGetFramebufferSize(window, &width, &height); 84 | 85 | glViewport(0, 0, width, height); 86 | glClearColor(r / l, g / l, b / l, 1.f); 87 | glClear(GL_COLOR_BUFFER_BIT); 88 | glfwSwapBuffers(window); 89 | 90 | glfwWaitEventsTimeout(1.0); 91 | } 92 | 93 | glfwDestroyWindow(window); 94 | 95 | glfwTerminate(); 96 | exit(EXIT_SUCCESS); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /external/glfw/tests/title.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // UTF-8 window title test 3 | // Copyright (c) Camilla Löwy 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 | #define GLFW_INCLUDE_NONE 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | static void error_callback(int error, const char* description) 38 | { 39 | fprintf(stderr, "Error: %s\n", description); 40 | } 41 | 42 | int main(void) 43 | { 44 | GLFWwindow* window; 45 | 46 | glfwSetErrorCallback(error_callback); 47 | 48 | if (!glfwInit()) 49 | exit(EXIT_FAILURE); 50 | 51 | window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL); 52 | if (!window) 53 | { 54 | glfwTerminate(); 55 | exit(EXIT_FAILURE); 56 | } 57 | 58 | glfwMakeContextCurrent(window); 59 | gladLoadGL(glfwGetProcAddress); 60 | glfwSwapInterval(1); 61 | 62 | while (!glfwWindowShouldClose(window)) 63 | { 64 | glClear(GL_COLOR_BUFFER_BIT); 65 | glfwSwapBuffers(window); 66 | glfwWaitEvents(); 67 | } 68 | 69 | glfwTerminate(); 70 | exit(EXIT_SUCCESS); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /external/imgui/include/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. 9 | // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 12 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 13 | // https://github.com/ocornut/imgui 14 | 15 | // About GLSL version: 16 | // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. 17 | // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! 18 | 19 | #pragma once 20 | 21 | struct GLFWwindow; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 24 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 25 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 27 | 28 | // InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any. 29 | // InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks. 30 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 31 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 32 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 33 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 34 | -------------------------------------------------------------------------------- /external/imgui/include/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 2.x 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! 8 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 11 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 12 | // https://github.com/ocornut/imgui 13 | 14 | // About Desktop OpenGL function loaders: 15 | // Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. 16 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad). 17 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 18 | 19 | // About GLSL version: 20 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 21 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 22 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 23 | 24 | #pragma once 25 | 26 | // Backend API 27 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 28 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 29 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 30 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 31 | 32 | // (Optional) Called by Init/NewFrame/Shutdown 33 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 34 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 35 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 36 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 37 | 38 | // Specific OpenGL versions 39 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten 40 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android 41 | 42 | // Desktop OpenGL: attempt to detect default GL loader based on available header files. 43 | // If auto-detection fails or doesn't select the same GL loader file as used by your application, 44 | // you are likely to get a crash in ImGui_ImplOpenGL3_Init(). 45 | // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. 46 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 47 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 48 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 49 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 50 | #if defined(__has_include) 51 | #if __has_include() 52 | #define IMGUI_IMPL_OPENGL_LOADER_GLEW 53 | #elif __has_include() 54 | #define IMGUI_IMPL_OPENGL_LOADER_GLAD 55 | #elif __has_include() 56 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W 57 | #else 58 | #error "Cannot detect OpenGL loader!" 59 | #endif 60 | #else 61 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W 62 | #endif 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /external/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.0) 3 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/external) 4 | project(lua) 5 | include_directories("include") 6 | file(GLOB srcs "include/*.h" "src/*.c") 7 | add_library(lua ${srcs}) 8 | 9 | -------------------------------------------------------------------------------- /external/lua/include/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /external/lua/include/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | /* get (pointer to) instruction of given 'expdesc' */ 44 | #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) 45 | 46 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 47 | 48 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 49 | 50 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 51 | 52 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 53 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 54 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 55 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 56 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 57 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 58 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 59 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 60 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); 61 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 62 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 63 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 64 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 65 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 66 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 67 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 68 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 69 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 70 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 71 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 72 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 73 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 74 | LUAI_FUNC int luaK_jump (FuncState *fs); 75 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 76 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 77 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 78 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 79 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 80 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 81 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 82 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 83 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 84 | expdesc *v2, int line); 85 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /external/lua/include/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /external/lua/include/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /external/lua/include/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /external/lua/include/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15.1.1 2017/04/19 17:39:34 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /external/lua/include/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.79.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | } LexState; 73 | 74 | 75 | LUAI_FUNC void luaX_init (lua_State *L); 76 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 77 | TString *source, int firstchar); 78 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 79 | LUAI_FUNC void luaX_next (LexState *ls); 80 | LUAI_FUNC int luaX_lookahead (LexState *ls); 81 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 82 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /external/lua/include/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /external/lua/include/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /external/lua/include/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /external/lua/include/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23.1.2 2018/05/24 19:39:05 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 45 | TValue *value); 46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 51 | LUAI_FUNC Table *luaH_new (lua_State *L); 52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 53 | unsigned int nhsize); 54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 57 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /external/lua/include/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | 55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 59 | 60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 62 | TMS event); 63 | LUAI_FUNC void luaT_init (lua_State *L); 64 | 65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 66 | const TValue *p2, TValue *p3, int hasres); 67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 68 | StkId res, TMS event); 69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 70 | StkId res, TMS event); 71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 72 | const TValue *p2, TMS event); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /external/lua/include/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /external/lua/include/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /external/lua/include/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.41.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | /* 31 | ** You can define LUA_FLOORN2I if you want to convert floats to integers 32 | ** by flooring them (instead of raising an error if they are not 33 | ** integral values) 34 | */ 35 | #if !defined(LUA_FLOORN2I) 36 | #define LUA_FLOORN2I 0 37 | #endif 38 | 39 | 40 | #define tonumber(o,n) \ 41 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 42 | 43 | #define tointeger(o,i) \ 44 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) 45 | 46 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 47 | 48 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 49 | 50 | 51 | /* 52 | ** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, 53 | ** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, 54 | ** return 0 (meaning it will have to check metamethod) with 'slot' 55 | ** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). 56 | ** 'f' is the raw get function to use. 57 | */ 58 | #define luaV_fastget(L,t,k,slot,f) \ 59 | (!ttistable(t) \ 60 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 61 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ 62 | !ttisnil(slot))) /* result not nil? */ 63 | 64 | /* 65 | ** standard implementation for 'gettable' 66 | */ 67 | #define luaV_gettable(L,t,k,v) { const TValue *slot; \ 68 | if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ 69 | else luaV_finishget(L,t,k,v,slot); } 70 | 71 | 72 | /* 73 | ** Fast track for set table. If 't' is a table and 't[k]' is not nil, 74 | ** call GC barrier, do a raw 't[k]=v', and return true; otherwise, 75 | ** return false with 'slot' equal to NULL (if 't' is not a table) or 76 | ** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro 77 | ** returns true, there is no need to 'invalidateTMcache', because the 78 | ** call is not creating a new entry. 79 | */ 80 | #define luaV_fastset(L,t,k,slot,f,v) \ 81 | (!ttistable(t) \ 82 | ? (slot = NULL, 0) \ 83 | : (slot = f(hvalue(t), k), \ 84 | ttisnil(slot) ? 0 \ 85 | : (luaC_barrierback(L, hvalue(t), v), \ 86 | setobj2t(L, cast(TValue *,slot), v), \ 87 | 1))) 88 | 89 | 90 | #define luaV_settable(L,t,k,v) { const TValue *slot; \ 91 | if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ 92 | luaV_finishset(L,t,k,v,slot); } 93 | 94 | 95 | 96 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 97 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 98 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 99 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 100 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); 101 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 102 | StkId val, const TValue *slot); 103 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 104 | StkId val, const TValue *slot); 105 | LUAI_FUNC void luaV_finishOp (lua_State *L); 106 | LUAI_FUNC void luaV_execute (lua_State *L); 107 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 108 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 109 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 110 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 111 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /external/lua/include/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /external/lua/src/lcorolib.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcorolib.c,v 1.10.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Coroutine Library 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lcorolib_c 8 | #define LUA_LIB 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "lauxlib.h" 18 | #include "lualib.h" 19 | 20 | 21 | static lua_State *getco (lua_State *L) { 22 | lua_State *co = lua_tothread(L, 1); 23 | luaL_argcheck(L, co, 1, "thread expected"); 24 | return co; 25 | } 26 | 27 | 28 | static int auxresume (lua_State *L, lua_State *co, int narg) { 29 | int status; 30 | if (!lua_checkstack(co, narg)) { 31 | lua_pushliteral(L, "too many arguments to resume"); 32 | return -1; /* error flag */ 33 | } 34 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { 35 | lua_pushliteral(L, "cannot resume dead coroutine"); 36 | return -1; /* error flag */ 37 | } 38 | lua_xmove(L, co, narg); 39 | status = lua_resume(co, L, narg); 40 | if (status == LUA_OK || status == LUA_YIELD) { 41 | int nres = lua_gettop(co); 42 | if (!lua_checkstack(L, nres + 1)) { 43 | lua_pop(co, nres); /* remove results anyway */ 44 | lua_pushliteral(L, "too many results to resume"); 45 | return -1; /* error flag */ 46 | } 47 | lua_xmove(co, L, nres); /* move yielded values */ 48 | return nres; 49 | } 50 | else { 51 | lua_xmove(co, L, 1); /* move error message */ 52 | return -1; /* error flag */ 53 | } 54 | } 55 | 56 | 57 | static int luaB_coresume (lua_State *L) { 58 | lua_State *co = getco(L); 59 | int r; 60 | r = auxresume(L, co, lua_gettop(L) - 1); 61 | if (r < 0) { 62 | lua_pushboolean(L, 0); 63 | lua_insert(L, -2); 64 | return 2; /* return false + error message */ 65 | } 66 | else { 67 | lua_pushboolean(L, 1); 68 | lua_insert(L, -(r + 1)); 69 | return r + 1; /* return true + 'resume' returns */ 70 | } 71 | } 72 | 73 | 74 | static int luaB_auxwrap (lua_State *L) { 75 | lua_State *co = lua_tothread(L, lua_upvalueindex(1)); 76 | int r = auxresume(L, co, lua_gettop(L)); 77 | if (r < 0) { 78 | if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ 79 | luaL_where(L, 1); /* add extra info */ 80 | lua_insert(L, -2); 81 | lua_concat(L, 2); 82 | } 83 | return lua_error(L); /* propagate error */ 84 | } 85 | return r; 86 | } 87 | 88 | 89 | static int luaB_cocreate (lua_State *L) { 90 | lua_State *NL; 91 | luaL_checktype(L, 1, LUA_TFUNCTION); 92 | NL = lua_newthread(L); 93 | lua_pushvalue(L, 1); /* move function to top */ 94 | lua_xmove(L, NL, 1); /* move function from L to NL */ 95 | return 1; 96 | } 97 | 98 | 99 | static int luaB_cowrap (lua_State *L) { 100 | luaB_cocreate(L); 101 | lua_pushcclosure(L, luaB_auxwrap, 1); 102 | return 1; 103 | } 104 | 105 | 106 | static int luaB_yield (lua_State *L) { 107 | return lua_yield(L, lua_gettop(L)); 108 | } 109 | 110 | 111 | static int luaB_costatus (lua_State *L) { 112 | lua_State *co = getco(L); 113 | if (L == co) lua_pushliteral(L, "running"); 114 | else { 115 | switch (lua_status(co)) { 116 | case LUA_YIELD: 117 | lua_pushliteral(L, "suspended"); 118 | break; 119 | case LUA_OK: { 120 | lua_Debug ar; 121 | if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ 122 | lua_pushliteral(L, "normal"); /* it is running */ 123 | else if (lua_gettop(co) == 0) 124 | lua_pushliteral(L, "dead"); 125 | else 126 | lua_pushliteral(L, "suspended"); /* initial state */ 127 | break; 128 | } 129 | default: /* some error occurred */ 130 | lua_pushliteral(L, "dead"); 131 | break; 132 | } 133 | } 134 | return 1; 135 | } 136 | 137 | 138 | static int luaB_yieldable (lua_State *L) { 139 | lua_pushboolean(L, lua_isyieldable(L)); 140 | return 1; 141 | } 142 | 143 | 144 | static int luaB_corunning (lua_State *L) { 145 | int ismain = lua_pushthread(L); 146 | lua_pushboolean(L, ismain); 147 | return 2; 148 | } 149 | 150 | 151 | static const luaL_Reg co_funcs[] = { 152 | {"create", luaB_cocreate}, 153 | {"resume", luaB_coresume}, 154 | {"running", luaB_corunning}, 155 | {"status", luaB_costatus}, 156 | {"wrap", luaB_cowrap}, 157 | {"yield", luaB_yield}, 158 | {"isyieldable", luaB_yieldable}, 159 | {NULL, NULL} 160 | }; 161 | 162 | 163 | 164 | LUAMOD_API int luaopen_coroutine (lua_State *L) { 165 | luaL_newlib(L, co_funcs); 166 | return 1; 167 | } 168 | 169 | -------------------------------------------------------------------------------- /external/lua/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /external/lua/src/lfunc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.c,v 2.45.1.1 2017/04/19 17:39:34 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lfunc_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "lfunc.h" 18 | #include "lgc.h" 19 | #include "lmem.h" 20 | #include "lobject.h" 21 | #include "lstate.h" 22 | 23 | 24 | 25 | CClosure *luaF_newCclosure (lua_State *L, int n) { 26 | GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); 27 | CClosure *c = gco2ccl(o); 28 | c->nupvalues = cast_byte(n); 29 | return c; 30 | } 31 | 32 | 33 | LClosure *luaF_newLclosure (lua_State *L, int n) { 34 | GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); 35 | LClosure *c = gco2lcl(o); 36 | c->p = NULL; 37 | c->nupvalues = cast_byte(n); 38 | while (n--) c->upvals[n] = NULL; 39 | return c; 40 | } 41 | 42 | /* 43 | ** fill a closure with new closed upvalues 44 | */ 45 | void luaF_initupvals (lua_State *L, LClosure *cl) { 46 | int i; 47 | for (i = 0; i < cl->nupvalues; i++) { 48 | UpVal *uv = luaM_new(L, UpVal); 49 | uv->refcount = 1; 50 | uv->v = &uv->u.value; /* make it closed */ 51 | setnilvalue(uv->v); 52 | cl->upvals[i] = uv; 53 | } 54 | } 55 | 56 | 57 | UpVal *luaF_findupval (lua_State *L, StkId level) { 58 | UpVal **pp = &L->openupval; 59 | UpVal *p; 60 | UpVal *uv; 61 | lua_assert(isintwups(L) || L->openupval == NULL); 62 | while (*pp != NULL && (p = *pp)->v >= level) { 63 | lua_assert(upisopen(p)); 64 | if (p->v == level) /* found a corresponding upvalue? */ 65 | return p; /* return it */ 66 | pp = &p->u.open.next; 67 | } 68 | /* not found: create a new upvalue */ 69 | uv = luaM_new(L, UpVal); 70 | uv->refcount = 0; 71 | uv->u.open.next = *pp; /* link it to list of open upvalues */ 72 | uv->u.open.touched = 1; 73 | *pp = uv; 74 | uv->v = level; /* current value lives in the stack */ 75 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ 76 | L->twups = G(L)->twups; /* link it to the list */ 77 | G(L)->twups = L; 78 | } 79 | return uv; 80 | } 81 | 82 | 83 | void luaF_close (lua_State *L, StkId level) { 84 | UpVal *uv; 85 | while (L->openupval != NULL && (uv = L->openupval)->v >= level) { 86 | lua_assert(upisopen(uv)); 87 | L->openupval = uv->u.open.next; /* remove from 'open' list */ 88 | if (uv->refcount == 0) /* no references? */ 89 | luaM_free(L, uv); /* free upvalue */ 90 | else { 91 | setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ 92 | uv->v = &uv->u.value; /* now current value lives here */ 93 | luaC_upvalbarrier(L, uv); 94 | } 95 | } 96 | } 97 | 98 | 99 | Proto *luaF_newproto (lua_State *L) { 100 | GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); 101 | Proto *f = gco2p(o); 102 | f->k = NULL; 103 | f->sizek = 0; 104 | f->p = NULL; 105 | f->sizep = 0; 106 | f->code = NULL; 107 | f->cache = NULL; 108 | f->sizecode = 0; 109 | f->lineinfo = NULL; 110 | f->sizelineinfo = 0; 111 | f->upvalues = NULL; 112 | f->sizeupvalues = 0; 113 | f->numparams = 0; 114 | f->is_vararg = 0; 115 | f->maxstacksize = 0; 116 | f->locvars = NULL; 117 | f->sizelocvars = 0; 118 | f->linedefined = 0; 119 | f->lastlinedefined = 0; 120 | f->source = NULL; 121 | return f; 122 | } 123 | 124 | 125 | void luaF_freeproto (lua_State *L, Proto *f) { 126 | luaM_freearray(L, f->code, f->sizecode); 127 | luaM_freearray(L, f->p, f->sizep); 128 | luaM_freearray(L, f->k, f->sizek); 129 | luaM_freearray(L, f->lineinfo, f->sizelineinfo); 130 | luaM_freearray(L, f->locvars, f->sizelocvars); 131 | luaM_freearray(L, f->upvalues, f->sizeupvalues); 132 | luaM_free(L, f); 133 | } 134 | 135 | 136 | /* 137 | ** Look for n-th local variable at line 'line' in function 'func'. 138 | ** Returns NULL if not found. 139 | */ 140 | const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { 141 | int i; 142 | for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { 143 | if (pc < f->locvars[i].endpc) { /* is variable active? */ 144 | local_number--; 145 | if (local_number == 0) 146 | return getstr(f->locvars[i].varname); 147 | } 148 | } 149 | return NULL; /* not found */ 150 | } 151 | 152 | -------------------------------------------------------------------------------- /external/lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /external/lua/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.91.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ 89 | if (g->version) { /* is state fully built? */ 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | } 93 | if (newblock == NULL) 94 | luaD_throw(L, LUA_ERRMEM); 95 | } 96 | lua_assert((nsize == 0) == (newblock == NULL)); 97 | g->GCdebt = (g->GCdebt + nsize) - realosize; 98 | return newblock; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /external/lua/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.55.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Opcodes for Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lopcodes.h" 16 | 17 | 18 | /* ORDER OP */ 19 | 20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { 21 | "MOVE", 22 | "LOADK", 23 | "LOADKX", 24 | "LOADBOOL", 25 | "LOADNIL", 26 | "GETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "SETTABUP", 30 | "SETUPVAL", 31 | "SETTABLE", 32 | "NEWTABLE", 33 | "SELF", 34 | "ADD", 35 | "SUB", 36 | "MUL", 37 | "MOD", 38 | "POW", 39 | "DIV", 40 | "IDIV", 41 | "BAND", 42 | "BOR", 43 | "BXOR", 44 | "SHL", 45 | "SHR", 46 | "UNM", 47 | "BNOT", 48 | "NOT", 49 | "LEN", 50 | "CONCAT", 51 | "JMP", 52 | "EQ", 53 | "LT", 54 | "LE", 55 | "TEST", 56 | "TESTSET", 57 | "CALL", 58 | "TAILCALL", 59 | "RETURN", 60 | "FORLOOP", 61 | "FORPREP", 62 | "TFORCALL", 63 | "TFORLOOP", 64 | "SETLIST", 65 | "CLOSURE", 66 | "VARARG", 67 | "EXTRAARG", 68 | NULL 69 | }; 70 | 71 | 72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 73 | 74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 75 | /* T A B C mode opcode */ 76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ 79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ 81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ 83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ 85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ 96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ 97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ 98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ 99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ 100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ 101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ 103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ 111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ 118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ 119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ 123 | }; 124 | 125 | -------------------------------------------------------------------------------- /external/lua/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /external/lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /external/serial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.0) 3 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/external) 4 | project(serial) 5 | include_directories("include") 6 | file(GLOB srcs "include/serial/*.h" "src/*.cc") 7 | 8 | if(UNIX) 9 | list(APPEND srcs src/impl/unix.cc) 10 | list(APPEND srcs src/impl/list_ports/list_ports_linux.cc) 11 | else() 12 | list(APPEND srcs src/impl/win.cc) 13 | list(APPEND srcs src/impl/list_ports/list_ports_win.cc) 14 | endif() 15 | 16 | add_library(serial ${srcs}) 17 | -------------------------------------------------------------------------------- /external/serial/include/serial/v8stdint.h: -------------------------------------------------------------------------------- 1 | // This header is from the v8 google project: 2 | // http://code.google.com/p/v8/source/browse/trunk/include/v8stdint.h 3 | 4 | // Copyright 2012 the V8 project authors. All rights reserved. 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following 13 | // disclaimer in the documentation and/or other materials provided 14 | // with the distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived 17 | // from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Load definitions of standard types. 32 | 33 | #ifndef V8STDINT_H_ 34 | #define V8STDINT_H_ 35 | 36 | #include 37 | #include 38 | 39 | #if defined(_WIN32) && !defined(__MINGW32__) 40 | 41 | typedef signed char int8_t; 42 | typedef unsigned char uint8_t; 43 | typedef short int16_t; // NOLINT 44 | typedef unsigned short uint16_t; // NOLINT 45 | typedef int int32_t; 46 | typedef unsigned int uint32_t; 47 | typedef __int64 int64_t; 48 | typedef unsigned __int64 uint64_t; 49 | // intptr_t and friends are defined in crtdefs.h through stdio.h. 50 | 51 | #else 52 | 53 | #include 54 | 55 | #endif 56 | 57 | #endif // V8STDINT_H_ 58 | -------------------------------------------------------------------------------- /external/serial/src/impl/list_ports/list_ports_win.cc: -------------------------------------------------------------------------------- 1 | #if defined(_WIN32) 2 | 3 | /* 4 | * Copyright (c) 2014 Craig Lilley 5 | * This software is made available under the terms of the MIT licence. 6 | * A copy of the licence can be obtained from: 7 | * http://opensource.org/licenses/MIT 8 | */ 9 | 10 | #include "serial/serial.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using serial::PortInfo; 19 | using std::vector; 20 | using std::string; 21 | 22 | static const DWORD port_name_max_length = 256; 23 | static const DWORD friendly_name_max_length = 256; 24 | static const DWORD hardware_id_max_length = 256; 25 | 26 | // Convert a wide Unicode string to an UTF8 string 27 | std::string utf8_encode(const std::wstring &wstr) 28 | { 29 | int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); 30 | std::string strTo( size_needed, 0 ); 31 | WideCharToMultiByte (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); 32 | return strTo; 33 | } 34 | 35 | vector 36 | serial::list_ports() 37 | { 38 | vector devices_found; 39 | 40 | HDEVINFO device_info_set = SetupDiGetClassDevs( 41 | (const GUID *) &GUID_DEVCLASS_PORTS, 42 | NULL, 43 | NULL, 44 | DIGCF_PRESENT); 45 | 46 | unsigned int device_info_set_index = 0; 47 | SP_DEVINFO_DATA device_info_data; 48 | 49 | device_info_data.cbSize = sizeof(SP_DEVINFO_DATA); 50 | 51 | while(SetupDiEnumDeviceInfo(device_info_set, device_info_set_index, &device_info_data)) 52 | { 53 | device_info_set_index++; 54 | 55 | // Get port name 56 | 57 | HKEY hkey = SetupDiOpenDevRegKey( 58 | device_info_set, 59 | &device_info_data, 60 | DICS_FLAG_GLOBAL, 61 | 0, 62 | DIREG_DEV, 63 | KEY_READ); 64 | 65 | TCHAR port_name[port_name_max_length]; 66 | DWORD port_name_length = port_name_max_length; 67 | 68 | LONG return_code = RegQueryValueEx( 69 | hkey, 70 | _T("PortName"), 71 | NULL, 72 | NULL, 73 | (LPBYTE)port_name, 74 | &port_name_length); 75 | 76 | RegCloseKey(hkey); 77 | 78 | if(return_code != EXIT_SUCCESS) 79 | continue; 80 | 81 | if(port_name_length > 0 && port_name_length <= port_name_max_length) 82 | port_name[port_name_length-1] = '\0'; 83 | else 84 | port_name[0] = '\0'; 85 | 86 | // Ignore parallel ports 87 | 88 | if(_tcsstr(port_name, _T("LPT")) != NULL) 89 | continue; 90 | 91 | // Get port friendly name 92 | 93 | TCHAR friendly_name[friendly_name_max_length]; 94 | DWORD friendly_name_actual_length = 0; 95 | 96 | BOOL got_friendly_name = SetupDiGetDeviceRegistryProperty( 97 | device_info_set, 98 | &device_info_data, 99 | SPDRP_FRIENDLYNAME, 100 | NULL, 101 | (PBYTE)friendly_name, 102 | friendly_name_max_length, 103 | &friendly_name_actual_length); 104 | 105 | if(got_friendly_name == TRUE && friendly_name_actual_length > 0) 106 | friendly_name[friendly_name_actual_length-1] = '\0'; 107 | else 108 | friendly_name[0] = '\0'; 109 | 110 | // Get hardware ID 111 | 112 | TCHAR hardware_id[hardware_id_max_length]; 113 | DWORD hardware_id_actual_length = 0; 114 | 115 | BOOL got_hardware_id = SetupDiGetDeviceRegistryProperty( 116 | device_info_set, 117 | &device_info_data, 118 | SPDRP_HARDWAREID, 119 | NULL, 120 | (PBYTE)hardware_id, 121 | hardware_id_max_length, 122 | &hardware_id_actual_length); 123 | 124 | if(got_hardware_id == TRUE && hardware_id_actual_length > 0) 125 | hardware_id[hardware_id_actual_length-1] = '\0'; 126 | else 127 | hardware_id[0] = '\0'; 128 | 129 | #ifdef UNICODE 130 | std::string portName = utf8_encode(port_name); 131 | std::string friendlyName = utf8_encode(friendly_name); 132 | std::string hardwareId = utf8_encode(hardware_id); 133 | #else 134 | std::string portName = port_name; 135 | std::string friendlyName = friendly_name; 136 | std::string hardwareId = hardware_id; 137 | #endif 138 | 139 | PortInfo port_entry; 140 | port_entry.port = portName; 141 | port_entry.description = friendlyName; 142 | port_entry.hardware_id = hardwareId; 143 | 144 | devices_found.push_back(port_entry); 145 | } 146 | 147 | SetupDiDestroyDeviceInfoList(device_info_set); 148 | 149 | return devices_found; 150 | } 151 | 152 | #endif // #if defined(_WIN32) 153 | -------------------------------------------------------------------------------- /resources/fonts/input_mono_medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andydbc/Dot/b3d9f2c1a46c3dda3910f018a50b64e0f9754539/resources/fonts/input_mono_medium.ttf -------------------------------------------------------------------------------- /resources/fonts/input_mono_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andydbc/Dot/b3d9f2c1a46c3dda3910f018a50b64e0f9754539/resources/fonts/input_mono_regular.ttf -------------------------------------------------------------------------------- /resources/scripts/dot_dither.lua: -------------------------------------------------------------------------------- 1 | 2 | local lib = {} 3 | 4 | local matrix = {} 5 | matrix[0] = {} 6 | matrix[1] = {} 7 | matrix[2] = {} 8 | matrix[3] = {} 9 | 10 | matrix[0][0] = 1 11 | matrix[0][1] = 9 12 | matrix[0][2] = 3 13 | matrix[0][3] = 11 14 | matrix[1][0] = 13 15 | matrix[1][1] = 5 16 | matrix[1][2] = 15 17 | matrix[1][3] = 7 18 | matrix[2][0] = 4 19 | matrix[2][1] = 12 20 | matrix[2][2] = 2 21 | matrix[2][3] = 10 22 | matrix[3][0] = 16 23 | matrix[3][1] = 8 24 | matrix[3][2] = 14 25 | matrix[3][3] = 6 26 | 27 | function lib.dither(x, y, r, f) 28 | -- r = 1.0 / 8.0 29 | xx = math.fmod(x, 4) 30 | yy = math.fmod(y, 4) 31 | return r * matrix[xx][yy] * f 32 | end 33 | 34 | return lib -------------------------------------------------------------------------------- /resources/scripts/dot_math.lua: -------------------------------------------------------------------------------- 1 | local lib = {} 2 | 3 | function lib.dist(x1, y1, x2, y2) 4 | x = x1-x2 5 | y = y1-y2 6 | return math.sqrt(x*x+y*y) 7 | end 8 | 9 | function lib.clamp(n, low, high) 10 | return math.min(math.max(n, low), high) 11 | end 12 | 13 | function lib.lerp(a, b, t) 14 | return a + (b - a) * t 15 | end 16 | 17 | function lib.smin(d1, d2, k) 18 | h = lib.clamp(0.5 + 0.5 * (d2-d1) / k, 0.0, 1.0) 19 | return lib.lerp(d2, d1, h) - k * h * (1.0-h) 20 | end 21 | 22 | return lib -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Platform 4 | #ifdef _MSC_VER 5 | #define DOT_WINDOWS 6 | #else 7 | #define DOT_UNIX 8 | #endif 9 | 10 | // Namespaces 11 | #define DOT_NS_BEGIN namespace dot { 12 | #define DOT_NS_END } 13 | 14 | #include 15 | #include 16 | 17 | // Version MAJOR.MINOR.PATCH 18 | #define DOT_VERSION_MAJOR 0 19 | #define DOT_VERSION_MINOR 2 20 | #define DOT_VERSION_PATCH 3 21 | 22 | #define STR_HELPER(x) #x 23 | #define STR(x) STR_HELPER(x) 24 | 25 | #define DOT_VERSION_STR STR(DOT_VERSION_MAJOR.DOT_VERSION_MINOR.DOT_VERSION_PATCH) 26 | 27 | using Window = GLFWwindow; 28 | typedef Window* WindowPtr; -------------------------------------------------------------------------------- /src/controller.cpp: -------------------------------------------------------------------------------- 1 | #include "controller.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static size_t buffer_length = 1024 * 10; 9 | static char defaultScript[1024] = "-- welcome to Dot - v0.1 \n\n" 10 | "function all_whites()\n" 11 | " return 1 \n" 12 | "end\n\n" 13 | "function all_blacks()\n" 14 | " return 0\n" 15 | "end\n\n" 16 | "function main(x, y, frame)\n" 17 | " return all_whites()\n" 18 | "end"; 19 | 20 | static const char* entry = "main"; 21 | 22 | DOT_NS_BEGIN 23 | 24 | controller::controller() 25 | { 26 | open_midi(); 27 | _script.resize(buffer_length); 28 | memcpy(&_script[0], &defaultScript[0], buffer_length); 29 | 30 | std::string packages = "package.path = package.path .. \";resources/scripts/?.lua\""; 31 | _interpreter.run_from_memory(packages); 32 | _interpreter.run_from_memory(&_script[0]); 33 | 34 | _frame_count = 0; 35 | } 36 | 37 | controller::controller(hardware& hardware) 38 | { 39 | open_midi(); 40 | _pixels.resize(hardware.rows * hardware.colums); 41 | _hardware = hardware; 42 | 43 | _script.resize(buffer_length); 44 | memcpy(&_script[0], &defaultScript[0], buffer_length); 45 | 46 | std::string packages = "package.path = package.path .. \";resources/scripts/?.lua\""; 47 | _interpreter.run_from_memory(packages); 48 | _interpreter.run_from_memory(&_script[0]); 49 | 50 | _frame_count = 0; 51 | } 52 | 53 | void controller::open_midi() 54 | { 55 | unsigned int ports_count = _midi.getPortCount(); 56 | 57 | if (ports_count > 0) 58 | _midi.openPort(0); 59 | } 60 | 61 | void controller::execute(bool reload) 62 | { 63 | if (reload) 64 | { 65 | _exec_sucess = _interpreter.run_from_memory(&_script[0]); 66 | } 67 | 68 | if (!_exec_sucess) 69 | { 70 | return; 71 | } 72 | 73 | for (int j = 0; j < _hardware.colums; ++j) 74 | { 75 | for (int i = 0; i < _hardware.rows; ++i) 76 | { 77 | int value = _interpreter.call(entry, i, j, _frame_count); 78 | int idx = i + _hardware.rows * j; 79 | _pixels[idx] = value; 80 | } 81 | } 82 | _frame_count++; 83 | 84 | std::vector msg; 85 | _midi.getMessage(&msg); 86 | int nBytes = msg.size(); 87 | if(nBytes == 3) 88 | { 89 | _interpreter.call("on_midi_input", msg[0], msg[1]); 90 | } 91 | } 92 | 93 | void controller::set_hardware(const hardware& h) 94 | { 95 | _pixels.resize(h.rows * h.colums); 96 | _hardware = h; 97 | } 98 | 99 | 100 | void controller::from_file(const std::string& script) 101 | { 102 | std::ifstream script_file(script); 103 | if (script_file) 104 | { 105 | memset(&_script[0], 0, buffer_length); 106 | script_file.seekg(0, std::ios::end); 107 | std::streampos length = script_file.tellg(); 108 | script_file.seekg(0, std::ios::beg); 109 | script_file.read(&_script[0], length); 110 | 111 | _script_path = script; 112 | } 113 | 114 | execute(true); 115 | } 116 | 117 | void controller::get_script(std::vector& buffer) 118 | { 119 | buffer.resize(_script.size()); 120 | memcpy(&buffer[0], &_script[0], _script.size()); 121 | } 122 | 123 | void controller::set_script(std::vector& buffer) 124 | { 125 | _script.resize(_script.size()); 126 | memcpy(&_script[0], &buffer[0], buffer.size()); 127 | } 128 | 129 | void controller::save_script() 130 | { 131 | if (!_script_path.empty()) 132 | { 133 | std::ofstream script; 134 | script.open(_script_path); 135 | auto it = std::find(_script.begin(), _script.end(), '\0'); 136 | script.write(&_script[0], std::distance(_script.begin(), it)); 137 | script.close(); 138 | } 139 | } 140 | 141 | void controller::send() 142 | { 143 | if (_hardware.port.empty()) 144 | return; 145 | 146 | if (!_serial.isOpen()) 147 | { 148 | _serial.setPort(_hardware.port); 149 | _serial.setBaudrate(9600); 150 | auto timeout = serial::Timeout::simpleTimeout(1000); 151 | _serial.setTimeout(timeout); 152 | _serial.open(); 153 | } 154 | 155 | int panel_width = 7; 156 | int num_panels = _hardware.rows / panel_width; 157 | 158 | for (int p = 0; p < num_panels; ++p) 159 | { 160 | int panel = p; 161 | 162 | std::bitset<8> panelmask; 163 | panelmask[(num_panels - 1) - panel] = 1; 164 | 165 | std::vector msg; 166 | msg.push_back(0x80); 167 | msg.push_back(0x83); 168 | msg.push_back((unsigned char)panelmask.to_ulong()); 169 | 170 | for (int32_t y = 0; y < _hardware.colums; ++y) 171 | { 172 | std::bitset<8> bitmask; 173 | 174 | for(int i = 0; i < panel_width; ++i) 175 | { 176 | int idx = (i + _hardware.rows * y) + panel_width * p; 177 | bitmask[i] = _pixels[idx]; 178 | } 179 | 180 | unsigned long b = bitmask.to_ulong(); 181 | msg.push_back((unsigned char)b); 182 | } 183 | 184 | msg.push_back(0x8F); 185 | _serial.write(&msg[0], msg.size()); 186 | } 187 | } 188 | 189 | DOT_NS_END 190 | -------------------------------------------------------------------------------- /src/controller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "interpreter.h" 5 | 6 | #include "RtMidi.h" 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | DOT_NS_BEGIN 13 | 14 | struct hardware 15 | { 16 | int rows; 17 | int colums; 18 | std::string port; 19 | }; 20 | 21 | class controller 22 | { 23 | public: 24 | 25 | controller(); 26 | controller(hardware& description); 27 | 28 | void execute(bool reload = false); 29 | 30 | void open_midi(); 31 | void set_hardware(const hardware& h); 32 | 33 | void from_file(const std::string& script); 34 | 35 | void get_script(std::vector& buffer); 36 | void set_script(std::vector& buffer); 37 | 38 | const std::vector& get_pixels() const 39 | { 40 | return _pixels; 41 | } 42 | 43 | const std::string& get_script_path() { return _script_path; } 44 | void save_script(); 45 | 46 | hardware& get_hardware() { return _hardware; } 47 | interpreter& get_interpreter() { return _interpreter; } 48 | 49 | void send(); 50 | 51 | private: 52 | 53 | hardware _hardware; 54 | interpreter _interpreter; 55 | std::vector _script; 56 | std::vector _pixels; 57 | std::string _script_path; 58 | int _frame_count; 59 | bool _exec_sucess; 60 | 61 | serial::Serial _serial; 62 | RtMidiIn _midi; 63 | }; 64 | 65 | DOT_NS_END -------------------------------------------------------------------------------- /src/dot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "controller.h" 5 | #include "interpreter.h" 6 | #include "view.h" 7 | #include "window.h" -------------------------------------------------------------------------------- /src/editor_view.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "dot.h" 4 | 5 | class editor_view : public dot::view 6 | { 7 | public: 8 | editor_view(dot::controller* c) : _controller(c) { } 9 | 10 | void initialize(dot::window& w) override; 11 | void on_render(dot::window& w) override; 12 | 13 | void on_save(); 14 | private: 15 | bool _has_changes; 16 | std::vector _buffer; 17 | dot::controller* _controller; 18 | }; -------------------------------------------------------------------------------- /src/interpreter.cpp: -------------------------------------------------------------------------------- 1 | #include "interpreter.h" 2 | 3 | DOT_NS_BEGIN 4 | 5 | interpreter::interpreter() 6 | { 7 | _lua = std::shared_ptr( 8 | luaL_newstate(), 9 | lua_close 10 | ); 11 | 12 | luaL_openlibs(_lua.get()); 13 | } 14 | 15 | bool interpreter::run_from_memory(const std::string& code) 16 | { 17 | return luaL_dostring(_lua.get(), code.c_str())==0; 18 | } 19 | 20 | bool interpreter::run_from_file(const std::string& filepath) 21 | { 22 | return luaL_dofile(_lua.get(), filepath.c_str())==0; 23 | } 24 | 25 | int interpreter::wrapper(StatePtr state) 26 | { 27 | auto* lambda = (std::function*)lua_touserdata(state, lua_upvalueindex(1)); 28 | return (*lambda)(state); 29 | } 30 | 31 | DOT_NS_END -------------------------------------------------------------------------------- /src/interpreter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern "C" { 14 | #include 15 | #include 16 | #include 17 | } 18 | 19 | using State = lua_State; 20 | typedef State* StatePtr; 21 | 22 | DOT_NS_BEGIN 23 | 24 | namespace detail 25 | { 26 | template 27 | inline T get(std::shared_ptr _lua) { } 28 | 29 | template<> 30 | inline int get(std::shared_ptr _lua) 31 | { 32 | int value = (int)lua_tointeger(_lua.get(), -1); 33 | lua_pop(_lua.get(), 1); 34 | return value; 35 | } 36 | 37 | template<> 38 | inline float get(std::shared_ptr _lua) 39 | { 40 | float value = (float)lua_tonumber(_lua.get(), -1); 41 | lua_pop(_lua.get(), 1); 42 | return value; 43 | } 44 | } 45 | 46 | class interpreter 47 | { 48 | public: 49 | 50 | interpreter(); 51 | 52 | bool run_from_memory(const std::string& code); 53 | bool run_from_file(const std::string& filepath); 54 | 55 | template 56 | void add(const std::string& name, To function(Ts...)) 57 | { 58 | std::function lambda; 59 | lambda = [this, function](StatePtr state) 60 | { 61 | To r = function(); 62 | this->push(r); 63 | return 1; 64 | }; 65 | 66 | _functions[name] = lambda; 67 | 68 | lua_pushlightuserdata(_lua.get(), &_functions[name]); 69 | lua_pushcclosure(_lua.get(), interpreter::wrapper, 1); 70 | lua_setglobal(_lua.get(), name.c_str()); 71 | } 72 | 73 | template 74 | To call(const std::string& name, Ts... args) 75 | { 76 | lua_getglobal(_lua.get(), name.c_str()); 77 | auto args_tuple = std::tuple(args...); 78 | push(args_tuple); 79 | auto args_count = sizeof...(args); 80 | 81 | if (lua_pcall(_lua.get(), args_count, 1, 0)) 82 | { 83 | std::cout << lua_tostring(_lua.get(), -1) << std::endl; 84 | } 85 | 86 | return get(); 87 | } 88 | 89 | private: 90 | 91 | static int wrapper(StatePtr state); 92 | 93 | template 94 | inline typename std::enable_if::type 95 | push(std::tuple& t) { } 96 | 97 | template 98 | inline typename std::enable_if < I < sizeof...(Tp), void>::type 99 | push(std::tuple& t) 100 | { 101 | push(std::get(t)); 102 | push(t); 103 | } 104 | 105 | void push(void) { } 106 | void push(int v) { lua_pushinteger(_lua.get(), v); } 107 | void push(float v) { lua_pushnumber(_lua.get(), v); } 108 | 109 | template 110 | T get() { return detail::get(_lua); } 111 | 112 | private: 113 | 114 | std::shared_ptr _lua; 115 | std::map> _functions; 116 | }; 117 | 118 | DOT_NS_END 119 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "dot.h" 2 | 3 | #include "editor_view.h" 4 | 5 | #include 6 | #include 7 | 8 | std::string window_title = "Dot"; 9 | int window_width = 1000; 10 | int window_height = 600; 11 | bool refresh = false; 12 | 13 | void on_error(int action,const char* msg) 14 | { 15 | std::cout << msg << std::endl; 16 | } 17 | 18 | void on_key(dot::window& w, int action, int mod, int key) 19 | { 20 | if (action == GLFW_PRESS) 21 | { 22 | if (key == GLFW_KEY_ESCAPE) 23 | w.close(); 24 | if (key == GLFW_KEY_F5) 25 | refresh = true; 26 | if (mod == GLFW_MOD_CONTROL && key == GLFW_KEY_S) 27 | w.get_view().get()->on_save(); 28 | } 29 | } 30 | 31 | void update(dot::controller& c) 32 | { 33 | c.execute(refresh); 34 | refresh = false; 35 | } 36 | 37 | auto parse_options(int argc, char* argv[]) 38 | { 39 | std::map options; 40 | 41 | for (int i = 1; i < argc; ++i) { 42 | std::string arg = argv[i]; 43 | if (arg == "-s") 44 | { 45 | if (i + 1 < argc) 46 | { 47 | options[arg] = argv[i+1]; 48 | } 49 | } 50 | } 51 | return options; 52 | } 53 | 54 | int main(int argc, char* argv[]) 55 | { 56 | auto devices = serial::list_ports(); 57 | auto options = parse_options(argc, argv); 58 | 59 | dot::hardware hardware = { 14, 28, "" }; 60 | dot::controller controller; 61 | 62 | if (!devices.empty()) 63 | hardware.port = devices[0].port; 64 | 65 | controller.set_hardware(hardware); 66 | 67 | auto scriptIt = options.find("-s"); 68 | if (scriptIt != options.end()) 69 | { 70 | auto& scriptPath = scriptIt->second; 71 | controller.from_file(scriptPath); 72 | } 73 | 74 | dot::window window; 75 | 76 | window.initialize(window_width, window_height, window_title, on_key, on_error); 77 | window.set_view(&controller); 78 | 79 | float timeInterval = 1.0f / 30.0f; 80 | float lastTime = glfwGetTime(); 81 | 82 | while (window.is_open()) 83 | { 84 | update(controller); 85 | window.render(); 86 | controller.send(); 87 | while (glfwGetTime() < lastTime + timeInterval) { } 88 | lastTime += timeInterval; 89 | } 90 | 91 | return 0; 92 | } -------------------------------------------------------------------------------- /src/view.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "window.h" 5 | 6 | DOT_NS_BEGIN 7 | 8 | class view 9 | { 10 | public: 11 | virtual void initialize(window& w) { } 12 | virtual void on_render(window& w) { } 13 | }; 14 | 15 | DOT_NS_END -------------------------------------------------------------------------------- /src/window.cpp: -------------------------------------------------------------------------------- 1 | #include "window.h" 2 | #include "view.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | DOT_NS_BEGIN 11 | 12 | color color::black = { 0.0,0.0,0.0,1.0 }; 13 | color color::white = { 1.0,1.0,1.0,1.0 }; 14 | 15 | void window::initialize(int w, int h, const std::string& title, onKey& on_key, onError& on_error) 16 | { 17 | glfwSetErrorCallback(on_error); 18 | glfwInit(); 19 | 20 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 21 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); 22 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 23 | glfwWindowHint(GLFW_SAMPLES, 4); 24 | glfwWindowHint(GLFW_RESIZABLE, false); 25 | 26 | _window = std::shared_ptr( 27 | glfwCreateWindow(w, h, title.c_str(), NULL, NULL), 28 | glfwDestroyWindow 29 | ); 30 | 31 | if (_window == nullptr) 32 | { 33 | std::cout << "Failed to create GLFW window" << std::endl; 34 | glfwTerminate(); 35 | return; 36 | } 37 | 38 | glfwMakeContextCurrent(_window.get()); 39 | glfwSetKeyCallback(_window.get(), window::_key_cb); 40 | glfwSetWindowUserPointer(_window.get(), this); 41 | 42 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) 43 | { 44 | std::cout << "Failed to initialize GLAD" << std::endl; 45 | return; 46 | } 47 | 48 | IMGUI_CHECKVERSION(); 49 | ImGui::CreateContext(); 50 | const char* glsl_version = "#version 460"; 51 | ImGui_ImplGlfw_InitForOpenGL(_window.get(), true); 52 | ImGui_ImplOpenGL3_Init(glsl_version); 53 | 54 | ImGuiIO& io = ImGui::GetIO(); 55 | io.ConfigInputTextCursorBlink = true; 56 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; 57 | 58 | _on_key = *on_key; 59 | } 60 | 61 | void window::close() 62 | { 63 | glfwSetWindowShouldClose(_window.get(), true); 64 | } 65 | 66 | int window::get_width() 67 | { 68 | int w, h; 69 | glfwGetWindowSize(_window.get(), &w, &h); 70 | return w; 71 | } 72 | 73 | int window::get_height() 74 | { 75 | int w, h; 76 | glfwGetWindowSize(_window.get(), &w, &h); 77 | return h; 78 | } 79 | 80 | void window::render() 81 | { 82 | glfwPollEvents(); 83 | 84 | if (_view != nullptr) 85 | { 86 | _view->on_render(*this); 87 | } 88 | 89 | ImGui::Render(); 90 | 91 | int w, h; 92 | glfwGetFramebufferSize(_window.get(), &w, &h); 93 | glViewport(0, 0, w, h); 94 | glClearColor(_clear_color.r, _clear_color.g, _clear_color.b, _clear_color.a); 95 | glClear(GL_COLOR_BUFFER_BIT); 96 | ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); 97 | glfwSwapBuffers(_window.get()); 98 | } 99 | 100 | bool window::is_open() 101 | { 102 | return !glfwWindowShouldClose(_window.get()); 103 | } 104 | 105 | void window::events() 106 | { 107 | glfwPollEvents(); 108 | } 109 | 110 | void window::_key_cb(WindowPtr w, int key, int scancode, int action, int mods) 111 | { 112 | auto owner = (window*)glfwGetWindowUserPointer(w); 113 | owner->_on_key((*owner), action, mods, key); 114 | } 115 | 116 | DOT_NS_END -------------------------------------------------------------------------------- /src/window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | #include 6 | #include 7 | 8 | DOT_NS_BEGIN 9 | 10 | class view; 11 | 12 | struct color 13 | { 14 | float r, g, b, a; 15 | 16 | static color black; 17 | static color white; 18 | }; 19 | 20 | class window 21 | { 22 | public: 23 | 24 | typedef void(onKey)(window&, int, int, int); 25 | typedef void(onError)(int, const char*); 26 | 27 | void initialize(int w, int h, const std::string& title, onKey& on_key, onError& on_error); 28 | void close(); 29 | 30 | void render(); 31 | 32 | bool is_open(); 33 | void events(); 34 | 35 | int get_width(); 36 | int get_height(); 37 | 38 | template 39 | std::shared_ptr set_view(Ts... args) 40 | { 41 | auto v = std::make_shared(args...); 42 | 43 | _view = v; 44 | _view->initialize(*this); 45 | 46 | return v; 47 | } 48 | 49 | template 50 | std::shared_ptr get_view() 51 | { 52 | return std::static_pointer_cast(_view); 53 | } 54 | 55 | void set_clear_color(const color& c) { 56 | _clear_color = c; 57 | } 58 | 59 | bool key_pressed(int code) { 60 | return glfwGetKey(_window.get(), code) == GLFW_PRESS; 61 | } 62 | 63 | private: 64 | 65 | onKey* _on_key; 66 | 67 | private: 68 | static void _key_cb(WindowPtr window, int key, int scancode, int action, int mods); 69 | 70 | std::shared_ptr _window; 71 | std::shared_ptr _view; 72 | color _clear_color; 73 | }; 74 | 75 | DOT_NS_END --------------------------------------------------------------------------------