├── .gitignore ├── LICENSE.txt ├── README.md ├── assets ├── font.png └── vid_thumb.png ├── include ├── font │ └── font.h └── render_pass │ ├── blur_pass.h │ ├── bright_filter_pass.h │ ├── composite_pass.h │ └── render_pass_i.h ├── proc ├── html5 │ └── emcc.sh ├── linux │ └── compile_linux_gcc.sh ├── osx │ └── compile_osx_gcc.sh └── win │ └── cl.bat ├── source ├── font │ └── font_data.c ├── main.c └── render_passes │ ├── blur_pass.c │ ├── bright_filter_pass.c │ └── composite_pass.c └── third_party └── include └── gs ├── LICENSE ├── README.md ├── docs ├── audio.md ├── containers.md ├── getting_started.md ├── graphics.md ├── gs_logo2.png ├── math.md ├── platform.md └── utils.md ├── external ├── KHR │ └── khrplatform.h ├── ccd │ ├── BSD-LICENSE │ ├── libccd.c │ └── src │ │ ├── ccd.c │ │ ├── ccd │ │ ├── ccd.h │ │ ├── ccd_compiler.h │ │ ├── ccd_config.h │ │ ├── ccd_export.h │ │ ├── ccd_quat.h │ │ └── ccd_vec3.h │ │ ├── ccd_alloc.h │ │ ├── ccd_dbg.h │ │ ├── ccd_list.h │ │ ├── ccd_mpr.c │ │ ├── ccd_polytope.c │ │ ├── ccd_polytope.h │ │ ├── ccd_simplex.h │ │ ├── ccd_support.c │ │ ├── ccd_support.h │ │ └── ccd_vec3.c ├── cgltf │ ├── LICENSE │ ├── cgltf.h │ └── cgltf_write.h ├── dirent │ ├── LICENSE │ ├── README.md │ └── dirent.h ├── dr_libs │ ├── dr_mp3.h │ └── dr_wav.h ├── glad │ ├── glad.h │ └── glad_impl.h ├── glfw │ ├── 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.h │ ├── glfw3native.h │ ├── glfw_config.h.in │ ├── glfw_impl.h │ ├── 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 ├── miniaudio │ └── miniaudio.h ├── sg_noise │ └── sg_noise.h └── stb │ ├── stb.h │ ├── stb_dxt.h │ ├── stb_image.h │ ├── stb_image_write.h │ ├── stb_truetype.h │ └── stb_vorbis.c ├── gs.h ├── impl ├── gs_audio_impl.h ├── gs_graphics_impl.h └── gs_platform_impl.h └── util ├── .gs_gui.h.swp ├── gs_asset.h ├── gs_audxt.h ├── gs_gfxt.h ├── gs_gui.h ├── gs_idraw.h ├── gs_meta.h └── gs_physics.h /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.db 3 | *.opendb 4 | *.ipch 5 | *.obj 6 | *.exe 7 | sand_sim/.vs/sand_sim/v15/.suo 8 | sand_sim/.vs/slnx.sqlite 9 | sand_sim/.vs/VSWorkspaceState.json 10 | sand_sim/.vs/ProjectSettings.json 11 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, John Jackson 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Recreating Noita's Falling Sand Simulation | Game Engineering - EP01 2 | 3 |

4 | 5 |

6 | 7 | https://www.youtube.com/watch?v=VLZjd_Y1gJ8 8 | 9 | Inspired by Noita, this is a simple "falling sand" simulation to demonstrate the mechanics and ideas behind Cellular Automata. 10 | 11 | ## Building 12 | 13 | **NOTE(john)**: Currently requires at least **OpenGL v3.3** to run. This will be addressed in the future to allow for 14 | previous opengl versions. 15 | 16 | 17 | - **windows**: 18 | - You'll need to have Visual Studio 2015 or greater. 19 | - From start menu, search for "x64 Native Tool Command Prompt for {Insert your Version Here}" 20 | - Navigate to where you have `EP01_SandSim` repo placed 21 | - run `proc\win\cl.bat` 22 | - The executable will be placed in `bin\` 23 | - run `bin\SandSim.exe` 24 | - **mac**: 25 | - You'll need gcc 26 | - From the terminal, `cd`into the root directory for this project. 27 | - run `bash ./proc/osx/gcc.sh` 28 | - The exectuable will be placed in `bin/` 29 | - run `./bin/SandSim` 30 | - **linux**: 31 | - You'll need gcc 32 | - From the terminal, `cd` into the root directory for this project. 33 | - run `bash ./proc/linux/gcc.sh` 34 | - The exectuable will be placed in `bin/` 35 | - run `./bin/SandSim` 36 | 37 | ## Controls 38 | - `[`: Decrease paint tool radius 39 | - `]`: Increase paint tool radius 40 | - `c`: Clear canvas of all particles 41 | - `i`: Enable/Disable all UI 42 | - `p`: Pause simulation 43 | - `b`: Enable/Disable post-processing 44 | - `esc`: Quit application 45 | - Left click mouse to paint particles into scene 46 | - Right click mouse to erase particles from scene 47 | - The user can drag & drop images into the program. Any `.png`, `.jpeg/.jpg` images will work. 48 | 49 | -------------------------------------------------------------------------------- /assets/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GameEngineering/EP01_SandSim/7fd7d5a215071db7ecbc9c5d2e54b5f82c79e31f/assets/font.png -------------------------------------------------------------------------------- /assets/vid_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GameEngineering/EP01_SandSim/7fd7d5a215071db7ecbc9c5d2e54b5f82c79e31f/assets/vid_thumb.png -------------------------------------------------------------------------------- /include/font/font.h: -------------------------------------------------------------------------------- 1 | #ifndef GS_SAND_SIM_FONT_H 2 | #define GS_SAND_SIM_FONT_H 3 | 4 | #include 5 | 6 | // For this font, Each glyph is monospaced, 5 x 7 pixels. 7 | // Total font size is 128 x 64. 8 | typedef struct font_glyph_t 9 | { 10 | u32 x; 11 | u32 y; 12 | u32 width; 13 | u32 height; 14 | } font_glyph_t; 15 | 16 | // 6 rows of font data to use * 18 columns 17 | // Total num glyphs = 6 * 18 - (18 - 5) 18 | #define total_num_font_glyphs (6 * 18) 19 | 20 | typedef struct font_t 21 | { 22 | void* data; 23 | u32 width; 24 | u32 height; 25 | u32 num_comps; 26 | u32 glyph_advance; 27 | gs_graphics_texture_format_type texture_format; 28 | font_glyph_t glyphs[total_num_font_glyphs]; 29 | } font_t; 30 | 31 | #endif -------------------------------------------------------------------------------- /include/render_pass/blur_pass.h: -------------------------------------------------------------------------------- 1 | #ifndef SS_BLUR_RENDER_PASS 2 | #define SS_BLUR_RENDER_PASS 3 | 4 | #include "render_pass/render_pass_i.h" 5 | 6 | typedef struct blur_data_t 7 | { 8 | u32 iterations; 9 | gs_handle(gs_graphics_texture_t) blur_render_target_a; 10 | gs_handle(gs_graphics_texture_t) blur_render_target_b; 11 | gs_handle(gs_graphics_texture_t) small_blur_render_target_a; 12 | gs_handle(gs_graphics_texture_t) small_blur_render_target_b; 13 | gs_handle(gs_graphics_texture_t) medium_blur_render_target_a; 14 | gs_handle(gs_graphics_texture_t) medium_blur_render_target_b; 15 | gs_handle(gs_graphics_texture_t) large_blur_render_target_a; 16 | gs_handle(gs_graphics_texture_t) large_blur_render_target_b; 17 | gs_handle(gs_graphics_shader_t) horizontal_blur_shader; 18 | gs_handle(gs_graphics_shader_t) vertical_blur_shader; 19 | gs_handle (gs_graphics_uniform_t) u_input_tex; 20 | gs_handle (gs_graphics_uniform_t) u_tex_size; 21 | gs_handle(gs_graphics_vertex_buffer_t) vbo; 22 | gs_handle(gs_graphics_index_buffer_t) ibo; 23 | gs_handle(gs_graphics_render_pass_t) rp_vertical; 24 | gs_handle(gs_graphics_render_pass_t) rp_horizontal; 25 | gs_handle(gs_graphics_pipeline_t) pip_horizontal; 26 | gs_handle(gs_graphics_pipeline_t) pip_vertical; 27 | } blur_data_t; 28 | 29 | typedef struct blur_pass_t 30 | { 31 | _base(render_pass_i); 32 | blur_data_t data; 33 | } blur_pass_t; 34 | 35 | // Use this to pass in parameters for the pass ( will check for this) 36 | typedef struct blur_pass_parameters_t { 37 | gs_handle(gs_graphics_texture_t) input_texture; 38 | } blur_pass_parameters_t; 39 | 40 | // Used to construct new instance of a blur pass 41 | blur_pass_t blur_pass_ctor(gs_handle(gs_graphics_framebuffer_t) fb); 42 | 43 | #endif -------------------------------------------------------------------------------- /include/render_pass/bright_filter_pass.h: -------------------------------------------------------------------------------- 1 | #ifndef SS_BRIGHT_FILTER_PASS_H 2 | #define SS_BRIGHT_FILTER_PASS_H 3 | 4 | #include "render_pass/render_pass_i.h" 5 | 6 | typedef struct bright_filter_data_t 7 | { 8 | gs_handle(gs_graphics_shader_t) shader; 9 | gs_handle(gs_graphics_uniform_t) u_input_tex; 10 | gs_handle(gs_graphics_texture_t) rt; 11 | gs_handle(gs_graphics_vertex_buffer_t) vbo; 12 | gs_handle(gs_graphics_index_buffer_t) ibo; 13 | gs_handle(gs_graphics_render_pass_t) rp; 14 | gs_handle(gs_graphics_pipeline_t) pip; 15 | } bright_filter_data_t; 16 | 17 | typedef struct bright_filter_pass_t 18 | { 19 | _base(render_pass_i); 20 | bright_filter_data_t data; 21 | } bright_filter_pass_t; 22 | 23 | // Use this to pass in parameters for the pass ( will check for this) 24 | typedef struct bright_filter_pass_parameters_t 25 | { 26 | gs_handle(gs_graphics_texture_t) input_texture; 27 | } bright_filter_pass_parameters_t; 28 | 29 | bright_filter_pass_t bright_filter_pass_ctor(gs_handle(gs_graphics_framebuffer_t) fb); 30 | 31 | #endif -------------------------------------------------------------------------------- /include/render_pass/composite_pass.h: -------------------------------------------------------------------------------- 1 | #ifndef SS_COMPOSITE_PASS_H 2 | #define SS_COMPOSITE_PASS_H 3 | 4 | #include "render_pass/render_pass_i.h" 5 | 6 | typedef struct composite_pass_data_t 7 | { 8 | gs_handle(gs_graphics_shader_t) shader; 9 | gs_handle(gs_graphics_uniform_t) u_input_tex; 10 | gs_handle(gs_graphics_uniform_t) u_blur_tex; 11 | gs_handle(gs_graphics_uniform_t) u_exposure; 12 | gs_handle(gs_graphics_uniform_t) u_gamma; 13 | gs_handle(gs_graphics_uniform_t) u_bloom_scalar; 14 | gs_handle(gs_graphics_uniform_t) u_saturation; 15 | gs_handle(gs_graphics_texture_t) rt; 16 | gs_handle(gs_graphics_vertex_buffer_t) vbo; 17 | gs_handle(gs_graphics_index_buffer_t) ibo; 18 | gs_handle(gs_graphics_render_pass_t) rp; 19 | gs_handle(gs_graphics_pipeline_t) pip; 20 | } composite_pass_data_t; 21 | 22 | typedef struct composite_pass_t 23 | { 24 | _base(render_pass_i); 25 | composite_pass_data_t data; 26 | } composite_pass_t; 27 | 28 | // Use this to pass in parameters for the pass ( will check for this) 29 | typedef struct composite_pass_parameters_t 30 | { 31 | gs_handle(gs_graphics_texture_t) input_texture; 32 | gs_handle(gs_graphics_texture_t) blur_texture; 33 | } composite_pass_parameters_t; 34 | 35 | composite_pass_t composite_pass_ctor(gs_handle(gs_graphics_framebuffer_t) fb); 36 | 37 | #endif -------------------------------------------------------------------------------- /include/render_pass/render_pass_i.h: -------------------------------------------------------------------------------- 1 | #ifndef SS_RENDER_PASS_I 2 | #define SS_RENDER_PASS_I 3 | 4 | #include 5 | 6 | #define _base(base_type) base_type _base 7 | 8 | // Abstract interface for all render passes passes 9 | typedef struct render_pass_i { 10 | void (* pass)(gs_command_buffer_t* cb, struct render_pass_i* pass, void* paramters); 11 | } render_pass_i; 12 | 13 | #endif -------------------------------------------------------------------------------- /proc/html5/emcc.sh: -------------------------------------------------------------------------------- 1 | #!bin/sh 2 | 3 | rm -rf bin 4 | mkdir bin 5 | cd bin 6 | 7 | proj_name=App 8 | proj_root_dir=$(pwd)/../ 9 | 10 | flags=( 11 | -w -s WASM=1 -s USE_WEBGL2=1 -s ASYNCIFY=1 -O3 -s ALLOW_MEMORY_GROWTH=1 12 | ) 13 | 14 | # Include directories 15 | inc=( 16 | -I ../third_party/include/ # Gunslinger includes 17 | -I ../include/ 18 | ) 19 | 20 | # Source files 21 | src=( 22 | ../source/*.c 23 | ../source/render_passes/*.c 24 | ) 25 | 26 | libs=( 27 | ) 28 | 29 | # Build 30 | emcc ${inc[*]} ${src[*]} ${flags[*]} -o $proj_name.html 31 | 32 | cd .. 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /proc/linux/compile_linux_gcc.sh: -------------------------------------------------------------------------------- 1 | #!bin/sh 2 | 3 | rm -rf bin 4 | mkdir bin 5 | cd bin 6 | 7 | proj_root_dir=$(pwd)/../ 8 | 9 | flags=( 10 | -std=gnu99 -Wl,--no-as-needed -ldl -lGL -lX11 -pthread -lXi 11 | ) 12 | 13 | # Include directories 14 | inc=( 15 | -I ../third_party/include/gunslinger/ # Gunslinger includes 16 | -I ../include/ # SandSim includes 17 | ) 18 | 19 | # Source files 20 | src=( 21 | ../source/main.c 22 | ../source/render_passes/*.c 23 | ) 24 | 25 | lib_dirs=( 26 | -L ../third_party/libs/linux/ 27 | ) 28 | 29 | libs=( 30 | -lgunslinger 31 | ) 32 | 33 | # Build 34 | gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} ${lib_dirs[*]} ${libs[*]} -lm -o SandSim 35 | 36 | cd .. 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /proc/osx/compile_osx_gcc.sh: -------------------------------------------------------------------------------- 1 | #!bin/sh 2 | 3 | rm -rf bin 4 | mkdir bin 5 | cd bin 6 | 7 | proj_root_dir=$(pwd)/../ 8 | 9 | flags=( 10 | -std=c99 11 | ) 12 | 13 | # Include directories 14 | inc=( 15 | -I ../third_party/include/gunslinger/ # Gunslinger includes 16 | -I ../include/ # SandSim includes 17 | ) 18 | 19 | # Source files 20 | src=( 21 | ../source/main.c 22 | ../source/render_passes/*.c 23 | ) 24 | 25 | lib_dirs=( 26 | -L ../third_party/libs/osx 27 | ) 28 | 29 | fworks=( 30 | -framework OpenGL 31 | -framework CoreFoundation 32 | -framework CoreVideo 33 | -framework IOKit 34 | -framework Cocoa 35 | -framework Carbon 36 | ) 37 | 38 | libs=( 39 | -lgunslinger 40 | ) 41 | 42 | # Build 43 | gcc -O3 ${lib_dirs[*]} ${libs[*]} ${fworks[*]} ${inc[*]} ${src[*]} ${flags[*]} -o SandSim 44 | 45 | cd .. 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /proc/win/cl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rmdir /Q /S bin 3 | mkdir bin 4 | pushd bin 5 | 6 | rem Name 7 | set name=App 8 | 9 | rem Include directories 10 | set inc=/I ..\include /I ..\third_party\include\ 11 | 12 | rem Source files 13 | set src_main=..\source\*.c ..\source\render_passes\*.c 14 | 15 | rem All source together 16 | set src_all=%src_main% 17 | 18 | rem OS Libraries 19 | set os_libs= opengl32.lib kernel32.lib user32.lib ^ 20 | shell32.lib vcruntime.lib msvcrt.lib gdi32.lib Winmm.lib Advapi32.lib 21 | 22 | rem Link options 23 | set l_options=/EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib 24 | 25 | rem Compile Release 26 | cl /MP /FS /Ox /W1 /Fe%name%.exe %src_all% %inc% ^ 27 | /EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT ^ 28 | %os_libs% 29 | 30 | rem Compile Debug 31 | rem cl /w /MP -Zi /DEBUG:FULL /Fe%name%.exe %src_all% %inc% ^ 32 | rem /EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT ^ 33 | rem %os_libs% 34 | 35 | popd 36 | -------------------------------------------------------------------------------- /source/render_passes/bright_filter_pass.c: -------------------------------------------------------------------------------- 1 | #include "render_pass/bright_filter_pass.h" 2 | 3 | // Foward Decls 4 | void bp_pass(gs_command_buffer_t* cb, struct render_pass_i* pass, void* paramters); 5 | 6 | // Shaders 7 | #if (defined GS_PLATFORM_WEB || defined GS_PLATFORM_ANDROID) 8 | #define GL_VERSION_STR "#version 300 es\n" 9 | #else 10 | #define GL_VERSION_STR "#version 330 core\n" 11 | #endif 12 | 13 | const char* bp_v_src = 14 | GL_VERSION_STR 15 | "precision mediump float;\n" 16 | "layout (location = 0) in vec2 a_position;\n" 17 | "layout (location = 1) in vec2 a_uv;\n" 18 | "out vec2 tex_coord;\n" 19 | "void main() {\n" 20 | " gl_Position = vec4(a_position, 0.0, 1.0);\n" 21 | " tex_coord = a_uv;\n" 22 | "}\n"; 23 | 24 | const char* bp_f_src = 25 | GL_VERSION_STR 26 | "precision mediump float;\n" 27 | "in vec2 tex_coord;\n" 28 | "out vec4 frag_color;\n" 29 | "uniform sampler2D u_tex;\n" 30 | "void main() {\n" 31 | " frag_color = vec4(0.0, 0.0, 0.0, 1.0);\n" 32 | " vec3 tex_color = texture(u_tex, tex_coord).rgb;\n" 33 | " float brightness = dot(tex_color, vec3(0.2126, 0.7152, 0.0722));\n" 34 | " if (tex_color.b < 0.2 && brightness > 0.4) {\n" 35 | " vec3 op = clamp(tex_color, vec3(0), vec3(255));\n" 36 | " frag_color = vec4(op * 0.1, 1.0);\n" 37 | " }\n" 38 | "}\n"; 39 | 40 | // Vertex data layout for our mesh (for this shader, it's a single float2 attribute for position) 41 | // gs_global gs_vertex_attribute_type layout[] = { 42 | // gs_vertex_attribute_float2, 43 | // gs_vertex_attribute_float2 44 | // }; 45 | // // Count of our vertex attribute array 46 | // gs_global u32 layout_count = sizeof(layout) / sizeof(gs_vertex_attribute_type); 47 | 48 | // Vertex data for triangle 49 | gs_global f32 v_data[] = { 50 | // Positions UVs 51 | -1.0f, -1.0f, 0.0f, 0.0f, // Top Left 52 | 1.0f, -1.0f, 1.0f, 0.0f, // Top Right 53 | -1.0f, 1.0f, 0.0f, 1.0f, // Bottom Left 54 | 1.0f, 1.0f, 1.0f, 1.0f // Bottom Right 55 | }; 56 | 57 | gs_global u32 i_data[] = { 58 | 0, 2, 3, 59 | 3, 1, 0 60 | }; 61 | 62 | bright_filter_pass_t bright_filter_pass_ctor(gs_handle(gs_graphics_framebuffer_t) fb) 63 | { 64 | bright_filter_pass_t bp = {0}; 65 | 66 | bp._base.pass = &bp_pass; 67 | 68 | // Construct vertex buffer 69 | bp.data.vbo = gs_graphics_vertex_buffer_create( 70 | &(gs_graphics_vertex_buffer_desc_t) { 71 | .data = v_data, 72 | .size = sizeof(v_data) 73 | } 74 | ); 75 | 76 | // Construct index buffer 77 | bp.data.ibo = gs_graphics_index_buffer_create( 78 | &(gs_graphics_index_buffer_desc_t) { 79 | .data = i_data, 80 | .size = sizeof(i_data) 81 | } 82 | ); 83 | 84 | bp.data.shader = gs_graphics_shader_create ( 85 | &(gs_graphics_shader_desc_t) { 86 | .sources = (gs_graphics_shader_source_desc_t[]) { 87 | {.type = GS_GRAPHICS_SHADER_STAGE_VERTEX, .source = bp_v_src}, 88 | {.type = GS_GRAPHICS_SHADER_STAGE_FRAGMENT, .source = bp_f_src} 89 | }, 90 | .size = 2 * sizeof(gs_graphics_shader_source_desc_t), 91 | .name = "bright_shader" 92 | } 93 | ); 94 | 95 | // bp.data.u_input_tex = gfx->construct_uniform(bp.data.shader, "u_tex", gs_uniform_type_sampler2d); 96 | 97 | // Construct uniforms for shader 98 | bp.data.u_input_tex = gs_graphics_uniform_create ( 99 | &(gs_graphics_uniform_desc_t) { 100 | .name = "u_tex", 101 | .layout = &(gs_graphics_uniform_layout_desc_t){.type = GS_GRAPHICS_UNIFORM_SAMPLER2D} 102 | } 103 | ); 104 | 105 | gs_vec2 ws = gs_platform_window_sizev(gs_platform_main_window()); 106 | 107 | gs_graphics_texture_desc_t t_desc = gs_default_val(); 108 | t_desc.wrap_s = GS_GRAPHICS_TEXTURE_WRAP_CLAMP_TO_EDGE; 109 | t_desc.wrap_t = GS_GRAPHICS_TEXTURE_WRAP_CLAMP_TO_EDGE; 110 | t_desc.mag_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; 111 | t_desc.min_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; 112 | t_desc.format = GS_GRAPHICS_TEXTURE_FORMAT_RGBA16F; 113 | t_desc.num_mips = 0; 114 | t_desc.data = NULL; 115 | t_desc.width = (s32)(ws.x / 8); 116 | t_desc.height = (s32)(ws.y / 8); 117 | bp.data.rt = gs_graphics_texture_create(&t_desc); 118 | 119 | // Construct render passes 120 | bp.data.rp = gs_graphics_render_pass_create( 121 | &(gs_graphics_render_pass_desc_t){ 122 | .fbo = fb, // Frame buffer to bind for render pass 123 | .color = &bp.data.rt, // Color buffer array to bind to frame buffer 124 | .color_size = sizeof(bp.data.rt) // Size of color attachment array in bytes 125 | } 126 | ); 127 | 128 | bp.data.pip = gs_graphics_pipeline_create( 129 | &(gs_graphics_pipeline_desc_t) { 130 | .raster = { 131 | .shader = bp.data.shader 132 | }, 133 | .blend = { 134 | .func = GS_GRAPHICS_BLEND_EQUATION_ADD, 135 | .src = GS_GRAPHICS_BLEND_MODE_SRC_ALPHA, 136 | .dst = GS_GRAPHICS_BLEND_MODE_ONE_MINUS_SRC_ALPHA 137 | }, 138 | .layout = { 139 | .attrs = (gs_graphics_vertex_attribute_desc_t[]){ 140 | {.format = GS_GRAPHICS_VERTEX_ATTRIBUTE_FLOAT2, .name = "a_position"}, // Named attribute required for lower GL versions / ES2 / ES3 141 | {.format = GS_GRAPHICS_VERTEX_ATTRIBUTE_FLOAT2, .name = "a_uv"} // Named attribute required for lower GL versions / ES2 / ES3 142 | }, 143 | .size = 2 * sizeof(gs_graphics_vertex_attribute_desc_t) 144 | } 145 | } 146 | ); 147 | 148 | return bp; 149 | } 150 | 151 | void bp_pass(gs_command_buffer_t* cb, struct render_pass_i* _pass, void* _params) 152 | { 153 | bright_filter_pass_t* bp = (bright_filter_pass_t*)_pass; 154 | if (!bp) { 155 | return; 156 | } 157 | 158 | // Can only use valid params 159 | bright_filter_pass_parameters_t* params = (bright_filter_pass_parameters_t*)_params; 160 | if (!params) { 161 | return; 162 | } 163 | 164 | gs_vec2 ws = gs_platform_window_sizev(gs_platform_main_window()); 165 | 166 | gs_graphics_texture_desc_t t_desc = gs_default_val(); 167 | t_desc.wrap_s = GS_GRAPHICS_TEXTURE_WRAP_CLAMP_TO_BORDER; 168 | t_desc.wrap_t = GS_GRAPHICS_TEXTURE_WRAP_CLAMP_TO_BORDER; 169 | t_desc.mag_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; 170 | t_desc.min_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; 171 | t_desc.format = GS_GRAPHICS_TEXTURE_FORMAT_RGBA16F; 172 | t_desc.num_mips = 0; 173 | t_desc.data = NULL; 174 | t_desc.width = (s32)(ws.x / 8); 175 | t_desc.height = (s32)(ws.y / 8); 176 | 177 | // Two render targets for double buffered separable blur (For now, just set to window's viewport) 178 | //gs_graphics_texture_request_update(cb, bp->data.rt, &t_desc); 179 | // gfx->update_texture_data(bp->data.render_target, t_desc); 180 | 181 | // Render pass action for clearing the screen 182 | gs_graphics_clear_desc_t clear = (gs_graphics_clear_desc_t){ 183 | .actions = &(gs_graphics_clear_action_t){.color = {0.0f, 0.0f, 0.0f, 1.f}} 184 | }; 185 | 186 | // Uniform buffer array 187 | gs_graphics_bind_uniform_desc_t uniforms[] = { 188 | (gs_graphics_bind_uniform_desc_t){.uniform = bp->data.u_input_tex, .data = ¶ms->input_texture, .binding = 0} 189 | }; 190 | 191 | // Binding descriptor for vertex buffer 192 | gs_graphics_bind_desc_t binds = { 193 | .vertex_buffers = {.desc = &(gs_graphics_bind_vertex_buffer_desc_t){.buffer = bp->data.vbo}}, 194 | .index_buffers = {.desc = &(gs_graphics_bind_index_buffer_desc_t){.buffer = bp->data.ibo}}, 195 | .uniforms = {.desc = uniforms, .size = sizeof(uniforms)} 196 | }; 197 | 198 | // Bind render pass, bind pipeline, set up everything... 199 | gs_graphics_begin_render_pass(cb, bp->data.rp); 200 | gs_graphics_bind_pipeline(cb, bp->data.pip); 201 | gs_graphics_set_viewport(cb, 0, 0, (u32)(ws.x / 8), (u32)(ws.y / 8)); 202 | gs_graphics_clear(cb, &clear); 203 | gs_graphics_apply_bindings(cb, &binds); 204 | gs_graphics_draw(cb, &(gs_graphics_draw_desc_t){.start = 0, .count = 6}); 205 | gs_graphics_end_render_pass(cb); 206 | 207 | // Set frame buffer attachment for rendering 208 | // gfx->set_frame_buffer_attachment(cb, bp->data.render_target, 0); 209 | 210 | // Set viewport 211 | // gfx->set_view_port(cb, (u32)(ws.x / 8), (u32)(ws.y / 8)); 212 | 213 | // Clear 214 | // f32 cc[4] = {0.f, 0.f, 0.f, 1.f}; 215 | // gfx->set_view_clear(cb, (f32*)&cc); 216 | 217 | // Use the program 218 | // gfx->bind_shader(cb, bp->data.shader); 219 | // { 220 | // gfx->bind_texture(cb, bp->data.u_input_tex, params->input_texture, 0); 221 | // gfx->bind_vertex_buffer(cb, bp->data.vb); 222 | // gfx->bind_index_buffer(cb, bp->data.ib); 223 | // gfx->draw_indexed(cb, 6); 224 | // } 225 | } 226 | 227 | 228 | -------------------------------------------------------------------------------- /third_party/include/gs/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020 John Jackson 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDi 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /third_party/include/gs/README.md: -------------------------------------------------------------------------------- 1 | ![gunslinger](https://raw.githubusercontent.com/MrFrenik/gunslinger/master/docs/gs_logo2.png) 2 | ![GitHub](https://img.shields.io/github/license/mrfrenik/gunslinger) 3 | [![Discord](https://img.shields.io/discord/485178488203116567?label=discord&logo=discord)](https://discord.gg/QXwpETB) 4 | ![GitHub top language](https://img.shields.io/github/languages/top/mrfrenik/gunslinger?label=c99) 5 | 6 | Gunslinger is a header-only c99 framework for multimedia applications. 7 | 8 | ## Features 9 | - Header-only: drag-drop into any project without any additional compiling required. 10 | - All externals included in the framework itself. 11 | - Simple API inspired by [sokol](https://github.com/floooh/sokol) headers. 12 | - Provides core framework for quickly developing multimedia applications: [Platform](https://github.com/MrFrenik/gunslinger/blob/master/docs/platform.md), [Graphics](https://github.com/MrFrenik/gunslinger/blob/master/docs/graphics.md), [Audio layers](https://github.com/MrFrenik/gunslinger/blob/master/docs/audio.md). 13 | - Provides custom utilities for [math](https://github.com/MrFrenik/gunslinger/blob/master/docs/math.md) and [generic data structures](https://github.com/MrFrenik/gunslinger/blob/master/docs/containers.md). 14 | - Optional [helper utilties](https://github.com/MrFrenik/gunslinger/tree/master/util) are provided, such as [OpenGL 2.0-style immediate-mode rendering](https://github.com/MrFrenik/gunslinger/blob/master/util/gs_idraw.h), [asset management system](https://github.com/MrFrenik/gunslinger/blob/master/util/gs_asset.h), [physics util](https://github.com/MrFrenik/gunslinger/blob/master/util/gs_physics.h), and a [data reflection utility](https://github.com/MrFrenik/gunslinger/blob/master/util/gs_meta.h). 15 | - Supports a growing list of platforms: `Windows`, `OSX`, `Linux`, `Android`, and `HTML5` currently with plans to add `UWP`, `RPI`, `IOS`. 16 | - Graphics pipeline follows an explicit rendering framework, making it easier to write for modern backends, such as `Vulkan`/`DX12`/`Metal`. 17 | - All core layers can be fully swapped out with custom user implementations. 18 | - Large collection of [examples](https://github.com/MrFrenik/gs_examples) for quickly getting started. 19 | - An available [project template](https://github.com/MrFrenik/gs_project_template) for various platforms and build systems to get started with a blank gunslinger project. 20 | - Official framework used for all [Game Engineering](https://www.youtube.com/watch?v=VLZjd_Y1gJ8&list=PLIozaEI1hFu3Cd0YJMwOBQKTKfe9uZoyn) YouTube videos. 21 | 22 | ## Documentation 23 | 24 | * [Official Documentation (Docsforge)](https://gunslinger.docsforge.com/) 25 | * [Online Sample Repo](https://mrfrenik.github.io/gunslinger) 26 | * [Getting Started](https://github.com/MrFrenik/gunslinger/blob/master/docs/getting_started.md) 27 | * [Containers](https://github.com/MrFrenik/gunslinger/blob/master/docs/containers.md) 28 | * [Examples](https://github.com/MrFrenik/gs_examples) 29 | * Platform: WIP 30 | * Audio: WIP 31 | * Graphics: WIP 32 | * Math: WIP 33 | * Utils: WIP 34 | 35 | [//]: # "(* [Platform](https://github.com/MrFrenik/gunslinger/blob/master/docs/platform.md) )" 36 | [//]: # "(* [Graphics](https://github.com/MrFrenik/gunslinger/blob/master/docs/graphics.md) )" 37 | [//]: # "(* [Audio](https://github.com/MrFrenik/gunslinger/blob/master/docs/audio.md) )" 38 | [//]: # "(* [Math](https://github.com/MrFrenik/gunslinger/blob/master/docs/math.md) )" 39 | [//]: # "(* [Utils](https://github.com/MrFrenik/gunslinger/blob/master/docs/utils.md) )" 40 | 41 | ## Basic Example 42 | A simple c99 'Hello World' example using gunslinger: 43 | 44 | ```c 45 | #define GS_IMPL 46 | #include 47 | 48 | gs_app_desc_t gs_main(int32_t argc, char** argv) 49 | { 50 | return (gs_app_desc_t){0}; 51 | } 52 | ``` 53 | ## Roadmap 54 | 55 | * Support Android/iOS/RPI/UWP backends 56 | * Support Vulkan/Metal/DX12 backends 57 | * Add support for more texture sampler types: 1D, 3D, Cube Maps, Arrays 58 | * Material Asset utils 59 | * Language Ports: (Python, JS, Rust, C#) 60 | * Add platform-independent threading utils to framework 61 | * MRT 62 | * Job System Util 63 | * Write more docs for github 64 | * Hot-reload util 65 | * Remove all externals from core framework 66 | * Add more texture formats (including compressed) 67 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/audio.md: -------------------------------------------------------------------------------- 1 | # Audio 2 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/getting_started.md: -------------------------------------------------------------------------------- 1 | # Gunslinger Getting Started Guide 2 | This document is meant as a guide for quickly getting started writing gunslinger applications. 3 | 4 | ## Contents: 5 | * [Basic Example](https://github.com/MrFrenik/gunslinger/blob/master/docs/getting_started.md#basic-example) 6 | * [GS Main](https://github.com/MrFrenik/gunslinger/blob/master/docs/getting_started.md#gs-main) 7 | * [Application Descriptor](https://github.com/MrFrenik/gunslinger/blob/master/docs/getting_started.md#application-descriptor) 8 | * [Building](https://github.com/MrFrenik/gunslinger/blob/master/docs/getting_started.md#building) 9 | 10 | ## Basic Example 11 | Let's look at a basic example. In fact, it's the simplest gunslinger application you can create and run successfully. 12 | 13 | ```c 14 | #define GS_IMPL 15 | #include 16 | 17 | gs_app_desc_t gs_main(int32_t argc, char** argv) 18 | { 19 | return (gs_app_desc_t){0}; 20 | } 21 | ``` 22 | Overview of this example: 23 | * Before using gunslinger, the application defines `GS_IMPL` in ONE source file before including the framework. 24 | * The main function returns a `gs_app_desc_t` for gunslinger, which gives various hints about your application. 25 | * Creates a graphics context with the specified graphics backend. OpenGL modern is provided and selected by default. 26 | * Creates an audio context with the specified backend for your operating system. 27 | * Creates a platform context with your operating system as well as a window. 28 | * Initializes the `gs_engine_t` instance for the application, which is accessible globally via the `gs_engine_instance()` macro. 29 | 30 | Running this example gives the following result: 31 | 32 | ![hello_gs](https://raw.githubusercontent.com/MrFrenik/gs_examples/main/00_hello_gs/screenshot/screen.png) 33 | 34 | *Default 800x600 resizable window titled "App"* 35 | 36 | ## GS Main 37 | The default main entry point for any gunslinger application is `gs_main()`. It expects you to return a `gs_app_desc_t` instance that describes attributes about 38 | the application you wish to create. It conveniently wraps all of the necessary framework initialization and startup for you. 39 | 40 | ```c 41 | gs_app_desc_t gs_main(int32_t argc, char** argv) 42 | ``` 43 | 44 | It is possible to use gunslinger without this entry point by defining `GS_NO_HIJACK_MAIN` before implementing the framework: 45 | 46 | ```c 47 | #define GS_NO_HIJACK_MAIN 48 | #define GS_IMPL 49 | #include 50 | 51 | int32_t main(int32_t argc, char** argv) 52 | { 53 | gs_app_desc_t app = {0}; // Fill this with whatever your app needs 54 | gs_engine_create(app); // Create instance of engine for framework and run 55 | while (gs_engine_app()->is_running) { 56 | gs_engine_frame(); 57 | } 58 | return 0; 59 | } 60 | ``` 61 | ### Important Note: 62 | ``` 63 | While it is possible to use gunslinger without it controlling the main application loop, this isn't recommended. 64 | Internally, gunslinger does its best to handle the boiler plate drudge work of implementing (in correct order) 65 | the various layers required for a basic hardware accelerated multi-media application program to work. This involves allocating 66 | memory for internal data structures for these layers as well initializing them in a particular order so they can inter-operate 67 | as expected. If you're interested in taking care of this yourself, look at the `gs_engine_run()` function to get a feeling 68 | for how this is being handled. 69 | ``` 70 | 71 | ## Application Descriptor 72 | Gunslinger runs its own core loop and provides methods for hooking into your application at certain sync points. Your application is initialized at startup via a `gs_app_desc_t` object. It has the following fields: 73 | ```c 74 | typedef struct gs_app_desc_t 75 | { 76 | void (* init)(); // Initialization callback for the application 77 | void (* update)(); // Update callback for the application 78 | void (* shutdown)(); // Shutdown callback for the application 79 | const char* window_title; // Title of main window 80 | uint32_t window_width; // Width of main window 81 | uint32_t window_height; // Height of main window 82 | uint32_t window_flags; // Flags for the window (resizeable, fullscreen, borderless, etc.) 83 | float frame_rate; // Desired frame rate for application 84 | bool32 enable_vsync; // Whether or not vsync is enabled 85 | bool32 is_running; // Internal indicator for framework to know whether application should continue running 86 | bool32 debug_gfx; // Whether or not to enable debug logging for the graphics API 87 | void* user_data; // Any user data for the application 88 | } gs_app_desc_t; 89 | ``` 90 | 91 | Gunslinger interfaces with your application via callbacks that you can register with your application descriptor. These are `init`, `update`, and `shutdown`. When creating a `gs_app_desc_t`, you can set these callbacks like so: 92 | 93 | ```c 94 | void app_init() { 95 | } 96 | 97 | void app_update() { 98 | } 99 | 100 | void app_shutdown() { 101 | } 102 | 103 | gs_app_desc_t gs_main(int32_t argc, char** argv) 104 | { 105 | return (gs_app_desc_t){ 106 | .init = app_init, 107 | .update = app_update, 108 | .shutdown = app_shutdown 109 | }; 110 | } 111 | ``` 112 | 113 | You can register a pointer to any application data you'd like to be globally accessible via the application descriptor `user_data` field: 114 | 115 | ```c 116 | typedef struct your_user_data { 117 | uint32_t u_val; 118 | float f_val; 119 | } your_user_data; 120 | 121 | gs_global user_data = {0}; 122 | 123 | gs_app_desc_t gs_main(int32_t argc, char** argv) 124 | { 125 | return (gs_app_desc_t){ 126 | .user_data = &data; 127 | }; 128 | } 129 | ``` 130 | 131 | To access a mutable pointer to this data, you can use the `gs_engine_user_data(T)` macro, where `T` is the type of your data. 132 | 133 | ```c 134 | void app_init() { 135 | your_user_data* data = gs_engine_user_data(your_user_data); 136 | } 137 | ``` 138 | 139 | # Building 140 | 141 | Gunslinger is a header-only framework, so no prior building is required before using it in your application. However, linking against certain system level libraries is required for successful project compilation. 142 | 143 | ## Windows (MSVC) 144 | * System Libs 145 | ``` 146 | kernel32.lib user32.lib shell32.lib vcruntime.lib msvcrt.lib gdi32.lib Advapi32.lib 147 | ``` 148 | * OpenGL (if using OpenGL as backend) 149 | ``` 150 | opengl32.lib 151 | ``` 152 | ## Windows (MINGW) 153 | * System Libs 154 | ``` 155 | -lkernel32 -luser32 -lshell32 -lgdi32 -lAdvapi32 156 | ``` 157 | * Flags (gcc) 158 | ``` 159 | -std=gnu99 160 | ``` 161 | * Flags (g++) 162 | ``` 163 | -std=c++11 164 | ``` 165 | * OpenGL (if using OpenGL as backend) 166 | ``` 167 | -lopengl32 168 | ``` 169 | ## Linux (GCC/G++) 170 | * System Libs 171 | ``` 172 | -ldl -lX11 -lXi -lm 173 | ``` 174 | * Flags (gcc) 175 | ``` 176 | -std=gnu99 -pthread 177 | ``` 178 | * Flags (g++) 179 | ``` 180 | -std=c++11 -pthread 181 | ``` 182 | * OpenGL (if using OpenGL as backend) 183 | ``` 184 | -lGL 185 | ``` 186 | ## OSX (GCC/G++) 187 | * Frameworks 188 | ``` 189 | -framework CoreFoundation -framework CoreVideo -framework IOKit -framework Cocoa -framework Carbon 190 | ``` 191 | * Flags (gcc) 192 | ``` 193 | -std=c99 -objective-c 194 | ``` 195 | * Flags (g++) 196 | ``` 197 | -std=c++11 -objective-c++ 198 | ``` 199 | * OpenGL (if using OpenGL as backend) 200 | ``` 201 | -framework OpenGL 202 | ``` 203 | 204 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/graphics.md: -------------------------------------------------------------------------------- 1 | # Graphics 2 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/gs_logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GameEngineering/EP01_SandSim/7fd7d5a215071db7ecbc9c5d2e54b5f82c79e31f/third_party/include/gs/docs/gs_logo2.png -------------------------------------------------------------------------------- /third_party/include/gs/docs/math.md: -------------------------------------------------------------------------------- 1 | # Math 2 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/platform.md: -------------------------------------------------------------------------------- 1 | # Platform 2 | -------------------------------------------------------------------------------- /third_party/include/gs/docs/utils.md: -------------------------------------------------------------------------------- 1 | # Utils 2 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/BSD-LICENSE: -------------------------------------------------------------------------------- 1 | libccd 2 | ------- 3 | 4 | Copyright (c)2010-2012 Daniel Fiser , 5 | Intelligent and Mobile Robotics Group, Department of Cybernetics, 6 | Faculty of Electrical Engineering, Czech Technical University in Prague. 7 | All rights reserved. 8 | 9 | 10 | This work was supported by SYMBRION and REPLICATOR projects. 11 | The SYMBRION project is funded by European Commission within the work 12 | "Future and Emergent Technologies Proactive" under grant agreement no. 13 | 216342. 14 | The REPLICATOR project is funded within the work programme "Cognitive 15 | Systems, Interaction, Robotics" under grant agreement no. 216240. 16 | http://www.symbrion.eu/ 17 | http://www.replicators.eu/ 18 | 19 | 20 | Redistribution and use in source and binary forms, with or without 21 | modification, are permitted provided that the following conditions are met: 22 | 23 | - Redistributions of source code must retain the above copyright notice, 24 | this list of conditions and the following disclaimer. 25 | 26 | - Redistributions in binary form must reproduce the above copyright 27 | notice, this list of conditions and the following disclaimer in the 28 | documentation and/or other materials provided with the distribution. 29 | 30 | - Neither the name of the University nor the names of its contributors 31 | may be used to endorse or promote products derived from this software 32 | without specific prior written permission. 33 | 34 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 38 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 39 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 42 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 43 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44 | POSSIBILITY OF SUCH DAMAGE. 45 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/libccd.c: -------------------------------------------------------------------------------- 1 | // libccd unity build file 2 | #include "src/ccd/ccd.h" 3 | #include "src/ccd/ccd_quat.h" 4 | #include "src/ccd/ccd_vec3.h" 5 | 6 | #include "src/ccd_vec3.c" 7 | #include "src/ccd_support.c" 8 | #include "src/ccd_polytope.c" 9 | #include "src/ccd_mpr.c" 10 | #include "src/ccd.c" 11 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010,2011 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_H__ 19 | #define __CCD_H__ 20 | 21 | #include "ccd_vec3.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /** 28 | * Type of *support* function that takes pointer to 3D object and direction 29 | * and returns (via vec argument) furthest point from object in specified 30 | * direction. 31 | */ 32 | typedef void (*ccd_support_fn)(const void *obj, const ccd_vec3_t *dir, 33 | ccd_vec3_t *vec); 34 | 35 | /** 36 | * Returns (via dir argument) first direction vector that will be used in 37 | * initialization of algorithm. 38 | */ 39 | typedef void (*ccd_first_dir_fn)(const void *obj1, const void *obj2, 40 | ccd_vec3_t *dir); 41 | 42 | 43 | /** 44 | * Returns (via center argument) geometric center (some point near center) 45 | * of given object. 46 | */ 47 | typedef void (*ccd_center_fn)(const void *obj1, ccd_vec3_t *center); 48 | 49 | /** 50 | * Main structure of CCD algorithm. 51 | */ 52 | struct _ccd_t { 53 | ccd_first_dir_fn first_dir; //!< Returns initial direction where first 54 | //!< support point will be searched 55 | ccd_support_fn support1; //!< Function that returns support point of 56 | //!< first object 57 | ccd_support_fn support2; //!< Function that returns support point of 58 | //!< second object 59 | 60 | ccd_center_fn center1; //!< Function that returns geometric center of 61 | //!< first object 62 | ccd_center_fn center2; //!< Function that returns geometric center of 63 | //!< second object 64 | 65 | unsigned long max_iterations; //!< Maximal number of iterations 66 | ccd_real_t epa_tolerance; 67 | ccd_real_t mpr_tolerance; //!< Boundary tolerance for MPR algorithm 68 | ccd_real_t dist_tolerance; 69 | }; 70 | typedef struct _ccd_t ccd_t; 71 | 72 | /** 73 | * Default first direction. 74 | */ 75 | CCD_EXPORT void ccdFirstDirDefault(const void *o1, const void *o2, 76 | ccd_vec3_t *dir); 77 | 78 | #define CCD_INIT(ccd) \ 79 | do { \ 80 | (ccd)->first_dir = ccdFirstDirDefault; \ 81 | (ccd)->support1 = NULL; \ 82 | (ccd)->support2 = NULL; \ 83 | (ccd)->center1 = NULL; \ 84 | (ccd)->center2 = NULL; \ 85 | \ 86 | (ccd)->max_iterations = (unsigned long)-1; \ 87 | (ccd)->epa_tolerance = CCD_REAL(0.0001); \ 88 | (ccd)->mpr_tolerance = CCD_REAL(0.0001); \ 89 | (ccd)->dist_tolerance = CCD_REAL(1E-6); \ 90 | } while(0) 91 | 92 | 93 | /** 94 | * Returns true if two given objects interest. 95 | */ 96 | CCD_EXPORT int ccdGJKIntersect(const void *obj1, const void *obj2, 97 | const ccd_t *ccd); 98 | 99 | /** 100 | * This function computes separation vector of two objects. Separation 101 | * vector is minimal translation of obj2 to get obj1 and obj2 speparated 102 | * (without intersection). 103 | * Returns 0 if obj1 and obj2 intersect and sep is filled with translation 104 | * vector. If obj1 and obj2 don't intersect -1 is returned. 105 | * If memory allocation fails -2 is returned. 106 | */ 107 | CCD_EXPORT int ccdGJKSeparate(const void *obj1, const void *obj2, 108 | const ccd_t *ccd, ccd_vec3_t *sep); 109 | 110 | /** 111 | * Computes penetration of obj2 into obj1. 112 | * Depth of penetration, direction and position is returned. It means that 113 | * if obj2 is translated by distance depth in direction dir objects will 114 | * have touching contact, pos should be position in global coordinates 115 | * where force should take a place. 116 | * 117 | * CCD+EPA algorithm is used. 118 | * 119 | * Returns 0 if obj1 and obj2 intersect and depth, dir and pos are filled 120 | * if given non-NULL pointers. 121 | * If obj1 and obj2 don't intersect -1 is returned. 122 | * If memory allocation fails -2 is returned. 123 | */ 124 | CCD_EXPORT int ccdGJKPenetration(const void *obj1, const void *obj2, 125 | const ccd_t *ccd, ccd_real_t *depth, 126 | ccd_vec3_t *dir, ccd_vec3_t *pos); 127 | 128 | /** 129 | * Returns true if two given objects intersect - MPR algorithm is used. 130 | */ 131 | CCD_EXPORT int ccdMPRIntersect(const void *obj1, const void *obj2, 132 | const ccd_t *ccd); 133 | 134 | /** 135 | * Computes penetration of obj2 into obj1. 136 | * Depth of penetration, direction and position is returned, i.e. if obj2 137 | * is translated by computed depth in resulting direction obj1 and obj2 138 | * would have touching contact. Position is point in global coordinates 139 | * where force should take a place. 140 | * 141 | * Minkowski Portal Refinement algorithm is used (MPR, a.k.a. XenoCollide, 142 | * see Game Programming Gem 7). 143 | * 144 | * Returns 0 if obj1 and obj2 intersect, otherwise -1 is returned. 145 | */ 146 | CCD_EXPORT int ccdMPRPenetration(const void *obj1, const void *obj2, 147 | const ccd_t *ccd, ccd_real_t *depth, 148 | ccd_vec3_t *dir, ccd_vec3_t *pos); 149 | 150 | #ifdef __cplusplus 151 | } /* extern "C" */ 152 | #endif /* __cplusplus */ 153 | 154 | #endif /* __CCD_H__ */ 155 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd_compiler.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_COMPILER_H__ 19 | #define __CCD_COMPILER_H__ 20 | 21 | #include 22 | 23 | #define ccd_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER) 24 | 25 | #define ccd_container_of(ptr, type, member) \ 26 | (type *)( (char *)ptr - ccd_offsetof(type, member)) 27 | 28 | /** 29 | * Marks inline function. 30 | */ 31 | #ifdef __GNUC__ 32 | # define _ccd_inline static inline __attribute__((always_inline)) 33 | #else /* __GNUC__ */ 34 | # define _ccd_inline static __inline 35 | #endif /* __GNUC__ */ 36 | 37 | 38 | /** 39 | * __prefetch(x) - prefetches the cacheline at "x" for read 40 | * __prefetchw(x) - prefetches the cacheline at "x" for write 41 | */ 42 | #ifdef __GNUC__ 43 | # define _ccd_prefetch(x) __builtin_prefetch(x) 44 | # define _ccd_prefetchw(x) __builtin_prefetch(x,1) 45 | #else /* __GNUC__ */ 46 | # define _ccd_prefetch(x) ((void)0) 47 | # define _ccd_prefetchw(x) ((void)0) 48 | #endif /* __GNUC__ */ 49 | 50 | 51 | #ifdef __ICC 52 | // disable unused parameter warning 53 | # pragma warning(disable:869) 54 | // disable annoying "operands are evaluated in unspecified order" warning 55 | # pragma warning(disable:981) 56 | #endif /* __ICC */ 57 | 58 | #ifdef _MSC_VER 59 | // disable unsafe function warning 60 | # define _CRT_SECURE_NO_WARNINGS 61 | #endif /* _MSC_VER */ 62 | 63 | #endif /* __CCD_COMPILER_H__ */ 64 | 65 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CCD_CONFIG_H__ 2 | #define __CCD_CONFIG_H__ 3 | 4 | // #ifdef(`USE_SINGLE', `#define CCD_SINGLE') 5 | // #ifdef(`USE_DOUBLE', `#define CCD_DOUBLE') 6 | 7 | #define CCD_DOUBLE 8 | 9 | #endif /* __CCD_CONFIG_H__ */ 10 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd_export.h: -------------------------------------------------------------------------------- 1 | #ifndef CCD_EXPORT_H 2 | #define CCD_EXPORT_H 3 | 4 | // #ifdef CCD_STATIC_DEFINE 5 | // # define CCD_EXPORT 6 | // #else 7 | // # ifdef _MSC_VER 8 | // # ifdef ccd_EXPORTS 9 | // # define CCD_EXPORT __declspec(dllexport) 10 | // # else /* ccd_EXPORTS */ 11 | // # define CCD_EXPORT __declspec(dllimport) 12 | // # endif /* ccd_EXPORTS */ 13 | // # else 14 | // # ifndef CCD_EXPORT 15 | // # ifdef ccd_EXPORTS 16 | // /* We are building this library */ 17 | // # define CCD_EXPORT __attribute__((visibility("default"))) 18 | // # else 19 | // /* We are using this library */ 20 | // # define CCD_EXPORT __attribute__((visibility("default"))) 21 | // # endif 22 | // # endif 23 | // # endif 24 | // #endif 25 | #define CCD_EXPORT GS_API_DECL 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd_quat.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_QUAT_H__ 19 | #define __CCD_QUAT_H__ 20 | 21 | #include "ccd_compiler.h" 22 | #include "ccd_vec3.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif /* __cplusplus */ 27 | 28 | struct _ccd_quat_t { 29 | ccd_real_t q[4]; //!< x, y, z, w 30 | }; 31 | typedef struct _ccd_quat_t ccd_quat_t; 32 | 33 | #define CCD_QUAT(name, x, y, z, w) \ 34 | ccd_quat_t name = { {x, y, z, w} } 35 | 36 | _ccd_inline ccd_real_t ccdQuatLen2(const ccd_quat_t *q); 37 | _ccd_inline ccd_real_t ccdQuatLen(const ccd_quat_t *q); 38 | 39 | _ccd_inline void ccdQuatSet(ccd_quat_t *q, ccd_real_t x, ccd_real_t y, ccd_real_t z, ccd_real_t w); 40 | _ccd_inline void ccdQuatCopy(ccd_quat_t *dest, const ccd_quat_t *src); 41 | 42 | _ccd_inline int ccdQuatNormalize(ccd_quat_t *q); 43 | 44 | _ccd_inline void ccdQuatSetAngleAxis(ccd_quat_t *q, 45 | ccd_real_t angle, const ccd_vec3_t *axis); 46 | 47 | _ccd_inline void ccdQuatScale(ccd_quat_t *q, ccd_real_t k); 48 | 49 | /** 50 | * q = q * q2 51 | */ 52 | _ccd_inline void ccdQuatMul(ccd_quat_t *q, const ccd_quat_t *q2); 53 | 54 | /** 55 | * q = a * b 56 | */ 57 | _ccd_inline void ccdQuatMul2(ccd_quat_t *q, 58 | const ccd_quat_t *a, const ccd_quat_t *b); 59 | 60 | /** 61 | * Inverts quaternion. 62 | * Returns 0 on success. 63 | */ 64 | _ccd_inline int ccdQuatInvert(ccd_quat_t *q); 65 | _ccd_inline int ccdQuatInvert2(ccd_quat_t *dest, const ccd_quat_t *src); 66 | 67 | 68 | /** 69 | * Rotate vector v by quaternion q. 70 | */ 71 | _ccd_inline void ccdQuatRotVec(ccd_vec3_t *v, const ccd_quat_t *q); 72 | 73 | 74 | /**** INLINES ****/ 75 | _ccd_inline ccd_real_t ccdQuatLen2(const ccd_quat_t *q) 76 | { 77 | ccd_real_t len; 78 | 79 | len = q->q[0] * q->q[0]; 80 | len += q->q[1] * q->q[1]; 81 | len += q->q[2] * q->q[2]; 82 | len += q->q[3] * q->q[3]; 83 | 84 | return len; 85 | } 86 | 87 | _ccd_inline ccd_real_t ccdQuatLen(const ccd_quat_t *q) 88 | { 89 | return CCD_SQRT(ccdQuatLen2(q)); 90 | } 91 | 92 | _ccd_inline void ccdQuatSet(ccd_quat_t *q, ccd_real_t x, ccd_real_t y, ccd_real_t z, ccd_real_t w) 93 | { 94 | q->q[0] = x; 95 | q->q[1] = y; 96 | q->q[2] = z; 97 | q->q[3] = w; 98 | } 99 | 100 | _ccd_inline void ccdQuatCopy(ccd_quat_t *dest, const ccd_quat_t *src) 101 | { 102 | *dest = *src; 103 | } 104 | 105 | 106 | _ccd_inline int ccdQuatNormalize(ccd_quat_t *q) 107 | { 108 | ccd_real_t len = ccdQuatLen(q); 109 | if (len < CCD_EPS) 110 | return 0; 111 | 112 | ccdQuatScale(q, CCD_ONE / len); 113 | return 1; 114 | } 115 | 116 | _ccd_inline void ccdQuatSetAngleAxis(ccd_quat_t *q, 117 | ccd_real_t angle, const ccd_vec3_t *axis) 118 | { 119 | ccd_real_t a, x, y, z, n, s; 120 | 121 | a = angle/2; 122 | x = ccdVec3X(axis); 123 | y = ccdVec3Y(axis); 124 | z = ccdVec3Z(axis); 125 | n = CCD_SQRT(x*x + y*y + z*z); 126 | 127 | // axis==0? (treat this the same as angle==0 with an arbitrary axis) 128 | if (n < CCD_EPS){ 129 | q->q[0] = q->q[1] = q->q[2] = CCD_ZERO; 130 | q->q[3] = CCD_ONE; 131 | }else{ 132 | s = sin(a)/n; 133 | 134 | q->q[3] = cos(a); 135 | q->q[0] = x*s; 136 | q->q[1] = y*s; 137 | q->q[2] = z*s; 138 | 139 | ccdQuatNormalize(q); 140 | } 141 | } 142 | 143 | 144 | _ccd_inline void ccdQuatScale(ccd_quat_t *q, ccd_real_t k) 145 | { 146 | size_t i; 147 | for (i = 0; i < 4; i++) 148 | q->q[i] *= k; 149 | } 150 | 151 | _ccd_inline void ccdQuatMul(ccd_quat_t *q, const ccd_quat_t *q2) 152 | { 153 | ccd_quat_t a; 154 | ccdQuatCopy(&a, q); 155 | ccdQuatMul2(q, &a, q2); 156 | } 157 | 158 | _ccd_inline void ccdQuatMul2(ccd_quat_t *q, 159 | const ccd_quat_t *a, const ccd_quat_t *b) 160 | { 161 | q->q[0] = a->q[3] * b->q[0] 162 | + a->q[0] * b->q[3] 163 | + a->q[1] * b->q[2] 164 | - a->q[2] * b->q[1]; 165 | q->q[1] = a->q[3] * b->q[1] 166 | + a->q[1] * b->q[3] 167 | - a->q[0] * b->q[2] 168 | + a->q[2] * b->q[0]; 169 | q->q[2] = a->q[3] * b->q[2] 170 | + a->q[2] * b->q[3] 171 | + a->q[0] * b->q[1] 172 | - a->q[1] * b->q[0]; 173 | q->q[3] = a->q[3] * b->q[3] 174 | - a->q[0] * b->q[0] 175 | - a->q[1] * b->q[1] 176 | - a->q[2] * b->q[2]; 177 | } 178 | 179 | _ccd_inline int ccdQuatInvert(ccd_quat_t *q) 180 | { 181 | ccd_real_t len2 = ccdQuatLen2(q); 182 | if (len2 < CCD_EPS) 183 | return -1; 184 | 185 | len2 = CCD_ONE / len2; 186 | 187 | q->q[0] = -q->q[0] * len2; 188 | q->q[1] = -q->q[1] * len2; 189 | q->q[2] = -q->q[2] * len2; 190 | q->q[3] = q->q[3] * len2; 191 | 192 | return 0; 193 | } 194 | _ccd_inline int ccdQuatInvert2(ccd_quat_t *dest, const ccd_quat_t *src) 195 | { 196 | ccdQuatCopy(dest, src); 197 | return ccdQuatInvert(dest); 198 | } 199 | 200 | _ccd_inline void ccdQuatRotVec(ccd_vec3_t *v, const ccd_quat_t *q) 201 | { 202 | // original version: 31 mul + 21 add 203 | // optimized version: 18 mul + 12 add 204 | // formula: v = v + 2 * cross(q.xyz, cross(q.xyz, v) + q.w * v) 205 | ccd_real_t cross1_x, cross1_y, cross1_z, cross2_x, cross2_y, cross2_z; 206 | ccd_real_t x, y, z, w; 207 | ccd_real_t vx, vy, vz; 208 | 209 | vx = ccdVec3X(v); 210 | vy = ccdVec3Y(v); 211 | vz = ccdVec3Z(v); 212 | 213 | w = q->q[3]; 214 | x = q->q[0]; 215 | y = q->q[1]; 216 | z = q->q[2]; 217 | 218 | cross1_x = y * vz - z * vy + w * vx; 219 | cross1_y = z * vx - x * vz + w * vy; 220 | cross1_z = x * vy - y * vx + w * vz; 221 | cross2_x = y * cross1_z - z * cross1_y; 222 | cross2_y = z * cross1_x - x * cross1_z; 223 | cross2_z = x * cross1_y - y * cross1_x; 224 | ccdVec3Set(v, vx + 2 * cross2_x, vy + 2 * cross2_y, vz + 2 * cross2_z); 225 | } 226 | 227 | #ifdef __cplusplus 228 | } /* extern "C" */ 229 | #endif /* __cplusplus */ 230 | 231 | #endif /* __CCD_QUAT_H__ */ 232 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd/ccd_vec3.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010-2013 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_VEC3_H__ 19 | #define __CCD_VEC3_H__ 20 | 21 | #include 22 | #include 23 | #include 24 | #include "ccd_compiler.h" 25 | #include "ccd_config.h" 26 | #include "ccd_export.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif /* __cplusplus */ 31 | 32 | 33 | #ifndef CCD_SINGLE 34 | # ifndef CCD_DOUBLE 35 | # error You must define CCD_SINGLE or CCD_DOUBLE 36 | # endif /* CCD_DOUBLE */ 37 | #endif /* CCD_SINGLE */ 38 | 39 | #ifdef WIN32 40 | # define CCD_FMIN(x, y) ((x) < (y) ? (x) : (y)) 41 | #endif /* WIN32 */ 42 | 43 | #ifdef CCD_SINGLE 44 | # ifdef CCD_DOUBLE 45 | # error You can define either CCD_SINGLE or CCD_DOUBLE, not both! 46 | # endif /* CCD_DOUBLE */ 47 | 48 | typedef float ccd_real_t; 49 | 50 | //# define CCD_EPS 1E-6 51 | # define CCD_EPS FLT_EPSILON 52 | 53 | # define CCD_REAL_MAX FLT_MAX 54 | 55 | # define CCD_REAL(x) (x ## f) /*!< form a constant */ 56 | # define CCD_SQRT(x) (sqrtf(x)) /*!< square root */ 57 | # define CCD_FABS(x) (fabsf(x)) /*!< absolute value */ 58 | # define CCD_FMAX(x, y) (fmaxf((x), (y))) /*!< maximum of two floats */ 59 | 60 | # ifndef CCD_FMIN 61 | # define CCD_FMIN(x, y) (fminf((x), (y))) /*!< minimum of two floats */ 62 | # endif /* CCD_FMIN */ 63 | 64 | #endif /* CCD_SINGLE */ 65 | 66 | #ifdef CCD_DOUBLE 67 | typedef double ccd_real_t; 68 | 69 | //# define CCD_EPS 1E-10 70 | # define CCD_EPS DBL_EPSILON 71 | 72 | # define CCD_REAL_MAX DBL_MAX 73 | 74 | # define CCD_REAL(x) (x) /*!< form a constant */ 75 | # define CCD_SQRT(x) (sqrt(x)) /*!< square root */ 76 | # define CCD_FABS(x) (fabs(x)) /*!< absolute value */ 77 | # define CCD_FMAX(x, y) (fmax((x), (y))) /*!< maximum of two floats */ 78 | 79 | # ifndef CCD_FMIN 80 | # define CCD_FMIN(x, y) (fmin((x), (y))) /*!< minimum of two floats */ 81 | # endif /* CCD_FMIN */ 82 | 83 | #endif /* CCD_DOUBLE */ 84 | 85 | #define CCD_ONE CCD_REAL(1.) 86 | #define CCD_ZERO CCD_REAL(0.) 87 | 88 | struct _ccd_vec3_t { 89 | ccd_real_t v[3]; 90 | }; 91 | typedef struct _ccd_vec3_t ccd_vec3_t; 92 | 93 | 94 | /** 95 | * Holds origin (0,0,0) - this variable is meant to be read-only! 96 | */ 97 | CCD_EXPORT ccd_vec3_t *ccd_vec3_origin; 98 | 99 | /** 100 | * Array of points uniformly distributed on unit sphere. 101 | */ 102 | CCD_EXPORT ccd_vec3_t *ccd_points_on_sphere; 103 | CCD_EXPORT size_t ccd_points_on_sphere_len; 104 | 105 | /** Returns sign of value. */ 106 | _ccd_inline int ccdSign(ccd_real_t val); 107 | /** Returns true if val is zero. **/ 108 | _ccd_inline int ccdIsZero(ccd_real_t val); 109 | /** Returns true if a and b equal. **/ 110 | _ccd_inline int ccdEq(ccd_real_t a, ccd_real_t b); 111 | 112 | 113 | #define CCD_VEC3_STATIC(x, y, z) \ 114 | { { (x), (y), (z) } } 115 | 116 | #define CCD_VEC3(name, x, y, z) \ 117 | ccd_vec3_t name = CCD_VEC3_STATIC((x), (y), (z)) 118 | 119 | _ccd_inline ccd_real_t ccdVec3X(const ccd_vec3_t *v); 120 | _ccd_inline ccd_real_t ccdVec3Y(const ccd_vec3_t *v); 121 | _ccd_inline ccd_real_t ccdVec3Z(const ccd_vec3_t *v); 122 | 123 | /** 124 | * Returns true if a and b equal. 125 | */ 126 | _ccd_inline int ccdVec3Eq(const ccd_vec3_t *a, const ccd_vec3_t *b); 127 | 128 | /** 129 | * Returns squared length of vector. 130 | */ 131 | _ccd_inline ccd_real_t ccdVec3Len2(const ccd_vec3_t *v); 132 | 133 | /** 134 | * Returns distance between a and b. 135 | */ 136 | _ccd_inline ccd_real_t ccdVec3Dist2(const ccd_vec3_t *a, const ccd_vec3_t *b); 137 | 138 | 139 | _ccd_inline void ccdVec3Set(ccd_vec3_t *v, ccd_real_t x, ccd_real_t y, ccd_real_t z); 140 | 141 | /** 142 | * v = w 143 | */ 144 | _ccd_inline void ccdVec3Copy(ccd_vec3_t *v, const ccd_vec3_t *w); 145 | 146 | /** 147 | * Substracts coordinates of vector w from vector v. v = v - w 148 | */ 149 | _ccd_inline void ccdVec3Sub(ccd_vec3_t *v, const ccd_vec3_t *w); 150 | 151 | /** 152 | * Adds coordinates of vector w to vector v. v = v + w 153 | */ 154 | _ccd_inline void ccdVec3Add(ccd_vec3_t *v, const ccd_vec3_t *w); 155 | 156 | /** 157 | * d = v - w 158 | */ 159 | _ccd_inline void ccdVec3Sub2(ccd_vec3_t *d, const ccd_vec3_t *v, const ccd_vec3_t *w); 160 | 161 | /** 162 | * d = d * k; 163 | */ 164 | _ccd_inline void ccdVec3Scale(ccd_vec3_t *d, ccd_real_t k); 165 | 166 | /** 167 | * Normalizes given vector to unit length. 168 | */ 169 | _ccd_inline void ccdVec3Normalize(ccd_vec3_t *d); 170 | 171 | 172 | /** 173 | * Dot product of two vectors. 174 | */ 175 | _ccd_inline ccd_real_t ccdVec3Dot(const ccd_vec3_t *a, const ccd_vec3_t *b); 176 | 177 | /** 178 | * Cross product: d = a x b. 179 | */ 180 | _ccd_inline void ccdVec3Cross(ccd_vec3_t *d, const ccd_vec3_t *a, const ccd_vec3_t *b); 181 | 182 | 183 | /** 184 | * Returns distance^2 of point P to segment ab. 185 | * If witness is non-NULL it is filled with coordinates of point from which 186 | * was computed distance to point P. 187 | */ 188 | CCD_EXPORT ccd_real_t ccdVec3PointSegmentDist2(const ccd_vec3_t *P, 189 | const ccd_vec3_t *a, 190 | const ccd_vec3_t *b, 191 | ccd_vec3_t *witness); 192 | 193 | /** 194 | * Returns distance^2 of point P from triangle formed by triplet a, b, c. 195 | * If witness vector is provided it is filled with coordinates of point 196 | * from which was computed distance to point P. 197 | */ 198 | CCD_EXPORT ccd_real_t ccdVec3PointTriDist2(const ccd_vec3_t *P, 199 | const ccd_vec3_t *a, 200 | const ccd_vec3_t *b, 201 | const ccd_vec3_t *c, 202 | ccd_vec3_t *witness); 203 | 204 | 205 | /**** INLINES ****/ 206 | _ccd_inline int ccdSign(ccd_real_t val) 207 | { 208 | if (ccdIsZero(val)){ 209 | return 0; 210 | }else if (val < CCD_ZERO){ 211 | return -1; 212 | } 213 | return 1; 214 | } 215 | 216 | _ccd_inline int ccdIsZero(ccd_real_t val) 217 | { 218 | return CCD_FABS(val) < CCD_EPS; 219 | } 220 | 221 | _ccd_inline int ccdEq(ccd_real_t _a, ccd_real_t _b) 222 | { 223 | ccd_real_t ab; 224 | ccd_real_t a, b; 225 | 226 | ab = CCD_FABS(_a - _b); 227 | if (CCD_FABS(ab) < CCD_EPS) 228 | return 1; 229 | 230 | a = CCD_FABS(_a); 231 | b = CCD_FABS(_b); 232 | if (b > a){ 233 | return ab < CCD_EPS * b; 234 | }else{ 235 | return ab < CCD_EPS * a; 236 | } 237 | } 238 | 239 | 240 | _ccd_inline ccd_real_t ccdVec3X(const ccd_vec3_t *v) 241 | { 242 | return v->v[0]; 243 | } 244 | 245 | _ccd_inline ccd_real_t ccdVec3Y(const ccd_vec3_t *v) 246 | { 247 | return v->v[1]; 248 | } 249 | 250 | _ccd_inline ccd_real_t ccdVec3Z(const ccd_vec3_t *v) 251 | { 252 | return v->v[2]; 253 | } 254 | 255 | _ccd_inline int ccdVec3Eq(const ccd_vec3_t *a, const ccd_vec3_t *b) 256 | { 257 | return ccdEq(ccdVec3X(a), ccdVec3X(b)) 258 | && ccdEq(ccdVec3Y(a), ccdVec3Y(b)) 259 | && ccdEq(ccdVec3Z(a), ccdVec3Z(b)); 260 | } 261 | 262 | _ccd_inline ccd_real_t ccdVec3Len2(const ccd_vec3_t *v) 263 | { 264 | return ccdVec3Dot(v, v); 265 | } 266 | 267 | _ccd_inline ccd_real_t ccdVec3Dist2(const ccd_vec3_t *a, const ccd_vec3_t *b) 268 | { 269 | ccd_vec3_t ab; 270 | ccdVec3Sub2(&ab, a, b); 271 | return ccdVec3Len2(&ab); 272 | } 273 | 274 | _ccd_inline void ccdVec3Set(ccd_vec3_t *v, ccd_real_t x, ccd_real_t y, ccd_real_t z) 275 | { 276 | v->v[0] = x; 277 | v->v[1] = y; 278 | v->v[2] = z; 279 | } 280 | 281 | _ccd_inline void ccdVec3Copy(ccd_vec3_t *v, const ccd_vec3_t *w) 282 | { 283 | *v = *w; 284 | } 285 | 286 | _ccd_inline void ccdVec3Sub(ccd_vec3_t *v, const ccd_vec3_t *w) 287 | { 288 | v->v[0] -= w->v[0]; 289 | v->v[1] -= w->v[1]; 290 | v->v[2] -= w->v[2]; 291 | } 292 | _ccd_inline void ccdVec3Sub2(ccd_vec3_t *d, const ccd_vec3_t *v, const ccd_vec3_t *w) 293 | { 294 | d->v[0] = v->v[0] - w->v[0]; 295 | d->v[1] = v->v[1] - w->v[1]; 296 | d->v[2] = v->v[2] - w->v[2]; 297 | } 298 | 299 | _ccd_inline void ccdVec3Add(ccd_vec3_t *v, const ccd_vec3_t *w) 300 | { 301 | v->v[0] += w->v[0]; 302 | v->v[1] += w->v[1]; 303 | v->v[2] += w->v[2]; 304 | } 305 | 306 | _ccd_inline void ccdVec3Scale(ccd_vec3_t *d, ccd_real_t k) 307 | { 308 | d->v[0] *= k; 309 | d->v[1] *= k; 310 | d->v[2] *= k; 311 | } 312 | 313 | _ccd_inline void ccdVec3Normalize(ccd_vec3_t *d) 314 | { 315 | ccd_real_t k = CCD_ONE / CCD_SQRT(ccdVec3Len2(d)); 316 | ccdVec3Scale(d, k); 317 | } 318 | 319 | _ccd_inline ccd_real_t ccdVec3Dot(const ccd_vec3_t *a, const ccd_vec3_t *b) 320 | { 321 | ccd_real_t dot; 322 | 323 | dot = a->v[0] * b->v[0]; 324 | dot += a->v[1] * b->v[1]; 325 | dot += a->v[2] * b->v[2]; 326 | return dot; 327 | } 328 | 329 | _ccd_inline void ccdVec3Cross(ccd_vec3_t *d, const ccd_vec3_t *a, const ccd_vec3_t *b) 330 | { 331 | d->v[0] = (a->v[1] * b->v[2]) - (a->v[2] * b->v[1]); 332 | d->v[1] = (a->v[2] * b->v[0]) - (a->v[0] * b->v[2]); 333 | d->v[2] = (a->v[0] * b->v[1]) - (a->v[1] * b->v[0]); 334 | } 335 | 336 | #ifdef __cplusplus 337 | } /* extern "C" */ 338 | #endif /* __cplusplus */ 339 | 340 | #endif /* __CCD_VEC3_H__ */ 341 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_alloc.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_ALLOC_H__ 19 | #define __CCD_ALLOC_H__ 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /** 28 | * Functions and macros required for memory allocation. 29 | */ 30 | 31 | /* Memory allocation: */ 32 | #define __CCD_ALLOC_MEMORY(type, ptr_old, size) \ 33 | (type *)realloc((void *)ptr_old, (size)) 34 | 35 | /** Allocate memory for one element of type. */ 36 | #define CCD_ALLOC(type) \ 37 | __CCD_ALLOC_MEMORY(type, NULL, sizeof(type)) 38 | 39 | /** Allocate memory for array of elements of type type. */ 40 | #define CCD_ALLOC_ARR(type, num_elements) \ 41 | __CCD_ALLOC_MEMORY(type, NULL, sizeof(type) * (num_elements)) 42 | 43 | #define CCD_REALLOC_ARR(ptr, type, num_elements) \ 44 | __CCD_ALLOC_MEMORY(type, ptr, sizeof(type) * (num_elements)) 45 | 46 | #ifdef __cplusplus 47 | } /* extern "C" */ 48 | #endif /* __cplusplus */ 49 | 50 | #endif /* __CCD_ALLOC_H__ */ 51 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_dbg.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_DBG_H__ 19 | #define __CCD_DBG_H__ 20 | 21 | /** 22 | * Some macros which can be used for printing debug info to stderr if macro 23 | * NDEBUG not defined. 24 | * 25 | * DBG_PROLOGUE can be specified as string and this string will be 26 | * prepended to output text 27 | */ 28 | #ifndef NDEBUG 29 | 30 | #include 31 | 32 | #ifndef DBG_PROLOGUE 33 | # define DBG_PROLOGUE 34 | #endif 35 | 36 | # define DBG(format, ...) do { \ 37 | fprintf(stderr, DBG_PROLOGUE "%s :: " format "\n", __func__, ## __VA_ARGS__); \ 38 | fflush(stderr); \ 39 | } while (0) 40 | 41 | # define DBG2(str) do { \ 42 | fprintf(stderr, DBG_PROLOGUE "%s :: " str "\n", __func__); \ 43 | fflush(stderr); \ 44 | } while (0) 45 | 46 | # define DBG_VEC3(vec, prefix) do {\ 47 | fprintf(stderr, DBG_PROLOGUE "%s :: %s[%lf %lf %lf]\n", \ 48 | __func__, prefix, ccdVec3X(vec), ccdVec3Y(vec), ccdVec3Z(vec)); \ 49 | fflush(stderr); \ 50 | } while (0) 51 | /* 52 | # define DBG_VEC3(vec, prefix) do {\ 53 | fprintf(stderr, DBG_PROLOGUE "%s :: %s[%.20lf %.20lf %.20lf]\n", \ 54 | __func__, prefix, ccdVec3X(vec), ccdVec3Y(vec), ccdVec3Z(vec)); \ 55 | fflush(stderr); \ 56 | } while (0) 57 | */ 58 | 59 | #else 60 | # define DBG(format, ...) 61 | # define DBG2(str) 62 | # define DBG_VEC3(v, prefix) 63 | #endif 64 | 65 | #endif /* __CCD_DBG_H__ */ 66 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_list.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_LIST_H__ 19 | #define __CCD_LIST_H__ 20 | 21 | #include 22 | #include "ccd/ccd_compiler.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif /* __cplusplus */ 27 | 28 | struct _ccd_list_t { 29 | struct _ccd_list_t *next, *prev; 30 | }; 31 | typedef struct _ccd_list_t ccd_list_t; 32 | 33 | 34 | 35 | /** 36 | * Get the struct for this entry. 37 | * @ptr: the &ccd_list_t pointer. 38 | * @type: the type of the struct this is embedded in. 39 | * @member: the name of the list_struct within the struct. 40 | */ 41 | #define ccdListEntry(ptr, type, member) \ 42 | ccd_container_of(ptr, type, member) 43 | 44 | /** 45 | * Iterates over list. 46 | */ 47 | #define ccdListForEach(list, item) \ 48 | for (item = (list)->next; \ 49 | _ccd_prefetch((item)->next), item != (list); \ 50 | item = (item)->next) 51 | 52 | /** 53 | * Iterates over list safe against remove of list entry 54 | */ 55 | #define ccdListForEachSafe(list, item, tmp) \ 56 | for (item = (list)->next, tmp = (item)->next; \ 57 | item != (list); \ 58 | item = tmp, tmp = (item)->next) 59 | 60 | /** 61 | * Iterates over list of given type. 62 | * @pos: the type * to use as a loop cursor. 63 | * @head: the head for your list. 64 | * @member: the name of the list_struct within the struct. 65 | */ 66 | #define ccdListForEachEntry(head, pos, postype, member) \ 67 | for (pos = ccdListEntry((head)->next, postype, member); \ 68 | _ccd_prefetch(pos->member.next), &pos->member != (head); \ 69 | pos = ccdListEntry(pos->member.next, postype, member)) 70 | 71 | /** 72 | * Iterates over list of given type safe against removal of list entry 73 | * @pos: the type * to use as a loop cursor. 74 | * @n: another type * to use as temporary storage 75 | * @head: the head for your list. 76 | * @member: the name of the list_struct within the struct. 77 | */ 78 | #define ccdListForEachEntrySafe(head, pos, postype, n, ntype, member) \ 79 | for (pos = ccdListEntry((head)->next, postype, member), \ 80 | n = ccdListEntry(pos->member.next, postype, member); \ 81 | &pos->member != (head); \ 82 | pos = n, n = ccdListEntry(n->member.next, ntype, member)) 83 | 84 | 85 | /** 86 | * Initialize list. 87 | */ 88 | _ccd_inline void ccdListInit(ccd_list_t *l); 89 | 90 | _ccd_inline ccd_list_t *ccdListNext(ccd_list_t *l); 91 | _ccd_inline ccd_list_t *ccdListPrev(ccd_list_t *l); 92 | 93 | /** 94 | * Returns true if list is empty. 95 | */ 96 | _ccd_inline int ccdListEmpty(const ccd_list_t *head); 97 | 98 | /** 99 | * Appends item to end of the list l. 100 | */ 101 | _ccd_inline void ccdListAppend(ccd_list_t *l, ccd_list_t *item); 102 | 103 | /** 104 | * Removes item from list. 105 | */ 106 | _ccd_inline void ccdListDel(ccd_list_t *item); 107 | 108 | 109 | 110 | /// 111 | /// INLINES: 112 | /// 113 | 114 | _ccd_inline void ccdListInit(ccd_list_t *l) 115 | { 116 | l->next = l; 117 | l->prev = l; 118 | } 119 | 120 | _ccd_inline ccd_list_t *ccdListNext(ccd_list_t *l) 121 | { 122 | return l->next; 123 | } 124 | 125 | _ccd_inline ccd_list_t *ccdListPrev(ccd_list_t *l) 126 | { 127 | return l->prev; 128 | } 129 | 130 | _ccd_inline int ccdListEmpty(const ccd_list_t *head) 131 | { 132 | return head->next == head; 133 | } 134 | 135 | _ccd_inline void ccdListAppend(ccd_list_t *l, ccd_list_t *n) 136 | { 137 | n->prev = l->prev; 138 | n->next = l; 139 | l->prev->next = n; 140 | l->prev = n; 141 | } 142 | 143 | _ccd_inline void ccdListDel(ccd_list_t *item) 144 | { 145 | item->next->prev = item->prev; 146 | item->prev->next = item->next; 147 | item->next = item; 148 | item->prev = item; 149 | } 150 | 151 | #ifdef __cplusplus 152 | } /* extern "C" */ 153 | #endif /* __cplusplus */ 154 | 155 | #endif /* __CCD_LIST_H__ */ 156 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_polytope.c: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #include 19 | #include 20 | #include "ccd_polytope.h" 21 | #include "ccd_alloc.h" 22 | 23 | _ccd_inline void _ccdPtNearestUpdate(ccd_pt_t *pt, ccd_pt_el_t *el) 24 | { 25 | if (ccdEq(pt->nearest_dist, el->dist)){ 26 | if (el->type < pt->nearest_type){ 27 | pt->nearest = el; 28 | pt->nearest_dist = el->dist; 29 | pt->nearest_type = el->type; 30 | } 31 | }else if (el->dist < pt->nearest_dist){ 32 | pt->nearest = el; 33 | pt->nearest_dist = el->dist; 34 | pt->nearest_type = el->type; 35 | } 36 | } 37 | 38 | static void _ccdPtNearestRenew(ccd_pt_t *pt) 39 | { 40 | ccd_pt_vertex_t *v; 41 | ccd_pt_edge_t *e; 42 | ccd_pt_face_t *f; 43 | 44 | pt->nearest_dist = CCD_REAL_MAX; 45 | pt->nearest_type = 3; 46 | pt->nearest = NULL; 47 | 48 | ccdListForEachEntry(&pt->vertices, v, ccd_pt_vertex_t, list){ 49 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)v); 50 | } 51 | 52 | ccdListForEachEntry(&pt->edges, e, ccd_pt_edge_t, list){ 53 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)e); 54 | } 55 | 56 | ccdListForEachEntry(&pt->faces, f, ccd_pt_face_t, list){ 57 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)f); 58 | } 59 | } 60 | 61 | 62 | 63 | void ccdPtInit(ccd_pt_t *pt) 64 | { 65 | ccdListInit(&pt->vertices); 66 | ccdListInit(&pt->edges); 67 | ccdListInit(&pt->faces); 68 | 69 | pt->nearest = NULL; 70 | pt->nearest_dist = CCD_REAL_MAX; 71 | pt->nearest_type = 3; 72 | } 73 | 74 | void ccdPtDestroy(ccd_pt_t *pt) 75 | { 76 | ccd_pt_face_t *f, *f2; 77 | ccd_pt_edge_t *e, *e2; 78 | ccd_pt_vertex_t *v, *v2; 79 | 80 | // first delete all faces 81 | ccdListForEachEntrySafe(&pt->faces, f, ccd_pt_face_t, f2, ccd_pt_face_t, list){ 82 | ccdPtDelFace(pt, f); 83 | } 84 | 85 | // delete all edges 86 | ccdListForEachEntrySafe(&pt->edges, e, ccd_pt_edge_t, e2, ccd_pt_edge_t, list){ 87 | ccdPtDelEdge(pt, e); 88 | } 89 | 90 | // delete all vertices 91 | ccdListForEachEntrySafe(&pt->vertices, v, ccd_pt_vertex_t, v2, ccd_pt_vertex_t, list){ 92 | ccdPtDelVertex(pt, v); 93 | } 94 | } 95 | 96 | 97 | ccd_pt_vertex_t *ccdPtAddVertex(ccd_pt_t *pt, const ccd_support_t *v) 98 | { 99 | ccd_pt_vertex_t *vert; 100 | 101 | vert = CCD_ALLOC(ccd_pt_vertex_t); 102 | if (vert == NULL) 103 | return NULL; 104 | 105 | vert->type = CCD_PT_VERTEX; 106 | ccdSupportCopy(&vert->v, v); 107 | 108 | vert->dist = ccdVec3Len2(&vert->v.v); 109 | ccdVec3Copy(&vert->witness, &vert->v.v); 110 | 111 | ccdListInit(&vert->edges); 112 | 113 | // add vertex to list 114 | ccdListAppend(&pt->vertices, &vert->list); 115 | 116 | // update position in .nearest array 117 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)vert); 118 | 119 | return vert; 120 | } 121 | 122 | ccd_pt_edge_t *ccdPtAddEdge(ccd_pt_t *pt, ccd_pt_vertex_t *v1, 123 | ccd_pt_vertex_t *v2) 124 | { 125 | const ccd_vec3_t *a, *b; 126 | ccd_pt_edge_t *edge; 127 | 128 | if (v1 == NULL || v2 == NULL) 129 | return NULL; 130 | 131 | edge = CCD_ALLOC(ccd_pt_edge_t); 132 | if (edge == NULL) 133 | return NULL; 134 | 135 | edge->type = CCD_PT_EDGE; 136 | edge->vertex[0] = v1; 137 | edge->vertex[1] = v2; 138 | edge->faces[0] = edge->faces[1] = NULL; 139 | 140 | a = &edge->vertex[0]->v.v; 141 | b = &edge->vertex[1]->v.v; 142 | edge->dist = ccdVec3PointSegmentDist2(ccd_vec3_origin, a, b, &edge->witness); 143 | 144 | ccdListAppend(&edge->vertex[0]->edges, &edge->vertex_list[0]); 145 | ccdListAppend(&edge->vertex[1]->edges, &edge->vertex_list[1]); 146 | 147 | ccdListAppend(&pt->edges, &edge->list); 148 | 149 | // update position in .nearest array 150 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)edge); 151 | 152 | return edge; 153 | } 154 | 155 | ccd_pt_face_t *ccdPtAddFace(ccd_pt_t *pt, ccd_pt_edge_t *e1, 156 | ccd_pt_edge_t *e2, 157 | ccd_pt_edge_t *e3) 158 | { 159 | const ccd_vec3_t *a, *b, *c; 160 | ccd_pt_face_t *face; 161 | ccd_pt_edge_t *e; 162 | size_t i; 163 | 164 | if (e1 == NULL || e2 == NULL || e3 == NULL) 165 | return NULL; 166 | 167 | face = CCD_ALLOC(ccd_pt_face_t); 168 | if (face == NULL) 169 | return NULL; 170 | 171 | face->type = CCD_PT_FACE; 172 | face->edge[0] = e1; 173 | face->edge[1] = e2; 174 | face->edge[2] = e3; 175 | 176 | // obtain triplet of vertices 177 | a = &face->edge[0]->vertex[0]->v.v; 178 | b = &face->edge[0]->vertex[1]->v.v; 179 | e = face->edge[1]; 180 | if (e->vertex[0] != face->edge[0]->vertex[0] 181 | && e->vertex[0] != face->edge[0]->vertex[1]){ 182 | c = &e->vertex[0]->v.v; 183 | }else{ 184 | c = &e->vertex[1]->v.v; 185 | } 186 | face->dist = ccdVec3PointTriDist2(ccd_vec3_origin, a, b, c, &face->witness); 187 | 188 | 189 | for (i = 0; i < 3; i++){ 190 | if (face->edge[i]->faces[0] == NULL){ 191 | face->edge[i]->faces[0] = face; 192 | }else{ 193 | face->edge[i]->faces[1] = face; 194 | } 195 | } 196 | 197 | ccdListAppend(&pt->faces, &face->list); 198 | 199 | // update position in .nearest array 200 | _ccdPtNearestUpdate(pt, (ccd_pt_el_t *)face); 201 | 202 | return face; 203 | } 204 | 205 | 206 | void ccdPtRecomputeDistances(ccd_pt_t *pt) 207 | { 208 | ccd_pt_vertex_t *v; 209 | ccd_pt_edge_t *e; 210 | ccd_pt_face_t *f; 211 | const ccd_vec3_t *a, *b, *c; 212 | ccd_real_t dist; 213 | 214 | ccdListForEachEntry(&pt->vertices, v, ccd_pt_vertex_t, list){ 215 | dist = ccdVec3Len2(&v->v.v); 216 | v->dist = dist; 217 | ccdVec3Copy(&v->witness, &v->v.v); 218 | } 219 | 220 | ccdListForEachEntry(&pt->edges, e, ccd_pt_edge_t, list){ 221 | a = &e->vertex[0]->v.v; 222 | b = &e->vertex[1]->v.v; 223 | dist = ccdVec3PointSegmentDist2(ccd_vec3_origin, a, b, &e->witness); 224 | e->dist = dist; 225 | } 226 | 227 | ccdListForEachEntry(&pt->faces, f, ccd_pt_face_t, list){ 228 | // obtain triplet of vertices 229 | a = &f->edge[0]->vertex[0]->v.v; 230 | b = &f->edge[0]->vertex[1]->v.v; 231 | e = f->edge[1]; 232 | if (e->vertex[0] != f->edge[0]->vertex[0] 233 | && e->vertex[0] != f->edge[0]->vertex[1]){ 234 | c = &e->vertex[0]->v.v; 235 | }else{ 236 | c = &e->vertex[1]->v.v; 237 | } 238 | 239 | dist = ccdVec3PointTriDist2(ccd_vec3_origin, a, b, c, &f->witness); 240 | f->dist = dist; 241 | } 242 | } 243 | 244 | ccd_pt_el_t *ccdPtNearest(ccd_pt_t *pt) 245 | { 246 | if (!pt->nearest){ 247 | _ccdPtNearestRenew(pt); 248 | } 249 | return pt->nearest; 250 | } 251 | 252 | 253 | void ccdPtDumpSVT(ccd_pt_t *pt, const char *fn) 254 | { 255 | FILE *fout; 256 | 257 | fout = fopen(fn, "a"); 258 | if (fout == NULL) 259 | return; 260 | 261 | ccdPtDumpSVT2(pt, fout); 262 | 263 | fclose(fout); 264 | } 265 | 266 | void ccdPtDumpSVT2(ccd_pt_t *pt, FILE *fout) 267 | { 268 | ccd_pt_vertex_t *v, *a, *b, *c; 269 | ccd_pt_edge_t *e; 270 | ccd_pt_face_t *f; 271 | size_t i; 272 | 273 | fprintf(fout, "-----\n"); 274 | 275 | fprintf(fout, "Points:\n"); 276 | i = 0; 277 | ccdListForEachEntry(&pt->vertices, v, ccd_pt_vertex_t, list){ 278 | v->id = i++; 279 | fprintf(fout, "%lf %lf %lf\n", 280 | ccdVec3X(&v->v.v), ccdVec3Y(&v->v.v), ccdVec3Z(&v->v.v)); 281 | } 282 | 283 | fprintf(fout, "Edges:\n"); 284 | ccdListForEachEntry(&pt->edges, e, ccd_pt_edge_t, list){ 285 | fprintf(fout, "%d %d\n", e->vertex[0]->id, e->vertex[1]->id); 286 | } 287 | 288 | fprintf(fout, "Faces:\n"); 289 | ccdListForEachEntry(&pt->faces, f, ccd_pt_face_t, list){ 290 | a = f->edge[0]->vertex[0]; 291 | b = f->edge[0]->vertex[1]; 292 | c = f->edge[1]->vertex[0]; 293 | if (c == a || c == b){ 294 | c = f->edge[1]->vertex[1]; 295 | } 296 | fprintf(fout, "%d %d %d\n", a->id, b->id, c->id); 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_simplex.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_SIMPLEX_H__ 19 | #define __CCD_SIMPLEX_H__ 20 | 21 | #include "ccd/ccd_compiler.h" 22 | #include "ccd_support.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif /* __cplusplus */ 27 | 28 | struct _ccd_simplex_t { 29 | ccd_support_t ps[4]; 30 | int last; //!< index of last added point 31 | }; 32 | typedef struct _ccd_simplex_t ccd_simplex_t; 33 | 34 | 35 | _ccd_inline void ccdSimplexInit(ccd_simplex_t *s); 36 | _ccd_inline int ccdSimplexSize(const ccd_simplex_t *s); 37 | _ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s); 38 | _ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx); 39 | _ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx); 40 | 41 | _ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v); 42 | _ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a); 43 | _ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size); 44 | _ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2); 45 | 46 | 47 | /**** INLINES ****/ 48 | 49 | _ccd_inline void ccdSimplexInit(ccd_simplex_t *s) 50 | { 51 | s->last = -1; 52 | } 53 | 54 | _ccd_inline int ccdSimplexSize(const ccd_simplex_t *s) 55 | { 56 | return s->last + 1; 57 | } 58 | 59 | _ccd_inline const ccd_support_t *ccdSimplexLast(const ccd_simplex_t *s) 60 | { 61 | return ccdSimplexPoint(s, s->last); 62 | } 63 | 64 | _ccd_inline const ccd_support_t *ccdSimplexPoint(const ccd_simplex_t *s, int idx) 65 | { 66 | // here is no check on boundaries 67 | return &s->ps[idx]; 68 | } 69 | _ccd_inline ccd_support_t *ccdSimplexPointW(ccd_simplex_t *s, int idx) 70 | { 71 | return &s->ps[idx]; 72 | } 73 | 74 | _ccd_inline void ccdSimplexAdd(ccd_simplex_t *s, const ccd_support_t *v) 75 | { 76 | // here is no check on boundaries in sake of speed 77 | ++s->last; 78 | ccdSupportCopy(s->ps + s->last, v); 79 | } 80 | 81 | _ccd_inline void ccdSimplexSet(ccd_simplex_t *s, size_t pos, const ccd_support_t *a) 82 | { 83 | ccdSupportCopy(s->ps + pos, a); 84 | } 85 | 86 | _ccd_inline void ccdSimplexSetSize(ccd_simplex_t *s, int size) 87 | { 88 | s->last = size - 1; 89 | } 90 | 91 | _ccd_inline void ccdSimplexSwap(ccd_simplex_t *s, size_t pos1, size_t pos2) 92 | { 93 | ccd_support_t supp; 94 | 95 | ccdSupportCopy(&supp, &s->ps[pos1]); 96 | ccdSupportCopy(&s->ps[pos1], &s->ps[pos2]); 97 | ccdSupportCopy(&s->ps[pos2], &supp); 98 | } 99 | 100 | #ifdef __cplusplus 101 | } /* extern "C" */ 102 | #endif /* __cplusplus */ 103 | 104 | #endif /* __CCD_SIMPLEX_H__ */ 105 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_support.c: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #include "ccd_support.h" 19 | 20 | void __ccdSupport(const void *obj1, const void *obj2, 21 | const ccd_vec3_t *_dir, const ccd_t *ccd, 22 | ccd_support_t *supp) 23 | { 24 | ccd_vec3_t dir; 25 | 26 | ccdVec3Copy(&dir, _dir); 27 | 28 | ccd->support1(obj1, &dir, &supp->v1); 29 | 30 | ccdVec3Scale(&dir, -CCD_ONE); 31 | ccd->support2(obj2, &dir, &supp->v2); 32 | 33 | ccdVec3Sub2(&supp->v, &supp->v1, &supp->v2); 34 | } 35 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_support.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #ifndef __CCD_SUPPORT_H__ 19 | #define __CCD_SUPPORT_H__ 20 | 21 | #include "ccd/ccd.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | struct _ccd_support_t { 28 | ccd_vec3_t v; //!< Support point in minkowski sum 29 | ccd_vec3_t v1; //!< Support point in obj1 30 | ccd_vec3_t v2; //!< Support point in obj2 31 | }; 32 | typedef struct _ccd_support_t ccd_support_t; 33 | 34 | _ccd_inline void ccdSupportCopy(ccd_support_t *, const ccd_support_t *s); 35 | 36 | /** 37 | * Computes support point of obj1 and obj2 in direction dir. 38 | * Support point is returned via supp. 39 | */ 40 | CCD_EXPORT void __ccdSupport(const void *obj1, const void *obj2, 41 | const ccd_vec3_t *dir, const ccd_t *ccd, 42 | ccd_support_t *supp); 43 | 44 | 45 | /**** INLINES ****/ 46 | _ccd_inline void ccdSupportCopy(ccd_support_t *d, const ccd_support_t *s) 47 | { 48 | *d = *s; 49 | } 50 | 51 | #ifdef __cplusplus 52 | } /* extern "C" */ 53 | #endif /* __cplusplus */ 54 | 55 | #endif /* __CCD_SUPPORT_H__ */ 56 | -------------------------------------------------------------------------------- /third_party/include/gs/external/ccd/src/ccd_vec3.c: -------------------------------------------------------------------------------- 1 | /*** 2 | * libccd 3 | * --------------------------------- 4 | * Copyright (c)2010 Daniel Fiser 5 | * 6 | * 7 | * This file is part of libccd. 8 | * 9 | * Distributed under the OSI-approved BSD License (the "License"); 10 | * see accompanying file BDS-LICENSE for details or see 11 | * . 12 | * 13 | * This software is distributed WITHOUT ANY WARRANTY; without even the 14 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * See the License for more information. 16 | */ 17 | 18 | #include 19 | #include "ccd/ccd_vec3.h" 20 | #include "ccd_dbg.h" 21 | 22 | static CCD_VEC3(__ccd_vec3_origin, CCD_ZERO, CCD_ZERO, CCD_ZERO); 23 | ccd_vec3_t *ccd_vec3_origin = &__ccd_vec3_origin; 24 | 25 | static ccd_vec3_t points_on_sphere[] = { 26 | CCD_VEC3_STATIC(CCD_REAL( 0.000000), CCD_REAL(-0.000000), CCD_REAL(-1.000000)), 27 | CCD_VEC3_STATIC(CCD_REAL( 0.723608), CCD_REAL(-0.525725), CCD_REAL(-0.447219)), 28 | CCD_VEC3_STATIC(CCD_REAL(-0.276388), CCD_REAL(-0.850649), CCD_REAL(-0.447219)), 29 | CCD_VEC3_STATIC(CCD_REAL(-0.894426), CCD_REAL(-0.000000), CCD_REAL(-0.447216)), 30 | CCD_VEC3_STATIC(CCD_REAL(-0.276388), CCD_REAL( 0.850649), CCD_REAL(-0.447220)), 31 | CCD_VEC3_STATIC(CCD_REAL( 0.723608), CCD_REAL( 0.525725), CCD_REAL(-0.447219)), 32 | CCD_VEC3_STATIC(CCD_REAL( 0.276388), CCD_REAL(-0.850649), CCD_REAL( 0.447220)), 33 | CCD_VEC3_STATIC(CCD_REAL(-0.723608), CCD_REAL(-0.525725), CCD_REAL( 0.447219)), 34 | CCD_VEC3_STATIC(CCD_REAL(-0.723608), CCD_REAL( 0.525725), CCD_REAL( 0.447219)), 35 | CCD_VEC3_STATIC(CCD_REAL( 0.276388), CCD_REAL( 0.850649), CCD_REAL( 0.447219)), 36 | CCD_VEC3_STATIC(CCD_REAL( 0.894426), CCD_REAL( 0.000000), CCD_REAL( 0.447216)), 37 | CCD_VEC3_STATIC(CCD_REAL(-0.000000), CCD_REAL( 0.000000), CCD_REAL( 1.000000)), 38 | CCD_VEC3_STATIC(CCD_REAL( 0.425323), CCD_REAL(-0.309011), CCD_REAL(-0.850654)), 39 | CCD_VEC3_STATIC(CCD_REAL(-0.162456), CCD_REAL(-0.499995), CCD_REAL(-0.850654)), 40 | CCD_VEC3_STATIC(CCD_REAL( 0.262869), CCD_REAL(-0.809012), CCD_REAL(-0.525738)), 41 | CCD_VEC3_STATIC(CCD_REAL( 0.425323), CCD_REAL( 0.309011), CCD_REAL(-0.850654)), 42 | CCD_VEC3_STATIC(CCD_REAL( 0.850648), CCD_REAL(-0.000000), CCD_REAL(-0.525736)), 43 | CCD_VEC3_STATIC(CCD_REAL(-0.525730), CCD_REAL(-0.000000), CCD_REAL(-0.850652)), 44 | CCD_VEC3_STATIC(CCD_REAL(-0.688190), CCD_REAL(-0.499997), CCD_REAL(-0.525736)), 45 | CCD_VEC3_STATIC(CCD_REAL(-0.162456), CCD_REAL( 0.499995), CCD_REAL(-0.850654)), 46 | CCD_VEC3_STATIC(CCD_REAL(-0.688190), CCD_REAL( 0.499997), CCD_REAL(-0.525736)), 47 | CCD_VEC3_STATIC(CCD_REAL( 0.262869), CCD_REAL( 0.809012), CCD_REAL(-0.525738)), 48 | CCD_VEC3_STATIC(CCD_REAL( 0.951058), CCD_REAL( 0.309013), CCD_REAL( 0.000000)), 49 | CCD_VEC3_STATIC(CCD_REAL( 0.951058), CCD_REAL(-0.309013), CCD_REAL( 0.000000)), 50 | CCD_VEC3_STATIC(CCD_REAL( 0.587786), CCD_REAL(-0.809017), CCD_REAL( 0.000000)), 51 | CCD_VEC3_STATIC(CCD_REAL( 0.000000), CCD_REAL(-1.000000), CCD_REAL( 0.000000)), 52 | CCD_VEC3_STATIC(CCD_REAL(-0.587786), CCD_REAL(-0.809017), CCD_REAL( 0.000000)), 53 | CCD_VEC3_STATIC(CCD_REAL(-0.951058), CCD_REAL(-0.309013), CCD_REAL(-0.000000)), 54 | CCD_VEC3_STATIC(CCD_REAL(-0.951058), CCD_REAL( 0.309013), CCD_REAL(-0.000000)), 55 | CCD_VEC3_STATIC(CCD_REAL(-0.587786), CCD_REAL( 0.809017), CCD_REAL(-0.000000)), 56 | CCD_VEC3_STATIC(CCD_REAL(-0.000000), CCD_REAL( 1.000000), CCD_REAL(-0.000000)), 57 | CCD_VEC3_STATIC(CCD_REAL( 0.587786), CCD_REAL( 0.809017), CCD_REAL(-0.000000)), 58 | CCD_VEC3_STATIC(CCD_REAL( 0.688190), CCD_REAL(-0.499997), CCD_REAL( 0.525736)), 59 | CCD_VEC3_STATIC(CCD_REAL(-0.262869), CCD_REAL(-0.809012), CCD_REAL( 0.525738)), 60 | CCD_VEC3_STATIC(CCD_REAL(-0.850648), CCD_REAL( 0.000000), CCD_REAL( 0.525736)), 61 | CCD_VEC3_STATIC(CCD_REAL(-0.262869), CCD_REAL( 0.809012), CCD_REAL( 0.525738)), 62 | CCD_VEC3_STATIC(CCD_REAL( 0.688190), CCD_REAL( 0.499997), CCD_REAL( 0.525736)), 63 | CCD_VEC3_STATIC(CCD_REAL( 0.525730), CCD_REAL( 0.000000), CCD_REAL( 0.850652)), 64 | CCD_VEC3_STATIC(CCD_REAL( 0.162456), CCD_REAL(-0.499995), CCD_REAL( 0.850654)), 65 | CCD_VEC3_STATIC(CCD_REAL(-0.425323), CCD_REAL(-0.309011), CCD_REAL( 0.850654)), 66 | CCD_VEC3_STATIC(CCD_REAL(-0.425323), CCD_REAL( 0.309011), CCD_REAL( 0.850654)), 67 | CCD_VEC3_STATIC(CCD_REAL( 0.162456), CCD_REAL( 0.499995), CCD_REAL( 0.850654)) 68 | }; 69 | ccd_vec3_t *ccd_points_on_sphere = points_on_sphere; 70 | size_t ccd_points_on_sphere_len = sizeof(points_on_sphere) / sizeof(ccd_vec3_t); 71 | 72 | 73 | _ccd_inline ccd_real_t __ccdVec3PointSegmentDist2(const ccd_vec3_t *P, 74 | const ccd_vec3_t *x0, 75 | const ccd_vec3_t *b, 76 | ccd_vec3_t *witness) 77 | { 78 | // The computation comes from solving equation of segment: 79 | // S(t) = x0 + t.d 80 | // where - x0 is initial point of segment 81 | // - d is direction of segment from x0 (|d| > 0) 82 | // - t belongs to <0, 1> interval 83 | // 84 | // Than, distance from a segment to some point P can be expressed: 85 | // D(t) = |x0 + t.d - P|^2 86 | // which is distance from any point on segment. Minimization 87 | // of this function brings distance from P to segment. 88 | // Minimization of D(t) leads to simple quadratic equation that's 89 | // solving is straightforward. 90 | // 91 | // Bonus of this method is witness point for free. 92 | 93 | ccd_real_t dist, t; 94 | ccd_vec3_t d, a; 95 | 96 | // direction of segment 97 | ccdVec3Sub2(&d, b, x0); 98 | 99 | // precompute vector from P to x0 100 | ccdVec3Sub2(&a, x0, P); 101 | 102 | t = -CCD_REAL(1.) * ccdVec3Dot(&a, &d); 103 | t /= ccdVec3Len2(&d); 104 | 105 | if (t < CCD_ZERO || ccdIsZero(t)){ 106 | dist = ccdVec3Dist2(x0, P); 107 | if (witness) 108 | ccdVec3Copy(witness, x0); 109 | }else if (t > CCD_ONE || ccdEq(t, CCD_ONE)){ 110 | dist = ccdVec3Dist2(b, P); 111 | if (witness) 112 | ccdVec3Copy(witness, b); 113 | }else{ 114 | if (witness){ 115 | ccdVec3Copy(witness, &d); 116 | ccdVec3Scale(witness, t); 117 | ccdVec3Add(witness, x0); 118 | dist = ccdVec3Dist2(witness, P); 119 | }else{ 120 | // recycling variables 121 | ccdVec3Scale(&d, t); 122 | ccdVec3Add(&d, &a); 123 | dist = ccdVec3Len2(&d); 124 | } 125 | } 126 | 127 | return dist; 128 | } 129 | 130 | ccd_real_t ccdVec3PointSegmentDist2(const ccd_vec3_t *P, 131 | const ccd_vec3_t *x0, const ccd_vec3_t *b, 132 | ccd_vec3_t *witness) 133 | { 134 | return __ccdVec3PointSegmentDist2(P, x0, b, witness); 135 | } 136 | 137 | ccd_real_t ccdVec3PointTriDist2(const ccd_vec3_t *P, 138 | const ccd_vec3_t *x0, const ccd_vec3_t *B, 139 | const ccd_vec3_t *C, 140 | ccd_vec3_t *witness) 141 | { 142 | // Computation comes from analytic expression for triangle (x0, B, C) 143 | // T(s, t) = x0 + s.d1 + t.d2, where d1 = B - x0 and d2 = C - x0 and 144 | // Then equation for distance is: 145 | // D(s, t) = | T(s, t) - P |^2 146 | // This leads to minimization of quadratic function of two variables. 147 | // The solution from is taken only if s is between 0 and 1, t is 148 | // between 0 and 1 and t + s < 1, otherwise distance from segment is 149 | // computed. 150 | 151 | ccd_vec3_t d1, d2, a; 152 | ccd_real_t u, v, w, p, q, r, d; 153 | ccd_real_t s, t, dist, dist2; 154 | ccd_vec3_t witness2; 155 | 156 | ccdVec3Sub2(&d1, B, x0); 157 | ccdVec3Sub2(&d2, C, x0); 158 | ccdVec3Sub2(&a, x0, P); 159 | 160 | u = ccdVec3Dot(&a, &a); 161 | v = ccdVec3Dot(&d1, &d1); 162 | w = ccdVec3Dot(&d2, &d2); 163 | p = ccdVec3Dot(&a, &d1); 164 | q = ccdVec3Dot(&a, &d2); 165 | r = ccdVec3Dot(&d1, &d2); 166 | 167 | d = w * v - r * r; 168 | if (ccdIsZero(d)){ 169 | // To avoid division by zero for zero (or near zero) area triangles 170 | s = t = -1.; 171 | }else{ 172 | s = (q * r - w * p) / d; 173 | t = (-s * r - q) / w; 174 | } 175 | 176 | if ((ccdIsZero(s) || s > CCD_ZERO) 177 | && (ccdEq(s, CCD_ONE) || s < CCD_ONE) 178 | && (ccdIsZero(t) || t > CCD_ZERO) 179 | && (ccdEq(t, CCD_ONE) || t < CCD_ONE) 180 | && (ccdEq(t + s, CCD_ONE) || t + s < CCD_ONE)){ 181 | 182 | if (witness){ 183 | ccdVec3Scale(&d1, s); 184 | ccdVec3Scale(&d2, t); 185 | ccdVec3Copy(witness, x0); 186 | ccdVec3Add(witness, &d1); 187 | ccdVec3Add(witness, &d2); 188 | 189 | dist = ccdVec3Dist2(witness, P); 190 | }else{ 191 | dist = s * s * v; 192 | dist += t * t * w; 193 | dist += CCD_REAL(2.) * s * t * r; 194 | dist += CCD_REAL(2.) * s * p; 195 | dist += CCD_REAL(2.) * t * q; 196 | dist += u; 197 | } 198 | }else{ 199 | dist = __ccdVec3PointSegmentDist2(P, x0, B, witness); 200 | 201 | dist2 = __ccdVec3PointSegmentDist2(P, x0, C, &witness2); 202 | if (dist2 < dist){ 203 | dist = dist2; 204 | if (witness) 205 | ccdVec3Copy(witness, &witness2); 206 | } 207 | 208 | dist2 = __ccdVec3PointSegmentDist2(P, B, C, &witness2); 209 | if (dist2 < dist){ 210 | dist = dist2; 211 | if (witness) 212 | ccdVec3Copy(witness, &witness2); 213 | } 214 | } 215 | 216 | return dist; 217 | } 218 | -------------------------------------------------------------------------------- /third_party/include/gs/external/cgltf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Johannes Kuhlmann 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /third_party/include/gs/external/dirent/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 1998-2019 Toni Ronkko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /third_party/include/gs/external/dirent/README.md: -------------------------------------------------------------------------------- 1 | # Dirent 2 | 3 | Dirent is a C/C++ programming interface that allows programmers to retrieve 4 | information about files and directories under Linux/UNIX. This project 5 | provides Linux compatible Dirent interface for Microsoft Windows. 6 | 7 | 8 | # How to Enable UTF-8 Support 9 | 10 | By default, Dirent functions expect that directory names are represented in 11 | the currently selected windows codepage. Moverover, Dirent functions return 12 | file names in the currently selected codepage. If you wish to use UTF-8 file 13 | names instead, then set the program's locale to ".utf8" or similar. For 14 | example, you C main program might look like 15 | 16 | ``` 17 | #include 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | setlocale(LC_ALL, "LC_CTYPE=.utf8"); 22 | 23 | /*...*/ 24 | } 25 | ``` 26 | 27 | For more information on UTF-8 support, please see setlocale in Visual Studio 28 | [C runtime library reference](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#utf-8-support). 29 | 30 | 31 | # Installation 32 | 33 | Download the latest Dirent installation package from 34 | [GitHub](https://github.com/tronkko/dirent/releases) and 35 | unpack the installation file with 7-zip, for example. The installation 36 | package contains ``include/dirent.h`` file as well as a few example and test 37 | programs. 38 | 39 | 40 | ## Installing Dirent for All Programs 41 | 42 | To make dirent.h available for all C/C++ programs, simply copy the 43 | ``include/dirent.h`` file to the system include directory. System include 44 | directory contains header files such as ``assert.h`` and ``windows.h``. In 45 | Visual Studio 2008, for example, the system include may be found at 46 | ``C:\Program Files\Microsoft Visual Studio 9.0\VC\include``. 47 | 48 | Everything you need is included in the single ``dirent.h`` file, and you can 49 | start using Dirent immediately -- there is no need to add files to your 50 | Visual Studio project. 51 | 52 | 53 | ## Embedding Dirent into Your Own Project 54 | 55 | If you wish to distribute ``dirent.h`` alongside with your own source code, 56 | then copy ``include/dirent.h`` file to a new sub-directory within your project 57 | and add that directory to include path on Windows while omitting the directory 58 | under Linux/UNIX. This allows your project to be compiled against native 59 | ``dirent.h`` on Linux/UNIX while substituting the functionality on Microsoft 60 | Windows. 61 | 62 | 63 | ## Examples 64 | 65 | The installation package contains six example programs: 66 | 67 | Program | Purpose 68 | -------- | ----------------------------------------------------------------- 69 | ls | List files in a directory, e.g. ls "c:\Program Files" 70 | find | Find files in subdirectories, e.g. find "c:\Program Files\CMake" 71 | updatedb | Build database of files in a drive, e.g. updatedb c:\ 72 | locate | Locate a file from database, e.g. locate notepad 73 | scandir | Demonstrate scandir() function 74 | cat | Print a text file to screen 75 | 76 | Please install [CMake](https://cmake.org/) to build example and test programs. 77 | Then, open command prompt and create a temporary directory ``c:\temp\dirent`` 78 | for the build files as 79 | 80 | ``` 81 | c:\ 82 | mkdir temp 83 | mkdir temp\dirent 84 | cd temp\dirent 85 | ``` 86 | 87 | Generate build files as 88 | 89 | ``` 90 | cmake d:\dirent 91 | ``` 92 | 93 | where ``d:\dirent`` is the root directory of the Dirent package (containing 94 | this README.md file). If wish to omit example programs from the 95 | build, then append the option ``-DDIRENT_BUILD_TESTS=OFF`` to the CMake 96 | command line. 97 | 98 | Once CMake is finished, open Visual Studio, load the generated ``dirent.sln`` 99 | file from the build directory and build the whole solution. Once the build 100 | completes, run the example programs ls, find, updatedb and locate from the 101 | command prompt as 102 | 103 | ``` 104 | cd Debug 105 | ls . 106 | find . 107 | updatedb c:\ 108 | locate cmd.exe 109 | ``` 110 | 111 | Visual Studio project also contains a solution named ``check`` which can be 112 | used to verify that Dirent works as expected. Just build the solution from 113 | Visual Studio to run the test programs. 114 | 115 | 116 | # Contributing 117 | 118 | We love to receive contributions from you. See the 119 | [CONTRIBUTING](CONTRIBUTING.md) file for details. 120 | 121 | 122 | # Copying 123 | 124 | Dirent may be freely distributed under the MIT license. See the 125 | [LICENSE](LICENSE) file for details. 126 | 127 | 128 | # Alternatives to Dirent 129 | 130 | I ported Dirent to Microsoft Windows in 1998 when only a few alternatives 131 | were available. However, the situation has changed since then and nowadays 132 | both [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org) 133 | allow you to compile a great number of UNIX programs in Microsoft Windows. 134 | They both provide a full dirent API as well as many other UNIX APIs. MingW 135 | can even be used for commercial applications! 136 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/cocoa_platform.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 | #include 28 | #include 29 | 30 | #include 31 | 32 | // NOTE: All of NSGL was deprecated in the 10.14 SDK 33 | // This disables the pointless warnings for every symbol we use 34 | #define GL_SILENCE_DEPRECATION 35 | 36 | #if defined(__OBJC__) 37 | #import 38 | #else 39 | typedef void* id; 40 | #endif 41 | 42 | // NOTE: Many Cocoa enum values have been renamed and we need to build across 43 | // SDK versions where one is unavailable or the other deprecated 44 | // We use the newer names in code and these macros to handle compatibility 45 | #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 46 | #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat 47 | #define NSEventMaskAny NSAnyEventMask 48 | #define NSEventMaskKeyUp NSKeyUpMask 49 | #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask 50 | #define NSEventModifierFlagCommand NSCommandKeyMask 51 | #define NSEventModifierFlagControl NSControlKeyMask 52 | #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask 53 | #define NSEventModifierFlagOption NSAlternateKeyMask 54 | #define NSEventModifierFlagShift NSShiftKeyMask 55 | #define NSEventTypeApplicationDefined NSApplicationDefined 56 | #define NSWindowStyleMaskBorderless NSBorderlessWindowMask 57 | #define NSWindowStyleMaskClosable NSClosableWindowMask 58 | #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask 59 | #define NSWindowStyleMaskResizable NSResizableWindowMask 60 | #define NSWindowStyleMaskTitled NSTitledWindowMask 61 | #endif 62 | 63 | typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; 64 | typedef VkFlags VkMetalSurfaceCreateFlagsEXT; 65 | 66 | typedef struct VkMacOSSurfaceCreateInfoMVK 67 | { 68 | VkStructureType sType; 69 | const void* pNext; 70 | VkMacOSSurfaceCreateFlagsMVK flags; 71 | const void* pView; 72 | } VkMacOSSurfaceCreateInfoMVK; 73 | 74 | typedef struct VkMetalSurfaceCreateInfoEXT 75 | { 76 | VkStructureType sType; 77 | const void* pNext; 78 | VkMetalSurfaceCreateFlagsEXT flags; 79 | const void* pLayer; 80 | } VkMetalSurfaceCreateInfoEXT; 81 | 82 | typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); 83 | typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); 84 | 85 | #include "posix_thread.h" 86 | #include "cocoa_joystick.h" 87 | #include "nsgl_context.h" 88 | #include "egl_context.h" 89 | #include "osmesa_context.h" 90 | 91 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 92 | #define _glfw_dlclose(handle) dlclose(handle) 93 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 94 | 95 | #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view) 96 | #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY 97 | 98 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns 99 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns 100 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns 101 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns 102 | #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns 103 | 104 | // HIToolbox.framework pointer typedefs 105 | #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData 106 | typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); 107 | #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource 108 | typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); 109 | #define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty 110 | typedef UInt8 (*PFN_LMGetKbdType)(void); 111 | #define LMGetKbdType _glfw.ns.tis.GetKbdType 112 | 113 | 114 | // Cocoa-specific per-window data 115 | // 116 | typedef struct _GLFWwindowNS 117 | { 118 | id object; 119 | id delegate; 120 | id view; 121 | id layer; 122 | 123 | GLFWbool maximized; 124 | GLFWbool retina; 125 | 126 | // Cached window properties to filter out duplicate events 127 | int width, height; 128 | int fbWidth, fbHeight; 129 | float xscale, yscale; 130 | 131 | // The total sum of the distances the cursor has been warped 132 | // since the last cursor motion event was processed 133 | // This is kept to counteract Cocoa doing the same internally 134 | double cursorWarpDeltaX, cursorWarpDeltaY; 135 | 136 | } _GLFWwindowNS; 137 | 138 | // Cocoa-specific global data 139 | // 140 | typedef struct _GLFWlibraryNS 141 | { 142 | CGEventSourceRef eventSource; 143 | id delegate; 144 | GLFWbool cursorHidden; 145 | TISInputSourceRef inputSource; 146 | IOHIDManagerRef hidManager; 147 | id unicodeData; 148 | id helper; 149 | id keyUpMonitor; 150 | id nibObjects; 151 | 152 | char keynames[GLFW_KEY_LAST + 1][17]; 153 | short int keycodes[256]; 154 | short int scancodes[GLFW_KEY_LAST + 1]; 155 | char* clipboardString; 156 | CGPoint cascadePoint; 157 | // Where to place the cursor when re-enabled 158 | double restoreCursorPosX, restoreCursorPosY; 159 | // The window whose disabled cursor mode is active 160 | _GLFWwindow* disabledCursorWindow; 161 | 162 | struct { 163 | CFBundleRef bundle; 164 | PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource; 165 | PFN_TISGetInputSourceProperty GetInputSourceProperty; 166 | PFN_LMGetKbdType GetKbdType; 167 | CFStringRef kPropertyUnicodeKeyLayoutData; 168 | } tis; 169 | 170 | } _GLFWlibraryNS; 171 | 172 | // Cocoa-specific per-monitor data 173 | // 174 | typedef struct _GLFWmonitorNS 175 | { 176 | CGDirectDisplayID displayID; 177 | CGDisplayModeRef previousMode; 178 | uint32_t unitNumber; 179 | id screen; 180 | double fallbackRefreshRate; 181 | 182 | } _GLFWmonitorNS; 183 | 184 | // Cocoa-specific per-cursor data 185 | // 186 | typedef struct _GLFWcursorNS 187 | { 188 | id object; 189 | 190 | } _GLFWcursorNS; 191 | 192 | // Cocoa-specific global timer data 193 | // 194 | typedef struct _GLFWtimerNS 195 | { 196 | uint64_t frequency; 197 | 198 | } _GLFWtimerNS; 199 | 200 | 201 | void _glfwInitTimerNS(void); 202 | 203 | void _glfwPollMonitorsNS(void); 204 | void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); 205 | void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); 206 | 207 | float _glfwTransformYNS(float y); 208 | 209 | void* _glfwLoadLocalVulkanLoaderNS(void); 210 | 211 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/egl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 EGL - 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 | #if defined(_GLFW_USE_EGLPLATFORM_H) 29 | #include 30 | #elif defined(_GLFW_WIN32) 31 | #define EGLAPIENTRY __stdcall 32 | typedef HDC EGLNativeDisplayType; 33 | typedef HWND EGLNativeWindowType; 34 | #elif defined(_GLFW_COCOA) 35 | #define EGLAPIENTRY 36 | typedef void* EGLNativeDisplayType; 37 | typedef id EGLNativeWindowType; 38 | #elif defined(_GLFW_X11) 39 | #define EGLAPIENTRY 40 | typedef Display* EGLNativeDisplayType; 41 | typedef Window EGLNativeWindowType; 42 | #elif defined(_GLFW_WAYLAND) 43 | #define EGLAPIENTRY 44 | typedef struct wl_display* EGLNativeDisplayType; 45 | typedef struct wl_egl_window* EGLNativeWindowType; 46 | #else 47 | #error "No supported EGL platform selected" 48 | #endif 49 | 50 | #define EGL_SUCCESS 0x3000 51 | #define EGL_NOT_INITIALIZED 0x3001 52 | #define EGL_BAD_ACCESS 0x3002 53 | #define EGL_BAD_ALLOC 0x3003 54 | #define EGL_BAD_ATTRIBUTE 0x3004 55 | #define EGL_BAD_CONFIG 0x3005 56 | #define EGL_BAD_CONTEXT 0x3006 57 | #define EGL_BAD_CURRENT_SURFACE 0x3007 58 | #define EGL_BAD_DISPLAY 0x3008 59 | #define EGL_BAD_MATCH 0x3009 60 | #define EGL_BAD_NATIVE_PIXMAP 0x300a 61 | #define EGL_BAD_NATIVE_WINDOW 0x300b 62 | #define EGL_BAD_PARAMETER 0x300c 63 | #define EGL_BAD_SURFACE 0x300d 64 | #define EGL_CONTEXT_LOST 0x300e 65 | #define EGL_COLOR_BUFFER_TYPE 0x303f 66 | #define EGL_RGB_BUFFER 0x308e 67 | #define EGL_SURFACE_TYPE 0x3033 68 | #define EGL_WINDOW_BIT 0x0004 69 | #define EGL_RENDERABLE_TYPE 0x3040 70 | #define EGL_OPENGL_ES_BIT 0x0001 71 | #define EGL_OPENGL_ES2_BIT 0x0004 72 | #define EGL_OPENGL_BIT 0x0008 73 | #define EGL_ALPHA_SIZE 0x3021 74 | #define EGL_BLUE_SIZE 0x3022 75 | #define EGL_GREEN_SIZE 0x3023 76 | #define EGL_RED_SIZE 0x3024 77 | #define EGL_DEPTH_SIZE 0x3025 78 | #define EGL_STENCIL_SIZE 0x3026 79 | #define EGL_SAMPLES 0x3031 80 | #define EGL_OPENGL_ES_API 0x30a0 81 | #define EGL_OPENGL_API 0x30a2 82 | #define EGL_NONE 0x3038 83 | #define EGL_EXTENSIONS 0x3055 84 | #define EGL_CONTEXT_CLIENT_VERSION 0x3098 85 | #define EGL_NATIVE_VISUAL_ID 0x302e 86 | #define EGL_NO_SURFACE ((EGLSurface) 0) 87 | #define EGL_NO_DISPLAY ((EGLDisplay) 0) 88 | #define EGL_NO_CONTEXT ((EGLContext) 0) 89 | #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) 90 | 91 | #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 92 | #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 93 | #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 94 | #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 95 | #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd 96 | #define EGL_NO_RESET_NOTIFICATION_KHR 0x31be 97 | #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf 98 | #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 99 | #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 100 | #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb 101 | #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd 102 | #define EGL_CONTEXT_FLAGS_KHR 0x30fc 103 | #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3 104 | #define EGL_GL_COLORSPACE_KHR 0x309d 105 | #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 106 | #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 107 | #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 108 | #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 109 | 110 | typedef int EGLint; 111 | typedef unsigned int EGLBoolean; 112 | typedef unsigned int EGLenum; 113 | typedef void* EGLConfig; 114 | typedef void* EGLContext; 115 | typedef void* EGLDisplay; 116 | typedef void* EGLSurface; 117 | 118 | // EGL function pointer typedefs 119 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); 120 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); 121 | typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); 122 | typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); 123 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); 124 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); 125 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); 126 | typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); 127 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); 128 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); 129 | typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); 130 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); 131 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); 132 | typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); 133 | typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); 134 | typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); 135 | #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib 136 | #define eglGetConfigs _glfw.egl.GetConfigs 137 | #define eglGetDisplay _glfw.egl.GetDisplay 138 | #define eglGetError _glfw.egl.GetError 139 | #define eglInitialize _glfw.egl.Initialize 140 | #define eglTerminate _glfw.egl.Terminate 141 | #define eglBindAPI _glfw.egl.BindAPI 142 | #define eglCreateContext _glfw.egl.CreateContext 143 | #define eglDestroySurface _glfw.egl.DestroySurface 144 | #define eglDestroyContext _glfw.egl.DestroyContext 145 | #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface 146 | #define eglMakeCurrent _glfw.egl.MakeCurrent 147 | #define eglSwapBuffers _glfw.egl.SwapBuffers 148 | #define eglSwapInterval _glfw.egl.SwapInterval 149 | #define eglQueryString _glfw.egl.QueryString 150 | #define eglGetProcAddress _glfw.egl.GetProcAddress 151 | 152 | #define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl 153 | #define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl 154 | 155 | 156 | // EGL-specific per-context data 157 | // 158 | typedef struct _GLFWcontextEGL 159 | { 160 | EGLConfig config; 161 | EGLContext handle; 162 | EGLSurface surface; 163 | 164 | void* client; 165 | 166 | } _GLFWcontextEGL; 167 | 168 | // EGL-specific global data 169 | // 170 | typedef struct _GLFWlibraryEGL 171 | { 172 | EGLDisplay display; 173 | EGLint major, minor; 174 | GLFWbool prefix; 175 | 176 | GLFWbool KHR_create_context; 177 | GLFWbool KHR_create_context_no_error; 178 | GLFWbool KHR_gl_colorspace; 179 | GLFWbool KHR_get_all_proc_addresses; 180 | GLFWbool KHR_context_flush_control; 181 | 182 | void* handle; 183 | 184 | PFN_eglGetConfigAttrib GetConfigAttrib; 185 | PFN_eglGetConfigs GetConfigs; 186 | PFN_eglGetDisplay GetDisplay; 187 | PFN_eglGetError GetError; 188 | PFN_eglInitialize Initialize; 189 | PFN_eglTerminate Terminate; 190 | PFN_eglBindAPI BindAPI; 191 | PFN_eglCreateContext CreateContext; 192 | PFN_eglDestroySurface DestroySurface; 193 | PFN_eglDestroyContext DestroyContext; 194 | PFN_eglCreateWindowSurface CreateWindowSurface; 195 | PFN_eglMakeCurrent MakeCurrent; 196 | PFN_eglSwapBuffers SwapBuffers; 197 | PFN_eglSwapInterval SwapInterval; 198 | PFN_eglQueryString QueryString; 199 | PFN_eglGetProcAddress GetProcAddress; 200 | 201 | } _GLFWlibraryEGL; 202 | 203 | 204 | GLFWbool _glfwInitEGL(void); 205 | void _glfwTerminateEGL(void); 206 | GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, 207 | const _GLFWctxconfig* ctxconfig, 208 | const _GLFWfbconfig* fbconfig); 209 | #if defined(_GLFW_X11) 210 | GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, 211 | const _GLFWctxconfig* ctxconfig, 212 | const _GLFWfbconfig* fbconfig, 213 | Visual** visual, int* depth); 214 | #endif /*_GLFW_X11*/ 215 | 216 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/glfw_impl.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLFW_IMPL_H__ 2 | #define __GLFW_IMPL_H__ 3 | 4 | #include "glfw3.h" 5 | 6 | #ifdef GLFW_IMPL 7 | 8 | #if defined(_WIN32) 9 | #define _GLFW_WIN32 10 | #endif 11 | #if defined(__linux__) 12 | #if !defined(_GLFW_WAYLAND) // Required for Wayland windowing 13 | #define _GLFW_X11 14 | #endif 15 | #endif 16 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) 17 | #define _GLFW_X11 18 | #endif 19 | #if defined(__APPLE__) 20 | #define _GLFW_COCOA 21 | #define _GLFW_USE_MENUBAR // To create and populate the menu bar when the first window is created 22 | #define _GLFW_USE_RETINA // To have windows use the full resolution of Retina displays 23 | #endif 24 | #if defined(__TINYC__) 25 | #define _WIN32_WINNT_WINXP 0x0501 26 | #endif 27 | 28 | // NOTE: _GLFW_MIR experimental platform not supported at this moment 29 | 30 | #include "context.c" 31 | #include "init.c" 32 | #include "input.c" 33 | #include "monitor.c" 34 | #include "vulkan.c" 35 | #include "window.c" 36 | 37 | #if (defined _WIN32 | defined _WIN64) 38 | #include "win32_init.c" 39 | #include "win32_joystick.c" 40 | #include "win32_monitor.c" 41 | #include "win32_time.c" 42 | #include "win32_thread.c" 43 | #include "win32_window.c" 44 | #include "wgl_context.c" 45 | #include "egl_context.c" 46 | #include "osmesa_context.c" 47 | #endif 48 | 49 | #if (defined __linux__ || defined _linux || defined __linux) 50 | #if defined(_GLFW_WAYLAND) 51 | #include "wl_init.c" 52 | #include "wl_monitor.c" 53 | #include "wl_window.c" 54 | #include "wayland-pointer-constraints-unstable-v1-client-protocol.c" 55 | #include "wayland-relative-pointer-unstable-v1-client-protocol.c" 56 | #endif 57 | #if defined(_GLFW_X11) 58 | #include "x11_init.c" 59 | #include "x11_monitor.c" 60 | #include "x11_window.c" 61 | #include "glx_context.c" 62 | #endif 63 | 64 | #include "linux_joystick.c" 65 | #include "posix_thread.c" 66 | #include "posix_time.c" 67 | #include "xkb_unicode.c" 68 | #include "egl_context.c" 69 | #include "osmesa_context.c" 70 | #endif 71 | 72 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) 73 | #include "x11_init.c" 74 | #include "x11_monitor.c" 75 | #include "x11_window.c" 76 | #include "xkb_unicode.c" 77 | // TODO: Joystick implementation 78 | #include "null_joystick.c" 79 | #include "posix_time.c" 80 | #include "posix_thread.c" 81 | #include "glx_context.c" 82 | #include "egl_context.c" 83 | #include "osmesa_context.c" 84 | #endif 85 | 86 | #if defined(__APPLE__) 87 | #include "cocoa_init.m" 88 | #include "cocoa_joystick.m" 89 | #include "cocoa_monitor.m" 90 | #include "cocoa_window.m" 91 | #include "cocoa_time.c" 92 | #include "posix_thread.c" 93 | #include "nsgl_context.m" 94 | #include "egl_context.c" 95 | #include "osmesa_context.c" 96 | #endif 97 | 98 | #endif // GLFW_IMPL 99 | 100 | #endif // __GLFW_IMPL_H__ 101 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/glx_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 GLX - 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 GLX_VENDOR 1 29 | #define GLX_RGBA_BIT 0x00000001 30 | #define GLX_WINDOW_BIT 0x00000001 31 | #define GLX_DRAWABLE_TYPE 0x8010 32 | #define GLX_RENDER_TYPE 0x8011 33 | #define GLX_RGBA_TYPE 0x8014 34 | #define GLX_DOUBLEBUFFER 5 35 | #define GLX_STEREO 6 36 | #define GLX_AUX_BUFFERS 7 37 | #define GLX_RED_SIZE 8 38 | #define GLX_GREEN_SIZE 9 39 | #define GLX_BLUE_SIZE 10 40 | #define GLX_ALPHA_SIZE 11 41 | #define GLX_DEPTH_SIZE 12 42 | #define GLX_STENCIL_SIZE 13 43 | #define GLX_ACCUM_RED_SIZE 14 44 | #define GLX_ACCUM_GREEN_SIZE 15 45 | #define GLX_ACCUM_BLUE_SIZE 16 46 | #define GLX_ACCUM_ALPHA_SIZE 17 47 | #define GLX_SAMPLES 0x186a1 48 | #define GLX_VISUAL_ID 0x800b 49 | 50 | #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 51 | #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 52 | #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 53 | #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 54 | #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 55 | #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 56 | #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 57 | #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 58 | #define GLX_CONTEXT_FLAGS_ARB 0x2094 59 | #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 60 | #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 61 | #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 62 | #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 63 | #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 64 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 65 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 66 | #define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 67 | #define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 68 | 69 | typedef XID GLXWindow; 70 | typedef XID GLXDrawable; 71 | typedef struct __GLXFBConfig* GLXFBConfig; 72 | typedef struct __GLXcontext* GLXContext; 73 | typedef void (*__GLXextproc)(void); 74 | 75 | typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*); 76 | typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int); 77 | typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*); 78 | typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*); 79 | typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext); 80 | typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext); 81 | typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable); 82 | typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int); 83 | typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*); 84 | typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool); 85 | typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName); 86 | typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int); 87 | typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig); 88 | typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*); 89 | typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); 90 | 91 | typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); 92 | typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int); 93 | typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*); 94 | 95 | // libGL.so function pointer typedefs 96 | #define glXGetFBConfigs _glfw.glx.GetFBConfigs 97 | #define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib 98 | #define glXGetClientString _glfw.glx.GetClientString 99 | #define glXQueryExtension _glfw.glx.QueryExtension 100 | #define glXQueryVersion _glfw.glx.QueryVersion 101 | #define glXDestroyContext _glfw.glx.DestroyContext 102 | #define glXMakeCurrent _glfw.glx.MakeCurrent 103 | #define glXSwapBuffers _glfw.glx.SwapBuffers 104 | #define glXQueryExtensionsString _glfw.glx.QueryExtensionsString 105 | #define glXCreateNewContext _glfw.glx.CreateNewContext 106 | #define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig 107 | #define glXCreateWindow _glfw.glx.CreateWindow 108 | #define glXDestroyWindow _glfw.glx.DestroyWindow 109 | 110 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx 111 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx 112 | 113 | 114 | // GLX-specific per-context data 115 | // 116 | typedef struct _GLFWcontextGLX 117 | { 118 | GLXContext handle; 119 | GLXWindow window; 120 | 121 | } _GLFWcontextGLX; 122 | 123 | // GLX-specific global data 124 | // 125 | typedef struct _GLFWlibraryGLX 126 | { 127 | int major, minor; 128 | int eventBase; 129 | int errorBase; 130 | 131 | // dlopen handle for libGL.so.1 132 | void* handle; 133 | 134 | // GLX 1.3 functions 135 | PFNGLXGETFBCONFIGSPROC GetFBConfigs; 136 | PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib; 137 | PFNGLXGETCLIENTSTRINGPROC GetClientString; 138 | PFNGLXQUERYEXTENSIONPROC QueryExtension; 139 | PFNGLXQUERYVERSIONPROC QueryVersion; 140 | PFNGLXDESTROYCONTEXTPROC DestroyContext; 141 | PFNGLXMAKECURRENTPROC MakeCurrent; 142 | PFNGLXSWAPBUFFERSPROC SwapBuffers; 143 | PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString; 144 | PFNGLXCREATENEWCONTEXTPROC CreateNewContext; 145 | PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig; 146 | PFNGLXCREATEWINDOWPROC CreateWindow; 147 | PFNGLXDESTROYWINDOWPROC DestroyWindow; 148 | 149 | // GLX 1.4 and extension functions 150 | PFNGLXGETPROCADDRESSPROC GetProcAddress; 151 | PFNGLXGETPROCADDRESSPROC GetProcAddressARB; 152 | PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; 153 | PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; 154 | PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; 155 | PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 156 | GLFWbool SGI_swap_control; 157 | GLFWbool EXT_swap_control; 158 | GLFWbool MESA_swap_control; 159 | GLFWbool ARB_multisample; 160 | GLFWbool ARB_framebuffer_sRGB; 161 | GLFWbool EXT_framebuffer_sRGB; 162 | GLFWbool ARB_create_context; 163 | GLFWbool ARB_create_context_profile; 164 | GLFWbool ARB_create_context_robustness; 165 | GLFWbool EXT_create_context_es2_profile; 166 | GLFWbool ARB_create_context_no_error; 167 | GLFWbool ARB_context_flush_control; 168 | 169 | } _GLFWlibraryGLX; 170 | 171 | GLFWbool _glfwInitGLX(void); 172 | void _glfwTerminateGLX(void); 173 | GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, 174 | const _GLFWctxconfig* ctxconfig, 175 | const _GLFWfbconfig* fbconfig); 176 | void _glfwDestroyContextGLX(_GLFWwindow* window); 177 | GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, 178 | const _GLFWctxconfig* ctxconfig, 179 | const _GLFWfbconfig* fbconfig, 180 | Visual** visual, int* depth); 181 | 182 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/mappings.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2018 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 mappings.h.in, this file is used by CMake to produce the mappings.h 27 | // header file. If you are adding a GLFW specific gamepad mapping, this is 28 | // where to put it. 29 | //======================================================================== 30 | // As mappings.h, this provides all pre-defined gamepad mappings, including 31 | // all available in SDL_GameControllerDB. Do not edit this file. Any gamepad 32 | // mappings not specific to GLFW should be submitted to SDL_GameControllerDB. 33 | // This file can be re-generated from mappings.h.in and the upstream 34 | // gamecontrollerdb.txt with the GenerateMappings.cmake script. 35 | //======================================================================== 36 | 37 | // All gamepad mappings not labeled GLFW are copied from the 38 | // SDL_GameControllerDB project under the following license: 39 | // 40 | // Simple DirectMedia Layer 41 | // Copyright (C) 1997-2013 Sam Lantinga 42 | // 43 | // This software is provided 'as-is', without any express or implied warranty. 44 | // In no event will the authors be held liable for any damages arising from the 45 | // use of this software. 46 | // 47 | // Permission is granted to anyone to use this software for any purpose, 48 | // including commercial applications, and to alter it and redistribute it 49 | // freely, subject to the following restrictions: 50 | // 51 | // 1. The origin of this software must not be misrepresented; you must not 52 | // claim that you wrote the original software. If you use this software 53 | // in a product, an acknowledgment in the product documentation would 54 | // be appreciated but is not required. 55 | // 56 | // 2. Altered source versions must be plainly marked as such, and must not be 57 | // misrepresented as being the original software. 58 | // 59 | // 3. This notice may not be removed or altered from any source distribution. 60 | 61 | const char* _glfwDefaultMappings[] = 62 | { 63 | @GLFW_GAMEPAD_MAPPINGS@ 64 | "78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 65 | "78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 66 | "78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 67 | "78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 68 | "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 69 | "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 70 | "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", 71 | NULL 72 | }; 73 | 74 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/null_window.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 | static int createNativeWindow(_GLFWwindow* window, 34 | const _GLFWwndconfig* wndconfig) 35 | { 36 | window->null.width = wndconfig->width; 37 | window->null.height = wndconfig->height; 38 | 39 | return GLFW_TRUE; 40 | } 41 | 42 | 43 | ////////////////////////////////////////////////////////////////////////// 44 | ////// GLFW platform API ////// 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | int _glfwPlatformCreateWindow(_GLFWwindow* window, 48 | const _GLFWwndconfig* wndconfig, 49 | const _GLFWctxconfig* ctxconfig, 50 | const _GLFWfbconfig* fbconfig) 51 | { 52 | if (!createNativeWindow(window, wndconfig)) 53 | return GLFW_FALSE; 54 | 55 | if (ctxconfig->client != GLFW_NO_API) 56 | { 57 | if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API || 58 | ctxconfig->source == GLFW_OSMESA_CONTEXT_API) 59 | { 60 | if (!_glfwInitOSMesa()) 61 | return GLFW_FALSE; 62 | if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) 63 | return GLFW_FALSE; 64 | } 65 | else 66 | { 67 | _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available"); 68 | return GLFW_FALSE; 69 | } 70 | } 71 | 72 | return GLFW_TRUE; 73 | } 74 | 75 | void _glfwPlatformDestroyWindow(_GLFWwindow* window) 76 | { 77 | if (window->context.destroy) 78 | window->context.destroy(window); 79 | } 80 | 81 | void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) 82 | { 83 | } 84 | 85 | void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, 86 | const GLFWimage* images) 87 | { 88 | } 89 | 90 | void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, 91 | _GLFWmonitor* monitor, 92 | int xpos, int ypos, 93 | int width, int height, 94 | int refreshRate) 95 | { 96 | } 97 | 98 | void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) 99 | { 100 | } 101 | 102 | void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) 103 | { 104 | } 105 | 106 | void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) 107 | { 108 | if (width) 109 | *width = window->null.width; 110 | if (height) 111 | *height = window->null.height; 112 | } 113 | 114 | void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) 115 | { 116 | window->null.width = width; 117 | window->null.height = height; 118 | } 119 | 120 | void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, 121 | int minwidth, int minheight, 122 | int maxwidth, int maxheight) 123 | { 124 | } 125 | 126 | void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) 127 | { 128 | } 129 | 130 | void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) 131 | { 132 | if (width) 133 | *width = window->null.width; 134 | if (height) 135 | *height = window->null.height; 136 | } 137 | 138 | void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, 139 | int* left, int* top, 140 | int* right, int* bottom) 141 | { 142 | } 143 | 144 | void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, 145 | float* xscale, float* yscale) 146 | { 147 | if (xscale) 148 | *xscale = 1.f; 149 | if (yscale) 150 | *yscale = 1.f; 151 | } 152 | 153 | void _glfwPlatformIconifyWindow(_GLFWwindow* window) 154 | { 155 | } 156 | 157 | void _glfwPlatformRestoreWindow(_GLFWwindow* window) 158 | { 159 | } 160 | 161 | void _glfwPlatformMaximizeWindow(_GLFWwindow* window) 162 | { 163 | } 164 | 165 | int _glfwPlatformWindowMaximized(_GLFWwindow* window) 166 | { 167 | return GLFW_FALSE; 168 | } 169 | 170 | int _glfwPlatformWindowHovered(_GLFWwindow* window) 171 | { 172 | return GLFW_FALSE; 173 | } 174 | 175 | int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) 176 | { 177 | return GLFW_FALSE; 178 | } 179 | 180 | void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) 181 | { 182 | } 183 | 184 | void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) 185 | { 186 | } 187 | 188 | void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) 189 | { 190 | } 191 | 192 | float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) 193 | { 194 | return 1.f; 195 | } 196 | 197 | void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) 198 | { 199 | } 200 | 201 | void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) 202 | { 203 | } 204 | 205 | GLFWbool _glfwPlatformRawMouseMotionSupported(void) 206 | { 207 | return GLFW_FALSE; 208 | } 209 | 210 | void _glfwPlatformShowWindow(_GLFWwindow* window) 211 | { 212 | } 213 | 214 | 215 | void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) 216 | { 217 | } 218 | 219 | void _glfwPlatformUnhideWindow(_GLFWwindow* window) 220 | { 221 | } 222 | 223 | void _glfwPlatformHideWindow(_GLFWwindow* window) 224 | { 225 | } 226 | 227 | void _glfwPlatformFocusWindow(_GLFWwindow* window) 228 | { 229 | } 230 | 231 | int _glfwPlatformWindowFocused(_GLFWwindow* window) 232 | { 233 | return GLFW_FALSE; 234 | } 235 | 236 | int _glfwPlatformWindowIconified(_GLFWwindow* window) 237 | { 238 | return GLFW_FALSE; 239 | } 240 | 241 | int _glfwPlatformWindowVisible(_GLFWwindow* window) 242 | { 243 | return GLFW_FALSE; 244 | } 245 | 246 | void _glfwPlatformPollEvents(void) 247 | { 248 | } 249 | 250 | void _glfwPlatformWaitEvents(void) 251 | { 252 | } 253 | 254 | void _glfwPlatformWaitEventsTimeout(double timeout) 255 | { 256 | } 257 | 258 | void _glfwPlatformPostEmptyEvent(void) 259 | { 260 | } 261 | 262 | void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) 263 | { 264 | } 265 | 266 | void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) 267 | { 268 | } 269 | 270 | void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) 271 | { 272 | } 273 | 274 | int _glfwPlatformCreateCursor(_GLFWcursor* cursor, 275 | const GLFWimage* image, 276 | int xhot, int yhot) 277 | { 278 | return GLFW_TRUE; 279 | } 280 | 281 | int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) 282 | { 283 | return GLFW_TRUE; 284 | } 285 | 286 | void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) 287 | { 288 | } 289 | 290 | void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) 291 | { 292 | } 293 | 294 | void _glfwPlatformSetClipboardString(const char* string) 295 | { 296 | } 297 | 298 | const char* _glfwPlatformGetClipboardString(void) 299 | { 300 | return NULL; 301 | } 302 | 303 | const char* _glfwPlatformGetScancodeName(int scancode) 304 | { 305 | return ""; 306 | } 307 | 308 | int _glfwPlatformGetKeyScancode(int key) 309 | { 310 | return -1; 311 | } 312 | 313 | void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) 314 | { 315 | } 316 | 317 | int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, 318 | VkPhysicalDevice device, 319 | uint32_t queuefamily) 320 | { 321 | return GLFW_FALSE; 322 | } 323 | 324 | VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, 325 | _GLFWwindow* window, 326 | const VkAllocationCallbacks* allocator, 327 | VkSurfaceKHR* surface) 328 | { 329 | // This seems like the most appropriate error to return here 330 | return VK_ERROR_INITIALIZATION_FAILED; 331 | } 332 | 333 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/wgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 WGL - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2018 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 WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 29 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 30 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 31 | #define WGL_PIXEL_TYPE_ARB 0x2013 32 | #define WGL_TYPE_RGBA_ARB 0x202b 33 | #define WGL_ACCELERATION_ARB 0x2003 34 | #define WGL_NO_ACCELERATION_ARB 0x2025 35 | #define WGL_RED_BITS_ARB 0x2015 36 | #define WGL_RED_SHIFT_ARB 0x2016 37 | #define WGL_GREEN_BITS_ARB 0x2017 38 | #define WGL_GREEN_SHIFT_ARB 0x2018 39 | #define WGL_BLUE_BITS_ARB 0x2019 40 | #define WGL_BLUE_SHIFT_ARB 0x201a 41 | #define WGL_ALPHA_BITS_ARB 0x201b 42 | #define WGL_ALPHA_SHIFT_ARB 0x201c 43 | #define WGL_ACCUM_BITS_ARB 0x201d 44 | #define WGL_ACCUM_RED_BITS_ARB 0x201e 45 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201f 46 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 47 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 48 | #define WGL_DEPTH_BITS_ARB 0x2022 49 | #define WGL_STENCIL_BITS_ARB 0x2023 50 | #define WGL_AUX_BUFFERS_ARB 0x2024 51 | #define WGL_STEREO_ARB 0x2012 52 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 53 | #define WGL_SAMPLES_ARB 0x2042 54 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9 55 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 56 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 57 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 58 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 59 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 60 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 61 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 62 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 63 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 64 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 65 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 66 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 67 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 68 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 69 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 70 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 71 | #define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 72 | #define WGL_COLORSPACE_EXT 0x309d 73 | #define WGL_COLORSPACE_SRGB_EXT 0x3089 74 | 75 | #define ERROR_INVALID_VERSION_ARB 0x2095 76 | #define ERROR_INVALID_PROFILE_ARB 0x2096 77 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 78 | 79 | // WGL extension pointer typedefs 80 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); 81 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); 82 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); 83 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); 84 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); 85 | #define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT 86 | #define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB 87 | #define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT 88 | #define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB 89 | #define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB 90 | 91 | // opengl32.dll function pointer typedefs 92 | typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); 93 | typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC); 94 | typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR); 95 | typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void); 96 | typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void); 97 | typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC); 98 | typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); 99 | #define wglCreateContext _glfw.wgl.CreateContext 100 | #define wglDeleteContext _glfw.wgl.DeleteContext 101 | #define wglGetProcAddress _glfw.wgl.GetProcAddress 102 | #define wglGetCurrentDC _glfw.wgl.GetCurrentDC 103 | #define wglGetCurrentContext _glfw.wgl.GetCurrentContext 104 | #define wglMakeCurrent _glfw.wgl.MakeCurrent 105 | #define wglShareLists _glfw.wgl.ShareLists 106 | 107 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl 108 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl 109 | 110 | 111 | // WGL-specific per-context data 112 | // 113 | typedef struct _GLFWcontextWGL 114 | { 115 | HDC dc; 116 | HGLRC handle; 117 | int interval; 118 | 119 | } _GLFWcontextWGL; 120 | 121 | // WGL-specific global data 122 | // 123 | typedef struct _GLFWlibraryWGL 124 | { 125 | HINSTANCE instance; 126 | PFN_wglCreateContext CreateContext; 127 | PFN_wglDeleteContext DeleteContext; 128 | PFN_wglGetProcAddress GetProcAddress; 129 | PFN_wglGetCurrentDC GetCurrentDC; 130 | PFN_wglGetCurrentContext GetCurrentContext; 131 | PFN_wglMakeCurrent MakeCurrent; 132 | PFN_wglShareLists ShareLists; 133 | 134 | PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; 135 | PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; 136 | PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; 137 | PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; 138 | PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 139 | GLFWbool EXT_swap_control; 140 | GLFWbool EXT_colorspace; 141 | GLFWbool ARB_multisample; 142 | GLFWbool ARB_framebuffer_sRGB; 143 | GLFWbool EXT_framebuffer_sRGB; 144 | GLFWbool ARB_pixel_format; 145 | GLFWbool ARB_create_context; 146 | GLFWbool ARB_create_context_profile; 147 | GLFWbool EXT_create_context_es2_profile; 148 | GLFWbool ARB_create_context_robustness; 149 | GLFWbool ARB_create_context_no_error; 150 | GLFWbool ARB_context_flush_control; 151 | 152 | } _GLFWlibraryWGL; 153 | 154 | 155 | GLFWbool _glfwInitWGL(void); 156 | void _glfwTerminateWGL(void); 157 | GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, 158 | const _GLFWctxconfig* ctxconfig, 159 | const _GLFWfbconfig* fbconfig); 160 | 161 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/wl_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Wayland - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // 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 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | static void outputHandleGeometry(void* data, 39 | struct wl_output* output, 40 | int32_t x, 41 | int32_t y, 42 | int32_t physicalWidth, 43 | int32_t physicalHeight, 44 | int32_t subpixel, 45 | const char* make, 46 | const char* model, 47 | int32_t transform) 48 | { 49 | struct _GLFWmonitor *monitor = data; 50 | char name[1024]; 51 | 52 | monitor->wl.x = x; 53 | monitor->wl.y = y; 54 | monitor->widthMM = physicalWidth; 55 | monitor->heightMM = physicalHeight; 56 | 57 | snprintf(name, sizeof(name), "%s %s", make, model); 58 | monitor->name = _glfw_strdup(name); 59 | } 60 | 61 | static void outputHandleMode(void* data, 62 | struct wl_output* output, 63 | uint32_t flags, 64 | int32_t width, 65 | int32_t height, 66 | int32_t refresh) 67 | { 68 | struct _GLFWmonitor *monitor = data; 69 | GLFWvidmode mode; 70 | 71 | mode.width = width; 72 | mode.height = height; 73 | mode.redBits = 8; 74 | mode.greenBits = 8; 75 | mode.blueBits = 8; 76 | mode.refreshRate = (int) round(refresh / 1000.0); 77 | 78 | monitor->modeCount++; 79 | monitor->modes = 80 | realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode)); 81 | monitor->modes[monitor->modeCount - 1] = mode; 82 | 83 | if (flags & WL_OUTPUT_MODE_CURRENT) 84 | monitor->wl.currentMode = monitor->modeCount - 1; 85 | } 86 | 87 | static void outputHandleDone(void* data, struct wl_output* output) 88 | { 89 | struct _GLFWmonitor *monitor = data; 90 | 91 | _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); 92 | } 93 | 94 | static void outputHandleScale(void* data, 95 | struct wl_output* output, 96 | int32_t factor) 97 | { 98 | struct _GLFWmonitor *monitor = data; 99 | 100 | monitor->wl.scale = factor; 101 | } 102 | 103 | static const struct wl_output_listener outputListener = { 104 | outputHandleGeometry, 105 | outputHandleMode, 106 | outputHandleDone, 107 | outputHandleScale, 108 | }; 109 | 110 | 111 | ////////////////////////////////////////////////////////////////////////// 112 | ////// GLFW internal API ////// 113 | ////////////////////////////////////////////////////////////////////////// 114 | 115 | void _glfwAddOutputWayland(uint32_t name, uint32_t version) 116 | { 117 | _GLFWmonitor *monitor; 118 | struct wl_output *output; 119 | 120 | if (version < 2) 121 | { 122 | _glfwInputError(GLFW_PLATFORM_ERROR, 123 | "Wayland: Unsupported output interface version"); 124 | return; 125 | } 126 | 127 | // The actual name of this output will be set in the geometry handler. 128 | monitor = _glfwAllocMonitor(NULL, 0, 0); 129 | 130 | output = wl_registry_bind(_glfw.wl.registry, 131 | name, 132 | &wl_output_interface, 133 | 2); 134 | if (!output) 135 | { 136 | _glfwFreeMonitor(monitor); 137 | return; 138 | } 139 | 140 | monitor->wl.scale = 1; 141 | monitor->wl.output = output; 142 | monitor->wl.name = name; 143 | 144 | wl_output_add_listener(output, &outputListener, monitor); 145 | } 146 | 147 | 148 | ////////////////////////////////////////////////////////////////////////// 149 | ////// GLFW platform API ////// 150 | ////////////////////////////////////////////////////////////////////////// 151 | 152 | void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) 153 | { 154 | if (monitor->wl.output) 155 | wl_output_destroy(monitor->wl.output); 156 | } 157 | 158 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 159 | { 160 | if (xpos) 161 | *xpos = monitor->wl.x; 162 | if (ypos) 163 | *ypos = monitor->wl.y; 164 | } 165 | 166 | void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, 167 | float* xscale, float* yscale) 168 | { 169 | if (xscale) 170 | *xscale = (float) monitor->wl.scale; 171 | if (yscale) 172 | *yscale = (float) monitor->wl.scale; 173 | } 174 | 175 | void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, 176 | int* xpos, int* ypos, 177 | int* width, int* height) 178 | { 179 | if (xpos) 180 | *xpos = monitor->wl.x; 181 | if (ypos) 182 | *ypos = monitor->wl.y; 183 | if (width) 184 | *width = monitor->modes[monitor->wl.currentMode].width; 185 | if (height) 186 | *height = monitor->modes[monitor->wl.currentMode].height; 187 | } 188 | 189 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 190 | { 191 | *found = monitor->modeCount; 192 | return monitor->modes; 193 | } 194 | 195 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 196 | { 197 | *mode = monitor->modes[monitor->wl.currentMode]; 198 | } 199 | 200 | GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 201 | { 202 | _glfwInputError(GLFW_PLATFORM_ERROR, 203 | "Wayland: Gamma ramp access is not available"); 204 | return GLFW_FALSE; 205 | } 206 | 207 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, 208 | const GLFWgammaramp* ramp) 209 | { 210 | _glfwInputError(GLFW_PLATFORM_ERROR, 211 | "Wayland: Gamma ramp access is not available"); 212 | } 213 | 214 | 215 | ////////////////////////////////////////////////////////////////////////// 216 | ////// GLFW native API ////// 217 | ////////////////////////////////////////////////////////////////////////// 218 | 219 | GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) 220 | { 221 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 222 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 223 | return monitor->wl.output; 224 | } 225 | 226 | -------------------------------------------------------------------------------- /third_party/include/gs/external/glfw/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 | -------------------------------------------------------------------------------- /third_party/include/gs/util/.gs_gui.h.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GameEngineering/EP01_SandSim/7fd7d5a215071db7ecbc9c5d2e54b5f82c79e31f/third_party/include/gs/util/.gs_gui.h.swp -------------------------------------------------------------------------------- /third_party/include/gs/util/gs_asset.h: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Copyright: 2020 John Jackson 3 | * GSAsset: Asset Manager Util for Gunslinger 4 | * File: gs_asset.h 5 | All Rights Reserved 6 | =================================================================*/ 7 | 8 | #ifndef GS_ASSET_H 9 | #define GS_ASSET_H 10 | 11 | /* 12 | USAGE: (IMPORTANT) 13 | 14 | ================================================================================================================= 15 | 16 | Before including, define the gunslinger asset manager implementation like this: 17 | 18 | #define GS_ASSET_IMPL 19 | 20 | in EXACTLY ONE C or C++ file that includes this header, BEFORE the 21 | include, like this: 22 | 23 | #define GS_ASSET_IMPL 24 | #include "gs_asset.h" 25 | 26 | All other files should just #include "gs_asset.h" without the #define. 27 | 28 | MUST include "gs.h" and declare GS_IMPL BEFORE this file, since this file relies on that: 29 | 30 | #define GS_IMPL 31 | #include "gs.h" 32 | 33 | #define GS_ASSET_IMPL 34 | #include "gs_asset.h" 35 | 36 | ================================================================================================================ 37 | */ 38 | 39 | /*==== Interface ====*/ 40 | 41 | /** @defgroup gs_asset_util Asset Util 42 | * Gunslinger Asset Util 43 | * @{ 44 | */ 45 | 46 | // Asset handle 47 | typedef struct gs_asset_t 48 | { 49 | uint64_t type_id; 50 | uint32_t asset_id; 51 | uint32_t importer_id; // 'Unique' id of importer, used for type safety 52 | } gs_asset_t; 53 | 54 | GS_API_DECL gs_asset_t __gs_asset_handle_create_impl(uint64_t type_id, uint32_t asset_id, uint32_t importer_id); 55 | 56 | #define gs_asset_handle_create(T, ID, IMPID)\ 57 | __gs_asset_handle_create_impl(gs_hash_str64(gs_to_str(T)), ID, IMPID) 58 | 59 | typedef void (* gs_asset_load_func)(const char *,void *,...); 60 | typedef gs_asset_t (* gs_asset_default_func)(void *); 61 | 62 | typedef struct gs_asset_importer_desc_t { 63 | void (* load_from_file)(const char* path, void* out, ...); 64 | gs_asset_t (* default_asset)(void* out); 65 | } gs_asset_importer_desc_t; 66 | 67 | typedef struct gs_asset_importer_t 68 | { 69 | void* slot_array; 70 | void* slot_array_data_ptr; 71 | void* slot_array_indices_ptr; 72 | void* tmp_ptr; 73 | uint32_t tmpid; 74 | size_t data_size; 75 | gs_asset_importer_desc_t desc; 76 | uint32_t importer_id; 77 | gs_asset_t default_asset; 78 | } gs_asset_importer_t; 79 | 80 | GS_API_DECL void gs_asset_default_load_from_file( const char* path, void* out ); 81 | GS_API_DECL gs_asset_t gs_asset_default_asset(); 82 | GS_API_DECL void gs_asset_importer_set_desc(gs_asset_importer_t* imp, gs_asset_importer_desc_t* desc); 83 | 84 | #define gs_assets_get_importerp(AM, T)\ 85 | (gs_hash_table_getp((AM)->importers, gs_hash_str64(gs_to_str(T)))) 86 | 87 | #ifdef __cplusplus 88 | #define gsa_imsa(IMPORTER, T)\ 89 | (decltype(gs_slot_array(T))(IMPORTER)->slot_array) 90 | #else 91 | #define gsa_imsa(IMPORTER, T)\ 92 | ((gs_slot_array(T))(IMPORTER)->slot_array) 93 | #endif 94 | 95 | #define gs_assets_register_importer(AM, T, DESC)\ 96 | do {\ 97 | gs_asset_importer_t ai = gs_default_val();\ 98 | ai.data_size = sizeof(T);\ 99 | ai.importer_id = (AM)->free_importer_id++;\ 100 | gs_asset_importer_set_desc(&ai, (DESC));\ 101 | size_t sz = 2 * sizeof(void*) + sizeof(T);\ 102 | gs_slot_array(T) sa = NULL;\ 103 | gs_slot_array_init((void**)&sa, sizeof(*sa));\ 104 | gs_dyn_array_init((void**)&sa->indices, sizeof(uint32_t));\ 105 | gs_dyn_array_init((void**)&sa->data, sizeof(T));\ 106 | ai.slot_array = (void*)sa;\ 107 | ai.tmp_ptr = (void*)&sa->tmp;\ 108 | ai.slot_array_indices_ptr = (void*)sa->indices;\ 109 | ai.slot_array_data_ptr = (void*)sa->data;\ 110 | if (!ai.desc.load_from_file) {ai.desc.load_from_file = (gs_asset_load_func)&gs_asset_default_load_from_file;}\ 111 | gs_hash_table_insert((AM)->importers, gs_hash_str64(gs_to_str(T)), ai);\ 112 | } while(0) 113 | 114 | // Need a way to be able to print upon assert 115 | #define gs_assets_load_from_file(AM, T, PATH, ...)\ 116 | (\ 117 | /*gs_assert(gs_hash_table_key_exists((AM)->importers, gs_hash_str64(gs_to_str(T)))),*/\ 118 | (AM)->tmpi = gs_hash_table_getp((AM)->importers, gs_hash_str64(gs_to_str(T))),\ 119 | (AM)->tmpi->desc.load_from_file(PATH, (AM)->tmpi->tmp_ptr, ## __VA_ARGS__),\ 120 | (AM)->tmpi->tmpid = gs_slot_array_insert_func(&(AM)->tmpi->slot_array_indices_ptr, &(AM)->tmpi->slot_array_data_ptr, (AM)->tmpi->tmp_ptr, (AM)->tmpi->data_size, NULL),\ 121 | gs_asset_handle_create(T, (AM)->tmpi->tmpid, (AM)->tmpi->importer_id)\ 122 | ) 123 | 124 | #define gs_assets_create_asset(AM, T, DATA)\ 125 | (\ 126 | /*gs_assert(gs_hash_table_key_exists((AM)->importers, gs_hash_str64(gs_to_str(T)))),*/\ 127 | (AM)->tmpi = gs_hash_table_getp((AM)->importers, gs_hash_str64(gs_to_str(T))),\ 128 | (AM)->tmpi->tmp_ptr = (DATA),\ 129 | (AM)->tmpi->tmpid = gs_slot_array_insert_func(&(AM)->tmpi->slot_array_indices_ptr, &(AM)->tmpi->slot_array_data_ptr, (AM)->tmpi->tmp_ptr, (AM)->tmpi->data_size, NULL),\ 130 | gs_asset_handle_create(T, (AM)->tmpi->tmpid, (AM)->tmpi->importer_id)\ 131 | ) 132 | 133 | typedef struct gs_asset_manager_t 134 | { 135 | gs_hash_table(uint64_t, gs_asset_importer_t) importers; // Maps hashed types to importer 136 | gs_asset_importer_t* tmpi; // Temporary importer for caching 137 | uint32_t free_importer_id; 138 | } gs_asset_manager_t; 139 | 140 | GS_API_DECL gs_asset_manager_t gs_asset_manager_new(); 141 | GS_API_DECL void gs_asset_manager_free(gs_asset_manager_t* am); 142 | GS_API_DECL void* __gs_assets_getp_impl(gs_asset_manager_t* am, uint64_t type_id, gs_asset_t hndl); 143 | 144 | #define gs_assets_getp(AM, T, HNDL)\ 145 | (T*)(__gs_assets_getp_impl(AM, gs_hash_str64(gs_to_str(T)), HNDL)) 146 | 147 | #define gs_assets_get(AM, T, HNDL)\ 148 | *(gs_assets_getp(AM, T, HNDL)); 149 | 150 | /** @} */ // end of gs_asset_util 151 | 152 | /*==== Implementation ====*/ 153 | 154 | #ifdef GS_ASSET_IMPL 155 | 156 | gs_asset_t __gs_asset_handle_create_impl(uint64_t type_id, uint32_t asset_id, uint32_t importer_id) 157 | { 158 | gs_asset_t asset = gs_default_val(); 159 | asset.type_id = type_id; 160 | asset.asset_id = asset_id; 161 | asset.importer_id = importer_id; 162 | return asset; 163 | } 164 | 165 | gs_asset_manager_t gs_asset_manager_new() 166 | { 167 | gs_asset_manager_t assets = gs_default_val(); 168 | 169 | // Register default asset importers 170 | gs_asset_importer_desc_t tex_desc = gs_default_val(); 171 | gs_asset_importer_desc_t font_desc = gs_default_val(); 172 | gs_asset_importer_desc_t audio_desc = gs_default_val(); 173 | gs_asset_importer_desc_t mesh_desc = gs_default_val(); 174 | gs_asset_importer_desc_t asset_desc = gs_default_val(); 175 | 176 | tex_desc.load_from_file = (gs_asset_load_func)&gs_asset_texture_load_from_file; 177 | font_desc.load_from_file = (gs_asset_load_func)&gs_asset_font_load_from_file; 178 | audio_desc.load_from_file = (gs_asset_load_func)&gs_asset_audio_load_from_file; 179 | mesh_desc.load_from_file = (gs_asset_load_func)&gs_asset_mesh_load_from_file; 180 | 181 | gs_assets_register_importer(&assets, gs_asset_t, &asset_desc); 182 | gs_assets_register_importer(&assets, gs_asset_texture_t, &tex_desc); 183 | gs_assets_register_importer(&assets, gs_asset_font_t, &font_desc); 184 | gs_assets_register_importer(&assets, gs_asset_audio_t, &audio_desc); 185 | gs_assets_register_importer(&assets, gs_asset_mesh_t, &mesh_desc); 186 | 187 | return assets; 188 | } 189 | 190 | void gs_asset_manager_free(gs_asset_manager_t* am) 191 | { 192 | // Free all data 193 | } 194 | 195 | void* __gs_assets_getp_impl(gs_asset_manager_t* am, uint64_t type_id, gs_asset_t hndl) 196 | { 197 | if (type_id != hndl.type_id) { 198 | gs_println("Warning: Type id: %zu doesn't match handle type id: %zu.", type_id, hndl.type_id); 199 | gs_assert(false); 200 | return NULL; 201 | } 202 | 203 | // Need to grab the appropriate importer based on type 204 | if (!gs_hash_table_key_exists(am->importers, type_id)) { 205 | gs_println("Warning: Importer type %zu does not exist.", type_id); 206 | gs_assert(false); 207 | return NULL; 208 | } 209 | 210 | gs_asset_importer_t* imp = gs_hash_table_getp(am->importers, type_id); 211 | 212 | // Vertify that importer id and handle importer id align 213 | if (imp->importer_id != hndl.importer_id) { 214 | gs_println("Warning: Importer id: %zu does not match handle importer id: %zu.", 215 | imp->importer_id, hndl.importer_id); 216 | gs_assert(false); 217 | return NULL; 218 | } 219 | 220 | // Need to get data index from slot array using hndl asset id 221 | size_t offset = (((sizeof(uint32_t) * hndl.asset_id) + 3) & (~3)); 222 | uint32_t idx = *(uint32_t*)((char*)(imp->slot_array_indices_ptr) + offset); 223 | // Then need to return pointer to data at index 224 | size_t data_sz = imp->data_size; 225 | size_t s = data_sz == 8 ? 7 : 3; 226 | offset = (((data_sz * idx) + s) & (~s)); 227 | return ((char*)(imp->slot_array_data_ptr) + offset); 228 | } 229 | 230 | void gs_asset_importer_set_desc(gs_asset_importer_t* imp, gs_asset_importer_desc_t* desc) 231 | { 232 | imp->desc = desc ? *desc : imp->desc; 233 | imp->desc.load_from_file = imp->desc.load_from_file ? (gs_asset_load_func)imp->desc.load_from_file 234 | : (gs_asset_load_func)&gs_asset_default_load_from_file; 235 | imp->desc.default_asset = imp->desc.default_asset ? (gs_asset_default_func)imp->desc.default_asset 236 | : (gs_asset_default_func)&gs_asset_default_asset; 237 | } 238 | 239 | gs_asset_t gs_asset_default_asset() 240 | { 241 | gs_asset_t a = gs_default_val(); 242 | return a; 243 | } 244 | 245 | void gs_asset_default_load_from_file(const char* path, void* out) 246 | { 247 | // Nothing... 248 | } 249 | 250 | #undef GS_ASSET_IMPL 251 | #endif // GS_ASSET_IMPL 252 | 253 | #endif // GS_ASSET_H 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | -------------------------------------------------------------------------------- /third_party/include/gs/util/gs_audxt.h: -------------------------------------------------------------------------------- 1 | #ifndef GS_AUDXT_H 2 | #define GS_AUDXT_H 3 | 4 | // Start of optional audio extensions 5 | 6 | #endif 7 | --------------------------------------------------------------------------------