├── .clang-format ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── Doxyfile-mcss ├── Doxyfile.in ├── README.md ├── images ├── RB.png ├── blobs_1.png ├── blobs_2.png ├── blobs_3.png ├── equations │ ├── CFL.png │ ├── NS.png │ └── advection.png ├── simple_fluid.png ├── smoke.png ├── smoke_1.png ├── smoke_2.png ├── smoke_3.png └── splats.png ├── mainpage.md └── src ├── Clouds.cpp ├── Clouds.h ├── GLFWHandler.cpp ├── GLFWHandler.h ├── GLUtils.cpp ├── GLUtils.h ├── ProgramOptions.cpp ├── ProgramOptions.h ├── SimpleFluid.cpp ├── SimpleFluid.h ├── SimulationBase.h ├── SimulationFactory.cpp ├── SimulationFactory.h ├── Smoke.cpp ├── Smoke.h ├── glad.c ├── glad.h ├── khrplatform.h ├── lodepng.cpp ├── lodepng.h ├── main.cpp └── shaders ├── fragment.glsl ├── simulation ├── RKAdvect.comp ├── addSmokeSpot.comp ├── applyVorticity.comp ├── buoyantForce.comp ├── copy.comp ├── divCurl.comp ├── divRB.comp ├── includes.comp ├── jacobi.comp ├── jacobiBlack.comp ├── jacobiRed.comp ├── layout_size.comp ├── maxReduce.comp ├── mccormack.comp ├── pressureProjectionRB.comp ├── pressure_projection.comp └── waterContinuity.comp └── vertex.glsl /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # This configuration requires clang-format 3.8 or higher. 3 | BasedOnStyle: Mozilla 4 | AlignAfterOpenBracket: DontAlign 5 | AlignOperands: false 6 | AlwaysBreakAfterReturnType: None 7 | AlwaysBreakAfterDefinitionReturnType: None 8 | BreakBeforeBraces: Allman 9 | BinPackArguments: true 10 | BinPackParameters: true 11 | ColumnLimit: 100 12 | # Note that on versions after 4.0 you need to specify 13 | # SpaceAfterTemplateKeyword: true 14 | # which is not an option prior to 4.0. Later versions 15 | # of clang may produce results different from 3.8. 16 | # For your commits to be compatible with clang 3.8 17 | # you are best off running clang-format 3.8 on your 18 | # system 19 | Standard: Cpp03 20 | ... 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/glfw"] 2 | path = libs/glfw 3 | url = https://github.com/glfw/glfw.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - language: python 4 | dist: xenial 5 | sudo: false 6 | 7 | # Blacklist 8 | branches: 9 | only: 10 | - master 11 | python: 12 | - "3.6" 13 | addons: 14 | apt: 15 | packages: 16 | - libgs-dev 17 | before_install: 18 | - pip install -U pip jinja2 Pygments 19 | script: 20 | - curl http://doxygen.nl/files/doxygen-1.8.15.linux.bin.tar.gz --output doxygen.tar.gz 21 | - tar xfv doxygen.tar.gz 22 | - PATH=$PATH:doxygen-1.8.15/bin 23 | - export PATH 24 | - git clone https://github.com/mosra/m.css.git 25 | - python m.css/documentation/doxygen.py --debug Doxyfile-mcss 26 | - cp images html -R 27 | deploy: 28 | provider: pages 29 | skip_cleanup: true 30 | local_dir: html 31 | github_token: $GH_REPO_TOKEN 32 | on: 33 | branch: master 34 | 35 | - language: cpp 36 | dist: trusty 37 | addons: 38 | apt: 39 | update: true 40 | sources: 41 | - sourceline: 'ppa:mhier/libboost-latest' 42 | - ubuntu-toolchain-r-test 43 | packages: 44 | - gcc-7 45 | - g++-7 46 | - libxrandr-dev 47 | - libxinerama-dev 48 | - libxcursor-dev 49 | - libxi-dev 50 | - boost1.70 51 | script: 52 | - export CC=gcc-7 53 | - export CXX=g++-7 54 | - mkdir build 55 | - cd build 56 | - cmake .. 57 | - make 58 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.9) 2 | 3 | PROJECT(Simulation) 4 | 5 | SET(CMAKE_CXX_STANDARD 17) 6 | 7 | SET(OpenGL_GL_PREFERENCE "GLVND") 8 | FIND_PACKAGE( OpenGL REQUIRED ) 9 | 10 | INCLUDE_DIRECTORIES("libs/glfw/include") 11 | 12 | SET( ENKITS_BUILD_EXAMPLES OFF CACHE BOOL "Build basic example applications" ) 13 | SET( GLFW_BUILD_EXAMPLES OFF CACHE BOOL "GLFW lib only" ) 14 | SET( GLFW_BUILD_TESTS OFF CACHE BOOL "GLFW lib only" ) 15 | SET( GLFW_BUILD_DOCS OFF CACHE BOOL "GLFW lib only" ) 16 | SET( GLFW_BUILD_INSTALL OFF CACHE BOOL "GLFW lib only" ) 17 | 18 | ADD_SUBDIRECTORY("libs/glfw") 19 | 20 | FIND_PACKAGE(Boost COMPONENTS regex program_options REQUIRED) 21 | INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) 22 | 23 | FILE(GLOB toCompile 24 | "src/*.cpp" 25 | "src/*.c") 26 | 27 | ADD_EXECUTABLE( 28 | sim 29 | ${toCompile} 30 | ) 31 | 32 | TARGET_LINK_LIBRARIES(sim 33 | glfw 34 | OpenGL::GL 35 | ${Boost_LIBRARIES} 36 | ${Boost_REGEX_LIBRARY} 37 | ) 38 | 39 | IF(NOT WIN32) 40 | TARGET_LINK_LIBRARIES(sim 41 | ${CMAKE_DL_LIBS} 42 | ) 43 | ENDIF(NOT WIN32) 44 | 45 | ADD_CUSTOM_COMMAND(TARGET sim POST_BUILD 46 | COMMAND ${CMAKE_COMMAND} -E copy_directory 47 | ${CMAKE_SOURCE_DIR}/src/shaders $/shaders) 48 | -------------------------------------------------------------------------------- /Doxyfile-mcss: -------------------------------------------------------------------------------- 1 | @INCLUDE = Doxyfile.in 2 | GENERATE_HTML = NO 3 | GENERATE_XML = YES 4 | XML_PROGRAMLISTING = NO 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | # 2D Fluid Simulator using OpenGL [![Build Status](https://travis-ci.org/cgurps/2DFluidSimulation.svg?branch=master)](https://travis-ci.org/cgurps/2DFluidSimulation) 12 | 13 | This project is an implementation of an eulerian fluid simulation on GPU using OpenGL 4.3 compute shaders capabilities. 14 | 15 | ## Getting Started 16 | You will first need to clone the repository 17 | ``` 18 | git clone https://github.com/cgurps/2DFluidSimulation.git [PROJECT_FOLDER] 19 | ``` 20 | and then init the submodules 21 | ``` 22 | cd [PROJECT_FOLDER] 23 | git submodule update --init 24 | ``` 25 | To compile the project, you will need OpenGL with a version above 4.3 in order to get compute shader capabilities. You will also need [Boost](https://www.boost.org/) installed on your machine. To project uses CMake to generate the Makefile needed for the compilation. You can use these commands to build the executable 26 | 27 | ``` 28 | mkdir build 29 | cd build 30 | cmake .. 31 | make -j [YOUR_NUMBER_OF_CORES] 32 | ``` 33 | 34 | You can query the program options using `-h`. 35 | 36 | ## Numerical Scheme 37 | We solve the Navier-Stokes equation for incompressible fluids: 38 |

39 | 40 |

41 | As every eulerian approaches, the quantites (velocties, pressure, divergence, curl and so on) are stored in a square grid. The advection step uses a semi-Lagragian approach. The advection combines a Maccormack numerical scheme with a Runge Kutta method of order 4. The new created extremas are clamped using values from the first advection. If the new extrama is too far from the original computed value, I remove the error correction term (which boils down to reverting to the 4th order Runge Kutta approach). The next step adds forces to the velocity field (note that vorticity is implemented, but not used as the advection scheme is accurate enough to conserve swirls in the field). After that, the intermediate field is made incompressible using a projection method based on the Helmholtz-Hodge decomposition. I solve the associated poisson equation using the Jacobi method. The time step is computed at each iteration with 42 |

43 | 44 |

45 | The maximum of the velocity field is computed through a reduce method on the GPU. 46 | 47 | ## Implementation 48 | Each quantities is represented by a texture of 16bits floating points on the GPU. For exact texels query, I use the texelFetch method (which runs faster than using texture2D) and then handle the boundary cases by hand. The bilinear interpolation for the advection step is also computed by hand for better accuracy. The implementation contains three main classes: 49 | 1. `GLFWHandler` is the GLFW wrapper that contains the OpenGL initilization and the main program loop 50 | 2. `SimulationBase` which is a pure virtual function that gives the interface for the simulation. The main loop of the program accesses the `shared_texture` variable and display the associated texture on screen. This is where the various textures are created and stored. 51 | 3. `SimulationFactory` which contains helpers for computing steps of the simulation (like advection, pressure projection, etc). This class does not allocate GPU memory, but is instead feeded by the simulation loop. 52 | 53 | If you (ever) wish to play around this simulation, you should create a new class that inherits from `SimulationBase` and uses the `SimulationFactory` to compute whatever you need to compute. This new class must overload `Init()`, `Update()`, `AddSplat()`, `AddSplat(const int)` and `RemoveSplat()` for the simulation to work. 54 | 55 | ### Note on the Jacobi method 56 | I implemented a variation on the original Jacobi method described in [Harris et al.](https://users.cg.tuwien.ac.at/bruckner/ss2004/seminar/A3b/Harris2003%20-%20Simulation%20of%20Cloud%20Dynamics%20on%20Graphics%20Hardware.pdf) called the Red-Black Jacobi method. The idea is to pack four values into a single texel. The packing is done both on the divergence and on the pressure values. The next figure (reproduced from the Figure 5 of [Harris et al.](https://users.cg.tuwien.ac.at/bruckner/ss2004/seminar/A3b/Harris2003%20-%20Simulation%20of%20Cloud%20Dynamics%20on%20Graphics%20Hardware.pdf)) shows the process 57 |

58 | 59 |

60 | The resulting texture has half the size of the original one. Then, the Jacobi iteration updates first the black values (which only depend on the red one) and second the red values (using the computed black values). This almost divides the number of texel fetches by two, hence we can obtain the same order of convergence in approximatively half the time! The actual tricky part is to pack the divergence into one texel. This is done in one shader pass by grabing numerous adjacent values of the current texel (see the file divRB.comp). 61 | 62 | ## References 63 | 1. [@](http://jamie-wong.com/2016/08/05/webgl-fluid-simulation/): a simple tutorial on fluid simulation 64 | 2. [@](https://www.cs.ubc.ca/~rbridson/fluidsimulation/fluids_notes.pdf): this awesome books covers a lot of techniques for simulating fluids (classic!) 65 | 3. [@](https://cg.informatik.uni-freiburg.de/intern/seminar/gridFluids_GPU_Gems.pdf): 2D fluids from GPU gems 1 66 | 4. [@](https://www.cs.cmu.edu/~kmcrane/Projects/GPUFluid/): 3D fluids from GPU gems 3 67 | 5. [@](http://physbam.stanford.edu/~fedkiw/papers/stanford2006-09.pdf): the Maccormack method 68 | 6. [@](https://pdfs.semanticscholar.org/e1b5/f19526125df4de425f00f74a5271898e3258.pdf): this article explains the reverse method to handle extremas generated by the Maccormack scheme 69 | 7. [@](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods): The Runge Kutta method for the particle advection in the semi-Lagragian approach 70 | 71 | ## Nice github projects 72 | 1. [tunabrain/gpu-fluid](https://github.com/tunabrain/gpu-fluid): 2D fluid simulation on the GPU using an hydrid approach (FLIP) 73 | 2. [PavelDoGreat/WebGL-Fluid-Simulation](https://github.com/PavelDoGreat/WebGL-Fluid-Simulation): online fluid simulation 74 | 75 | -------------------------------------------------------------------------------- /images/RB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/RB.png -------------------------------------------------------------------------------- /images/blobs_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/blobs_1.png -------------------------------------------------------------------------------- /images/blobs_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/blobs_2.png -------------------------------------------------------------------------------- /images/blobs_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/blobs_3.png -------------------------------------------------------------------------------- /images/equations/CFL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/equations/CFL.png -------------------------------------------------------------------------------- /images/equations/NS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/equations/NS.png -------------------------------------------------------------------------------- /images/equations/advection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/equations/advection.png -------------------------------------------------------------------------------- /images/simple_fluid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/simple_fluid.png -------------------------------------------------------------------------------- /images/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/smoke.png -------------------------------------------------------------------------------- /images/smoke_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/smoke_1.png -------------------------------------------------------------------------------- /images/smoke_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/smoke_2.png -------------------------------------------------------------------------------- /images/smoke_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/smoke_3.png -------------------------------------------------------------------------------- /images/splats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgurps/2DFluidSimulation/058502ad88cc26c9c28265a03464f2fa4fb23bb3/images/splats.png -------------------------------------------------------------------------------- /mainpage.md: -------------------------------------------------------------------------------- 1 | # 2D Fluid Simulator using OpenGL 2 | This project is an implementation of an eulerian fluid simulation on GPU using OpenGL 4.3 compute shaders capabilities. 3 | ## Getting Started 4 | You will first need to clone the repository 5 | and then init the submodules 6 | ``` 7 | git clone https://github.com/cgurps/2DFluidSimulation.git [PROJECT_FOLDER] 8 | cd [PROJECT_FOLDER] 9 | git submodule update --init 10 | ``` 11 | To compile the project, you will need OpenGL with a version above 4.3 in order to get compute shader capabilities. 12 | You will also need [Boost](https://www.boost.org/) installed on your machine. To project uses CMake to generate 13 | the Makefile needed for the compilation. You can use these commands to build the executable 14 | ``` 15 | mkdir build 16 | cd build 17 | cmake .. 18 | make -j [YOUR_NUMBER_OF_CORES] 19 | ``` 20 | You can query the program options using `-h`. 21 | 22 | ## Implementation 23 | Each quantities is represented by a texture of 16bits floating points on the GPU. For exact texels query, 24 | I use the texelFetch method (which runs faster than using texture2D) and then handle the boundary cases 25 | by hand. The bilinear interpolation for the advection step is also computed by hand for better accuracy. 26 | The implementation contains three main classes: 27 | 1. `GLFWHandler` is the GLFW wrapper that contains the OpenGL initilization and the main program loop 28 | 2. `SimulationBase` which is a pure virtual function that gives the interface for the simulation. 29 | The main loop of the program accesses the `shared_texture` variable and display the associated texture on screen. 30 | This is where the various textures are created and stored. 31 | 3. `SimulationFactory` which contains helpers for computing steps of the simulation (like advection, 32 | pressure projection, etc). This class does not allocate GPU memory, but is instead feeded by the simulation loop. 33 | 34 | If you (ever) wish to play around this simulation, you should create a new class that inherits from `SimulationBase` and uses the 35 | `SimulationFactory` to compute whatever you need to compute. This new class must overload `Init()`, `Update()`, `AddSplat()`, 36 | `AddSplat(const int)` and `RemoveSplat()` for the simulation to work. 37 | 38 | ## References 39 | 1. [LINK](http://jamie-wong.com/2016/08/05/webgl-fluid-simulation/): a simple tutorial on fluid simulation 40 | 2. [LINK](https://www.cs.ubc.ca/~rbridson/fluidsimulation/fluids_notes.pdf): this awesome books covers a lot of techniques for simulating fluids (classic!) 41 | 3. [LINK](https://cg.informatik.uni-freiburg.de/intern/seminar/gridFluids_GPU_Gems.pdf): 2D fluids from GPU gems 1 42 | 4. [LINK](https://www.cs.cmu.edu/~kmcrane/Projects/GPUFluid/): 3D fluids from GPU gems 3 43 | 5. [LINK](http://physbam.stanford.edu/~fedkiw/papers/stanford2006-09.pdf): the Maccormack method 44 | 6. [LINK](https://pdfs.semanticscholar.org/e1b5/f19526125df4de425f00f74a5271898e3258.pdf): this article explains the reverse method to handle extremas generated by the Maccormack scheme 45 | 7. [LINK](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods): The Runge Kutta method for the particle advection in the semi-Lagragian approach 46 | 47 | ## Nice github projects 48 | 1. [tunabrain/gpu-fluid](https://github.com/tunabrain/gpu-fluid): 2D fluid simulation on the GPU using an hydrid approach (FLIP) 49 | 2. [PavelDoGreat/WebGL-Fluid-Simulation](https://github.com/PavelDoGreat/WebGL-Fluid-Simulation): online fluid simulation 50 | 51 | -------------------------------------------------------------------------------- /src/Clouds.cpp: -------------------------------------------------------------------------------- 1 | #include "Clouds.h" 2 | #include "GLUtils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | Clouds::~Clouds() 10 | { 11 | glDeleteTextures(4, velocitiesTexture); 12 | glDeleteTextures(4, density); 13 | glDeleteTextures(1, &divergenceCurlTexture); 14 | glDeleteTextures(2, pressureTexture); 15 | glDeleteTextures(1, &emptyTexture); 16 | } 17 | 18 | void Clouds::Init() 19 | { 20 | /********** Texture Initilization **********/ 21 | auto f = [](unsigned, unsigned) 22 | { 23 | return std::make_tuple(0.0f, 0.0f, 0.0f, 0.0f); 24 | }; 25 | 26 | auto f1 = [](unsigned, unsigned y) 27 | { 28 | if(y <= 5) return std::make_tuple(1.0f, 0.0f, 0.0f, 0.0f); 29 | else return std::make_tuple(0.0f, 0.0f, 0.0f, 0.0f); 30 | }; 31 | 32 | auto f2 = [](unsigned, unsigned y) 33 | { 34 | if(y <= 5) return std::make_tuple(20.0f, 0.0f, 0.0f, 0.0f); 35 | else return std::make_tuple(0.0f, 0.0f, 0.0f, 0.0f); 36 | }; 37 | 38 | density[0] = createTexture2D(options->simWidth, options->simHeight); 39 | density[1] = createTexture2D(options->simWidth, options->simHeight); 40 | density[2] = createTexture2D(options->simWidth, options->simHeight); 41 | fillTextureWithFunctor(density[0], options->simWidth, options->simHeight, f1); 42 | 43 | potentialTemperature[0] = createTexture2D(options->simWidth, options->simHeight); 44 | potentialTemperature[1] = createTexture2D(options->simWidth, options->simHeight); 45 | potentialTemperature[2] = createTexture2D(options->simWidth, options->simHeight); 46 | fillTextureWithFunctor(potentialTemperature[0], options->simWidth, options->simHeight, f2); 47 | 48 | velocitiesTexture[0] = createTexture2D(options->simWidth, options->simHeight); 49 | velocitiesTexture[1] = createTexture2D(options->simWidth, options->simHeight); 50 | velocitiesTexture[2] = createTexture2D(options->simWidth, options->simHeight); 51 | fillTextureWithFunctor(velocitiesTexture[0], options->simWidth, options->simHeight, f); 52 | 53 | divergenceCurlTexture = createTexture2D(options->simWidth, options->simHeight); 54 | fillTextureWithFunctor(divergenceCurlTexture, options->simWidth, options->simHeight, f); 55 | 56 | pressureTexture[0] = createTexture2D(options->simWidth, options->simHeight); 57 | pressureTexture[1] = createTexture2D(options->simWidth, options->simHeight); 58 | fillTextureWithFunctor(pressureTexture[0], options->simWidth, options->simHeight, f); 59 | 60 | emptyTexture = createTexture2D(options->simWidth, options->simHeight); 61 | fillTextureWithFunctor(emptyTexture, options->simWidth, options->simHeight, f); 62 | } 63 | 64 | void Clouds::AddSplat() 65 | { 66 | } 67 | 68 | void Clouds::AddMultipleSplat(const int) 69 | { 70 | } 71 | 72 | void Clouds::RemoveSplat() 73 | { 74 | } 75 | 76 | void Clouds::Update() 77 | { 78 | /********** Adding Clouds Origin *********/ 79 | auto rd = []() -> double 80 | { 81 | return (double) rand() / (double) RAND_MAX; 82 | }; 83 | 84 | int x = options->simWidth / 2; int y = 75; 85 | 86 | /* 87 | sFact.addSplat(density[READ], std::make_tuple(x, y), std::make_tuple(0.12f, 0.31f, 0.7f), 1.0f); 88 | sFact.addSplat(potentialTemperature[READ], std::make_tuple(x, y), std::make_tuple(rd() * 20.0f + 10.0f, 0.0f, 0.0f), 8.0f); 89 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(x, y), std::make_tuple(2.0f * rd() - 1.0f, 0.0f, 0.0f), 75.0f); 90 | */ 91 | 92 | /********** Convection **********/ 93 | sFact.mcAdvect(velocitiesTexture[READ], velocitiesTexture); 94 | std::swap(velocitiesTexture[0], velocitiesTexture[2]); 95 | 96 | /********** Advections **********/ 97 | sFact.mcAdvect(velocitiesTexture[READ], density); 98 | std::swap(density[0], density[2]); 99 | sFact.mcAdvect(velocitiesTexture[READ], potentialTemperature); 100 | std::swap(potentialTemperature[0], potentialTemperature[2]); 101 | 102 | /********** Buoyant Force **********/ 103 | sFact.applyBuoyantForce(velocitiesTexture[READ], potentialTemperature[READ], density[READ], 0.25f, 0.1f, 15.0f); 104 | 105 | /********** Divergence & Curl **********/ 106 | sFact.divergenceCurl(velocitiesTexture[READ], divergenceCurlTexture); 107 | 108 | /********** Vorticity **********/ 109 | sFact.applyVorticity(velocitiesTexture[READ], divergenceCurlTexture); 110 | 111 | /********** Updating Thermodynamics *********/ 112 | sFact.updateQAndTheta(density[READ], potentialTemperature); 113 | 114 | /********** Poisson Solving with Jacobi **********/ 115 | sFact.copy(emptyTexture, pressureTexture[READ]); 116 | for(int k = 0; k < 25; ++k) 117 | { 118 | sFact.solvePressure(divergenceCurlTexture, pressureTexture[READ], pressureTexture[WRITE]); 119 | std::swap(pressureTexture[READ], pressureTexture[WRITE]); 120 | } 121 | 122 | /********** Pressure Projection **********/ 123 | sFact.pressureProjection(pressureTexture[READ], velocitiesTexture[READ], velocitiesTexture[WRITE]); 124 | std::swap(velocitiesTexture[READ], velocitiesTexture[WRITE]); 125 | 126 | /********** Updating the shared texture **********/ 127 | shared_texture = density[READ]; 128 | } 129 | -------------------------------------------------------------------------------- /src/Clouds.h: -------------------------------------------------------------------------------- 1 | #ifndef CLOUDS_H 2 | #define CLOUDS_H 3 | 4 | #include "SimulationBase.h" 5 | #include "SimulationFactory.h" 6 | 7 | class Clouds : public SimulationBase 8 | { 9 | public: 10 | Clouds(ProgramOptions *options, GLFWHandler *handler) 11 | : SimulationBase(options, handler) {} 12 | 13 | ~Clouds(); 14 | 15 | void Init() override; 16 | void Update() override; 17 | 18 | void AddSplat() override; 19 | void AddMultipleSplat(const int nb) override; 20 | void RemoveSplat() override; 21 | private: 22 | int READ = 0, WRITE = 1; 23 | 24 | GLuint velocitiesTexture[3]; 25 | GLuint density[3]; 26 | GLuint potentialTemperature[3]; 27 | GLuint divergenceCurlTexture; 28 | GLuint pressureTexture[2]; 29 | GLuint emptyTexture; 30 | }; 31 | 32 | #endif //CLOUD_H 33 | -------------------------------------------------------------------------------- /src/GLFWHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "GLFWHandler.h" 2 | #include "SimulationBase.h" 3 | #include "lodepng.h" 4 | 5 | #include 6 | 7 | /********** Event Callbacks **********/ 8 | static void glfwErrorCallback(int error, const char* description) 9 | { 10 | std::cerr << "Error(" << error << "): " << description << std::endl; 11 | } 12 | 13 | static void mouseCallback(GLFWwindow* window, int button, int action, int) 14 | { 15 | if(button == GLFW_MOUSE_BUTTON_LEFT) 16 | { 17 | GLFWHandler *handler = (GLFWHandler*) glfwGetWindowUserPointer(window); 18 | if(action == GLFW_PRESS || handler->leftMouseButtonLastState == GLFW_PRESS) 19 | handler->simulation->AddSplat(); 20 | else if(action == GLFW_RELEASE) 21 | handler->simulation->RemoveSplat(); 22 | } 23 | } 24 | 25 | static void keyCallback(GLFWwindow* window, int key, int, int action, int) 26 | { 27 | if(key == GLFW_KEY_E && action == GLFW_PRESS) 28 | { 29 | GLFWHandler *handler = (GLFWHandler*) glfwGetWindowUserPointer(window); 30 | handler->simulation->AddMultipleSplat(10); 31 | } 32 | 33 | if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 34 | { 35 | glfwSetWindowShouldClose(window, GLFW_TRUE); 36 | } 37 | } 38 | 39 | static void windowResizeCallback(GLFWwindow* window, int width, int height) 40 | { 41 | GLFWHandler *handler = (GLFWHandler*) glfwGetWindowUserPointer(window); 42 | handler->options->windowWidth = width; 43 | handler->options->windowHeight = height; 44 | } 45 | /*************************************/ 46 | 47 | GLFWHandler::GLFWHandler(ProgramOptions *options) 48 | : options(options) 49 | { 50 | glfwSetErrorCallback(glfwErrorCallback); 51 | 52 | if(!glfwInit()) 53 | { 54 | std::cerr << "GLFW Init failed!" << std::endl; 55 | std::exit(1); 56 | } 57 | 58 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); 59 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); 60 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); 61 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE); 62 | glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); 63 | 64 | window = glfwCreateWindow(options->windowWidth, options->windowHeight, "Fluid Simulation", NULL, NULL); 65 | if(!window) 66 | { 67 | std::cerr << "GLFW Window creation failed!" << std::endl; 68 | std::exit(1); 69 | } 70 | 71 | glfwMakeContextCurrent(window); 72 | 73 | registerEvent(); 74 | 75 | if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) 76 | { 77 | std::cerr << "Failed to initialize GLAD" << std::endl; 78 | std::exit(1); 79 | } 80 | 81 | printf("OpenGL version supported by this platform (%s)\n", 82 | glGetString(GL_VERSION)); 83 | printf("Supported GLSL version is %s.\n", 84 | glGetString(GL_SHADING_LANGUAGE_VERSION)); 85 | 86 | glfwSwapInterval(1); 87 | 88 | GLint flags; 89 | glGetIntegerv(GL_CONTEXT_FLAGS, &flags); 90 | if(flags & GL_CONTEXT_FLAG_DEBUG_BIT) 91 | { 92 | glEnable(GL_DEBUG_OUTPUT); 93 | glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); 94 | glDebugMessageCallback(MessageCallback, 0); 95 | glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); 96 | } 97 | else 98 | { 99 | std::cout << "Failed to init debug context" << std::endl; 100 | } 101 | 102 | /********** Configuring pipeline *********/ 103 | const float vertices[] = 104 | { 105 | // positions // texture coords 106 | 1.0f, 1.0f, 1.0f, 1.0f, 107 | 1.0f, - 1.0f, 1.0f, 0.0f, 108 | - 1.0f, 1.0f, 0.0f, 1.0f, 109 | - 1.0f, - 1.0f, 0.0f, 0.0f 110 | }; 111 | 112 | const std::uint32_t indices[] = 113 | { 114 | 0, 1, 2, 115 | 3, 1, 2 116 | }; 117 | 118 | GLuint vbo; 119 | 120 | glGenBuffers(1, &vbo); 121 | glBindBuffer(GL_ARRAY_BUFFER, vbo); 122 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); 123 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*) 0); 124 | glEnableVertexAttribArray(0); 125 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float))); 126 | glEnableVertexAttribArray(1); 127 | glGenBuffers(1, &ebo); 128 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); 129 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); 130 | 131 | /********** Linking shaders **********/ 132 | const GLuint vertex_shader = compileShader("shaders/vertex.glsl", GL_VERTEX_SHADER); 133 | const GLuint fragment_shader = compileShader("shaders/fragment.glsl", GL_FRAGMENT_SHADER); 134 | 135 | shader_program = glCreateProgram(); 136 | glAttachShader(shader_program, vertex_shader); 137 | glAttachShader(shader_program, fragment_shader); 138 | glBindFragDataLocation(shader_program, 0, "outColor"); 139 | glLinkProgram(shader_program); 140 | glUseProgram(shader_program); 141 | 142 | glDeleteShader(vertex_shader); 143 | glDeleteShader(fragment_shader); 144 | } 145 | 146 | GLFWHandler::~GLFWHandler() 147 | { 148 | glfwDestroyWindow(window); 149 | glfwTerminate(); 150 | } 151 | 152 | void GLFWHandler::attachSimulation(SimulationBase* sim) 153 | { 154 | simulation = sim; 155 | simulation->Init(); 156 | } 157 | 158 | void GLFWHandler::registerEvent() 159 | { 160 | glfwSetWindowUserPointer(window, this); 161 | glfwSetMouseButtonCallback(window, mouseCallback); 162 | glfwSetKeyCallback(window, keyCallback); 163 | glfwSetWindowSizeCallback(window, windowResizeCallback); 164 | } 165 | 166 | void GLFWHandler::run() 167 | { 168 | int tex_loc = glGetUniformLocation(shader_program, "tex"); 169 | glUseProgram(shader_program); 170 | glUniform1i(tex_loc, 0); 171 | 172 | /********** Linear Sampler for rendering the texture **********/ 173 | GLuint linearSampler; 174 | glGenSamplers(1, &linearSampler); 175 | glSamplerParameteri(linearSampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 176 | glSamplerParameteri(linearSampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 177 | glSamplerParameteri(linearSampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 178 | glSamplerParameteri(linearSampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 179 | glSamplerParameteri(linearSampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); 180 | 181 | /********** Compute shader timings ***********/ 182 | GLint64 startTime, stopTime; 183 | GLuint queryID[2]; 184 | 185 | std::chrono::high_resolution_clock::time_point 186 | start = std::chrono::high_resolution_clock::now(); 187 | double sumOfDeltaT = 0.0; 188 | 189 | /********** Array of images for the export **********/ 190 | std::vector buffers; 191 | 192 | char text[100]; 193 | 194 | /********** Rendering & Simulation Loop ***********/ 195 | while (!glfwWindowShouldClose(window)) 196 | { 197 | /********** Generating queries for timing **********/ 198 | glGenQueries(2, queryID); 199 | glQueryCounter(queryID[0], GL_TIMESTAMP); 200 | 201 | /********** Updating the simulation **********/ 202 | simulation->Update(); 203 | 204 | /********** Compute shader execution time *********/ 205 | glQueryCounter(queryID[1], GL_TIMESTAMP); 206 | GLint stopTimerAvailable = 0; 207 | while (!stopTimerAvailable) { 208 | glGetQueryObjectiv(queryID[1], 209 | GL_QUERY_RESULT_AVAILABLE, 210 | &stopTimerAvailable); 211 | } 212 | glGetQueryObjectui64v(queryID[0], GL_QUERY_RESULT, (GLuint64*) &startTime); 213 | glGetQueryObjectui64v(queryID[1], GL_QUERY_RESULT, (GLuint64*) &stopTime); 214 | 215 | std::chrono::high_resolution_clock::time_point 216 | current = std::chrono::high_resolution_clock::now(); 217 | sumOfDeltaT += options->dt; 218 | std::chrono::duration timeSpan = current - start; 219 | 220 | sprintf(text, "\rDelta from real time: %.4f s (%.3f ms, %.5f dt)" 221 | , sumOfDeltaT - timeSpan.count() / 1000.0 222 | , (stopTime - startTime) / 1000000.0 223 | , options->dt); 224 | printf("%s", text); 225 | fflush(stdout); 226 | 227 | glfwPollEvents(); 228 | 229 | /********** Rendering the texture **********/ 230 | int displayW, displayH; 231 | glfwGetFramebufferSize(window, &displayW, &displayH); 232 | glViewport(0, 0, displayW, displayH); 233 | 234 | glClearColor(0.0, 0.0, 0.0, 1.0); 235 | glClear(GL_COLOR_BUFFER_BIT); 236 | 237 | glUseProgram(shader_program); 238 | glActiveTexture(GL_TEXTURE0); 239 | glBindTexture(GL_TEXTURE_2D, simulation->shared_texture); 240 | glBindSampler(0, linearSampler); 241 | 242 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); 243 | glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); 244 | 245 | glBindSampler(0, 0); 246 | 247 | /********** Saving texture for the export **********/ 248 | if(options->exportImages) 249 | { 250 | unsigned char *colors = new unsigned char[3 * options->simWidth * options->simHeight]; 251 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, colors); 252 | buffers.push_back(colors); 253 | } 254 | 255 | glfwSwapBuffers(window); 256 | } 257 | 258 | /********** Exporting the frames to the disk **********/ 259 | if(options->exportImages) 260 | { 261 | auto storeImage = [](const char* path, const unsigned char* colors, unsigned int w, unsigned int h) 262 | { 263 | std::cout << "Storing " << path << std::endl; 264 | 265 | unsigned char reversed[3 * w * h]; 266 | for(unsigned int x = 0; x < w; ++x) 267 | { 268 | for(unsigned int y = 0; y < h; ++y) 269 | { 270 | reversed[3 * (y * w + x)] = colors[ 3 * ( (h - y - 1) * w + x )]; 271 | reversed[3 * (y * w + x) + 1] = colors[3 * ( (h - y - 1) * w + x ) + 1]; 272 | reversed[3 * (y * w + x) + 2] = colors[3 * ( (h - y - 1) * w + x ) + 2]; 273 | } 274 | } 275 | 276 | unsigned error = lodepng_encode24_file(path, reversed, w, h); 277 | if(error) std::cout << "Encode Error: " << error << ": " << lodepng_error_text(error) << std::endl; 278 | delete[] colors; 279 | }; 280 | 281 | for(unsigned int i = 0; i < buffers.size(); ++i) 282 | { 283 | char path[1024]; 284 | if(i < 10) 285 | sprintf(path, "frame_00%i.png", i); 286 | else if (i < 100) 287 | sprintf(path, "frame_0%i.png", i); 288 | else 289 | sprintf(path, "frame_%i.png", i); 290 | 291 | storeImage(path, buffers[i], options->simWidth, options->simHeight); 292 | } 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /src/GLFWHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * @dir src 5 | * @brief The source directory 6 | */ 7 | 8 | /** 9 | * @file GLFWHandler.h 10 | * @author Thomas Caissard (\c thomas.caissard@gmail.com) 11 | * @date 2019/08/05 12 | * @brief Handler for OpenGL main rendering loop 13 | */ 14 | 15 | 16 | #include 17 | 18 | #include "GLUtils.h" 19 | #include "ProgramOptions.h" 20 | 21 | /** 22 | * @ref SimulationBase 23 | */ 24 | class SimulationBase; 25 | 26 | /** 27 | * @class GLFWHandler 28 | * @brief Initilization and main loop for OpenGL 29 | */ 30 | class GLFWHandler 31 | { 32 | public: 33 | /** 34 | * Default constructor deletion 35 | */ 36 | GLFWHandler() = delete; 37 | 38 | /** 39 | * Default constructor 40 | * @param options Program options 41 | */ 42 | GLFWHandler(ProgramOptions *options); 43 | 44 | /** 45 | * Default destructor 46 | */ 47 | ~GLFWHandler(); 48 | 49 | /** 50 | * Setter for the simulation class 51 | * @param sim Pointer to the simulation 52 | */ 53 | void attachSimulation(SimulationBase* sim); 54 | 55 | /** 56 | * Main rendering loop 57 | */ 58 | void run(); 59 | 60 | /** 61 | * The program options 62 | */ 63 | ProgramOptions *options; 64 | 65 | /** 66 | * The rendering window 67 | */ 68 | GLFWwindow* window; 69 | 70 | /** 71 | * Pointer to the simulation class 72 | */ 73 | SimulationBase* simulation; 74 | 75 | /** 76 | * Left button state memory 77 | */ 78 | int leftMouseButtonLastState = GLFW_RELEASE; 79 | private: 80 | /** 81 | * Register all application events 82 | */ 83 | void registerEvent(); 84 | 85 | /** 86 | * Shader Program ID 87 | */ 88 | GLuint shader_program; 89 | 90 | /** 91 | * EBO ID 92 | */ 93 | GLuint ebo; 94 | }; 95 | -------------------------------------------------------------------------------- /src/GLUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "GLUtils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void APIENTRY MessageCallback(GLenum source, 8 | GLenum type, 9 | GLuint id, 10 | GLenum severity, 11 | GLsizei length, 12 | const GLchar* message, 13 | const void* userParam) 14 | { 15 | if(id == 131169 || id == 131185 || id == 131218 || id == 131204) return; 16 | 17 | std::cout << "---------------" << std::endl; 18 | std::cout << "Debug message (" << id << "): " << message << std::endl; 19 | 20 | switch (source) 21 | { 22 | case GL_DEBUG_SOURCE_API: std::cout << "Source: API"; break; 23 | case GL_DEBUG_SOURCE_WINDOW_SYSTEM: std::cout << "Source: Window System"; break; 24 | case GL_DEBUG_SOURCE_SHADER_COMPILER: std::cout << "Source: Shader Compiler"; break; 25 | case GL_DEBUG_SOURCE_THIRD_PARTY: std::cout << "Source: Third Party"; break; 26 | case GL_DEBUG_SOURCE_APPLICATION: std::cout << "Source: Application"; break; 27 | case GL_DEBUG_SOURCE_OTHER: std::cout << "Source: Other"; break; 28 | } std::cout << std::endl; 29 | 30 | switch (type) 31 | { 32 | case GL_DEBUG_TYPE_ERROR: std::cout << "Type: Error"; break; 33 | case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: std::cout << "Type: Deprecated Behaviour"; break; 34 | case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: std::cout << "Type: Undefined Behaviour"; break; 35 | case GL_DEBUG_TYPE_PORTABILITY: std::cout << "Type: Portability"; break; 36 | case GL_DEBUG_TYPE_PERFORMANCE: std::cout << "Type: Performance"; break; 37 | case GL_DEBUG_TYPE_MARKER: std::cout << "Type: Marker"; break; 38 | case GL_DEBUG_TYPE_PUSH_GROUP: std::cout << "Type: Push Group"; break; 39 | case GL_DEBUG_TYPE_POP_GROUP: std::cout << "Type: Pop Group"; break; 40 | case GL_DEBUG_TYPE_OTHER: std::cout << "Type: Other"; break; 41 | } std::cout << std::endl; 42 | 43 | switch (severity) 44 | { 45 | case GL_DEBUG_SEVERITY_HIGH: std::cout << "Severity: high"; break; 46 | case GL_DEBUG_SEVERITY_MEDIUM: std::cout << "Severity: medium"; break; 47 | case GL_DEBUG_SEVERITY_LOW: std::cout << "Severity: low"; break; 48 | case GL_DEBUG_SEVERITY_NOTIFICATION: std::cout << "Severity: notification"; break; 49 | } std::cout << std::endl; 50 | std::cout << std::endl; 51 | } 52 | 53 | GLuint createTexture2D(const unsigned width, const unsigned height) 54 | { 55 | 56 | GLuint tex; 57 | glGenTextures(1, &tex); 58 | glBindTexture(GL_TEXTURE_2D, tex); 59 | 60 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 61 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 62 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); 63 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 64 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 65 | 66 | const std::vector data(4 * width * height, 0.0f); 67 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, data.data()); 68 | 69 | glBindTexture(GL_TEXTURE_2D, 0); 70 | 71 | return tex; 72 | } 73 | 74 | GLuint compileShader(const std::string& s, GLenum type) 75 | { 76 | std::cout << "Compiling " << s << "..."; 77 | std::ifstream shader_file(s); 78 | std::ostringstream shader_buffer; 79 | shader_buffer << shader_file.rdbuf(); 80 | std::string shader_string = preprocessIncludes(shader_buffer.str(), "shaders/simulation/", 32); 81 | const GLchar *shader_source = shader_string.c_str(); 82 | 83 | GLuint shader_id = glCreateShader(type); 84 | glShaderSource(shader_id, 1, &shader_source, NULL); 85 | glCompileShader(shader_id); 86 | 87 | GLint status; 88 | glGetShaderiv(shader_id, GL_COMPILE_STATUS, &status); 89 | 90 | if(status == GL_TRUE) 91 | { 92 | std::cout << " OK" << std::endl; 93 | return shader_id; 94 | } 95 | else 96 | { 97 | exit(1); 98 | } 99 | } 100 | 101 | GLuint compileAndLinkShader(const std::string& s, GLenum type) 102 | { 103 | GLuint shader = compileShader(s, type); 104 | GLuint program = glCreateProgram(); 105 | glAttachShader(program, shader); 106 | glLinkProgram(program); 107 | 108 | return program; 109 | } 110 | 111 | std::string preprocessIncludes( const std::string source, const std::string shader_path, int level /*= 0 */ ) 112 | { 113 | static const boost::regex re("^[ ]*#[ ]*include[ ]+[\"<](.*)[\">].*"); 114 | std::stringstream input; 115 | std::stringstream output; 116 | input << source; 117 | 118 | size_t line_number = 1; 119 | boost::smatch matches; 120 | 121 | std::string line; 122 | while(std::getline(input,line)) 123 | { 124 | if (boost::regex_search(line, matches, re)) 125 | { 126 | std::string include_file = matches[1]; 127 | std::string include_string; 128 | 129 | std::ifstream shader_file(shader_path + include_file); 130 | std::ostringstream shader_buffer; 131 | shader_buffer << shader_file.rdbuf(); 132 | include_string = shader_buffer.str(); 133 | 134 | output << preprocessIncludes(include_string, shader_path, level + 1) << std::endl; 135 | } 136 | else 137 | { 138 | output << line << std::endl; 139 | } 140 | ++line_number; 141 | } 142 | 143 | return output.str(); 144 | } 145 | -------------------------------------------------------------------------------- /src/GLUtils.h: -------------------------------------------------------------------------------- 1 | #include "glad.h" 2 | 3 | #ifdef __unix__ 4 | #define GLFW_EXPOSE_NATIVE_X11 5 | #define GLFW_EXPOSE_NATIVE_GLX 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | void APIENTRY MessageCallback(GLenum source, 16 | GLenum type, 17 | GLuint id, 18 | GLenum severity, 19 | GLsizei length, 20 | const GLchar* message, 21 | const void* userParam); 22 | 23 | GLuint createTexture2D(const unsigned width, const unsigned height); 24 | GLuint compileShader(const std::string& s, GLenum type); 25 | GLuint compileAndLinkShader(const std::string& s, GLenum type); 26 | std::string preprocessIncludes(const std::string source, const std::string shader_path, int level); 27 | -------------------------------------------------------------------------------- /src/ProgramOptions.cpp: -------------------------------------------------------------------------------- 1 | #include "ProgramOptions.h" 2 | 3 | #include 4 | 5 | std::ostream& operator<<(std::ostream& os, const SimulationType& type) 6 | { 7 | switch(type) 8 | { 9 | case SPLATS: 10 | os << "splats"; 11 | break; 12 | case SMOKE: 13 | os << "smoke"; 14 | break; 15 | case CLOUDS: 16 | os << "clouds"; 17 | break; 18 | } 19 | 20 | return os; 21 | } 22 | 23 | std::istream& operator>>(std::istream& is, SimulationType& type) 24 | { 25 | std::string token; 26 | is >> token; 27 | if(token == "splats") { type = SPLATS; return is; } 28 | if(token == "smoke") { type = SMOKE; return is; } 29 | if(token == "clouds") { type = CLOUDS; return is; } 30 | 31 | throw std::invalid_argument("bad simulation"); 32 | return is; 33 | } 34 | 35 | ProgramOptions parseOptions(int argc, char* argv[]) 36 | { 37 | namespace po = boost::program_options; 38 | 39 | ProgramOptions options; 40 | 41 | po::options_description poWindow("Window options"); 42 | poWindow.add_options() 43 | ("windowWidth", po::value(&options.windowWidth)->default_value(800), "window width") 44 | ("windowHeight", po::value(&options.windowHeight)->default_value(800), "window height") 45 | ("exportImages", po::value(&options.exportImages)->default_value(false), "export simulation to a set of PNG files") 46 | ; 47 | 48 | po::options_description poSim("Simulation options"); 49 | poSim.add_options() 50 | ("simType,s", po::value(&options.simType)->default_value(SPLATS), "type of simulation (splats, smoke)") 51 | ("deltaTime,t", po::value(&options.dt)->default_value(0.1f), "time step for the simulation") 52 | ("simWidth", po::value(&options.simWidth)->default_value(1024), "simulation width (must be a power of 2)") 53 | ("simHeight", po::value(&options.simHeight)->default_value(1024), "simulation height (must be a power of 2)") 54 | ("jacobi-iterations", po::value(&options.jacobiIterations)->default_value(50), "number of iterations for the Jacobi method") 55 | ("mc-revert", po::value(&options.mcRevert)->default_value(0.05), "revert parameter for the maccormack advection scheme") 56 | ; 57 | 58 | po::options_description po_options("sim [options]"); 59 | po_options.add(poWindow).add(poSim).add_options() 60 | ("help,h", "display this message") 61 | ; 62 | 63 | try 64 | { 65 | po::variables_map vm; 66 | po::store(po::command_line_parser(argc, argv).options(po_options).run(), vm); 67 | po::notify(vm); 68 | 69 | if(vm.count("help")) 70 | { 71 | std::cout << po_options; 72 | std::exit(0); 73 | } 74 | } 75 | catch (std::exception& ex) 76 | { 77 | std::cout << ex.what() << std::endl; 78 | std::cout << po_options; 79 | std::exit(1); 80 | } 81 | 82 | return options; 83 | } 84 | -------------------------------------------------------------------------------- /src/ProgramOptions.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRAMOPTIONS_H 2 | #define PROGRAMOPTIONS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum SimulationType 11 | { 12 | SPLATS, 13 | SMOKE, 14 | CLOUDS 15 | }; 16 | 17 | std::ostream& operator<<(std::ostream& os, const SimulationType& type); 18 | std::istream& operator>>(std::istream& os, SimulationType& type); 19 | 20 | struct ProgramOptions 21 | { 22 | unsigned windowWidth, windowHeight; 23 | 24 | SimulationType simType; 25 | unsigned simWidth, simHeight; 26 | unsigned jacobiIterations; 27 | float dt; 28 | float mcRevert; 29 | 30 | bool exportImages; 31 | }; 32 | 33 | ProgramOptions parseOptions(int argc, char* argv[]); 34 | 35 | #endif //PROGRAMOPTIONS_H 36 | -------------------------------------------------------------------------------- /src/SimpleFluid.cpp: -------------------------------------------------------------------------------- 1 | #include "SimpleFluid.h" 2 | #include "GLUtils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | float rd() 10 | { 11 | return (float) rand() / (float) RAND_MAX; 12 | } 13 | 14 | SimpleFluid::~SimpleFluid() 15 | { 16 | glDeleteTextures(4, velocitiesTexture); 17 | glDeleteTextures(4, density); 18 | glDeleteTextures(1, &divergenceCurlTexture); 19 | glDeleteTextures(1, &divRBTexture); 20 | glDeleteTextures(1, &pressureRBTexture); 21 | } 22 | 23 | void SimpleFluid::Init() 24 | { 25 | /********** Texture Initilization **********/ 26 | auto f = [](unsigned, unsigned) 27 | { 28 | return std::make_tuple(0.0f, 0.0f, 29 | 0.0f, 0.0f); 30 | }; 31 | 32 | density[0] = createTexture2D(options->simWidth, options->simHeight); 33 | density[1] = createTexture2D(options->simWidth, options->simHeight); 34 | density[2] = createTexture2D(options->simWidth, options->simHeight); 35 | density[3] = createTexture2D(options->simWidth, options->simHeight); 36 | fillTextureWithFunctor(density[0], options->simWidth, options->simHeight, f); 37 | 38 | velocitiesTexture[0] = createTexture2D(options->simWidth, options->simHeight); 39 | velocitiesTexture[1] = createTexture2D(options->simWidth, options->simHeight); 40 | velocitiesTexture[2] = createTexture2D(options->simWidth, options->simHeight); 41 | velocitiesTexture[3] = createTexture2D(options->simWidth, options->simHeight); 42 | fillTextureWithFunctor(velocitiesTexture[0], options->simWidth, options->simHeight, f); 43 | 44 | divergenceCurlTexture = createTexture2D(options->simWidth, options->simHeight); 45 | fillTextureWithFunctor(divergenceCurlTexture, options->simWidth, options->simHeight, f); 46 | 47 | divRBTexture = createTexture2D(options->simWidth / 2, options->simHeight / 2); 48 | fillTextureWithFunctor(divRBTexture, options->simWidth / 2, options->simHeight / 2, f); 49 | 50 | pressureRBTexture = createTexture2D(options->simWidth / 2, options->simHeight / 2); 51 | 52 | unsigned x = 300u; unsigned y = 512u; 53 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(x, y), std::make_tuple(80.0f, 7.0f, 0.0f), 1.0f); 54 | sFact.addSplat(density[READ], std::make_tuple(x, y), std::make_tuple(75.0 / 255.0, 89.0 / 255.0, 1.0), 2.5f); 55 | 56 | x = 700u; y = 512u; 57 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(x, y), std::make_tuple(- 80.0f, - 7.0f, 0.0f), 1.0f); 58 | sFact.addSplat(density[READ], std::make_tuple(x, y), std::make_tuple(1.0, 151.0 / 255.0, 60.0 / 255.0), 2.5f); 59 | } 60 | 61 | void SimpleFluid::AddSplat() 62 | { 63 | glfwGetCursorPos(handler->window, &sOriginX, &sOriginY); 64 | sOriginX = (double) options->simWidth * sOriginX / (double) options->windowWidth; 65 | sOriginY = (double) options->simHeight * (1.0 - sOriginY / (double) options->windowHeight); 66 | 67 | addSplat = true; 68 | } 69 | 70 | void SimpleFluid::AddMultipleSplat(const int nb) 71 | { 72 | nbSplat += nb; 73 | } 74 | 75 | void SimpleFluid::RemoveSplat() 76 | { 77 | addSplat = false; 78 | } 79 | 80 | void SimpleFluid::Update() 81 | { 82 | /********** Adding Splat *********/ 83 | while(nbSplat > 0) 84 | { 85 | int x = std::clamp(static_cast(options->simWidth * rd()), 50u, options->simWidth - 50); 86 | int y = std::clamp(static_cast(options->simHeight * rd()), 50u, options->simHeight - 50); 87 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(x, y), std::make_tuple(100.0f * rd() - 50.0f, 100.0f * rd() - 50.0f, 0.0f), 50.0f); 88 | sFact.addSplat(density[READ], std::make_tuple(x, y), std::make_tuple(rd(), rd(), rd()), 2.5f); 89 | 90 | --nbSplat; 91 | } 92 | 93 | if(addSplat) 94 | { 95 | float vScale = 1.0f; 96 | double sX, sY; 97 | glfwGetCursorPos(handler->window, &sX, &sY); 98 | sX = (double) options->simWidth * sX / (double) options->windowWidth; 99 | sY = (double) options->simHeight * (1.0 - sY / (double) options->windowHeight); 100 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(sX, sY), std::make_tuple(vScale * (sX - sOriginX), vScale * (sY - sOriginY), 0.0f), 40.0f); 101 | sFact.addSplat(density[READ], std::make_tuple(sX, sY), std::make_tuple(rd(), rd(), rd()), 1.0f); 102 | 103 | sOriginX = sX; 104 | sOriginY = sY; 105 | } 106 | 107 | float vMax = sFact.maxReduce(velocitiesTexture[READ]); 108 | if(vMax > 1e-10f) options->dt = 5.0f / vMax; 109 | 110 | /********** Convection **********/ 111 | //sFact.RKAdvect(velocitiesTexture[READ], velocitiesTexture[READ], velocitiesTexture[WRITE], options->dt); 112 | sFact.mcAdvect(velocitiesTexture[READ], velocitiesTexture); 113 | std::swap(velocitiesTexture[0], velocitiesTexture[3]); 114 | 115 | /********** Field Advection **********/ 116 | //sFact.RKAdvect(velocitiesTexture[READ], density[READ], density[WRITE], options->dt); 117 | sFact.mcAdvect(velocitiesTexture[READ], density); 118 | std::swap(density[0], density[3]); 119 | 120 | /********** Red-Black Jacobi for the pressure projection *********/ 121 | sFact.RBMethod(velocitiesTexture, divRBTexture, pressureRBTexture); 122 | std::swap(velocitiesTexture[READ], velocitiesTexture[WRITE]); 123 | 124 | /********** Updating the shared texture **********/ 125 | shared_texture = density[READ]; 126 | } 127 | -------------------------------------------------------------------------------- /src/SimpleFluid.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLEFLUID_H 2 | #define SIMPLEFLUID_H 3 | 4 | #include "SimulationBase.h" 5 | #include "SimulationFactory.h" 6 | 7 | class SimpleFluid : public SimulationBase 8 | { 9 | public: 10 | SimpleFluid(ProgramOptions *options, GLFWHandler* handler) 11 | : SimulationBase(options, handler) {} 12 | 13 | ~SimpleFluid(); 14 | 15 | void Init() override; 16 | void Update() override; 17 | 18 | void AddSplat() override; 19 | void AddMultipleSplat(const int nb) override; 20 | void RemoveSplat() override; 21 | private: 22 | int READ = 0, WRITE = 1; 23 | 24 | bool addSplat = false; 25 | double sOriginX, sOriginY; 26 | int nbSplat = 0; 27 | 28 | GLuint velocitiesTexture[4]; 29 | GLuint density[4]; 30 | GLuint divRBTexture; 31 | GLuint pressureRBTexture; 32 | GLuint divergenceCurlTexture; 33 | }; 34 | 35 | #endif //SIMPLEFLUID_H 36 | -------------------------------------------------------------------------------- /src/SimulationBase.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATIONBASE_H 2 | #define SIMULATIONBASE_H 3 | 4 | /** 5 | * @dir src 6 | * @brief The source directory 7 | */ 8 | 9 | /** 10 | * @file SimulationBase.h 11 | * @author Thomas Caissard (\c thomas.caissard@gmail.com) 12 | * @date 2019/08/05 13 | * @brief The pure virtual class representing the base simulation 14 | */ 15 | 16 | #include "GLUtils.h" 17 | #include "ProgramOptions.h" 18 | #include "GLFWHandler.h" 19 | #include "SimulationFactory.h" 20 | 21 | /** 22 | * @class SimulationBase 23 | * @brief The pure virtual class of the simulation 24 | */ 25 | class SimulationBase 26 | { 27 | public: 28 | /** 29 | * Default constructor of the mother class 30 | * @param options the program options 31 | * @param handler the OpenGL handler 32 | */ 33 | SimulationBase(ProgramOptions *options, GLFWHandler *handler) 34 | : options(options), handler(handler), sFact(SimulationFactory(options)) 35 | {} 36 | 37 | /** 38 | * Default destructor 39 | */ 40 | virtual ~SimulationBase() {} 41 | 42 | /** 43 | * Pure virtual initialization of the simulation. 44 | */ 45 | virtual void Init() = 0; 46 | 47 | /** 48 | * Pure virtual Update of the simulation 49 | */ 50 | virtual void Update() = 0; 51 | 52 | /** 53 | * Pure virtual single splat adding for the simulation 54 | */ 55 | virtual void AddSplat() = 0; 56 | 57 | /** 58 | * Pure virtual multiple splat adding for the simulation 59 | */ 60 | virtual void AddMultipleSplat(const int nb) = 0; 61 | 62 | /** 63 | * Pure virtual splat removal for the simulation 64 | */ 65 | virtual void RemoveSplat() = 0; 66 | 67 | /** 68 | * The program options 69 | */ 70 | ProgramOptions *options; 71 | 72 | /** 73 | * The shared texture for the OpenGL rendering 74 | */ 75 | GLuint shared_texture; 76 | 77 | /** 78 | * The OpenGL renderer class 79 | */ 80 | GLFWHandler *handler; 81 | 82 | /** 83 | * Simulation factory class 84 | */ 85 | SimulationFactory sFact; 86 | }; 87 | 88 | #endif //SIMULATIONBASE_H 89 | -------------------------------------------------------------------------------- /src/SimulationFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "SimulationFactory.h" 2 | #include "GLUtils.h" 3 | 4 | #include 5 | #include 6 | 7 | /********** Utility Functions **********/ 8 | void bindImageTexture(const GLuint binding, const GLuint tex) 9 | { 10 | glBindImageTexture(binding, tex, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA16F); 11 | } 12 | 13 | void bindTexture(const GLuint binding, const GLuint tex) 14 | { 15 | glActiveTexture(GL_TEXTURE0 + binding); 16 | glBindTexture(GL_TEXTURE_2D, tex); 17 | } 18 | 19 | void fillTextureWithFunctor(GLuint tex, 20 | const unsigned width, 21 | const unsigned height, 22 | std::function(unsigned, unsigned)> f) 23 | { 24 | float *data = new float[4 * width * height]; 25 | 26 | for(unsigned x = 0; x < width; ++x) 27 | { 28 | for(unsigned y = 0; y < height; ++y) 29 | { 30 | const unsigned pos = 4 * (y * width + x); 31 | 32 | auto [r, g, b, a] = f(x, y); 33 | 34 | data[pos ] = r; 35 | data[pos + 1] = g; 36 | data[pos + 2] = b; 37 | data[pos + 3] = a; 38 | } 39 | } 40 | 41 | glBindTexture(GL_TEXTURE_2D, tex); 42 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_FLOAT, data); 43 | 44 | delete [] data; 45 | } 46 | 47 | SimulationFactory::SimulationFactory(ProgramOptions *options) 48 | : options(options), 49 | globalSizeX(options->simWidth / 32), 50 | globalSizeY(options->simHeight / 32) 51 | { 52 | copyProgram = compileAndLinkShader("shaders/simulation/copy.comp", GL_COMPUTE_SHADER); 53 | maxReduceProgram = compileAndLinkShader("shaders/simulation/maxReduce.comp", GL_COMPUTE_SHADER); 54 | addSmokeSpotProgram = compileAndLinkShader("shaders/simulation/addSmokeSpot.comp", GL_COMPUTE_SHADER); 55 | maccormackProgram = compileAndLinkShader("shaders/simulation/mccormack.comp", GL_COMPUTE_SHADER); 56 | RKProgram = compileAndLinkShader("shaders/simulation/RKAdvect.comp", GL_COMPUTE_SHADER); 57 | divCurlProgram = compileAndLinkShader("shaders/simulation/divCurl.comp", GL_COMPUTE_SHADER); 58 | divRBProgram = compileAndLinkShader("shaders/simulation/divRB.comp", GL_COMPUTE_SHADER); 59 | jacobiProgram = compileAndLinkShader("shaders/simulation/jacobi.comp", GL_COMPUTE_SHADER); 60 | jacobiBlackProgram = compileAndLinkShader("shaders/simulation/jacobiBlack.comp", GL_COMPUTE_SHADER); 61 | jacobiRedProgram = compileAndLinkShader("shaders/simulation/jacobiRed.comp", GL_COMPUTE_SHADER); 62 | pressureProjectionProgram = compileAndLinkShader("shaders/simulation/pressure_projection.comp", GL_COMPUTE_SHADER); 63 | pressureProjectionRBProgram = compileAndLinkShader("shaders/simulation/pressureProjectionRB.comp", GL_COMPUTE_SHADER); 64 | applyVorticityProgram = compileAndLinkShader("shaders/simulation/applyVorticity.comp", GL_COMPUTE_SHADER); 65 | applyBuoyantForceProgram = compileAndLinkShader("shaders/simulation/buoyantForce.comp", GL_COMPUTE_SHADER); 66 | waterContinuityProgram = compileAndLinkShader("shaders/simulation/waterContinuity.comp", GL_COMPUTE_SHADER); 67 | 68 | /********** Textures for reduce **********/ 69 | int nb = static_cast(std::log(static_cast(options->simWidth)) / std::log(2.0)); 70 | 71 | int tSize = options->simWidth / 2; 72 | for(int i = 0; i < nb; ++i) 73 | { 74 | reduceTextures.emplace_back(createTexture2D(tSize, tSize)); 75 | tSize /= 2; 76 | } 77 | 78 | emptyTexture = createTexture2D(options->simWidth / 2, options->simHeight / 2); 79 | } 80 | 81 | SimulationFactory::~SimulationFactory() 82 | { 83 | glDeleteTextures(reduceTextures.size(), reduceTextures.data()); 84 | glDeleteTextures(1, &emptyTexture); 85 | } 86 | 87 | void SimulationFactory::dispatch(const unsigned wSize, const unsigned hSize) 88 | { 89 | glDispatchCompute(wSize, hSize, 1); 90 | glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 91 | } 92 | 93 | void SimulationFactory::copy(const GLuint in, const GLuint out) 94 | { 95 | glUseProgram(copyProgram); 96 | bindImageTexture(0, out); 97 | bindImageTexture(1, in); 98 | dispatch(globalSizeX, globalSizeY); 99 | } 100 | 101 | float SimulationFactory::maxReduce(const GLuint tex) 102 | { 103 | auto rUtil = [&](const GLuint iTex, const GLuint oTex, const unsigned size) 104 | { 105 | glUseProgram(maxReduceProgram); 106 | bindImageTexture(0, oTex); 107 | bindTexture(1, iTex); 108 | unsigned dSize = std::max(size / 32, 1u); 109 | dispatch(dSize, dSize); 110 | }; 111 | 112 | unsigned tSize = options->simWidth / 2; 113 | rUtil(tex, reduceTextures[0], tSize); 114 | for(unsigned i = 0; i < reduceTextures.size() - 1; ++i) 115 | { 116 | tSize /= 2; 117 | rUtil(reduceTextures[i], reduceTextures[i + 1], tSize); 118 | } 119 | 120 | float *data = new float[4]; 121 | glBindTexture(GL_TEXTURE_2D, reduceTextures[reduceTextures.size() - 1]); 122 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, data); 123 | 124 | using std::max; using std::abs; 125 | float m = max(max(max(abs(data[0]), abs(data[1])), abs(data[2])), abs(data[3])); 126 | 127 | delete[] data; 128 | 129 | return m; 130 | } 131 | 132 | void SimulationFactory::RKAdvect(const GLuint velocities, const GLuint field_READ, const GLuint field_WRITE, const float dt) 133 | { 134 | glUseProgram(RKProgram); 135 | GLuint location = glGetUniformLocation(RKProgram, "dt"); 136 | glUniform1f(location, dt); 137 | bindImageTexture(0, field_WRITE); 138 | bindTexture(1, field_READ); 139 | bindTexture(2, velocities); 140 | dispatch(globalSizeX, globalSizeY); 141 | } 142 | 143 | void SimulationFactory::mcAdvect(const GLuint velocities, const GLuint *fields) 144 | { 145 | RKAdvect(velocities, fields[0], fields[1], options->dt); 146 | RKAdvect(velocities, fields[1], fields[2], - options->dt); 147 | maccormackStep(fields[3], fields[0], fields[1], fields[2], velocities); 148 | } 149 | 150 | void SimulationFactory::maccormackStep(const GLuint field_WRITE, const GLuint field_n, const GLuint field_n_1, const GLuint field_n_hat, const GLuint velocities) 151 | { 152 | glUseProgram(maccormackProgram); 153 | GLuint location = glGetUniformLocation(maccormackProgram, "dt"); 154 | glUniform1f(location, options->dt); 155 | location = glGetUniformLocation(maccormackProgram, "revert"); 156 | glUniform1f(location, options->mcRevert); 157 | bindImageTexture(0, field_WRITE); 158 | bindTexture(1, field_n); 159 | bindTexture(2, field_n_hat); 160 | bindTexture(3, field_n_1); 161 | bindTexture(4, velocities); 162 | dispatch(globalSizeX, globalSizeY); 163 | } 164 | 165 | void SimulationFactory::RBMethod(const GLuint *velocities, const GLuint divergence, const GLuint pressure) 166 | { 167 | glUseProgram(divRBProgram); 168 | bindImageTexture(0, divergence); 169 | bindTexture(1, velocities[0]); 170 | dispatch(globalSizeX / 2, globalSizeY / 2); 171 | 172 | copy(emptyTexture, pressure); //TODO 173 | 174 | for(unsigned i = 0; i < options->jacobiIterations; ++i) 175 | { 176 | glUseProgram(jacobiBlackProgram); 177 | bindImageTexture(0, pressure); 178 | bindTexture(1, pressure); 179 | bindTexture(2, divergence); 180 | dispatch(globalSizeX / 2, globalSizeY / 2); 181 | 182 | glUseProgram(jacobiRedProgram); 183 | bindImageTexture(0, pressure); 184 | bindTexture(1, pressure); 185 | bindTexture(2, divergence); 186 | dispatch(globalSizeX / 2, globalSizeY / 2); 187 | } 188 | 189 | glUseProgram(pressureProjectionRBProgram); 190 | bindImageTexture(0, velocities[1]); 191 | bindTexture(1, velocities[0]); 192 | bindTexture(2, pressure); 193 | dispatch(globalSizeX / 2, globalSizeY / 2); 194 | } 195 | 196 | void SimulationFactory::divergenceCurl(const GLuint velocities, const GLuint divergence_curl_WRITE) 197 | { 198 | glUseProgram(divCurlProgram); 199 | bindImageTexture(0, divergence_curl_WRITE); 200 | bindTexture(1, velocities); 201 | dispatch(globalSizeX, globalSizeY); 202 | } 203 | 204 | void SimulationFactory::solvePressure(const GLuint divergence_READ, const GLuint pressure_READ, const GLuint pressure_WRITE) 205 | { 206 | glUseProgram(jacobiProgram); 207 | bindImageTexture(0, pressure_WRITE); 208 | bindTexture(1, pressure_READ); 209 | bindTexture(2, divergence_READ); 210 | dispatch(globalSizeX, globalSizeY); 211 | } 212 | 213 | void SimulationFactory::pressureProjection(const GLuint pressure_READ, const GLuint velocities_READ, const GLuint velocities_WRITE) 214 | { 215 | glUseProgram(pressureProjectionProgram); 216 | bindImageTexture(0, velocities_WRITE); 217 | bindTexture(1, velocities_READ); 218 | bindTexture(2, pressure_READ); 219 | dispatch(globalSizeX, globalSizeY); 220 | } 221 | 222 | void SimulationFactory::applyVorticity(const GLuint velocities_READ_WRITE, const GLuint curl) 223 | { 224 | glUseProgram(applyVorticityProgram); 225 | GLuint location = glGetUniformLocation(applyVorticityProgram, "dt"); 226 | glUniform1f(location, options->dt); 227 | bindImageTexture(0, velocities_READ_WRITE); 228 | bindTexture(1, curl); 229 | dispatch(globalSizeX, globalSizeY); 230 | } 231 | 232 | void SimulationFactory::applyBuoyantForce(const GLuint velocities_READ_WRITE, const GLuint temperature, const GLuint density, const float kappa, const float sigma, const float t0) 233 | { 234 | glUseProgram(applyBuoyantForceProgram); 235 | GLuint location = glGetUniformLocation(applyBuoyantForceProgram, "dt"); 236 | glUniform1f(location, options->dt); 237 | location = glGetUniformLocation(applyBuoyantForceProgram, "kappa"); 238 | glUniform1f(location, kappa); 239 | location = glGetUniformLocation(applyBuoyantForceProgram, "sigma"); 240 | glUniform1f(location, sigma); 241 | location = glGetUniformLocation(applyBuoyantForceProgram, "t0"); 242 | glUniform1f(location, t0); 243 | bindImageTexture(0, velocities_READ_WRITE); 244 | bindTexture(1, temperature); 245 | bindTexture(2, density); 246 | dispatch(globalSizeX, globalSizeY); 247 | } 248 | 249 | void SimulationFactory::addSplat(const GLuint field, const std::tuple pos, const std::tuple color, const float intensity) 250 | { 251 | auto [x, y] = pos; 252 | auto [r, g, b] = color; 253 | 254 | glUseProgram(addSmokeSpotProgram); 255 | GLuint location = glGetUniformLocation(addSmokeSpotProgram, "spotPos"); 256 | glUniform2i(location, x, y); 257 | location = glGetUniformLocation(addSmokeSpotProgram, "color"); 258 | glUniform3f(location, r, g, b); 259 | location = glGetUniformLocation(addSmokeSpotProgram, "intensity"); 260 | glUniform1f(location, intensity); 261 | bindImageTexture(0, field); 262 | dispatch(globalSizeX, globalSizeY); 263 | } 264 | 265 | void SimulationFactory::updateQAndTheta(const GLuint qTex, const GLuint* thetaTex) 266 | { 267 | glUseProgram(waterContinuityProgram); 268 | bindImageTexture(0, qTex); 269 | bindImageTexture(1, thetaTex[2]); 270 | bindTexture(2, thetaTex[0]); 271 | dispatch(globalSizeX, globalSizeY); 272 | } 273 | -------------------------------------------------------------------------------- /src/SimulationFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATIONFACTORY_H 2 | #define SIMULATIONFACTORY_H 3 | 4 | #include "GLUtils.h" 5 | #include "ProgramOptions.h" 6 | 7 | #include 8 | #include 9 | 10 | void fillTextureWithFunctor(GLuint tex, const unsigned width, const unsigned height, 11 | std::function(unsigned, unsigned)> f); 12 | 13 | class SimulationFactory 14 | { 15 | public: 16 | SimulationFactory(ProgramOptions *options); 17 | 18 | ~SimulationFactory(); 19 | 20 | void copy(const GLuint in, const GLuint out); 21 | float maxReduce(const GLuint tex); 22 | void addSplat(const GLuint field, const std::tuple pos, const std::tuple color, const float intensity); 23 | void simpleAdvect(const GLuint velocities, const GLuint field_READ, const GLuint field_WRITE); 24 | void RKAdvect(const GLuint velocities, const GLuint field_READ, const GLuint field_WRITE, const float dt); 25 | void mcAdvect(const GLuint velocities, const GLuint *fieldst); 26 | void maccormackStep(const GLuint field_WRITE, const GLuint field_n, const GLuint field_n_1, const GLuint field_n_hat, const GLuint velocities); 27 | void divergenceCurl(const GLuint velocities, const GLuint divergence_curl_WRITE); 28 | void solvePressure(const GLuint divergence_READ, const GLuint pressure_READ, const GLuint pressure_WRITE); 29 | void pressureProjection(const GLuint pressure_READ, const GLuint velocities_READ, const GLuint velocities_WRITE); 30 | void RBMethod(const GLuint *velocities, const GLuint divergence, const GLuint pressure); 31 | void applyVorticity(const GLuint velocities_READ_WRITE, const GLuint curl); 32 | void applyBuoyantForce(const GLuint velocities_READ_WRITE, const GLuint temperature, const GLuint density, const float kappa, const float sigma, const float t0); 33 | void updateQAndTheta(const GLuint qTex, const GLuint* thetaTex); 34 | private: 35 | void dispatch(const unsigned wSize, const unsigned hSize); 36 | 37 | ProgramOptions *options; 38 | 39 | unsigned globalSizeX, globalSizeY; 40 | 41 | GLint copyProgram; 42 | GLint maxReduceProgram; 43 | GLint addSmokeSpotProgram; 44 | GLint maccormackProgram; 45 | GLint RKProgram; 46 | GLint divCurlProgram; 47 | GLint divRBProgram; 48 | GLint jacobiProgram; 49 | GLint jacobiBlackProgram; 50 | GLint jacobiRedProgram; 51 | GLint pressureProjectionProgram; 52 | GLint pressureProjectionRBProgram; 53 | GLint applyVorticityProgram; 54 | GLint applyBuoyantForceProgram; 55 | GLint waterContinuityProgram; 56 | 57 | std::vector reduceTextures; 58 | GLuint emptyTexture; 59 | }; 60 | 61 | #endif //SIMULATIONFACTORY_H 62 | -------------------------------------------------------------------------------- /src/Smoke.cpp: -------------------------------------------------------------------------------- 1 | #include "Smoke.h" 2 | #include "GLUtils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | Smoke::~Smoke() 10 | { 11 | glDeleteTextures(4, velocitiesTexture); 12 | glDeleteTextures(4, density); 13 | glDeleteTextures(4, temperature); 14 | glDeleteTextures(1, &pressureRBTexture); 15 | glDeleteTextures(1, &divRBTexture); 16 | glDeleteTextures(1, &divergenceCurlTexture); 17 | } 18 | 19 | void Smoke::Init() 20 | { 21 | density[0] = createTexture2D(options->simWidth, options->simHeight); 22 | density[1] = createTexture2D(options->simWidth, options->simHeight); 23 | density[2] = createTexture2D(options->simWidth, options->simHeight); 24 | density[3] = createTexture2D(options->simWidth, options->simHeight); 25 | 26 | temperature[0] = createTexture2D(options->simWidth, options->simHeight); 27 | temperature[1] = createTexture2D(options->simWidth, options->simHeight); 28 | temperature[2] = createTexture2D(options->simWidth, options->simHeight); 29 | temperature[3] = createTexture2D(options->simWidth, options->simHeight); 30 | 31 | velocitiesTexture[0] = createTexture2D(options->simWidth, options->simHeight); 32 | velocitiesTexture[1] = createTexture2D(options->simWidth, options->simHeight); 33 | velocitiesTexture[2] = createTexture2D(options->simWidth, options->simHeight); 34 | velocitiesTexture[3] = createTexture2D(options->simWidth, options->simHeight); 35 | 36 | divergenceCurlTexture = createTexture2D(options->simWidth, options->simHeight); 37 | 38 | divRBTexture = createTexture2D(options->simWidth / 2, options->simHeight / 2); 39 | 40 | pressureRBTexture = createTexture2D(options->simWidth / 2, options->simHeight / 2); 41 | } 42 | 43 | void Smoke::AddSplat() 44 | { 45 | } 46 | 47 | void Smoke::AddMultipleSplat(const int) 48 | { 49 | } 50 | 51 | void Smoke::RemoveSplat() 52 | { 53 | } 54 | 55 | void Smoke::Update() 56 | { 57 | /********** Adding Smoke Origin *********/ 58 | auto rd = []() -> double 59 | { 60 | return (double) rand() / (double) RAND_MAX; 61 | }; 62 | 63 | const int x = options->simWidth / 2; 64 | const int y = 75; 65 | 66 | sFact.addSplat(density[READ], std::make_tuple(x, y), std::make_tuple(0.12f, 0.31f, 0.7f), 0.5f); 67 | sFact.addSplat(temperature[READ], std::make_tuple(x, y), std::make_tuple(rd() * 20.0f + 10.0f, 0.0f, 0.0f), 3.0f); 68 | sFact.addSplat(velocitiesTexture[READ], std::make_tuple(x, y), std::make_tuple(2.0f * rd() - 1.0f, 0.0f, 0.0f), 5.0f); 69 | 70 | float vMax = sFact.maxReduce(velocitiesTexture[READ]); 71 | if(vMax > 1e-5f) options->dt = 5.0f / (vMax + options->dt); 72 | 73 | /********** Convection **********/ 74 | //sFact.RKAdvect(velocitiesTexture[READ], velocitiesTexture[READ], velocitiesTexture[WRITE], options->dt); 75 | sFact.mcAdvect(velocitiesTexture[READ], velocitiesTexture); 76 | std::swap(velocitiesTexture[0], velocitiesTexture[3]); 77 | 78 | /********** Fields Advection **********/ 79 | //sFact.RKAdvect(velocitiesTexture[READ], density[READ], density[WRITE], options->dt); 80 | sFact.mcAdvect(velocitiesTexture[READ], density); 81 | std::swap(density[0], density[3]); 82 | 83 | //sFact.RKAdvect(velocitiesTexture[READ], temperature[READ], temperature[WRITE], options->dt); 84 | sFact.mcAdvect(velocitiesTexture[READ], temperature); 85 | std::swap(temperature[0], temperature[3]); 86 | 87 | /********** Buoyant Force **********/ 88 | sFact.applyBuoyantForce(velocitiesTexture[READ], temperature[READ], density[READ], 0.25f, 0.1f, 10.0f); 89 | 90 | /********** Red-Black Jacobi for the pressure projection *********/ 91 | sFact.RBMethod(velocitiesTexture, divRBTexture, pressureRBTexture); 92 | std::swap(velocitiesTexture[READ], velocitiesTexture[WRITE]); 93 | 94 | /********** Updating the shared texture **********/ 95 | shared_texture = density[READ]; 96 | } 97 | -------------------------------------------------------------------------------- /src/Smoke.h: -------------------------------------------------------------------------------- 1 | #ifndef SMOKE_H 2 | #define SMOKE_H 3 | 4 | #include "SimulationBase.h" 5 | #include "SimulationFactory.h" 6 | 7 | class Smoke : public SimulationBase 8 | { 9 | public: 10 | Smoke(ProgramOptions *options, GLFWHandler *handler) 11 | : SimulationBase(options, handler) {} 12 | 13 | ~Smoke(); 14 | 15 | void Init() override; 16 | void Update() override; 17 | 18 | void AddSplat() override; 19 | void AddMultipleSplat(const int nb) override; 20 | void RemoveSplat() override; 21 | private: 22 | int READ = 0, WRITE = 1; 23 | 24 | GLuint velocitiesTexture[4]; 25 | GLuint density[4]; 26 | GLuint temperature[4]; 27 | GLuint divRBTexture; 28 | GLuint pressureRBTexture; 29 | GLuint divergenceCurlTexture; 30 | }; 31 | 32 | #endif //SMOKE_H 33 | -------------------------------------------------------------------------------- /src/glad.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | OpenGL loader generated by glad 0.1.31 on Mon Jul 15 10:07:48 2019. 4 | 5 | Language/Generator: C/C++ 6 | Specification: gl 7 | APIs: gl=4.3 8 | Profile: core 9 | Extensions: 10 | 11 | Loader: True 12 | Local files: True 13 | Omit khrplatform: False 14 | Reproducible: False 15 | 16 | Commandline: 17 | --profile="core" --api="gl=4.3" --generator="c" --spec="gl" --local-files --extensions="" 18 | Online: 19 | https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D4.3 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include "glad.h" 26 | 27 | static void* get_proc(const char *namez); 28 | 29 | #if defined(_WIN32) || defined(__CYGWIN__) 30 | #include 31 | static HMODULE libGL; 32 | 33 | typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*); 34 | static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; 35 | 36 | #ifdef _MSC_VER 37 | #ifdef __has_include 38 | #if __has_include() 39 | #define HAVE_WINAPIFAMILY 1 40 | #endif 41 | #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ 42 | #define HAVE_WINAPIFAMILY 1 43 | #endif 44 | #endif 45 | 46 | #ifdef HAVE_WINAPIFAMILY 47 | #include 48 | #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 49 | #define IS_UWP 1 50 | #endif 51 | #endif 52 | 53 | static 54 | int open_gl(void) { 55 | #ifndef IS_UWP 56 | libGL = LoadLibraryW(L"opengl32.dll"); 57 | if(libGL != NULL) { 58 | void (* tmp)(void); 59 | tmp = (void(*)(void)) GetProcAddress(libGL, "wglGetProcAddress"); 60 | gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE) tmp; 61 | return gladGetProcAddressPtr != NULL; 62 | } 63 | #endif 64 | 65 | return 0; 66 | } 67 | 68 | static 69 | void close_gl(void) { 70 | if(libGL != NULL) { 71 | FreeLibrary((HMODULE) libGL); 72 | libGL = NULL; 73 | } 74 | } 75 | #else 76 | #include 77 | static void* libGL; 78 | 79 | #if !defined(__APPLE__) && !defined(__HAIKU__) 80 | typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*); 81 | static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; 82 | #endif 83 | 84 | static 85 | int open_gl(void) { 86 | #ifdef __APPLE__ 87 | static const char *NAMES[] = { 88 | "../Frameworks/OpenGL.framework/OpenGL", 89 | "/Library/Frameworks/OpenGL.framework/OpenGL", 90 | "/System/Library/Frameworks/OpenGL.framework/OpenGL", 91 | "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL" 92 | }; 93 | #else 94 | static const char *NAMES[] = {"libGL.so.1", "libGL.so"}; 95 | #endif 96 | 97 | unsigned int index = 0; 98 | for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) { 99 | libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL); 100 | 101 | if(libGL != NULL) { 102 | #if defined(__APPLE__) || defined(__HAIKU__) 103 | return 1; 104 | #else 105 | gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL, 106 | "glXGetProcAddressARB"); 107 | return gladGetProcAddressPtr != NULL; 108 | #endif 109 | } 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | static 116 | void close_gl(void) { 117 | if(libGL != NULL) { 118 | dlclose(libGL); 119 | libGL = NULL; 120 | } 121 | } 122 | #endif 123 | 124 | static 125 | void* get_proc(const char *namez) { 126 | void* result = NULL; 127 | if(libGL == NULL) return NULL; 128 | 129 | #if !defined(__APPLE__) && !defined(__HAIKU__) 130 | if(gladGetProcAddressPtr != NULL) { 131 | result = gladGetProcAddressPtr(namez); 132 | } 133 | #endif 134 | if(result == NULL) { 135 | #if defined(_WIN32) || defined(__CYGWIN__) 136 | result = (void*)GetProcAddress((HMODULE) libGL, namez); 137 | #else 138 | result = dlsym(libGL, namez); 139 | #endif 140 | } 141 | 142 | return result; 143 | } 144 | 145 | int gladLoadGL(void) { 146 | int status = 0; 147 | 148 | if(open_gl()) { 149 | status = gladLoadGLLoader(&get_proc); 150 | close_gl(); 151 | } 152 | 153 | return status; 154 | } 155 | 156 | struct gladGLversionStruct GLVersion = { 0, 0 }; 157 | 158 | #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) 159 | #define _GLAD_IS_SOME_NEW_VERSION 1 160 | #endif 161 | 162 | static int max_loaded_major; 163 | static int max_loaded_minor; 164 | 165 | static const char *exts = NULL; 166 | static int num_exts_i = 0; 167 | static char **exts_i = NULL; 168 | 169 | static int get_exts(void) { 170 | #ifdef _GLAD_IS_SOME_NEW_VERSION 171 | if(max_loaded_major < 3) { 172 | #endif 173 | exts = (const char *)glGetString(GL_EXTENSIONS); 174 | #ifdef _GLAD_IS_SOME_NEW_VERSION 175 | } else { 176 | unsigned int index; 177 | 178 | num_exts_i = 0; 179 | glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i); 180 | if (num_exts_i > 0) { 181 | exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i)); 182 | } 183 | 184 | if (exts_i == NULL) { 185 | return 0; 186 | } 187 | 188 | for(index = 0; index < (unsigned)num_exts_i; index++) { 189 | const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index); 190 | size_t len = strlen(gl_str_tmp); 191 | 192 | char *local_str = (char*)malloc((len+1) * sizeof(char)); 193 | if(local_str != NULL) { 194 | memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char)); 195 | } 196 | exts_i[index] = local_str; 197 | } 198 | } 199 | #endif 200 | return 1; 201 | } 202 | 203 | static void free_exts(void) { 204 | if (exts_i != NULL) { 205 | int index; 206 | for(index = 0; index < num_exts_i; index++) { 207 | free((char *)exts_i[index]); 208 | } 209 | free((void *)exts_i); 210 | exts_i = NULL; 211 | } 212 | } 213 | 214 | static int has_ext(const char *ext) { 215 | #ifdef _GLAD_IS_SOME_NEW_VERSION 216 | if(max_loaded_major < 3) { 217 | #endif 218 | const char *extensions; 219 | const char *loc; 220 | const char *terminator; 221 | extensions = exts; 222 | if(extensions == NULL || ext == NULL) { 223 | return 0; 224 | } 225 | 226 | while(1) { 227 | loc = strstr(extensions, ext); 228 | if(loc == NULL) { 229 | return 0; 230 | } 231 | 232 | terminator = loc + strlen(ext); 233 | if((loc == extensions || *(loc - 1) == ' ') && 234 | (*terminator == ' ' || *terminator == '\0')) { 235 | return 1; 236 | } 237 | extensions = terminator; 238 | } 239 | #ifdef _GLAD_IS_SOME_NEW_VERSION 240 | } else { 241 | int index; 242 | if(exts_i == NULL) return 0; 243 | for(index = 0; index < num_exts_i; index++) { 244 | const char *e = exts_i[index]; 245 | 246 | if(exts_i[index] != NULL && strcmp(e, ext) == 0) { 247 | return 1; 248 | } 249 | } 250 | } 251 | #endif 252 | 253 | return 0; 254 | } 255 | int GLAD_GL_VERSION_1_0 = 0; 256 | int GLAD_GL_VERSION_1_1 = 0; 257 | int GLAD_GL_VERSION_1_2 = 0; 258 | int GLAD_GL_VERSION_1_3 = 0; 259 | int GLAD_GL_VERSION_1_4 = 0; 260 | int GLAD_GL_VERSION_1_5 = 0; 261 | int GLAD_GL_VERSION_2_0 = 0; 262 | int GLAD_GL_VERSION_2_1 = 0; 263 | int GLAD_GL_VERSION_3_0 = 0; 264 | int GLAD_GL_VERSION_3_1 = 0; 265 | int GLAD_GL_VERSION_3_2 = 0; 266 | int GLAD_GL_VERSION_3_3 = 0; 267 | int GLAD_GL_VERSION_4_0 = 0; 268 | int GLAD_GL_VERSION_4_1 = 0; 269 | int GLAD_GL_VERSION_4_2 = 0; 270 | int GLAD_GL_VERSION_4_3 = 0; 271 | PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram = NULL; 272 | PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; 273 | PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; 274 | PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL; 275 | PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL; 276 | PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed = NULL; 277 | PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL; 278 | PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; 279 | PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; 280 | PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL; 281 | PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL; 282 | PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL; 283 | PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL; 284 | PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; 285 | PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture = NULL; 286 | PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline = NULL; 287 | PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; 288 | PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL; 289 | PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; 290 | PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback = NULL; 291 | PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL; 292 | PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer = NULL; 293 | PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; 294 | PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; 295 | PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; 296 | PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei = NULL; 297 | PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi = NULL; 298 | PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; 299 | PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; 300 | PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei = NULL; 301 | PFNGLBLENDFUNCIPROC glad_glBlendFunci = NULL; 302 | PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL; 303 | PFNGLBUFFERDATAPROC glad_glBufferData = NULL; 304 | PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; 305 | PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; 306 | PFNGLCLAMPCOLORPROC glad_glClampColor = NULL; 307 | PFNGLCLEARPROC glad_glClear = NULL; 308 | PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData = NULL; 309 | PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData = NULL; 310 | PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL; 311 | PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL; 312 | PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL; 313 | PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL; 314 | PFNGLCLEARCOLORPROC glad_glClearColor = NULL; 315 | PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL; 316 | PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL; 317 | PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; 318 | PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL; 319 | PFNGLCOLORMASKPROC glad_glColorMask = NULL; 320 | PFNGLCOLORMASKIPROC glad_glColorMaski = NULL; 321 | PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL; 322 | PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL; 323 | PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL; 324 | PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL; 325 | PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; 326 | PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL; 327 | PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; 328 | PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL; 329 | PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL; 330 | PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; 331 | PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL; 332 | PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL; 333 | PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData = NULL; 334 | PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL; 335 | PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; 336 | PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL; 337 | PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; 338 | PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL; 339 | PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; 340 | PFNGLCREATESHADERPROC glad_glCreateShader = NULL; 341 | PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv = NULL; 342 | PFNGLCULLFACEPROC glad_glCullFace = NULL; 343 | PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL; 344 | PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL; 345 | PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL; 346 | PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; 347 | PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; 348 | PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; 349 | PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines = NULL; 350 | PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL; 351 | PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; 352 | PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL; 353 | PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; 354 | PFNGLDELETESYNCPROC glad_glDeleteSync = NULL; 355 | PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; 356 | PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks = NULL; 357 | PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL; 358 | PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; 359 | PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; 360 | PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL; 361 | PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv = NULL; 362 | PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed = NULL; 363 | PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL; 364 | PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; 365 | PFNGLDISABLEPROC glad_glDisable = NULL; 366 | PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; 367 | PFNGLDISABLEIPROC glad_glDisablei = NULL; 368 | PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute = NULL; 369 | PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect = NULL; 370 | PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; 371 | PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect = NULL; 372 | PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL; 373 | PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance = NULL; 374 | PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL; 375 | PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL; 376 | PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; 377 | PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL; 378 | PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect = NULL; 379 | PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL; 380 | PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance = NULL; 381 | PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL; 382 | PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance = NULL; 383 | PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL; 384 | PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL; 385 | PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback = NULL; 386 | PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced = NULL; 387 | PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream = NULL; 388 | PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced = NULL; 389 | PFNGLENABLEPROC glad_glEnable = NULL; 390 | PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; 391 | PFNGLENABLEIPROC glad_glEnablei = NULL; 392 | PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL; 393 | PFNGLENDQUERYPROC glad_glEndQuery = NULL; 394 | PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed = NULL; 395 | PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL; 396 | PFNGLFENCESYNCPROC glad_glFenceSync = NULL; 397 | PFNGLFINISHPROC glad_glFinish = NULL; 398 | PFNGLFLUSHPROC glad_glFlush = NULL; 399 | PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL; 400 | PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri = NULL; 401 | PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; 402 | PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL; 403 | PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL; 404 | PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; 405 | PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL; 406 | PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL; 407 | PFNGLFRONTFACEPROC glad_glFrontFace = NULL; 408 | PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; 409 | PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; 410 | PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines = NULL; 411 | PFNGLGENQUERIESPROC glad_glGenQueries = NULL; 412 | PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; 413 | PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL; 414 | PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; 415 | PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks = NULL; 416 | PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL; 417 | PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; 418 | PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv = NULL; 419 | PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; 420 | PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName = NULL; 421 | PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName = NULL; 422 | PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv = NULL; 423 | PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; 424 | PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL; 425 | PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL; 426 | PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL; 427 | PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL; 428 | PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; 429 | PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; 430 | PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL; 431 | PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; 432 | PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL; 433 | PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; 434 | PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL; 435 | PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL; 436 | PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL; 437 | PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL; 438 | PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v = NULL; 439 | PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL; 440 | PFNGLGETERRORPROC glad_glGetError = NULL; 441 | PFNGLGETFLOATI_VPROC glad_glGetFloati_v = NULL; 442 | PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; 443 | PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL; 444 | PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL; 445 | PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; 446 | PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv = NULL; 447 | PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL; 448 | PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL; 449 | PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL; 450 | PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; 451 | PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v = NULL; 452 | PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ = NULL; 453 | PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL; 454 | PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL; 455 | PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL; 456 | PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL; 457 | PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary = NULL; 458 | PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; 459 | PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv = NULL; 460 | PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog = NULL; 461 | PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv = NULL; 462 | PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex = NULL; 463 | PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation = NULL; 464 | PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex = NULL; 465 | PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName = NULL; 466 | PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv = NULL; 467 | PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv = NULL; 468 | PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; 469 | PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv = NULL; 470 | PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL; 471 | PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL; 472 | PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL; 473 | PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL; 474 | PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL; 475 | PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; 476 | PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL; 477 | PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL; 478 | PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL; 479 | PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL; 480 | PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; 481 | PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL; 482 | PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; 483 | PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; 484 | PFNGLGETSTRINGPROC glad_glGetString = NULL; 485 | PFNGLGETSTRINGIPROC glad_glGetStringi = NULL; 486 | PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex = NULL; 487 | PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation = NULL; 488 | PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL; 489 | PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL; 490 | PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL; 491 | PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL; 492 | PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL; 493 | PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL; 494 | PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; 495 | PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; 496 | PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL; 497 | PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL; 498 | PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL; 499 | PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; 500 | PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv = NULL; 501 | PFNGLGETUNIFORMDVPROC glad_glGetUniformdv = NULL; 502 | PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; 503 | PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; 504 | PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL; 505 | PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL; 506 | PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL; 507 | PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv = NULL; 508 | PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; 509 | PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL; 510 | PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; 511 | PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; 512 | PFNGLHINTPROC glad_glHint = NULL; 513 | PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData = NULL; 514 | PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData = NULL; 515 | PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer = NULL; 516 | PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer = NULL; 517 | PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage = NULL; 518 | PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage = NULL; 519 | PFNGLISBUFFERPROC glad_glIsBuffer = NULL; 520 | PFNGLISENABLEDPROC glad_glIsEnabled = NULL; 521 | PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL; 522 | PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; 523 | PFNGLISPROGRAMPROC glad_glIsProgram = NULL; 524 | PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline = NULL; 525 | PFNGLISQUERYPROC glad_glIsQuery = NULL; 526 | PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; 527 | PFNGLISSAMPLERPROC glad_glIsSampler = NULL; 528 | PFNGLISSHADERPROC glad_glIsShader = NULL; 529 | PFNGLISSYNCPROC glad_glIsSync = NULL; 530 | PFNGLISTEXTUREPROC glad_glIsTexture = NULL; 531 | PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback = NULL; 532 | PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL; 533 | PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; 534 | PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; 535 | PFNGLLOGICOPPROC glad_glLogicOp = NULL; 536 | PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL; 537 | PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL; 538 | PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier = NULL; 539 | PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading = NULL; 540 | PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL; 541 | PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect = NULL; 542 | PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL; 543 | PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL; 544 | PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect = NULL; 545 | PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL; 546 | PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL; 547 | PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL; 548 | PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL; 549 | PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL; 550 | PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL; 551 | PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL; 552 | PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL; 553 | PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL; 554 | PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL; 555 | PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL; 556 | PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL; 557 | PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv = NULL; 558 | PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri = NULL; 559 | PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback = NULL; 560 | PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL; 561 | PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; 562 | PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL; 563 | PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL; 564 | PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL; 565 | PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL; 566 | PFNGLPOINTSIZEPROC glad_glPointSize = NULL; 567 | PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL; 568 | PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; 569 | PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL; 570 | PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL; 571 | PFNGLPROGRAMBINARYPROC glad_glProgramBinary = NULL; 572 | PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri = NULL; 573 | PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d = NULL; 574 | PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv = NULL; 575 | PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f = NULL; 576 | PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv = NULL; 577 | PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i = NULL; 578 | PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv = NULL; 579 | PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui = NULL; 580 | PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv = NULL; 581 | PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d = NULL; 582 | PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv = NULL; 583 | PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f = NULL; 584 | PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv = NULL; 585 | PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i = NULL; 586 | PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv = NULL; 587 | PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui = NULL; 588 | PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv = NULL; 589 | PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d = NULL; 590 | PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv = NULL; 591 | PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f = NULL; 592 | PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv = NULL; 593 | PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i = NULL; 594 | PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv = NULL; 595 | PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui = NULL; 596 | PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv = NULL; 597 | PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d = NULL; 598 | PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv = NULL; 599 | PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f = NULL; 600 | PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv = NULL; 601 | PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i = NULL; 602 | PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv = NULL; 603 | PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui = NULL; 604 | PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv = NULL; 605 | PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv = NULL; 606 | PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv = NULL; 607 | PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv = NULL; 608 | PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv = NULL; 609 | PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv = NULL; 610 | PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv = NULL; 611 | PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv = NULL; 612 | PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv = NULL; 613 | PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv = NULL; 614 | PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv = NULL; 615 | PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv = NULL; 616 | PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv = NULL; 617 | PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv = NULL; 618 | PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv = NULL; 619 | PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv = NULL; 620 | PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv = NULL; 621 | PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv = NULL; 622 | PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv = NULL; 623 | PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL; 624 | PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL; 625 | PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL; 626 | PFNGLREADBUFFERPROC glad_glReadBuffer = NULL; 627 | PFNGLREADPIXELSPROC glad_glReadPixels = NULL; 628 | PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL; 629 | PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; 630 | PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL; 631 | PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback = NULL; 632 | PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; 633 | PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL; 634 | PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL; 635 | PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL; 636 | PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL; 637 | PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL; 638 | PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL; 639 | PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL; 640 | PFNGLSCISSORPROC glad_glScissor = NULL; 641 | PFNGLSCISSORARRAYVPROC glad_glScissorArrayv = NULL; 642 | PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed = NULL; 643 | PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv = NULL; 644 | PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL; 645 | PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL; 646 | PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL; 647 | PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; 648 | PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding = NULL; 649 | PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; 650 | PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; 651 | PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; 652 | PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; 653 | PFNGLSTENCILOPPROC glad_glStencilOp = NULL; 654 | PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; 655 | PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL; 656 | PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange = NULL; 657 | PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL; 658 | PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL; 659 | PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL; 660 | PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL; 661 | PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL; 662 | PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL; 663 | PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL; 664 | PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL; 665 | PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL; 666 | PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; 667 | PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL; 668 | PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL; 669 | PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL; 670 | PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL; 671 | PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL; 672 | PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; 673 | PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; 674 | PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; 675 | PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; 676 | PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D = NULL; 677 | PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D = NULL; 678 | PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample = NULL; 679 | PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D = NULL; 680 | PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample = NULL; 681 | PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL; 682 | PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; 683 | PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL; 684 | PFNGLTEXTUREVIEWPROC glad_glTextureView = NULL; 685 | PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL; 686 | PFNGLUNIFORM1DPROC glad_glUniform1d = NULL; 687 | PFNGLUNIFORM1DVPROC glad_glUniform1dv = NULL; 688 | PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; 689 | PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; 690 | PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; 691 | PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; 692 | PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL; 693 | PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL; 694 | PFNGLUNIFORM2DPROC glad_glUniform2d = NULL; 695 | PFNGLUNIFORM2DVPROC glad_glUniform2dv = NULL; 696 | PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; 697 | PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; 698 | PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; 699 | PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; 700 | PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL; 701 | PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL; 702 | PFNGLUNIFORM3DPROC glad_glUniform3d = NULL; 703 | PFNGLUNIFORM3DVPROC glad_glUniform3dv = NULL; 704 | PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; 705 | PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; 706 | PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; 707 | PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; 708 | PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL; 709 | PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL; 710 | PFNGLUNIFORM4DPROC glad_glUniform4d = NULL; 711 | PFNGLUNIFORM4DVPROC glad_glUniform4dv = NULL; 712 | PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; 713 | PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; 714 | PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; 715 | PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; 716 | PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL; 717 | PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL; 718 | PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL; 719 | PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv = NULL; 720 | PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; 721 | PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv = NULL; 722 | PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL; 723 | PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv = NULL; 724 | PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL; 725 | PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv = NULL; 726 | PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; 727 | PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv = NULL; 728 | PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL; 729 | PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv = NULL; 730 | PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL; 731 | PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv = NULL; 732 | PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; 733 | PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv = NULL; 734 | PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL; 735 | PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv = NULL; 736 | PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL; 737 | PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv = NULL; 738 | PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL; 739 | PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; 740 | PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages = NULL; 741 | PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; 742 | PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline = NULL; 743 | PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL; 744 | PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL; 745 | PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; 746 | PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; 747 | PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL; 748 | PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL; 749 | PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL; 750 | PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL; 751 | PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; 752 | PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; 753 | PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL; 754 | PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL; 755 | PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL; 756 | PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL; 757 | PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; 758 | PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; 759 | PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL; 760 | PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL; 761 | PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL; 762 | PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL; 763 | PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL; 764 | PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL; 765 | PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL; 766 | PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL; 767 | PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL; 768 | PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL; 769 | PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL; 770 | PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL; 771 | PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; 772 | PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; 773 | PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL; 774 | PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL; 775 | PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL; 776 | PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL; 777 | PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL; 778 | PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL; 779 | PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding = NULL; 780 | PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL; 781 | PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat = NULL; 782 | PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL; 783 | PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL; 784 | PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL; 785 | PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL; 786 | PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL; 787 | PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL; 788 | PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL; 789 | PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL; 790 | PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL; 791 | PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL; 792 | PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL; 793 | PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL; 794 | PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL; 795 | PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL; 796 | PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL; 797 | PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL; 798 | PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL; 799 | PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL; 800 | PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL; 801 | PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL; 802 | PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat = NULL; 803 | PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL; 804 | PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d = NULL; 805 | PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv = NULL; 806 | PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d = NULL; 807 | PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv = NULL; 808 | PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d = NULL; 809 | PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv = NULL; 810 | PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d = NULL; 811 | PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv = NULL; 812 | PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat = NULL; 813 | PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer = NULL; 814 | PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL; 815 | PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL; 816 | PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL; 817 | PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL; 818 | PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL; 819 | PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL; 820 | PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL; 821 | PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL; 822 | PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; 823 | PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor = NULL; 824 | PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL; 825 | PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL; 826 | PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL; 827 | PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL; 828 | PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL; 829 | PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL; 830 | PFNGLVIEWPORTPROC glad_glViewport = NULL; 831 | PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv = NULL; 832 | PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf = NULL; 833 | PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv = NULL; 834 | PFNGLWAITSYNCPROC glad_glWaitSync = NULL; 835 | static void load_GL_VERSION_1_0(GLADloadproc load) { 836 | if(!GLAD_GL_VERSION_1_0) return; 837 | glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace"); 838 | glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace"); 839 | glad_glHint = (PFNGLHINTPROC)load("glHint"); 840 | glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth"); 841 | glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize"); 842 | glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode"); 843 | glad_glScissor = (PFNGLSCISSORPROC)load("glScissor"); 844 | glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf"); 845 | glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv"); 846 | glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri"); 847 | glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv"); 848 | glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D"); 849 | glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D"); 850 | glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer"); 851 | glad_glClear = (PFNGLCLEARPROC)load("glClear"); 852 | glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor"); 853 | glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil"); 854 | glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth"); 855 | glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask"); 856 | glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask"); 857 | glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask"); 858 | glad_glDisable = (PFNGLDISABLEPROC)load("glDisable"); 859 | glad_glEnable = (PFNGLENABLEPROC)load("glEnable"); 860 | glad_glFinish = (PFNGLFINISHPROC)load("glFinish"); 861 | glad_glFlush = (PFNGLFLUSHPROC)load("glFlush"); 862 | glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc"); 863 | glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp"); 864 | glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc"); 865 | glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp"); 866 | glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc"); 867 | glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref"); 868 | glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei"); 869 | glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer"); 870 | glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels"); 871 | glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv"); 872 | glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev"); 873 | glad_glGetError = (PFNGLGETERRORPROC)load("glGetError"); 874 | glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv"); 875 | glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv"); 876 | glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); 877 | glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage"); 878 | glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv"); 879 | glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv"); 880 | glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv"); 881 | glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv"); 882 | glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled"); 883 | glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange"); 884 | glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport"); 885 | } 886 | static void load_GL_VERSION_1_1(GLADloadproc load) { 887 | if(!GLAD_GL_VERSION_1_1) return; 888 | glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays"); 889 | glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements"); 890 | glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset"); 891 | glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D"); 892 | glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D"); 893 | glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D"); 894 | glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D"); 895 | glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D"); 896 | glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D"); 897 | glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture"); 898 | glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures"); 899 | glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures"); 900 | glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture"); 901 | } 902 | static void load_GL_VERSION_1_2(GLADloadproc load) { 903 | if(!GLAD_GL_VERSION_1_2) return; 904 | glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements"); 905 | glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D"); 906 | glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D"); 907 | glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D"); 908 | } 909 | static void load_GL_VERSION_1_3(GLADloadproc load) { 910 | if(!GLAD_GL_VERSION_1_3) return; 911 | glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture"); 912 | glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage"); 913 | glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D"); 914 | glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D"); 915 | glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D"); 916 | glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D"); 917 | glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D"); 918 | glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D"); 919 | glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage"); 920 | } 921 | static void load_GL_VERSION_1_4(GLADloadproc load) { 922 | if(!GLAD_GL_VERSION_1_4) return; 923 | glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate"); 924 | glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays"); 925 | glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements"); 926 | glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf"); 927 | glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv"); 928 | glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri"); 929 | glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv"); 930 | glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor"); 931 | glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation"); 932 | } 933 | static void load_GL_VERSION_1_5(GLADloadproc load) { 934 | if(!GLAD_GL_VERSION_1_5) return; 935 | glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries"); 936 | glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries"); 937 | glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery"); 938 | glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery"); 939 | glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery"); 940 | glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv"); 941 | glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv"); 942 | glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv"); 943 | glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer"); 944 | glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers"); 945 | glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers"); 946 | glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer"); 947 | glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData"); 948 | glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData"); 949 | glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData"); 950 | glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer"); 951 | glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer"); 952 | glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv"); 953 | glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv"); 954 | } 955 | static void load_GL_VERSION_2_0(GLADloadproc load) { 956 | if(!GLAD_GL_VERSION_2_0) return; 957 | glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate"); 958 | glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers"); 959 | glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate"); 960 | glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate"); 961 | glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate"); 962 | glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader"); 963 | glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation"); 964 | glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader"); 965 | glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram"); 966 | glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader"); 967 | glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram"); 968 | glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader"); 969 | glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader"); 970 | glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray"); 971 | glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray"); 972 | glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib"); 973 | glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform"); 974 | glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders"); 975 | glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation"); 976 | glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv"); 977 | glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog"); 978 | glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv"); 979 | glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog"); 980 | glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource"); 981 | glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation"); 982 | glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv"); 983 | glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv"); 984 | glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv"); 985 | glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv"); 986 | glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv"); 987 | glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv"); 988 | glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram"); 989 | glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader"); 990 | glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram"); 991 | glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource"); 992 | glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram"); 993 | glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f"); 994 | glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f"); 995 | glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f"); 996 | glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f"); 997 | glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i"); 998 | glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i"); 999 | glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i"); 1000 | glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i"); 1001 | glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv"); 1002 | glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv"); 1003 | glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv"); 1004 | glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv"); 1005 | glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv"); 1006 | glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv"); 1007 | glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv"); 1008 | glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv"); 1009 | glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv"); 1010 | glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv"); 1011 | glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv"); 1012 | glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram"); 1013 | glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d"); 1014 | glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv"); 1015 | glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f"); 1016 | glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv"); 1017 | glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s"); 1018 | glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv"); 1019 | glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d"); 1020 | glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv"); 1021 | glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f"); 1022 | glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv"); 1023 | glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s"); 1024 | glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv"); 1025 | glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d"); 1026 | glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv"); 1027 | glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f"); 1028 | glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv"); 1029 | glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s"); 1030 | glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv"); 1031 | glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv"); 1032 | glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv"); 1033 | glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv"); 1034 | glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub"); 1035 | glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv"); 1036 | glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv"); 1037 | glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv"); 1038 | glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv"); 1039 | glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d"); 1040 | glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv"); 1041 | glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f"); 1042 | glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv"); 1043 | glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv"); 1044 | glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s"); 1045 | glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv"); 1046 | glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv"); 1047 | glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv"); 1048 | glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv"); 1049 | glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer"); 1050 | } 1051 | static void load_GL_VERSION_2_1(GLADloadproc load) { 1052 | if(!GLAD_GL_VERSION_2_1) return; 1053 | glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv"); 1054 | glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv"); 1055 | glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv"); 1056 | glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv"); 1057 | glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv"); 1058 | glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv"); 1059 | } 1060 | static void load_GL_VERSION_3_0(GLADloadproc load) { 1061 | if(!GLAD_GL_VERSION_3_0) return; 1062 | glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski"); 1063 | glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v"); 1064 | glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); 1065 | glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei"); 1066 | glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei"); 1067 | glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi"); 1068 | glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback"); 1069 | glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback"); 1070 | glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); 1071 | glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); 1072 | glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings"); 1073 | glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying"); 1074 | glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor"); 1075 | glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender"); 1076 | glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender"); 1077 | glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer"); 1078 | glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv"); 1079 | glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv"); 1080 | glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i"); 1081 | glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i"); 1082 | glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i"); 1083 | glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i"); 1084 | glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui"); 1085 | glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui"); 1086 | glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui"); 1087 | glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui"); 1088 | glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv"); 1089 | glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv"); 1090 | glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv"); 1091 | glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv"); 1092 | glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv"); 1093 | glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv"); 1094 | glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv"); 1095 | glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv"); 1096 | glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv"); 1097 | glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv"); 1098 | glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv"); 1099 | glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv"); 1100 | glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv"); 1101 | glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation"); 1102 | glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation"); 1103 | glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui"); 1104 | glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui"); 1105 | glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui"); 1106 | glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui"); 1107 | glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv"); 1108 | glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv"); 1109 | glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv"); 1110 | glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv"); 1111 | glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv"); 1112 | glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv"); 1113 | glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv"); 1114 | glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv"); 1115 | glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv"); 1116 | glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv"); 1117 | glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv"); 1118 | glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi"); 1119 | glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi"); 1120 | glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer"); 1121 | glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer"); 1122 | glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers"); 1123 | glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers"); 1124 | glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage"); 1125 | glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv"); 1126 | glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer"); 1127 | glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer"); 1128 | glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers"); 1129 | glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers"); 1130 | glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus"); 1131 | glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D"); 1132 | glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D"); 1133 | glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D"); 1134 | glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer"); 1135 | glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv"); 1136 | glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap"); 1137 | glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer"); 1138 | glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample"); 1139 | glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer"); 1140 | glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange"); 1141 | glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange"); 1142 | glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray"); 1143 | glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays"); 1144 | glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays"); 1145 | glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray"); 1146 | } 1147 | static void load_GL_VERSION_3_1(GLADloadproc load) { 1148 | if(!GLAD_GL_VERSION_3_1) return; 1149 | glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced"); 1150 | glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced"); 1151 | glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer"); 1152 | glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex"); 1153 | glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData"); 1154 | glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices"); 1155 | glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv"); 1156 | glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName"); 1157 | glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex"); 1158 | glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv"); 1159 | glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName"); 1160 | glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding"); 1161 | glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); 1162 | glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); 1163 | glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); 1164 | } 1165 | static void load_GL_VERSION_3_2(GLADloadproc load) { 1166 | if(!GLAD_GL_VERSION_3_2) return; 1167 | glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex"); 1168 | glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex"); 1169 | glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex"); 1170 | glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex"); 1171 | glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex"); 1172 | glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync"); 1173 | glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync"); 1174 | glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync"); 1175 | glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync"); 1176 | glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync"); 1177 | glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v"); 1178 | glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv"); 1179 | glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v"); 1180 | glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v"); 1181 | glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture"); 1182 | glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample"); 1183 | glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample"); 1184 | glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv"); 1185 | glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski"); 1186 | } 1187 | static void load_GL_VERSION_3_3(GLADloadproc load) { 1188 | if(!GLAD_GL_VERSION_3_3) return; 1189 | glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed"); 1190 | glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex"); 1191 | glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers"); 1192 | glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers"); 1193 | glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler"); 1194 | glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler"); 1195 | glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri"); 1196 | glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv"); 1197 | glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf"); 1198 | glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv"); 1199 | glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv"); 1200 | glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv"); 1201 | glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv"); 1202 | glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv"); 1203 | glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv"); 1204 | glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv"); 1205 | glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter"); 1206 | glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v"); 1207 | glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v"); 1208 | glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor"); 1209 | glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui"); 1210 | glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv"); 1211 | glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui"); 1212 | glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv"); 1213 | glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui"); 1214 | glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv"); 1215 | glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui"); 1216 | glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv"); 1217 | glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui"); 1218 | glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv"); 1219 | glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui"); 1220 | glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv"); 1221 | glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui"); 1222 | glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv"); 1223 | glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui"); 1224 | glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv"); 1225 | glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui"); 1226 | glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv"); 1227 | glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui"); 1228 | glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv"); 1229 | glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui"); 1230 | glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv"); 1231 | glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui"); 1232 | glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv"); 1233 | glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui"); 1234 | glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv"); 1235 | glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui"); 1236 | glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv"); 1237 | glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui"); 1238 | glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv"); 1239 | glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui"); 1240 | glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv"); 1241 | glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui"); 1242 | glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv"); 1243 | glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui"); 1244 | glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv"); 1245 | glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui"); 1246 | glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv"); 1247 | } 1248 | static void load_GL_VERSION_4_0(GLADloadproc load) { 1249 | if(!GLAD_GL_VERSION_4_0) return; 1250 | glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)load("glMinSampleShading"); 1251 | glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)load("glBlendEquationi"); 1252 | glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)load("glBlendEquationSeparatei"); 1253 | glad_glBlendFunci = (PFNGLBLENDFUNCIPROC)load("glBlendFunci"); 1254 | glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)load("glBlendFuncSeparatei"); 1255 | glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)load("glDrawArraysIndirect"); 1256 | glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)load("glDrawElementsIndirect"); 1257 | glad_glUniform1d = (PFNGLUNIFORM1DPROC)load("glUniform1d"); 1258 | glad_glUniform2d = (PFNGLUNIFORM2DPROC)load("glUniform2d"); 1259 | glad_glUniform3d = (PFNGLUNIFORM3DPROC)load("glUniform3d"); 1260 | glad_glUniform4d = (PFNGLUNIFORM4DPROC)load("glUniform4d"); 1261 | glad_glUniform1dv = (PFNGLUNIFORM1DVPROC)load("glUniform1dv"); 1262 | glad_glUniform2dv = (PFNGLUNIFORM2DVPROC)load("glUniform2dv"); 1263 | glad_glUniform3dv = (PFNGLUNIFORM3DVPROC)load("glUniform3dv"); 1264 | glad_glUniform4dv = (PFNGLUNIFORM4DVPROC)load("glUniform4dv"); 1265 | glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)load("glUniformMatrix2dv"); 1266 | glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)load("glUniformMatrix3dv"); 1267 | glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)load("glUniformMatrix4dv"); 1268 | glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)load("glUniformMatrix2x3dv"); 1269 | glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)load("glUniformMatrix2x4dv"); 1270 | glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)load("glUniformMatrix3x2dv"); 1271 | glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)load("glUniformMatrix3x4dv"); 1272 | glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)load("glUniformMatrix4x2dv"); 1273 | glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)load("glUniformMatrix4x3dv"); 1274 | glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC)load("glGetUniformdv"); 1275 | glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)load("glGetSubroutineUniformLocation"); 1276 | glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)load("glGetSubroutineIndex"); 1277 | glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)load("glGetActiveSubroutineUniformiv"); 1278 | glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)load("glGetActiveSubroutineUniformName"); 1279 | glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)load("glGetActiveSubroutineName"); 1280 | glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)load("glUniformSubroutinesuiv"); 1281 | glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)load("glGetUniformSubroutineuiv"); 1282 | glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)load("glGetProgramStageiv"); 1283 | glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)load("glPatchParameteri"); 1284 | glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)load("glPatchParameterfv"); 1285 | glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)load("glBindTransformFeedback"); 1286 | glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)load("glDeleteTransformFeedbacks"); 1287 | glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)load("glGenTransformFeedbacks"); 1288 | glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)load("glIsTransformFeedback"); 1289 | glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)load("glPauseTransformFeedback"); 1290 | glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)load("glResumeTransformFeedback"); 1291 | glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)load("glDrawTransformFeedback"); 1292 | glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)load("glDrawTransformFeedbackStream"); 1293 | glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)load("glBeginQueryIndexed"); 1294 | glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)load("glEndQueryIndexed"); 1295 | glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)load("glGetQueryIndexediv"); 1296 | } 1297 | static void load_GL_VERSION_4_1(GLADloadproc load) { 1298 | if(!GLAD_GL_VERSION_4_1) return; 1299 | glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load("glReleaseShaderCompiler"); 1300 | glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load("glShaderBinary"); 1301 | glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load("glGetShaderPrecisionFormat"); 1302 | glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load("glDepthRangef"); 1303 | glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf"); 1304 | glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)load("glGetProgramBinary"); 1305 | glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC)load("glProgramBinary"); 1306 | glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri"); 1307 | glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)load("glUseProgramStages"); 1308 | glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)load("glActiveShaderProgram"); 1309 | glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)load("glCreateShaderProgramv"); 1310 | glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)load("glBindProgramPipeline"); 1311 | glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)load("glDeleteProgramPipelines"); 1312 | glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)load("glGenProgramPipelines"); 1313 | glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)load("glIsProgramPipeline"); 1314 | glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)load("glGetProgramPipelineiv"); 1315 | glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri"); 1316 | glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)load("glProgramUniform1i"); 1317 | glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)load("glProgramUniform1iv"); 1318 | glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)load("glProgramUniform1f"); 1319 | glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)load("glProgramUniform1fv"); 1320 | glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)load("glProgramUniform1d"); 1321 | glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)load("glProgramUniform1dv"); 1322 | glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)load("glProgramUniform1ui"); 1323 | glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)load("glProgramUniform1uiv"); 1324 | glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)load("glProgramUniform2i"); 1325 | glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)load("glProgramUniform2iv"); 1326 | glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)load("glProgramUniform2f"); 1327 | glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)load("glProgramUniform2fv"); 1328 | glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)load("glProgramUniform2d"); 1329 | glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)load("glProgramUniform2dv"); 1330 | glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)load("glProgramUniform2ui"); 1331 | glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)load("glProgramUniform2uiv"); 1332 | glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)load("glProgramUniform3i"); 1333 | glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)load("glProgramUniform3iv"); 1334 | glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)load("glProgramUniform3f"); 1335 | glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)load("glProgramUniform3fv"); 1336 | glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)load("glProgramUniform3d"); 1337 | glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)load("glProgramUniform3dv"); 1338 | glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)load("glProgramUniform3ui"); 1339 | glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)load("glProgramUniform3uiv"); 1340 | glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)load("glProgramUniform4i"); 1341 | glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)load("glProgramUniform4iv"); 1342 | glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)load("glProgramUniform4f"); 1343 | glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)load("glProgramUniform4fv"); 1344 | glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)load("glProgramUniform4d"); 1345 | glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)load("glProgramUniform4dv"); 1346 | glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)load("glProgramUniform4ui"); 1347 | glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)load("glProgramUniform4uiv"); 1348 | glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)load("glProgramUniformMatrix2fv"); 1349 | glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)load("glProgramUniformMatrix3fv"); 1350 | glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)load("glProgramUniformMatrix4fv"); 1351 | glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)load("glProgramUniformMatrix2dv"); 1352 | glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)load("glProgramUniformMatrix3dv"); 1353 | glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)load("glProgramUniformMatrix4dv"); 1354 | glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)load("glProgramUniformMatrix2x3fv"); 1355 | glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)load("glProgramUniformMatrix3x2fv"); 1356 | glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)load("glProgramUniformMatrix2x4fv"); 1357 | glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)load("glProgramUniformMatrix4x2fv"); 1358 | glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)load("glProgramUniformMatrix3x4fv"); 1359 | glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)load("glProgramUniformMatrix4x3fv"); 1360 | glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)load("glProgramUniformMatrix2x3dv"); 1361 | glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)load("glProgramUniformMatrix3x2dv"); 1362 | glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)load("glProgramUniformMatrix2x4dv"); 1363 | glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)load("glProgramUniformMatrix4x2dv"); 1364 | glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)load("glProgramUniformMatrix3x4dv"); 1365 | glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)load("glProgramUniformMatrix4x3dv"); 1366 | glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)load("glValidateProgramPipeline"); 1367 | glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)load("glGetProgramPipelineInfoLog"); 1368 | glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)load("glVertexAttribL1d"); 1369 | glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)load("glVertexAttribL2d"); 1370 | glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)load("glVertexAttribL3d"); 1371 | glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)load("glVertexAttribL4d"); 1372 | glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)load("glVertexAttribL1dv"); 1373 | glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)load("glVertexAttribL2dv"); 1374 | glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)load("glVertexAttribL3dv"); 1375 | glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)load("glVertexAttribL4dv"); 1376 | glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)load("glVertexAttribLPointer"); 1377 | glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)load("glGetVertexAttribLdv"); 1378 | glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)load("glViewportArrayv"); 1379 | glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)load("glViewportIndexedf"); 1380 | glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)load("glViewportIndexedfv"); 1381 | glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC)load("glScissorArrayv"); 1382 | glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)load("glScissorIndexed"); 1383 | glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)load("glScissorIndexedv"); 1384 | glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)load("glDepthRangeArrayv"); 1385 | glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)load("glDepthRangeIndexed"); 1386 | glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC)load("glGetFloati_v"); 1387 | glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)load("glGetDoublei_v"); 1388 | } 1389 | static void load_GL_VERSION_4_2(GLADloadproc load) { 1390 | if(!GLAD_GL_VERSION_4_2) return; 1391 | glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)load("glDrawArraysInstancedBaseInstance"); 1392 | glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)load("glDrawElementsInstancedBaseInstance"); 1393 | glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)load("glDrawElementsInstancedBaseVertexBaseInstance"); 1394 | glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)load("glGetInternalformativ"); 1395 | glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)load("glGetActiveAtomicCounterBufferiv"); 1396 | glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)load("glBindImageTexture"); 1397 | glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)load("glMemoryBarrier"); 1398 | glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)load("glTexStorage1D"); 1399 | glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)load("glTexStorage2D"); 1400 | glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)load("glTexStorage3D"); 1401 | glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)load("glDrawTransformFeedbackInstanced"); 1402 | glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)load("glDrawTransformFeedbackStreamInstanced"); 1403 | } 1404 | static void load_GL_VERSION_4_3(GLADloadproc load) { 1405 | if(!GLAD_GL_VERSION_4_3) return; 1406 | glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)load("glClearBufferData"); 1407 | glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)load("glClearBufferSubData"); 1408 | glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)load("glDispatchCompute"); 1409 | glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)load("glDispatchComputeIndirect"); 1410 | glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)load("glCopyImageSubData"); 1411 | glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)load("glFramebufferParameteri"); 1412 | glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)load("glGetFramebufferParameteriv"); 1413 | glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)load("glGetInternalformati64v"); 1414 | glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)load("glInvalidateTexSubImage"); 1415 | glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)load("glInvalidateTexImage"); 1416 | glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)load("glInvalidateBufferSubData"); 1417 | glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)load("glInvalidateBufferData"); 1418 | glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)load("glInvalidateFramebuffer"); 1419 | glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)load("glInvalidateSubFramebuffer"); 1420 | glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)load("glMultiDrawArraysIndirect"); 1421 | glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)load("glMultiDrawElementsIndirect"); 1422 | glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)load("glGetProgramInterfaceiv"); 1423 | glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)load("glGetProgramResourceIndex"); 1424 | glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)load("glGetProgramResourceName"); 1425 | glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)load("glGetProgramResourceiv"); 1426 | glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)load("glGetProgramResourceLocation"); 1427 | glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)load("glGetProgramResourceLocationIndex"); 1428 | glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)load("glShaderStorageBlockBinding"); 1429 | glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)load("glTexBufferRange"); 1430 | glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)load("glTexStorage2DMultisample"); 1431 | glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)load("glTexStorage3DMultisample"); 1432 | glad_glTextureView = (PFNGLTEXTUREVIEWPROC)load("glTextureView"); 1433 | glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load("glBindVertexBuffer"); 1434 | glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load("glVertexAttribFormat"); 1435 | glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load("glVertexAttribIFormat"); 1436 | glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load("glVertexAttribLFormat"); 1437 | glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load("glVertexAttribBinding"); 1438 | glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load("glVertexBindingDivisor"); 1439 | glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)load("glDebugMessageControl"); 1440 | glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)load("glDebugMessageInsert"); 1441 | glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)load("glDebugMessageCallback"); 1442 | glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)load("glGetDebugMessageLog"); 1443 | glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)load("glPushDebugGroup"); 1444 | glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)load("glPopDebugGroup"); 1445 | glad_glObjectLabel = (PFNGLOBJECTLABELPROC)load("glObjectLabel"); 1446 | glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)load("glGetObjectLabel"); 1447 | glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)load("glObjectPtrLabel"); 1448 | glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)load("glGetObjectPtrLabel"); 1449 | glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load("glGetPointerv"); 1450 | } 1451 | static int find_extensionsGL(void) { 1452 | if (!get_exts()) return 0; 1453 | (void)&has_ext; 1454 | free_exts(); 1455 | return 1; 1456 | } 1457 | 1458 | static void find_coreGL(void) { 1459 | 1460 | /* Thank you @elmindreda 1461 | * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176 1462 | * https://github.com/glfw/glfw/blob/master/src/context.c#L36 1463 | */ 1464 | int i, major, minor; 1465 | 1466 | const char* version; 1467 | const char* prefixes[] = { 1468 | "OpenGL ES-CM ", 1469 | "OpenGL ES-CL ", 1470 | "OpenGL ES ", 1471 | NULL 1472 | }; 1473 | 1474 | version = (const char*) glGetString(GL_VERSION); 1475 | if (!version) return; 1476 | 1477 | for (i = 0; prefixes[i]; i++) { 1478 | const size_t length = strlen(prefixes[i]); 1479 | if (strncmp(version, prefixes[i], length) == 0) { 1480 | version += length; 1481 | break; 1482 | } 1483 | } 1484 | 1485 | /* PR #18 */ 1486 | #ifdef _MSC_VER 1487 | sscanf_s(version, "%d.%d", &major, &minor); 1488 | #else 1489 | sscanf(version, "%d.%d", &major, &minor); 1490 | #endif 1491 | 1492 | GLVersion.major = major; GLVersion.minor = minor; 1493 | max_loaded_major = major; max_loaded_minor = minor; 1494 | GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; 1495 | GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; 1496 | GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; 1497 | GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; 1498 | GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; 1499 | GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; 1500 | GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; 1501 | GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; 1502 | GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; 1503 | GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; 1504 | GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; 1505 | GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; 1506 | GLAD_GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4; 1507 | GLAD_GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4; 1508 | GLAD_GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4; 1509 | GLAD_GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4; 1510 | if (GLVersion.major > 4 || (GLVersion.major >= 4 && GLVersion.minor >= 3)) { 1511 | max_loaded_major = 4; 1512 | max_loaded_minor = 3; 1513 | } 1514 | } 1515 | 1516 | int gladLoadGLLoader(GLADloadproc load) { 1517 | GLVersion.major = 0; GLVersion.minor = 0; 1518 | glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); 1519 | if(glGetString == NULL) return 0; 1520 | if(glGetString(GL_VERSION) == NULL) return 0; 1521 | find_coreGL(); 1522 | load_GL_VERSION_1_0(load); 1523 | load_GL_VERSION_1_1(load); 1524 | load_GL_VERSION_1_2(load); 1525 | load_GL_VERSION_1_3(load); 1526 | load_GL_VERSION_1_4(load); 1527 | load_GL_VERSION_1_5(load); 1528 | load_GL_VERSION_2_0(load); 1529 | load_GL_VERSION_2_1(load); 1530 | load_GL_VERSION_3_0(load); 1531 | load_GL_VERSION_3_1(load); 1532 | load_GL_VERSION_3_2(load); 1533 | load_GL_VERSION_3_3(load); 1534 | load_GL_VERSION_4_0(load); 1535 | load_GL_VERSION_4_1(load); 1536 | load_GL_VERSION_4_2(load); 1537 | load_GL_VERSION_4_3(load); 1538 | 1539 | if (!find_extensionsGL()) return 0; 1540 | return GLVersion.major != 0 || GLVersion.minor != 0; 1541 | } 1542 | 1543 | -------------------------------------------------------------------------------- /src/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(KHRONOS_STATIC) 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 | #elif defined(__VMS ) || defined(__sgi) 158 | 159 | /* 160 | * Using 161 | */ 162 | #include 163 | typedef int32_t khronos_int32_t; 164 | typedef uint32_t khronos_uint32_t; 165 | typedef int64_t khronos_int64_t; 166 | typedef uint64_t khronos_uint64_t; 167 | #define KHRONOS_SUPPORT_INT64 1 168 | #define KHRONOS_SUPPORT_FLOAT 1 169 | 170 | #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) 171 | 172 | /* 173 | * Win32 174 | */ 175 | typedef __int32 khronos_int32_t; 176 | typedef unsigned __int32 khronos_uint32_t; 177 | typedef __int64 khronos_int64_t; 178 | typedef unsigned __int64 khronos_uint64_t; 179 | #define KHRONOS_SUPPORT_INT64 1 180 | #define KHRONOS_SUPPORT_FLOAT 1 181 | 182 | #elif defined(__sun__) || defined(__digital__) 183 | 184 | /* 185 | * Sun or Digital 186 | */ 187 | typedef int khronos_int32_t; 188 | typedef unsigned int khronos_uint32_t; 189 | #if defined(__arch64__) || defined(_LP64) 190 | typedef long int khronos_int64_t; 191 | typedef unsigned long int khronos_uint64_t; 192 | #else 193 | typedef long long int khronos_int64_t; 194 | typedef unsigned long long int khronos_uint64_t; 195 | #endif /* __arch64__ */ 196 | #define KHRONOS_SUPPORT_INT64 1 197 | #define KHRONOS_SUPPORT_FLOAT 1 198 | 199 | #elif 0 200 | 201 | /* 202 | * Hypothetical platform with no float or int64 support 203 | */ 204 | typedef int khronos_int32_t; 205 | typedef unsigned int khronos_uint32_t; 206 | #define KHRONOS_SUPPORT_INT64 0 207 | #define KHRONOS_SUPPORT_FLOAT 0 208 | 209 | #else 210 | 211 | /* 212 | * Generic fallback 213 | */ 214 | #include 215 | typedef int32_t khronos_int32_t; 216 | typedef uint32_t khronos_uint32_t; 217 | typedef int64_t khronos_int64_t; 218 | typedef uint64_t khronos_uint64_t; 219 | #define KHRONOS_SUPPORT_INT64 1 220 | #define KHRONOS_SUPPORT_FLOAT 1 221 | 222 | #endif 223 | 224 | 225 | /* 226 | * Types that are (so far) the same on all platforms 227 | */ 228 | typedef signed char khronos_int8_t; 229 | typedef unsigned char khronos_uint8_t; 230 | typedef signed short int khronos_int16_t; 231 | typedef unsigned short int khronos_uint16_t; 232 | 233 | /* 234 | * Types that differ between LLP64 and LP64 architectures - in LLP64, 235 | * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears 236 | * to be the only LLP64 architecture in current use. 237 | */ 238 | #ifdef _WIN64 239 | typedef signed long long int khronos_intptr_t; 240 | typedef unsigned long long int khronos_uintptr_t; 241 | typedef signed long long int khronos_ssize_t; 242 | typedef unsigned long long int khronos_usize_t; 243 | #else 244 | typedef signed long int khronos_intptr_t; 245 | typedef unsigned long int khronos_uintptr_t; 246 | typedef signed long int khronos_ssize_t; 247 | typedef unsigned long int khronos_usize_t; 248 | #endif 249 | 250 | #if KHRONOS_SUPPORT_FLOAT 251 | /* 252 | * Float type 253 | */ 254 | typedef float khronos_float_t; 255 | #endif 256 | 257 | #if KHRONOS_SUPPORT_INT64 258 | /* Time types 259 | * 260 | * These types can be used to represent a time interval in nanoseconds or 261 | * an absolute Unadjusted System Time. Unadjusted System Time is the number 262 | * of nanoseconds since some arbitrary system event (e.g. since the last 263 | * time the system booted). The Unadjusted System Time is an unsigned 264 | * 64 bit value that wraps back to 0 every 584 years. Time intervals 265 | * may be either signed or unsigned. 266 | */ 267 | typedef khronos_uint64_t khronos_utime_nanoseconds_t; 268 | typedef khronos_int64_t khronos_stime_nanoseconds_t; 269 | #endif 270 | 271 | /* 272 | * Dummy value used to pad enum types to 32 bits. 273 | */ 274 | #ifndef KHRONOS_MAX_ENUM 275 | #define KHRONOS_MAX_ENUM 0x7FFFFFFF 276 | #endif 277 | 278 | /* 279 | * Enumerated boolean type 280 | * 281 | * Values other than zero should be considered to be true. Therefore 282 | * comparisons should not be made against KHRONOS_TRUE. 283 | */ 284 | typedef enum { 285 | KHRONOS_FALSE = 0, 286 | KHRONOS_TRUE = 1, 287 | KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM 288 | } khronos_boolean_enum_t; 289 | 290 | #endif /* __khrplatform_h_ */ 291 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ProgramOptions.h" 2 | #include "GLFWHandler.h" 3 | #include "SimpleFluid.h" 4 | #include "Smoke.h" 5 | #include "Clouds.h" 6 | 7 | int main(int argc, char** argv) 8 | { 9 | srand(time(NULL)); 10 | 11 | ProgramOptions options = parseOptions(argc, argv); 12 | 13 | GLFWHandler handler(&options); 14 | 15 | /*********** SIMULATION CHOICE ***********/ 16 | SimulationBase *sim; 17 | switch(options.simType) 18 | { 19 | case SPLATS: 20 | { 21 | sim = new SimpleFluid(&options, &handler); 22 | break; 23 | } 24 | case SMOKE: 25 | { 26 | sim = new Smoke(&options, &handler); 27 | break; 28 | } 29 | case CLOUDS: 30 | { 31 | sim = new Clouds(&options, &handler); 32 | break; 33 | } 34 | } 35 | 36 | handler.attachSimulation(sim); 37 | handler.run(); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /src/shaders/fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | in vec2 texCoord; 4 | 5 | out vec4 outColor; 6 | 7 | uniform sampler2D tex; 8 | 9 | void main() 10 | { 11 | outColor = texture(tex, texCoord); 12 | //outColor = vec4(texCoord, texCoord); 13 | } 14 | -------------------------------------------------------------------------------- /src/shaders/simulation/RKAdvect.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(location = 0) uniform float dt; 7 | 8 | layout(rgba16f, binding = 0) uniform image2D field_WRITE; 9 | layout(binding = 1) uniform sampler2D field_READ; 10 | layout(binding = 2) uniform sampler2D velocities_READ; 11 | 12 | void main() 13 | { 14 | vec2 tSize = TEXTURE_SIZE(field_READ); 15 | vec2 pixelCoords = gl_GlobalInvocationID.xy; 16 | 17 | vec2 v = RK(velocities_READ, pixelCoords, dt); 18 | vec2 pos = pixelCoords - dt * v; 19 | vec4 val = TEXTURE_2D(field_READ, pixelToTexel(pos, tSize)); 20 | 21 | imageStore(field_WRITE, ivec2(pixelCoords), val); 22 | } 23 | -------------------------------------------------------------------------------- /src/shaders/simulation/addSmokeSpot.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | uniform ivec2 spotPos; 7 | uniform vec3 color; 8 | uniform float intensity; 9 | 10 | layout(rgba16f, binding = 0) uniform image2D field; 11 | 12 | void main() 13 | { 14 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 15 | vec2 p = vec2(pixelCoords - spotPos); 16 | 17 | vec3 splat = intensity * exp(- dot(p, p) / 200.0f) * color; 18 | vec3 baseD = imageLoad(field, pixelCoords).xyz; 19 | 20 | imageStore(field, pixelCoords, vec4(baseD + splat, 1.0f)); 21 | } 22 | -------------------------------------------------------------------------------- /src/shaders/simulation/applyVorticity.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | uniform float dt; 7 | 8 | layout(rgba16f, binding = 0) uniform image2D velocities_READ_WRITE; 9 | layout(binding = 1) uniform sampler2D curl; 10 | 11 | void main() 12 | { 13 | const ivec2 tSize = TEXTURE_SIZE(curl); 14 | const ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 15 | const ivec2 dx = ivec2(1, 0); 16 | const ivec2 dy = ivec2(0, 1); 17 | 18 | float vL = texelFetchOffset(curl, pixelCoords, 0, - dx).y; 19 | float vR = texelFetchOffset(curl, pixelCoords, 0, dx).y; 20 | float vB = texelFetchOffset(curl, pixelCoords, 0, - dy).y; 21 | float vT = texelFetchOffset(curl, pixelCoords, 0, dy).y; 22 | 23 | float vC = texelFetch(curl, pixelCoords, 0).y; 24 | if(pixelCoords.x == 0) vL = vC; 25 | if(pixelCoords.y == 0) vB = vC; 26 | if(pixelCoords.x >= tSize.x - 1) vR = vC; 27 | if(pixelCoords.y >= tSize.y - 1) vT = vC; 28 | 29 | vec2 force = 0.5f * vec2(abs(vT) - abs(vB), abs(vR) - abs(vL)); 30 | force /= 1e-10 + length(force); 31 | force *= vC * vec2(1.0f, -1.0f); 32 | 33 | imageStore(velocities_READ_WRITE, pixelCoords, imageLoad(velocities_READ_WRITE, pixelCoords) + dt * vec4(force, 0.0f, 0.0f)); 34 | } 35 | -------------------------------------------------------------------------------- /src/shaders/simulation/buoyantForce.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | uniform float dt; 7 | uniform float kappa; 8 | uniform float sigma; 9 | uniform float t0; 10 | 11 | layout(rgba16f, binding = 0) uniform image2D velocities_READ_WRITE; 12 | layout(binding = 1) uniform sampler2D temperature; 13 | layout(binding = 2) uniform sampler2D density; 14 | 15 | void main() 16 | { 17 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 18 | 19 | float t = texelFetch(temperature, pixelCoords, 0).x; 20 | float d = texelFetch(density, pixelCoords, 0).x; 21 | 22 | vec2 force = (- kappa * d + sigma * (t - t0)) * vec2(0.0f, 1.0f); 23 | vec4 oldVel = imageLoad(velocities_READ_WRITE, pixelCoords); 24 | 25 | imageStore(velocities_READ_WRITE, pixelCoords, oldVel + dt * vec4(force, 0.0f, 0.0f)); 26 | } 27 | -------------------------------------------------------------------------------- /src/shaders/simulation/copy.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D tex_WRITE; 7 | layout(rgba16f, binding = 1) uniform image2D tex_READ; 8 | 9 | void main() 10 | { 11 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 12 | vec4 pixel = imageLoad(tex_READ, pixelCoords); 13 | 14 | imageStore(tex_WRITE, pixelCoords, pixel); 15 | } 16 | -------------------------------------------------------------------------------- /src/shaders/simulation/divCurl.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D divergence; 7 | layout(binding = 1) uniform sampler2D velocities_READ; 8 | 9 | void main() 10 | { 11 | const ivec2 tSize = TEXTURE_SIZE(velocities_READ); 12 | const ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 13 | 14 | const ivec2 dx = ivec2(1, 0); 15 | const ivec2 dy = ivec2(0, 1); 16 | 17 | vec2 fieldL = texelFetchOffset(velocities_READ, pixelCoords, 0, - dx).xy; 18 | vec2 fieldR = texelFetchOffset(velocities_READ, pixelCoords, 0, dx).xy; 19 | vec2 fieldB = texelFetchOffset(velocities_READ, pixelCoords, 0, - dy).xy; 20 | vec2 fieldT = texelFetchOffset(velocities_READ, pixelCoords, 0, dy).xy; 21 | 22 | vec2 fieldC = texelFetch(velocities_READ, pixelCoords, 0).xy; 23 | if(pixelCoords.x == 0) fieldL.x = - fieldC.x; 24 | if(pixelCoords.y == 0) fieldB.y = - fieldC.y; 25 | if(pixelCoords.x >= tSize.x - 1) fieldR.x = - fieldC.x; 26 | if(pixelCoords.y >= tSize.y - 1) fieldT.y = - fieldC.y; 27 | 28 | float div = 0.5f * (fieldR.x - fieldL.x + fieldT.y - fieldB.y); 29 | float curl = 0.5f * (fieldR.y - fieldL.y - fieldT.x + fieldB.x); 30 | 31 | imageStore(divergence, pixelCoords, vec4(div, curl, 0.0f, 0.0f)); 32 | } 33 | -------------------------------------------------------------------------------- /src/shaders/simulation/divRB.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D divergence; 7 | layout(binding = 1) uniform sampler2D velocities_READ; 8 | 9 | // The grid point 11 corresponds to the pixel coords 2 * pixelCoords 10 | // We then fetch various neighboors to compute the divergence of points 11, 21, 12, 22 11 | // and store them in a single point on the divergence texture with r -> 11, g -> 21, b -> 22, a -> 12 12 | 13 | // 03 ------ 13 ------ 23 ------ 33 14 | // | | | | 15 | // | | | | 16 | // 02 ------ 12 ------ 22 ------ 32 17 | // | | | | 18 | // | | | | 19 | // 01 ------ 11 ------ 21 ------ 31 20 | // | | | | 21 | // | | | | 22 | // 00 ------ 10 ------ 20 ------ 30 23 | 24 | 25 | void main() 26 | { 27 | const ivec2 tSize = TEXTURE_SIZE(velocities_READ); 28 | const ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 29 | 30 | vec2 field11 = texelFetch(velocities_READ , 2 * pixelCoords, 0 ).xy; 31 | vec2 field01 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2(-1, 0)).xy; 32 | vec2 field21 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 1, 0)).xy; 33 | vec2 field10 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 0, -1)).xy; 34 | vec2 field12 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 0, 1)).xy; 35 | vec2 field20 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 1, -1)).xy; 36 | vec2 field02 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2(-1, 1)).xy; 37 | vec2 field13 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 0, 2)).xy; 38 | vec2 field23 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 1, 2)).xy; 39 | vec2 field22 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 1, 1)).xy; 40 | vec2 field31 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 2, 0)).xy; 41 | vec2 field32 = texelFetchOffset(velocities_READ, 2 * pixelCoords, 0, ivec2( 2, 1)).xy; 42 | 43 | if(pixelCoords.x == 0) 44 | { 45 | field01.x = - field11.x; 46 | field02.x = - field12.x; 47 | } 48 | if(pixelCoords.y == 0) 49 | { 50 | field10.y = - field11.y; 51 | field20.y = - field21.y; 52 | } 53 | if(2 * pixelCoords.x + 1 >= tSize.x - 1) 54 | { 55 | field31.x = - field21.x; 56 | field32.x = - field22.x; 57 | } 58 | if(2 * pixelCoords.y + 1 >= tSize.y - 1) 59 | { 60 | field13.y = - field12.y; 61 | field23.y = - field22.y; 62 | } 63 | 64 | const float r = 0.5 * (field21.x - field01.x + field12.y - field10.y); 65 | const float g = 0.5 * (field31.x - field11.x + field22.y - field20.y); 66 | const float b = 0.5 * (field32.x - field12.x + field23.y - field21.y); 67 | const float a = 0.5 * (field22.x - field02.x + field13.y - field11.y); 68 | 69 | imageStore(divergence, pixelCoords, vec4(r, g, b, a)); 70 | } 71 | -------------------------------------------------------------------------------- /src/shaders/simulation/includes.comp: -------------------------------------------------------------------------------- 1 | //https://stackoverflow.com/questions/2631324/opengl-shading-language-backwards-compatibility 2 | #if __VERSION__ >= 130 3 | 4 | #define TEXTURE_2D texture 5 | #define TEXTURE_3D texture 6 | #define TEXTURE_RECT texture 7 | #define TEXTURE_CUBE texture 8 | 9 | #if __VERSION__ >= 150 10 | #define TEXTURE_SIZE(sampler) textureSize(sampler, 0) 11 | #else 12 | #define TEXTURE_SIZE(sampler) sampler ## _Size 13 | #endif 14 | 15 | #else 16 | 17 | #define TEXTURE_2D texture2D 18 | #define TEXTURE_3D texture3D 19 | #define TEXTURE_RECT texture2DRect 20 | #define TEXTURE_CUBE textureCube 21 | 22 | #endif 23 | 24 | vec2 pixelToTexel(in vec2 p, in vec2 tSize) 25 | { 26 | return (p + 0.5) / tSize; 27 | } 28 | 29 | //https://www.iquilezles.org/www/articles/hwinterpolation/hwinterpolation.htm 30 | vec4 texture2D_bilinear(in sampler2D t, in vec2 uv) 31 | { 32 | vec2 res = TEXTURE_SIZE( t ); 33 | 34 | vec2 st = uv*res - 0.5; 35 | 36 | vec2 iuv = floor( st ); 37 | vec2 fuv = fract( st ); 38 | 39 | vec4 a = TEXTURE_2D( t, (iuv+vec2(0.5,0.5))/res ); 40 | vec4 b = TEXTURE_2D( t, (iuv+vec2(1.5,0.5))/res ); 41 | vec4 c = TEXTURE_2D( t, (iuv+vec2(0.5,1.5))/res ); 42 | vec4 d = TEXTURE_2D( t, (iuv+vec2(1.5,1.5))/res ); 43 | 44 | return mix( mix( a, b, fuv.x), 45 | mix( c, d, fuv.x), fuv.y ); 46 | } 47 | 48 | vec4 clampValue(in sampler2D t, in vec4 value, in vec2 uv) 49 | { 50 | vec2 tSize = TEXTURE_SIZE(t); 51 | 52 | vec2 npos = floor(uv * tSize - 0.5); 53 | 54 | vec4 a = texture2D_bilinear(t, pixelToTexel(npos + vec2(0.0, 0.0), tSize)); 55 | vec4 b = texture2D_bilinear(t, pixelToTexel(npos + vec2(1.0, 0.0), tSize)); 56 | vec4 c = texture2D_bilinear(t, pixelToTexel(npos + vec2(0.0, 1.0), tSize)); 57 | vec4 d = texture2D_bilinear(t, pixelToTexel(npos + vec2(1.0, 1.0), tSize)); 58 | 59 | vec4 vMin = min(min(min(a, b), c), d); 60 | vec4 vMax = max(max(max(a, b), c), d); 61 | 62 | return clamp(value, vMin, vMax); 63 | } 64 | 65 | vec2 RK(in sampler2D t, in vec2 pos, in float dt) 66 | { 67 | vec2 tSize = TEXTURE_SIZE(t); 68 | 69 | vec2 v1 = texture2D_bilinear(t, pixelToTexel(pos, tSize)).xy; 70 | vec2 v2 = texture2D_bilinear(t, pixelToTexel(pos + 0.5 * v1 * dt, tSize)).xy; 71 | vec2 v3 = texture2D_bilinear(t, pixelToTexel(pos + 0.5 * v2 * dt, tSize)).xy; 72 | vec2 v4 = texture2D_bilinear(t, pixelToTexel(pos + v3 * dt, tSize)).xy; 73 | 74 | return (v1 + 2.0 * (v2 + v3) + v4) * (1.0 / 6.0); 75 | } 76 | -------------------------------------------------------------------------------- /src/shaders/simulation/jacobi.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D pressure_WRITE; 7 | layout(binding = 1) uniform sampler2D pressure_READ; 8 | layout(binding = 2) uniform sampler2D divergence; 9 | 10 | void main() 11 | { 12 | ivec2 tSize = TEXTURE_SIZE(pressure_READ); 13 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 14 | const ivec2 dx = ivec2(1, 0); 15 | const ivec2 dy = ivec2(0, 1); 16 | 17 | float dC = texelFetch(divergence, pixelCoords, 0).x; 18 | 19 | float pL = texelFetchOffset(pressure_READ, pixelCoords, 0, - dx).x; 20 | float pR = texelFetchOffset(pressure_READ, pixelCoords, 0, dx).x; 21 | float pB = texelFetchOffset(pressure_READ, pixelCoords, 0, - dy).x; 22 | float pT = texelFetchOffset(pressure_READ, pixelCoords, 0, dy).x; 23 | 24 | float pC = texelFetch(pressure_READ, pixelCoords, 0).x; 25 | if(pixelCoords.x == 0) pL = pC; 26 | if(pixelCoords.y == 0) pB = pC; 27 | if(pixelCoords.x == tSize.x - 1) pR = pC; 28 | if(pixelCoords.y == tSize.y - 1) pT = pC; 29 | 30 | imageStore(pressure_WRITE, pixelCoords, vec4(0.25f * (pL + pR + pB + pT - dC), 0.0f, 0.0f, 1.0f)); 31 | } 32 | -------------------------------------------------------------------------------- /src/shaders/simulation/jacobiBlack.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D pressure_WRITE; 7 | layout(binding = 1) uniform sampler2D pressure_READ; 8 | layout(binding = 2) uniform sampler2D divergence; 9 | 10 | // The divergence and pressure is packed in an half-size texture. 11 | // This black pass updates the bottom left and top right points (black points) 12 | // using neighbooring red points. 13 | // For example result(22) = p(12) + p(32) + p(23) + (21) - div(22) 14 | // = p(0, 1).g + p(1, 1).a + p(1, 1).g + p(1, 0).a - div(1, 1).g; 15 | 16 | // 03 ------ 13 23 ------ 33 17 | // | | | | 18 | // | (0, 1) | | (1, 1) | 19 | // | | | | 20 | // 02 ------ 12 22 ------ 32 21 | // 22 | // 23 | // 01 ------ 11 21 ------ 31 24 | // | | | | 25 | // | (0, 0) | | (1, 0) | 26 | // | | | | 27 | // 00 ------ 10 20 ------ 30 28 | 29 | void main() 30 | { 31 | const ivec2 tSize = TEXTURE_SIZE(pressure_READ); 32 | const vec2 pixelCoords = gl_GlobalInvocationID.xy; 33 | const vec2 dx = vec2(1, 0); 34 | const vec2 dy = vec2(0, 1); 35 | 36 | const vec4 dC = texelFetch(divergence, ivec2(pixelCoords), 0); 37 | 38 | const vec4 pC = texelFetch(pressure_READ, ivec2(pixelCoords), 0); 39 | const vec4 pL = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dx, tSize)); 40 | const vec4 pR = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dx, tSize)); 41 | const vec4 pB = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dy, tSize)); 42 | const vec4 pT = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dy, tSize)); 43 | 44 | const float r = 0.25 * (pL.y + pC.y + pB.w + pC.w - dC.x); 45 | const float b = 0.25 * (pC.w + pR.w + pC.y + pT.y - dC.z); 46 | 47 | imageStore(pressure_WRITE, ivec2(pixelCoords), vec4(r, pC.y, b, pC.w)); 48 | } 49 | -------------------------------------------------------------------------------- /src/shaders/simulation/jacobiRed.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D pressure_WRITE; 7 | layout(binding = 1) uniform sampler2D pressure_READ; 8 | layout(binding = 2) uniform sampler2D divergence; 9 | 10 | // The divergence and pressure is packed in an half-size texture. 11 | // This red pass updates the top left and bottom right points (red points) 12 | // using neighbooring black points. 13 | 14 | // 03 ------ 13 23 ------ 33 15 | // | | | | 16 | // | (0, 1) | | (1, 1) | 17 | // | | | | 18 | // 02 ------ 12 22 ------ 32 19 | // 20 | // 21 | // 01 ------ 11 21 ------ 31 22 | // | | | | 23 | // | (0, 0) | | (1, 0) | 24 | // | | | | 25 | // 00 ------ 10 20 ------ 30 26 | 27 | void main() 28 | { 29 | const ivec2 tSize = TEXTURE_SIZE(pressure_READ); 30 | const vec2 pixelCoords = gl_GlobalInvocationID.xy; 31 | const vec2 dx = vec2(1, 0); 32 | const vec2 dy = vec2(0, 1); 33 | 34 | const vec4 dC = texelFetch(divergence, ivec2(pixelCoords), 0); 35 | 36 | const vec4 pC = texelFetch(pressure_READ, ivec2(pixelCoords), 0); 37 | const vec4 pL = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dx, tSize)); 38 | const vec4 pR = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dx, tSize)); 39 | const vec4 pB = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dy, tSize)); 40 | const vec4 pT = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dy, tSize)); 41 | 42 | const float g = 0.25 * (pC.x + pR.x + pB.z + pC.z - dC.y); 43 | const float a = 0.25 * (pL.z + pC.z + pT.x + pC.x - dC.w); 44 | 45 | imageStore(pressure_WRITE, ivec2(pixelCoords), vec4(pC.x, g, pC.z, a)); 46 | } 47 | -------------------------------------------------------------------------------- /src/shaders/simulation/layout_size.comp: -------------------------------------------------------------------------------- 1 | layout(local_size_x = 32, local_size_y = 32) in; 2 | -------------------------------------------------------------------------------- /src/shaders/simulation/maxReduce.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D oTex; 7 | layout(binding = 1) uniform sampler2D iTex; 8 | 9 | void main() 10 | { 11 | ivec2 tSize = TEXTURE_SIZE(iTex); 12 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 13 | 14 | vec4 a = TEXTURE_2D(iTex, pixelToTexel(2 * pixelCoords , tSize)); 15 | vec4 b = TEXTURE_2D(iTex, pixelToTexel(2 * pixelCoords + ivec2(1, 0), tSize)); 16 | vec4 c = TEXTURE_2D(iTex, pixelToTexel(2 * pixelCoords + ivec2(0, 1), tSize)); 17 | vec4 d = TEXTURE_2D(iTex, pixelToTexel(2 * pixelCoords + ivec2(1, 1), tSize)); 18 | 19 | imageStore(oTex, pixelCoords, max(max(max(a, b), c), d)); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/shaders/simulation/mccormack.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(location = 0) uniform float dt; 7 | layout(location = 1) uniform float revert; 8 | 9 | layout(rgba16f, binding = 0) uniform image2D field_WRITE; 10 | layout(binding = 1) uniform sampler2D field_n; 11 | layout(binding = 2) uniform sampler2D field_n_hat_READ; 12 | layout(binding = 3) uniform sampler2D field_n_1_READ; 13 | layout(binding = 4) uniform sampler2D velocities_READ; 14 | 15 | void main() 16 | { 17 | vec2 tSize = TEXTURE_SIZE(field_n_hat_READ); 18 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 19 | 20 | vec4 qAdv = texelFetch(field_n_1_READ, pixelCoords, 0); 21 | 22 | vec4 r = qAdv + 0.5 * texelFetch(field_n, pixelCoords, 0) 23 | - 0.5 * texelFetch(field_n_hat_READ, pixelCoords, 0); 24 | 25 | vec2 v = RK(velocities_READ, pixelCoords, dt); 26 | vec2 pos = pixelCoords - dt * v; 27 | vec4 rClamped = clampValue(field_n, r, pixelToTexel(pos, tSize)); 28 | 29 | r = length(rClamped - r) > revert ? qAdv : rClamped; 30 | 31 | imageStore(field_WRITE, pixelCoords, r); 32 | } 33 | -------------------------------------------------------------------------------- /src/shaders/simulation/pressureProjectionRB.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D velocities_WRITE; 7 | layout(binding = 1) uniform sampler2D velocities_READ; 8 | layout(binding = 2) uniform sampler2D pressure_READ; 9 | 10 | // 01 ------ 11 11 | // | | 12 | // | (0, 0) | 13 | // | | 14 | // 00 ------ 10 15 | 16 | void main() 17 | { 18 | const ivec2 tSize = TEXTURE_SIZE(pressure_READ); 19 | const vec2 pixelCoords = gl_GlobalInvocationID.xy; 20 | const vec2 dx = vec2(1, 0); 21 | const vec2 dy = vec2(0, 1); 22 | 23 | const vec4 pC = texelFetch(pressure_READ, ivec2(pixelCoords), 0); 24 | const vec4 pL = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dx, tSize)); 25 | const vec4 pR = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dx, tSize)); 26 | const vec4 pB = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords - dy, tSize)); 27 | const vec4 pT = TEXTURE_2D(pressure_READ, pixelToTexel(pixelCoords + dy, tSize)); 28 | 29 | const vec2 rGrad = 0.5 * vec2(pC.y - pL.y, pC.w - pB.w); 30 | const vec2 gGrad = 0.5 * vec2(pR.x - pC.x, pC.z - pB.z); 31 | const vec2 bGrad = 0.5 * vec2(pR.w - pC.w, pT.y - pC.y); 32 | const vec2 aGrad = 0.5 * vec2(pC.z - pL.z, pT.x - pC.x); 33 | 34 | const ivec2 pCoords = 2 * ivec2(pixelCoords); 35 | const vec2 rVel = texelFetch( velocities_READ, pCoords, 0 ).xy; 36 | const vec2 gVel = texelFetchOffset(velocities_READ, pCoords, 0, ivec2(1, 0)).xy; 37 | const vec2 bVel = texelFetchOffset(velocities_READ, pCoords, 0, ivec2(1, 1)).xy; 38 | const vec2 aVel = texelFetchOffset(velocities_READ, pCoords, 0, ivec2(0, 1)).xy; 39 | 40 | imageStore(velocities_WRITE, pCoords , vec4(rVel - rGrad, 0.0, 0.0)); 41 | imageStore(velocities_WRITE, pCoords + ivec2(1, 0), vec4(gVel - gGrad, 0.0, 0.0)); 42 | imageStore(velocities_WRITE, pCoords + ivec2(1, 1), vec4(bVel - bGrad, 0.0, 0.0)); 43 | imageStore(velocities_WRITE, pCoords + ivec2(0, 1), vec4(aVel - aGrad, 0.0, 0.0)); 44 | } 45 | -------------------------------------------------------------------------------- /src/shaders/simulation/pressure_projection.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D velocities_WRITE; 7 | layout(binding = 1) uniform sampler2D velocities_READ; 8 | layout(binding = 2) uniform sampler2D pressure_READ; 9 | 10 | void main() 11 | { 12 | ivec2 tSize = TEXTURE_SIZE(velocities_READ); 13 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 14 | const ivec2 dx = ivec2(1, 0); 15 | const ivec2 dy = ivec2(0, 1); 16 | 17 | float pL = texelFetchOffset(pressure_READ, pixelCoords, 0, - dx).x; 18 | float pR = texelFetchOffset(pressure_READ, pixelCoords, 0, dx).x; 19 | float pB = texelFetchOffset(pressure_READ, pixelCoords, 0, - dy).x; 20 | float pT = texelFetchOffset(pressure_READ, pixelCoords, 0, dy).x; 21 | 22 | float pC = texelFetch(pressure_READ, pixelCoords, 0).x; 23 | if(pixelCoords.x == 0) pL = pC; 24 | if(pixelCoords.y == 0) pB = pC; 25 | if(pixelCoords.x >= tSize.x - 1) pR = pC; 26 | if(pixelCoords.y >= tSize.y - 1) pT = pC; 27 | 28 | vec2 gradP = 0.5f * vec2(pR - pL, pT - pB); 29 | 30 | vec2 oldVel = texelFetch(velocities_READ, pixelCoords, 0).xy; 31 | 32 | imageStore(velocities_WRITE, pixelCoords, vec4(oldVel - gradP, 0.0f, 0.0f)); 33 | } 34 | -------------------------------------------------------------------------------- /src/shaders/simulation/waterContinuity.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #include "includes.comp" 4 | #include "layout_size.comp" 5 | 6 | layout(rgba16f, binding = 0) uniform image2D qTex; 7 | layout(rgba16f, binding = 1) uniform image2D pTemp; 8 | layout(binding = 2) uniform sampler2D pAdvectedTemp; 9 | 10 | #define G 9.80665 11 | #define P0 101325.0 12 | #define T0 290.0 13 | #define LAPSE_RATE 10.0 14 | #define RD 287.0 15 | #define kappa 0.286 16 | #define L 2.501 17 | 18 | void main() 19 | { 20 | vec2 tSize = TEXTURE_SIZE(pAdvectedTemp); 21 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 22 | 23 | // Water Continuity 24 | vec4 theta = imageLoad(pTemp, pixelCoords); 25 | vec4 q = imageLoad(qTex, pixelCoords); 26 | 27 | float z = float(pixelCoords.y) / tSize.y; 28 | float p = P0 * pow(1.0 - z * LAPSE_RATE / T0, G / (LAPSE_RATE / RD)); 29 | float t = pow(P0 / p, kappa) / theta.x; 30 | float qvs = (380.16 / p) * exp(17.67 * t / (t + 243.5)); 31 | float deltaQ = min(qvs - q.x, q.y); 32 | 33 | q.x += deltaQ; 34 | q.y -= deltaQ; 35 | 36 | // Thermodynamics 37 | vec4 thetaAdv = texelFetch(pAdvectedTemp, pixelCoords, 0); 38 | t = pow(P0 / p, kappa) / thetaAdv.x; 39 | qvs = (380.16 / p) * exp(17.67 * t / (t + 243.5)); 40 | deltaQ = min(qvs - q.x, q.y); 41 | thetaAdv.x += (RD * L / kappa) * pow(P0 / p, kappa) * deltaQ; 42 | 43 | imageStore(qTex, pixelCoords, q); 44 | imageStore(pTemp, pixelCoords, thetaAdv); 45 | } 46 | -------------------------------------------------------------------------------- /src/shaders/vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout (location = 0) in vec2 position; 4 | layout (location = 1) in vec2 tCoords; 5 | 6 | out vec2 texCoord; 7 | 8 | void main() 9 | { 10 | texCoord = tCoords; 11 | gl_Position = vec4(position, 0.0, 1.0); 12 | } 13 | --------------------------------------------------------------------------------