├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── assets ├── demo.gif └── demo.png ├── glad ├── include │ ├── KHR │ │ └── khrplatform.h │ └── glad │ │ └── glad.h └── src │ └── glad.c ├── imgui ├── backends │ ├── imgui_impl_glfw.cpp │ ├── imgui_impl_glfw.h │ ├── imgui_impl_opengl3.cpp │ ├── imgui_impl_opengl3.h │ └── imgui_impl_opengl3_loader.h ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_draw.cpp ├── imgui_internal.h ├── imgui_tables.cpp ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h └── imstb_truetype.h ├── imnodes ├── imnodes.cpp ├── imnodes.h └── imnodes_internal.h ├── main.cpp └── ringbuffer └── ringbuffer.c /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '**.md' 7 | - 'LICENSE' 8 | branches: 9 | - '*' 10 | tags: 11 | - 'v*' 12 | workflow_dispatch: ~ 13 | schedule: 14 | - cron: '0 16 * * *' 15 | 16 | jobs: 17 | build: 18 | name: Build 19 | runs-on: ubuntu-latest 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | target: [win64,linux64,linuxarm64] 24 | container: ghcr.io/btbn/ffmpeg-builds/${{ matrix.target }}-gpl:latest 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v3 28 | - name: Clone FFmpeg 29 | id: ffclone 30 | run: | 31 | set -xe 32 | git clone --filter=blob:none https://github.com/FFmpeg/FFmpeg.git /FFmpeg 33 | echo "ffsha=$(git -C /FFmpeg rev-parse --verify HEAD)" >> $GITHUB_OUTPUT 34 | echo "contsha=$(curl --unix-socket /var/run/docker.sock http://localhost/containers/${HOSTNAME}/json | python3 -c "import sys, json; print(json.load(sys.stdin)['Image'].rpartition(':')[2])")" >> $GITHUB_OUTPUT 35 | - name: Cache FFmpeg 36 | id: ffcache 37 | uses: actions/cache@v3 38 | with: 39 | path: /FFmpeg 40 | key: ffcache-${{ matrix.target }}-${{ steps.ffclone.outputs.ffsha }}-${{ steps.ffclone.outputs.contsha }} 41 | - name: Build FFmpeg 42 | if: ${{ steps.ffcache.outputs.cache-hit != 'true' }} 43 | run: | 44 | set -xe 45 | cd /FFmpeg 46 | ./configure --prefix="$FFBUILD_PREFIX" --pkg-config-flags="--static" $FFBUILD_TARGET_FLAGS \ 47 | --disable-debug --disable-shared --enable-static --disable-programs --disable-doc --enable-gpl --enable-version3 \ 48 | --enable-zlib --enable-libx264 --enable-libx265 --enable-libvpx --enable-libass --enable-libmp3lame \ 49 | --enable-libzimg 50 | make -j$(nproc) 51 | - name: Install FFmpeg 52 | run: | 53 | set -xe 54 | cd /FFmpeg 55 | make install 56 | - name: Build GLFW 57 | run: | 58 | set -xe 59 | git clone --filter=blob:none https://github.com/glfw/glfw.git /glfw 60 | cd /glfw 61 | mkdir build && cd build 62 | cmake -GNinja -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \ 63 | -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_WAYLAND=OFF .. 64 | ninja -j$(nproc) 65 | ninja install 66 | - name: Build 67 | run: | 68 | set -xe 69 | make -j$(nproc) CC="${FFBUILD_CROSS_PREFIX}gcc" CXX="${FFBUILD_CROSS_PREFIX}g++" \ 70 | PKG_CONFIG_FLAGS="--static" PKG_CONFIG_PATH="$PKG_CONFIG_LIBDIR" 71 | - name: Prepare artifacts 72 | run: | 73 | set -xe 74 | ${FFBUILD_CROSS_PREFIX}strip --strip-unneeded lavfi-preview* 75 | mkdir artifacts 76 | mv lavfi-preview* artifacts/lavfi-preview-${{ matrix.target }}$(test -f *.exe && echo .exe) 77 | xz -9 -e artifacts/* 78 | - name: Upload artifacts 79 | uses: actions/upload-artifact@v4 80 | with: 81 | name: lavfi-preview-${{ matrix.target }} 82 | path: artifacts/* 83 | release: 84 | name: Release 85 | needs: build 86 | runs-on: ubuntu-latest 87 | if: ${{ startsWith(github.ref, 'refs/tags/') }} 88 | steps: 89 | - name: Checkout 90 | uses: actions/checkout@v3 91 | - name: Download artifacts 92 | uses: actions/download-artifact@v4 93 | with: 94 | path: artifacts 95 | pattern: lavfi-preview-* 96 | merge-multiple: true 97 | - name: Create Release 98 | env: 99 | GITHUB_TOKEN: ${{ github.token }} 100 | run: | 101 | set -xe 102 | TAGNAME="${GITHUB_REF#refs/*/}" 103 | gh release create -t "Release $TAGNAME" $TAGNAME artifacts/* 104 | # merge: 105 | # runs-on: ubuntu-latest 106 | # needs: upload 107 | # steps: 108 | # - name: Merge Artifacts 109 | # uses: actions/upload-artifact/merge@v4 110 | # with: 111 | # name: lavfi-preview 112 | # pattern: lavfi-preview-* 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | *.o 3 | lavfi-preview 4 | imgui.ini 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Paul B Mahol 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Cross Platform Makefile 3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X 4 | # 5 | # You will need GLFW (http://www.glfw.org): 6 | # Linux: 7 | # apt-get install libglfw-dev 8 | # Mac OS X: 9 | # brew install glfw 10 | # MSYS2: 11 | # pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw 12 | # 13 | 14 | #CXX = g++ 15 | #CXX = clang++ 16 | 17 | PKG_CONFIG_PATH = /usr/local/lib/pkgconfig 18 | PKG_CONFIG_FLAGS = --shared 19 | EXE = lavfi-preview 20 | IMGUI_DIR = imgui 21 | IMNODES_DIR = imnodes 22 | GLAD_DIR = glad 23 | SOURCES = main.cpp 24 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp 25 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp 26 | SOURCES += $(IMNODES_DIR)/imnodes.cpp 27 | SOURCES += $(GLAD_DIR)/src/glad.c 28 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) 29 | UNAME_S := $(shell uname -s) 30 | 31 | CXXFLAGS ?= -g -Wall -Wformat 32 | CXXFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I$(IMNODES_DIR) -I$(GLAD_DIR)/include 33 | LIBS ?= -L/usr/local/lib 34 | 35 | ##--------------------------------------------------------------------- 36 | ## BUILD FLAGS PER PLATFORM 37 | ##--------------------------------------------------------------------- 38 | 39 | ifeq ($(UNAME_S), Linux) #LINUX 40 | LIBS += `pkg-config --with-path=$(PKG_CONFIG_PATH) $(PKG_CONFIG_FLAGS) --libs glfw3 libavutil libavcodec libavformat libswresample libswscale libavfilter libavdevice openal` 41 | CXXFLAGS += `pkg-config --with-path=$(PKG_CONFIG_PATH) $(PKG_CONFIG_FLAGS) --cflags glfw3 libavutil libavcodec libavformat libswresample libswscale libavfilter libavdevice openal` 42 | endif 43 | 44 | CFLAGS = $(CXXFLAGS) 45 | 46 | ##--------------------------------------------------------------------- 47 | ## BUILD RULES 48 | ##--------------------------------------------------------------------- 49 | 50 | %.o:%.cpp 51 | $(CXX) $(CXXFLAGS) -c -o $@ $< 52 | 53 | %.o:$(IMGUI_DIR)/%.cpp 54 | $(CXX) $(CXXFLAGS) -c -o $@ $< 55 | 56 | %.o:$(IMGUI_DIR)/backends/%.cpp 57 | $(CXX) $(CXXFLAGS) -c -o $@ $< 58 | 59 | %.o:$(IMNODES_DIR)/%.cpp 60 | $(CXX) $(CXXFLAGS) -c -o $@ $< 61 | 62 | %.o:$(GLAD_DIR)/src/%.c 63 | $(CC) $(CFLAGS) -c -o $@ $< 64 | 65 | all: $(EXE) 66 | @echo Build complete for lavfi-preview 67 | 68 | $(EXE): $(OBJS) 69 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) 70 | 71 | clean: 72 | rm -f $(EXE) $(OBJS) 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GUI for libavfilter 2 | 3 | ![screenshot](https://github.com/richardpl/lavfi-preview/blob/master/assets/demo.png) 4 | 5 | GUI to preview filtergraphs from libavfilter. 6 | 7 | Depends on ImGui, FFmpeg >=5.0, glfw, OpenGL3 and OpenAL-Soft. 8 | 9 | For list of useful keys press F1 while running. 10 | -------------------------------------------------------------------------------- /assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richardpl/lavfi-preview/7bf2ce769393da621488a6065c998fec778ce84a/assets/demo.gif -------------------------------------------------------------------------------- /assets/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richardpl/lavfi-preview/7bf2ce769393da621488a6065c998fec778ce84a/assets/demo.png -------------------------------------------------------------------------------- /glad/include/KHR/khrplatform.h: -------------------------------------------------------------------------------- 1 | #ifndef __khrplatform_h_ 2 | #define __khrplatform_h_ 3 | 4 | /* 5 | ** Copyright (c) 2008-2018 The Khronos Group Inc. 6 | ** 7 | ** Permission is hereby granted, free of charge, to any person obtaining a 8 | ** copy of this software and/or associated documentation files (the 9 | ** "Materials"), to deal in the Materials without restriction, including 10 | ** without limitation the rights to use, copy, modify, merge, publish, 11 | ** distribute, sublicense, and/or sell copies of the Materials, and to 12 | ** permit persons to whom the Materials are furnished to do so, subject to 13 | ** the following conditions: 14 | ** 15 | ** The above copyright notice and this permission notice shall be included 16 | ** in all copies or substantial portions of the Materials. 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 25 | */ 26 | 27 | /* Khronos platform-specific types and definitions. 28 | * 29 | * The master copy of khrplatform.h is maintained in the Khronos EGL 30 | * Registry repository at https://github.com/KhronosGroup/EGL-Registry 31 | * The last semantic modification to khrplatform.h was at commit ID: 32 | * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 33 | * 34 | * Adopters may modify this file to suit their platform. Adopters are 35 | * encouraged to submit platform specific modifications to the Khronos 36 | * group so that they can be included in future versions of this file. 37 | * Please submit changes by filing pull requests or issues on 38 | * the EGL Registry repository linked above. 39 | * 40 | * 41 | * See the Implementer's Guidelines for information about where this file 42 | * should be located on your system and for more details of its use: 43 | * http://www.khronos.org/registry/implementers_guide.pdf 44 | * 45 | * This file should be included as 46 | * #include 47 | * by Khronos client API header files that use its types and defines. 48 | * 49 | * The types in khrplatform.h should only be used to define API-specific types. 50 | * 51 | * Types defined in khrplatform.h: 52 | * khronos_int8_t signed 8 bit 53 | * khronos_uint8_t unsigned 8 bit 54 | * khronos_int16_t signed 16 bit 55 | * khronos_uint16_t unsigned 16 bit 56 | * khronos_int32_t signed 32 bit 57 | * khronos_uint32_t unsigned 32 bit 58 | * khronos_int64_t signed 64 bit 59 | * khronos_uint64_t unsigned 64 bit 60 | * khronos_intptr_t signed same number of bits as a pointer 61 | * khronos_uintptr_t unsigned same number of bits as a pointer 62 | * khronos_ssize_t signed size 63 | * khronos_usize_t unsigned size 64 | * khronos_float_t signed 32 bit floating point 65 | * khronos_time_ns_t unsigned 64 bit time in nanoseconds 66 | * khronos_utime_nanoseconds_t unsigned time interval or absolute time in 67 | * nanoseconds 68 | * khronos_stime_nanoseconds_t signed time interval in nanoseconds 69 | * khronos_boolean_enum_t enumerated boolean type. This should 70 | * only be used as a base type when a client API's boolean type is 71 | * an enum. Client APIs which use an integer or other type for 72 | * booleans cannot use this as the base type for their boolean. 73 | * 74 | * Tokens defined in khrplatform.h: 75 | * 76 | * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. 77 | * 78 | * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. 79 | * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. 80 | * 81 | * Calling convention macros defined in this file: 82 | * KHRONOS_APICALL 83 | * KHRONOS_APIENTRY 84 | * KHRONOS_APIATTRIBUTES 85 | * 86 | * These may be used in function prototypes as: 87 | * 88 | * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( 89 | * int arg1, 90 | * int arg2) KHRONOS_APIATTRIBUTES; 91 | */ 92 | 93 | #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) 94 | # define KHRONOS_STATIC 1 95 | #endif 96 | 97 | /*------------------------------------------------------------------------- 98 | * Definition of KHRONOS_APICALL 99 | *------------------------------------------------------------------------- 100 | * This precedes the return type of the function in the function prototype. 101 | */ 102 | #if defined(KHRONOS_STATIC) 103 | /* If the preprocessor constant KHRONOS_STATIC is defined, make the 104 | * header compatible with static linking. */ 105 | # define KHRONOS_APICALL 106 | #elif defined(_WIN32) 107 | # define KHRONOS_APICALL __declspec(dllimport) 108 | #elif defined (__SYMBIAN32__) 109 | # define KHRONOS_APICALL IMPORT_C 110 | #elif defined(__ANDROID__) 111 | # define KHRONOS_APICALL __attribute__((visibility("default"))) 112 | #else 113 | # define KHRONOS_APICALL 114 | #endif 115 | 116 | /*------------------------------------------------------------------------- 117 | * Definition of KHRONOS_APIENTRY 118 | *------------------------------------------------------------------------- 119 | * This follows the return type of the function and precedes the function 120 | * name in the function prototype. 121 | */ 122 | #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) 123 | /* Win32 but not WinCE */ 124 | # define KHRONOS_APIENTRY __stdcall 125 | #else 126 | # define KHRONOS_APIENTRY 127 | #endif 128 | 129 | /*------------------------------------------------------------------------- 130 | * Definition of KHRONOS_APIATTRIBUTES 131 | *------------------------------------------------------------------------- 132 | * This follows the closing parenthesis of the function prototype arguments. 133 | */ 134 | #if defined (__ARMCC_2__) 135 | #define KHRONOS_APIATTRIBUTES __softfp 136 | #else 137 | #define KHRONOS_APIATTRIBUTES 138 | #endif 139 | 140 | /*------------------------------------------------------------------------- 141 | * basic type definitions 142 | *-----------------------------------------------------------------------*/ 143 | #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) 144 | 145 | 146 | /* 147 | * Using 148 | */ 149 | #include 150 | typedef int32_t khronos_int32_t; 151 | typedef uint32_t khronos_uint32_t; 152 | typedef int64_t khronos_int64_t; 153 | typedef uint64_t khronos_uint64_t; 154 | #define KHRONOS_SUPPORT_INT64 1 155 | #define KHRONOS_SUPPORT_FLOAT 1 156 | /* 157 | * To support platform where unsigned long cannot be used interchangeably with 158 | * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. 159 | * Ideally, we could just use (u)intptr_t everywhere, but this could result in 160 | * ABI breakage if khronos_uintptr_t is changed from unsigned long to 161 | * unsigned long long or similar (this results in different C++ name mangling). 162 | * To avoid changes for existing platforms, we restrict usage of intptr_t to 163 | * platforms where the size of a pointer is larger than the size of long. 164 | */ 165 | #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) 166 | #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ 167 | #define KHRONOS_USE_INTPTR_T 168 | #endif 169 | #endif 170 | 171 | #elif defined(__VMS ) || defined(__sgi) 172 | 173 | /* 174 | * Using 175 | */ 176 | #include 177 | typedef int32_t khronos_int32_t; 178 | typedef uint32_t khronos_uint32_t; 179 | typedef int64_t khronos_int64_t; 180 | typedef uint64_t khronos_uint64_t; 181 | #define KHRONOS_SUPPORT_INT64 1 182 | #define KHRONOS_SUPPORT_FLOAT 1 183 | 184 | #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) 185 | 186 | /* 187 | * Win32 188 | */ 189 | typedef __int32 khronos_int32_t; 190 | typedef unsigned __int32 khronos_uint32_t; 191 | typedef __int64 khronos_int64_t; 192 | typedef unsigned __int64 khronos_uint64_t; 193 | #define KHRONOS_SUPPORT_INT64 1 194 | #define KHRONOS_SUPPORT_FLOAT 1 195 | 196 | #elif defined(__sun__) || defined(__digital__) 197 | 198 | /* 199 | * Sun or Digital 200 | */ 201 | typedef int khronos_int32_t; 202 | typedef unsigned int khronos_uint32_t; 203 | #if defined(__arch64__) || defined(_LP64) 204 | typedef long int khronos_int64_t; 205 | typedef unsigned long int khronos_uint64_t; 206 | #else 207 | typedef long long int khronos_int64_t; 208 | typedef unsigned long long int khronos_uint64_t; 209 | #endif /* __arch64__ */ 210 | #define KHRONOS_SUPPORT_INT64 1 211 | #define KHRONOS_SUPPORT_FLOAT 1 212 | 213 | #elif 0 214 | 215 | /* 216 | * Hypothetical platform with no float or int64 support 217 | */ 218 | typedef int khronos_int32_t; 219 | typedef unsigned int khronos_uint32_t; 220 | #define KHRONOS_SUPPORT_INT64 0 221 | #define KHRONOS_SUPPORT_FLOAT 0 222 | 223 | #else 224 | 225 | /* 226 | * Generic fallback 227 | */ 228 | #include 229 | typedef int32_t khronos_int32_t; 230 | typedef uint32_t khronos_uint32_t; 231 | typedef int64_t khronos_int64_t; 232 | typedef uint64_t khronos_uint64_t; 233 | #define KHRONOS_SUPPORT_INT64 1 234 | #define KHRONOS_SUPPORT_FLOAT 1 235 | 236 | #endif 237 | 238 | 239 | /* 240 | * Types that are (so far) the same on all platforms 241 | */ 242 | typedef signed char khronos_int8_t; 243 | typedef unsigned char khronos_uint8_t; 244 | typedef signed short int khronos_int16_t; 245 | typedef unsigned short int khronos_uint16_t; 246 | 247 | /* 248 | * Types that differ between LLP64 and LP64 architectures - in LLP64, 249 | * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears 250 | * to be the only LLP64 architecture in current use. 251 | */ 252 | #ifdef KHRONOS_USE_INTPTR_T 253 | typedef intptr_t khronos_intptr_t; 254 | typedef uintptr_t khronos_uintptr_t; 255 | #elif defined(_WIN64) 256 | typedef signed long long int khronos_intptr_t; 257 | typedef unsigned long long int khronos_uintptr_t; 258 | #else 259 | typedef signed long int khronos_intptr_t; 260 | typedef unsigned long int khronos_uintptr_t; 261 | #endif 262 | 263 | #if defined(_WIN64) 264 | typedef signed long long int khronos_ssize_t; 265 | typedef unsigned long long int khronos_usize_t; 266 | #else 267 | typedef signed long int khronos_ssize_t; 268 | typedef unsigned long int khronos_usize_t; 269 | #endif 270 | 271 | #if KHRONOS_SUPPORT_FLOAT 272 | /* 273 | * Float type 274 | */ 275 | typedef float khronos_float_t; 276 | #endif 277 | 278 | #if KHRONOS_SUPPORT_INT64 279 | /* Time types 280 | * 281 | * These types can be used to represent a time interval in nanoseconds or 282 | * an absolute Unadjusted System Time. Unadjusted System Time is the number 283 | * of nanoseconds since some arbitrary system event (e.g. since the last 284 | * time the system booted). The Unadjusted System Time is an unsigned 285 | * 64 bit value that wraps back to 0 every 584 years. Time intervals 286 | * may be either signed or unsigned. 287 | */ 288 | typedef khronos_uint64_t khronos_utime_nanoseconds_t; 289 | typedef khronos_int64_t khronos_stime_nanoseconds_t; 290 | #endif 291 | 292 | /* 293 | * Dummy value used to pad enum types to 32 bits. 294 | */ 295 | #ifndef KHRONOS_MAX_ENUM 296 | #define KHRONOS_MAX_ENUM 0x7FFFFFFF 297 | #endif 298 | 299 | /* 300 | * Enumerated boolean type 301 | * 302 | * Values other than zero should be considered to be true. Therefore 303 | * comparisons should not be made against KHRONOS_TRUE. 304 | */ 305 | typedef enum { 306 | KHRONOS_FALSE = 0, 307 | KHRONOS_TRUE = 1, 308 | KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM 309 | } khronos_boolean_enum_t; 310 | 311 | #endif /* __khrplatform_h_ */ 312 | -------------------------------------------------------------------------------- /glad/src/glad.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | OpenGL loader generated by glad 0.1.36 on Sat Oct 29 20:20:19 2022. 4 | 5 | Language/Generator: C/C++ 6 | Specification: gl 7 | APIs: gl=3.0 8 | Profile: core 9 | Extensions: 10 | 11 | Loader: False 12 | Local files: False 13 | Omit khrplatform: False 14 | Reproducible: False 15 | 16 | Commandline: 17 | --profile="core" --api="gl=3.0" --generator="c" --spec="gl" --no-loader --extensions="" 18 | Online: 19 | https://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.0 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | struct gladGLversionStruct GLVersion = { 0, 0 }; 28 | 29 | #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) 30 | #define _GLAD_IS_SOME_NEW_VERSION 1 31 | #endif 32 | 33 | static int max_loaded_major; 34 | static int max_loaded_minor; 35 | 36 | static const char *exts = NULL; 37 | static int num_exts_i = 0; 38 | static char **exts_i = NULL; 39 | 40 | static int get_exts(void) { 41 | #ifdef _GLAD_IS_SOME_NEW_VERSION 42 | if(max_loaded_major < 3) { 43 | #endif 44 | exts = (const char *)glGetString(GL_EXTENSIONS); 45 | #ifdef _GLAD_IS_SOME_NEW_VERSION 46 | } else { 47 | unsigned int index; 48 | 49 | num_exts_i = 0; 50 | glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i); 51 | if (num_exts_i > 0) { 52 | exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i)); 53 | } 54 | 55 | if (exts_i == NULL) { 56 | return 0; 57 | } 58 | 59 | for(index = 0; index < (unsigned)num_exts_i; index++) { 60 | const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index); 61 | size_t len = strlen(gl_str_tmp); 62 | 63 | char *local_str = (char*)malloc((len+1) * sizeof(char)); 64 | if(local_str != NULL) { 65 | memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char)); 66 | } 67 | exts_i[index] = local_str; 68 | } 69 | } 70 | #endif 71 | return 1; 72 | } 73 | 74 | static void free_exts(void) { 75 | if (exts_i != NULL) { 76 | int index; 77 | for(index = 0; index < num_exts_i; index++) { 78 | free((char *)exts_i[index]); 79 | } 80 | free((void *)exts_i); 81 | exts_i = NULL; 82 | } 83 | } 84 | 85 | static int has_ext(const char *ext) { 86 | #ifdef _GLAD_IS_SOME_NEW_VERSION 87 | if(max_loaded_major < 3) { 88 | #endif 89 | const char *extensions; 90 | const char *loc; 91 | const char *terminator; 92 | extensions = exts; 93 | if(extensions == NULL || ext == NULL) { 94 | return 0; 95 | } 96 | 97 | while(1) { 98 | loc = strstr(extensions, ext); 99 | if(loc == NULL) { 100 | return 0; 101 | } 102 | 103 | terminator = loc + strlen(ext); 104 | if((loc == extensions || *(loc - 1) == ' ') && 105 | (*terminator == ' ' || *terminator == '\0')) { 106 | return 1; 107 | } 108 | extensions = terminator; 109 | } 110 | #ifdef _GLAD_IS_SOME_NEW_VERSION 111 | } else { 112 | int index; 113 | if(exts_i == NULL) return 0; 114 | for(index = 0; index < num_exts_i; index++) { 115 | const char *e = exts_i[index]; 116 | 117 | if(exts_i[index] != NULL && strcmp(e, ext) == 0) { 118 | return 1; 119 | } 120 | } 121 | } 122 | #endif 123 | 124 | return 0; 125 | } 126 | int GLAD_GL_VERSION_1_0 = 0; 127 | int GLAD_GL_VERSION_1_1 = 0; 128 | int GLAD_GL_VERSION_1_2 = 0; 129 | int GLAD_GL_VERSION_1_3 = 0; 130 | int GLAD_GL_VERSION_1_4 = 0; 131 | int GLAD_GL_VERSION_1_5 = 0; 132 | int GLAD_GL_VERSION_2_0 = 0; 133 | int GLAD_GL_VERSION_2_1 = 0; 134 | int GLAD_GL_VERSION_3_0 = 0; 135 | PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; 136 | PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; 137 | PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL; 138 | PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL; 139 | PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL; 140 | PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; 141 | PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; 142 | PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL; 143 | PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL; 144 | PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL; 145 | PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; 146 | PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; 147 | PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; 148 | PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL; 149 | PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; 150 | PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; 151 | PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; 152 | PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; 153 | PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; 154 | PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL; 155 | PFNGLBUFFERDATAPROC glad_glBufferData = NULL; 156 | PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; 157 | PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; 158 | PFNGLCLAMPCOLORPROC glad_glClampColor = NULL; 159 | PFNGLCLEARPROC glad_glClear = NULL; 160 | PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL; 161 | PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL; 162 | PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL; 163 | PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL; 164 | PFNGLCLEARCOLORPROC glad_glClearColor = NULL; 165 | PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL; 166 | PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; 167 | PFNGLCOLORMASKPROC glad_glColorMask = NULL; 168 | PFNGLCOLORMASKIPROC glad_glColorMaski = NULL; 169 | PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; 170 | PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL; 171 | PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; 172 | PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL; 173 | PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL; 174 | PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; 175 | PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL; 176 | PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL; 177 | PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; 178 | PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL; 179 | PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; 180 | PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL; 181 | PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; 182 | PFNGLCREATESHADERPROC glad_glCreateShader = NULL; 183 | PFNGLCULLFACEPROC glad_glCullFace = NULL; 184 | PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; 185 | PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; 186 | PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; 187 | PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL; 188 | PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; 189 | PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; 190 | PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; 191 | PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL; 192 | PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; 193 | PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; 194 | PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL; 195 | PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; 196 | PFNGLDISABLEPROC glad_glDisable = NULL; 197 | PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; 198 | PFNGLDISABLEIPROC glad_glDisablei = NULL; 199 | PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; 200 | PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL; 201 | PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL; 202 | PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; 203 | PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL; 204 | PFNGLENABLEPROC glad_glEnable = NULL; 205 | PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; 206 | PFNGLENABLEIPROC glad_glEnablei = NULL; 207 | PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL; 208 | PFNGLENDQUERYPROC glad_glEndQuery = NULL; 209 | PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL; 210 | PFNGLFINISHPROC glad_glFinish = NULL; 211 | PFNGLFLUSHPROC glad_glFlush = NULL; 212 | PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL; 213 | PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; 214 | PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL; 215 | PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; 216 | PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL; 217 | PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL; 218 | PFNGLFRONTFACEPROC glad_glFrontFace = NULL; 219 | PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; 220 | PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; 221 | PFNGLGENQUERIESPROC glad_glGenQueries = NULL; 222 | PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; 223 | PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; 224 | PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL; 225 | PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; 226 | PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; 227 | PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; 228 | PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; 229 | PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; 230 | PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL; 231 | PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; 232 | PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; 233 | PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL; 234 | PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL; 235 | PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL; 236 | PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL; 237 | PFNGLGETERRORPROC glad_glGetError = NULL; 238 | PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; 239 | PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL; 240 | PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; 241 | PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL; 242 | PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; 243 | PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; 244 | PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; 245 | PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL; 246 | PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL; 247 | PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL; 248 | PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; 249 | PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; 250 | PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; 251 | PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; 252 | PFNGLGETSTRINGPROC glad_glGetString = NULL; 253 | PFNGLGETSTRINGIPROC glad_glGetStringi = NULL; 254 | PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL; 255 | PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL; 256 | PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL; 257 | PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL; 258 | PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL; 259 | PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; 260 | PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; 261 | PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL; 262 | PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; 263 | PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; 264 | PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; 265 | PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL; 266 | PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL; 267 | PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL; 268 | PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; 269 | PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL; 270 | PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; 271 | PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; 272 | PFNGLHINTPROC glad_glHint = NULL; 273 | PFNGLISBUFFERPROC glad_glIsBuffer = NULL; 274 | PFNGLISENABLEDPROC glad_glIsEnabled = NULL; 275 | PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL; 276 | PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; 277 | PFNGLISPROGRAMPROC glad_glIsProgram = NULL; 278 | PFNGLISQUERYPROC glad_glIsQuery = NULL; 279 | PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; 280 | PFNGLISSHADERPROC glad_glIsShader = NULL; 281 | PFNGLISTEXTUREPROC glad_glIsTexture = NULL; 282 | PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL; 283 | PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; 284 | PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; 285 | PFNGLLOGICOPPROC glad_glLogicOp = NULL; 286 | PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL; 287 | PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL; 288 | PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL; 289 | PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL; 290 | PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL; 291 | PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; 292 | PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL; 293 | PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL; 294 | PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL; 295 | PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL; 296 | PFNGLPOINTSIZEPROC glad_glPointSize = NULL; 297 | PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL; 298 | PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; 299 | PFNGLREADBUFFERPROC glad_glReadBuffer = NULL; 300 | PFNGLREADPIXELSPROC glad_glReadPixels = NULL; 301 | PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; 302 | PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL; 303 | PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; 304 | PFNGLSCISSORPROC glad_glScissor = NULL; 305 | PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; 306 | PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; 307 | PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; 308 | PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; 309 | PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; 310 | PFNGLSTENCILOPPROC glad_glStencilOp = NULL; 311 | PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; 312 | PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL; 313 | PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; 314 | PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL; 315 | PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL; 316 | PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL; 317 | PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; 318 | PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; 319 | PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; 320 | PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; 321 | PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL; 322 | PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; 323 | PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL; 324 | PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL; 325 | PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; 326 | PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; 327 | PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; 328 | PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; 329 | PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL; 330 | PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL; 331 | PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; 332 | PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; 333 | PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; 334 | PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; 335 | PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL; 336 | PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL; 337 | PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; 338 | PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; 339 | PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; 340 | PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; 341 | PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL; 342 | PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL; 343 | PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; 344 | PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; 345 | PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; 346 | PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; 347 | PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL; 348 | PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL; 349 | PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; 350 | PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL; 351 | PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL; 352 | PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; 353 | PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL; 354 | PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL; 355 | PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; 356 | PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL; 357 | PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL; 358 | PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL; 359 | PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; 360 | PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; 361 | PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL; 362 | PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL; 363 | PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; 364 | PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; 365 | PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL; 366 | PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL; 367 | PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL; 368 | PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL; 369 | PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; 370 | PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; 371 | PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL; 372 | PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL; 373 | PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL; 374 | PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL; 375 | PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; 376 | PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; 377 | PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL; 378 | PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL; 379 | PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL; 380 | PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL; 381 | PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL; 382 | PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL; 383 | PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL; 384 | PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL; 385 | PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL; 386 | PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL; 387 | PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL; 388 | PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL; 389 | PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; 390 | PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; 391 | PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL; 392 | PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL; 393 | PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL; 394 | PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL; 395 | PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL; 396 | PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL; 397 | PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL; 398 | PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL; 399 | PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL; 400 | PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL; 401 | PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL; 402 | PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL; 403 | PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL; 404 | PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL; 405 | PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL; 406 | PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL; 407 | PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL; 408 | PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL; 409 | PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL; 410 | PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL; 411 | PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL; 412 | PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL; 413 | PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL; 414 | PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL; 415 | PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL; 416 | PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL; 417 | PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL; 418 | PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; 419 | PFNGLVIEWPORTPROC glad_glViewport = NULL; 420 | static void load_GL_VERSION_1_0(GLADloadproc load) { 421 | if(!GLAD_GL_VERSION_1_0) return; 422 | glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace"); 423 | glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace"); 424 | glad_glHint = (PFNGLHINTPROC)load("glHint"); 425 | glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth"); 426 | glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize"); 427 | glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode"); 428 | glad_glScissor = (PFNGLSCISSORPROC)load("glScissor"); 429 | glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf"); 430 | glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv"); 431 | glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri"); 432 | glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv"); 433 | glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D"); 434 | glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D"); 435 | glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer"); 436 | glad_glClear = (PFNGLCLEARPROC)load("glClear"); 437 | glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor"); 438 | glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil"); 439 | glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth"); 440 | glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask"); 441 | glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask"); 442 | glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask"); 443 | glad_glDisable = (PFNGLDISABLEPROC)load("glDisable"); 444 | glad_glEnable = (PFNGLENABLEPROC)load("glEnable"); 445 | glad_glFinish = (PFNGLFINISHPROC)load("glFinish"); 446 | glad_glFlush = (PFNGLFLUSHPROC)load("glFlush"); 447 | glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc"); 448 | glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp"); 449 | glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc"); 450 | glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp"); 451 | glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc"); 452 | glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref"); 453 | glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei"); 454 | glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer"); 455 | glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels"); 456 | glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv"); 457 | glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev"); 458 | glad_glGetError = (PFNGLGETERRORPROC)load("glGetError"); 459 | glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv"); 460 | glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv"); 461 | glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); 462 | glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage"); 463 | glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv"); 464 | glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv"); 465 | glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv"); 466 | glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv"); 467 | glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled"); 468 | glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange"); 469 | glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport"); 470 | } 471 | static void load_GL_VERSION_1_1(GLADloadproc load) { 472 | if(!GLAD_GL_VERSION_1_1) return; 473 | glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays"); 474 | glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements"); 475 | glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset"); 476 | glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D"); 477 | glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D"); 478 | glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D"); 479 | glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D"); 480 | glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D"); 481 | glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D"); 482 | glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture"); 483 | glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures"); 484 | glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures"); 485 | glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture"); 486 | } 487 | static void load_GL_VERSION_1_2(GLADloadproc load) { 488 | if(!GLAD_GL_VERSION_1_2) return; 489 | glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements"); 490 | glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D"); 491 | glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D"); 492 | glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D"); 493 | } 494 | static void load_GL_VERSION_1_3(GLADloadproc load) { 495 | if(!GLAD_GL_VERSION_1_3) return; 496 | glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture"); 497 | glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage"); 498 | glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D"); 499 | glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D"); 500 | glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D"); 501 | glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D"); 502 | glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D"); 503 | glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D"); 504 | glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage"); 505 | } 506 | static void load_GL_VERSION_1_4(GLADloadproc load) { 507 | if(!GLAD_GL_VERSION_1_4) return; 508 | glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate"); 509 | glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays"); 510 | glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements"); 511 | glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf"); 512 | glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv"); 513 | glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri"); 514 | glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv"); 515 | glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor"); 516 | glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation"); 517 | } 518 | static void load_GL_VERSION_1_5(GLADloadproc load) { 519 | if(!GLAD_GL_VERSION_1_5) return; 520 | glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries"); 521 | glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries"); 522 | glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery"); 523 | glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery"); 524 | glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery"); 525 | glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv"); 526 | glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv"); 527 | glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv"); 528 | glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer"); 529 | glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers"); 530 | glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers"); 531 | glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer"); 532 | glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData"); 533 | glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData"); 534 | glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData"); 535 | glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer"); 536 | glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer"); 537 | glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv"); 538 | glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv"); 539 | } 540 | static void load_GL_VERSION_2_0(GLADloadproc load) { 541 | if(!GLAD_GL_VERSION_2_0) return; 542 | glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate"); 543 | glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers"); 544 | glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate"); 545 | glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate"); 546 | glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate"); 547 | glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader"); 548 | glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation"); 549 | glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader"); 550 | glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram"); 551 | glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader"); 552 | glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram"); 553 | glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader"); 554 | glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader"); 555 | glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray"); 556 | glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray"); 557 | glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib"); 558 | glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform"); 559 | glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders"); 560 | glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation"); 561 | glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv"); 562 | glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog"); 563 | glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv"); 564 | glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog"); 565 | glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource"); 566 | glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation"); 567 | glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv"); 568 | glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv"); 569 | glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv"); 570 | glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv"); 571 | glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv"); 572 | glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv"); 573 | glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram"); 574 | glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader"); 575 | glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram"); 576 | glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource"); 577 | glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram"); 578 | glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f"); 579 | glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f"); 580 | glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f"); 581 | glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f"); 582 | glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i"); 583 | glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i"); 584 | glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i"); 585 | glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i"); 586 | glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv"); 587 | glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv"); 588 | glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv"); 589 | glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv"); 590 | glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv"); 591 | glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv"); 592 | glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv"); 593 | glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv"); 594 | glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv"); 595 | glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv"); 596 | glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv"); 597 | glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram"); 598 | glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d"); 599 | glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv"); 600 | glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f"); 601 | glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv"); 602 | glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s"); 603 | glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv"); 604 | glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d"); 605 | glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv"); 606 | glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f"); 607 | glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv"); 608 | glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s"); 609 | glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv"); 610 | glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d"); 611 | glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv"); 612 | glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f"); 613 | glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv"); 614 | glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s"); 615 | glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv"); 616 | glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv"); 617 | glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv"); 618 | glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv"); 619 | glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub"); 620 | glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv"); 621 | glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv"); 622 | glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv"); 623 | glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv"); 624 | glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d"); 625 | glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv"); 626 | glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f"); 627 | glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv"); 628 | glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv"); 629 | glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s"); 630 | glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv"); 631 | glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv"); 632 | glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv"); 633 | glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv"); 634 | glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer"); 635 | } 636 | static void load_GL_VERSION_2_1(GLADloadproc load) { 637 | if(!GLAD_GL_VERSION_2_1) return; 638 | glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv"); 639 | glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv"); 640 | glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv"); 641 | glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv"); 642 | glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv"); 643 | glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv"); 644 | } 645 | static void load_GL_VERSION_3_0(GLADloadproc load) { 646 | if(!GLAD_GL_VERSION_3_0) return; 647 | glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski"); 648 | glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v"); 649 | glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); 650 | glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei"); 651 | glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei"); 652 | glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi"); 653 | glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback"); 654 | glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback"); 655 | glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); 656 | glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); 657 | glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings"); 658 | glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying"); 659 | glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor"); 660 | glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender"); 661 | glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender"); 662 | glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer"); 663 | glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv"); 664 | glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv"); 665 | glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i"); 666 | glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i"); 667 | glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i"); 668 | glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i"); 669 | glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui"); 670 | glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui"); 671 | glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui"); 672 | glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui"); 673 | glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv"); 674 | glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv"); 675 | glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv"); 676 | glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv"); 677 | glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv"); 678 | glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv"); 679 | glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv"); 680 | glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv"); 681 | glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv"); 682 | glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv"); 683 | glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv"); 684 | glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv"); 685 | glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv"); 686 | glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation"); 687 | glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation"); 688 | glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui"); 689 | glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui"); 690 | glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui"); 691 | glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui"); 692 | glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv"); 693 | glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv"); 694 | glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv"); 695 | glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv"); 696 | glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv"); 697 | glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv"); 698 | glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv"); 699 | glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv"); 700 | glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv"); 701 | glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv"); 702 | glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv"); 703 | glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi"); 704 | glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi"); 705 | glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer"); 706 | glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer"); 707 | glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers"); 708 | glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers"); 709 | glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage"); 710 | glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv"); 711 | glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer"); 712 | glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer"); 713 | glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers"); 714 | glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers"); 715 | glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus"); 716 | glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D"); 717 | glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D"); 718 | glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D"); 719 | glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer"); 720 | glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv"); 721 | glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap"); 722 | glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer"); 723 | glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample"); 724 | glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer"); 725 | glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange"); 726 | glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange"); 727 | glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray"); 728 | glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays"); 729 | glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays"); 730 | glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray"); 731 | } 732 | static int find_extensionsGL(void) { 733 | if (!get_exts()) return 0; 734 | (void)&has_ext; 735 | free_exts(); 736 | return 1; 737 | } 738 | 739 | static void find_coreGL(void) { 740 | 741 | /* Thank you @elmindreda 742 | * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176 743 | * https://github.com/glfw/glfw/blob/master/src/context.c#L36 744 | */ 745 | int i, major, minor; 746 | 747 | const char* version; 748 | const char* prefixes[] = { 749 | "OpenGL ES-CM ", 750 | "OpenGL ES-CL ", 751 | "OpenGL ES ", 752 | NULL 753 | }; 754 | 755 | version = (const char*) glGetString(GL_VERSION); 756 | if (!version) return; 757 | 758 | for (i = 0; prefixes[i]; i++) { 759 | const size_t length = strlen(prefixes[i]); 760 | if (strncmp(version, prefixes[i], length) == 0) { 761 | version += length; 762 | break; 763 | } 764 | } 765 | 766 | /* PR #18 */ 767 | #ifdef _MSC_VER 768 | sscanf_s(version, "%d.%d", &major, &minor); 769 | #else 770 | sscanf(version, "%d.%d", &major, &minor); 771 | #endif 772 | 773 | GLVersion.major = major; GLVersion.minor = minor; 774 | max_loaded_major = major; max_loaded_minor = minor; 775 | GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; 776 | GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; 777 | GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; 778 | GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; 779 | GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; 780 | GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; 781 | GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; 782 | GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; 783 | GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; 784 | if (GLVersion.major > 3 || (GLVersion.major >= 3 && GLVersion.minor >= 0)) { 785 | max_loaded_major = 3; 786 | max_loaded_minor = 0; 787 | } 788 | } 789 | 790 | int gladLoadGLLoader(GLADloadproc load) { 791 | GLVersion.major = 0; GLVersion.minor = 0; 792 | glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); 793 | if(glGetString == NULL) return 0; 794 | if(glGetString(GL_VERSION) == NULL) return 0; 795 | find_coreGL(); 796 | load_GL_VERSION_1_0(load); 797 | load_GL_VERSION_1_1(load); 798 | load_GL_VERSION_1_2(load); 799 | load_GL_VERSION_1_3(load); 800 | load_GL_VERSION_1_4(load); 801 | load_GL_VERSION_1_5(load); 802 | load_GL_VERSION_2_0(load); 803 | load_GL_VERSION_2_1(load); 804 | load_GL_VERSION_3_0(load); 805 | 806 | if (!find_extensionsGL()) return 0; 807 | return GLVersion.major != 0 || GLVersion.minor != 0; 808 | } 809 | 810 | -------------------------------------------------------------------------------- /imgui/backends/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only). 8 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values are obsolete since 1.87 and not supported since 1.91.5] 9 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 10 | // [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 11 | // Missing features or Issues: 12 | // [ ] Touch events are only correctly identified as Touch on Windows. This create issues with some interactions. GLFW doesn't provide a way to identify touch inputs from mouse inputs, we cannot call io.AddMouseSourceEvent() to identify the source. We provide a Windows-specific workaround. 13 | // [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors. 14 | 15 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 16 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 17 | // Learn about Dear ImGui: 18 | // - FAQ https://dearimgui.com/faq 19 | // - Getting Started https://dearimgui.com/getting-started 20 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 21 | // - Introduction, links and more at the top of imgui.cpp 22 | 23 | #pragma once 24 | #include "imgui.h" // IMGUI_IMPL_API 25 | #ifndef IMGUI_DISABLE 26 | 27 | struct GLFWwindow; 28 | struct GLFWmonitor; 29 | 30 | // Follow "Getting Started" link and check examples/ folder to learn about using backends! 31 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 32 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 33 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); 34 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 35 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 36 | 37 | // Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL) 38 | #ifdef __EMSCRIPTEN__ 39 | IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector); 40 | //static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0 41 | #endif 42 | 43 | // GLFW callbacks install 44 | // - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any. 45 | // - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks. 46 | IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window); 47 | IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window); 48 | 49 | // GFLW callbacks options: 50 | // - Set 'chain_for_all_windows=true' to enable chaining callbacks for all windows (including secondary viewports created by backends or by user) 51 | IMGUI_IMPL_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows); 52 | 53 | // GLFW callbacks (individual callbacks to call yourself if you didn't install callbacks) 54 | IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84 55 | IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84 56 | IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87 57 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 58 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 59 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 60 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 61 | IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event); 62 | 63 | // GLFW helpers 64 | IMGUI_IMPL_API void ImGui_ImplGlfw_Sleep(int milliseconds); 65 | 66 | #endif // #ifndef IMGUI_DISABLE 67 | -------------------------------------------------------------------------------- /imgui/backends/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 2.x 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! 8 | // [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!] 9 | 10 | // About WebGL/ES: 11 | // - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES. 12 | // - This is done automatically on iOS, Android and Emscripten targets. 13 | // - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h. 14 | 15 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 16 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 17 | // Learn about Dear ImGui: 18 | // - FAQ https://dearimgui.com/faq 19 | // - Getting Started https://dearimgui.com/getting-started 20 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 21 | // - Introduction, links and more at the top of imgui.cpp 22 | 23 | // About GLSL version: 24 | // The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string. 25 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 26 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 27 | 28 | #pragma once 29 | #include "imgui.h" // IMGUI_IMPL_API 30 | #ifndef IMGUI_DISABLE 31 | 32 | // Follow "Getting Started" link and check examples/ folder to learn about using backends! 33 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr); 34 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 35 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 36 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 37 | 38 | // (Optional) Called by Init/NewFrame/Shutdown 39 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 40 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 41 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 42 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 43 | 44 | // Configuration flags to add in your imconfig file: 45 | //#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten) 46 | //#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android) 47 | 48 | // You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. 49 | #if !defined(IMGUI_IMPL_OPENGL_ES2) \ 50 | && !defined(IMGUI_IMPL_OPENGL_ES3) 51 | 52 | // Try to detect GLES on matching platforms 53 | #if defined(__APPLE__) 54 | #include 55 | #endif 56 | #if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__)) 57 | #define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es" 58 | #elif defined(__EMSCRIPTEN__) || defined(__amigaos4__) 59 | #define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100" 60 | #else 61 | // Otherwise imgui_impl_opengl3_loader.h will be used. 62 | #endif 63 | 64 | #endif 65 | 66 | #endif // #ifndef IMGUI_DISABLE 67 | -------------------------------------------------------------------------------- /imgui/backends/imgui_impl_opengl3_loader.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // About imgui_impl_opengl3_loader.h: 3 | // 4 | // We embed our own OpenGL loader to not require user to provide their own or to have to use ours, 5 | // which proved to be endless problems for users. 6 | // Our loader is custom-generated, based on gl3w but automatically filtered to only include 7 | // enums/functions that we use in our imgui_impl_opengl3.cpp source file in order to be small. 8 | // 9 | // YOU SHOULD NOT NEED TO INCLUDE/USE THIS DIRECTLY. THIS IS USED BY imgui_impl_opengl3.cpp ONLY. 10 | // THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE. 11 | // 12 | // IF YOU GET BUILD ERRORS IN THIS FILE (commonly macro redefinitions or function redefinitions): 13 | // IT LIKELY MEANS THAT YOU ARE BUILDING 'imgui_impl_opengl3.cpp' OR INCLUDING 'imgui_impl_opengl3_loader.h' 14 | // IN THE SAME COMPILATION UNIT AS ONE OF YOUR FILE WHICH IS USING A THIRD-PARTY OPENGL LOADER. 15 | // (e.g. COULD HAPPEN IF YOU ARE DOING A UNITY/JUMBO BUILD, OR INCLUDING .CPP FILES FROM OTHERS) 16 | // YOU SHOULD NOT BUILD BOTH IN THE SAME COMPILATION UNIT. 17 | // BUT IF YOU REALLY WANT TO, you can '#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM' and imgui_impl_opengl3.cpp 18 | // WILL NOT BE USING OUR LOADER, AND INSTEAD EXPECT ANOTHER/YOUR LOADER TO BE AVAILABLE IN THE COMPILATION UNIT. 19 | // 20 | // Regenerate with: 21 | // python3 gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt 22 | // 23 | // More info: 24 | // https://github.com/dearimgui/gl3w_stripped 25 | // https://github.com/ocornut/imgui/issues/4445 26 | //----------------------------------------------------------------------------- 27 | 28 | /* 29 | * This file was generated with gl3w_gen.py, part of imgl3w 30 | * (hosted at https://github.com/dearimgui/gl3w_stripped) 31 | * 32 | * This is free and unencumbered software released into the public domain. 33 | * 34 | * Anyone is free to copy, modify, publish, use, compile, sell, or 35 | * distribute this software, either in source code form or as a compiled 36 | * binary, for any purpose, commercial or non-commercial, and by any 37 | * means. 38 | * 39 | * In jurisdictions that recognize copyright laws, the author or authors 40 | * of this software dedicate any and all copyright interest in the 41 | * software to the public domain. We make this dedication for the benefit 42 | * of the public at large and to the detriment of our heirs and 43 | * successors. We intend this dedication to be an overt act of 44 | * relinquishment in perpetuity of all present and future rights to this 45 | * software under copyright law. 46 | * 47 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 48 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 49 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 50 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 51 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 52 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 53 | * OTHER DEALINGS IN THE SOFTWARE. 54 | */ 55 | 56 | #ifndef __gl3w_h_ 57 | #define __gl3w_h_ 58 | 59 | // Adapted from KHR/khrplatform.h to avoid including entire file. 60 | #ifndef __khrplatform_h_ 61 | typedef float khronos_float_t; 62 | typedef signed char khronos_int8_t; 63 | typedef unsigned char khronos_uint8_t; 64 | typedef signed short int khronos_int16_t; 65 | typedef unsigned short int khronos_uint16_t; 66 | #ifdef _WIN64 67 | typedef signed long long int khronos_intptr_t; 68 | typedef signed long long int khronos_ssize_t; 69 | #else 70 | typedef signed long int khronos_intptr_t; 71 | typedef signed long int khronos_ssize_t; 72 | #endif 73 | 74 | #if defined(_MSC_VER) && !defined(__clang__) 75 | typedef signed __int64 khronos_int64_t; 76 | typedef unsigned __int64 khronos_uint64_t; 77 | #elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) 78 | #include 79 | typedef int64_t khronos_int64_t; 80 | typedef uint64_t khronos_uint64_t; 81 | #else 82 | typedef signed long long khronos_int64_t; 83 | typedef unsigned long long khronos_uint64_t; 84 | #endif 85 | #endif // __khrplatform_h_ 86 | 87 | #ifndef __gl_glcorearb_h_ 88 | #define __gl_glcorearb_h_ 1 89 | #ifdef __cplusplus 90 | extern "C" { 91 | #endif 92 | /* 93 | ** Copyright 2013-2020 The Khronos Group Inc. 94 | ** SPDX-License-Identifier: MIT 95 | ** 96 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML 97 | ** API Registry. The current version of the Registry, generator scripts 98 | ** used to make the header, and the header can be found at 99 | ** https://github.com/KhronosGroup/OpenGL-Registry 100 | */ 101 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 102 | #ifndef WIN32_LEAN_AND_MEAN 103 | #define WIN32_LEAN_AND_MEAN 1 104 | #endif 105 | #include 106 | #endif 107 | #ifndef APIENTRY 108 | #define APIENTRY 109 | #endif 110 | #ifndef APIENTRYP 111 | #define APIENTRYP APIENTRY * 112 | #endif 113 | #ifndef GLAPI 114 | #define GLAPI extern 115 | #endif 116 | /* glcorearb.h is for use with OpenGL core profile implementations. 117 | ** It should should be placed in the same directory as gl.h and 118 | ** included as . 119 | ** 120 | ** glcorearb.h includes only APIs in the latest OpenGL core profile 121 | ** implementation together with APIs in newer ARB extensions which 122 | ** can be supported by the core profile. It does not, and never will 123 | ** include functionality removed from the core profile, such as 124 | ** fixed-function vertex and fragment processing. 125 | ** 126 | ** Do not #include both and either of or 127 | ** in the same source file. 128 | */ 129 | /* Generated C header for: 130 | * API: gl 131 | * Profile: core 132 | * Versions considered: .* 133 | * Versions emitted: .* 134 | * Default extensions included: glcore 135 | * Additional extensions included: _nomatch_^ 136 | * Extensions removed: _nomatch_^ 137 | */ 138 | #ifndef GL_VERSION_1_0 139 | typedef void GLvoid; 140 | typedef unsigned int GLenum; 141 | 142 | typedef khronos_float_t GLfloat; 143 | typedef int GLint; 144 | typedef int GLsizei; 145 | typedef unsigned int GLbitfield; 146 | typedef double GLdouble; 147 | typedef unsigned int GLuint; 148 | typedef unsigned char GLboolean; 149 | typedef khronos_uint8_t GLubyte; 150 | #define GL_COLOR_BUFFER_BIT 0x00004000 151 | #define GL_FALSE 0 152 | #define GL_TRUE 1 153 | #define GL_TRIANGLES 0x0004 154 | #define GL_ONE 1 155 | #define GL_SRC_ALPHA 0x0302 156 | #define GL_ONE_MINUS_SRC_ALPHA 0x0303 157 | #define GL_FRONT 0x0404 158 | #define GL_BACK 0x0405 159 | #define GL_FRONT_AND_BACK 0x0408 160 | #define GL_POLYGON_MODE 0x0B40 161 | #define GL_CULL_FACE 0x0B44 162 | #define GL_DEPTH_TEST 0x0B71 163 | #define GL_STENCIL_TEST 0x0B90 164 | #define GL_VIEWPORT 0x0BA2 165 | #define GL_BLEND 0x0BE2 166 | #define GL_SCISSOR_BOX 0x0C10 167 | #define GL_SCISSOR_TEST 0x0C11 168 | #define GL_UNPACK_ROW_LENGTH 0x0CF2 169 | #define GL_PACK_ALIGNMENT 0x0D05 170 | #define GL_TEXTURE_2D 0x0DE1 171 | #define GL_UNSIGNED_BYTE 0x1401 172 | #define GL_UNSIGNED_SHORT 0x1403 173 | #define GL_UNSIGNED_INT 0x1405 174 | #define GL_FLOAT 0x1406 175 | #define GL_RGBA 0x1908 176 | #define GL_FILL 0x1B02 177 | #define GL_VENDOR 0x1F00 178 | #define GL_RENDERER 0x1F01 179 | #define GL_VERSION 0x1F02 180 | #define GL_EXTENSIONS 0x1F03 181 | #define GL_LINEAR 0x2601 182 | #define GL_TEXTURE_MAG_FILTER 0x2800 183 | #define GL_TEXTURE_MIN_FILTER 0x2801 184 | #define GL_TEXTURE_WRAP_S 0x2802 185 | #define GL_TEXTURE_WRAP_T 0x2803 186 | #define GL_REPEAT 0x2901 187 | typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); 188 | typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); 189 | typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); 190 | typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); 191 | typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); 192 | typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 193 | typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); 194 | typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); 195 | typedef void (APIENTRYP PFNGLFLUSHPROC) (void); 196 | typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); 197 | typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); 198 | typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); 199 | typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); 200 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); 201 | typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); 202 | typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); 203 | #ifdef GL_GLEXT_PROTOTYPES 204 | GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); 205 | GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); 206 | GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); 207 | GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); 208 | GLAPI void APIENTRY glClear (GLbitfield mask); 209 | GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 210 | GLAPI void APIENTRY glDisable (GLenum cap); 211 | GLAPI void APIENTRY glEnable (GLenum cap); 212 | GLAPI void APIENTRY glFlush (void); 213 | GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); 214 | GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); 215 | GLAPI GLenum APIENTRY glGetError (void); 216 | GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); 217 | GLAPI const GLubyte *APIENTRY glGetString (GLenum name); 218 | GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); 219 | GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); 220 | #endif 221 | #endif /* GL_VERSION_1_0 */ 222 | #ifndef GL_VERSION_1_1 223 | typedef khronos_float_t GLclampf; 224 | typedef double GLclampd; 225 | #define GL_TEXTURE_BINDING_2D 0x8069 226 | typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); 227 | typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); 228 | typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); 229 | typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); 230 | #ifdef GL_GLEXT_PROTOTYPES 231 | GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); 232 | GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); 233 | GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); 234 | GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); 235 | #endif 236 | #endif /* GL_VERSION_1_1 */ 237 | #ifndef GL_VERSION_1_2 238 | #define GL_CLAMP_TO_EDGE 0x812F 239 | #endif /* GL_VERSION_1_2 */ 240 | #ifndef GL_VERSION_1_3 241 | #define GL_TEXTURE0 0x84C0 242 | #define GL_ACTIVE_TEXTURE 0x84E0 243 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); 244 | #ifdef GL_GLEXT_PROTOTYPES 245 | GLAPI void APIENTRY glActiveTexture (GLenum texture); 246 | #endif 247 | #endif /* GL_VERSION_1_3 */ 248 | #ifndef GL_VERSION_1_4 249 | #define GL_BLEND_DST_RGB 0x80C8 250 | #define GL_BLEND_SRC_RGB 0x80C9 251 | #define GL_BLEND_DST_ALPHA 0x80CA 252 | #define GL_BLEND_SRC_ALPHA 0x80CB 253 | #define GL_FUNC_ADD 0x8006 254 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 255 | typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); 256 | #ifdef GL_GLEXT_PROTOTYPES 257 | GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 258 | GLAPI void APIENTRY glBlendEquation (GLenum mode); 259 | #endif 260 | #endif /* GL_VERSION_1_4 */ 261 | #ifndef GL_VERSION_1_5 262 | typedef khronos_ssize_t GLsizeiptr; 263 | typedef khronos_intptr_t GLintptr; 264 | #define GL_ARRAY_BUFFER 0x8892 265 | #define GL_ELEMENT_ARRAY_BUFFER 0x8893 266 | #define GL_ARRAY_BUFFER_BINDING 0x8894 267 | #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 268 | #define GL_STREAM_DRAW 0x88E0 269 | typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); 270 | typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); 271 | typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); 272 | typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); 273 | typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); 274 | #ifdef GL_GLEXT_PROTOTYPES 275 | GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); 276 | GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); 277 | GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); 278 | GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); 279 | GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); 280 | #endif 281 | #endif /* GL_VERSION_1_5 */ 282 | #ifndef GL_VERSION_2_0 283 | typedef char GLchar; 284 | typedef khronos_int16_t GLshort; 285 | typedef khronos_int8_t GLbyte; 286 | typedef khronos_uint16_t GLushort; 287 | #define GL_BLEND_EQUATION_RGB 0x8009 288 | #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 289 | #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 290 | #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 291 | #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 292 | #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 293 | #define GL_BLEND_EQUATION_ALPHA 0x883D 294 | #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A 295 | #define GL_FRAGMENT_SHADER 0x8B30 296 | #define GL_VERTEX_SHADER 0x8B31 297 | #define GL_COMPILE_STATUS 0x8B81 298 | #define GL_LINK_STATUS 0x8B82 299 | #define GL_INFO_LOG_LENGTH 0x8B84 300 | #define GL_CURRENT_PROGRAM 0x8B8D 301 | #define GL_UPPER_LEFT 0x8CA2 302 | typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); 303 | typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); 304 | typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); 305 | typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); 306 | typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); 307 | typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); 308 | typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); 309 | typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); 310 | typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); 311 | typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); 312 | typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); 313 | typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); 314 | typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 315 | typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); 316 | typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 317 | typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); 318 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); 319 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); 320 | typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); 321 | typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); 322 | typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); 323 | typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); 324 | typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); 325 | typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 326 | typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); 327 | #ifdef GL_GLEXT_PROTOTYPES 328 | GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); 329 | GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); 330 | GLAPI void APIENTRY glCompileShader (GLuint shader); 331 | GLAPI GLuint APIENTRY glCreateProgram (void); 332 | GLAPI GLuint APIENTRY glCreateShader (GLenum type); 333 | GLAPI void APIENTRY glDeleteProgram (GLuint program); 334 | GLAPI void APIENTRY glDeleteShader (GLuint shader); 335 | GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); 336 | GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); 337 | GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); 338 | GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); 339 | GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); 340 | GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 341 | GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); 342 | GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 343 | GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); 344 | GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); 345 | GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); 346 | GLAPI GLboolean APIENTRY glIsProgram (GLuint program); 347 | GLAPI void APIENTRY glLinkProgram (GLuint program); 348 | GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); 349 | GLAPI void APIENTRY glUseProgram (GLuint program); 350 | GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); 351 | GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 352 | GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); 353 | #endif 354 | #endif /* GL_VERSION_2_0 */ 355 | #ifndef GL_VERSION_2_1 356 | #define GL_PIXEL_UNPACK_BUFFER 0x88EC 357 | #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF 358 | #endif /* GL_VERSION_2_1 */ 359 | #ifndef GL_VERSION_3_0 360 | typedef khronos_uint16_t GLhalf; 361 | #define GL_MAJOR_VERSION 0x821B 362 | #define GL_MINOR_VERSION 0x821C 363 | #define GL_NUM_EXTENSIONS 0x821D 364 | #define GL_FRAMEBUFFER_SRGB 0x8DB9 365 | #define GL_VERTEX_ARRAY_BINDING 0x85B5 366 | typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); 367 | typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); 368 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); 369 | typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); 370 | typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); 371 | typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); 372 | #ifdef GL_GLEXT_PROTOTYPES 373 | GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); 374 | GLAPI void APIENTRY glBindVertexArray (GLuint array); 375 | GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); 376 | GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); 377 | #endif 378 | #endif /* GL_VERSION_3_0 */ 379 | #ifndef GL_VERSION_3_1 380 | #define GL_VERSION_3_1 1 381 | #define GL_PRIMITIVE_RESTART 0x8F9D 382 | #endif /* GL_VERSION_3_1 */ 383 | #ifndef GL_VERSION_3_2 384 | #define GL_VERSION_3_2 1 385 | typedef struct __GLsync *GLsync; 386 | typedef khronos_uint64_t GLuint64; 387 | typedef khronos_int64_t GLint64; 388 | #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 389 | #define GL_CONTEXT_PROFILE_MASK 0x9126 390 | typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); 391 | typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); 392 | #ifdef GL_GLEXT_PROTOTYPES 393 | GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); 394 | #endif 395 | #endif /* GL_VERSION_3_2 */ 396 | #ifndef GL_VERSION_3_3 397 | #define GL_VERSION_3_3 1 398 | #define GL_SAMPLER_BINDING 0x8919 399 | typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); 400 | #ifdef GL_GLEXT_PROTOTYPES 401 | GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); 402 | #endif 403 | #endif /* GL_VERSION_3_3 */ 404 | #ifndef GL_VERSION_4_1 405 | typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); 406 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); 407 | #endif /* GL_VERSION_4_1 */ 408 | #ifndef GL_VERSION_4_3 409 | typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 410 | #endif /* GL_VERSION_4_3 */ 411 | #ifndef GL_VERSION_4_5 412 | #define GL_CLIP_ORIGIN 0x935C 413 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); 414 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); 415 | #endif /* GL_VERSION_4_5 */ 416 | #ifndef GL_ARB_bindless_texture 417 | typedef khronos_uint64_t GLuint64EXT; 418 | #endif /* GL_ARB_bindless_texture */ 419 | #ifndef GL_ARB_cl_event 420 | struct _cl_context; 421 | struct _cl_event; 422 | #endif /* GL_ARB_cl_event */ 423 | #ifndef GL_ARB_clip_control 424 | #define GL_ARB_clip_control 1 425 | #endif /* GL_ARB_clip_control */ 426 | #ifndef GL_ARB_debug_output 427 | typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 428 | #endif /* GL_ARB_debug_output */ 429 | #ifndef GL_EXT_EGL_image_storage 430 | typedef void *GLeglImageOES; 431 | #endif /* GL_EXT_EGL_image_storage */ 432 | #ifndef GL_EXT_direct_state_access 433 | typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); 434 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); 435 | typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); 436 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); 437 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); 438 | #endif /* GL_EXT_direct_state_access */ 439 | #ifndef GL_NV_draw_vulkan_image 440 | typedef void (APIENTRY *GLVULKANPROCNV)(void); 441 | #endif /* GL_NV_draw_vulkan_image */ 442 | #ifndef GL_NV_gpu_shader5 443 | typedef khronos_int64_t GLint64EXT; 444 | #endif /* GL_NV_gpu_shader5 */ 445 | #ifndef GL_NV_vertex_buffer_unified_memory 446 | typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); 447 | #endif /* GL_NV_vertex_buffer_unified_memory */ 448 | #ifdef __cplusplus 449 | } 450 | #endif 451 | #endif 452 | 453 | #ifndef GL3W_API 454 | #define GL3W_API 455 | #endif 456 | 457 | #ifndef __gl_h_ 458 | #define __gl_h_ 459 | #endif 460 | 461 | #ifdef __cplusplus 462 | extern "C" { 463 | #endif 464 | 465 | #define GL3W_OK 0 466 | #define GL3W_ERROR_INIT -1 467 | #define GL3W_ERROR_LIBRARY_OPEN -2 468 | #define GL3W_ERROR_OPENGL_VERSION -3 469 | 470 | typedef void (*GL3WglProc)(void); 471 | typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc); 472 | 473 | /* gl3w api */ 474 | GL3W_API int imgl3wInit(void); 475 | GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc); 476 | GL3W_API int imgl3wIsSupported(int major, int minor); 477 | GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc); 478 | 479 | /* gl3w internal state */ 480 | union ImGL3WProcs { 481 | GL3WglProc ptr[59]; 482 | struct { 483 | PFNGLACTIVETEXTUREPROC ActiveTexture; 484 | PFNGLATTACHSHADERPROC AttachShader; 485 | PFNGLBINDBUFFERPROC BindBuffer; 486 | PFNGLBINDSAMPLERPROC BindSampler; 487 | PFNGLBINDTEXTUREPROC BindTexture; 488 | PFNGLBINDVERTEXARRAYPROC BindVertexArray; 489 | PFNGLBLENDEQUATIONPROC BlendEquation; 490 | PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate; 491 | PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate; 492 | PFNGLBUFFERDATAPROC BufferData; 493 | PFNGLBUFFERSUBDATAPROC BufferSubData; 494 | PFNGLCLEARPROC Clear; 495 | PFNGLCLEARCOLORPROC ClearColor; 496 | PFNGLCOMPILESHADERPROC CompileShader; 497 | PFNGLCREATEPROGRAMPROC CreateProgram; 498 | PFNGLCREATESHADERPROC CreateShader; 499 | PFNGLDELETEBUFFERSPROC DeleteBuffers; 500 | PFNGLDELETEPROGRAMPROC DeleteProgram; 501 | PFNGLDELETESHADERPROC DeleteShader; 502 | PFNGLDELETETEXTURESPROC DeleteTextures; 503 | PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays; 504 | PFNGLDETACHSHADERPROC DetachShader; 505 | PFNGLDISABLEPROC Disable; 506 | PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray; 507 | PFNGLDRAWELEMENTSPROC DrawElements; 508 | PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex; 509 | PFNGLENABLEPROC Enable; 510 | PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; 511 | PFNGLFLUSHPROC Flush; 512 | PFNGLGENBUFFERSPROC GenBuffers; 513 | PFNGLGENTEXTURESPROC GenTextures; 514 | PFNGLGENVERTEXARRAYSPROC GenVertexArrays; 515 | PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; 516 | PFNGLGETERRORPROC GetError; 517 | PFNGLGETINTEGERVPROC GetIntegerv; 518 | PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; 519 | PFNGLGETPROGRAMIVPROC GetProgramiv; 520 | PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; 521 | PFNGLGETSHADERIVPROC GetShaderiv; 522 | PFNGLGETSTRINGPROC GetString; 523 | PFNGLGETSTRINGIPROC GetStringi; 524 | PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; 525 | PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv; 526 | PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv; 527 | PFNGLISENABLEDPROC IsEnabled; 528 | PFNGLISPROGRAMPROC IsProgram; 529 | PFNGLLINKPROGRAMPROC LinkProgram; 530 | PFNGLPIXELSTOREIPROC PixelStorei; 531 | PFNGLPOLYGONMODEPROC PolygonMode; 532 | PFNGLREADPIXELSPROC ReadPixels; 533 | PFNGLSCISSORPROC Scissor; 534 | PFNGLSHADERSOURCEPROC ShaderSource; 535 | PFNGLTEXIMAGE2DPROC TexImage2D; 536 | PFNGLTEXPARAMETERIPROC TexParameteri; 537 | PFNGLUNIFORM1IPROC Uniform1i; 538 | PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; 539 | PFNGLUSEPROGRAMPROC UseProgram; 540 | PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; 541 | PFNGLVIEWPORTPROC Viewport; 542 | } gl; 543 | }; 544 | 545 | GL3W_API extern union ImGL3WProcs imgl3wProcs; 546 | 547 | /* OpenGL functions */ 548 | #define glActiveTexture imgl3wProcs.gl.ActiveTexture 549 | #define glAttachShader imgl3wProcs.gl.AttachShader 550 | #define glBindBuffer imgl3wProcs.gl.BindBuffer 551 | #define glBindSampler imgl3wProcs.gl.BindSampler 552 | #define glBindTexture imgl3wProcs.gl.BindTexture 553 | #define glBindVertexArray imgl3wProcs.gl.BindVertexArray 554 | #define glBlendEquation imgl3wProcs.gl.BlendEquation 555 | #define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate 556 | #define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate 557 | #define glBufferData imgl3wProcs.gl.BufferData 558 | #define glBufferSubData imgl3wProcs.gl.BufferSubData 559 | #define glClear imgl3wProcs.gl.Clear 560 | #define glClearColor imgl3wProcs.gl.ClearColor 561 | #define glCompileShader imgl3wProcs.gl.CompileShader 562 | #define glCreateProgram imgl3wProcs.gl.CreateProgram 563 | #define glCreateShader imgl3wProcs.gl.CreateShader 564 | #define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers 565 | #define glDeleteProgram imgl3wProcs.gl.DeleteProgram 566 | #define glDeleteShader imgl3wProcs.gl.DeleteShader 567 | #define glDeleteTextures imgl3wProcs.gl.DeleteTextures 568 | #define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays 569 | #define glDetachShader imgl3wProcs.gl.DetachShader 570 | #define glDisable imgl3wProcs.gl.Disable 571 | #define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray 572 | #define glDrawElements imgl3wProcs.gl.DrawElements 573 | #define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex 574 | #define glEnable imgl3wProcs.gl.Enable 575 | #define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray 576 | #define glFlush imgl3wProcs.gl.Flush 577 | #define glGenBuffers imgl3wProcs.gl.GenBuffers 578 | #define glGenTextures imgl3wProcs.gl.GenTextures 579 | #define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays 580 | #define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation 581 | #define glGetError imgl3wProcs.gl.GetError 582 | #define glGetIntegerv imgl3wProcs.gl.GetIntegerv 583 | #define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog 584 | #define glGetProgramiv imgl3wProcs.gl.GetProgramiv 585 | #define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog 586 | #define glGetShaderiv imgl3wProcs.gl.GetShaderiv 587 | #define glGetString imgl3wProcs.gl.GetString 588 | #define glGetStringi imgl3wProcs.gl.GetStringi 589 | #define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation 590 | #define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv 591 | #define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv 592 | #define glIsEnabled imgl3wProcs.gl.IsEnabled 593 | #define glIsProgram imgl3wProcs.gl.IsProgram 594 | #define glLinkProgram imgl3wProcs.gl.LinkProgram 595 | #define glPixelStorei imgl3wProcs.gl.PixelStorei 596 | #define glPolygonMode imgl3wProcs.gl.PolygonMode 597 | #define glReadPixels imgl3wProcs.gl.ReadPixels 598 | #define glScissor imgl3wProcs.gl.Scissor 599 | #define glShaderSource imgl3wProcs.gl.ShaderSource 600 | #define glTexImage2D imgl3wProcs.gl.TexImage2D 601 | #define glTexParameteri imgl3wProcs.gl.TexParameteri 602 | #define glUniform1i imgl3wProcs.gl.Uniform1i 603 | #define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv 604 | #define glUseProgram imgl3wProcs.gl.UseProgram 605 | #define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer 606 | #define glViewport imgl3wProcs.gl.Viewport 607 | 608 | #ifdef __cplusplus 609 | } 610 | #endif 611 | 612 | #endif 613 | 614 | #ifdef IMGL3W_IMPL 615 | #ifdef __cplusplus 616 | extern "C" { 617 | #endif 618 | 619 | #include 620 | 621 | #define GL3W_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 622 | 623 | #if defined(_WIN32) 624 | #ifndef WIN32_LEAN_AND_MEAN 625 | #define WIN32_LEAN_AND_MEAN 1 626 | #endif 627 | #include 628 | 629 | static HMODULE libgl; 630 | typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR); 631 | static GL3WglGetProcAddr wgl_get_proc_address; 632 | 633 | static int open_libgl(void) 634 | { 635 | libgl = LoadLibraryA("opengl32.dll"); 636 | if (!libgl) 637 | return GL3W_ERROR_LIBRARY_OPEN; 638 | wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress"); 639 | return GL3W_OK; 640 | } 641 | 642 | static void close_libgl(void) { FreeLibrary(libgl); } 643 | static GL3WglProc get_proc(const char *proc) 644 | { 645 | GL3WglProc res; 646 | res = (GL3WglProc)wgl_get_proc_address(proc); 647 | if (!res) 648 | res = (GL3WglProc)GetProcAddress(libgl, proc); 649 | return res; 650 | } 651 | #elif defined(__APPLE__) 652 | #include 653 | 654 | static void *libgl; 655 | static int open_libgl(void) 656 | { 657 | libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL); 658 | if (!libgl) 659 | return GL3W_ERROR_LIBRARY_OPEN; 660 | return GL3W_OK; 661 | } 662 | 663 | static void close_libgl(void) { dlclose(libgl); } 664 | 665 | static GL3WglProc get_proc(const char *proc) 666 | { 667 | GL3WglProc res; 668 | *(void **)(&res) = dlsym(libgl, proc); 669 | return res; 670 | } 671 | #else 672 | #include 673 | 674 | static void* libgl; // OpenGL library 675 | static void* libglx; // GLX library 676 | static void* libegl; // EGL library 677 | static GL3WGetProcAddressProc gl_get_proc_address; 678 | 679 | static void close_libgl(void) 680 | { 681 | if (libgl) { 682 | dlclose(libgl); 683 | libgl = NULL; 684 | } 685 | if (libegl) { 686 | dlclose(libegl); 687 | libegl = NULL; 688 | } 689 | if (libglx) { 690 | dlclose(libglx); 691 | libglx = NULL; 692 | } 693 | } 694 | 695 | static int is_library_loaded(const char* name, void** lib) 696 | { 697 | *lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); 698 | return *lib != NULL; 699 | } 700 | 701 | static int open_libs(void) 702 | { 703 | // On Linux we have two APIs to get process addresses: EGL and GLX. 704 | // EGL is supported under both X11 and Wayland, whereas GLX is X11-specific. 705 | 706 | libgl = NULL; 707 | libegl = NULL; 708 | libglx = NULL; 709 | 710 | // First check what's already loaded, the windowing library might have 711 | // already loaded either EGL or GLX and we want to use the same one. 712 | 713 | if (is_library_loaded("libEGL.so.1", &libegl) || 714 | is_library_loaded("libGLX.so.0", &libglx)) { 715 | libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL); 716 | if (libgl) 717 | return GL3W_OK; 718 | else 719 | close_libgl(); 720 | } 721 | 722 | if (is_library_loaded("libGL.so", &libgl)) 723 | return GL3W_OK; 724 | if (is_library_loaded("libGL.so.1", &libgl)) 725 | return GL3W_OK; 726 | if (is_library_loaded("libGL.so.3", &libgl)) 727 | return GL3W_OK; 728 | 729 | // Neither is already loaded, so we have to load one. Try EGL first 730 | // because it is supported under both X11 and Wayland. 731 | 732 | // Load OpenGL + EGL 733 | libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL); 734 | libegl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL); 735 | if (libgl && libegl) 736 | return GL3W_OK; 737 | else 738 | close_libgl(); 739 | 740 | // Fall back to legacy libGL, which includes GLX 741 | // While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983 742 | libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL); 743 | if (!libgl) 744 | libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL); 745 | if (!libgl) 746 | libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL); 747 | 748 | if (libgl) 749 | return GL3W_OK; 750 | 751 | return GL3W_ERROR_LIBRARY_OPEN; 752 | } 753 | 754 | static int open_libgl(void) 755 | { 756 | int res = open_libs(); 757 | if (res) 758 | return res; 759 | 760 | if (libegl) 761 | *(void**)(&gl_get_proc_address) = dlsym(libegl, "eglGetProcAddress"); 762 | else if (libglx) 763 | *(void**)(&gl_get_proc_address) = dlsym(libglx, "glXGetProcAddressARB"); 764 | else 765 | *(void**)(&gl_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB"); 766 | 767 | if (!gl_get_proc_address) { 768 | close_libgl(); 769 | return GL3W_ERROR_LIBRARY_OPEN; 770 | } 771 | 772 | return GL3W_OK; 773 | } 774 | 775 | static GL3WglProc get_proc(const char* proc) 776 | { 777 | GL3WglProc res = NULL; 778 | 779 | // Before EGL version 1.5, eglGetProcAddress doesn't support querying core 780 | // functions and may return a dummy function if we try, so try to load the 781 | // function from the GL library directly first. 782 | if (libegl) 783 | *(void**)(&res) = dlsym(libgl, proc); 784 | 785 | if (!res) 786 | res = gl_get_proc_address(proc); 787 | 788 | if (!libegl && !res) 789 | *(void**)(&res) = dlsym(libgl, proc); 790 | 791 | return res; 792 | } 793 | #endif 794 | 795 | static struct { int major, minor; } version; 796 | 797 | static int parse_version(void) 798 | { 799 | if (!glGetIntegerv) 800 | return GL3W_ERROR_INIT; 801 | glGetIntegerv(GL_MAJOR_VERSION, &version.major); 802 | glGetIntegerv(GL_MINOR_VERSION, &version.minor); 803 | if (version.major == 0 && version.minor == 0) 804 | { 805 | // Query GL_VERSION in desktop GL 2.x, the string will start with "." 806 | if (const char* gl_version = (const char*)glGetString(GL_VERSION)) 807 | sscanf(gl_version, "%d.%d", &version.major, &version.minor); 808 | } 809 | if (version.major < 2) 810 | return GL3W_ERROR_OPENGL_VERSION; 811 | return GL3W_OK; 812 | } 813 | 814 | static void load_procs(GL3WGetProcAddressProc proc); 815 | 816 | int imgl3wInit(void) 817 | { 818 | int res = open_libgl(); 819 | if (res) 820 | return res; 821 | atexit(close_libgl); 822 | return imgl3wInit2(get_proc); 823 | } 824 | 825 | int imgl3wInit2(GL3WGetProcAddressProc proc) 826 | { 827 | load_procs(proc); 828 | return parse_version(); 829 | } 830 | 831 | int imgl3wIsSupported(int major, int minor) 832 | { 833 | if (major < 2) 834 | return 0; 835 | if (version.major == major) 836 | return version.minor >= minor; 837 | return version.major >= major; 838 | } 839 | 840 | GL3WglProc imgl3wGetProcAddress(const char *proc) { return get_proc(proc); } 841 | 842 | static const char *proc_names[] = { 843 | "glActiveTexture", 844 | "glAttachShader", 845 | "glBindBuffer", 846 | "glBindSampler", 847 | "glBindTexture", 848 | "glBindVertexArray", 849 | "glBlendEquation", 850 | "glBlendEquationSeparate", 851 | "glBlendFuncSeparate", 852 | "glBufferData", 853 | "glBufferSubData", 854 | "glClear", 855 | "glClearColor", 856 | "glCompileShader", 857 | "glCreateProgram", 858 | "glCreateShader", 859 | "glDeleteBuffers", 860 | "glDeleteProgram", 861 | "glDeleteShader", 862 | "glDeleteTextures", 863 | "glDeleteVertexArrays", 864 | "glDetachShader", 865 | "glDisable", 866 | "glDisableVertexAttribArray", 867 | "glDrawElements", 868 | "glDrawElementsBaseVertex", 869 | "glEnable", 870 | "glEnableVertexAttribArray", 871 | "glFlush", 872 | "glGenBuffers", 873 | "glGenTextures", 874 | "glGenVertexArrays", 875 | "glGetAttribLocation", 876 | "glGetError", 877 | "glGetIntegerv", 878 | "glGetProgramInfoLog", 879 | "glGetProgramiv", 880 | "glGetShaderInfoLog", 881 | "glGetShaderiv", 882 | "glGetString", 883 | "glGetStringi", 884 | "glGetUniformLocation", 885 | "glGetVertexAttribPointerv", 886 | "glGetVertexAttribiv", 887 | "glIsEnabled", 888 | "glIsProgram", 889 | "glLinkProgram", 890 | "glPixelStorei", 891 | "glPolygonMode", 892 | "glReadPixels", 893 | "glScissor", 894 | "glShaderSource", 895 | "glTexImage2D", 896 | "glTexParameteri", 897 | "glUniform1i", 898 | "glUniformMatrix4fv", 899 | "glUseProgram", 900 | "glVertexAttribPointer", 901 | "glViewport", 902 | }; 903 | 904 | GL3W_API union ImGL3WProcs imgl3wProcs; 905 | 906 | static void load_procs(GL3WGetProcAddressProc proc) 907 | { 908 | size_t i; 909 | for (i = 0; i < GL3W_ARRAY_SIZE(proc_names); i++) 910 | imgl3wProcs.ptr[i] = proc(proc_names[i]); 911 | } 912 | 913 | #ifdef __cplusplus 914 | } 915 | #endif 916 | #endif 917 | -------------------------------------------------------------------------------- /imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // DEAR IMGUI COMPILE-TIME OPTIONS 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // - Windows DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec(dllexport) // MSVC Windows: DLL export 27 | //#define IMGUI_API __declspec(dllimport) // MSVC Windows: DLL import 28 | //#define IMGUI_API __attribute__((visibility("default"))) // GCC/Clang: override visibility when set is hidden 29 | 30 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names. 31 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 32 | 33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools. 34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp. 35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. 37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty. 38 | 39 | //---- Don't implement some functions to reduce linkage requirements. 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) 42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) 43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME). 44 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 45 | //#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS // Don't implement default platform_io.Platform_OpenInShellFn() handler (Win32: ShellExecute(), require shell32.lib/.a, Mac/Linux: use system("")). 46 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 47 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 48 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 49 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 50 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 51 | //#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded font (ProggyClean.ttf), remove ~9.5 KB from output binary. AddFontDefault() will assert. 52 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available 53 | 54 | //---- Enable Test Engine / Automation features. 55 | //#define IMGUI_ENABLE_TEST_ENGINE // Enable imgui_test_engine hooks. Generally set automatically by include "imgui_te_config.h", see Test Engine for details. 56 | 57 | //---- Include imgui_user.h at the end of imgui.h as a convenience 58 | // May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included. 59 | //#define IMGUI_INCLUDE_IMGUI_USER_H 60 | //#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h" 61 | 62 | //---- Pack vertex colors as BGRA8 instead of RGBA8 (to avoid converting from one to another). Need dedicated backend support. 63 | //#define IMGUI_USE_BGRA_PACKED_COLOR 64 | 65 | //---- Use legacy CRC32-adler tables (used before 1.91.6), in order to preserve old .ini data that you cannot afford to invalidate. 66 | //#define IMGUI_USE_LEGACY_CRC32_ADLER 67 | 68 | //---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 69 | //#define IMGUI_USE_WCHAR32 70 | 71 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 72 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 73 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 74 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 75 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined. 76 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 77 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 78 | //#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined. 79 | 80 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 81 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h. 82 | //#define IMGUI_USE_STB_SPRINTF 83 | 84 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 85 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 86 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. 87 | //#define IMGUI_ENABLE_FREETYPE 88 | 89 | //---- Use FreeType + plutosvg or lunasvg to render OpenType SVG fonts (SVGinOT) 90 | // Only works in combination with IMGUI_ENABLE_FREETYPE. 91 | // - plutosvg is currently easier to install, as e.g. it is part of vcpkg. It will support more fonts and may load them faster. See misc/freetype/README for instructions. 92 | // - Both require headers to be available in the include path + program to be linked with the library code (not provided). 93 | // - (note: lunasvg implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement) 94 | //#define IMGUI_ENABLE_FREETYPE_PLUTOSVG 95 | //#define IMGUI_ENABLE_FREETYPE_LUNASVG 96 | 97 | //---- Use stb_truetype to build and rasterize the font atlas (default) 98 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 99 | //#define IMGUI_ENABLE_STB_TRUETYPE 100 | 101 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 102 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 103 | /* 104 | #define IM_VEC2_CLASS_EXTRA \ 105 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \ 106 | operator MyVec2() const { return MyVec2(x,y); } 107 | 108 | #define IM_VEC4_CLASS_EXTRA \ 109 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \ 110 | operator MyVec4() const { return MyVec4(x,y,z,w); } 111 | */ 112 | //---- ...Or use Dear ImGui's own very basic math operators. 113 | //#define IMGUI_DEFINE_MATH_OPERATORS 114 | 115 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 116 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 117 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 118 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 119 | //#define ImDrawIdx unsigned int 120 | 121 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 122 | //struct ImDrawList; 123 | //struct ImDrawCmd; 124 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 125 | //#define ImDrawCallback MyImDrawCallback 126 | 127 | //---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase) 128 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 129 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 130 | //#define IM_DEBUG_BREAK __debugbreak() 131 | 132 | //---- Debug Tools: Enable slower asserts 133 | //#define IMGUI_DEBUG_PARANOID 134 | 135 | //---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files) 136 | /* 137 | namespace ImGui 138 | { 139 | void MyFunction(const char* name, MyMatrix44* mtx); 140 | } 141 | */ 142 | -------------------------------------------------------------------------------- /imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.01. 3 | // Grep for [DEAR IMGUI] to find the changes. 4 | // 5 | // stb_rect_pack.h - v1.01 - public domain - rectangle packing 6 | // Sean Barrett 2014 7 | // 8 | // Useful for e.g. packing rectangular textures into an atlas. 9 | // Does not do rotation. 10 | // 11 | // Before #including, 12 | // 13 | // #define STB_RECT_PACK_IMPLEMENTATION 14 | // 15 | // in the file that you want to have the implementation. 16 | // 17 | // Not necessarily the awesomest packing method, but better than 18 | // the totally naive one in stb_truetype (which is primarily what 19 | // this is meant to replace). 20 | // 21 | // Has only had a few tests run, may have issues. 22 | // 23 | // More docs to come. 24 | // 25 | // No memory allocations; uses qsort() and assert() from stdlib. 26 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 27 | // 28 | // This library currently uses the Skyline Bottom-Left algorithm. 29 | // 30 | // Please note: better rectangle packers are welcome! Please 31 | // implement them to the same API, but with a different init 32 | // function. 33 | // 34 | // Credits 35 | // 36 | // Library 37 | // Sean Barrett 38 | // Minor features 39 | // Martins Mozeiko 40 | // github:IntellectualKitty 41 | // 42 | // Bugfixes / warning fixes 43 | // Jeremy Jaussaud 44 | // Fabian Giesen 45 | // 46 | // Version history: 47 | // 48 | // 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section 49 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 50 | // 0.99 (2019-02-07) warning fixes 51 | // 0.11 (2017-03-03) return packing success/fail result 52 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 53 | // 0.09 (2016-08-27) fix compiler warnings 54 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 55 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 56 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 57 | // 0.05: added STBRP_ASSERT to allow replacing assert 58 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 59 | // 0.01: initial release 60 | // 61 | // LICENSE 62 | // 63 | // See end of file for license information. 64 | 65 | ////////////////////////////////////////////////////////////////////////////// 66 | // 67 | // INCLUDE SECTION 68 | // 69 | 70 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 71 | #define STB_INCLUDE_STB_RECT_PACK_H 72 | 73 | #define STB_RECT_PACK_VERSION 1 74 | 75 | #ifdef STBRP_STATIC 76 | #define STBRP_DEF static 77 | #else 78 | #define STBRP_DEF extern 79 | #endif 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | 85 | typedef struct stbrp_context stbrp_context; 86 | typedef struct stbrp_node stbrp_node; 87 | typedef struct stbrp_rect stbrp_rect; 88 | 89 | typedef int stbrp_coord; 90 | 91 | #define STBRP__MAXVAL 0x7fffffff 92 | // Mostly for internal use, but this is the maximum supported coordinate value. 93 | 94 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 95 | // Assign packed locations to rectangles. The rectangles are of type 96 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 97 | // are 'num_rects' many of them. 98 | // 99 | // Rectangles which are successfully packed have the 'was_packed' flag 100 | // set to a non-zero value and 'x' and 'y' store the minimum location 101 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 102 | // if you imagine y increasing downwards). Rectangles which do not fit 103 | // have the 'was_packed' flag set to 0. 104 | // 105 | // You should not try to access the 'rects' array from another thread 106 | // while this function is running, as the function temporarily reorders 107 | // the array while it executes. 108 | // 109 | // To pack into another rectangle, you need to call stbrp_init_target 110 | // again. To continue packing into the same rectangle, you can call 111 | // this function again. Calling this multiple times with multiple rect 112 | // arrays will probably produce worse packing results than calling it 113 | // a single time with the full rectangle array, but the option is 114 | // available. 115 | // 116 | // The function returns 1 if all of the rectangles were successfully 117 | // packed and 0 otherwise. 118 | 119 | struct stbrp_rect 120 | { 121 | // reserved for your use: 122 | int id; 123 | 124 | // input: 125 | stbrp_coord w, h; 126 | 127 | // output: 128 | stbrp_coord x, y; 129 | int was_packed; // non-zero if valid packing 130 | 131 | }; // 16 bytes, nominally 132 | 133 | 134 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 135 | // Initialize a rectangle packer to: 136 | // pack a rectangle that is 'width' by 'height' in dimensions 137 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 138 | // 139 | // You must call this function every time you start packing into a new target. 140 | // 141 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 142 | // the following stbrp_pack_rects() call (or calls), but can be freed after 143 | // the call (or calls) finish. 144 | // 145 | // Note: to guarantee best results, either: 146 | // 1. make sure 'num_nodes' >= 'width' 147 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 148 | // 149 | // If you don't do either of the above things, widths will be quantized to multiples 150 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 151 | // 152 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 153 | // may run out of temporary storage and be unable to pack some rectangles. 154 | 155 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 156 | // Optionally call this function after init but before doing any packing to 157 | // change the handling of the out-of-temp-memory scenario, described above. 158 | // If you call init again, this will be reset to the default (false). 159 | 160 | 161 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 162 | // Optionally select which packing heuristic the library should use. Different 163 | // heuristics will produce better/worse results for different data sets. 164 | // If you call init again, this will be reset to the default. 165 | 166 | enum 167 | { 168 | STBRP_HEURISTIC_Skyline_default=0, 169 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 170 | STBRP_HEURISTIC_Skyline_BF_sortHeight 171 | }; 172 | 173 | 174 | ////////////////////////////////////////////////////////////////////////////// 175 | // 176 | // the details of the following structures don't matter to you, but they must 177 | // be visible so you can handle the memory allocations for them 178 | 179 | struct stbrp_node 180 | { 181 | stbrp_coord x,y; 182 | stbrp_node *next; 183 | }; 184 | 185 | struct stbrp_context 186 | { 187 | int width; 188 | int height; 189 | int align; 190 | int init_mode; 191 | int heuristic; 192 | int num_nodes; 193 | stbrp_node *active_head; 194 | stbrp_node *free_head; 195 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 196 | }; 197 | 198 | #ifdef __cplusplus 199 | } 200 | #endif 201 | 202 | #endif 203 | 204 | ////////////////////////////////////////////////////////////////////////////// 205 | // 206 | // IMPLEMENTATION SECTION 207 | // 208 | 209 | #ifdef STB_RECT_PACK_IMPLEMENTATION 210 | #ifndef STBRP_SORT 211 | #include 212 | #define STBRP_SORT qsort 213 | #endif 214 | 215 | #ifndef STBRP_ASSERT 216 | #include 217 | #define STBRP_ASSERT assert 218 | #endif 219 | 220 | #ifdef _MSC_VER 221 | #define STBRP__NOTUSED(v) (void)(v) 222 | #define STBRP__CDECL __cdecl 223 | #else 224 | #define STBRP__NOTUSED(v) (void)sizeof(v) 225 | #define STBRP__CDECL 226 | #endif 227 | 228 | enum 229 | { 230 | STBRP__INIT_skyline = 1 231 | }; 232 | 233 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 234 | { 235 | switch (context->init_mode) { 236 | case STBRP__INIT_skyline: 237 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 238 | context->heuristic = heuristic; 239 | break; 240 | default: 241 | STBRP_ASSERT(0); 242 | } 243 | } 244 | 245 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 246 | { 247 | if (allow_out_of_mem) 248 | // if it's ok to run out of memory, then don't bother aligning them; 249 | // this gives better packing, but may fail due to OOM (even though 250 | // the rectangles easily fit). @TODO a smarter approach would be to only 251 | // quantize once we've hit OOM, then we could get rid of this parameter. 252 | context->align = 1; 253 | else { 254 | // if it's not ok to run out of memory, then quantize the widths 255 | // so that num_nodes is always enough nodes. 256 | // 257 | // I.e. num_nodes * align >= width 258 | // align >= width / num_nodes 259 | // align = ceil(width/num_nodes) 260 | 261 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 262 | } 263 | } 264 | 265 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 266 | { 267 | int i; 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | context->extra[1].y = (1<<30); 287 | context->extra[1].next = NULL; 288 | } 289 | 290 | // find minimum y position if it starts at x1 291 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 292 | { 293 | stbrp_node *node = first; 294 | int x1 = x0 + width; 295 | int min_y, visited_width, waste_area; 296 | 297 | STBRP__NOTUSED(c); 298 | 299 | STBRP_ASSERT(first->x <= x0); 300 | 301 | #if 0 302 | // skip in case we're past the node 303 | while (node->next->x <= x0) 304 | ++node; 305 | #else 306 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 307 | #endif 308 | 309 | STBRP_ASSERT(node->x <= x0); 310 | 311 | min_y = 0; 312 | waste_area = 0; 313 | visited_width = 0; 314 | while (node->x < x1) { 315 | if (node->y > min_y) { 316 | // raise min_y higher. 317 | // we've accounted for all waste up to min_y, 318 | // but we'll now add more waste for everything we've visted 319 | waste_area += visited_width * (node->y - min_y); 320 | min_y = node->y; 321 | // the first time through, visited_width might be reduced 322 | if (node->x < x0) 323 | visited_width += node->next->x - x0; 324 | else 325 | visited_width += node->next->x - node->x; 326 | } else { 327 | // add waste area 328 | int under_width = node->next->x - node->x; 329 | if (under_width + visited_width > width) 330 | under_width = width - visited_width; 331 | waste_area += under_width * (min_y - node->y); 332 | visited_width += under_width; 333 | } 334 | node = node->next; 335 | } 336 | 337 | *pwaste = waste_area; 338 | return min_y; 339 | } 340 | 341 | typedef struct 342 | { 343 | int x,y; 344 | stbrp_node **prev_link; 345 | } stbrp__findresult; 346 | 347 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 348 | { 349 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 350 | stbrp__findresult fr; 351 | stbrp_node **prev, *node, *tail, **best = NULL; 352 | 353 | // align to multiple of c->align 354 | width = (width + c->align - 1); 355 | width -= width % c->align; 356 | STBRP_ASSERT(width % c->align == 0); 357 | 358 | // if it can't possibly fit, bail immediately 359 | if (width > c->width || height > c->height) { 360 | fr.prev_link = NULL; 361 | fr.x = fr.y = 0; 362 | return fr; 363 | } 364 | 365 | node = c->active_head; 366 | prev = &c->active_head; 367 | while (node->x + width <= c->width) { 368 | int y,waste; 369 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 370 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 371 | // bottom left 372 | if (y < best_y) { 373 | best_y = y; 374 | best = prev; 375 | } 376 | } else { 377 | // best-fit 378 | if (y + height <= c->height) { 379 | // can only use it if it first vertically 380 | if (y < best_y || (y == best_y && waste < best_waste)) { 381 | best_y = y; 382 | best_waste = waste; 383 | best = prev; 384 | } 385 | } 386 | } 387 | prev = &node->next; 388 | node = node->next; 389 | } 390 | 391 | best_x = (best == NULL) ? 0 : (*best)->x; 392 | 393 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 394 | // 395 | // e.g, if fitting 396 | // 397 | // ____________________ 398 | // |____________________| 399 | // 400 | // into 401 | // 402 | // | | 403 | // | ____________| 404 | // |____________| 405 | // 406 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 407 | // 408 | // This makes BF take about 2x the time 409 | 410 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 411 | tail = c->active_head; 412 | node = c->active_head; 413 | prev = &c->active_head; 414 | // find first node that's admissible 415 | while (tail->x < width) 416 | tail = tail->next; 417 | while (tail) { 418 | int xpos = tail->x - width; 419 | int y,waste; 420 | STBRP_ASSERT(xpos >= 0); 421 | // find the left position that matches this 422 | while (node->next->x <= xpos) { 423 | prev = &node->next; 424 | node = node->next; 425 | } 426 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 427 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 428 | if (y + height <= c->height) { 429 | if (y <= best_y) { 430 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 431 | best_x = xpos; 432 | //STBRP_ASSERT(y <= best_y); [DEAR IMGUI] 433 | best_y = y; 434 | best_waste = waste; 435 | best = prev; 436 | } 437 | } 438 | } 439 | tail = tail->next; 440 | } 441 | } 442 | 443 | fr.prev_link = best; 444 | fr.x = best_x; 445 | fr.y = best_y; 446 | return fr; 447 | } 448 | 449 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 450 | { 451 | // find best position according to heuristic 452 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 453 | stbrp_node *node, *cur; 454 | 455 | // bail if: 456 | // 1. it failed 457 | // 2. the best node doesn't fit (we don't always check this) 458 | // 3. we're out of memory 459 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 460 | res.prev_link = NULL; 461 | return res; 462 | } 463 | 464 | // on success, create new node 465 | node = context->free_head; 466 | node->x = (stbrp_coord) res.x; 467 | node->y = (stbrp_coord) (res.y + height); 468 | 469 | context->free_head = node->next; 470 | 471 | // insert the new node into the right starting point, and 472 | // let 'cur' point to the remaining nodes needing to be 473 | // stiched back in 474 | 475 | cur = *res.prev_link; 476 | if (cur->x < res.x) { 477 | // preserve the existing one, so start testing with the next one 478 | stbrp_node *next = cur->next; 479 | cur->next = node; 480 | cur = next; 481 | } else { 482 | *res.prev_link = node; 483 | } 484 | 485 | // from here, traverse cur and free the nodes, until we get to one 486 | // that shouldn't be freed 487 | while (cur->next && cur->next->x <= res.x + width) { 488 | stbrp_node *next = cur->next; 489 | // move the current node to the free list 490 | cur->next = context->free_head; 491 | context->free_head = cur; 492 | cur = next; 493 | } 494 | 495 | // stitch the list back in 496 | node->next = cur; 497 | 498 | if (cur->x < res.x + width) 499 | cur->x = (stbrp_coord) (res.x + width); 500 | 501 | #ifdef _DEBUG 502 | cur = context->active_head; 503 | while (cur->x < context->width) { 504 | STBRP_ASSERT(cur->x < cur->next->x); 505 | cur = cur->next; 506 | } 507 | STBRP_ASSERT(cur->next == NULL); 508 | 509 | { 510 | int count=0; 511 | cur = context->active_head; 512 | while (cur) { 513 | cur = cur->next; 514 | ++count; 515 | } 516 | cur = context->free_head; 517 | while (cur) { 518 | cur = cur->next; 519 | ++count; 520 | } 521 | STBRP_ASSERT(count == context->num_nodes+2); 522 | } 523 | #endif 524 | 525 | return res; 526 | } 527 | 528 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 529 | { 530 | const stbrp_rect *p = (const stbrp_rect *) a; 531 | const stbrp_rect *q = (const stbrp_rect *) b; 532 | if (p->h > q->h) 533 | return -1; 534 | if (p->h < q->h) 535 | return 1; 536 | return (p->w > q->w) ? -1 : (p->w < q->w); 537 | } 538 | 539 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 540 | { 541 | const stbrp_rect *p = (const stbrp_rect *) a; 542 | const stbrp_rect *q = (const stbrp_rect *) b; 543 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 544 | } 545 | 546 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 547 | { 548 | int i, all_rects_packed = 1; 549 | 550 | // we use the 'was_packed' field internally to allow sorting/unsorting 551 | for (i=0; i < num_rects; ++i) { 552 | rects[i].was_packed = i; 553 | } 554 | 555 | // sort according to heuristic 556 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 557 | 558 | for (i=0; i < num_rects; ++i) { 559 | if (rects[i].w == 0 || rects[i].h == 0) { 560 | rects[i].x = rects[i].y = 0; // empty rect needs no space 561 | } else { 562 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 563 | if (fr.prev_link) { 564 | rects[i].x = (stbrp_coord) fr.x; 565 | rects[i].y = (stbrp_coord) fr.y; 566 | } else { 567 | rects[i].x = rects[i].y = STBRP__MAXVAL; 568 | } 569 | } 570 | } 571 | 572 | // unsort 573 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 574 | 575 | // set was_packed flags and all_rects_packed status 576 | for (i=0; i < num_rects; ++i) { 577 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 578 | if (!rects[i].was_packed) 579 | all_rects_packed = 0; 580 | } 581 | 582 | // return the all_rects_packed status 583 | return all_rects_packed; 584 | } 585 | #endif 586 | 587 | /* 588 | ------------------------------------------------------------------------------ 589 | This software is available under 2 licenses -- choose whichever you prefer. 590 | ------------------------------------------------------------------------------ 591 | ALTERNATIVE A - MIT License 592 | Copyright (c) 2017 Sean Barrett 593 | Permission is hereby granted, free of charge, to any person obtaining a copy of 594 | this software and associated documentation files (the "Software"), to deal in 595 | the Software without restriction, including without limitation the rights to 596 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 597 | of the Software, and to permit persons to whom the Software is furnished to do 598 | so, subject to the following conditions: 599 | The above copyright notice and this permission notice shall be included in all 600 | copies or substantial portions of the Software. 601 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 602 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 603 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 604 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 605 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 606 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 607 | SOFTWARE. 608 | ------------------------------------------------------------------------------ 609 | ALTERNATIVE B - Public Domain (www.unlicense.org) 610 | This is free and unencumbered software released into the public domain. 611 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 612 | software, either in source code form or as a compiled binary, for any purpose, 613 | commercial or non-commercial, and by any means. 614 | In jurisdictions that recognize copyright laws, the author or authors of this 615 | software dedicate any and all copyright interest in the software to the public 616 | domain. We make this dedication for the benefit of the public at large and to 617 | the detriment of our heirs and successors. We intend this dedication to be an 618 | overt act of relinquishment in perpetuity of all present and future rights to 619 | this software under copyright law. 620 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 621 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 622 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 623 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 624 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 625 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 626 | ------------------------------------------------------------------------------ 627 | */ 628 | -------------------------------------------------------------------------------- /imnodes/imnodes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef IMNODES_USER_CONFIG 7 | #include IMNODES_USER_CONFIG 8 | #endif 9 | 10 | #ifndef IMNODES_NAMESPACE 11 | #define IMNODES_NAMESPACE ImNodes 12 | #endif 13 | 14 | typedef int ImNodesCol; // -> enum ImNodesCol_ 15 | typedef int ImNodesStyleVar; // -> enum ImNodesStyleVar_ 16 | typedef int ImNodesStyleFlags; // -> enum ImNodesStyleFlags_ 17 | typedef int ImNodesPinShape; // -> enum ImNodesPinShape_ 18 | typedef int ImNodesAttributeFlags; // -> enum ImNodesAttributeFlags_ 19 | typedef int ImNodesMiniMapLocation; // -> enum ImNodesMiniMapLocation_ 20 | 21 | enum ImNodesCol_ 22 | { 23 | ImNodesCol_NodeBackground = 0, 24 | ImNodesCol_NodeBackgroundHovered, 25 | ImNodesCol_NodeBackgroundSelected, 26 | ImNodesCol_NodeOutline, 27 | ImNodesCol_TitleBar, 28 | ImNodesCol_TitleBarHovered, 29 | ImNodesCol_TitleBarSelected, 30 | ImNodesCol_Link, 31 | ImNodesCol_LinkHovered, 32 | ImNodesCol_LinkSelected, 33 | ImNodesCol_Pin, 34 | ImNodesCol_PinHovered, 35 | ImNodesCol_BoxSelector, 36 | ImNodesCol_BoxSelectorOutline, 37 | ImNodesCol_GridBackground, 38 | ImNodesCol_GridLine, 39 | ImNodesCol_GridLinePrimary, 40 | ImNodesCol_MiniMapBackground, 41 | ImNodesCol_MiniMapBackgroundHovered, 42 | ImNodesCol_MiniMapOutline, 43 | ImNodesCol_MiniMapOutlineHovered, 44 | ImNodesCol_MiniMapNodeBackground, 45 | ImNodesCol_MiniMapNodeBackgroundHovered, 46 | ImNodesCol_MiniMapNodeBackgroundSelected, 47 | ImNodesCol_MiniMapNodeOutline, 48 | ImNodesCol_MiniMapLink, 49 | ImNodesCol_MiniMapLinkSelected, 50 | ImNodesCol_MiniMapCanvas, 51 | ImNodesCol_MiniMapCanvasOutline, 52 | ImNodesCol_COUNT 53 | }; 54 | 55 | enum ImNodesStyleVar_ 56 | { 57 | ImNodesStyleVar_GridSpacing = 0, 58 | ImNodesStyleVar_NodeCornerRounding, 59 | ImNodesStyleVar_NodePadding, 60 | ImNodesStyleVar_NodeBorderThickness, 61 | ImNodesStyleVar_LinkThickness, 62 | ImNodesStyleVar_LinkLineSegmentsPerLength, 63 | ImNodesStyleVar_LinkHoverDistance, 64 | ImNodesStyleVar_PinCircleRadius, 65 | ImNodesStyleVar_PinQuadSideLength, 66 | ImNodesStyleVar_PinTriangleSideLength, 67 | ImNodesStyleVar_PinLineThickness, 68 | ImNodesStyleVar_PinHoverRadius, 69 | ImNodesStyleVar_PinOffset, 70 | ImNodesStyleVar_MiniMapPadding, 71 | ImNodesStyleVar_MiniMapOffset, 72 | ImNodesStyleVar_COUNT 73 | }; 74 | 75 | enum ImNodesStyleFlags_ 76 | { 77 | ImNodesStyleFlags_None = 0, 78 | ImNodesStyleFlags_NodeOutline = 1 << 0, 79 | ImNodesStyleFlags_GridLines = 1 << 2, 80 | ImNodesStyleFlags_GridLinesPrimary = 1 << 3, 81 | ImNodesStyleFlags_GridSnapping = 1 << 4 82 | }; 83 | 84 | enum ImNodesPinShape_ 85 | { 86 | ImNodesPinShape_Circle, 87 | ImNodesPinShape_CircleFilled, 88 | ImNodesPinShape_Triangle, 89 | ImNodesPinShape_TriangleFilled, 90 | ImNodesPinShape_Quad, 91 | ImNodesPinShape_QuadFilled 92 | }; 93 | 94 | // This enum controls the way the attribute pins behave. 95 | enum ImNodesAttributeFlags_ 96 | { 97 | ImNodesAttributeFlags_None = 0, 98 | // Allow detaching a link by left-clicking and dragging the link at a pin it is connected to. 99 | // NOTE: the user has to actually delete the link for this to work. A deleted link can be 100 | // detected by calling IsLinkDestroyed() after EndNodeEditor(). 101 | ImNodesAttributeFlags_EnableLinkDetachWithDragClick = 1 << 0, 102 | // Visual snapping of an in progress link will trigger IsLink Created/Destroyed events. Allows 103 | // for previewing the creation of a link while dragging it across attributes. See here for demo: 104 | // https://github.com/Nelarius/imnodes/issues/41#issuecomment-647132113 NOTE: the user has to 105 | // actually delete the link for this to work. A deleted link can be detected by calling 106 | // IsLinkDestroyed() after EndNodeEditor(). 107 | ImNodesAttributeFlags_EnableLinkCreationOnSnap = 1 << 1 108 | }; 109 | 110 | struct ImNodesIO 111 | { 112 | struct EmulateThreeButtonMouse 113 | { 114 | EmulateThreeButtonMouse(); 115 | 116 | // The keyboard modifier to use in combination with mouse left click to pan the editor view. 117 | // Set to NULL by default. To enable this feature, set the modifier to point to a boolean 118 | // indicating the state of a modifier. For example, 119 | // 120 | // ImNodes::GetIO().EmulateThreeButtonMouse.Modifier = &ImGui::GetIO().KeyAlt; 121 | const bool* Modifier; 122 | } EmulateThreeButtonMouse; 123 | 124 | struct LinkDetachWithModifierClick 125 | { 126 | LinkDetachWithModifierClick(); 127 | 128 | // Pointer to a boolean value indicating when the desired modifier is pressed. Set to NULL 129 | // by default. To enable the feature, set the modifier to point to a boolean indicating the 130 | // state of a modifier. For example, 131 | // 132 | // ImNodes::GetIO().LinkDetachWithModifierClick.Modifier = &ImGui::GetIO().KeyCtrl; 133 | // 134 | // Left-clicking a link with this modifier pressed will detach that link. NOTE: the user has 135 | // to actually delete the link for this to work. A deleted link can be detected by calling 136 | // IsLinkDestroyed() after EndNodeEditor(). 137 | const bool* Modifier; 138 | } LinkDetachWithModifierClick; 139 | 140 | struct MultipleSelectModifier 141 | { 142 | MultipleSelectModifier(); 143 | 144 | // Pointer to a boolean value indicating when the desired modifier is pressed. Set to NULL 145 | // by default. To enable the feature, set the modifier to point to a boolean indicating the 146 | // state of a modifier. For example, 147 | // 148 | // ImNodes::GetIO().MultipleSelectModifier.Modifier = &ImGui::GetIO().KeyCtrl; 149 | // 150 | // Left-clicking a node with this modifier pressed will add the node to the list of 151 | // currently selected nodes. If this value is NULL, the Ctrl key will be used. 152 | const bool* Modifier; 153 | } MultipleSelectModifier; 154 | 155 | // Holding alt mouse button pans the node area, by default middle mouse button will be used 156 | // Set based on ImGuiMouseButton values 157 | int AltMouseButton; 158 | 159 | // Panning speed when dragging an element and mouse is outside the main editor view. 160 | float AutoPanningSpeed; 161 | 162 | ImNodesIO(); 163 | }; 164 | 165 | struct ImNodesStyle 166 | { 167 | float GridSpacing; 168 | 169 | float NodeCornerRounding; 170 | ImVec2 NodePadding; 171 | float NodeBorderThickness; 172 | 173 | float LinkThickness; 174 | float LinkLineSegmentsPerLength; 175 | float LinkHoverDistance; 176 | 177 | // The following variables control the look and behavior of the pins. The default size of each 178 | // pin shape is balanced to occupy approximately the same surface area on the screen. 179 | 180 | // The circle radius used when the pin shape is either ImNodesPinShape_Circle or 181 | // ImNodesPinShape_CircleFilled. 182 | float PinCircleRadius; 183 | // The quad side length used when the shape is either ImNodesPinShape_Quad or 184 | // ImNodesPinShape_QuadFilled. 185 | float PinQuadSideLength; 186 | // The equilateral triangle side length used when the pin shape is either 187 | // ImNodesPinShape_Triangle or ImNodesPinShape_TriangleFilled. 188 | float PinTriangleSideLength; 189 | // The thickness of the line used when the pin shape is not filled. 190 | float PinLineThickness; 191 | // The radius from the pin's center position inside of which it is detected as being hovered 192 | // over. 193 | float PinHoverRadius; 194 | // Offsets the pins' positions from the edge of the node to the outside of the node. 195 | float PinOffset; 196 | 197 | // Mini-map padding size between mini-map edge and mini-map content. 198 | ImVec2 MiniMapPadding; 199 | // Mini-map offset from the screen side. 200 | ImVec2 MiniMapOffset; 201 | 202 | // By default, ImNodesStyleFlags_NodeOutline and ImNodesStyleFlags_Gridlines are enabled. 203 | ImNodesStyleFlags Flags; 204 | // Set these mid-frame using Push/PopColorStyle. You can index this color array with with a 205 | // ImNodesCol value. 206 | unsigned int Colors[ImNodesCol_COUNT]; 207 | 208 | ImNodesStyle(); 209 | }; 210 | 211 | enum ImNodesMiniMapLocation_ 212 | { 213 | ImNodesMiniMapLocation_BottomLeft, 214 | ImNodesMiniMapLocation_BottomRight, 215 | ImNodesMiniMapLocation_TopLeft, 216 | ImNodesMiniMapLocation_TopRight, 217 | }; 218 | 219 | struct ImGuiContext; 220 | struct ImVec2; 221 | 222 | struct ImNodesContext; 223 | 224 | // An editor context corresponds to a set of nodes in a single workspace (created with a single 225 | // Begin/EndNodeEditor pair) 226 | // 227 | // By default, the library creates an editor context behind the scenes, so using any of the imnodes 228 | // functions doesn't require you to explicitly create a context. 229 | struct ImNodesEditorContext; 230 | 231 | // Callback type used to specify special behavior when hovering a node in the minimap 232 | #ifndef ImNodesMiniMapNodeHoveringCallback 233 | typedef void (*ImNodesMiniMapNodeHoveringCallback)(int, void*); 234 | #endif 235 | 236 | #ifndef ImNodesMiniMapNodeHoveringCallbackUserData 237 | typedef void* ImNodesMiniMapNodeHoveringCallbackUserData; 238 | #endif 239 | 240 | namespace IMNODES_NAMESPACE 241 | { 242 | // Call this function if you are compiling imnodes in to a dll, separate from ImGui. Calling this 243 | // function sets the GImGui global variable, which is not shared across dll boundaries. 244 | void SetImGuiContext(ImGuiContext* ctx); 245 | 246 | ImNodesContext* CreateContext(); 247 | void DestroyContext(ImNodesContext* ctx = NULL); // NULL = destroy current context 248 | ImNodesContext* GetCurrentContext(); 249 | void SetCurrentContext(ImNodesContext* ctx); 250 | 251 | ImNodesEditorContext* EditorContextCreate(); 252 | void EditorContextFree(ImNodesEditorContext*); 253 | void EditorContextSet(ImNodesEditorContext*); 254 | ImVec2 EditorContextGetPanning(); 255 | void EditorContextResetPanning(const ImVec2& pos); 256 | void EditorContextMoveToNode(const int node_id); 257 | 258 | ImNodesIO& GetIO(); 259 | 260 | // Returns the global style struct. See the struct declaration for default values. 261 | ImNodesStyle& GetStyle(); 262 | // Style presets matching the dear imgui styles of the same name. If dest is NULL, the active 263 | // context's ImNodesStyle instance will be used as the destination. 264 | void StyleColorsDark(ImNodesStyle* dest = NULL); // on by default 265 | void StyleColorsClassic(ImNodesStyle* dest = NULL); 266 | void StyleColorsLight(ImNodesStyle* dest = NULL); 267 | 268 | // The top-level function call. Call this before calling BeginNode/EndNode. Calling this function 269 | // will result the node editor grid workspace being rendered. 270 | void BeginNodeEditor(); 271 | void EndNodeEditor(); 272 | 273 | // Add a navigable minimap to the editor; call before EndNodeEditor after all 274 | // nodes and links have been specified 275 | void MiniMap( 276 | const float minimap_size_fraction = 0.2f, 277 | const ImNodesMiniMapLocation location = ImNodesMiniMapLocation_TopLeft, 278 | const ImNodesMiniMapNodeHoveringCallback node_hovering_callback = NULL, 279 | const ImNodesMiniMapNodeHoveringCallbackUserData node_hovering_callback_data = NULL); 280 | 281 | // Use PushColorStyle and PopColorStyle to modify ImNodesStyle::Colors mid-frame. 282 | void PushColorStyle(ImNodesCol item, unsigned int color); 283 | void PopColorStyle(); 284 | void PushStyleVar(ImNodesStyleVar style_item, float value); 285 | void PushStyleVar(ImNodesStyleVar style_item, const ImVec2& value); 286 | void PopStyleVar(int count = 1); 287 | 288 | // id can be any positive or negative integer, but INT_MIN is currently reserved for internal use. 289 | void BeginNode(int id); 290 | void EndNode(); 291 | 292 | ImVec2 GetNodeDimensions(int id); 293 | 294 | // Place your node title bar content (such as the node title, using ImGui::Text) between the 295 | // following function calls. These functions have to be called before adding any attributes, or the 296 | // layout of the node will be incorrect. 297 | void BeginNodeTitleBar(); 298 | void EndNodeTitleBar(); 299 | 300 | // Attributes are ImGui UI elements embedded within the node. Attributes can have pin shapes 301 | // rendered next to them. Links are created between pins. 302 | // 303 | // The activity status of an attribute can be checked via the IsAttributeActive() and 304 | // IsAnyAttributeActive() function calls. This is one easy way of checking for any changes made to 305 | // an attribute's drag float UI, for instance. 306 | // 307 | // Each attribute id must be unique. 308 | 309 | // Create an input attribute block. The pin is rendered on left side. 310 | void BeginInputAttribute(int id, ImNodesPinShape shape = ImNodesPinShape_CircleFilled); 311 | void EndInputAttribute(); 312 | // Create an output attribute block. The pin is rendered on the right side. 313 | void BeginOutputAttribute(int id, ImNodesPinShape shape = ImNodesPinShape_CircleFilled); 314 | void EndOutputAttribute(); 315 | // Create a static attribute block. A static attribute has no pin, and therefore can't be linked to 316 | // anything. However, you can still use IsAttributeActive() and IsAnyAttributeActive() to check for 317 | // attribute activity. 318 | void BeginStaticAttribute(int id); 319 | void EndStaticAttribute(); 320 | 321 | // Push a single AttributeFlags value. By default, only AttributeFlags_None is set. 322 | void PushAttributeFlag(ImNodesAttributeFlags flag); 323 | void PopAttributeFlag(); 324 | 325 | // Render a link between attributes. 326 | // The attributes ids used here must match the ids used in Begin(Input|Output)Attribute function 327 | // calls. The order of start_attr and end_attr doesn't make a difference for rendering the link. 328 | void Link(int id, int start_attribute_id, int end_attribute_id); 329 | 330 | // Enable or disable the ability to click and drag a specific node. 331 | void SetNodeDraggable(int node_id, const bool draggable); 332 | 333 | // The node's position can be expressed in three coordinate systems: 334 | // * screen space coordinates, -- the origin is the upper left corner of the window. 335 | // * editor space coordinates -- the origin is the upper left corner of the node editor window 336 | // * grid space coordinates, -- the origin is the upper left corner of the node editor window, 337 | // translated by the current editor panning vector (see EditorContextGetPanning() and 338 | // EditorContextResetPanning()) 339 | 340 | // Use the following functions to get and set the node's coordinates in these coordinate systems. 341 | 342 | void SetNodeScreenSpacePos(int node_id, const ImVec2& screen_space_pos); 343 | void SetNodeEditorSpacePos(int node_id, const ImVec2& editor_space_pos); 344 | void SetNodeGridSpacePos(int node_id, const ImVec2& grid_pos); 345 | 346 | ImVec2 GetNodeScreenSpacePos(const int node_id); 347 | ImVec2 GetNodeEditorSpacePos(const int node_id); 348 | ImVec2 GetNodeGridSpacePos(const int node_id); 349 | 350 | // If ImNodesStyleFlags_GridSnapping is enabled, snap the specified node's origin to the grid. 351 | void SnapNodeToGrid(int node_id); 352 | 353 | // Returns true if the current node editor canvas is being hovered over by the mouse, and is not 354 | // blocked by any other windows. 355 | bool IsEditorHovered(); 356 | // The following functions return true if a UI element is being hovered over by the mouse cursor. 357 | // Assigns the id of the UI element being hovered over to the function argument. Use these functions 358 | // after EndNodeEditor() has been called. 359 | bool IsNodeHovered(int* node_id); 360 | bool IsLinkHovered(int* link_id); 361 | bool IsPinHovered(int* attribute_id); 362 | 363 | // Use The following two functions to query the number of selected nodes or links in the current 364 | // editor. Use after calling EndNodeEditor(). 365 | int NumSelectedNodes(); 366 | int NumSelectedLinks(); 367 | // Get the selected node/link ids. The pointer argument should point to an integer array with at 368 | // least as many elements as the respective NumSelectedNodes/NumSelectedLinks function call 369 | // returned. 370 | void GetSelectedNodes(int* node_ids); 371 | void GetSelectedLinks(int* link_ids); 372 | // Clears the list of selected nodes/links. Useful if you want to delete a selected node or link. 373 | void ClearNodeSelection(); 374 | void ClearLinkSelection(); 375 | // Use the following functions to add or remove individual nodes or links from the current editors 376 | // selection. Note that all functions require the id to be an existing valid id for this editor. 377 | // Select-functions has the precondition that the object is currently considered unselected. 378 | // Clear-functions has the precondition that the object is currently considered selected. 379 | // Preconditions listed above can be checked via IsNodeSelected/IsLinkSelected if not already 380 | // known. 381 | void SelectNode(int node_id); 382 | void ClearNodeSelection(int node_id); 383 | bool IsNodeSelected(int node_id); 384 | void SelectLink(int link_id); 385 | void ClearLinkSelection(int link_id); 386 | bool IsLinkSelected(int link_id); 387 | 388 | // Was the previous attribute active? This will continuously return true while the left mouse button 389 | // is being pressed over the UI content of the attribute. 390 | bool IsAttributeActive(); 391 | // Was any attribute active? If so, sets the active attribute id to the output function argument. 392 | bool IsAnyAttributeActive(int* attribute_id = NULL); 393 | 394 | // Use the following functions to query a change of state for an existing link, or new link. Call 395 | // these after EndNodeEditor(). 396 | 397 | // Did the user start dragging a new link from a pin? 398 | bool IsLinkStarted(int* started_at_attribute_id); 399 | // Did the user drop the dragged link before attaching it to a pin? 400 | // There are two different kinds of situations to consider when handling this event: 401 | // 1) a link which is created at a pin and then dropped 402 | // 2) an existing link which is detached from a pin and then dropped 403 | // Use the including_detached_links flag to control whether this function triggers when the user 404 | // detaches a link and drops it. 405 | bool IsLinkDropped(int* started_at_attribute_id = NULL, bool including_detached_links = true); 406 | // Did the user finish creating a new link? 407 | bool IsLinkCreated( 408 | int* started_at_attribute_id, 409 | int* ended_at_attribute_id, 410 | bool* created_from_snap = NULL); 411 | bool IsLinkCreated( 412 | int* started_at_node_id, 413 | int* started_at_attribute_id, 414 | int* ended_at_node_id, 415 | int* ended_at_attribute_id, 416 | bool* created_from_snap = NULL); 417 | 418 | // Was an existing link detached from a pin by the user? The detached link's id is assigned to the 419 | // output argument link_id. 420 | bool IsLinkDestroyed(int* link_id); 421 | 422 | // Use the following functions to write the editor context's state to a string, or directly to a 423 | // file. The editor context is serialized in the INI file format. 424 | 425 | const char* SaveCurrentEditorStateToIniString(size_t* data_size = NULL); 426 | const char* SaveEditorStateToIniString( 427 | const ImNodesEditorContext* editor, 428 | size_t* data_size = NULL); 429 | 430 | void LoadCurrentEditorStateFromIniString(const char* data, size_t data_size); 431 | void LoadEditorStateFromIniString(ImNodesEditorContext* editor, const char* data, size_t data_size); 432 | 433 | void SaveCurrentEditorStateToIniFile(const char* file_name); 434 | void SaveEditorStateToIniFile(const ImNodesEditorContext* editor, const char* file_name); 435 | 436 | void LoadCurrentEditorStateFromIniFile(const char* file_name); 437 | void LoadEditorStateFromIniFile(ImNodesEditorContext* editor, const char* file_name); 438 | } // namespace IMNODES_NAMESPACE 439 | -------------------------------------------------------------------------------- /imnodes/imnodes_internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define IMGUI_DEFINE_MATH_OPERATORS 4 | #include 5 | #include 6 | 7 | #include "imnodes.h" 8 | 9 | #include 10 | 11 | // the structure of this file: 12 | // 13 | // [SECTION] internal enums 14 | // [SECTION] internal data structures 15 | // [SECTION] global and editor context structs 16 | // [SECTION] object pool implementation 17 | 18 | struct ImNodesContext; 19 | 20 | extern ImNodesContext* GImNodes; 21 | 22 | // [SECTION] internal enums 23 | 24 | typedef int ImNodesScope; 25 | typedef int ImNodesAttributeType; 26 | typedef int ImNodesUIState; 27 | typedef int ImNodesClickInteractionType; 28 | typedef int ImNodesLinkCreationType; 29 | 30 | enum ImNodesScope_ 31 | { 32 | ImNodesScope_None = 1, 33 | ImNodesScope_Editor = 1 << 1, 34 | ImNodesScope_Node = 1 << 2, 35 | ImNodesScope_Attribute = 1 << 3 36 | }; 37 | 38 | enum ImNodesAttributeType_ 39 | { 40 | ImNodesAttributeType_None, 41 | ImNodesAttributeType_Input, 42 | ImNodesAttributeType_Output 43 | }; 44 | 45 | enum ImNodesUIState_ 46 | { 47 | ImNodesUIState_None = 0, 48 | ImNodesUIState_LinkStarted = 1 << 0, 49 | ImNodesUIState_LinkDropped = 1 << 1, 50 | ImNodesUIState_LinkCreated = 1 << 2 51 | }; 52 | 53 | enum ImNodesClickInteractionType_ 54 | { 55 | ImNodesClickInteractionType_Node, 56 | ImNodesClickInteractionType_Link, 57 | ImNodesClickInteractionType_LinkCreation, 58 | ImNodesClickInteractionType_Panning, 59 | ImNodesClickInteractionType_BoxSelection, 60 | ImNodesClickInteractionType_ImGuiItem, 61 | ImNodesClickInteractionType_None 62 | }; 63 | 64 | enum ImNodesLinkCreationType_ 65 | { 66 | ImNodesLinkCreationType_Standard, 67 | ImNodesLinkCreationType_FromDetach 68 | }; 69 | 70 | // [SECTION] internal data structures 71 | 72 | // The object T must have the following interface: 73 | // 74 | // struct T 75 | // { 76 | // T(); 77 | // 78 | // int id; 79 | // }; 80 | template 81 | struct ImObjectPool 82 | { 83 | ImVector Pool; 84 | ImVector InUse; 85 | ImVector FreeList; 86 | ImGuiStorage IdMap; 87 | 88 | ImObjectPool() : Pool(), InUse(), FreeList(), IdMap() {} 89 | }; 90 | 91 | // Emulates std::optional using the sentinel value `INVALID_INDEX`. 92 | struct ImOptionalIndex 93 | { 94 | ImOptionalIndex() : _Index(INVALID_INDEX) {} 95 | ImOptionalIndex(const int value) : _Index(value) {} 96 | 97 | // Observers 98 | 99 | inline bool HasValue() const { return _Index != INVALID_INDEX; } 100 | 101 | inline int Value() const 102 | { 103 | IM_ASSERT(HasValue()); 104 | return _Index; 105 | } 106 | 107 | // Modifiers 108 | 109 | inline ImOptionalIndex& operator=(const int value) 110 | { 111 | _Index = value; 112 | return *this; 113 | } 114 | 115 | inline void Reset() { _Index = INVALID_INDEX; } 116 | 117 | inline bool operator==(const ImOptionalIndex& rhs) const { return _Index == rhs._Index; } 118 | 119 | inline bool operator==(const int rhs) const { return _Index == rhs; } 120 | 121 | inline bool operator!=(const ImOptionalIndex& rhs) const { return _Index != rhs._Index; } 122 | 123 | inline bool operator!=(const int rhs) const { return _Index != rhs; } 124 | 125 | static const int INVALID_INDEX = -1; 126 | 127 | private: 128 | int _Index; 129 | }; 130 | 131 | struct ImNodeData 132 | { 133 | int Id; 134 | ImVec2 Origin; // The node origin is in editor space 135 | ImRect TitleBarContentRect; 136 | ImRect Rect; 137 | 138 | struct 139 | { 140 | ImU32 Background, BackgroundHovered, BackgroundSelected, Outline, Titlebar, TitlebarHovered, 141 | TitlebarSelected; 142 | } ColorStyle; 143 | 144 | struct 145 | { 146 | float CornerRounding; 147 | ImVec2 Padding; 148 | float BorderThickness; 149 | } LayoutStyle; 150 | 151 | ImVector PinIndices; 152 | bool Draggable; 153 | 154 | ImNodeData(const int node_id) 155 | : Id(node_id), Origin(0.0f, 0.0f), TitleBarContentRect(), 156 | Rect(ImVec2(0.0f, 0.0f), ImVec2(0.0f, 0.0f)), ColorStyle(), LayoutStyle(), PinIndices(), 157 | Draggable(true) 158 | { 159 | } 160 | 161 | ~ImNodeData() { Id = INT_MIN; } 162 | }; 163 | 164 | struct ImPinData 165 | { 166 | int Id; 167 | int ParentNodeIdx; 168 | ImRect AttributeRect; 169 | ImNodesAttributeType Type; 170 | ImNodesPinShape Shape; 171 | ImVec2 Pos; // screen-space coordinates 172 | int Flags; 173 | 174 | struct 175 | { 176 | ImU32 Background, Hovered; 177 | } ColorStyle; 178 | 179 | ImPinData(const int pin_id) 180 | : Id(pin_id), ParentNodeIdx(), AttributeRect(), Type(ImNodesAttributeType_None), 181 | Shape(ImNodesPinShape_CircleFilled), Pos(), Flags(ImNodesAttributeFlags_None), 182 | ColorStyle() 183 | { 184 | } 185 | }; 186 | 187 | struct ImLinkData 188 | { 189 | int Id; 190 | int StartPinIdx, EndPinIdx; 191 | 192 | struct 193 | { 194 | ImU32 Base, Hovered, Selected; 195 | } ColorStyle; 196 | 197 | ImLinkData(const int link_id) : Id(link_id), StartPinIdx(), EndPinIdx(), ColorStyle() {} 198 | }; 199 | 200 | struct ImClickInteractionState 201 | { 202 | ImNodesClickInteractionType Type; 203 | 204 | struct 205 | { 206 | int StartPinIdx; 207 | ImOptionalIndex EndPinIdx; 208 | ImNodesLinkCreationType Type; 209 | } LinkCreation; 210 | 211 | struct 212 | { 213 | ImRect Rect; // Coordinates in grid space 214 | } BoxSelector; 215 | 216 | ImClickInteractionState() : Type(ImNodesClickInteractionType_None) {} 217 | }; 218 | 219 | struct ImNodesColElement 220 | { 221 | ImU32 Color; 222 | ImNodesCol Item; 223 | 224 | ImNodesColElement(const ImU32 c, const ImNodesCol s) : Color(c), Item(s) {} 225 | }; 226 | 227 | struct ImNodesStyleVarElement 228 | { 229 | ImNodesStyleVar Item; 230 | float FloatValue[2]; 231 | 232 | ImNodesStyleVarElement(const ImNodesStyleVar variable, const float value) : Item(variable) 233 | { 234 | FloatValue[0] = value; 235 | } 236 | 237 | ImNodesStyleVarElement(const ImNodesStyleVar variable, const ImVec2 value) : Item(variable) 238 | { 239 | FloatValue[0] = value.x; 240 | FloatValue[1] = value.y; 241 | } 242 | }; 243 | 244 | // [SECTION] global and editor context structs 245 | 246 | struct ImNodesEditorContext 247 | { 248 | ImObjectPool Nodes; 249 | ImObjectPool Pins; 250 | ImObjectPool Links; 251 | 252 | ImVector NodeDepthOrder; 253 | 254 | // ui related fields 255 | ImVec2 Panning; 256 | ImVec2 AutoPanningDelta; 257 | // Minimum and maximum extents of all content in grid space. Valid after final 258 | // ImNodes::EndNode() call. 259 | ImRect GridContentBounds; 260 | 261 | ImVector SelectedNodeIndices; 262 | ImVector SelectedLinkIndices; 263 | 264 | // Relative origins of selected nodes for snapping of dragged nodes 265 | ImVector SelectedNodeOffsets; 266 | // Offset of the primary node origin relative to the mouse cursor. 267 | ImVec2 PrimaryNodeOffset; 268 | 269 | ImClickInteractionState ClickInteraction; 270 | 271 | // Mini-map state set by MiniMap() 272 | 273 | bool MiniMapEnabled; 274 | ImNodesMiniMapLocation MiniMapLocation; 275 | float MiniMapSizeFraction; 276 | ImNodesMiniMapNodeHoveringCallback MiniMapNodeHoveringCallback; 277 | ImNodesMiniMapNodeHoveringCallbackUserData MiniMapNodeHoveringCallbackUserData; 278 | 279 | // Mini-map state set during EndNodeEditor() call 280 | 281 | ImRect MiniMapRectScreenSpace; 282 | ImRect MiniMapContentScreenSpace; 283 | float MiniMapScaling; 284 | 285 | ImNodesEditorContext() 286 | : Nodes(), Pins(), Links(), Panning(0.f, 0.f), SelectedNodeIndices(), SelectedLinkIndices(), 287 | SelectedNodeOffsets(), PrimaryNodeOffset(0.f, 0.f), ClickInteraction(), 288 | MiniMapEnabled(false), MiniMapSizeFraction(0.0f), MiniMapNodeHoveringCallback(NULL), 289 | MiniMapNodeHoveringCallbackUserData(NULL), MiniMapScaling(0.0f) 290 | { 291 | } 292 | }; 293 | 294 | struct ImNodesContext 295 | { 296 | ImNodesEditorContext* DefaultEditorCtx; 297 | ImNodesEditorContext* EditorCtx; 298 | 299 | // Canvas draw list and helper state 300 | ImDrawList* CanvasDrawList; 301 | ImGuiStorage NodeIdxToSubmissionIdx; 302 | ImVector NodeIdxSubmissionOrder; 303 | ImVector NodeIndicesOverlappingWithMouse; 304 | ImVector OccludedPinIndices; 305 | 306 | // Canvas extents 307 | ImVec2 CanvasOriginScreenSpace; 308 | ImRect CanvasRectScreenSpace; 309 | 310 | // Debug helpers 311 | ImNodesScope CurrentScope; 312 | 313 | // Configuration state 314 | ImNodesIO Io; 315 | ImNodesStyle Style; 316 | ImVector ColorModifierStack; 317 | ImVector StyleModifierStack; 318 | ImGuiTextBuffer TextBuffer; 319 | 320 | int CurrentAttributeFlags; 321 | ImVector AttributeFlagStack; 322 | 323 | // UI element state 324 | int CurrentNodeIdx; 325 | int CurrentPinIdx; 326 | int CurrentAttributeId; 327 | 328 | ImOptionalIndex HoveredNodeIdx; 329 | ImOptionalIndex HoveredLinkIdx; 330 | ImOptionalIndex HoveredPinIdx; 331 | 332 | ImOptionalIndex DeletedLinkIdx; 333 | ImOptionalIndex SnapLinkIdx; 334 | 335 | // Event helper state 336 | // TODO: this should be a part of a state machine, and not a member of the global struct. 337 | // Unclear what parts of the code this relates to. 338 | int ImNodesUIState; 339 | 340 | int ActiveAttributeId; 341 | bool ActiveAttribute; 342 | 343 | // ImGui::IO cache 344 | 345 | ImVec2 MousePos; 346 | 347 | bool LeftMouseClicked; 348 | bool LeftMouseReleased; 349 | bool AltMouseClicked; 350 | bool LeftMouseDragging; 351 | bool AltMouseDragging; 352 | float AltMouseScrollDelta; 353 | bool MultipleSelectModifier; 354 | }; 355 | 356 | namespace IMNODES_NAMESPACE 357 | { 358 | static inline ImNodesEditorContext& EditorContextGet() 359 | { 360 | // No editor context was set! Did you forget to call ImNodes::CreateContext()? 361 | IM_ASSERT(GImNodes->EditorCtx != NULL); 362 | return *GImNodes->EditorCtx; 363 | } 364 | 365 | // [SECTION] ObjectPool implementation 366 | 367 | template 368 | static inline int ObjectPoolFind(const ImObjectPool& objects, const int id) 369 | { 370 | const int index = objects.IdMap.GetInt(static_cast(id), -1); 371 | return index; 372 | } 373 | 374 | template 375 | static inline void ObjectPoolUpdate(ImObjectPool& objects) 376 | { 377 | for (int i = 0; i < objects.InUse.size(); ++i) 378 | { 379 | const int id = objects.Pool[i].Id; 380 | 381 | if (!objects.InUse[i] && objects.IdMap.GetInt(id, -1) == i) 382 | { 383 | objects.IdMap.SetInt(id, -1); 384 | objects.FreeList.push_back(i); 385 | (objects.Pool.Data + i)->~T(); 386 | } 387 | } 388 | } 389 | 390 | template<> 391 | inline void ObjectPoolUpdate(ImObjectPool& nodes) 392 | { 393 | for (int i = 0; i < nodes.InUse.size(); ++i) 394 | { 395 | if (nodes.InUse[i]) 396 | { 397 | nodes.Pool[i].PinIndices.clear(); 398 | } 399 | else 400 | { 401 | const int id = nodes.Pool[i].Id; 402 | 403 | if (nodes.IdMap.GetInt(id, -1) == i) 404 | { 405 | // Remove node idx form depth stack the first time we detect that this idx slot is 406 | // unused 407 | ImVector& depth_stack = EditorContextGet().NodeDepthOrder; 408 | const int* const elem = depth_stack.find(i); 409 | IM_ASSERT(elem != depth_stack.end()); 410 | depth_stack.erase(elem); 411 | 412 | nodes.IdMap.SetInt(id, -1); 413 | nodes.FreeList.push_back(i); 414 | (nodes.Pool.Data + i)->~ImNodeData(); 415 | } 416 | } 417 | } 418 | } 419 | 420 | template 421 | static inline void ObjectPoolReset(ImObjectPool& objects) 422 | { 423 | if (!objects.InUse.empty()) 424 | { 425 | memset(objects.InUse.Data, 0, objects.InUse.size_in_bytes()); 426 | } 427 | } 428 | 429 | template 430 | static inline int ObjectPoolFindOrCreateIndex(ImObjectPool& objects, const int id) 431 | { 432 | int index = objects.IdMap.GetInt(static_cast(id), -1); 433 | 434 | // Construct new object 435 | if (index == -1) 436 | { 437 | if (objects.FreeList.empty()) 438 | { 439 | index = objects.Pool.size(); 440 | IM_ASSERT(objects.Pool.size() == objects.InUse.size()); 441 | const int new_size = objects.Pool.size() + 1; 442 | objects.Pool.resize(new_size); 443 | objects.InUse.resize(new_size); 444 | } 445 | else 446 | { 447 | index = objects.FreeList.back(); 448 | objects.FreeList.pop_back(); 449 | } 450 | IM_PLACEMENT_NEW(objects.Pool.Data + index) T(id); 451 | objects.IdMap.SetInt(static_cast(id), index); 452 | } 453 | 454 | // Flag it as used 455 | objects.InUse[index] = true; 456 | 457 | return index; 458 | } 459 | 460 | template<> 461 | inline int ObjectPoolFindOrCreateIndex(ImObjectPool& nodes, const int node_id) 462 | { 463 | int node_idx = nodes.IdMap.GetInt(static_cast(node_id), -1); 464 | 465 | // Construct new node 466 | if (node_idx == -1) 467 | { 468 | if (nodes.FreeList.empty()) 469 | { 470 | node_idx = nodes.Pool.size(); 471 | IM_ASSERT(nodes.Pool.size() == nodes.InUse.size()); 472 | const int new_size = nodes.Pool.size() + 1; 473 | nodes.Pool.resize(new_size); 474 | nodes.InUse.resize(new_size); 475 | } 476 | else 477 | { 478 | node_idx = nodes.FreeList.back(); 479 | nodes.FreeList.pop_back(); 480 | } 481 | IM_PLACEMENT_NEW(nodes.Pool.Data + node_idx) ImNodeData(node_id); 482 | nodes.IdMap.SetInt(static_cast(node_id), node_idx); 483 | 484 | ImNodesEditorContext& editor = EditorContextGet(); 485 | editor.NodeDepthOrder.push_back(node_idx); 486 | } 487 | 488 | // Flag node as used 489 | nodes.InUse[node_idx] = true; 490 | 491 | return node_idx; 492 | } 493 | 494 | template 495 | static inline T& ObjectPoolFindOrCreateObject(ImObjectPool& objects, const int id) 496 | { 497 | const int index = ObjectPoolFindOrCreateIndex(objects, id); 498 | return objects.Pool[index]; 499 | } 500 | } // namespace IMNODES_NAMESPACE 501 | -------------------------------------------------------------------------------- /ringbuffer/ringbuffer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct ring_item_t { 6 | AVFrame *frame; 7 | Buffer id; 8 | } ring_item_t; 9 | 10 | typedef struct ring_buffer_t { 11 | unsigned size; 12 | unsigned mask; 13 | ring_item_t *items; 14 | unsigned tail_index; 15 | unsigned head_index; 16 | } ring_buffer_t; 17 | 18 | static int ring_buffer_init(ring_buffer_t *buffer, unsigned size) 19 | { 20 | buffer->tail_index = 0; 21 | buffer->head_index = 0; 22 | buffer->size = 1U << av_ceil_log2(size); 23 | buffer->mask = buffer->size-1U; 24 | 25 | buffer->items = (ring_item_t *)av_calloc(buffer->size, sizeof(*buffer->items)); 26 | if (!buffer->items) { 27 | buffer->size = 0; 28 | buffer->mask = 0; 29 | return AVERROR(ENOMEM); 30 | } 31 | return 0; 32 | } 33 | 34 | static void ring_buffer_free(ring_buffer_t *buffer) 35 | { 36 | av_freep(&buffer->items); 37 | buffer->mask = 0; 38 | buffer->size = 0; 39 | } 40 | 41 | static inline int ring_buffer_is_empty(ring_buffer_t *buffer) 42 | { 43 | return buffer->head_index == buffer->tail_index; 44 | } 45 | 46 | static inline int ring_buffer_is_full(ring_buffer_t *buffer) 47 | { 48 | return ((buffer->head_index - buffer->tail_index) & buffer->mask) == buffer->mask; 49 | } 50 | 51 | static void ring_buffer_enqueue(ring_buffer_t *buffer, ring_item_t data) 52 | { 53 | buffer->items[buffer->head_index] = data; 54 | buffer->head_index = ((buffer->head_index + 1U) & buffer->mask); 55 | } 56 | 57 | static void ring_buffer_dequeue(ring_buffer_t *buffer, ring_item_t *data) 58 | { 59 | if (!ring_buffer_is_empty(buffer)) { 60 | data[0] = buffer->items[buffer->tail_index]; 61 | buffer->items[buffer->tail_index] = { NULL, 0 }; 62 | buffer->tail_index = ((buffer->tail_index + 1U) & buffer->mask); 63 | } 64 | } 65 | 66 | static void ring_buffer_peek(ring_buffer_t *buffer, ring_item_t *data, unsigned index) 67 | { 68 | unsigned max = (buffer->head_index - buffer->tail_index) & buffer->mask; 69 | if (max > 0) { 70 | unsigned data_index = (buffer->tail_index + std::min(index, max - 1)) & buffer->mask; 71 | data[0] = buffer->items[data_index]; 72 | } 73 | } 74 | 75 | static inline unsigned ring_buffer_num_items(ring_buffer_t *buffer) 76 | { 77 | unsigned ret; 78 | 79 | ret = (buffer->head_index - buffer->tail_index) & buffer->mask; 80 | 81 | return ret; 82 | } 83 | --------------------------------------------------------------------------------