diff --git "a/dataset_full.jsonl" "b/dataset_full.jsonl" --- "a/dataset_full.jsonl" +++ "b/dataset_full.jsonl" @@ -1,13 +1,3 @@ -{"id": "ssgl_impl", "source": "https://github.com/local/ssgl", "source_commit": "4d3f2977620be74782a6523fc950e98c0b7f69bb", "collected_at": "2026-08-17T14:37:31+00:00", "source_type": "repo", "title": "Impl", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "compute/texturing/framebuffer/basics", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "impl/gl_helpers.cpp", "language": "cpp", "loc": 86, "comment_density": 0.023, "code": "\n#ifdef _WIN32\n#include \n\n#include \"gl_helpers.h\"\n\n#include \n#pragma comment(lib, \"gdiplus.lib\")\n#include \n#include \n\nTexture loadImage(const wchar_t* path) {\n\tusing namespace Gdiplus;\n\tULONG_PTR token;\n\tGdiplusStartupInput startupInput;\n\tGdiplusStartup(&token, &startupInput, nullptr);\n\n\tTexture result;\n\t// new scope so RAII objects are released before gdi+ shutdown\n\t{\n\t\tImage image(path);\n\t\timage.RotateFlip(RotateNoneFlipY);\n\t\tconst Rect r(0, 0, image.GetWidth(), image.GetHeight());\n\t\tBitmapData data;\n\t\t((Bitmap*)&image)->LockBits(&r, ImageLockModeRead, PixelFormat32bppARGB, &data);\n\n\t\tglBindTexture(GL_TEXTURE_2D, result);\n\t\tglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.GetWidth(), image.GetHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, data.Scan0);\n\t\tglGenerateMipmap(GL_TEXTURE_2D);\n\t\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);\n\t\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n\n\t\t((Bitmap*)&image)->UnlockBits(&data);\n\t}\n\tGdiplusShutdown(token);\n\treturn result;\n}\n\nTexture loadImage(const char* path) {\n\twchar_t str[1024];\n\tMultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, path, -1, str, 1024);\n\treturn loadImage(str);\n}\n#else\n\n#include \n#include \n#include \n#include \n#include \n#include \"gl_helpers.h\"\n\nTexture loadImage(const wchar_t* path) {}\nTexture loadImage(const char* path) {\n unsigned char header[8];\n\n FILE* fp = fopen(path, \"rb\");\n fread(header, 1, 8, fp);\n assert(!png_sig_cmp(header, 0, 8));\n\n png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n\n png_infop info = png_create_info_struct(png);\n\n setjmp(png_jmpbuf(png));\n \n\tpng_init_io(png, fp);\n png_set_sig_bytes(png, 8);\n\n png_read_info(png, info);\n\n int width = png_get_image_width(png, info);\n int height = png_get_image_height(png, info);\n png_byte color_type = png_get_color_type(png, info);\n png_byte bit_depth = png_get_bit_depth(png, info);\n\tassert(bit_depth == 8); // let's just support this\n\n int number_of_passes = png_set_interlace_handling(png);\n png_read_update_info(png, info);\n\n\n\tsetjmp(png_jmpbuf(png));\n\n png_bytep* row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height);\n\tsize_t stride = png_get_rowbytes(png, info);\n for (int i = 0; i < height; i++)\n row_pointers[i] = (png_byte*)malloc(stride);\n\n png_read_image(png, row_pointers);\n\n\tunsigned char* contiguous = (unsigned char*)malloc(stride * height);\n\n\tfor (int i = 0; i < height; i++)\n\t\tmemcpy(contiguous + stride * (height-1-i), row_pointers[i], stride);\n\n\tGLenum format = GL_INVALID_ENUM, order;\n\tif (PNG_COLOR_TYPE_GRAY == color_type) { format = GL_R8; order = GL_RED; }\n\tif (PNG_COLOR_TYPE_RGB == color_type) { format = GL_RGB8; order = GL_RGB; }\n\tif (PNG_COLOR_TYPE_RGB_ALPHA == color_type) { format = GL_RGBA8; order = GL_RGBA; }\n\tassert(format != GL_INVALID_ENUM);\n\n\tTexture result;\n\tglBindTexture(GL_TEXTURE_2D, result);\n\tglTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, order, GL_UNSIGNED_BYTE, contiguous);\n\tglGenerateMipmap(GL_TEXTURE_2D);\n\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);\n\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n\n\tfree(row_pointers);\n fclose(fp);\n\n\treturn result;\n}\n#endif\n\n"}, {"path": "impl/gl_helpers.h", "language": "c", "loc": 134, "comment_density": 0.007, "code": "#pragma once\n\n#define GL_GLEXT_LEGACY\n#include \n#undef GL_VERSION_1_3\n#include \"glext.h\"\n\n#include \"loadgl46.h\"\n\n#include \n// RAII lifetime handlers for GLuint-based buffers and textures; in principle, very close to unique pointers (with GLuint playing the role of a raw pointer).\n\nstruct Buffer {\npublic:\n\tvoid destroy() { if (object != 0 && owning) { glDeleteBuffers(1, &object); object = 0; } }\n\tBuffer() : owning(true) { glCreateBuffers(1, &object); }\n\tBuffer(size_t size, void* data = nullptr, bool immutable = false, GLenum usage_or_flags = GL_STATIC_DRAW) : owning(true) {\n\t\tglCreateBuffers(1, &object);\n\t\tif(immutable)\n\t\t\tglNamedBufferStorage(object, size, data, usage_or_flags);\n\t\telse\n\t\t\tglNamedBufferData(object, size, data, usage_or_flags);\n\t}\n\ttemplate\n\tBuffer(const std::vector& v, bool immutable = false, GLenum usage_or_flags = GL_STATIC_DRAW) : owning(true) {\n\t\tglCreateBuffers(1, &object);\n\t\tif(immutable)\n\t\t\tglNamedBufferStorage(object, v.size()*sizeof(T), v.data(), usage_or_flags);\n\t\telse\n\t\t\tglNamedBufferData(object, v.size()*sizeof(T), v.data(), usage_or_flags);\n\t}\n\ttemplate\n\toperator std::vector() const {\n\t\tGLint64 size;\n\t\tglGetNamedBufferParameteri64v(object, GL_BUFFER_SIZE, &size);\n\t\tif (size % sizeof(T)) printf(\"warning: buffer and vector types don't align\");\n\t\tstd::vector result(size/sizeof(T));\n\t\tglGetNamedBufferSubData(object, 0, result.size()*sizeof(T), result.data());\n\t\treturn result;\n\t}\n\t~Buffer() { destroy(); }\n\tBuffer(const Buffer& other) : object(other.object), owning(false) { }\n\tBuffer(GLuint object, bool owning = false) : object(object), owning(owning) { }\n\tBuffer(Buffer&& other) : object(other.object), owning(other.owning) { other.owning = false; }\n\tauto& operator=(const Buffer& other) { object = other.object; owning = false; return *this; }\n\tauto& operator=(Buffer&& other) { object = other.object; owning = other.owning; other.owning = false; return *this; }\n\toperator GLuint() const { return object; }\n\toperator bool() const { return object != 0; }\nprivate:\n\tGLuint object = 0; bool owning;\n};\n\ntemplate struct Texture;\n\ntemplate<>\nstruct Texture {\npublic:\n\tvoid destroy() {\n\t\tif (handle != 0) glMakeTextureHandleNonResident(handle);\n\t\tif (object && owning) { glDeleteTextures(1, &object); object = 0; }\n\t}\n\tTexture() : object(0), target(GL_INVALID_INDEX) {}\n\tTexture(GLuint target, bool owning = false) : target(target), owning(owning) { glCreateTextures(target, 1, &object); }\n\t~Texture() { if (object != 0 && owning) destroy(); }\n\ttemplate\n\tTexture(const Texture& other) : object(other.object), level(other.level), layer(other.layer), target(other.target), owning(false) { }\n\tTexture(GLuint object, GLuint target, bool owning = false) : object(object), target(target), owning(owning) { }\n\ttemplate\n\tTexture(Texture&& other) : object(other.object), level(other.level), layer(other.layer), target(other.target), owning(other.owning) { other.owning = false; }\n\ttemplate\n\tauto& operator=(const Texture& other) {\n\t\tdestroy();\n\t\tobject = other.object; level = other.level; layer = other.layer; target = other.target;\n\t\towning = false;\n\t\treturn *this;\n\t}\n\ttemplate\n\tauto& operator=(Texture&& other) {\n\t\tdestroy();\n\t\tobject = other.object; level = other.level; layer = other.layer; target = other.target;\n\t\towning = other.owning;\n\t\tother.owning = false;\n\t\treturn *this;\n\t}\n\toperator GLuint() const { return object; }\n\toperator bool() const { return object != 0; }\n\tGLuint level = 0, layer = GL_INVALID_INDEX, target;\n\tGLuint64 getBindless() {\n\t\tif (handle == 0) {\n\t\t\thandle = glGetTextureHandle(object);\n\t\t\tglMakeTextureHandleResident(handle);\n\t\t}\n\t\treturn handle;\n\t}\nprivate:\n\tGLuint object; bool owning; GLuint64 handle = 0;\n};\n\ntemplate\nstruct Texture {\npublic:\n\tvoid destroy() {\n\t\tif (handle != 0) glMakeTextureHandleNonResident(handle);\n\t\tif (object && owning) { glDeleteTextures(1, &object); object = 0; }\n\t}\n\tTexture() : owning(true) { glCreateTextures(T, 1, &object); }\n\t~Texture() { destroy(); }\n\tTexture(GLuint other, bool owning = false) : object(other), owning(owning) {}\n\tTexture(const Texture& other) : object(other.object), owning(false) { }\n\tTexture(Texture&& other) : object(other.object), owning(other.owning) { other.owning = false; }\n\tTexture& operator=(const Texture& other) { destroy(); object = other.object; owning = false; return *this; }\n\tTexture& operator=(Texture&& other) { destroy(); object = other.object; owning = other.owning; other.owning = false; return *this; }\n\toperator GLuint() const { return object; }\n\toperator bool() const { return object != 0; }\n\tstatic constexpr GLuint level = 0, layer = GL_INVALID_INDEX;\n\tfriend Texture<>;\n\tstatic constexpr GLuint target = T;\n\tGLuint64 getBindless() {\n\t\tif (handle == 0) {\n\t\t\thandle = glGetTextureHandle(object);\n\t\t\tglMakeTextureHandleResident(handle);\n\t\t}\n\t\treturn handle;\n\t}\nprivate:\n\tGLuint object = 0; bool owning; GLuint64 handle = 0;\n};\n\ntemplate\nTexture<> Level(const Texture& t, int level) {\n\tTexture<> result(t);\n\tresult.level = level;\n\treturn result;\n}\n\ntemplate\nTexture<> Layer(const Texture& t, int layer) {\n\tTexture<> result(t);\n\tresult.layer = layer;\n\treturn result;\n}\n\nTexture loadImage(const char* path);\nTexture loadImage(const wchar_t* path);\n"}, {"path": "impl/glsl.h", "language": "c", "loc": 1625, "comment_density": 0.003, "code": "#pragma once\n\nnamespace glsl {\n\n template\n constexpr int maximal(I... i) {\n int max = 0;\n ((max = max < i ? i : max), ...);\n return max;\n }\n\n template struct sequence { using type = sequence; };\n\n template struct append;\n template\n struct append, sequence> :\n sequence {};\n\n template\n struct iota : append::type, typename iota::type> {};\n template<> struct iota<0> : sequence<> {};\n template<> struct iota<1> : sequence<0> {};\n\n template struct Matrix;\n\n template\n auto id_ptr(sequence) {\n if constexpr (R == 1 && C == 1) return (F*) nullptr;\n else return (Matrix*) nullptr;\n }\n\n template struct no_ptr_ { using type = F; };\n template struct no_ptr_ { using type = F; };\n template struct no_ptr_ { using type = const F; };\n template using no_ptr = typename no_ptr_::type;\n\n template\n using identity = no_ptr(iota{})) > ;\n\n template struct no_const_ { using type = F; };\n template struct no_const_ { using type = F; };\n template struct no_const_ { using type = F*; };\n template using no_const = typename no_const_::type;\n\n template constexpr bool is_const = false;\n template constexpr bool is_const = true;\n\n template constexpr int Rows = 1;\n template\n constexpr int Rows> = R;\n\n template constexpr int Columns = 1;\n template\n constexpr int Columns> = C;\n\n template struct Field_ { using type = T; };\n template\n struct Field_> { using type = no_ptr; };\n\n template\n using Field = typename Field_::type;\n\n template\n struct enabler {};\n template<>\n struct enabler { using type = bool; };\n template\n using enable = typename enabler::type;\n\n template\n constexpr bool same = false;\n template\n constexpr bool same = true;\n\n\n template\n constexpr bool broadcastable = ((Rows == maximal(Rows...) && Columns == maximal(Columns...) || Rows == 1 && Columns == 1)&&...);\n template\n constexpr bool matmul_broadcastable = Columns == 1 && Rows == Rows || Columns == Rows || broadcastable;\n\n template\n auto broadcast_type(sequence) {\n constexpr int rows = maximal(Rows...), columns = maximal(Columns...);\n auto sum = (Field{} + ...);\n if constexpr (rows == 1 && columns == 1)\n return sum;\n else\n return Matrix {};\n }\n\n template\n using Iota = iota...)* maximal(Columns...)>;\n template\n using Common = decltype(broadcast_type(Iota{}));\n\n template\n auto matmul_type(sequence) {\n auto sum = Field{} + Field{};\n if constexpr (Columns == 1 && Columns == 1)\n return Matrix, Rows), 1, const decltype(sum), I...> {};\n else if constexpr (Columns == 1)\n return Matrix, 1, const decltype(sum), I...> {};\n else if constexpr (Rows == 1 && Columns == 1) return Second{};\n else if constexpr (Rows == 1 && Columns == 1) return First{};\n else\n return Matrix, Columns, const decltype(sum), I...> {};\n }\n\n template\n constexpr int mult_iota_length() {\n if constexpr (Columns == 1 && Columns == 1) return maximal(Rows, Rows);\n else return ((Columns == 1) ? 1 : Rows) * Columns;\n }\n\n template\n using MultCommon = decltype(matmul_type(iota()>{}));\n\n template\n constexpr int ordering(sequence) {\n return int(((int(I) * (int(1) << int((sizeof...(I) - Id) * 4))) + ... + 0));\n }\n\n template\n struct Container {\n Container() = default;\n no_ptr> data[1 + maximal(I...)];\n };\n\n template\n struct Matrix : Container, I...> {\n\n using Container, I...>::data;\n\n static_assert(sizeof...(I) == R * C);\n //static_assert(R* C > 1);\n\n Matrix() = default;\n\n explicit Matrix(const F& f) {\n if constexpr (C == 1 || is_const) ((data[I] = f), ...);\n else {\n F choice[2] = { F(0), f };\n ((data[I] = choice[I % R == I / R]), ...);\n }\n }\n template 1 && C2 > 1) || (R2==1 && C2==1)> >\n explicit Matrix(const Matrix& other) {\n if constexpr (R2 == 1 && C2 == 1) {\n constexpr int i2[] = { I2... };\n const auto f = F(other.data[i2[0]]);\n if constexpr (C == 1 || is_const) ((data[I] = f), ...);\n else {\n F choice[2] = { F(0), f };\n ((data[I] = choice[I % R == I / R]), ...);\n }\n }\n else if constexpr (R == R2 && C == C2) {\n int i2[] = { I2... };\n ((data[I] = F(other.data[i2[I]])), ...);\n }\n else {\n F choice[2] = { 0, 1 };\n // I%R gives the row and I/R the column\n ((data[I] = (I % R < R2&& I / R < C2) ? F(other.data[((I / R) * R2) + (I % R)]) : choice[I % R == I / R]), ...);\n }\n }\n\n template\n void place(const Matrix& m, int& i) {\n ((data[i++] = F(m.data[I2])), ...);\n }\n template\n void place(const F2& m, int& i) {\n data[i++] = F(m);\n }\n template == 1 && Columns == 1 && ((Columns == 1) && ...) && R * C == ((Rows +Rows) + ... + Rows)>>\n Matrix(const First& first, const Second& second, const Rest&... rest) {\n int i = 0;\n place(first, i); place(second, i); (place(rest, i), ...);\n }\n\n template>>\n operator Matrix() const {\n Matrix result;\n ((result.data[I] = no_ptr(data[I])), ...);\n return result;\n }\n\n template\n auto& operator=(const Matrix other) {\n ((data[I] = F(other.data[I2])), ...);\n return *this;\n }\n auto& operator=(const Matrix& other) {\n ((data[I] = other.data[I]), ...);\n return *this;\n }\n\n static constexpr int inds[] = { I... };\n auto& operator[](int i) {\n if constexpr (C == 1) return data[inds[i]];\n else return *reinterpret_cast*>(data + i * R);\n }\n const auto& operator[](int i) const {\n if constexpr (C == 1) return const_cast(data[inds[i]]);\n else return *reinterpret_cast*const>(data + i * R);\n }\n\n auto& operator+=(const identity& other) {return *this = *this + other;}\n auto& operator-=(const identity& other) {return *this = *this - other;}\n auto& operator/=(const identity& other) {return *this = *this / other;}\n auto& operator+=(const F& other) { return *this = *this + other; }\n auto& operator-=(const F& other) { return *this = *this - other; }\n auto& operator/=(const F& other) { return *this = *this / other; }\n template\n auto& operator*=(const Other& other) { return *this = *this * other; }\n };\n\n template\n struct Matrix {\n\n no_const data[1 + maximal(I...)];\n\n template || same < const decltype(F{} + no_ptr{}), const F > ) && (ordering(iota{}) >= ordering(iota{})) >>\n operator Matrix() const {\n Matrixresult;\n ((result.data[I2] = no_ptr(data[I])), ...);\n return result;\n }\n\n template\n auto& operator=(const Matrix other) {\n ((data[I] = F(other.data[I2])), ...);\n return *this;\n }\n auto& operator=(const Matrix& other) {\n ((data[I] = other.data[I]), ...);\n return *this;\n }\n\n auto& operator+=(const identity& other) { return *this = *this + other; }\n auto& operator-=(const identity& other) { return *this = *this - other; }\n auto& operator/=(const identity& other) { return *this = *this / other; }\n auto& operator+=(const F& other) { return *this = *this + other; }\n auto& operator-=(const F& other) { return *this = *this - other; }\n auto& operator/=(const F& other) { return *this = *this / other; }\n template\n auto& operator*=(const Other& other) { return *this = *this * other; }\n };\n\n template\n struct Matrix {\n\n F data[1 + maximal(I...)];\n\n template || same < const decltype(F{} + no_ptr{}), const F > ) && (ordering(iota{}) >= ordering(iota{})) >>\n operator Matrix() const {\n Matrix result;\n ((result.data[I2] = no_ptr(data[I])), ...);\n return result;\n }\n template\n operator Matrix, I2...>() const {\n Matrix, I2...> result;\n ((result.data[I2] = no_ptr(data[I])), ...);\n return result;\n }\n };\n\n template\n struct Matrix<1, 1, F*, I> {\n\n no_const data[1 + I];\n auto* operator&() {\n return &data[I];\n }\n auto& operator=(const F& other) {\n data[I] = other;\n return *this;\n }\n operator F& () { return data[I]; }\n operator F() const { return data[I]; }\n };\n\n template\n struct Matrix<1, 1, const F*, I> {\n F data[1 + I];\n operator F() const { return data[I]; }\n };\n\n\n template\n struct Container<2, 1, F, 0, 1> {\n Container() = default;\n union {\n no_ptr> data[2];\n\n Matrix<1, 1, no_ptr*, 0> x, r, s;\n Matrix<1, 1, no_ptr*, 1> y, g, t;\n\n Matrix<2, 1, const no_ptr*, 0, 0> xx, rr, ss;\n Matrix<2, 1, no_ptr*, 0, 1> xy, rg, st;\n Matrix<2, 1, no_ptr*, 1, 0> yx, gr, ts;\n Matrix<2, 1, const no_ptr*, 1, 1> yy, gg, tt;\n\n Matrix<3, 1, const no_ptr*, 0, 0, 0> xxx, rrr, sss;\n Matrix<3, 1, const no_ptr*, 0, 0, 1> xxy, rrg, sst;\n Matrix<3, 1, const no_ptr*, 0, 1, 0> xyx, rgr, sts;\n Matrix<3, 1, const no_ptr*, 0, 1, 1> xyy, rgg, stt;\n Matrix<3, 1, const no_ptr*, 1, 0, 0> yxx, grr, tss;\n Matrix<3, 1, const no_ptr*, 1, 0, 1> yxy, grg, tst;\n Matrix<3, 1, const no_ptr*, 1, 1, 0> yyx, ggr, tts;\n Matrix<3, 1, const no_ptr*, 1, 1, 1> yyy, ggg, ttt;\n\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 0> xxxx, rrrr, ssss;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 1> xxxy, rrrg, ssst;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 0> xxyx, rrgr, ssts;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 1> xxyy, rrgg, sstt;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 0> xyxx, rgrr, stss;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 1> xyxy, rgrg, stst;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 0> xyyx, rggr, stts;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 1> xyyy, rggg, sttt;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 0> yxxx, grrr, tsss;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 1> yxxy, grrg, tsst;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 0> yxyx, grgr, tsts;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 1> yxyy, grgg, tstt;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 0> yyxx, ggrr, ttss;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 1> yyxy, ggrg, ttst;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 0> yyyx, gggr, ttts;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 1> yyyy, gggg, tttt;\n };\n };\n\n template\n struct Container<3, 1, F, 0, 1, 2> {\n Container() = default;\n union {\n no_ptr> data[3];\n\n Matrix<1, 1, no_ptr*, 0> x, r, s;\n Matrix<1, 1, no_ptr*, 1> y, g, t;\n Matrix<1, 1, no_ptr*, 2> z, b, p;\n\n Matrix<2, 1, const no_ptr*, 0, 0> xx, rr, ss;\n Matrix<2, 1, no_ptr*, 0, 1> xy, rg, st;\n Matrix<2, 1, no_ptr*, 0, 2> xz, rb, sp;\n Matrix<2, 1, no_ptr*, 1, 0> yx, gr, ts;\n Matrix<2, 1, const no_ptr*, 1, 1> yy, gg, tt;\n Matrix<2, 1, no_ptr*, 1, 2> yz, gb, tp;\n Matrix<2, 1, no_ptr*, 2, 0> zx, br, ps;\n Matrix<2, 1, no_ptr*, 2, 1> zy, bg, pt;\n Matrix<2, 1, const no_ptr*, 2, 2> zz, bb, pp;\n\n Matrix<3, 1, const no_ptr*, 0, 0, 0> xxx, rrr, sss;\n Matrix<3, 1, const no_ptr*, 0, 0, 1> xxy, rrg, sst;\n Matrix<3, 1, const no_ptr*, 0, 0, 2> xxz, rrb, ssp;\n Matrix<3, 1, const no_ptr*, 0, 1, 0> xyx, rgr, sts;\n Matrix<3, 1, const no_ptr*, 0, 1, 1> xyy, rgg, stt;\n Matrix<3, 1, no_ptr*, 0, 1, 2> xyz, rgb, stp;\n Matrix<3, 1, const no_ptr*, 0, 2, 0> xzx, rbr, sps;\n Matrix<3, 1, no_ptr*, 0, 2, 1> xzy, rbg, spt;\n Matrix<3, 1, const no_ptr*, 0, 2, 2> xzz, rbb, spp;\n Matrix<3, 1, const no_ptr*, 1, 0, 0> yxx, grr, tss;\n Matrix<3, 1, const no_ptr*, 1, 0, 1> yxy, grg, tst;\n Matrix<3, 1, no_ptr*, 1, 0, 2> yxz, grb, tsp;\n Matrix<3, 1, const no_ptr*, 1, 1, 0> yyx, ggr, tts;\n Matrix<3, 1, const no_ptr*, 1, 1, 1> yyy, ggg, ttt;\n Matrix<3, 1, const no_ptr*, 1, 1, 2> yyz, ggb, ttp;\n Matrix<3, 1, no_ptr*, 1, 2, 0> yzx, gbr, tps;\n Matrix<3, 1, const no_ptr*, 1, 2, 1> yzy, gbg, tpt;\n Matrix<3, 1, const no_ptr*, 1, 2, 2> yzz, gbb, tpp;\n Matrix<3, 1, const no_ptr*, 2, 0, 0> zxx, brr, pss;\n Matrix<3, 1, no_ptr*, 2, 0, 1> zxy, brg, pst;\n Matrix<3, 1, const no_ptr*, 2, 0, 2> zxz, brb, psp;\n Matrix<3, 1, no_ptr*, 2, 1, 0> zyx, bgr, pts;\n Matrix<3, 1, const no_ptr*, 2, 1, 1> zyy, bgg, ptt;\n Matrix<3, 1, const no_ptr*, 2, 1, 2> zyz, bgb, ptp;\n Matrix<3, 1, const no_ptr*, 2, 2, 0> zzx, bbr, pps;\n Matrix<3, 1, const no_ptr*, 2, 2, 1> zzy, bbg, ppt;\n Matrix<3, 1, const no_ptr*, 2, 2, 2> zzz, bbb, ppp;\n\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 0> xxxx, rrrr, ssss;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 1> xxxy, rrrg, ssst;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 2> xxxz, rrrb, sssp;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 0> xxyx, rrgr, ssts;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 1> xxyy, rrgg, sstt;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 2> xxyz, rrgb, sstp;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 0> xxzx, rrbr, ssps;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 1> xxzy, rrbg, sspt;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 2> xxzz, rrbb, sspp;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 0> xyxx, rgrr, stss;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 1> xyxy, rgrg, stst;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 2> xyxz, rgrb, stsp;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 0> xyyx, rggr, stts;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 1> xyyy, rggg, sttt;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 2> xyyz, rggb, sttp;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 0> xyzx, rgbr, stps;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 1> xyzy, rgbg, stpt;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 2> xyzz, rgbb, stpp;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 0> xzxx, rbrr, spss;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 1> xzxy, rbrg, spst;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 2> xzxz, rbrb, spsp;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 0> xzyx, rbgr, spts;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 1> xzyy, rbgg, sptt;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 2> xzyz, rbgb, sptp;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 0> xzzx, rbbr, spps;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 1> xzzy, rbbg, sppt;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 2> xzzz, rbbb, sppp;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 0> yxxx, grrr, tsss;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 1> yxxy, grrg, tsst;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 2> yxxz, grrb, tssp;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 0> yxyx, grgr, tsts;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 1> yxyy, grgg, tstt;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 2> yxyz, grgb, tstp;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 0> yxzx, grbr, tsps;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 1> yxzy, grbg, tspt;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 2> yxzz, grbb, tspp;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 0> yyxx, ggrr, ttss;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 1> yyxy, ggrg, ttst;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 2> yyxz, ggrb, ttsp;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 0> yyyx, gggr, ttts;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 1> yyyy, gggg, tttt;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 2> yyyz, gggb, tttp;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 0> yyzx, ggbr, ttps;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 1> yyzy, ggbg, ttpt;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 2> yyzz, ggbb, ttpp;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 0> yzxx, gbrr, tpss;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 1> yzxy, gbrg, tpst;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 2> yzxz, gbrb, tpsp;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 0> yzyx, gbgr, tpts;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 1> yzyy, gbgg, tptt;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 2> yzyz, gbgb, tptp;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 0> yzzx, gbbr, tpps;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 1> yzzy, gbbg, tppt;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 2> yzzz, gbbb, tppp;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 0> zxxx, brrr, psss;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 1> zxxy, brrg, psst;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 2> zxxz, brrb, pssp;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 0> zxyx, brgr, psts;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 1> zxyy, brgg, pstt;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 2> zxyz, brgb, pstp;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 0> zxzx, brbr, psps;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 1> zxzy, brbg, pspt;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 2> zxzz, brbb, pspp;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 0> zyxx, bgrr, ptss;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 1> zyxy, bgrg, ptst;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 2> zyxz, bgrb, ptsp;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 0> zyyx, bggr, ptts;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 1> zyyy, bggg, pttt;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 2> zyyz, bggb, pttp;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 0> zyzx, bgbr, ptps;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 1> zyzy, bgbg, ptpt;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 2> zyzz, bgbb, ptpp;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 0> zzxx, bbrr, ppss;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 1> zzxy, bbrg, ppst;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 2> zzxz, bbrb, ppsp;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 0> zzyx, bbgr, ppts;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 1> zzyy, bbgg, pptt;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 2> zzyz, bbgb, pptp;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 0> zzzx, bbbr, ppps;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 1> zzzy, bbbg, pppt;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 2> zzzz, bbbb, pppp;\n };\n };\n template\n struct Container<4, 1, F, 0, 1, 2, 3> {\n Container() = default;\n union {\n no_ptr> data[4];\n\n Matrix<1, 1, no_ptr*, 0> x, r, s;\n Matrix<1, 1, no_ptr*, 1> y, g, t;\n Matrix<1, 1, no_ptr*, 2> z, b, p;\n Matrix<1, 1, no_ptr*, 3> w, a, q;\n\n Matrix<2, 1, const no_ptr*, 0, 0> xx, rr, ss;\n Matrix<2, 1, no_ptr*, 0, 1> xy, rg, st;\n Matrix<2, 1, no_ptr*, 0, 2> xz, rb, sp;\n Matrix<2, 1, no_ptr*, 0, 3> xw, ra, sq;\n Matrix<2, 1, no_ptr*, 1, 0> yx, gr, ts;\n Matrix<2, 1, const no_ptr*, 1, 1> yy, gg, tt;\n Matrix<2, 1, no_ptr*, 1, 2> yz, gb, tp;\n Matrix<2, 1, no_ptr*, 1, 3> yw, ga, tq;\n Matrix<2, 1, no_ptr*, 2, 0> zx, br, ps;\n Matrix<2, 1, no_ptr*, 2, 1> zy, bg, pt;\n Matrix<2, 1, const no_ptr*, 2, 2> zz, bb, pp;\n Matrix<2, 1, no_ptr*, 2, 3> zw, ba, pq;\n Matrix<2, 1, no_ptr*, 3, 0> wx, ar, qs;\n Matrix<2, 1, no_ptr*, 3, 1> wy, ag, qt;\n Matrix<2, 1, no_ptr*, 3, 2> wz, ab, qp;\n Matrix<2, 1, const no_ptr*, 3, 3> ww, aa, qq;\n\n Matrix<3, 1, const no_ptr*, 0, 0, 0> xxx, rrr, sss;\n Matrix<3, 1, const no_ptr*, 0, 0, 1> xxy, rrg, sst;\n Matrix<3, 1, const no_ptr*, 0, 0, 2> xxz, rrb, ssp;\n Matrix<3, 1, const no_ptr*, 0, 0, 3> xxw, rra, ssq;\n Matrix<3, 1, const no_ptr*, 0, 1, 0> xyx, rgr, sts;\n Matrix<3, 1, const no_ptr*, 0, 1, 1> xyy, rgg, stt;\n Matrix<3, 1, no_ptr*, 0, 1, 2> xyz, rgb, stp;\n Matrix<3, 1, no_ptr*, 0, 1, 3> xyw, rga, stq;\n Matrix<3, 1, const no_ptr*, 0, 2, 0> xzx, rbr, sps;\n Matrix<3, 1, no_ptr*, 0, 2, 1> xzy, rbg, spt;\n Matrix<3, 1, const no_ptr*, 0, 2, 2> xzz, rbb, spp;\n Matrix<3, 1, no_ptr*, 0, 2, 3> xzw, rba, spq;\n Matrix<3, 1, const no_ptr*, 0, 3, 0> xwx, rar, sqs;\n Matrix<3, 1, no_ptr*, 0, 3, 1> xwy, rag, sqt;\n Matrix<3, 1, no_ptr*, 0, 3, 2> xwz, rab, sqp;\n Matrix<3, 1, const no_ptr*, 0, 3, 3> xww, raa, sqq;\n Matrix<3, 1, const no_ptr*, 1, 0, 0> yxx, grr, tss;\n Matrix<3, 1, const no_ptr*, 1, 0, 1> yxy, grg, tst;\n Matrix<3, 1, no_ptr*, 1, 0, 2> yxz, grb, tsp;\n Matrix<3, 1, no_ptr*, 1, 0, 3> yxw, gra, tsq;\n Matrix<3, 1, const no_ptr*, 1, 1, 0> yyx, ggr, tts;\n Matrix<3, 1, const no_ptr*, 1, 1, 1> yyy, ggg, ttt;\n Matrix<3, 1, const no_ptr*, 1, 1, 2> yyz, ggb, ttp;\n Matrix<3, 1, const no_ptr*, 1, 1, 3> yyw, gga, ttq;\n Matrix<3, 1, no_ptr*, 1, 2, 0> yzx, gbr, tps;\n Matrix<3, 1, const no_ptr*, 1, 2, 1> yzy, gbg, tpt;\n Matrix<3, 1, const no_ptr*, 1, 2, 2> yzz, gbb, tpp;\n Matrix<3, 1, no_ptr*, 1, 2, 3> yzw, gba, tpq;\n Matrix<3, 1, no_ptr*, 1, 3, 0> ywx, gar, tqs;\n Matrix<3, 1, const no_ptr*, 1, 3, 1> ywy, gag, tqt;\n Matrix<3, 1, no_ptr*, 1, 3, 2> ywz, gab, tqp;\n Matrix<3, 1, const no_ptr*, 1, 3, 3> yww, gaa, tqq;\n Matrix<3, 1, const no_ptr*, 2, 0, 0> zxx, brr, pss;\n Matrix<3, 1, no_ptr*, 2, 0, 1> zxy, brg, pst;\n Matrix<3, 1, const no_ptr*, 2, 0, 2> zxz, brb, psp;\n Matrix<3, 1, no_ptr*, 2, 0, 3> zxw, bra, psq;\n Matrix<3, 1, no_ptr*, 2, 1, 0> zyx, bgr, pts;\n Matrix<3, 1, const no_ptr*, 2, 1, 1> zyy, bgg, ptt;\n Matrix<3, 1, const no_ptr*, 2, 1, 2> zyz, bgb, ptp;\n Matrix<3, 1, no_ptr*, 2, 1, 3> zyw, bga, ptq;\n Matrix<3, 1, const no_ptr*, 2, 2, 0> zzx, bbr, pps;\n Matrix<3, 1, const no_ptr*, 2, 2, 1> zzy, bbg, ppt;\n Matrix<3, 1, const no_ptr*, 2, 2, 2> zzz, bbb, ppp;\n Matrix<3, 1, const no_ptr*, 2, 2, 3> zzw, bba, ppq;\n Matrix<3, 1, no_ptr*, 2, 3, 0> zwx, bar, pqs;\n Matrix<3, 1, no_ptr*, 2, 3, 1> zwy, bag, pqt;\n Matrix<3, 1, const no_ptr*, 2, 3, 2> zwz, bab, pqp;\n Matrix<3, 1, const no_ptr*, 2, 3, 3> zww, baa, pqq;\n Matrix<3, 1, const no_ptr*, 3, 0, 0> wxx, arr, qss;\n Matrix<3, 1, no_ptr*, 3, 0, 1> wxy, arg, qst;\n Matrix<3, 1, no_ptr*, 3, 0, 2> wxz, arb, qsp;\n Matrix<3, 1, const no_ptr*, 3, 0, 3> wxw, ara, qsq;\n Matrix<3, 1, no_ptr*, 3, 1, 0> wyx, agr, qts;\n Matrix<3, 1, const no_ptr*, 3, 1, 1> wyy, agg, qtt;\n Matrix<3, 1, no_ptr*, 3, 1, 2> wyz, agb, qtp;\n Matrix<3, 1, const no_ptr*, 3, 1, 3> wyw, aga, qtq;\n Matrix<3, 1, no_ptr*, 3, 2, 0> wzx, abr, qps;\n Matrix<3, 1, no_ptr*, 3, 2, 1> wzy, abg, qpt;\n Matrix<3, 1, const no_ptr*, 3, 2, 2> wzz, abb, qpp;\n Matrix<3, 1, const no_ptr*, 3, 2, 3> wzw, aba, qpq;\n Matrix<3, 1, const no_ptr*, 3, 3, 0> wwx, aar, qqs;\n Matrix<3, 1, const no_ptr*, 3, 3, 1> wwy, aag, qqt;\n Matrix<3, 1, const no_ptr*, 3, 3, 2> wwz, aab, qqp;\n Matrix<3, 1, const no_ptr*, 3, 3, 3> www, aaa, qqq;\n\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 0> xxxx, rrrr, ssss;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 1> xxxy, rrrg, ssst;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 2> xxxz, rrrb, sssp;\n Matrix<4, 1, const no_ptr*, 0, 0, 0, 3> xxxw, rrra, sssq;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 0> xxyx, rrgr, ssts;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 1> xxyy, rrgg, sstt;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 2> xxyz, rrgb, sstp;\n Matrix<4, 1, const no_ptr*, 0, 0, 1, 3> xxyw, rrga, sstq;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 0> xxzx, rrbr, ssps;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 1> xxzy, rrbg, sspt;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 2> xxzz, rrbb, sspp;\n Matrix<4, 1, const no_ptr*, 0, 0, 2, 3> xxzw, rrba, sspq;\n Matrix<4, 1, const no_ptr*, 0, 0, 3, 0> xxwx, rrar, ssqs;\n Matrix<4, 1, const no_ptr*, 0, 0, 3, 1> xxwy, rrag, ssqt;\n Matrix<4, 1, const no_ptr*, 0, 0, 3, 2> xxwz, rrab, ssqp;\n Matrix<4, 1, const no_ptr*, 0, 0, 3, 3> xxww, rraa, ssqq;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 0> xyxx, rgrr, stss;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 1> xyxy, rgrg, stst;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 2> xyxz, rgrb, stsp;\n Matrix<4, 1, const no_ptr*, 0, 1, 0, 3> xyxw, rgra, stsq;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 0> xyyx, rggr, stts;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 1> xyyy, rggg, sttt;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 2> xyyz, rggb, sttp;\n Matrix<4, 1, const no_ptr*, 0, 1, 1, 3> xyyw, rgga, sttq;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 0> xyzx, rgbr, stps;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 1> xyzy, rgbg, stpt;\n Matrix<4, 1, const no_ptr*, 0, 1, 2, 2> xyzz, rgbb, stpp;\n Matrix<4, 1, no_ptr*, 0, 1, 2, 3> xyzw, rgba, stpq;\n Matrix<4, 1, const no_ptr*, 0, 1, 3, 0> xywx, rgar, stqs;\n Matrix<4, 1, const no_ptr*, 0, 1, 3, 1> xywy, rgag, stqt;\n Matrix<4, 1, no_ptr*, 0, 1, 3, 2> xywz, rgab, stqp;\n Matrix<4, 1, const no_ptr*, 0, 1, 3, 3> xyww, rgaa, stqq;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 0> xzxx, rbrr, spss;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 1> xzxy, rbrg, spst;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 2> xzxz, rbrb, spsp;\n Matrix<4, 1, const no_ptr*, 0, 2, 0, 3> xzxw, rbra, spsq;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 0> xzyx, rbgr, spts;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 1> xzyy, rbgg, sptt;\n Matrix<4, 1, const no_ptr*, 0, 2, 1, 2> xzyz, rbgb, sptp;\n Matrix<4, 1, no_ptr*, 0, 2, 1, 3> xzyw, rbga, sptq;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 0> xzzx, rbbr, spps;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 1> xzzy, rbbg, sppt;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 2> xzzz, rbbb, sppp;\n Matrix<4, 1, const no_ptr*, 0, 2, 2, 3> xzzw, rbba, sppq;\n Matrix<4, 1, const no_ptr*, 0, 2, 3, 0> xzwx, rbar, spqs;\n Matrix<4, 1, no_ptr*, 0, 2, 3, 1> xzwy, rbag, spqt;\n Matrix<4, 1, const no_ptr*, 0, 2, 3, 2> xzwz, rbab, spqp;\n Matrix<4, 1, const no_ptr*, 0, 2, 3, 3> xzww, rbaa, spqq;\n Matrix<4, 1, const no_ptr*, 0, 3, 0, 0> xwxx, rarr, sqss;\n Matrix<4, 1, const no_ptr*, 0, 3, 0, 1> xwxy, rarg, sqst;\n Matrix<4, 1, const no_ptr*, 0, 3, 0, 2> xwxz, rarb, sqsp;\n Matrix<4, 1, const no_ptr*, 0, 3, 0, 3> xwxw, rara, sqsq;\n Matrix<4, 1, const no_ptr*, 0, 3, 1, 0> xwyx, ragr, sqts;\n Matrix<4, 1, const no_ptr*, 0, 3, 1, 1> xwyy, ragg, sqtt;\n Matrix<4, 1, no_ptr*, 0, 3, 1, 2> xwyz, ragb, sqtp;\n Matrix<4, 1, const no_ptr*, 0, 3, 1, 3> xwyw, raga, sqtq;\n Matrix<4, 1, const no_ptr*, 0, 3, 2, 0> xwzx, rabr, sqps;\n Matrix<4, 1, no_ptr*, 0, 3, 2, 1> xwzy, rabg, sqpt;\n Matrix<4, 1, const no_ptr*, 0, 3, 2, 2> xwzz, rabb, sqpp;\n Matrix<4, 1, const no_ptr*, 0, 3, 2, 3> xwzw, raba, sqpq;\n Matrix<4, 1, const no_ptr*, 0, 3, 3, 0> xwwx, raar, sqqs;\n Matrix<4, 1, const no_ptr*, 0, 3, 3, 1> xwwy, raag, sqqt;\n Matrix<4, 1, const no_ptr*, 0, 3, 3, 2> xwwz, raab, sqqp;\n Matrix<4, 1, const no_ptr*, 0, 3, 3, 3> xwww, raaa, sqqq;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 0> yxxx, grrr, tsss;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 1> yxxy, grrg, tsst;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 2> yxxz, grrb, tssp;\n Matrix<4, 1, const no_ptr*, 1, 0, 0, 3> yxxw, grra, tssq;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 0> yxyx, grgr, tsts;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 1> yxyy, grgg, tstt;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 2> yxyz, grgb, tstp;\n Matrix<4, 1, const no_ptr*, 1, 0, 1, 3> yxyw, grga, tstq;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 0> yxzx, grbr, tsps;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 1> yxzy, grbg, tspt;\n Matrix<4, 1, const no_ptr*, 1, 0, 2, 2> yxzz, grbb, tspp;\n Matrix<4, 1, no_ptr*, 1, 0, 2, 3> yxzw, grba, tspq;\n Matrix<4, 1, const no_ptr*, 1, 0, 3, 0> yxwx, grar, tsqs;\n Matrix<4, 1, const no_ptr*, 1, 0, 3, 1> yxwy, grag, tsqt;\n Matrix<4, 1, no_ptr*, 1, 0, 3, 2> yxwz, grab, tsqp;\n Matrix<4, 1, const no_ptr*, 1, 0, 3, 3> yxww, graa, tsqq;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 0> yyxx, ggrr, ttss;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 1> yyxy, ggrg, ttst;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 2> yyxz, ggrb, ttsp;\n Matrix<4, 1, const no_ptr*, 1, 1, 0, 3> yyxw, ggra, ttsq;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 0> yyyx, gggr, ttts;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 1> yyyy, gggg, tttt;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 2> yyyz, gggb, tttp;\n Matrix<4, 1, const no_ptr*, 1, 1, 1, 3> yyyw, ggga, tttq;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 0> yyzx, ggbr, ttps;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 1> yyzy, ggbg, ttpt;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 2> yyzz, ggbb, ttpp;\n Matrix<4, 1, const no_ptr*, 1, 1, 2, 3> yyzw, ggba, ttpq;\n Matrix<4, 1, const no_ptr*, 1, 1, 3, 0> yywx, ggar, ttqs;\n Matrix<4, 1, const no_ptr*, 1, 1, 3, 1> yywy, ggag, ttqt;\n Matrix<4, 1, const no_ptr*, 1, 1, 3, 2> yywz, ggab, ttqp;\n Matrix<4, 1, const no_ptr*, 1, 1, 3, 3> yyww, ggaa, ttqq;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 0> yzxx, gbrr, tpss;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 1> yzxy, gbrg, tpst;\n Matrix<4, 1, const no_ptr*, 1, 2, 0, 2> yzxz, gbrb, tpsp;\n Matrix<4, 1, no_ptr*, 1, 2, 0, 3> yzxw, gbra, tpsq;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 0> yzyx, gbgr, tpts;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 1> yzyy, gbgg, tptt;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 2> yzyz, gbgb, tptp;\n Matrix<4, 1, const no_ptr*, 1, 2, 1, 3> yzyw, gbga, tptq;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 0> yzzx, gbbr, tpps;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 1> yzzy, gbbg, tppt;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 2> yzzz, gbbb, tppp;\n Matrix<4, 1, const no_ptr*, 1, 2, 2, 3> yzzw, gbba, tppq;\n Matrix<4, 1, no_ptr*, 1, 2, 3, 0> yzwx, gbar, tpqs;\n Matrix<4, 1, const no_ptr*, 1, 2, 3, 1> yzwy, gbag, tpqt;\n Matrix<4, 1, const no_ptr*, 1, 2, 3, 2> yzwz, gbab, tpqp;\n Matrix<4, 1, const no_ptr*, 1, 2, 3, 3> yzww, gbaa, tpqq;\n Matrix<4, 1, const no_ptr*, 1, 3, 0, 0> ywxx, garr, tqss;\n Matrix<4, 1, const no_ptr*, 1, 3, 0, 1> ywxy, garg, tqst;\n Matrix<4, 1, no_ptr*, 1, 3, 0, 2> ywxz, garb, tqsp;\n Matrix<4, 1, const no_ptr*, 1, 3, 0, 3> ywxw, gara, tqsq;\n Matrix<4, 1, const no_ptr*, 1, 3, 1, 0> ywyx, gagr, tqts;\n Matrix<4, 1, const no_ptr*, 1, 3, 1, 1> ywyy, gagg, tqtt;\n Matrix<4, 1, const no_ptr*, 1, 3, 1, 2> ywyz, gagb, tqtp;\n Matrix<4, 1, const no_ptr*, 1, 3, 1, 3> ywyw, gaga, tqtq;\n Matrix<4, 1, no_ptr*, 1, 3, 2, 0> ywzx, gabr, tqps;\n Matrix<4, 1, const no_ptr*, 1, 3, 2, 1> ywzy, gabg, tqpt;\n Matrix<4, 1, const no_ptr*, 1, 3, 2, 2> ywzz, gabb, tqpp;\n Matrix<4, 1, const no_ptr*, 1, 3, 2, 3> ywzw, gaba, tqpq;\n Matrix<4, 1, const no_ptr*, 1, 3, 3, 0> ywwx, gaar, tqqs;\n Matrix<4, 1, const no_ptr*, 1, 3, 3, 1> ywwy, gaag, tqqt;\n Matrix<4, 1, const no_ptr*, 1, 3, 3, 2> ywwz, gaab, tqqp;\n Matrix<4, 1, const no_ptr*, 1, 3, 3, 3> ywww, gaaa, tqqq;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 0> zxxx, brrr, psss;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 1> zxxy, brrg, psst;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 2> zxxz, brrb, pssp;\n Matrix<4, 1, const no_ptr*, 2, 0, 0, 3> zxxw, brra, pssq;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 0> zxyx, brgr, psts;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 1> zxyy, brgg, pstt;\n Matrix<4, 1, const no_ptr*, 2, 0, 1, 2> zxyz, brgb, pstp;\n Matrix<4, 1, no_ptr*, 2, 0, 1, 3> zxyw, brga, pstq;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 0> zxzx, brbr, psps;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 1> zxzy, brbg, pspt;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 2> zxzz, brbb, pspp;\n Matrix<4, 1, const no_ptr*, 2, 0, 2, 3> zxzw, brba, pspq;\n Matrix<4, 1, const no_ptr*, 2, 0, 3, 0> zxwx, brar, psqs;\n Matrix<4, 1, no_ptr*, 2, 0, 3, 1> zxwy, brag, psqt;\n Matrix<4, 1, const no_ptr*, 2, 0, 3, 2> zxwz, brab, psqp;\n Matrix<4, 1, const no_ptr*, 2, 0, 3, 3> zxww, braa, psqq;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 0> zyxx, bgrr, ptss;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 1> zyxy, bgrg, ptst;\n Matrix<4, 1, const no_ptr*, 2, 1, 0, 2> zyxz, bgrb, ptsp;\n Matrix<4, 1, no_ptr*, 2, 1, 0, 3> zyxw, bgra, ptsq;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 0> zyyx, bggr, ptts;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 1> zyyy, bggg, pttt;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 2> zyyz, bggb, pttp;\n Matrix<4, 1, const no_ptr*, 2, 1, 1, 3> zyyw, bgga, pttq;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 0> zyzx, bgbr, ptps;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 1> zyzy, bgbg, ptpt;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 2> zyzz, bgbb, ptpp;\n Matrix<4, 1, const no_ptr*, 2, 1, 2, 3> zyzw, bgba, ptpq;\n Matrix<4, 1, no_ptr*, 2, 1, 3, 0> zywx, bgar, ptqs;\n Matrix<4, 1, const no_ptr*, 2, 1, 3, 1> zywy, bgag, ptqt;\n Matrix<4, 1, const no_ptr*, 2, 1, 3, 2> zywz, bgab, ptqp;\n Matrix<4, 1, const no_ptr*, 2, 1, 3, 3> zyww, bgaa, ptqq;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 0> zzxx, bbrr, ppss;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 1> zzxy, bbrg, ppst;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 2> zzxz, bbrb, ppsp;\n Matrix<4, 1, const no_ptr*, 2, 2, 0, 3> zzxw, bbra, ppsq;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 0> zzyx, bbgr, ppts;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 1> zzyy, bbgg, pptt;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 2> zzyz, bbgb, pptp;\n Matrix<4, 1, const no_ptr*, 2, 2, 1, 3> zzyw, bbga, pptq;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 0> zzzx, bbbr, ppps;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 1> zzzy, bbbg, pppt;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 2> zzzz, bbbb, pppp;\n Matrix<4, 1, const no_ptr*, 2, 2, 2, 3> zzzw, bbba, pppq;\n Matrix<4, 1, const no_ptr*, 2, 2, 3, 0> zzwx, bbar, ppqs;\n Matrix<4, 1, const no_ptr*, 2, 2, 3, 1> zzwy, bbag, ppqt;\n Matrix<4, 1, const no_ptr*, 2, 2, 3, 2> zzwz, bbab, ppqp;\n Matrix<4, 1, const no_ptr*, 2, 2, 3, 3> zzww, bbaa, ppqq;\n Matrix<4, 1, const no_ptr*, 2, 3, 0, 0> zwxx, barr, pqss;\n Matrix<4, 1, no_ptr*, 2, 3, 0, 1> zwxy, barg, pqst;\n Matrix<4, 1, const no_ptr*, 2, 3, 0, 2> zwxz, barb, pqsp;\n Matrix<4, 1, const no_ptr*, 2, 3, 0, 3> zwxw, bara, pqsq;\n Matrix<4, 1, no_ptr*, 2, 3, 1, 0> zwyx, bagr, pqts;\n Matrix<4, 1, const no_ptr*, 2, 3, 1, 1> zwyy, bagg, pqtt;\n Matrix<4, 1, const no_ptr*, 2, 3, 1, 2> zwyz, bagb, pqtp;\n Matrix<4, 1, const no_ptr*, 2, 3, 1, 3> zwyw, baga, pqtq;\n Matrix<4, 1, const no_ptr*, 2, 3, 2, 0> zwzx, babr, pqps;\n Matrix<4, 1, const no_ptr*, 2, 3, 2, 1> zwzy, babg, pqpt;\n Matrix<4, 1, const no_ptr*, 2, 3, 2, 2> zwzz, babb, pqpp;\n Matrix<4, 1, const no_ptr*, 2, 3, 2, 3> zwzw, baba, pqpq;\n Matrix<4, 1, const no_ptr*, 2, 3, 3, 0> zwwx, baar, pqqs;\n Matrix<4, 1, const no_ptr*, 2, 3, 3, 1> zwwy, baag, pqqt;\n Matrix<4, 1, const no_ptr*, 2, 3, 3, 2> zwwz, baab, pqqp;\n Matrix<4, 1, const no_ptr*, 2, 3, 3, 3> zwww, baaa, pqqq;\n Matrix<4, 1, const no_ptr*, 3, 0, 0, 0> wxxx, arrr, qsss;\n Matrix<4, 1, const no_ptr*, 3, 0, 0, 1> wxxy, arrg, qsst;\n Matrix<4, 1, const no_ptr*, 3, 0, 0, 2> wxxz, arrb, qssp;\n Matrix<4, 1, const no_ptr*, 3, 0, 0, 3> wxxw, arra, qssq;\n Matrix<4, 1, const no_ptr*, 3, 0, 1, 0> wxyx, argr, qsts;\n Matrix<4, 1, const no_ptr*, 3, 0, 1, 1> wxyy, argg, qstt;\n Matrix<4, 1, no_ptr*, 3, 0, 1, 2> wxyz, argb, qstp;\n Matrix<4, 1, const no_ptr*, 3, 0, 1, 3> wxyw, arga, qstq;\n Matrix<4, 1, const no_ptr*, 3, 0, 2, 0> wxzx, arbr, qsps;\n Matrix<4, 1, no_ptr*, 3, 0, 2, 1> wxzy, arbg, qspt;\n Matrix<4, 1, const no_ptr*, 3, 0, 2, 2> wxzz, arbb, qspp;\n Matrix<4, 1, const no_ptr*, 3, 0, 2, 3> wxzw, arba, qspq;\n Matrix<4, 1, const no_ptr*, 3, 0, 3, 0> wxwx, arar, qsqs;\n Matrix<4, 1, const no_ptr*, 3, 0, 3, 1> wxwy, arag, qsqt;\n Matrix<4, 1, const no_ptr*, 3, 0, 3, 2> wxwz, arab, qsqp;\n Matrix<4, 1, const no_ptr*, 3, 0, 3, 3> wxww, araa, qsqq;\n Matrix<4, 1, const no_ptr*, 3, 1, 0, 0> wyxx, agrr, qtss;\n Matrix<4, 1, const no_ptr*, 3, 1, 0, 1> wyxy, agrg, qtst;\n Matrix<4, 1, no_ptr*, 3, 1, 0, 2> wyxz, agrb, qtsp;\n Matrix<4, 1, const no_ptr*, 3, 1, 0, 3> wyxw, agra, qtsq;\n Matrix<4, 1, const no_ptr*, 3, 1, 1, 0> wyyx, aggr, qtts;\n Matrix<4, 1, const no_ptr*, 3, 1, 1, 1> wyyy, aggg, qttt;\n Matrix<4, 1, const no_ptr*, 3, 1, 1, 2> wyyz, aggb, qttp;\n Matrix<4, 1, const no_ptr*, 3, 1, 1, 3> wyyw, agga, qttq;\n Matrix<4, 1, no_ptr*, 3, 1, 2, 0> wyzx, agbr, qtps;\n Matrix<4, 1, const no_ptr*, 3, 1, 2, 1> wyzy, agbg, qtpt;\n Matrix<4, 1, const no_ptr*, 3, 1, 2, 2> wyzz, agbb, qtpp;\n Matrix<4, 1, const no_ptr*, 3, 1, 2, 3> wyzw, agba, qtpq;\n Matrix<4, 1, const no_ptr*, 3, 1, 3, 0> wywx, agar, qtqs;\n Matrix<4, 1, const no_ptr*, 3, 1, 3, 1> wywy, agag, qtqt;\n Matrix<4, 1, const no_ptr*, 3, 1, 3, 2> wywz, agab, qtqp;\n Matrix<4, 1, const no_ptr*, 3, 1, 3, 3> wyww, agaa, qtqq;\n Matrix<4, 1, const no_ptr*, 3, 2, 0, 0> wzxx, abrr, qpss;\n Matrix<4, 1, no_ptr*, 3, 2, 0, 1> wzxy, abrg, qpst;\n Matrix<4, 1, const no_ptr*, 3, 2, 0, 2> wzxz, abrb, qpsp;\n Matrix<4, 1, const no_ptr*, 3, 2, 0, 3> wzxw, abra, qpsq;\n Matrix<4, 1, no_ptr*, 3, 2, 1, 0> wzyx, abgr, qpts;\n Matrix<4, 1, const no_ptr*, 3, 2, 1, 1> wzyy, abgg, qptt;\n Matrix<4, 1, const no_ptr*, 3, 2, 1, 2> wzyz, abgb, qptp;\n Matrix<4, 1, const no_ptr*, 3, 2, 1, 3> wzyw, abga, qptq;\n Matrix<4, 1, const no_ptr*, 3, 2, 2, 0> wzzx, abbr, qpps;\n Matrix<4, 1, const no_ptr*, 3, 2, 2, 1> wzzy, abbg, qppt;\n Matrix<4, 1, const no_ptr*, 3, 2, 2, 2> wzzz, abbb, qppp;\n Matrix<4, 1, const no_ptr*, 3, 2, 2, 3> wzzw, abba, qppq;\n Matrix<4, 1, const no_ptr*, 3, 2, 3, 0> wzwx, abar, qpqs;\n Matrix<4, 1, const no_ptr*, 3, 2, 3, 1> wzwy, abag, qpqt;\n Matrix<4, 1, const no_ptr*, 3, 2, 3, 2> wzwz, abab, qpqp;\n Matrix<4, 1, const no_ptr*, 3, 2, 3, 3> wzww, abaa, qpqq;\n Matrix<4, 1, const no_ptr*, 3, 3, 0, 0> wwxx, aarr, qqss;\n Matrix<4, 1, const no_ptr*, 3, 3, 0, 1> wwxy, aarg, qqst;\n Matrix<4, 1, const no_ptr*, 3, 3, 0, 2> wwxz, aarb, qqsp;\n Matrix<4, 1, const no_ptr*, 3, 3, 0, 3> wwxw, aara, qqsq;\n Matrix<4, 1, const no_ptr*, 3, 3, 1, 0> wwyx, aagr, qqts;\n Matrix<4, 1, const no_ptr*, 3, 3, 1, 1> wwyy, aagg, qqtt;\n Matrix<4, 1, const no_ptr*, 3, 3, 1, 2> wwyz, aagb, qqtp;\n Matrix<4, 1, const no_ptr*, 3, 3, 1, 3> wwyw, aaga, qqtq;\n Matrix<4, 1, const no_ptr*, 3, 3, 2, 0> wwzx, aabr, qqps;\n Matrix<4, 1, const no_ptr*, 3, 3, 2, 1> wwzy, aabg, qqpt;\n Matrix<4, 1, const no_ptr*, 3, 3, 2, 2> wwzz, aabb, qqpp;\n Matrix<4, 1, const no_ptr*, 3, 3, 2, 3> wwzw, aaba, qqpq;\n Matrix<4, 1, const no_ptr*, 3, 3, 3, 0> wwwx, aaar, qqqs;\n Matrix<4, 1, const no_ptr*, 3, 3, 3, 1> wwwy, aaag, qqqt;\n Matrix<4, 1, const no_ptr*, 3, 3, 3, 2> wwwz, aaab, qqqp;\n Matrix<4, 1, const no_ptr*, 3, 3, 3, 3> wwww, aaaa, qqqq;\n };\n };\n}\n\nusing uint = unsigned;\n\n#ifndef UINT64_C\nusing int64_t = long long;\nusing uint64_t = unsigned long long;\n#endif\n\nusing ivec2 = glsl::Matrix<2, 1, int, 0, 1>;\nusing ivec3 = glsl::Matrix<3, 1, int, 0, 1, 2>;\nusing ivec4 = glsl::Matrix<4, 1, int, 0, 1, 2, 3>;\n\nusing uvec2 = glsl::Matrix<2, 1, uint, 0, 1>;\nusing uvec3 = glsl::Matrix<3, 1, uint, 0, 1, 2>;\nusing uvec4 = glsl::Matrix<4, 1, uint, 0, 1, 2, 3>;\n\nusing i64vec2 = glsl::Matrix<2, 1, int64_t, 0, 1>;\nusing i64vec3 = glsl::Matrix<3, 1, int64_t, 0, 1, 2>;\nusing i64vec4 = glsl::Matrix<4, 1, int64_t, 0, 1, 2, 3>;\n\nusing u64vec2 = glsl::Matrix<2, 1, uint64_t, 0, 1>;\nusing u64vec3 = glsl::Matrix<3, 1, uint64_t, 0, 1, 2>;\nusing u64vec4 = glsl::Matrix<4, 1, uint64_t, 0, 1, 2, 3>;\n\nusing bvec2 = glsl::Matrix<2, 1, bool, 0, 1>;\nusing bvec3 = glsl::Matrix<3, 1, bool, 0, 1, 2>;\nusing bvec4 = glsl::Matrix<4, 1, bool, 0, 1, 2, 3>;\n\nusing vec2 = glsl::Matrix<2, 1, float, 0, 1>;\nusing vec3 = glsl::Matrix<3, 1, float, 0, 1, 2>;\nusing vec4 = glsl::Matrix<4, 1, float, 0, 1, 2, 3>;\n\nusing dvec2 = glsl::Matrix<2, 1, double, 0, 1>;\nusing dvec3 = glsl::Matrix<3, 1, double, 0, 1, 2>;\nusing dvec4 = glsl::Matrix<4, 1, double, 0, 1, 2, 3>;\n\nusing mat2x2 = glsl::Matrix<2, 2, float, 0, 1, 2, 3>;\nusing mat2x3 = glsl::Matrix<3, 2, float, 0, 1, 2, 3, 4, 5>;\nusing mat2x4 = glsl::Matrix<4, 2, float, 0, 1, 2, 3, 4, 5, 6, 7>;\n\nusing mat3x2 = glsl::Matrix<2, 3, float, 0, 1, 2, 3, 4, 5>;\nusing mat3x3 = glsl::Matrix<3, 3, float, 0, 1, 2, 3, 4, 5, 6, 7, 8>;\nusing mat3x4 = glsl::Matrix<4, 3, float, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;\n\nusing mat4x2 = glsl::Matrix<2, 4, float, 0, 1, 2, 3, 4, 5, 6, 7>;\nusing mat4x3 = glsl::Matrix<3, 4, float, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;\nusing mat4x4 = glsl::Matrix<4, 4, float, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15>;\n\nusing mat2 = mat2x2;\nusing mat3 = mat3x3;\nusing mat4 = mat4x4;\n\nusing dmat2x2 = glsl::Matrix<2, 2, double, 0, 1, 2, 3>;\nusing dmat2x3 = glsl::Matrix<3, 2, double, 0, 1, 2, 3, 4, 5>;\nusing dmat2x4 = glsl::Matrix<4, 2, double, 0, 1, 2, 3, 4, 5, 6, 7>;\n\nusing dmat3x2 = glsl::Matrix<2, 3, double, 0, 1, 2, 3, 4, 5>;\nusing dmat3x3 = glsl::Matrix<3, 3, double, 0, 1, 2, 3, 4, 5, 6, 7, 8>;\nusing dmat3x4 = glsl::Matrix<4, 3, double, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;\n\nusing dmat4x2 = glsl::Matrix<2, 4, double, 0, 1, 2, 3, 4, 5, 6, 7>;\nusing dmat4x3 = glsl::Matrix<3, 4, double, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;\nusing dmat4x4 = glsl::Matrix<4, 4, double, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15>;\n\nusing dmat2 = dmat2x2;\nusing dmat3 = dmat3x3;\nusing dmat4 = dmat4x4;\n\n#include \n#include \n\nnamespace glsl {\n\n template\n inline auto sum(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a + b;\n else return M(a.data[I] + b.data[I] ...);\n }\n template\n inline auto sub(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a - b;\n else return M(a.data[I] - b.data[I] ...);\n }\n template\n inline auto neg(const M& a, sequence) {\n if constexpr (sizeof...(I) == 1) return -a;\n else return M(-a.data[I] ...);\n }\n template\n inline auto div(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a / b;\n else return M(a.data[I] / b.data[I] ...);\n }\n template\n constexpr bool integral = same || same || same || same;\n template\n constexpr bool moddable = integral && integral;\n\n template\n inline auto mod(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a % b;\n else return M(a.data[I] % b.data[I] ...);\n }\n template\n inline auto bin_neg(const M& a, sequence) {\n if constexpr (sizeof...(I) == 1) return -a;\n else return M(~a.data[I] ...);\n }\n template\n inline auto lshift(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a << b;\n else return M(a.data[I] << b.data[I] ...);\n }\n template\n inline auto rshift(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a >> b;\n else return M(a.data[I] >> b.data[I] ...);\n }\n template\n inline auto and_(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a & b;\n else return M(a.data[I] & b.data[I] ...);\n }\n template\n inline auto or_(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a | b;\n else return M(a.data[I] | b.data[I] ...);\n }\n template\n inline auto xor_(const M & a, const M & b, sequence) {\n if constexpr (sizeof...(I) == 1) return a ^ b;\n else return M(a.data[I] ^ b.data[I] ...);\n }\n template\n inline bool equals(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a == b;\n else return ((a.data[I] == b.data[I]) && ...);\n }\n template\n inline auto mul(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return a * b;\n else return M(a.data[I] * b.data[I] ...);\n }\n template\n inline auto matmul(const M1& a, const M2& b, sequence, sequence, MultCommon result = {}) {\n int i;\n if constexpr (Columns == 1) return ((i = I, result.data[i] = ((a.data[K] * b.data[K + (i / Columns>) * Rows]) + ...)), ..., result);\n else {\n constexpr int result_rows = Rows>;\n return ((i = I, result.data[i] = ((a.data[(i % result_rows) + K * Rows] * b.data[K + (i / result_rows) * Rows]) + ...)), ..., result);\n }\n }\n template\n inline auto maximum(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return (a > b) ? a : b;\n else return M((a.data[I] > b.data[I]) ? a.data[I] : b.data[I] ...);\n }\n template\n inline auto mininum(const M& a, const M& b, sequence) {\n if constexpr (sizeof...(I) == 1) return (a < b) ? a : b;\n else return M((a.data[I] < b.data[I]) ? a.data[I] : b.data[I] ...);\n }\n template\n inline auto absolute(const M& x, sequence) {\n constexpr Field zero(0);\n if constexpr (sizeof...(I) == 1) return (x < zero) ? -x : x;\n else return M((x.data[I] < zero) ? -x.data[I] : x.data[I] ...);\n }\n\n template\n auto lt(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] < b.data[I]) ...);\n }\n template\n auto lte(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] <= b.data[I]) ...);\n }\n template\n auto gt(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] > b.data[I]) ...);\n }\n template\n auto gte(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] >= b.data[I]) ...);\n }\n template\n auto eq(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] == b.data[I]) ...);\n }\n template\n auto neq(const M& a, const M& b, sequence) {\n return Matrix, 1, bool, I...>((a.data[I] != b.data[I]) ...);\n }\n\n template\n auto not_(const M& x, sequence) {\n return M(!x.data[I]...);\n }\n template\n auto isnan(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::isnan(x);\n else return Matrix, Columns, bool, I...>(std::isnan(x.data[I])...);\n }\n template\n auto isinf(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::isinf(x);\n else return Matrix, Columns, bool, I...>(std::isinf(x.data[I])...);\n }\n\n template\n inline auto ceiling(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::ceil(float(x));\n else return M(std::ceil(float(x.data[I])) ...);\n }\n template\n inline auto flooring(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::floor(float(x));\n else return M(std::floor(float(x.data[I])) ...);\n }\n template\n inline auto fraction(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return x - std::floor(float(x));\n else return M(x.data[I] - std::floor(float(x.data[I])) ...);\n }\n template\n inline auto rounder(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::round(float(x));\n else return M(std::round(x.data[I]) ...);\n }\n template\n inline auto modulus(const M& x, const M& y, sequence) {\n if constexpr (sizeof...(I) == 1) return x - y * std::floor(float(x / y));\n else return M(x.data[I] - y.data[I] * std::floor(float(x.data[I] / y.data[I])) ...);\n }\n template\n inline auto power(const M& x, const M& y, sequence) {\n if constexpr (sizeof...(I) == 1) return std::pow(float(x), float(y));\n else return M(std::pow(float(x.data[I]), float(y.data[I])) ...);\n }\n template\n inline auto clamper(const M& x, const M& v, const M& V, sequence) {\n if constexpr (sizeof...(I) == 1) return (x < v) ? v : ((x > V) ? V : x);\n else return M((x.data[I] < v.data[I]) ? v.data[I] : ((x.data[I] > V.data[I]) ? V.data[I] : x.data[I]) ...);\n }\n template\n inline auto mixer(const M& x, const M& y, const M& a, sequence) {\n if constexpr (sizeof...(I) == 1) return x * (1 - a) + y * a;\n else return M(x.data[I] * (1 - a.data[I]) + y.data[I] * a.data[I] ...);\n }\n template\n inline auto smoothstepper(const M& e0, const M& e1, const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) {\n M t = (x - e0) / (e1 - e0);\n t = t < 0 ? 0 : (t > 1 ? 1 : t);\n return t * t * (3 - 2 * t);\n }\n else {\n M t;\n ((t.data[I] = (x.data[I] - e0.data[I]) / (e1.data[I] - e0.data[I])), ...);\n ((t.data[I] = t.data[I] < 0 ? 0 : (t.data[I] > 1 ? 1 : t.data[I])), ...);\n return M(t.data[I] * t.data[I] * (3 - 2 * t.data[I]) ...);\n }\n }\n template\n inline auto stepper(const M& edge, const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return x < edge ? 0 : 1;\n else return M(x.data[I] < edge.data[I] ? 0 : 1 ...);\n }\n template\n inline auto sine(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::sin(x);\n else return M(std::sin(x.data[I]) ...);\n }\n template\n inline auto arcussine(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::asin(x);\n else return M(std::asin(x.data[I]) ...);\n }\n template\n inline auto cosine(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::cos(x);\n else return M(std::cos(x.data[I]) ...);\n }\n template\n inline auto arcuscosine(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::acos(x);\n else return M(std::acos(x.data[I]) ...);\n }\n template\n inline auto tangent(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::tan(x);\n else return M(std::tan(x.data[I]) ...);\n }\n template\n inline auto arcustangent(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::atan(x);\n else return M(std::tan(x.data[I]) ...);\n }\n template\n inline auto arcustangent(const M& y, const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::atan2(y, x);\n else return M(std::atan2(y.data[I], x.data[I]) ...);\n }\n template\n inline auto to_degrees(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return x * 180.f / 3.14159265358979f;\n else return M(x.data[I] * 180.f / 3.14159265358979f ...);\n }\n template\n inline auto to_radians(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return x * 3.14159265358979f / 180.f;\n else return M(x.data[I] * 3.14159265358979f / 180.f ...);\n }\n\n template\n inline auto dotter(const M& x, const M& y, sequence) {\n if constexpr (sizeof...(I) == 1) return x * y;\n else return ((x.data[I] * y.data[I]) + ...);\n }\n template\n inline auto len(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::fabs(x);\n else return std::sqrt(((x.data[I] * x.data[I]) + ...));\n }\n template\n inline auto square_root(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::sqrt(x);\n else return M(std::sqrt(x.data[I]) ...);\n }\n template\n inline auto exper(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::exp(x);\n else return M(std::exp(x.data[I]) ...);\n }\n template\n inline auto exp2er(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::exp2(x);\n else return M(std::exp2f(x.data[I]) ...);\n }\n template\n inline auto loger(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::log(x);\n else return M(std::log(x.data[I]) ...);\n }\n template\n inline auto log2er(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return std::log2(x);\n else return M(std::log2(x.data[I]) ...);\n }\n template\n inline auto signum(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) return M((x < 0) ? (-1) : ((x > 0) ? 1 : 0));\n else return M((x.data[I] < 0) ? (-1) : ((x.data[I] > 0) ? 1 : 0) ...);\n }\n template\n inline auto cast(const M& x, sequence) {\n if constexpr (sizeof...(I) == 1) {\n F result; memcpy(&result, &x, sizeof(F));\n return result;\n }\n else {\n identity, Columns, F> result;\n memcpy(result.data, x.data, sizeof(F) * sizeof...(I));\n return result;\n }\n }\n template\n inline auto outer(const M1& c, const M2& r, sequence) {\n constexpr int R1 = Rows, R2 = Rows;\n return identity((c[I/R1]*r[I%R1]) ...);\n }\n\n template > 1 || Rows > 1) && broadcastable> >\n inline Common operator+(const genType& x, const genType_& y) {\n return sum(Common(x), Common(y), Iota{});\n }\n\n template > 1 || Rows > 1) && broadcastable> >\n inline Common operator-(const genType& x, const genType_& y) {\n return sub(Common(x), Common(y), Iota{});\n }\n\n template > 1)>>\n inline auto operator-(const genType& x) {\n return neg(identity, Columns, Field>(x), iota* Columns>{});\n }\n\n template > 1 || Rows > 1) && broadcastable> >\n inline Common operator/(const genType& x, const genType_& y) {\n return div(Common(x), Common(y), Iota{});\n }\n\n template > 1 || Rows > 1) && broadcastable && moddable, Field>> >\n inline auto operator%(const genType& x, const genType_& y) {\n return mod(Common(x), Common(y), Iota{});\n }\n template > 1) && integral>>>\n inline auto operator~(const genType& x) {\n return bin_neg(identity, Columns, Field>(x), iota* Columns>{});\n }\n template > 1 || Rows > 1) && broadcastable&& moddable, Field>> >\n inline auto operator<<(const genType& x, const genType_& y) {\n return lshift(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable&& moddable, Field>> >\n inline auto operator>>(const genType& x, const genType_& y) {\n return rshift(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable&& moddable, Field>> >\n inline auto operator&(const genType& x, const genType_& y) {\n return and_(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable&& moddable, Field>> >\n inline auto operator|(const genType& x, const genType_& y) {\n return or_(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable&& moddable, Field>> >\n inline auto operator^(const genType& x, const genType_& y) {\n return xor_(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable>>\n inline bool operator==(const genType& x, const genType_& y) {\n return equals(Common(x), Common(y), Iota{});\n }\n template > 1 || Rows > 1) && broadcastable>>\n inline auto operator!=(const genType& x, const genType_& y) {\n return !equals(Common(x), Common(y), Iota{});\n }\n\n template > 1 || Rows > 1) && matmul_broadcastable>>\n inline MultCommon operator*(const genType& x, const genType_& y) {\n if constexpr (Columns == 1 && Columns == 1 || (Rows == 1 && Columns == 1 || Rows == 1 && Columns == 1))\n return mul(Common(x), Common(y), Iota{});\n else\n return matmul(\n identity, Columns, Field>(x),\n identity, Columns, Field>(y),\n iota()>{},\n iota>{});\n }\n}\n\ntemplate > 1 && glsl::Rows > 1) && glsl::Columns == 1 && glsl::Columns == 1>>\ninline auto outerProduct(const genType& c, const genType_& r) {\n return glsl::outer(c, r, glsl::iota< glsl::Rows* glsl::Rows>{});\n}\n\ntemplate\ninline bool any(const glsl::Matrix& x) {\n return (x.data[I] || ...);\n}\ntemplate\ninline bool all(const glsl::Matrix& x) {\n return (x.data[I] && ...);\n}\ntemplate\ninline glsl::Matrix not_(const glsl::Matrix& x) {\n return glsl::not_(x, glsl::iota{});\n}\n\n//#define not not_ // gcc doesn't enjoy this; glsl code should just use not_ then I guess\n\ntemplate && glsl::same, const glsl::Field>>>\nauto lessThan(const genType& x, const genType_& y) {\n return glsl::lt(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\ntemplate&& glsl::same, const glsl::Field>>>\nauto lessThanEqual(const genType& x, const genType_& y) {\n return glsl::lte(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\ntemplate&& glsl::same, const glsl::Field>>>\nauto greaterThan(const genType& x, const genType_& y) {\n return glsl::gt(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\ntemplate&& glsl::same, const glsl::Field>>>\nauto greaterThanEqual(const genType& x, const genType_& y) {\n return glsl::gte(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\ntemplate&& glsl::same, const glsl::Field>>>\nauto equal(const genType& x, const genType_& y) {\n return glsl::eq(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\ntemplate&& glsl::same, const glsl::Field>>>\nauto notEqual(const genType& x, const genType_& y) {\n return glsl::neq(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\ntemplate\ninline auto isnan_(const genType& x) {\n return glsl::isnan(glsl::Common(x), glsl::Iota{});\n}\ntemplate\ninline auto isinf_(const genType& x) {\n return glsl::isinf(glsl::Common(x), glsl::Iota{});\n}\n#define isnan isnan_\n#define isinf isinf_\n\ntemplate> >\ninline auto max(const genType& x, const genType_& y) {\n return glsl::maximum(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\ntemplate> >\ninline auto min(const genType& x, const genType_& y) {\n return glsl::mininum(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\ntemplate\ninline auto abs(const genType& x) {\n return glsl::absolute(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto ceil(const genType& x) {\n return glsl::ceiling(glsl::Common(x), glsl::Iota{});\n}\ntemplate\ninline auto floor(const genType& x) {\n return glsl::flooring(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto fract(const genType& x) {\n return glsl::fraction(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto round(const genType& x) {\n return glsl::rounder(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate>>\ninline auto mod(const genType& x, const genType_& y) {\n return glsl::modulus(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\ntemplate || (glsl::same && glsl::same)) && glsl::Rows == glsl::Rows&& glsl::broadcastable>>\ninline auto pow(const genType& x, const genType_& y) {\n return glsl::power(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\n\ntemplate>>\ninline auto clamp(const genType& x, const genType_& minVal, const genType__& maxVal) {\n return glsl::clamper(glsl::Common(x), glsl::Common(minVal), glsl::Common(maxVal), glsl::Iota{});\n}\n\ntemplate>>\ninline auto mix(const genType& x, const genType_& y, const genType__& a) {\n return glsl::mixer(glsl::Common(x), glsl::Common(y), glsl::Common(a), glsl::Iota{});\n}\n\n\ntemplate>>\ninline auto smoothstep(const genType& edge0, const genType_& edge1, const genType__& x) {\n return glsl::smoothstepper(glsl::Common(edge0), glsl::Common(edge1), glsl::Common(x), glsl::Iota{});\n}\ntemplate>>\ninline auto step(const genType& edge, const genType_& x) {\n return glsl::stepper(glsl::Common(edge), glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto sin(const genType& angle) {\n return glsl::sine(glsl::Common(angle), glsl::Iota{});\n}\n\ntemplate\ninline auto asin(const genType& angle) {\n return glsl::arcussine(glsl::Common(angle), glsl::Iota{});\n}\n\ntemplate\ninline auto cos(const genType& angle) {\n return glsl::cosine(glsl::Common(angle), glsl::Iota{});\n}\n\ntemplate\ninline auto acos(const genType& angle) {\n return glsl::arcuscosine(glsl::Common(angle), glsl::Iota{});\n}\n\ntemplate\ninline auto tan(const genType& angle) {\n return glsl::tangent(glsl::Common(angle), glsl::Iota{});\n}\n\ntemplate\ninline auto atan(const genType& y_over_x) {\n return glsl::arcustangent(glsl::Common(y_over_x), glsl::Iota{});\n}\n\ntemplate>>\ninline auto atan(const genType& y, const genType_& x) {\n return glsl::arcustangent(glsl::Common(y), glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto degrees(const genType& radians) {\n return glsl::to_degrees(glsl::Common(radians), glsl::Iota{});\n}\n\ntemplate\ninline auto radians(const genType& degrees) {\n return glsl::to_radians(glsl::Common(degrees), glsl::Iota{});\n}\n\ninline vec3 cross(const vec3& x, const vec3& y) {\n return vec3(x.y * y.z - y.y * x.z, x.z * y.x - y.z * x.x, x.x * y.y - y.x * x.y);\n}\n\ninline float determinant(mat2 m) {\n return m[0][0] * m[1][1] - m[0][1] * m[1][0];\n}\ninline float determinant(mat3 m) {\n return m[0][0] * determinant(mat2(m[1].yz, m[2].yz))\n - m[1][0] * determinant(mat2(m[0].yz, m[2].yz))\n + m[2][0] * determinant(mat2(m[0].yz, m[1].yz));\n}\ninline float determinant(mat4 m) {\n return m[0][0] * determinant(mat3(m[1].yzw, m[2].yzw, m[3].yzw))\n - m[1][0] * determinant(mat3(m[0].yzw, m[2].yzw, m[3].yzw))\n + m[2][0] * determinant(mat3(m[0].yzw, m[1].yzw, m[3].yzw))\n - m[3][0] * determinant(mat3(m[0].yzw, m[1].yzw, m[2].yzw));\n}\n\ninline mat2 inverse(mat2 m) {\n return mat2(m[1][1], -m[0][1], -m[1][0], m[0][0]) / (m[0][0] * m[1][1] - m[0][1] * m[1][0]);\n}\nnamespace glsl {\n inline vec2 givens_rotation(float f, float g) {\n bool swap = false;\n if (abs(f) < abs(g)) {\n float tmp = f;\n f = g;\n g = tmp;\n swap = true;\n }\n if (g == .0f)\n return vec2(copysignf(1.f, f), .0f);\n else {\n float t = g / f, u = copysignf(1.f, f) * sqrtf(1.f + t * t);\n vec2 result = vec2(1.f, t) / u;\n if (swap)\n result = result.yx;\n return result;\n }\n }\n}\ninline mat3 inverse(mat3 m) {\n mat3 result(1.f), rhs(1.f);\n for (int c = 0; c < 2; ++c) {\n for (int r = 2; r > c; --r) {\n mat3 rot(1.f);\n vec2 cs = glsl::givens_rotation(m[c][c], m[c][r]);\n rot[c][c] = rot[r][r] = cs.x;\n rot[c][r] = -(rot[r][c] = cs.y);\n m = rot * m;\n rhs = rot * rhs;\n }\n }\n for (int i = 0; i < 3; ++i) {\n result[i].z = rhs[i].z / m[2].z;\n rhs[i].xy -= result[i].z * m[2].xy;\n result[i].y = rhs[i].y / m[1].y;\n rhs[i].x -= result[i].y * m[1].x;\n result[i].x = rhs[i].x / m[0].x;\n }\n return result;\n}\ninline mat4 inverse(mat4 m) {\n mat4 result(1.f), rhs(1.f);\n for (int c = 0; c < 3; ++c) {\n for (int r = 3; r > c; --r) {\n mat4 rot(1.f);\n vec2 cs = glsl::givens_rotation(m[c][c], m[c][r]);\n rot[c][c] = rot[r][r] = cs.x;\n rot[c][r] = -(rot[r][c] = cs.y);\n m = rot * m;\n rhs = rot * rhs;\n }\n }\n for (int i = 0; i < 4; ++i) {\n result[i].w = rhs[i].w / m[3].w;\n rhs[i].xyz -= result[i].w * m[3].xyz;\n result[i].z = rhs[i].z / m[2].z;\n rhs[i].xy -= result[i].z * m[2].xy;\n result[i].y = rhs[i].y / m[1].y;\n rhs[i].x -= result[i].y * m[1].x;\n result[i].x = rhs[i].x / m[0].x;\n }\n return result;\n}\n\ntemplate1)>>\n glsl::Matrix transpose(const glsl::Matrix& m) {\n glsl::Matrix result;\n ((result.data[I/R+(I%R)*C] = m.data[I]), ...);\n return result;\n}\n\n\ntemplate>>\ninline auto dot(const genType& x, const genType_& y) {\n return glsl::dotter(glsl::Common(x), glsl::Common(y), glsl::Iota{});\n}\n\ntemplate\ninline auto length(const genType& x) {\n return glsl::len(glsl::Common(x), glsl::Iota{});\n}\ntemplate>>\ninline auto distance(const genType& x, const genType_& y) {\n return glsl::len(glsl::Common(x-y), glsl::Iota{});\n}\ntemplate\ninline auto normalize(const genType& x) {\n return x / glsl::len(x, glsl::Iota{});\n}\n\ntemplate\ninline auto sqrt(const genType& x) {\n return glsl::square_root(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto exp(const genType& x) {\n return glsl::exper(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto exp2(const genType& x) {\n return glsl::exp2er(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto log(const genType& x) {\n return glsl::loger(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto log2(const genType& x) {\n return glsl::log2er(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto sign(const genType& x) {\n return glsl::signum(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate\ninline auto reflect(const genType& I, const genType_& N) {\n return I - 2 * dot(N, I) * N;\n}\n\ntemplate\ninline auto refract(const genType& I, const genType_& N, float eta) {\n glsl::Common R(.0f);\n float k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));\n if (k > 0.0)\n R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;\n return R;\n}\n\ntemplate, float>>>\ninline auto floatBitsToInt(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, float>>>\ninline auto floatBitsToUint(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, int>>>\ninline auto intBitsToFloat(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, uint>>>\ninline auto uintBitsToFloat(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\n\ntemplate, double>>>\ninline auto doubleBitsToInt(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, double>>>\ninline auto doubleBitsToUint(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, int64_t>>>\ninline auto int64BitsToDouble(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\ntemplate, uint64_t>>>\ninline auto uint64BitsToDouble(const genType& x) {\n return glsl::cast(glsl::Common(x), glsl::Iota{});\n}\n\ninline int64_t packInt2x32(ivec2 v) { return int64_t(v.y) << 32 | v.x; }\ninline uint64_t packUint2x32(uvec2 v) { return uint64_t(v.y) << 32 | v.x; }\n\ninline ivec2 unpackInt2x32(int64_t v) { return ivec2(v, v>>32); }\ninline uvec2 unpackUint2x32(uint64_t v) { return uvec2(v, v >> 32); }\n\ninline int atomicAdd(int& mem, int data) { return 0; }\ninline uint atomicAdd(uint& mem, uint data) { return 0u; }\ninline int64_t atomicAdd(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicAdd(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicAnd(int& mem, int data) { return 0; }\ninline uint atomicAnd(uint& mem, uint data) { return 0u; }\ninline int64_t atomicAnd(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicAnd(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicCompSwap(int& mem, int comp, int data) { return 0; }\ninline uint atomicCompSwap(uint& mem, uint comp, uint data) { return 0u; }\ninline int64_t atomicCompSwap(int64_t& mem, int64_t comp, int64_t data) { return 0; }\ninline uint64_t atomicCompSwap(uint64_t& mem, uint64_t comp, uint64_t data) { return 0; }\n\ninline int atomicExchange(int& mem, int data) { return 0; }\ninline uint atomicExchange(uint& mem, uint data) { return 0u; }\ninline int64_t atomicExchange(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicExchange(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicMax(int& mem, int data) { return 0; }\ninline uint atomicMax(uint& mem, uint data) { return 0u; }\ninline int64_t atomicMax(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicMax(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicMin(int& mem, int data) { return 0; }\ninline uint atomicMin(uint& mem, uint data) { return 0u; }\ninline int64_t atomicMin(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicMin(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicOr(int& mem, int data) { return 0; }\ninline uint atomicOr(uint& mem, uint data) { return 0u; }\ninline int64_t atomicOr(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicOr(uint64_t& mem, uint64_t data) { return 0; }\n\ninline int atomicXor(int& mem, int data) { return 0; }\ninline uint atomicXor(uint& mem, uint data) { return 0u; }\ninline int64_t atomicXor(int64_t& mem, int64_t data) { return 0; }\ninline uint64_t atomicXor(uint64_t& mem, uint64_t data) { return 0; }\n\ninline void barrier() {}\ninline void groupMemoryBarrier() {}\ninline void memoryBarrier() {}\ninline void memoryBarrierAtomicCounter() {}\ninline void memoryBarrierBuffer() {}\ninline void memoryBarrierImage() {}\ninline void memoryBarrierShared() {}\n\ninline const uvec3 gl_GlobalInvocationID = {};\ninline const uvec3 gl_LocalInvocationID = {};\ninline const uvec3 gl_WorkGroupSize = { 1, 1, 1 };\ninline const uvec3 gl_WorkGroupID = {};\ninline const uvec3 gl_NumWorkGroups = { 1, 1, 1 };\ninline const uint gl_LocalInvocationIndex = 0u;\n\ninline const vec4 gl_FragCoord = {};\ninline const vec2 gl_PointCoord = {};\ninline int gl_ViewportIndex;\ninline const int gl_VertexID = 0;\ninline const int gl_InstanceID = 0;\ninline const int gl_InvocationID = 0;\ninline int gl_PrimitiveIDIn;\ninline const int gl_PrimitiveID = 0;\ninline const int gl_PatchVerticesIn = 0;\ninline const int gl_Layer = 0;\n\ninline const vec3 gl_TessCoord = {};\ninline float gl_TessLevelInner[2];\ninline float gl_TessLevelOuter[4];\n\ninline const bool gl_FrontFacing = true;\ninline const bool gl_HelperInvocation = false;\n\ninline vec4 gl_Position;\ninline float gl_PointSize;\ninline float gl_FragDepth;\ninline float gl_ClipDistance[1];\ninline float gl_CullDistance[1];\nstruct gl_PerVertex\n{\n vec4 gl_Position;\n float gl_PointSize;\n float gl_ClipDistance[1];\n} inline gl_in[1];\n\ninline const int gl_NumSamples = 1;\ninline const int gl_SampleID = 0;\ninline int gl_SampleMask[1];\ninline const int gl_SampleMaskIn[1] = { 0 };\ninline const vec2 gl_SamplePosition = {};\n\ntemplate genType dFdx(genType p) { return p; }\ntemplate genType dFdy(genType p) { return p; }\ntemplate genType dFdxCoarse(genType p) { return p; }\ntemplate genType dFdyCoarse(genType p) { return p; }\ntemplate genType dFdxFine(genType p) { return p; }\ntemplate genType dFdyFine(genType p) { return p; }\ntemplate genType fwidth(genType p) { return p; }\ntemplate genType fwidthCoarse(genType p) { return p; }\ntemplate genType fwidthFine(genType p) { return p; }\n\n// subgroup extension: see https://www.khronos.org/blog/vulkan-subgroup-tutorial\n\ninline const uint gl_NumSubgroups = 1, gl_SubgroupID = 0, gl_SubgroupSize = 128, gl_SubgroupInvocationID = 0;\ninline const uvec4 gl_SubgroupEqMask{ 0 }, gl_SubgroupGeMask{ 0 }, gl_SubgroupGtMask{ 0 }, gl_SubgroupLeMask{ 0 }, gl_SubgroupLtMask{ 0 };\ninline void subgroupBarrier() {}\ninline void subgroupMemoryBarrier() {}\ninline void subgroupMemoryBarrierBuffer() {}\ninline void subgroupMemoryBarrierShared() {}\ninline void subgroupMemoryBarrierImage() {}\ninline bool subgroupElect() { return false; }\n\ninline bool subgroupAll(bool value) { return value; }\ninline bool subgroupAny(bool value) { return value; }\ntemplate bool subgroupAllEqual(T value) { (void)value; return false; }\n\ntemplate T subgroupBroadcast(T value, uint id) { (void)id; return value; }\ntemplate T subgroupBroadcastFirst(T value) { return value; }\ninline uvec4 subgroupBallot(bool value) { (void)value; return uvec4(0); }\ninline bool subgroupInverseBallot(uvec4 value) { (void)value; return false; }\ninline bool subgroupBallotBitExtract(uvec4 value, uint index) { (void)value; (void)index; return false; }\ninline uint subgroupBallotBitCount(uvec4 value) { (void)value; return 0; }\ninline uint subgroupBallotInclusiveBitCount(uvec4 value) { (void)value; return 0; }\ninline uint subgroupBallotExclusiveBitCount(uvec4 value) { (void)value; return 0; }\ninline uint subgroupBallotFindLSB(uvec4 value) { (void)value; return 0; }\ninline uint subgroupBallotFindMSB(uvec4 value) { (void)value; return 0; }\n\ntemplate T subgroupAdd(T value) { return value; }\ntemplate T subgroupMul(T value) { return value; }\ntemplate T subgroupMin(T value) { return value; }\ntemplate T subgroupMax(T value) { return value; }\ntemplate T subgroupAnd(T value) { return value; }\ntemplate T subgroupOr(T value) { return value; }\ntemplate T subgroupXor(T value) { return value; }\n\ntemplate T subgroupInclusiveAdd(T value) { return value; }\ntemplate T subgroupInclusiveMul(T value) { return value; }\ntemplate T subgroupInclusiveMin(T value) { return value; }\ntemplate T subgroupInclusiveMax(T value) { return value; }\ntemplate T subgroupInclusiveAnd(T value) { return value; }\ntemplate T subgroupInclusiveOr(T value) { return value; }\ntemplate T subgroupInclusiveXor(T value) { return value; }\n\ntemplate T subgroupExclusiveAdd(T value) { return value; }\ntemplate T subgroupExclusiveMul(T value) { return value; }\ntemplate T subgroupExclusiveMin(T value) { return value; }\ntemplate T subgroupExclusiveMax(T value) { return value; }\ntemplate T subgroupExclusiveAnd(T value) { return value; }\ntemplate T subgroupExclusiveOr(T value) { return value; }\ntemplate T subgroupExclusiveXor(T value) { return value; }\n\ntemplate T subgroupShuffle(T value, uint index) { (void)index; return value; }\ntemplate T subgroupShuffleXor(T value, uint mask) { (void)mask; return value; }\ntemplate T subgroupShuffleUp(T value, uint delta) { (void)delta; return value; }\ntemplate T subgroupShuffleDown(T value, uint delta) { (void)delta; return value; }\n\ntemplate T subgroupClusteredAdd(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredMul(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredMin(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredMax(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredAnd(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredOr(T value, uint clusterSize) { (void)clusterSize; return value; }\ntemplate T subgroupClusteredXor(T value, uint clusterSize) { (void)clusterSize; return value; }\n\ntemplate T subgroupQuadBroadcast(T value, uint id) { (void)id; return value; }\ntemplate T subgroupQuadSwapHorizontal(T value) { return value; }\ntemplate T subgroupQuadSwapVertical(T value) { return value; }\ntemplate T subgroupQuadSwapDiagonal(T value) { return value; }\n\n\n// missing: hyperbolic trigonometry, faceforward etc geometric functions.\n"}, {"path": "impl/inline_glsl.cpp", "language": "cpp", "loc": 719, "comment_density": 0.088, "code": "\n#include \"inline_glsl.h\"\n#ifdef _WIN32\n#include \n#endif\n\nivec2 windowSize();\n\nnamespace inline_glsl {\n#ifdef _WIN32\n long ShaderStore::id_counter = 1; // 0 reserved for non-existing shaders\n inline ULONGLONG lastAccess(const char* path) {\n HANDLE file = CreateFileA(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);\n FILETIME writeTime;\n GetFileTime(file, nullptr, nullptr, &writeTime);\n CloseHandle(file);\n return ULARGE_INTEGER{ writeTime.dwLowDateTime, writeTime.dwHighDateTime }.QuadPart;\n }\n#else\n\tstd::atomic ShaderStore::id_counter{1};\n inline auto lastAccess(const char* path) {\n return last_write_time(std::filesystem::path(path));\n }\n#endif\n\n inline bool alphanum_(char input) {\n return 'a' <= input && input <= 'z' || 'A' <= input && input <= 'Z' || '0' <= input && input <= '9' || input == '_';\n }\n\n inline void remove_bind_calls(char* input) {\n char* output = input;\n bool inside = false;\n const char* needle = \" bind\";\n\n while (*input != '\\0') {\n *output = *input;\n if (!alphanum_(*input)) {\n for (int i = 1;; i++) {\n if (needle[i] == '\\0') {\n while (*input != '(' && *input != '\\0') input++;\n inside = true;\n break;\n }\n if (input[i] != needle[i]) break;\n }\n }\n output++; input++;\n if (inside && *input == ')') {\n input++;\n inside = false;\n }\n }\n *output = '\\0';\n }\n\n inline char* search(char* input, const char* needle, int& line) {\n while (*input != '\\0') {\n if (*input == '\\n') line++;\n for (int i = 0;; i++) {\n if (needle[i] == '\\0') return input;\n else if (input[i] != needle[i]) break;\n }\n input++;\n }\n return input;\n }\n\n void remove_comments(char* source_in, uint* lines_in) {\n char* source_out = source_in;\n uint* lines_out = lines_in;\n bool multi_comment = false, single_comment = false;\n\n while(*source_in!='\\0') {\n if (multi_comment) {\n if (*source_in == '\\n') { // keep commented \\ns to preserve lines\n *(source_out++) = '\\n';\n *(lines_out++) = *lines_in;\n }\n else if (*source_in == '/' && *(source_in-1) == '*')\n multi_comment = false;\n }\n else if (single_comment && *source_in == '\\n') {\n *(source_out++) = '\\n';\n *(lines_out++) = *lines_in;\n single_comment = false;\n }\n else {\n if (*source_in == '/') {\n if (*(source_in+1) == '/')\n single_comment = true;\n else if (*(source_in + 1) == '*')\n multi_comment = true;\n }\n if (!single_comment && !multi_comment) {\n *(source_out++) = *source_in;\n *(lines_out++) = *lines_in;\n }\n }\n source_in++;\n lines_in++;\n }\n *source_out = '\\0';\n *lines_out = *lines_in;\n }\n\n void remove_float_suffixes(char* source_in, uint* lines_in) {\n char* source_out = source_in;\n uint* lines_out = lines_in;\n bool number = false;\n while (*source_in!='\\0') {\n bool keep = true;\n if (number) {\n if (*source_in == 'f')\n keep = number = false;\n if (!('0'<=*source_in && *source_in<='9') && *source_in != '.')\n number = false;\n }\n if (!alphanum_(*source_in) && ('0' <= *(source_in+1) && *(source_in+1) <= '9'))\n number = true;\n if (keep) {\n *(source_out++) = *source_in;\n *(lines_out++) = *lines_in;\n }\n source_in++;\n lines_in++;\n }\n *source_out = '\\0';\n *lines_out = *lines_in;\n }\n\n bool is_same(const char* a, const char* b) {\n while (*a == *b) {\n if (*a == '\\0') return true;\n a++; b++;\n }\n return false;\n }\n \n bool SourceStore::update(const char* path) {\n this->path = path;\n\n auto latestUpdate = lastAccess(path);\n for (auto include : includes) {\n //printf(\"checking include %s\\n\", include);\n auto includeUpdate = lastAccess(include);\n if (includeUpdate > latestUpdate)\n latestUpdate = includeUpdate;\n }\n\n if (latestUpdate == currentUpdate)\n return false;\n\n FILE* file = fopen(path, \"rb\");\n if(!file) return false;\n \n fseek(file, 0, SEEK_END);\n size_t size = size_t(ftell(file)) + 1;\n\t\tif(size == 0) return false;\n\n\t\titeration++;\n\n currentUpdate = latestUpdate;\n\n contents.resize(size);\n contents.back() = '\\0';\n fseek(file, 0, SEEK_SET);\n fread(contents.data(), 1, contents.size() - 1, file);\n fclose(file);\n\n lines.resize(contents.size());\n int line = 1;\n for (int i = 0; i < contents.size(); ++i) {\n lines[i] = line;\n if (contents[i] == '\\n') line++;\n }\n remove_comments(contents.data(), lines.data());\n remove_float_suffixes(contents.data(), lines.data());\n\n char* search = contents.data();\n\n for (auto a : includes) delete[] a;\n includes.clear();\n\n // add include files (absolutely beautiful code I know)\n while (true) {\n int dummy;\n //printf(\"%s\", contents.data());\n search = inline_glsl::search(search, \"#in\", dummy);\n\n if (*search != '\\0') {\n char* include_begin = search;\n while (*search != '\\\"' && *search != '<' && *search != '\\0') search++;\n if (*search == '\\\"' || *search == '<') {\n char* path = ++search;\n\n while (*search != '\\\"' && *search != '>' && *search != '\\0') search++;\n int64_t path_length = search - path + 1;\n char* filePath = new char[path_length];\n for (int i = 0; path < search; ++i)\n filePath[i] = *(path++);\n filePath[path_length - 1] = '\\0';\n \n search++;\n int64_t begin_ind = include_begin - contents.data(), search_ind = search - contents.data();\n\n bool already_included = false;\n for (auto& a : includes)\n if (is_same(a, filePath))\n already_included = true;\n\n if (!already_included && !is_same(filePath, \"glext.h\") && !is_same(filePath, \"window.h\") && !is_same(filePath, \"loadgl46.h\") && !is_same(filePath, \"inline_glsl.h\")) {\n\n //printf(\"%s\\n\", filePath);\n FILE* includeFile = fopen(filePath, \"rb\");\n if (includeFile) {\n\t\t\t\t\t\t\tfseek(includeFile, 0, SEEK_END);\n\t\t\t\t\t\t\tsize_t size = size_t(ftell(includeFile));\n includes.push_back(filePath);\n if(size>0) {\n \t uint includeMask = uint(includes.size()) << 20;\n \t if (includes.size() >= 4096)\n\t printf(\"too many includes, errors may be reported in incorrect files\\n\");\n\n \t size_t copy_length = contents.size() - search_ind;\n \t contents.resize(contents.size() + size - (search_ind - begin_ind) - 1);\n \t lines.resize(contents.size());\n \t memcpy(&contents[contents.size() - copy_length], &contents[search_ind], copy_length);\n \t memcpy(&lines[lines.size() - copy_length], &lines[search_ind], copy_length * sizeof(int));\n\t\n \t fseek(includeFile, 0, SEEK_SET);\n\t \t fread(&contents[begin_ind], 1, size, includeFile);\n \t \tfclose(includeFile);\n\t \t line = 1;\n\t\t\t\t\t\t\t\tfor (int i = 0; i < size; ++i) {\n \t lines[begin_ind + i] = includeMask | line;\n \t if (contents[begin_ind + i] == '\\n') line++;\n \t }\n \t remove_comments(contents.data(), lines.data());\n \t remove_float_suffixes(contents.data(), lines.data());\n\t }\n }\n else delete[] filePath;\n }\n else delete[] filePath;\n search = &contents[search_ind];\n }\n else\n search++;\n }\n else break;\n }\n contents.resize(search + 1 - contents.data());\n lines.resize(contents.size());\n\n /*int lineBegin = 0;\n for (int i = 0; i < contents.size(); ++i) {\n if (contents[i] == '\\n' || contents[i] == '\\0') {\n printf(\"%d: %.*s\", lines[lineBegin], i - lineBegin + 1, &contents[lineBegin]);\n lineBegin = i + 1;\n }\n }\n for (int i = 0; i < 5; ++i) {\n printf(\"%d, \", lines[lines.size() - 1 - i]);\n }*/\n\n glsl_mains.clear();\n glsl_main_lines.clear();\n glsl_functions.clear();\n \n search = contents.data();\n\n while (true) {\n search = inline_glsl::search(search, \"glsl_main\", line);\n if (*search != '\\0') {\n glsl_mains.push_back(search);\n glsl_main_lines.push_back(lines[search-contents.data()]);\n search++;\n }\n else break;\n }\n search = contents.data();\n while (true) {\n search = inline_glsl::search(search + 1, \"#define\", line);\n if (*search != '\\0') {\n glsl_functions.push_back(search);\n search++;\n }\n else break;\n }\n search = contents.data();\n while (true) {\n search = inline_glsl::search(search + 1, \"glsl_global\", line);\n if (*search != '\\0') {\n glsl_functions.push_back(search + 11);\n search++;\n }\n else break;\n }\n search = contents.data();\n while (true) {\n search = inline_glsl::search(search + 1, \"glsl_function\", line);\n if (*search != '\\0') {\n glsl_functions.push_back(search + 13);\n search++;\n }\n else break;\n }\n search = contents.data();\n while (true) {\n search = inline_glsl::search(search + 1, \"glsl_func(\", line);\n if (*search != '\\0') {\n for (int i = 0; i < 3; ++i) {\n char open = i < 2 ? '(' : '{', close = i < 2 ? ')' : '}';\n while (*search != open && *search != '\\0') search++;\n int inside = 1;\n while (inside > 0 && *(++search)!='\\0') {\n if (*search == open) inside++;\n if (*search == close) inside--;\n }\n }\n /*if (*(search + 1) != ';')\n printf(\"wrong character..?\\n\");\n else\n printf(\"semicolon removed!\\n\");*/\n *(search+1) = ' ';\n }\n else break;\n }\n\n glsl_begin_lines = glsl_main_lines;\n for (int i = 0; i < glsl_mains.size(); i++) {\n char*& c = glsl_mains[i];\n int inside = 1;\n char* k = c;\n while (inside > 0 && *k != '\\0') {\n if (*k == '{') inside++;\n if (*k == '}') inside--;\n k++;\n }\n *(k - 1) = '\\0';\n inside = 1;\n while (inside > 0 && c != contents.data()) {\n c--;\n if (*c == '}') inside++;\n if (*c == '{') inside--;\n if (*c == '\\n') glsl_begin_lines[i]--;\n }\n c++;\n\n remove_bind_calls(c);\n }\n for (char* c : glsl_functions) {\n if (*c == '#') {\n while (*c != '\\n' && *c != '\\0') c++;\n *c = '\\0';\n continue;\n }\n while (*c != ';' && *c != '{' && *c != '(' && *c != '\\0') c++;\n if (*c == '{') {\n c++;\n // struct\n int inside = 1;\n while (inside>0 && *c != '\\0') {\n if (*c == '{') inside++;\n if (*c == '}') inside--;\n c++;\n }\n }\n if (*c == ';') *(c + 1) = '\\0'; // variable\n else {\n // function\n c++;\n int inside = 1;\n while (inside > 0 && *c!='\\0') {\n if (*c == '(') inside++;\n if (*c == ')') inside--;\n c++;\n }\n while (*c != '{' && *c!=';' && *c != '\\0') c++;\n if (*c == ';')\n *(c+1) = '\\0';\n else {\n c++;\n inside = 1;\n while (inside > 0 && *c != '\\0') {\n if (*c == '{') inside++;\n if (*c == '}') inside--;\n c++;\n }\n *c = '\\0';\n }\n }\n }\n for (const char* c : includes) {\n while (*c != '\\\"' && *c != '>' && *c != '\\0') ++c;\n *const_cast(c) = '\\0';\n }\n\n return true;\n }\n\n void write_line(char* target, int line, int file) {\n for (int i = 0; i < 7; ++i) target[i] = \"\\n#line \"[i];\n sprintf(target + 7, \"%u %u\\n\", line, file);\n }\n\n bool add_shader(GLuint program, GLenum type, const char* name, const Shader& shader_obj, SourceStore& store) {\n\n GLuint shader = glCreateShader(type);\n\n if (!shader_obj.store->cached) {\n\n const char* stub = \"\\\n#extension GL_ARB_gpu_shader_int64 : enable\\n\\\n#define glsl_main() main()\\n\\\n#define glsl_func(a) a\\n\\\n#define dynamic_array(t, a) t a[]\\n\\\n#define arg_in(a) in a\\n\\\n#define arg_out(a) out a\\n\\\n#define arg_inout(a) inout a\\n\\\n#define arg_layout layout\\n\\\n#define glsl_extension(a,b) int _##a = 1\\n\\\n#define glsl_version(a) int glsl_version = a\\n\\\n#define glsl_subgroup(a) \\n\\\n#define not_(a) not(a)\\n\";\n\n size_t extensions = shader_obj.store->extensions.size();\n size_t functions = store.glsl_functions.size();\n const char** sources = const_cast(new char* [4 + extensions + 2 * functions]);\n\n sources[0] = shader_obj.store->version ? shader_obj.store->version : \"#version 460\\n\";\n for (int i = 0; i < extensions; ++i)\n sources[1 + i] = shader_obj.store->extensions[i];\n sources[extensions + 1] = stub;\n\n uint mask = 0xffffffffu << 20u;\n for (int i = 0; i < functions; ++i) {\n char* k = new char[32];\n uint line_file = store.lines[store.glsl_functions[i] - store.contents.data()];\n write_line(k, line_file & ~mask, (line_file & mask) >> 20u);\n sources[i * 2 + 2 + extensions] = k;\n sources[i * 2 + 3 + extensions] = store.glsl_functions[i];\n }\n char* l = new char[32];\n write_line(l, store.glsl_begin_lines[shader_obj.store->nth_in_file], 0);\n sources[2 + 2 * functions + extensions] = l;\n sources[3 + 2 * functions + extensions] = store.glsl_mains[shader_obj.store->nth_in_file];\n\n //printf(\"source: \\n\");\n //for (int i = 0; i < 4 + extensions + 2 * store.glsl_functions.size(); ++i)\n // printf(\"%s\", sources[i]);\n\n#ifdef _WIN32\n (void)_mkdir(\"shader_cache\");\n#else\n std::filesystem::create_directory(\"shader_cache\");\n#endif\n\n char cache_name[256];\n get_cache_name(cache_name, store.path, shader_obj.store->line);\n FILE* cache = fopen(cache_name, \"wb\");\n for (auto& include : store.includes) {\n int count = 0;\n while (include[count] != '\\0') count++;\n fwrite(include, 1, count, cache);\n fwrite(\",\", 1, 1, cache);\n }\n fwrite(\"\\n\", 1, 1, cache);\n for (int i = 0; i < 4 + extensions + 2 * store.glsl_functions.size(); ++i) {\n int count = 0;\n while (sources[i][count] != '\\0') count++;\n fwrite(sources[i], 1, count, cache);\n }\n fclose(cache);\n\n glShaderSource(shader, GLsizei(4 + extensions + 2 * functions), sources, nullptr);\n\n delete[] l;\n for (int i = 0; i < functions; ++i)\n delete[] const_cast(sources[i * 2 + 2 + extensions]);\n delete[] sources;\n }\n else\n glShaderSource(shader, 1, &shader_obj.store->cached, nullptr);\n \n glCompileShader(shader);\n GLint status;\n glGetShaderiv(shader, GL_COMPILE_STATUS, &status);\n if (status != GL_TRUE) {\n GLint length;\n glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);\n std::vector info_log(length);\n glGetShaderInfoLog(shader, length, nullptr, info_log.data());\n const GLubyte* vendor = glGetString(GL_VENDOR);\n \n if(vendor[0] == 'N' && vendor[1] == 'V') // should be enough :^)\n for (int i = 0; i < info_log.size(); ++i) {\n uint file_number, line_number;\n if ((i==0||info_log[i-1] == '\\n') && 2 == sscanf(info_log.data() + i, \"%u(%u)\", &file_number, &line_number)) {\n int j = 0; while (i+j < info_log.size() && info_log[i+j] != ')') j++; j++;\n \n const char* path = (file_number == 0) ? shader_obj.store->path : shader_obj.store->include_files[file_number-1];\n \n int last_dir = 0;\n for (int k = 0; path[k] != '\\0'; k++)\n if (path[k] == '\\\\' || path[k] == '/')\n last_dir = k;\n if(last_dir)\n path += last_dir + 1;\n\n int k = 0; while (path[k] != '\\0')k++;\n int t = int(ceil(log10(line_number)));\n // \", line \"\n size_t copy_size = info_log.size() - i - j;\n info_log.resize(info_log.size()-j+k+t+7);\n memcpy(info_log.data() + i + k + t + 7, info_log.data() + i + j, copy_size);\n for (int p = 0; p < k; ++p)\n info_log[i + p] = path[p];\n for (int p = 0; p < 7; ++p)\n info_log[i + k + p] = \", line \"[p];\n info_log[i+k+7+sprintf(info_log.data() + i + k + 7, \"%u\", line_number)] = ' ';\n i += k + t + 7;\n }\n }\n // TODO: AMD, Intel, ...? some vendors may have different error reporting schemes for different generations?\n printf(\"\\n%s failed: \\n%s\", name, info_log.data());\n glDeleteShader(shader);\n return false;\n }\n glAttachShader(program, shader);\n glDeleteShader(shader);\n return true;\n }\n\n // maybe make this O(log n) at some point\n inline Program& find_or_insert(int64_t ids[6], std::vector& programs) {\n for (int i = 0; i < programs.size(); ++i) {\n for (int j = 0; j < 6; ++j) {\n if (programs[i].ids[j] != ids[j]) break;\n else if (j == 5) return programs[i].p;\n }\n }\n programs.resize(programs.size() + 1);\n size_t location = programs.size() - 1;\n programs[location].p = Program();\n for (int i = 0; i < 6; ++i)\n programs[location].ids[i] = (long)ids[i];\n return programs[location].p;\n }\n\n std::vector draw_buffers;\n\n void useShader(const Shader& compute, const Shader& vertex, const Shader& geometry, const Shader& control, const Shader& evaluation, const Shader& fragment, std::vector& programs, ShaderState& shader_state, SourceStore& store) {\n\n int64_t ids[] = { compute.unique_id, vertex.unique_id, fragment.unique_id, geometry.unique_id, control.unique_id, evaluation.unique_id };\n Program& program = find_or_insert(ids, programs);\n\n shader_state.rebuilt = false;\n if (program.obj == 0 || compute.changed || vertex.changed || fragment.changed || geometry.changed || control.changed || evaluation.changed) {\n printf(\"compiling... \");\n GLuint newProgram = glCreateProgram();\n\n bool csuccess = !compute.unique_id || add_shader(newProgram, GL_COMPUTE_SHADER, \"compute\", compute, store);\n bool vsuccess = !vertex.unique_id || add_shader(newProgram, GL_VERTEX_SHADER, \"vertex\", vertex, store);\n bool gsuccess = !geometry.unique_id || add_shader(newProgram, GL_GEOMETRY_SHADER, \"geometry\", geometry, store);\n bool tsuccess = !control.unique_id || add_shader(newProgram, GL_TESS_CONTROL_SHADER, \"control\", control, store);\n bool esuccess = !evaluation.unique_id || add_shader(newProgram, GL_TESS_EVALUATION_SHADER, \"evaluation\", evaluation, store);\n bool fsuccess = !fragment.unique_id || add_shader(newProgram, GL_FRAGMENT_SHADER, \"fragment\", fragment, store);\n\n bool success = csuccess && vsuccess && gsuccess && tsuccess && esuccess && fsuccess;\n\n if (success) {\n glLinkProgram(newProgram);\n\n GLint status;\n glGetProgramiv(newProgram, GL_LINK_STATUS, &status);\n if (status != GL_TRUE) {\n GLint length;\n glGetProgramiv(newProgram, GL_INFO_LOG_LENGTH, &length);\n std::vector info_log(length);\n glGetProgramInfoLog(newProgram, length, nullptr, info_log.data());\n printf(\"\\ncouldn't link shader: \\n%s\\n\", info_log.data());\n glDeleteProgram(newProgram);\n success = false;\n }\n }\n else printf(\"\\n\");\n if (success) {\n printf(\"success! \\n\");\n if (program.obj != 0)\n glDeleteProgram(program.obj);\n program.obj = newProgram;\n\n if (program.vao != 0)\n glDeleteVertexArrays(1, &program.vao);\n glCreateVertexArrays(1, &program.vao);\n\n shader_state.rebuilt = true;\n }\n }\n\n glBindVertexArray(program.vao);\n\n glUseProgram(program.obj);\n\n if (draw_buffers.size() == 0) {\n GLint maxBuffers;\n glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxBuffers);\n draw_buffers.resize(maxBuffers);\n }\n for (auto& b : draw_buffers)\n b = GL_NONE;\n\n shader_state.fbo = program.fbo;\n shader_state.program = program.obj;\n shader_state.texture_unit = shader_state.image_unit = shader_state.fbo_width = shader_state.fbo_height = 0;\n\n shader_state.use_fbo = false;\n\n if (compute.unique_id) for (auto& f : compute.store->callbacks) f(shader_state);\n if (vertex.unique_id) for (auto& f : vertex.store->callbacks) f(shader_state);\n if (geometry.unique_id) for (auto& f : geometry.store->callbacks) f(shader_state);\n if (control.unique_id) for (auto& f : control.store->callbacks) f(shader_state);\n if (evaluation.unique_id) for (auto& f : evaluation.store->callbacks) f(shader_state);\n if (fragment.unique_id) for (auto& f : fragment.store->callbacks) f(shader_state);\n\n program.fbo = shader_state.fbo;\n\n if (shader_state.use_fbo) {\n glViewport(0, 0, shader_state.fbo_width, shader_state.fbo_height);\n //auto test = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n //if (test != GL_FRAMEBUFFER_COMPLETE)\n // printf(\"framebuffer status %X\\n\", test);\n\n glDrawBuffers(draw_buffers.size(), draw_buffers.data());\n }\n else {\n glBindFramebuffer(GL_FRAMEBUFFER, 0);\n auto size = windowSize();\n glViewport(0, 0, size.x, size.y);\n }\n }\n\n void Arg::findLocation(ShaderState& shader_state, ArgStore& store) {\n //printf(\"find location of SSBO '%s'\\n\", store.name);\n store.location = glGetProgramResourceIndex(shader_state.program, GL_SHADER_STORAGE_BLOCK, store.name);\n if (store.location != GL_INVALID_INDEX)\n glShaderStorageBlockBinding(shader_state.program, store.location, store.location);\n }\n void Arg::findLocation(ShaderState& shader_state, ArgStore& store) {\n //printf(\"find location of UBO '%s'\\n\", store.name);\n store.location = glGetProgramResourceIndex(shader_state.program, GL_UNIFORM_BLOCK, store.name);\n if (store.location != GL_INVALID_INDEX)\n glUniformBlockBinding(shader_state.program, store.location, store.location);\n }\n void Arg::findLocation(ShaderState& shader_state, ArgStore& store) {\n //printf(\"find location of color attachment '%s'\\n\", store.name);\n store.location = glGetProgramResourceIndex(shader_state.program, GL_PROGRAM_OUTPUT, store.name);\n }\n void Arg::findLocation(ShaderState& shader_state, ArgStore& store) {\n //printf(\"'location' of depth attachment '%s' is obvious\\n\", store.name);\n }\n\n#undef bind\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform float '%s' to %g\\n\", store.name, store.item);\n glUniform1f(store.location, store.item);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform int '%s' to %i\\n\", store.name, store.item);\n glUniform1i(store.location, store.item);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform uint '%s' to %ui\\n\", store.name, store.item);\n glUniform1ui(store.location, store.item);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform uint '%s' to %ui\\n\", store.name, store.item);\n glUniform1ui64(store.location, store.item);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform vec2 '%s'\\n\", store.name);\n glUniform2fv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform ivec2 '%s'\\n\", store.name);\n glUniform2iv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform uvec2 '%s'\\n\", store.name);\n glUniform2uiv(store.location, 1, (const GLuint*)store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform vec3 '%s'\\n\", store.name);\n glUniform3fv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform ivec3 '%s'\\n\", store.name);\n glUniform3iv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform uvec3 '%s'\\n\", store.name);\n glUniform3uiv(store.location, 1, (const GLuint*)store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform vec4 '%s'\\n\", store.name);\n glUniform4fv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform ivec4 '%s'\\n\", store.name);\n glUniform4iv(store.location, 1, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform uvec4 '%s'\\n\", store.name);\n glUniform4uiv(store.location, 1, (const GLuint*)store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat2 '%s'\\n\", store.name);\n glUniformMatrix2fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat3 '%s'\\n\", store.name);\n glUniformMatrix3fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat4 '%s'\\n\", store.name);\n glUniformMatrix4fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat3x2 '%s'\\n\", store.name);\n glUniformMatrix3x2fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat4x2 '%s'\\n\", store.name);\n glUniformMatrix4x2fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat2x3 '%s'\\n\", store.name);\n glUniformMatrix2x3fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat4x3 '%s'\\n\", store.name);\n glUniformMatrix4x3fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat2x4 '%s'\\n\", store.name);\n glUniformMatrix2x4fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"set uniform mat3x4 '%s'\\n\", store.name);\n glUniformMatrix3x4fv(store.location, 1, false, store.item.data);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"bind SSBO '%s'\\n\", store.name);\n glBindBufferBase(GL_SHADER_STORAGE_BUFFER, store.location, store.item);\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"bind UBO '%s'\\n\", store.name);\n glBindBufferBase(GL_UNIFORM_BUFFER, store.location, store.item);\n }\n\n void set_fbo_size(GLuint texture, GLint level, ShaderState& state) {\n glGetTextureLevelParameteriv(texture, level, GL_TEXTURE_WIDTH, &state.fbo_width);\n glGetTextureLevelParameteriv(texture, level, GL_TEXTURE_HEIGHT, &state.fbo_height);\n }\n\n bool layered(GLenum type) {\n return type == GL_TEXTURE_2D_ARRAY || type == GL_TEXTURE_3D || type == GL_TEXTURE_CUBE_MAP || type == GL_TEXTURE_CUBE_MAP_ARRAY || type == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;\n }\n\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"attach color '%s'\\n\", store.name);\n if (store.item == 0) return;\n if (shader_state.fbo == 0)\n glGenFramebuffers(1, &shader_state.fbo);\n if(!shader_state.use_fbo)\n glBindFramebuffer(GL_FRAMEBUFFER, shader_state.fbo);\n shader_state.use_fbo = true;\n if (shader_state.fbo_width == 0) set_fbo_size(store.item, store.item.level, shader_state);\n if (layered(store.item.type))\n glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + store.location, store.item, store.item.level, store.item.layer);\n else\n glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + store.location, store.item, store.item.level);\n draw_buffers[store.location] = GL_COLOR_ATTACHMENT0 + store.location;\n }\n void Arg::bind(ShaderState& shader_state, ArgStore& store) {\n //printf(\"attach %s to depth\\n\", store.name);\n if (store.item == 0) return;\n if (shader_state.fbo == 0)\n glGenFramebuffers(1, &shader_state.fbo);\n if (!shader_state.use_fbo)\n glBindFramebuffer(GL_FRAMEBUFFER, shader_state.fbo);\n shader_state.use_fbo = true;\n if (shader_state.fbo_width == 0) set_fbo_size(store.item, store.item.level, shader_state);\n if (layered(store.item.type))\n glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, store.item, store.item.level, store.item.layer);\n else\n glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, store.item, store.item.level);\n }\n}\n"}, {"path": "impl/inline_glsl.h", "language": "c", "loc": 456, "comment_density": 0.033, "code": "#pragma once\n\n#include \n\n#ifdef _WIN32\n#define VC_EXTRALEAN\n#define WIN32_LEAN_AND_MEAN\n#define NOMINMAX\n#include \n#else\n#include \n#endif\n\n#include \"glsl.h\"\n#include \"shader_types.h\"\n\n#ifndef _WIN32\n#include \n#include \n#endif\n\nnamespace inline_glsl {\n \n struct SourceStore {\n std::vector contents;\n std::vector glsl_mains;\n std::vector glsl_functions;\n std::vector glsl_main_lines, glsl_begin_lines;\n std::vector includes;\n char const* path;\n std::vector lines;\n#ifdef _WIN32\n ULONGLONG currentUpdate = 0;\n#else\n std::filesystem::file_time_type currentUpdate = {};\n#endif\n uint iteration = 0;\n bool update(const char* path);\n ~SourceStore() {\n for (auto include : includes) delete[] include;\n }\n };\n\n static SourceStore store;\n\n // filled prior to invoking a program\n struct ShaderState {\n GLuint program;\n GLuint fbo;\n GLuint image_format, image_access;\n GLubyte texture_unit;\n GLubyte image_unit;\n GLint fbo_width, fbo_height;\n bool rebuilt, use_fbo;\n } static shader_state;\n\n struct Function {\n virtual void operator()(ShaderState&) = 0;\n virtual ~Function() {}\n };\n\n template\n struct Specific : Function {\n T func;\n Specific(T func) : func(func) {}\n virtual void operator()(ShaderState& state) { func(state); }\n };\n\n struct Func {\n Function* func = nullptr;\n template\n Func(T func) : func(new Specific(func)) {}\n Func(Func&& other) : func(other.func) { other.func = nullptr; }\n void operator()(ShaderState& state) { (*func)(state); }\n ~Func() { if (func) delete func; }\n };\n\n using ShaderSetup = std::vector;\n inline ShaderSetup* current_callbacks;\n inline std::vector* extensions;\n inline const char** version;\n\n inline void get_cache_name(char* result, const char* path, int line) {\n\n const char* path_name = path;\n while (*path_name != '\\0') path_name++;\n while (*path_name != '\\\\' && *path_name != '/' && path_name > path)path_name--;\n if (path_name > path) path_name++;\n\n int i = 0;\n for (i = 0; i < 13; ++i)\n result[i] = \"shader_cache/\"[i];\n while (*path_name != '.' && *path_name != '\\0')\n result[i++] = *path_name++;\n result[i++] = '_';\n\n i += sprintf(result+i, \"%d\", line);\n\n for (int j = 0; j < 6; ++j)\n result[i++] = \".glsl\"[j];\n }\n\n struct ShaderStore {\n ShaderSetup callbacks;\n std::vector extensions, include_files;\n const char* version;\n const char* path; int line;\n const char* cached = nullptr;\n uint nth_in_file, iteration = 0;\n long unique_id;\n#ifdef _WIN32\n static long id_counter;\n#else\n\t\tstatic std::atomic id_counter;\n#endif\n ShaderStore(const char* path, int line, SourceStore& store) : path(path), line(line) {\n#ifdef _WIN32\n unique_id = InterlockedAdd(&id_counter, 1);\n#else\n unique_id = id_counter++;\n#endif\n FILE* test = fopen(path, \"r\");\n if (test) {\n fclose(test);\n store.update(path);\n include_files = store.includes;\n for (nth_in_file = 0; nth_in_file < store.glsl_main_lines.size() && store.glsl_main_lines[nth_in_file] != line; ++nth_in_file);\n //printf(\"glsl_main %d at line %d\\n\", nth_in_file, line);\n }\n else {\n char name_buffer[256];\n get_cache_name(name_buffer, path, line);\n FILE* file = fopen(name_buffer, \"rb\");\n fseek(file, 0, SEEK_END);\n size_t size = size_t(ftell(file)) + 1;\n char* cache = new char[size];\n cache[size - 1] = '\\0';\n\n fseek(file, 0, SEEK_SET);\n fread(cache, 1, size - 1, file);\n fclose(file);\n\n while (*cache != '\\0' && *cache != '\\n') {\n include_files.push_back(cache);\n while (*cache != '\\0' && *cache != ',') cache++;\n if (*cache != '\\0') {\n *cache = '\\0';\n cache++;\n }\n }\n\n cached = cache+1;\n }\n }\n\n bool update(SourceStore& store) {\n callbacks.clear();\n extensions.clear();\n version = nullptr;\n inline_glsl::current_callbacks = &callbacks;\n inline_glsl::extensions = &extensions;\n inline_glsl::version = &version;\n if (cached) return false;\n store.update(path);\n uint old_iteration = iteration;\n iteration = store.iteration;\n return old_iteration != iteration;\n }\n ~ShaderStore() { delete[] cached; }\n };\n\n struct Extension {\n const char* ext;\n Extension(const char* ext) : ext(ext) {}\n ~Extension() { inline_glsl::extensions->push_back(ext); }\n };\n struct Version {\n const char* version;\n Version(const char* version) : version(version) {}\n ~Version() { *inline_glsl::version = version; }\n };\n}\nstruct Shader {\n uint unique_id = 0; bool changed = false;\n inline_glsl::ShaderStore* store = nullptr;\n Shader() {}\n Shader(inline_glsl::ShaderStore& shader, inline_glsl::SourceStore& source) {\n changed = shader.update(source);\n unique_id = shader.unique_id;\n store = &shader;\n }\n};\n\nnamespace inline_glsl {\n struct Program {\n GLuint obj = 0, vao = 0, fbo = 0;\n };\n\n struct ProgramEntry {\n long ids[6] = { 0 };\n Program p;\n };\n\n static std::vector programs;\n void useShader(const Shader& compute, const Shader& vertex, const Shader& geometry, const Shader& control, const Shader& evaluation, const Shader& fragment, std::vector& programs, ShaderState& shader_state, SourceStore& store);\n\n\n template\n struct ArgStore {\n const char* name;\n GLuint location, program;\n T item;\n ArgStore(const char* name, T i) : name(name), item(i) {\n //printf(\"retainer for %s\\n\", name);\n }\n };\n\n using glsl::same, glsl::Field, glsl::Rows;\n\n template\n constexpr bool is_image = false;\n template\n constexpr bool is_image> = true;\n\n struct Arg {\n template\n void findLocation(ShaderState& shader_state, ArgStore& store) {\n //printf(\"glGetUniformLocation(%s)\\n\", store.name);\n store.location = glGetUniformLocation(shader_state.program, store.name);\n }\n template\n void findLocation(ShaderState& shader_state, ArgStore>& store) {\n //printf(\"glGetUniformLocation(%s)\\n\", store.name);\n store.location = glGetUniformLocation(shader_state.program, store.name);\n if (store.location != GL_INVALID_INDEX)\n glUniform1i(store.location, shader_state.texture_unit);\n if constexpr (shadow) {\n glTextureParameteri(store.item, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);\n glTextureParameteri(store.item, GL_TEXTURE_COMPARE_FUNC, GL_LESS);\n }\n }\n template\n void findLocation(ShaderState& shader_state, ArgStore>& store) {\n store.location = glGetUniformLocation(shader_state.program, store.name);\n if (store.location != GL_INVALID_INDEX)\n glUniform1i(store.location, shader_state.image_unit);\n }\n void findLocation(ShaderState& shader_state, ArgStore& store);\n void findLocation(ShaderState& shader_state, ArgStore& store);\n template\n void findLocation(ShaderState& shader_state, ArgStore>& store) {\n //printf(\"find location of vertex attribute '%s'\\n\", store.name);\n store.location = glGetAttribLocation(shader_state.program, store.name);\n if(store.location!= GL_INVALID_INDEX)\n glEnableVertexAttribArray(store.location);\n }\n void findLocation(ShaderState& shader_state, ArgStore& store);\n void findLocation(ShaderState& shader_state, ArgStore& store);\n\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n template\n void bind(ShaderState& shader_state, ArgStore>& store) {\n //printf(\"bind vertex attribute '%s'\\n\", store.name);\n glBindBuffer(GL_ARRAY_BUFFER, store.item);\n\n static_assert(same, float> || same, int> || same,uint>, \"attribute base type not supported\");\n if constexpr (same, float>)\n glVertexAttribPointer(store.location, Rows, store.item.type, store.item.normalized, store.item.stride, (void*)(size_t)store.item.offset);\n else\n glVertexAttribIPointer(store.location, Rows, store.item.type, store.item.stride, (void*)(size_t)store.item.offset);\n }\n\n void bind(ShaderState& shader_state, ArgStore& store);\n void bind(ShaderState& shader_state, ArgStore& store);\n\n template\n void bind(ShaderState& shader_state, ArgStore>& store) {\n //printf(\"bind sampler2D '%s'\\n\", store.name);\n glBindTextureUnit(shader_state.texture_unit, store.item);\n shader_state.texture_unit++;\n }\n template\n void bind(ShaderState& shader_state, ArgStore>& store, GLuint access, GLuint format) {\n //printf(\"bind image2D '%s'\\n\", store.name);\n if (access == 1) access = GL_READ_ONLY;\n else if (access == 2) access = GL_WRITE_ONLY;\n else access = GL_READ_WRITE;\n\n bool layered = store.item.layer == GL_INVALID_INDEX;\n GLint tex_format, tex_size, bind_size;\n glGetTextureLevelParameteriv(store.item, store.item.level, GL_TEXTURE_INTERNAL_FORMAT, &tex_format);\n glGetInternalformativ(type, tex_format, GL_IMAGE_TEXEL_SIZE, 1, &tex_size);\n glGetInternalformativ(type, format, GL_IMAGE_TEXEL_SIZE, 1, &bind_size);\n if (tex_size != bind_size) {\n printf(\"warning: texture and shader image have different texel sizes\\n\");\n#ifdef _WIN32\n __debugbreak();\n#endif\n }\n glBindImageTexture(shader_state.image_unit, store.item, store.item.level, layered, layered ? 0 : store.item.layer, access, format);\n shader_state.image_unit++;\n }\n\n Func func;\n template\n Arg(volatile ArgStore& store_, const U& j) : func([&, j, state = shader_state](ShaderState& shader_state) {\n ArgStore& store = const_cast&>(store_); // volatile is a legit keyword for images and buffers; the variable is not actually volatile so we cast it away\n\n if (shader_state.rebuilt || store.program != shader_state.program) {\n store.program = shader_state.program;\n findLocation(shader_state, store);\n }\n\n store.item = j;\n if (store.location != -1)\n if constexpr (!is_image)\n bind(shader_state, store);\n else\n bind(shader_state, store, state.image_access, state.image_format);\n }) {}\n\n ~Arg() { current_callbacks->push_back(std::move(func)); }\n };\n}\n\n#define UNIQUE_(a, b) ___ ## a ## b\n#define UNIQUE(a, b) UNIQUE_(a, b)\n\n#define REPEAT1(m, a) m(a)\n#define REPEAT2(m, a, b) m(a), m(b)\n#define REPEAT3(m, a, b, c) m(a), m(b), m(c)\n#define REPEAT4(m, a, b, c, d) m(a), m(b), m(c), m(d)\n#define REPEAT5(m, a, b, c, d, e) m(a), m(b), m(c), m(d), m(e)\n#define REPEAT6(m, a, b, c, d, e, f) m(a), m(b), m(c), m(d), m(e), m(f)\n#define REPEAT7(m, a, b, c, d, e, f, g) m(a), m(b), m(c), m(d), m(e), m(f), m(g)\n#define REPEAT8(m, a, b, c, d, e, f, g, h) m(a), m(b), m(c), m(d), m(e), m(f), m(g), m(h)\n\n#define SELECT(a, b, c, d, e, f, g, h, macro, ...) macro\n#define REPEAT(...) SELECT(__VA_ARGS__, REPEAT8, REPEAT7, REPEAT6, REPEAT5, REPEAT4, REPEAT3, REPEAT2, REPEAT1)\n\n\n#define STORE(a) UNIQUE(a,0)(#a, a)\n#define ARG(a) UNIQUE(a##_,0)(UNIQUE(a, 0), (decltype(UNIQUE(a,0).item))a)\n#define SHADOW(a) a = {}\n\n#define UNIFORM static inline_glsl::ArgStore<\n#define BUFFER static inline_glsl::ArgStore REPEAT(__VA_ARGS__)(STORE, __VA_ARGS__); inline_glsl::Arg REPEAT(__VA_ARGS__)(ARG, __VA_ARGS__); const FIRSTTYPE(__VA_ARGS__, 0) REPEAT(__VA_ARGS__)(SHADOW, __VA_ARGS__); inline_glsl::shader_state.image_access = 0\n#define BIND_BLOCK(a) > UNIQUE(a,0)(#a, a); inline_glsl::Arg UNIQUE(a##_,0)(UNIQUE(a,0), (decltype(UNIQUE(a,0).item))a); inline_glsl::shader_state.image_access = 0; union\n\n// bind(uniform_1, uniform_2, ...)\n#define bind(...) BIND(__VA_ARGS__)\n\n// bind_block(ssbo/ubo) {...};\n#define bind_block(a) BIND_BLOCK(a)\n\n#define DECL_TARGET_(a) UNIQUE(a##_,0)(#a, a)\n#define SELECT_TARGET_DECLARE_(...) REPEAT(__VA_ARGS__)(DECL_TARGET_, __VA_ARGS__)\n\n#define DECL_TARGET(a) UNIQUE(a,0)(#a, a)\n#define SELECT_TARGET_DECLARE(...) REPEAT(__VA_ARGS__)(DECL_TARGET, __VA_ARGS__)\n\n#define TARGET_SETTER(a) UNIQUE(a##_,0)(UNIQUE(a, 0), Target(a))\n#define SELECT_TARGET_SET(...) REPEAT(__VA_ARGS__)(TARGET_SETTER, __VA_ARGS__)\n\n#define SET_ATTR(a) UNIQUE(a##_,0)(UNIQUE(a, 0), Attribute(a))\n#define SELECT_ATTRIB_SET(...) REPEAT(__VA_ARGS__)(SET_ATTR, __VA_ARGS__)\n\n\n#define BIND_ATTRIBUTE(...) UNIQUE(type, __LINE__);(void)UNIQUE(type, __LINE__); static inline_glsl::ArgStore> SELECT_TARGET_DECLARE(__VA_ARGS__); inline_glsl::Arg SELECT_ATTRIB_SET(__VA_ARGS__); const decltype(UNIQUE(type, __LINE__)) REPEAT(__VA_ARGS__)(SHADOW, __VA_ARGS__)\n#define BIND_TARGET(...) UNIQUE(type, __LINE__);(void)UNIQUE(type, __LINE__); static inline_glsl::ArgStore SELECT_TARGET_DECLARE(__VA_ARGS__); inline_glsl::Arg SELECT_TARGET_SET(__VA_ARGS__); decltype(UNIQUE(type, __LINE__)) REPEAT(__VA_ARGS__)(SHADOW, __VA_ARGS__)\n\n// bind_attribute(attribute_1, attribute_2, ...)\n#define bind_attribute(...) BIND_ATTRIBUTE(__VA_ARGS__)\n\n// bind_target(texture_1, texture_2, ...)\n#define bind_target(...) BIND_TARGET(__VA_ARGS__)\n\n#define glsl_func(name) *UNIQUE(type, __LINE__); (void)(UNIQUE(type, __LINE__)); auto name = [&]\n\n#define in\n#define out\n\n#define arg_in(type) type\n#define arg_out(type) type&\n#define arg_inout(type) type&\n\n#define flat\n#define noperspective\n#define smooth\n\n#define layout(...) __VA_ARGS__;\n\n#define std140 0\n#define std430 0\n\n#define shared\n\n#define glsl_extension(name, behavior) inline_glsl::Extension _##name(\"#extension \" #name \" : \" #behavior \"\\n\")\n#define glsl_version(version) inline_glsl::Version glsl_version(\"#version \" #version \"\\n\")\n#define glsl_subgroup(behavior) \\\n glsl_extension(GL_KHR_shader_subgroup_basic, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_vote, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_ballot, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_arithmetic, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_shuffle, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_shuffle_relative, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_clustered, behavior);\\\n glsl_extension(GL_KHR_shader_subgroup_quad, behavior)\n\ninline unsigned location, binding, component, offset, vertices, max_vertices, primitive, invocations, local_size_x, local_size_y, local_size_z;\ninline unsigned points, lines, lines_adjacency, triangles, triangles_adjacency, line_strip, triangle_strip;\n\n#define IMAGE_FORMAT(a) inline_glsl::shader_state.image_format = a\ntemplate\nstruct DynamicArray {\n T val;\n T& operator[](int){ return val; }\n int length() { return 0; }\n};\n#define dynamic_array(type, name) DynamicArray name;\n\n#define arg_layout(...)\n\n#define r11f_g11f_b10f IMAGE_FORMAT(GL_R11F_G11F_B10F)\n#define rgb10_a2 IMAGE_FORMAT(GL_RGB10_A2)\n#define rgba32f IMAGE_FORMAT(GL_RGBA32F)\n#define rgba16f IMAGE_FORMAT(GL_RGBA16F)\n#define rgba16 IMAGE_FORMAT(GL_RGBA16)\n#define rgba8 IMAGE_FORMAT(GL_RGBA8)\n#define rg32f IMAGE_FORMAT(GL_RG32F)\n#define rg16f IMAGE_FORMAT(GL_RG16F)\n#define rg16 IMAGE_FORMAT(GL_RG16)\n#define rg8 IMAGE_FORMAT(GL_RG8)\n#define r32f IMAGE_FORMAT(GL_R32F)\n#define r16f IMAGE_FORMAT(GL_R16F)\n#define r16 IMAGE_FORMAT(GL_R16)\n#define r8 IMAGE_FORMAT(GL_R8)\n#define rgba16_snorm IMAGE_FORMAT(GL_RGBA16_SNORM)\n#define rgba8_snorm IMAGE_FORMAT(GL_RGBA8_SNORM)\n#define rg16_snorm IMAGE_FORMAT(GL_RG16_SNORM)\n#define rg8_snorm IMAGE_FORMAT(GL_RG8_SNORM)\n#define r16_snorm IMAGE_FORMAT(GL_R16_SNORM)\n#define r8_snorm IMAGE_FORMAT(GL_R8_SNORM)\n\n#define rgba32i IMAGE_FORMAT(GL_RGBA32I)\n#define rgba16i IMAGE_FORMAT(GL_RGBA16I)\n#define rgba8i IMAGE_FORMAT(GL_RGBA8I)\n#define rg32i IMAGE_FORMAT(GL_RG32I)\n#define rg16i IMAGE_FORMAT(GL_RG16I)\n#define rg8i IMAGE_FORMAT(GL_RG8I)\n#define r32i IMAGE_FORMAT(GL_R32I)\n#define r16i IMAGE_FORMAT(GL_R16I)\n#define r8i IMAGE_FORMAT(GL_R8I)\n\n\n#define rgb10_a2ui IMAGE_FORMAT(GL_RGB10_A2UI)\n#define rgba32ui IMAGE_FORMAT(GL_RGBA32UI)\n#define rgba16ui IMAGE_FORMAT(GL_RGBA16UI)\n#define rgba8ui IMAGE_FORMAT(GL_RGBA8UI)\n#define rg32ui IMAGE_FORMAT(GL_RG32UI)\n#define rg16ui IMAGE_FORMAT(GL_RG16UI)\n#define rg8ui IMAGE_FORMAT(GL_RG8UI)\n#define r32ui IMAGE_FORMAT(GL_R32UI)\n#define r16ui IMAGE_FORMAT(GL_R16UI)\n#define r8ui IMAGE_FORMAT(GL_R8UI)\n\n#define READONLY inline_glsl::shader_state.image_access |= 1;\n#define readonly READONLY\n#define WRITEONLY inline_glsl::shader_state.image_access |= 2;\n#define writeonly WRITEONLY\n\n#define coherent\n#define restrict\n\n#define early_fragment_tests\n\n#define glsl_function\n#define glsl_global\n\n#define EmitVertex()\n#define EndPrimitive()\n#define EmitStreamVertex()\n\n#define GLSL_MAIN ();static inline_glsl::ShaderStore __s(__FILE__, __LINE__, inline_glsl::store); return Shader(__s, inline_glsl::store); if constexpr(false)\n#define glsl_main() GLSL_MAIN\n\n#define BIND_DEPTH(a) ();static inline_glsl::ArgStore UNIQUE(a,__LINE__)(#a, a); inline_glsl::Arg UNIQUE(a##_,__LINE__)(UNIQUE(a, __LINE__), DepthTarget(a))\n// bind_depth(texture)\n#define bind_depth(a) BIND_DEPTH(a)\n\nstatic void useShader(const Shader& compute) {\n inline_glsl::useShader(compute, Shader{}, Shader{}, Shader{}, Shader{}, Shader{}, inline_glsl::programs, inline_glsl::shader_state, inline_glsl::store);\n}\nstatic void useShader(const Shader& vertex, const Shader& fragment) {\n inline_glsl::useShader(Shader{}, vertex, Shader{}, Shader{}, Shader{}, fragment, inline_glsl::programs, inline_glsl::shader_state, inline_glsl::store);\n}\nstatic void useShader(const Shader& vertex, const Shader& geometry, const Shader& fragment) {\n inline_glsl::useShader(Shader{}, vertex, geometry, Shader{}, Shader{}, fragment, inline_glsl::programs, inline_glsl::shader_state, inline_glsl::store);\n}\nstatic void useShader(const Shader& vertex, const Shader& control, const Shader& evaluation, const Shader& fragment) {\n inline_glsl::useShader(Shader{}, vertex, Shader{}, control, evaluation, fragment, inline_glsl::programs, inline_glsl::shader_state, inline_glsl::store);\n}\nstatic void useShader(const Shader& vertex, const Shader& geometry, const Shader& control, const Shader& evaluation, const Shader& fragment) {\n inline_glsl::useShader(Shader{}, vertex, geometry, control, evaluation, fragment, inline_glsl::programs, inline_glsl::shader_state, inline_glsl::store);\n}\n\ninline const Texture<> screen = {};\ninline const Texture<> screen_depth = {};\n"}, {"path": "impl/shader_types.h", "language": "c", "loc": 354, "comment_density": 0.008, "code": "#pragma once\n\n#include \n#include \"gl_helpers.h\"\n\ntemplate\nstruct Image {\n GLuint obj, level, layer;\n Image() : obj(0) { }\n template\n Image(const Texture& t) : obj(t), level(t.level), layer(t.layer) { }\n operator int() { return obj; }\n bool operator !=(const Image& other) {\n return obj != other.obj;\n }\n};\n\n#define IMAGEBASIC(name, sizetype, prefix, ...)\\\ninline sizetype imageSize(prefix##name image) { return {}; }\\\ninline prefix##vec4 imageLoad(prefix##name image, __VA_ARGS__) { return {}; }\\\ninline void imageStore(prefix##name image, __VA_ARGS__, prefix##vec4 data) { }\\\n\n#define IMAGEATOMIC(func, name, ...)\\\ninline int func(i##name, __VA_ARGS__, int data){ return {}; }\\\ninline uint func(u##name, __VA_ARGS__, uint data){ return {}; }\n\n#define IMAGEDEF(name, glenum, sizetype, ...)\\\nusing name = Image < glenum, float>;\\\nusing i ## name = Image < glenum, int>;\\\nusing u ## name = Image < glenum, uint>;\\\nIMAGEBASIC(name, sizetype, , __VA_ARGS__)\\\nIMAGEBASIC(name, sizetype, i, __VA_ARGS__)\\\nIMAGEBASIC(name, sizetype, u, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicAdd, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicMin, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicMax, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicAnd, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicOr, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicXor, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicExchange, name, __VA_ARGS__)\\\nIMAGEATOMIC(imageAtomicCompSwap, name, __VA_ARGS__)\n\nIMAGEDEF(image1D, GL_TEXTURE_1D, int, int P)\nIMAGEDEF(image2D, GL_TEXTURE_2D, ivec2, ivec2 P)\nIMAGEDEF(image3D, GL_TEXTURE_3D, ivec3, ivec3 P)\nIMAGEDEF(imageCube, GL_TEXTURE_CUBE_MAP, ivec2, ivec3 P)\nIMAGEDEF(image2DRect, GL_TEXTURE_RECTANGLE, ivec2, ivec2 P)\nIMAGEDEF(image1DArray, GL_TEXTURE_1D_ARRAY, ivec2, ivec2 P)\nIMAGEDEF(image2DArray, GL_TEXTURE_2D_ARRAY, ivec3, ivec3 P)\nIMAGEDEF(imageCubeArray, GL_TEXTURE_CUBE_MAP_ARRAY, ivec3, ivec3 P)\nIMAGEDEF(imageBuffer, GL_TEXTURE_BUFFER, int, int P)\nIMAGEDEF(image2DMS, GL_TEXTURE_2D_MULTISAMPLE, ivec2, ivec2 P, int sample)\nIMAGEDEF(image2DMSArray, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, ivec3, ivec3 P, int sample)\n\ninline int imageSamples(image2DMS image) { return 0; }\ninline int imageSamples(iimage2DMS image) { return 0; }\ninline int imageSamples(uimage2DMS image) { return 0; }\ninline int imageSamples(image2DMSArray image) { return 0; }\ninline int imageSamples(iimage2DMSArray image) { return 0; }\ninline int imageSamples(uimage2DMSArray image) { return 0; }\n\n#undef IMAGEBASIC\n#undef IMAGEATOMIC\n#undef IMAGEDEF\n\ntemplate\nstruct Sampler {\n GLuint obj;\n Sampler() : obj(0) { }\n Sampler(uint64_t) : obj(0) { }\n template\n Sampler(const Texture& t) : obj(t) {}\n operator int() { return obj; }\n bool operator !=(const Sampler& other) {\n return obj != other.obj;\n }\n};\n\n#define COMMA ,\n\n#define SAMPLEFUNC(func, name, params)\\\ninline vec4 func(name sampler params) {return {};}\\\ninline ivec4 func(i##name sampler params) {return {};}\\\ninline uvec4 func(u##name sampler params) {return {};}\n\n#define TEXFUNC(func, name, params)\\\ninline func(name sampler params) { return {}; }\\\ninline func(i##name sampler params) { return {}; }\\\ninline func(u##name sampler params) { return {}; }\n\n#define MIPPABLE(name, glenum, sizetype)\\\nusing name = Sampler;\\\nusing i ## name= Sampler;\\\nusing u ## name = Sampler;\\\nTEXFUNC(sizetype textureSize, name,COMMA int lod)\\\nTEXFUNC(int textureQueryLevels, name,)\n\n#define UNMIPPABLE(name, glenum, sizetype)\\\nusing name = Sampler;\\\nusing i ## name= Sampler;\\\nusing u ## name = Sampler;\\\nTEXFUNC(sizetype textureSize, name,)\n\nMIPPABLE(sampler1D, GL_TEXTURE_1D, int)\nMIPPABLE(sampler2D, GL_TEXTURE_2D, ivec2)\nMIPPABLE(sampler3D, GL_TEXTURE_3D, ivec3)\nMIPPABLE(samplerCube, GL_TEXTURE_CUBE_MAP, ivec2)\nMIPPABLE(sampler1DArray, GL_TEXTURE_1D_ARRAY, ivec2)\nMIPPABLE(sampler2DArray, GL_TEXTURE_2D_ARRAY, ivec3)\nMIPPABLE(samplerCubeArray, GL_TEXTURE_CUBE_MAP_ARRAY, ivec3)\n\nUNMIPPABLE(sampler2DRect, GL_TEXTURE_RECTANGLE, ivec2)\nUNMIPPABLE(samplerBuffer, GL_TEXTURE_BUFFER, int)\nUNMIPPABLE(sampler2DMS, GL_TEXTURE_2D_MULTISAMPLE, ivec2)\nUNMIPPABLE(sampler2DMSArray, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, ivec3)\n\ninline int textureSamples(sampler2DMS image) { return 0; }\ninline int textureSamples(isampler2DMS image) { return 0; }\ninline int textureSamples(usampler2DMS image) { return 0; }\ninline int textureSamples(sampler2DMSArray image) { return 0; }\ninline int textureSamples(isampler2DMSArray image) { return 0; }\ninline int textureSamples(usampler2DMSArray image) { return 0; }\n\n#define MIPPABLE_SHADOW(name, glenum, sizetype)\\\nusing name = Sampler;\\\ninline sizetype textureSize(name sampler, int lod) {return {};}\\\ninline int textureQueryLevels(name sampler) {return 0;}\n\nMIPPABLE_SHADOW(sampler1DShadow, GL_TEXTURE_1D, int)\nMIPPABLE_SHADOW(sampler2DShadow, GL_TEXTURE_2D, ivec2)\nMIPPABLE_SHADOW(samplerCubeShadow, GL_TEXTURE_CUBE_MAP, ivec2)\nMIPPABLE_SHADOW(sampler1DArrayShadow, GL_TEXTURE_1D_ARRAY, ivec2)\nMIPPABLE_SHADOW(sampler2DArrayShadow, GL_TEXTURE_2D_ARRAY, ivec3)\nMIPPABLE_SHADOW(samplerCubeArrayShadow, GL_TEXTURE_CUBE_MAP_ARRAY, ivec3)\nusing sampler2DRectShadow = Sampler;\ninline ivec2 textureSize(sampler2DRectShadow sampler) { return {}; }\n\n\nSAMPLEFUNC(texelFetch, sampler1D, COMMA int P COMMA int lod)\nSAMPLEFUNC(texelFetch, sampler2D, COMMA ivec2 P COMMA int lod)\nSAMPLEFUNC(texelFetch, sampler3D, COMMA ivec3 P COMMA int lod)\nSAMPLEFUNC(texelFetch, sampler2DRect, COMMA ivec2 P)\nSAMPLEFUNC(texelFetch, sampler1DArray, COMMA ivec2 P COMMA int lod)\nSAMPLEFUNC(texelFetch, sampler2DArray, COMMA ivec3 P COMMA int lod)\nSAMPLEFUNC(texelFetch, samplerBuffer, COMMA int P)\nSAMPLEFUNC(texelFetch, sampler2DMS, COMMA ivec2 P COMMA int sample)\nSAMPLEFUNC(texelFetch, sampler2DMSArray, COMMA ivec3 P COMMA int sample)\n\nSAMPLEFUNC(texelFetchOffset, sampler1D, COMMA int P COMMA int lod COMMA int offset)\nSAMPLEFUNC(texelFetchOffset, sampler2D, COMMA ivec2 P COMMA int lod COMMA ivec2 offset)\nSAMPLEFUNC(texelFetchOffset, sampler3D, COMMA ivec3 P COMMA int lod COMMA ivec3 offset)\nSAMPLEFUNC(texelFetchOffset, sampler2DRect, COMMA ivec2 P COMMA ivec2 offset)\nSAMPLEFUNC(texelFetchOffset, sampler1DArray, COMMA ivec2 P COMMA int lod COMMA ivec2 offset)\nSAMPLEFUNC(texelFetchOffset, sampler2DArray, COMMA ivec3 P COMMA int lod COMMA ivec3 offset)\n\nSAMPLEFUNC(texture, sampler1D, COMMA float P COMMA float bias = .0f)\nSAMPLEFUNC(texture, sampler2D, COMMA vec2 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, sampler3D, COMMA vec3 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, samplerCube, COMMA vec3 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, sampler1DArray, COMMA vec2 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, sampler2DArray, COMMA vec3 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, samplerCubeArray, COMMA vec4 P COMMA float bias = .0f)\nSAMPLEFUNC(texture, sampler2DRect, COMMA vec2 P)\ninline float texture(sampler1DShadow sampler, vec3 P, float bias = .0f) { return {}; } // ... why does this take in a vec3???\ninline float texture(sampler2DShadow sampler, vec3 P, float bias = .0f) { return {}; }\ninline float texture(samplerCubeShadow sampler, vec4 P, float bias = .0f) { return {}; }\ninline float texture(sampler1DArrayShadow sampler, vec3 P, float bias = .0f) { return {}; }\ninline float texture(sampler2DArrayShadow sampler, vec4 P, float bias = .0f) { return {}; }\ninline float texture(sampler2DRectShadow sampler, vec3 P) { return {}; }\ninline float texture(samplerCubeArrayShadow sampler, vec4 P, float compare) { return {}; }\n\nSAMPLEFUNC(textureGather, sampler2D, COMMA vec2 P COMMA int comp = 0)\nSAMPLEFUNC(textureGather, sampler2DArray, COMMA vec3 P COMMA int comp = 0)\nSAMPLEFUNC(textureGather, samplerCube, COMMA vec3 P COMMA int comp = 0)\nSAMPLEFUNC(textureGather, samplerCubeArray, COMMA vec4 P COMMA int comp = 0)\nSAMPLEFUNC(textureGather, sampler2DRect, COMMA vec2 P COMMA int comp = 0)\ninline float textureGather(sampler2DShadow sampler, vec2 P, float refZ) { return {}; }\ninline float textureGather(sampler2DArrayShadow sampler, vec3 P, float refZ) { return {}; }\ninline float textureGather(samplerCubeShadow sampler, vec3 P, float refZ) { return {}; }\ninline float textureGather(samplerCubeArrayShadow sampler, vec4 P, float refZ) { return {}; }\ninline float textureGather(sampler2DRectShadow sampler, vec2 P, float refZ) { return {}; }\n\nSAMPLEFUNC(textureGatherOffset, sampler2D, COMMA vec2 P COMMA ivec2 offset COMMA int comp = 0)\nSAMPLEFUNC(textureGatherOffset, sampler2DArray, COMMA vec3 P COMMA ivec2 offset COMMA int comp = 0)\nSAMPLEFUNC(textureGatherOffset, sampler2DRect, COMMA vec2 P COMMA ivec2 offset COMMA int comp = 0)\ninline float textureGatherOffset(sampler2DShadow sampler, vec2 P, float refZ, ivec2 offset) { return {}; }\ninline float textureGatherOffset(sampler2DArrayShadow sampler, vec3 P, float refZ, ivec2 offset) { return {}; }\ninline float textureGatherOffset(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2 offset) { return {}; }\n\n\nSAMPLEFUNC(textureGatherOffsets, sampler2D, COMMA vec2 P COMMA ivec2 offsets[4] COMMA int comp = 0)\nSAMPLEFUNC(textureGatherOffsets, sampler2DArray, COMMA vec3 P COMMA ivec2 offsets[4] COMMA int comp = 0)\nSAMPLEFUNC(textureGatherOffsets, sampler2DRect, COMMA vec2 P COMMA ivec2 offsets[4] COMMA int comp = 0)\ninline float textureGatherOffsets(sampler2DShadow sampler, vec2 P, float refZ, ivec2 offsets[4]) { return {}; }\ninline float textureGatherOffsets(sampler2DArrayShadow sampler, vec3 P, float refZ, ivec2 offsets[4]) { return {}; }\ninline float textureGatherOffsets(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2 offsets[4]) { return {}; }\n\nSAMPLEFUNC(textureGrad, sampler1D, COMMA float P COMMA float dPdx COMMA float dPdy)\nSAMPLEFUNC(textureGrad, sampler2D, COMMA vec2 P COMMA vec2 dPdx COMMA vec2 dPdy)\nSAMPLEFUNC(textureGrad, sampler3D, COMMA vec3 P COMMA vec3 dPdx COMMA vec3 dPdy)\nSAMPLEFUNC(textureGrad, samplerCube, COMMA vec3 P COMMA vec3 dPdx COMMA vec3 dPdy)\nSAMPLEFUNC(textureGrad, sampler1DArray, COMMA vec2 P COMMA float dPdx COMMA float dPdy)\nSAMPLEFUNC(textureGrad, sampler2DArray, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy)\nSAMPLEFUNC(textureGrad, samplerCubeArray, COMMA vec4 P COMMA vec3 dPdx COMMA vec3 dPdy)\nSAMPLEFUNC(textureGrad, sampler2DRect, COMMA vec2 P COMMA vec2 dPdx COMMA vec2 dPdy)\ninline float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy) { return {}; }\ninline float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy) { return {}; }\ninline float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy) { return {}; }\ninline float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy) { return {}; }\ninline float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy) { return {}; }\ninline float textureGrad(sampler2DRectShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy) { return {}; }\n\nSAMPLEFUNC(textureGradOffset, sampler1D, COMMA float P COMMA float dPdx COMMA float dPdy COMMA int offset)\nSAMPLEFUNC(textureGradOffset, sampler2D, COMMA vec2 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\nSAMPLEFUNC(textureGradOffset, sampler3D, COMMA vec3 P COMMA vec3 dPdx COMMA vec3 dPdy COMMA ivec3 offset)\nSAMPLEFUNC(textureGradOffset, sampler1DArray, COMMA vec2 P COMMA float dPdx COMMA float dPdy COMMA int offset)\nSAMPLEFUNC(textureGradOffset, sampler2DArray, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\nSAMPLEFUNC(textureGradOffset, sampler2DRect, COMMA vec2 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\ninline float textureGradOffset(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy, int offset) { return {}; }\ninline float textureGradOffset(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset) { return {}; }\ninline float textureGradOffset(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy, int offset) { return {}; }\ninline float textureGradOffset(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset) { return {}; }\ninline float textureGradOffset(sampler2DRectShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset) { return {}; }\n\nSAMPLEFUNC(textureLod, sampler1D, COMMA float P COMMA float lod)\nSAMPLEFUNC(textureLod, sampler2D, COMMA vec2 P COMMA float lod)\nSAMPLEFUNC(textureLod, sampler3D, COMMA vec3 P COMMA float lod)\nSAMPLEFUNC(textureLod, samplerCube, COMMA vec3 P COMMA float lod)\nSAMPLEFUNC(textureLod, sampler1DArray, COMMA vec2 P COMMA float lod)\nSAMPLEFUNC(textureLod, sampler2DArray, COMMA vec3 P COMMA float lod)\nSAMPLEFUNC(textureLod, samplerCubeArray, COMMA vec4 P COMMA float lod)\ninline float textureLod(sampler1DShadow sampler, vec3 P, float lod) { return {}; }\ninline float textureLod(sampler2DShadow sampler, vec3 P, float lod) { return {}; }\ninline float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod) { return {}; }\n\nSAMPLEFUNC(textureLodOffset, sampler1D, COMMA float P COMMA float lod COMMA int offset)\nSAMPLEFUNC(textureLodOffset, sampler2D, COMMA vec2 P COMMA float lod COMMA ivec2 offset)\nSAMPLEFUNC(textureLodOffset, sampler3D, COMMA vec3 P COMMA float lod COMMA ivec3 offset)\nSAMPLEFUNC(textureLodOffset, sampler1DArray, COMMA vec2 P COMMA float lod COMMA int offset)\nSAMPLEFUNC(textureLodOffset, sampler2DArray, COMMA vec3 P COMMA float lod COMMA ivec2 offset)\ninline float textureLodOffset(sampler1DShadow sampler, vec3 P, float lod, int offset) { return {}; }\ninline float textureLodOffset(sampler2DShadow sampler, vec3 P, float lod, ivec2 offset) { return {}; }\ninline float textureLodOffset(sampler1DArrayShadow sampler, vec3 P, float lod, int offset) { return {}; }\n\nSAMPLEFUNC(textureProjLod, sampler1D, COMMA vec2 P COMMA float lod)\nSAMPLEFUNC(textureProjLod, sampler1D, COMMA vec4 P COMMA float lod)\nSAMPLEFUNC(textureProjLod, sampler2D, COMMA vec3 P COMMA float lod)\nSAMPLEFUNC(textureProjLod, sampler2D, COMMA vec4 P COMMA float lod)\nSAMPLEFUNC(textureProjLod, sampler3D, COMMA vec4 P COMMA float lod)\ninline float textureProjLod(sampler1DShadow sampler, vec4 P, float lod) { return {}; }\ninline float textureProjLod(sampler2DShadow sampler, vec4 P, float lod) { return {}; }\n\nSAMPLEFUNC(textureProjLodOffset, sampler1D, COMMA vec2 P COMMA float lod COMMA int offset)\nSAMPLEFUNC(textureProjLodOffset, sampler1D, COMMA vec4 P COMMA float lod COMMA int offset)\nSAMPLEFUNC(textureProjLodOffset, sampler2D, COMMA vec3 P COMMA float lod COMMA ivec2 offset)\nSAMPLEFUNC(textureProjLodOffset, sampler2D, COMMA vec4 P COMMA float lod COMMA ivec2 offset)\nSAMPLEFUNC(textureProjLodOffset, sampler3D, COMMA vec4 P COMMA float lod COMMA ivec3 offset)\ninline float textureProjLodOffset(sampler1DShadow sampler, vec4 P, float lod, int offset) { return {}; }\ninline float textureProjLodOffset(sampler2DShadow sampler, vec4 P, float lod, ivec2 offset) { return {}; }\n\nSAMPLEFUNC(textureProj, sampler1D, COMMA vec2 P COMMA float bias = .0f)\nSAMPLEFUNC(textureProj, sampler1D, COMMA vec4 P COMMA float bias = .0f)\nSAMPLEFUNC(textureProj, sampler2D, COMMA vec3 P COMMA float bias = .0f)\nSAMPLEFUNC(textureProj, sampler2D, COMMA vec4 P COMMA float bias = .0f)\nSAMPLEFUNC(textureProj, sampler3D, COMMA vec4 P COMMA float bias = .0f)\nSAMPLEFUNC(textureProj, sampler2DRect, COMMA vec3 P)\nSAMPLEFUNC(textureProj, sampler2DRect, COMMA vec4 P)\ninline float textureProj(sampler1DShadow sampler, vec4 P, float bias = .0f) { return {}; }\ninline float textureProj(sampler2DShadow sampler, vec4 P, float bias = .0f) { return {}; }\ninline float textureProj(sampler2DRectShadow sampler, vec4 P) { return {}; }\n\nSAMPLEFUNC(textureOffset, sampler1D, COMMA float P COMMA int offset COMMA float bias = .0f)\nSAMPLEFUNC(textureOffset, sampler2D, COMMA vec2 P COMMA ivec2 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureOffset, sampler3D, COMMA vec3 P COMMA ivec3 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureOffset, sampler1DArray, COMMA vec2 P COMMA int offset COMMA float bias = .0f)\nSAMPLEFUNC(textureOffset, sampler2DArray, COMMA vec3 P COMMA ivec2 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureOffset, sampler2DRect, COMMA vec2 P COMMA ivec2 offset)\ninline float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias = .0f) { return {}; } // ... why does this take in a vec3???\ninline float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias = .0f) { return {}; }\ninline float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset, float bias = .0f) { return {}; }\ninline float textureOffset(sampler2DArrayShadow sampler, vec4 P, ivec2 offset, float bias = .0f) { return {}; }\ninline float textureOffset(sampler2DRectShadow sampler, vec3 P, ivec2 offset) { return {}; }\n\nSAMPLEFUNC(textureProjGrad, sampler1D, COMMA vec2 P COMMA float dPdx COMMA float dPdy)\nSAMPLEFUNC(textureProjGrad, sampler1D, COMMA vec4 P COMMA float dPdx COMMA float dPdy)\nSAMPLEFUNC(textureProjGrad, sampler2D, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy)\nSAMPLEFUNC(textureProjGrad, sampler2D, COMMA vec4 P COMMA vec2 dPdx COMMA vec2 dPdy)\nSAMPLEFUNC(textureProjGrad, sampler3D, COMMA vec4 P COMMA vec3 dPdx COMMA vec3 dPdy)\nSAMPLEFUNC(textureProjGrad, sampler2DRect, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy)\nSAMPLEFUNC(textureProjGrad, sampler2DRect, COMMA vec4 P COMMA vec2 dPdx COMMA vec2 dPdy)\ninline float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy) { return {}; }\ninline float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy) { return {}; }\ninline float textureProjGrad(sampler2DRectShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy) { return {}; }\n\nSAMPLEFUNC(textureProjGradOffset, sampler1D, COMMA vec2 P COMMA float dPdx COMMA float dPdy COMMA int offset)\nSAMPLEFUNC(textureProjGradOffset, sampler1D, COMMA vec4 P COMMA float dPdx COMMA float dPdy COMMA int offset)\nSAMPLEFUNC(textureProjGradOffset, sampler2D, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\nSAMPLEFUNC(textureProjGradOffset, sampler2D, COMMA vec4 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\nSAMPLEFUNC(textureProjGradOffset, sampler3D, COMMA vec4 P COMMA vec3 dPdx COMMA vec3 dPdy COMMA ivec3 offset)\nSAMPLEFUNC(textureProjGradOffset, sampler2DRect, COMMA vec3 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\nSAMPLEFUNC(textureProjGradOffset, sampler2DRect, COMMA vec4 P COMMA vec2 dPdx COMMA vec2 dPdy COMMA ivec2 offset)\ninline float textureProjGradOffset(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy, int offset) { return {}; }\ninline float textureProjGradOffset(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset) { return {}; }\ninline float textureProjGradOffset(sampler2DRectShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset) { return {}; }\n\nSAMPLEFUNC(textureProjOffset, sampler1D, COMMA vec2 P COMMA int offset COMMA float bias = .0f)\nSAMPLEFUNC(textureProjOffset, sampler1D, COMMA vec4 P COMMA int offset COMMA float bias = .0f)\nSAMPLEFUNC(textureProjOffset, sampler2D, COMMA vec3 P COMMA ivec2 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureProjOffset, sampler2D, COMMA vec4 P COMMA ivec2 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureProjOffset, sampler3D, COMMA vec4 P COMMA ivec3 offset COMMA float bias = .0f)\nSAMPLEFUNC(textureProjOffset, sampler2DRect, COMMA vec3 P COMMA ivec2 offset)\nSAMPLEFUNC(textureProjOffset, sampler2DRect, COMMA vec4 P COMMA ivec2 offset)\ninline float textureProjOffset(sampler1DShadow sampler, vec4 P, int offset, float bias = .0f) { return {}; }\ninline float textureProjOffset(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias = .0f) { return {}; }\ninline float textureProjOffset(sampler2DRectShadow sampler, vec4 P, ivec2 offset) { return {}; }\n\nTEXFUNC(vec2 textureQueryLod, sampler1D, COMMA float P)\nTEXFUNC(vec2 textureQueryLod, sampler2D, COMMA vec2 P)\nTEXFUNC(vec2 textureQueryLod, sampler3D, COMMA vec3 P)\nTEXFUNC(vec2 textureQueryLod, samplerCube, COMMA vec3 P)\nTEXFUNC(vec2 textureQueryLod, sampler1DArray, COMMA float P)\nTEXFUNC(vec2 textureQueryLod, sampler2DArray, COMMA vec2 P)\nTEXFUNC(vec2 textureQueryLod, samplerCubeArray, COMMA vec3 P)\ninline vec2 textureQueryLod(sampler1DShadow sampler, float P) { return {}; } // ... why does this take in a vec3???\ninline vec2 textureQueryLod(sampler2DShadow sampler, vec2 P) { return {}; }\ninline vec2 textureQueryLod(samplerCubeShadow sampler, vec3 P) { return {}; }\ninline vec2 textureQueryLod(sampler1DArrayShadow sampler, float P) { return {}; }\ninline vec2 textureQueryLod(sampler2DArrayShadow sampler, vec2 P) { return {}; }\ninline vec2 textureQueryLod(samplerCubeArrayShadow sampler, vec3 P) { return {}; }\n\n#undef COMMA\n#undef SAMPLEFUNC\n#undef TEXFUNC\n#undef MIPPABLE\n#undef UNMIPPABLE\n#undef MIPPABLE_SHADOW\n\nstruct Target {\n GLuint obj, level, layer, type;\n Target() : obj(0) {}\n template\n Target(const Texture& t) : obj(t), level(t.level), layer(t.layer), type(t.target) { }\n operator int() { return obj; }\n bool operator !=(const Target& other) {\n return obj != other.obj;\n }\n};\n\nstruct DepthTarget {\n GLuint obj, level, layer, type;\n template\n DepthTarget(const Texture& t) : obj(t), level(t.level), layer(t.layer), type(t.target) { }\n operator int() { return obj; }\n bool operator !=(const DepthTarget& other) {\n return obj != other.obj;\n }\n};\n\nstruct UBO {\n GLuint obj;\n UBO(const Buffer& t) : obj(t) {}\n operator int() { return obj; };\n bool operator!=(const UBO& other) {\n return obj != other.obj;\n }\n};\nstruct SSBO {\n GLuint obj;\n SSBO(const Buffer& t) : obj(t) {}\n operator int() { return obj; };\n bool operator!=(const SSBO& other) {\n return obj != other.obj;\n }\n};\n\ntemplate\nstruct Attribute {\n GLuint obj, stride, offset, type;\n bool normalized;\n Attribute(const Buffer& b, int stride, int offset = 0, GLuint type = -1, bool normalized = false)\n : obj(b), stride(stride), offset(offset), type(type), normalized(normalized)\n {\n if (this->type == -1) {\n if constexpr (glsl::same, float>)\n this->type = GL_FLOAT;\n else if constexpr (glsl::same, int>)\n this->type = GL_INT;\n else if constexpr (glsl::same, uint>)\n this->type = GL_UNSIGNED_INT;\n else\n printf(\"vertex attribute type not given and couldn't be deduced from T in Attribute\\n\");\n }\n }\n\n operator int() { return obj; }\n bool operator!=(const Attribute& other) {\n return obj != other.obj || stride != other.stride || offset != other.offset || type != other.type || normalized != other.normalized;\n }\n};\n"}, {"path": "impl/ssgl.h", "language": "c", "loc": 4, "comment_density": 0.0, "code": "#pragma once\n\n#include \"window.h\"\n#include \"inline_glsl.h\"\n#include \"gl_timing.h\"\n"}], "validation": {"glslang_valid": 0, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "MIT", "non_commercial": false, "comment_density": 0.023, "dedup_hash": "9942bbbbbd69206f", "has_readme": true, "build_system": "make", "dependency_count": 31, "has_demo": false} -{"id": "ssgl_utils", "source": "https://github.com/local/ssgl", "source_commit": "4d3f2977620be74782a6523fc950e98c0b7f69bb", "collected_at": "2026-08-17T14:37:31+00:00", "source_type": "repo", "title": "Utils", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "texturing/framebuffer/basics", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "utils/gl_timing.h", "language": "c", "loc": 49, "comment_density": 0.163, "code": "#pragma once\n\n#include \n\n#include \n#include \"glext.h\"\n#include \"loadgl46.h\"\n\n// GPU timing object\nstruct TimeStamp {\n\t// todo: move construct, etc? might want map of string to stamp for global use\n\tGLint64 asynchronous;\n\tGLuint synchronousObject;\n\tmutable GLuint available = GL_FALSE;\n\tmutable GLint64 synchronous;\n\tTimeStamp() {\n\t\t// create GPU query\n\t\tglCreateQueries(GL_TIMESTAMP, 1, &synchronousObject);\n\t\tglQueryCounter(synchronousObject, GL_TIMESTAMP);\n\t\t// query CPU counter directly\n\t\tglGetInteger64v(GL_TIMESTAMP, &asynchronous);\n\t}\n\tvoid check() const {\n\t\twhile (available == GL_FALSE) {\n\t\t\tglGetQueryObjectuiv(synchronousObject, GL_QUERY_RESULT_AVAILABLE, &available);\n\t\t\tif(available == GL_TRUE)\n\t\t\t\tglGetQueryObjecti64v(synchronousObject, GL_QUERY_RESULT, &synchronous);\n\t\t}\n\t}\n\t// latency between CPU call and GPU execution, in ms\n\tdouble latency() const {\n\t\tcheck();\n\t\treturn double(synchronous - asynchronous)*1.0e-6;\n\t}\n\t~TimeStamp() {\n\t\tglDeleteQueries(1, &synchronousObject);\n\t}\n};\n\n// GPU time between two stamps, ms\ninline double operator-(const TimeStamp& end, const TimeStamp& begin) {\n\tbegin.check();\n\tend.check();\n\treturn double(end.synchronous - begin.synchronous)*1.0e-6;\n}\n\n// GPU time between two stamps, ms\ninline double gpuTime(const TimeStamp& begin, const TimeStamp& end) {\n\treturn end - begin;\n}\n\n// CPU-side time between two stamps, ms\ninline double cpuTime(const TimeStamp& begin, const TimeStamp& end) {\n\treturn double(end.asynchronous - begin.asynchronous)*1.0e-6;\n}\n"}, {"path": "utils/glext.h", "language": "c", "loc": 12484, "comment_density": 0.065}, {"path": "utils/loadgl46.cpp", "language": "cpp", "loc": 2312, "comment_density": 0.0}, {"path": "utils/loadgl46.h", "language": "c", "loc": 767, "comment_density": 0.0, "code": "#pragma once\nint loadgl();\nvoid unloadgl();\nextern PFNGLDRAWRANGEELEMENTSPROC ptr_glDrawRangeElements; void glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\nextern PFNGLTEXIMAGE3DPROC ptr_glTexImage3D; void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\nextern PFNGLTEXSUBIMAGE3DPROC ptr_glTexSubImage3D; void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nextern PFNGLCOPYTEXSUBIMAGE3DPROC ptr_glCopyTexSubImage3D; void glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nextern PFNGLACTIVETEXTUREPROC ptr_glActiveTexture; void glActiveTexture(GLenum texture);\nextern PFNGLSAMPLECOVERAGEPROC ptr_glSampleCoverage; void glSampleCoverage(GLfloat value, GLboolean invert);\nextern PFNGLCOMPRESSEDTEXIMAGE3DPROC ptr_glCompressedTexImage3D; void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXIMAGE2DPROC ptr_glCompressedTexImage2D; void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXIMAGE1DPROC ptr_glCompressedTexImage1D; void glCompressedTexImage1D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC ptr_glCompressedTexSubImage3D; void glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC ptr_glCompressedTexSubImage2D; void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC ptr_glCompressedTexSubImage1D; void glCompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLGETCOMPRESSEDTEXIMAGEPROC ptr_glGetCompressedTexImage; void glGetCompressedTexImage(GLenum target, GLint level, void *img);\nextern PFNGLCLIENTACTIVETEXTUREPROC ptr_glClientActiveTexture; void glClientActiveTexture(GLenum texture);\nextern PFNGLMULTITEXCOORD1DPROC ptr_glMultiTexCoord1d; void glMultiTexCoord1d(GLenum target, GLdouble s);\nextern PFNGLMULTITEXCOORD1DVPROC ptr_glMultiTexCoord1dv; void glMultiTexCoord1dv(GLenum target, const GLdouble *v);\nextern PFNGLMULTITEXCOORD1FPROC ptr_glMultiTexCoord1f; void glMultiTexCoord1f(GLenum target, GLfloat s);\nextern PFNGLMULTITEXCOORD1FVPROC ptr_glMultiTexCoord1fv; void glMultiTexCoord1fv(GLenum target, const GLfloat *v);\nextern PFNGLMULTITEXCOORD1IPROC ptr_glMultiTexCoord1i; void glMultiTexCoord1i(GLenum target, GLint s);\nextern PFNGLMULTITEXCOORD1IVPROC ptr_glMultiTexCoord1iv; void glMultiTexCoord1iv(GLenum target, const GLint *v);\nextern PFNGLMULTITEXCOORD1SPROC ptr_glMultiTexCoord1s; void glMultiTexCoord1s(GLenum target, GLshort s);\nextern PFNGLMULTITEXCOORD1SVPROC ptr_glMultiTexCoord1sv; void glMultiTexCoord1sv(GLenum target, const GLshort *v);\nextern PFNGLMULTITEXCOORD2DPROC ptr_glMultiTexCoord2d; void glMultiTexCoord2d(GLenum target, GLdouble s, GLdouble t);\nextern PFNGLMULTITEXCOORD2DVPROC ptr_glMultiTexCoord2dv; void glMultiTexCoord2dv(GLenum target, const GLdouble *v);\nextern PFNGLMULTITEXCOORD2FPROC ptr_glMultiTexCoord2f; void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t);\nextern PFNGLMULTITEXCOORD2FVPROC ptr_glMultiTexCoord2fv; void glMultiTexCoord2fv(GLenum target, const GLfloat *v);\nextern PFNGLMULTITEXCOORD2IPROC ptr_glMultiTexCoord2i; void glMultiTexCoord2i(GLenum target, GLint s, GLint t);\nextern PFNGLMULTITEXCOORD2IVPROC ptr_glMultiTexCoord2iv; void glMultiTexCoord2iv(GLenum target, const GLint *v);\nextern PFNGLMULTITEXCOORD2SPROC ptr_glMultiTexCoord2s; void glMultiTexCoord2s(GLenum target, GLshort s, GLshort t);\nextern PFNGLMULTITEXCOORD2SVPROC ptr_glMultiTexCoord2sv; void glMultiTexCoord2sv(GLenum target, const GLshort *v);\nextern PFNGLMULTITEXCOORD3DPROC ptr_glMultiTexCoord3d; void glMultiTexCoord3d(GLenum target, GLdouble s, GLdouble t, GLdouble r);\nextern PFNGLMULTITEXCOORD3DVPROC ptr_glMultiTexCoord3dv; void glMultiTexCoord3dv(GLenum target, const GLdouble *v);\nextern PFNGLMULTITEXCOORD3FPROC ptr_glMultiTexCoord3f; void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r);\nextern PFNGLMULTITEXCOORD3FVPROC ptr_glMultiTexCoord3fv; void glMultiTexCoord3fv(GLenum target, const GLfloat *v);\nextern PFNGLMULTITEXCOORD3IPROC ptr_glMultiTexCoord3i; void glMultiTexCoord3i(GLenum target, GLint s, GLint t, GLint r);\nextern PFNGLMULTITEXCOORD3IVPROC ptr_glMultiTexCoord3iv; void glMultiTexCoord3iv(GLenum target, const GLint *v);\nextern PFNGLMULTITEXCOORD3SPROC ptr_glMultiTexCoord3s; void glMultiTexCoord3s(GLenum target, GLshort s, GLshort t, GLshort r);\nextern PFNGLMULTITEXCOORD3SVPROC ptr_glMultiTexCoord3sv; void glMultiTexCoord3sv(GLenum target, const GLshort *v);\nextern PFNGLMULTITEXCOORD4DPROC ptr_glMultiTexCoord4d; void glMultiTexCoord4d(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nextern PFNGLMULTITEXCOORD4DVPROC ptr_glMultiTexCoord4dv; void glMultiTexCoord4dv(GLenum target, const GLdouble *v);\nextern PFNGLMULTITEXCOORD4FPROC ptr_glMultiTexCoord4f; void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nextern PFNGLMULTITEXCOORD4FVPROC ptr_glMultiTexCoord4fv; void glMultiTexCoord4fv(GLenum target, const GLfloat *v);\nextern PFNGLMULTITEXCOORD4IPROC ptr_glMultiTexCoord4i; void glMultiTexCoord4i(GLenum target, GLint s, GLint t, GLint r, GLint q);\nextern PFNGLMULTITEXCOORD4IVPROC ptr_glMultiTexCoord4iv; void glMultiTexCoord4iv(GLenum target, const GLint *v);\nextern PFNGLMULTITEXCOORD4SPROC ptr_glMultiTexCoord4s; void glMultiTexCoord4s(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\nextern PFNGLMULTITEXCOORD4SVPROC ptr_glMultiTexCoord4sv; void glMultiTexCoord4sv(GLenum target, const GLshort *v);\nextern PFNGLLOADTRANSPOSEMATRIXFPROC ptr_glLoadTransposeMatrixf; void glLoadTransposeMatrixf(const GLfloat *m);\nextern PFNGLLOADTRANSPOSEMATRIXDPROC ptr_glLoadTransposeMatrixd; void glLoadTransposeMatrixd(const GLdouble *m);\nextern PFNGLMULTTRANSPOSEMATRIXFPROC ptr_glMultTransposeMatrixf; void glMultTransposeMatrixf(const GLfloat *m);\nextern PFNGLMULTTRANSPOSEMATRIXDPROC ptr_glMultTransposeMatrixd; void glMultTransposeMatrixd(const GLdouble *m);\nextern PFNGLBLENDFUNCSEPARATEPROC ptr_glBlendFuncSeparate; void glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\nextern PFNGLMULTIDRAWARRAYSPROC ptr_glMultiDrawArrays; void glMultiDrawArrays(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);\nextern PFNGLMULTIDRAWELEMENTSPROC ptr_glMultiDrawElements; void glMultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);\nextern PFNGLPOINTPARAMETERFPROC ptr_glPointParameterf; void glPointParameterf(GLenum pname, GLfloat param);\nextern PFNGLPOINTPARAMETERFVPROC ptr_glPointParameterfv; void glPointParameterfv(GLenum pname, const GLfloat *params);\nextern PFNGLPOINTPARAMETERIPROC ptr_glPointParameteri; void glPointParameteri(GLenum pname, GLint param);\nextern PFNGLPOINTPARAMETERIVPROC ptr_glPointParameteriv; void glPointParameteriv(GLenum pname, const GLint *params);\nextern PFNGLFOGCOORDFPROC ptr_glFogCoordf; void glFogCoordf(GLfloat coord);\nextern PFNGLFOGCOORDFVPROC ptr_glFogCoordfv; void glFogCoordfv(const GLfloat *coord);\nextern PFNGLFOGCOORDDPROC ptr_glFogCoordd; void glFogCoordd(GLdouble coord);\nextern PFNGLFOGCOORDDVPROC ptr_glFogCoorddv; void glFogCoorddv(const GLdouble *coord);\nextern PFNGLFOGCOORDPOINTERPROC ptr_glFogCoordPointer; void glFogCoordPointer(GLenum type, GLsizei stride, const void *pointer);\nextern PFNGLSECONDARYCOLOR3BPROC ptr_glSecondaryColor3b; void glSecondaryColor3b(GLbyte red, GLbyte green, GLbyte blue);\nextern PFNGLSECONDARYCOLOR3BVPROC ptr_glSecondaryColor3bv; void glSecondaryColor3bv(const GLbyte *v);\nextern PFNGLSECONDARYCOLOR3DPROC ptr_glSecondaryColor3d; void glSecondaryColor3d(GLdouble red, GLdouble green, GLdouble blue);\nextern PFNGLSECONDARYCOLOR3DVPROC ptr_glSecondaryColor3dv; void glSecondaryColor3dv(const GLdouble *v);\nextern PFNGLSECONDARYCOLOR3FPROC ptr_glSecondaryColor3f; void glSecondaryColor3f(GLfloat red, GLfloat green, GLfloat blue);\nextern PFNGLSECONDARYCOLOR3FVPROC ptr_glSecondaryColor3fv; void glSecondaryColor3fv(const GLfloat *v);\nextern PFNGLSECONDARYCOLOR3IPROC ptr_glSecondaryColor3i; void glSecondaryColor3i(GLint red, GLint green, GLint blue);\nextern PFNGLSECONDARYCOLOR3IVPROC ptr_glSecondaryColor3iv; void glSecondaryColor3iv(const GLint *v);\nextern PFNGLSECONDARYCOLOR3SPROC ptr_glSecondaryColor3s; void glSecondaryColor3s(GLshort red, GLshort green, GLshort blue);\nextern PFNGLSECONDARYCOLOR3SVPROC ptr_glSecondaryColor3sv; void glSecondaryColor3sv(const GLshort *v);\nextern PFNGLSECONDARYCOLOR3UBPROC ptr_glSecondaryColor3ub; void glSecondaryColor3ub(GLubyte red, GLubyte green, GLubyte blue);\nextern PFNGLSECONDARYCOLOR3UBVPROC ptr_glSecondaryColor3ubv; void glSecondaryColor3ubv(const GLubyte *v);\nextern PFNGLSECONDARYCOLOR3UIPROC ptr_glSecondaryColor3ui; void glSecondaryColor3ui(GLuint red, GLuint green, GLuint blue);\nextern PFNGLSECONDARYCOLOR3UIVPROC ptr_glSecondaryColor3uiv; void glSecondaryColor3uiv(const GLuint *v);\nextern PFNGLSECONDARYCOLOR3USPROC ptr_glSecondaryColor3us; void glSecondaryColor3us(GLushort red, GLushort green, GLushort blue);\nextern PFNGLSECONDARYCOLOR3USVPROC ptr_glSecondaryColor3usv; void glSecondaryColor3usv(const GLushort *v);\nextern PFNGLSECONDARYCOLORPOINTERPROC ptr_glSecondaryColorPointer; void glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer);\nextern PFNGLWINDOWPOS2DPROC ptr_glWindowPos2d; void glWindowPos2d(GLdouble x, GLdouble y);\nextern PFNGLWINDOWPOS2DVPROC ptr_glWindowPos2dv; void glWindowPos2dv(const GLdouble *v);\nextern PFNGLWINDOWPOS2FPROC ptr_glWindowPos2f; void glWindowPos2f(GLfloat x, GLfloat y);\nextern PFNGLWINDOWPOS2FVPROC ptr_glWindowPos2fv; void glWindowPos2fv(const GLfloat *v);\nextern PFNGLWINDOWPOS2IPROC ptr_glWindowPos2i; void glWindowPos2i(GLint x, GLint y);\nextern PFNGLWINDOWPOS2IVPROC ptr_glWindowPos2iv; void glWindowPos2iv(const GLint *v);\nextern PFNGLWINDOWPOS2SPROC ptr_glWindowPos2s; void glWindowPos2s(GLshort x, GLshort y);\nextern PFNGLWINDOWPOS2SVPROC ptr_glWindowPos2sv; void glWindowPos2sv(const GLshort *v);\nextern PFNGLWINDOWPOS3DPROC ptr_glWindowPos3d; void glWindowPos3d(GLdouble x, GLdouble y, GLdouble z);\nextern PFNGLWINDOWPOS3DVPROC ptr_glWindowPos3dv; void glWindowPos3dv(const GLdouble *v);\nextern PFNGLWINDOWPOS3FPROC ptr_glWindowPos3f; void glWindowPos3f(GLfloat x, GLfloat y, GLfloat z);\nextern PFNGLWINDOWPOS3FVPROC ptr_glWindowPos3fv; void glWindowPos3fv(const GLfloat *v);\nextern PFNGLWINDOWPOS3IPROC ptr_glWindowPos3i; void glWindowPos3i(GLint x, GLint y, GLint z);\nextern PFNGLWINDOWPOS3IVPROC ptr_glWindowPos3iv; void glWindowPos3iv(const GLint *v);\nextern PFNGLWINDOWPOS3SPROC ptr_glWindowPos3s; void glWindowPos3s(GLshort x, GLshort y, GLshort z);\nextern PFNGLWINDOWPOS3SVPROC ptr_glWindowPos3sv; void glWindowPos3sv(const GLshort *v);\nextern PFNGLBLENDCOLORPROC ptr_glBlendColor; void glBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nextern PFNGLBLENDEQUATIONPROC ptr_glBlendEquation; void glBlendEquation(GLenum mode);\nextern PFNGLGENQUERIESPROC ptr_glGenQueries; void glGenQueries(GLsizei n, GLuint *ids);\nextern PFNGLDELETEQUERIESPROC ptr_glDeleteQueries; void glDeleteQueries(GLsizei n, const GLuint *ids);\nextern PFNGLISQUERYPROC ptr_glIsQuery; GLboolean glIsQuery(GLuint id);\nextern PFNGLBEGINQUERYPROC ptr_glBeginQuery; void glBeginQuery(GLenum target, GLuint id);\nextern PFNGLENDQUERYPROC ptr_glEndQuery; void glEndQuery(GLenum target);\nextern PFNGLGETQUERYIVPROC ptr_glGetQueryiv; void glGetQueryiv(GLenum target, GLenum pname, GLint *params);\nextern PFNGLGETQUERYOBJECTIVPROC ptr_glGetQueryObjectiv; void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params);\nextern PFNGLGETQUERYOBJECTUIVPROC ptr_glGetQueryObjectuiv; void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params);\nextern PFNGLBINDBUFFERPROC ptr_glBindBuffer; void glBindBuffer(GLenum target, GLuint buffer);\nextern PFNGLDELETEBUFFERSPROC ptr_glDeleteBuffers; void glDeleteBuffers(GLsizei n, const GLuint *buffers);\nextern PFNGLGENBUFFERSPROC ptr_glGenBuffers; void glGenBuffers(GLsizei n, GLuint *buffers);\nextern PFNGLISBUFFERPROC ptr_glIsBuffer; GLboolean glIsBuffer(GLuint buffer);\nextern PFNGLBUFFERDATAPROC ptr_glBufferData; void glBufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage);\nextern PFNGLBUFFERSUBDATAPROC ptr_glBufferSubData; void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data);\nextern PFNGLGETBUFFERSUBDATAPROC ptr_glGetBufferSubData; void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void *data);\nextern PFNGLMAPBUFFERPROC ptr_glMapBuffer; void * glMapBuffer(GLenum target, GLenum access);\nextern PFNGLUNMAPBUFFERPROC ptr_glUnmapBuffer; GLboolean glUnmapBuffer(GLenum target);\nextern PFNGLGETBUFFERPARAMETERIVPROC ptr_glGetBufferParameteriv; void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params);\nextern PFNGLGETBUFFERPOINTERVPROC ptr_glGetBufferPointerv; void glGetBufferPointerv(GLenum target, GLenum pname, void **params);\nextern PFNGLBLENDEQUATIONSEPARATEPROC ptr_glBlendEquationSeparate; void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);\nextern PFNGLDRAWBUFFERSPROC ptr_glDrawBuffers; void glDrawBuffers(GLsizei n, const GLenum *bufs);\nextern PFNGLSTENCILOPSEPARATEPROC ptr_glStencilOpSeparate; void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\nextern PFNGLSTENCILFUNCSEPARATEPROC ptr_glStencilFuncSeparate; void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);\nextern PFNGLSTENCILMASKSEPARATEPROC ptr_glStencilMaskSeparate; void glStencilMaskSeparate(GLenum face, GLuint mask);\nextern PFNGLATTACHSHADERPROC ptr_glAttachShader; void glAttachShader(GLuint program, GLuint shader);\nextern PFNGLBINDATTRIBLOCATIONPROC ptr_glBindAttribLocation; void glBindAttribLocation(GLuint program, GLuint index, const GLchar *name);\nextern PFNGLCOMPILESHADERPROC ptr_glCompileShader; void glCompileShader(GLuint shader);\nextern PFNGLCREATEPROGRAMPROC ptr_glCreateProgram; GLuint glCreateProgram(void);\nextern PFNGLCREATESHADERPROC ptr_glCreateShader; GLuint glCreateShader(GLenum type);\nextern PFNGLDELETEPROGRAMPROC ptr_glDeleteProgram; void glDeleteProgram(GLuint program);\nextern PFNGLDELETESHADERPROC ptr_glDeleteShader; void glDeleteShader(GLuint shader);\nextern PFNGLDETACHSHADERPROC ptr_glDetachShader; void glDetachShader(GLuint program, GLuint shader);\nextern PFNGLDISABLEVERTEXATTRIBARRAYPROC ptr_glDisableVertexAttribArray; void glDisableVertexAttribArray(GLuint index);\nextern PFNGLENABLEVERTEXATTRIBARRAYPROC ptr_glEnableVertexAttribArray; void glEnableVertexAttribArray(GLuint index);\nextern PFNGLGETACTIVEATTRIBPROC ptr_glGetActiveAttrib; void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\nextern PFNGLGETACTIVEUNIFORMPROC ptr_glGetActiveUniform; void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\nextern PFNGLGETATTACHEDSHADERSPROC ptr_glGetAttachedShaders; void glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);\nextern PFNGLGETATTRIBLOCATIONPROC ptr_glGetAttribLocation; GLint glGetAttribLocation(GLuint program, const GLchar *name);\nextern PFNGLGETPROGRAMIVPROC ptr_glGetProgramiv; void glGetProgramiv(GLuint program, GLenum pname, GLint *params);\nextern PFNGLGETPROGRAMINFOLOGPROC ptr_glGetProgramInfoLog; void glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nextern PFNGLGETSHADERIVPROC ptr_glGetShaderiv; void glGetShaderiv(GLuint shader, GLenum pname, GLint *params);\nextern PFNGLGETSHADERINFOLOGPROC ptr_glGetShaderInfoLog; void glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nextern PFNGLGETSHADERSOURCEPROC ptr_glGetShaderSource; void glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);\nextern PFNGLGETUNIFORMLOCATIONPROC ptr_glGetUniformLocation; GLint glGetUniformLocation(GLuint program, const GLchar *name);\nextern PFNGLGETUNIFORMFVPROC ptr_glGetUniformfv; void glGetUniformfv(GLuint program, GLint location, GLfloat *params);\nextern PFNGLGETUNIFORMIVPROC ptr_glGetUniformiv; void glGetUniformiv(GLuint program, GLint location, GLint *params);\nextern PFNGLGETVERTEXATTRIBDVPROC ptr_glGetVertexAttribdv; void glGetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);\nextern PFNGLGETVERTEXATTRIBFVPROC ptr_glGetVertexAttribfv; void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);\nextern PFNGLGETVERTEXATTRIBIVPROC ptr_glGetVertexAttribiv; void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params);\nextern PFNGLGETVERTEXATTRIBPOINTERVPROC ptr_glGetVertexAttribPointerv; void glGetVertexAttribPointerv(GLuint index, GLenum pname, void **pointer);\nextern PFNGLISPROGRAMPROC ptr_glIsProgram; GLboolean glIsProgram(GLuint program);\nextern PFNGLISSHADERPROC ptr_glIsShader; GLboolean glIsShader(GLuint shader);\nextern PFNGLLINKPROGRAMPROC ptr_glLinkProgram; void glLinkProgram(GLuint program);\nextern PFNGLSHADERSOURCEPROC ptr_glShaderSource; void glShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);\nextern PFNGLUSEPROGRAMPROC ptr_glUseProgram; void glUseProgram(GLuint program);\nextern PFNGLUNIFORM1FPROC ptr_glUniform1f; void glUniform1f(GLint location, GLfloat v0);\nextern PFNGLUNIFORM2FPROC ptr_glUniform2f; void glUniform2f(GLint location, GLfloat v0, GLfloat v1);\nextern PFNGLUNIFORM3FPROC ptr_glUniform3f; void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nextern PFNGLUNIFORM4FPROC ptr_glUniform4f; void glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nextern PFNGLUNIFORM1IPROC ptr_glUniform1i; void glUniform1i(GLint location, GLint v0);\nextern PFNGLUNIFORM2IPROC ptr_glUniform2i; void glUniform2i(GLint location, GLint v0, GLint v1);\nextern PFNGLUNIFORM3IPROC ptr_glUniform3i; void glUniform3i(GLint location, GLint v0, GLint v1, GLint v2);\nextern PFNGLUNIFORM4IPROC ptr_glUniform4i; void glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nextern PFNGLUNIFORM1FVPROC ptr_glUniform1fv; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLUNIFORM2FVPROC ptr_glUniform2fv; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLUNIFORM3FVPROC ptr_glUniform3fv; void glUniform3fv(GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLUNIFORM4FVPROC ptr_glUniform4fv; void glUniform4fv(GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLUNIFORM1IVPROC ptr_glUniform1iv; void glUniform1iv(GLint location, GLsizei count, const GLint *value);\nextern PFNGLUNIFORM2IVPROC ptr_glUniform2iv; void glUniform2iv(GLint location, GLsizei count, const GLint *value);\nextern PFNGLUNIFORM3IVPROC ptr_glUniform3iv; void glUniform3iv(GLint location, GLsizei count, const GLint *value);\nextern PFNGLUNIFORM4IVPROC ptr_glUniform4iv; void glUniform4iv(GLint location, GLsizei count, const GLint *value);\nextern PFNGLUNIFORMMATRIX2FVPROC ptr_glUniformMatrix2fv; void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX3FVPROC ptr_glUniformMatrix3fv; void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX4FVPROC ptr_glUniformMatrix4fv; void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLVALIDATEPROGRAMPROC ptr_glValidateProgram; void glValidateProgram(GLuint program);\nextern PFNGLVERTEXATTRIB1DPROC ptr_glVertexAttrib1d; void glVertexAttrib1d(GLuint index, GLdouble x);\nextern PFNGLVERTEXATTRIB1DVPROC ptr_glVertexAttrib1dv; void glVertexAttrib1dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIB1FPROC ptr_glVertexAttrib1f; void glVertexAttrib1f(GLuint index, GLfloat x);\nextern PFNGLVERTEXATTRIB1FVPROC ptr_glVertexAttrib1fv; void glVertexAttrib1fv(GLuint index, const GLfloat *v);\nextern PFNGLVERTEXATTRIB1SPROC ptr_glVertexAttrib1s; void glVertexAttrib1s(GLuint index, GLshort x);\nextern PFNGLVERTEXATTRIB1SVPROC ptr_glVertexAttrib1sv; void glVertexAttrib1sv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIB2DPROC ptr_glVertexAttrib2d; void glVertexAttrib2d(GLuint index, GLdouble x, GLdouble y);\nextern PFNGLVERTEXATTRIB2DVPROC ptr_glVertexAttrib2dv; void glVertexAttrib2dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIB2FPROC ptr_glVertexAttrib2f; void glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y);\nextern PFNGLVERTEXATTRIB2FVPROC ptr_glVertexAttrib2fv; void glVertexAttrib2fv(GLuint index, const GLfloat *v);\nextern PFNGLVERTEXATTRIB2SPROC ptr_glVertexAttrib2s; void glVertexAttrib2s(GLuint index, GLshort x, GLshort y);\nextern PFNGLVERTEXATTRIB2SVPROC ptr_glVertexAttrib2sv; void glVertexAttrib2sv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIB3DPROC ptr_glVertexAttrib3d; void glVertexAttrib3d(GLuint index, GLdouble x, GLdouble y, GLdouble z);\nextern PFNGLVERTEXATTRIB3DVPROC ptr_glVertexAttrib3dv; void glVertexAttrib3dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIB3FPROC ptr_glVertexAttrib3f; void glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);\nextern PFNGLVERTEXATTRIB3FVPROC ptr_glVertexAttrib3fv; void glVertexAttrib3fv(GLuint index, const GLfloat *v);\nextern PFNGLVERTEXATTRIB3SPROC ptr_glVertexAttrib3s; void glVertexAttrib3s(GLuint index, GLshort x, GLshort y, GLshort z);\nextern PFNGLVERTEXATTRIB3SVPROC ptr_glVertexAttrib3sv; void glVertexAttrib3sv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIB4NBVPROC ptr_glVertexAttrib4Nbv; void glVertexAttrib4Nbv(GLuint index, const GLbyte *v);\nextern PFNGLVERTEXATTRIB4NIVPROC ptr_glVertexAttrib4Niv; void glVertexAttrib4Niv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIB4NSVPROC ptr_glVertexAttrib4Nsv; void glVertexAttrib4Nsv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIB4NUBPROC ptr_glVertexAttrib4Nub; void glVertexAttrib4Nub(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\nextern PFNGLVERTEXATTRIB4NUBVPROC ptr_glVertexAttrib4Nubv; void glVertexAttrib4Nubv(GLuint index, const GLubyte *v);\nextern PFNGLVERTEXATTRIB4NUIVPROC ptr_glVertexAttrib4Nuiv; void glVertexAttrib4Nuiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIB4NUSVPROC ptr_glVertexAttrib4Nusv; void glVertexAttrib4Nusv(GLuint index, const GLushort *v);\nextern PFNGLVERTEXATTRIB4BVPROC ptr_glVertexAttrib4bv; void glVertexAttrib4bv(GLuint index, const GLbyte *v);\nextern PFNGLVERTEXATTRIB4DPROC ptr_glVertexAttrib4d; void glVertexAttrib4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern PFNGLVERTEXATTRIB4DVPROC ptr_glVertexAttrib4dv; void glVertexAttrib4dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIB4FPROC ptr_glVertexAttrib4f; void glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nextern PFNGLVERTEXATTRIB4FVPROC ptr_glVertexAttrib4fv; void glVertexAttrib4fv(GLuint index, const GLfloat *v);\nextern PFNGLVERTEXATTRIB4IVPROC ptr_glVertexAttrib4iv; void glVertexAttrib4iv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIB4SPROC ptr_glVertexAttrib4s; void glVertexAttrib4s(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\nextern PFNGLVERTEXATTRIB4SVPROC ptr_glVertexAttrib4sv; void glVertexAttrib4sv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIB4UBVPROC ptr_glVertexAttrib4ubv; void glVertexAttrib4ubv(GLuint index, const GLubyte *v);\nextern PFNGLVERTEXATTRIB4UIVPROC ptr_glVertexAttrib4uiv; void glVertexAttrib4uiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIB4USVPROC ptr_glVertexAttrib4usv; void glVertexAttrib4usv(GLuint index, const GLushort *v);\nextern PFNGLVERTEXATTRIBPOINTERPROC ptr_glVertexAttribPointer; void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\nextern PFNGLUNIFORMMATRIX2X3FVPROC ptr_glUniformMatrix2x3fv; void glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX3X2FVPROC ptr_glUniformMatrix3x2fv; void glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX2X4FVPROC ptr_glUniformMatrix2x4fv; void glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX4X2FVPROC ptr_glUniformMatrix4x2fv; void glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX3X4FVPROC ptr_glUniformMatrix3x4fv; void glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLUNIFORMMATRIX4X3FVPROC ptr_glUniformMatrix4x3fv; void glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLCOLORMASKIPROC ptr_glColorMaski; void glColorMaski(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\nextern PFNGLGETBOOLEANI_VPROC ptr_glGetBooleani_v; void glGetBooleani_v(GLenum target, GLuint index, GLboolean *data);\nextern PFNGLGETINTEGERI_VPROC ptr_glGetIntegeri_v; void glGetIntegeri_v(GLenum target, GLuint index, GLint *data);\nextern PFNGLENABLEIPROC ptr_glEnablei; void glEnablei(GLenum target, GLuint index);\nextern PFNGLDISABLEIPROC ptr_glDisablei; void glDisablei(GLenum target, GLuint index);\nextern PFNGLISENABLEDIPROC ptr_glIsEnabledi; GLboolean glIsEnabledi(GLenum target, GLuint index);\nextern PFNGLBEGINTRANSFORMFEEDBACKPROC ptr_glBeginTransformFeedback; void glBeginTransformFeedback(GLenum primitiveMode);\nextern PFNGLENDTRANSFORMFEEDBACKPROC ptr_glEndTransformFeedback; void glEndTransformFeedback(void);\nextern PFNGLBINDBUFFERRANGEPROC ptr_glBindBufferRange; void glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\nextern PFNGLBINDBUFFERBASEPROC ptr_glBindBufferBase; void glBindBufferBase(GLenum target, GLuint index, GLuint buffer);\nextern PFNGLTRANSFORMFEEDBACKVARYINGSPROC ptr_glTransformFeedbackVaryings; void glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);\nextern PFNGLGETTRANSFORMFEEDBACKVARYINGPROC ptr_glGetTransformFeedbackVarying; void glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\nextern PFNGLCLAMPCOLORPROC ptr_glClampColor; void glClampColor(GLenum target, GLenum clamp);\nextern PFNGLBEGINCONDITIONALRENDERPROC ptr_glBeginConditionalRender; void glBeginConditionalRender(GLuint id, GLenum mode);\nextern PFNGLENDCONDITIONALRENDERPROC ptr_glEndConditionalRender; void glEndConditionalRender(void);\nextern PFNGLVERTEXATTRIBIPOINTERPROC ptr_glVertexAttribIPointer; void glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nextern PFNGLGETVERTEXATTRIBIIVPROC ptr_glGetVertexAttribIiv; void glGetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);\nextern PFNGLGETVERTEXATTRIBIUIVPROC ptr_glGetVertexAttribIuiv; void glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);\nextern PFNGLVERTEXATTRIBI1IPROC ptr_glVertexAttribI1i; void glVertexAttribI1i(GLuint index, GLint x);\nextern PFNGLVERTEXATTRIBI2IPROC ptr_glVertexAttribI2i; void glVertexAttribI2i(GLuint index, GLint x, GLint y);\nextern PFNGLVERTEXATTRIBI3IPROC ptr_glVertexAttribI3i; void glVertexAttribI3i(GLuint index, GLint x, GLint y, GLint z);\nextern PFNGLVERTEXATTRIBI4IPROC ptr_glVertexAttribI4i; void glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);\nextern PFNGLVERTEXATTRIBI1UIPROC ptr_glVertexAttribI1ui; void glVertexAttribI1ui(GLuint index, GLuint x);\nextern PFNGLVERTEXATTRIBI2UIPROC ptr_glVertexAttribI2ui; void glVertexAttribI2ui(GLuint index, GLuint x, GLuint y);\nextern PFNGLVERTEXATTRIBI3UIPROC ptr_glVertexAttribI3ui; void glVertexAttribI3ui(GLuint index, GLuint x, GLuint y, GLuint z);\nextern PFNGLVERTEXATTRIBI4UIPROC ptr_glVertexAttribI4ui; void glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nextern PFNGLVERTEXATTRIBI1IVPROC ptr_glVertexAttribI1iv; void glVertexAttribI1iv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIBI2IVPROC ptr_glVertexAttribI2iv; void glVertexAttribI2iv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIBI3IVPROC ptr_glVertexAttribI3iv; void glVertexAttribI3iv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIBI4IVPROC ptr_glVertexAttribI4iv; void glVertexAttribI4iv(GLuint index, const GLint *v);\nextern PFNGLVERTEXATTRIBI1UIVPROC ptr_glVertexAttribI1uiv; void glVertexAttribI1uiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIBI2UIVPROC ptr_glVertexAttribI2uiv; void glVertexAttribI2uiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIBI3UIVPROC ptr_glVertexAttribI3uiv; void glVertexAttribI3uiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIBI4UIVPROC ptr_glVertexAttribI4uiv; void glVertexAttribI4uiv(GLuint index, const GLuint *v);\nextern PFNGLVERTEXATTRIBI4BVPROC ptr_glVertexAttribI4bv; void glVertexAttribI4bv(GLuint index, const GLbyte *v);\nextern PFNGLVERTEXATTRIBI4SVPROC ptr_glVertexAttribI4sv; void glVertexAttribI4sv(GLuint index, const GLshort *v);\nextern PFNGLVERTEXATTRIBI4UBVPROC ptr_glVertexAttribI4ubv; void glVertexAttribI4ubv(GLuint index, const GLubyte *v);\nextern PFNGLVERTEXATTRIBI4USVPROC ptr_glVertexAttribI4usv; void glVertexAttribI4usv(GLuint index, const GLushort *v);\nextern PFNGLGETUNIFORMUIVPROC ptr_glGetUniformuiv; void glGetUniformuiv(GLuint program, GLint location, GLuint *params);\nextern PFNGLBINDFRAGDATALOCATIONPROC ptr_glBindFragDataLocation; void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name);\nextern PFNGLGETFRAGDATALOCATIONPROC ptr_glGetFragDataLocation; GLint glGetFragDataLocation(GLuint program, const GLchar *name);\nextern PFNGLUNIFORM1UIPROC ptr_glUniform1ui; void glUniform1ui(GLint location, GLuint v0);\nextern PFNGLUNIFORM2UIPROC ptr_glUniform2ui; void glUniform2ui(GLint location, GLuint v0, GLuint v1);\nextern PFNGLUNIFORM3UIPROC ptr_glUniform3ui; void glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2);\nextern PFNGLUNIFORM4UIPROC ptr_glUniform4ui; void glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nextern PFNGLUNIFORM1UIVPROC ptr_glUniform1uiv; void glUniform1uiv(GLint location, GLsizei count, const GLuint *value);\nextern PFNGLUNIFORM2UIVPROC ptr_glUniform2uiv; void glUniform2uiv(GLint location, GLsizei count, const GLuint *value);\nextern PFNGLUNIFORM3UIVPROC ptr_glUniform3uiv; void glUniform3uiv(GLint location, GLsizei count, const GLuint *value);\nextern PFNGLUNIFORM4UIVPROC ptr_glUniform4uiv; void glUniform4uiv(GLint location, GLsizei count, const GLuint *value);\nextern PFNGLTEXPARAMETERIIVPROC ptr_glTexParameterIiv; void glTexParameterIiv(GLenum target, GLenum pname, const GLint *params);\nextern PFNGLTEXPARAMETERIUIVPROC ptr_glTexParameterIuiv; void glTexParameterIuiv(GLenum target, GLenum pname, const GLuint *params);\nextern PFNGLGETTEXPARAMETERIIVPROC ptr_glGetTexParameterIiv; void glGetTexParameterIiv(GLenum target, GLenum pname, GLint *params);\nextern PFNGLGETTEXPARAMETERIUIVPROC ptr_glGetTexParameterIuiv; void glGetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params);\nextern PFNGLCLEARBUFFERIVPROC ptr_glClearBufferiv; void glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value);\nextern PFNGLCLEARBUFFERUIVPROC ptr_glClearBufferuiv; void glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);\nextern PFNGLCLEARBUFFERFVPROC ptr_glClearBufferfv; void glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);\nextern PFNGLCLEARBUFFERFIPROC ptr_glClearBufferfi; void glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);\nextern PFNGLGETSTRINGIPROC ptr_glGetStringi; const GLubyte * glGetStringi(GLenum name, GLuint index);\nextern PFNGLISRENDERBUFFERPROC ptr_glIsRenderbuffer; GLboolean glIsRenderbuffer(GLuint renderbuffer);\nextern PFNGLBINDRENDERBUFFERPROC ptr_glBindRenderbuffer; void glBindRenderbuffer(GLenum target, GLuint renderbuffer);\nextern PFNGLDELETERENDERBUFFERSPROC ptr_glDeleteRenderbuffers; void glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers);\nextern PFNGLGENRENDERBUFFERSPROC ptr_glGenRenderbuffers; void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers);\nextern PFNGLRENDERBUFFERSTORAGEPROC ptr_glRenderbufferStorage; void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLGETRENDERBUFFERPARAMETERIVPROC ptr_glGetRenderbufferParameteriv; void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params);\nextern PFNGLISFRAMEBUFFERPROC ptr_glIsFramebuffer; GLboolean glIsFramebuffer(GLuint framebuffer);\nextern PFNGLBINDFRAMEBUFFERPROC ptr_glBindFramebuffer; void glBindFramebuffer(GLenum target, GLuint framebuffer);\nextern PFNGLDELETEFRAMEBUFFERSPROC ptr_glDeleteFramebuffers; void glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers);\nextern PFNGLGENFRAMEBUFFERSPROC ptr_glGenFramebuffers; void glGenFramebuffers(GLsizei n, GLuint *framebuffers);\nextern PFNGLCHECKFRAMEBUFFERSTATUSPROC ptr_glCheckFramebufferStatus; GLenum glCheckFramebufferStatus(GLenum target);\nextern PFNGLFRAMEBUFFERTEXTURE1DPROC ptr_glFramebufferTexture1D; void glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nextern PFNGLFRAMEBUFFERTEXTURE2DPROC ptr_glFramebufferTexture2D; void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nextern PFNGLFRAMEBUFFERTEXTURE3DPROC ptr_glFramebufferTexture3D; void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\nextern PFNGLFRAMEBUFFERRENDERBUFFERPROC ptr_glFramebufferRenderbuffer; void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nextern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC ptr_glGetFramebufferAttachmentParameteriv; void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params);\nextern PFNGLGENERATEMIPMAPPROC ptr_glGenerateMipmap; void glGenerateMipmap(GLenum target);\nextern PFNGLBLITFRAMEBUFFERPROC ptr_glBlitFramebuffer; void glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\nextern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC ptr_glRenderbufferStorageMultisample; void glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLFRAMEBUFFERTEXTURELAYERPROC ptr_glFramebufferTextureLayer; void glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\nextern PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\nextern PFNGLFLUSHMAPPEDBUFFERRANGEPROC ptr_glFlushMappedBufferRange; void glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);\nextern PFNGLBINDVERTEXARRAYPROC ptr_glBindVertexArray; void glBindVertexArray(GLuint array);\nextern PFNGLDELETEVERTEXARRAYSPROC ptr_glDeleteVertexArrays; void glDeleteVertexArrays(GLsizei n, const GLuint *arrays);\nextern PFNGLGENVERTEXARRAYSPROC ptr_glGenVertexArrays; void glGenVertexArrays(GLsizei n, GLuint *arrays);\nextern PFNGLISVERTEXARRAYPROC ptr_glIsVertexArray; GLboolean glIsVertexArray(GLuint array);\nextern PFNGLDRAWARRAYSINSTANCEDPROC ptr_glDrawArraysInstanced; void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);\nextern PFNGLDRAWELEMENTSINSTANCEDPROC ptr_glDrawElementsInstanced; void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);\nextern PFNGLTEXBUFFERPROC ptr_glTexBuffer; void glTexBuffer(GLenum target, GLenum internalformat, GLuint buffer);\nextern PFNGLPRIMITIVERESTARTINDEXPROC ptr_glPrimitiveRestartIndex; void glPrimitiveRestartIndex(GLuint index);\nextern PFNGLCOPYBUFFERSUBDATAPROC ptr_glCopyBufferSubData; void glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\nextern PFNGLGETUNIFORMINDICESPROC ptr_glGetUniformIndices; void glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);\nextern PFNGLGETACTIVEUNIFORMSIVPROC ptr_glGetActiveUniformsiv; void glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);\nextern PFNGLGETACTIVEUNIFORMNAMEPROC ptr_glGetActiveUniformName; void glGetActiveUniformName(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);\nextern PFNGLGETUNIFORMBLOCKINDEXPROC ptr_glGetUniformBlockIndex; GLuint glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName);\nextern PFNGLGETACTIVEUNIFORMBLOCKIVPROC ptr_glGetActiveUniformBlockiv; void glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);\nextern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC ptr_glGetActiveUniformBlockName; void glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);\nextern PFNGLUNIFORMBLOCKBINDINGPROC ptr_glUniformBlockBinding; void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\nextern PFNGLDRAWELEMENTSBASEVERTEXPROC ptr_glDrawElementsBaseVertex; void glDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);\nextern PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC ptr_glDrawRangeElementsBaseVertex; void glDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);\nextern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC ptr_glDrawElementsInstancedBaseVertex; void glDrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);\nextern PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC ptr_glMultiDrawElementsBaseVertex; void glMultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);\nextern PFNGLPROVOKINGVERTEXPROC ptr_glProvokingVertex; void glProvokingVertex(GLenum mode);\nextern PFNGLFENCESYNCPROC ptr_glFenceSync; GLsync glFenceSync(GLenum condition, GLbitfield flags);\nextern PFNGLISSYNCPROC ptr_glIsSync; GLboolean glIsSync(GLsync sync);\nextern PFNGLDELETESYNCPROC ptr_glDeleteSync; void glDeleteSync(GLsync sync);\nextern PFNGLCLIENTWAITSYNCPROC ptr_glClientWaitSync; GLenum glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);\nextern PFNGLWAITSYNCPROC ptr_glWaitSync; void glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);\nextern PFNGLGETINTEGER64VPROC ptr_glGetInteger64v; void glGetInteger64v(GLenum pname, GLint64 *data);\nextern PFNGLGETSYNCIVPROC ptr_glGetSynciv; void glGetSynciv(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values);\nextern PFNGLGETINTEGER64I_VPROC ptr_glGetInteger64i_v; void glGetInteger64i_v(GLenum target, GLuint index, GLint64 *data);\nextern PFNGLGETBUFFERPARAMETERI64VPROC ptr_glGetBufferParameteri64v; void glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);\nextern PFNGLFRAMEBUFFERTEXTUREPROC ptr_glFramebufferTexture; void glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);\nextern PFNGLTEXIMAGE2DMULTISAMPLEPROC ptr_glTexImage2DMultisample; void glTexImage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nextern PFNGLTEXIMAGE3DMULTISAMPLEPROC ptr_glTexImage3DMultisample; void glTexImage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nextern PFNGLGETMULTISAMPLEFVPROC ptr_glGetMultisamplefv; void glGetMultisamplefv(GLenum pname, GLuint index, GLfloat *val);\nextern PFNGLSAMPLEMASKIPROC ptr_glSampleMaski; void glSampleMaski(GLuint maskNumber, GLbitfield mask);\nextern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC ptr_glBindFragDataLocationIndexed; void glBindFragDataLocationIndexed(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);\nextern PFNGLGETFRAGDATAINDEXPROC ptr_glGetFragDataIndex; GLint glGetFragDataIndex(GLuint program, const GLchar *name);\nextern PFNGLGENSAMPLERSPROC ptr_glGenSamplers; void glGenSamplers(GLsizei count, GLuint *samplers);\nextern PFNGLDELETESAMPLERSPROC ptr_glDeleteSamplers; void glDeleteSamplers(GLsizei count, const GLuint *samplers);\nextern PFNGLISSAMPLERPROC ptr_glIsSampler; GLboolean glIsSampler(GLuint sampler);\nextern PFNGLBINDSAMPLERPROC ptr_glBindSampler; void glBindSampler(GLuint unit, GLuint sampler);\nextern PFNGLSAMPLERPARAMETERIPROC ptr_glSamplerParameteri; void glSamplerParameteri(GLuint sampler, GLenum pname, GLint param);\nextern PFNGLSAMPLERPARAMETERIVPROC ptr_glSamplerParameteriv; void glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint *param);\nextern PFNGLSAMPLERPARAMETERFPROC ptr_glSamplerParameterf; void glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param);\nextern PFNGLSAMPLERPARAMETERFVPROC ptr_glSamplerParameterfv; void glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param);\nextern PFNGLSAMPLERPARAMETERIIVPROC ptr_glSamplerParameterIiv; void glSamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param);\nextern PFNGLSAMPLERPARAMETERIUIVPROC ptr_glSamplerParameterIuiv; void glSamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param);\nextern PFNGLGETSAMPLERPARAMETERIVPROC ptr_glGetSamplerParameteriv; void glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params);\nextern PFNGLGETSAMPLERPARAMETERIIVPROC ptr_glGetSamplerParameterIiv; void glGetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params);\nextern PFNGLGETSAMPLERPARAMETERFVPROC ptr_glGetSamplerParameterfv; void glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params);\nextern PFNGLGETSAMPLERPARAMETERIUIVPROC ptr_glGetSamplerParameterIuiv; void glGetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params);\nextern PFNGLQUERYCOUNTERPROC ptr_glQueryCounter; void glQueryCounter(GLuint id, GLenum target);\nextern PFNGLGETQUERYOBJECTI64VPROC ptr_glGetQueryObjecti64v; void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params);\nextern PFNGLGETQUERYOBJECTUI64VPROC ptr_glGetQueryObjectui64v; void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params);\nextern PFNGLVERTEXATTRIBDIVISORPROC ptr_glVertexAttribDivisor; void glVertexAttribDivisor(GLuint index, GLuint divisor);\nextern PFNGLVERTEXATTRIBP1UIPROC ptr_glVertexAttribP1ui; void glVertexAttribP1ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);\nextern PFNGLVERTEXATTRIBP1UIVPROC ptr_glVertexAttribP1uiv; void glVertexAttribP1uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nextern PFNGLVERTEXATTRIBP2UIPROC ptr_glVertexAttribP2ui; void glVertexAttribP2ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);\nextern PFNGLVERTEXATTRIBP2UIVPROC ptr_glVertexAttribP2uiv; void glVertexAttribP2uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nextern PFNGLVERTEXATTRIBP3UIPROC ptr_glVertexAttribP3ui; void glVertexAttribP3ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);\nextern PFNGLVERTEXATTRIBP3UIVPROC ptr_glVertexAttribP3uiv; void glVertexAttribP3uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nextern PFNGLVERTEXATTRIBP4UIPROC ptr_glVertexAttribP4ui; void glVertexAttribP4ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);\nextern PFNGLVERTEXATTRIBP4UIVPROC ptr_glVertexAttribP4uiv; void glVertexAttribP4uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nextern PFNGLVERTEXP2UIPROC ptr_glVertexP2ui; void glVertexP2ui(GLenum type, GLuint value);\nextern PFNGLVERTEXP2UIVPROC ptr_glVertexP2uiv; void glVertexP2uiv(GLenum type, const GLuint *value);\nextern PFNGLVERTEXP3UIPROC ptr_glVertexP3ui; void glVertexP3ui(GLenum type, GLuint value);\nextern PFNGLVERTEXP3UIVPROC ptr_glVertexP3uiv; void glVertexP3uiv(GLenum type, const GLuint *value);\nextern PFNGLVERTEXP4UIPROC ptr_glVertexP4ui; void glVertexP4ui(GLenum type, GLuint value);\nextern PFNGLVERTEXP4UIVPROC ptr_glVertexP4uiv; void glVertexP4uiv(GLenum type, const GLuint *value);\nextern PFNGLTEXCOORDP1UIPROC ptr_glTexCoordP1ui; void glTexCoordP1ui(GLenum type, GLuint coords);\nextern PFNGLTEXCOORDP1UIVPROC ptr_glTexCoordP1uiv; void glTexCoordP1uiv(GLenum type, const GLuint *coords);\nextern PFNGLTEXCOORDP2UIPROC ptr_glTexCoordP2ui; void glTexCoordP2ui(GLenum type, GLuint coords);\nextern PFNGLTEXCOORDP2UIVPROC ptr_glTexCoordP2uiv; void glTexCoordP2uiv(GLenum type, const GLuint *coords);\nextern PFNGLTEXCOORDP3UIPROC ptr_glTexCoordP3ui; void glTexCoordP3ui(GLenum type, GLuint coords);\nextern PFNGLTEXCOORDP3UIVPROC ptr_glTexCoordP3uiv; void glTexCoordP3uiv(GLenum type, const GLuint *coords);\nextern PFNGLTEXCOORDP4UIPROC ptr_glTexCoordP4ui; void glTexCoordP4ui(GLenum type, GLuint coords);\nextern PFNGLTEXCOORDP4UIVPROC ptr_glTexCoordP4uiv; void glTexCoordP4uiv(GLenum type, const GLuint *coords);\nextern PFNGLMULTITEXCOORDP1UIPROC ptr_glMultiTexCoordP1ui; void glMultiTexCoordP1ui(GLenum texture, GLenum type, GLuint coords);\nextern PFNGLMULTITEXCOORDP1UIVPROC ptr_glMultiTexCoordP1uiv; void glMultiTexCoordP1uiv(GLenum texture, GLenum type, const GLuint *coords);\nextern PFNGLMULTITEXCOORDP2UIPROC ptr_glMultiTexCoordP2ui; void glMultiTexCoordP2ui(GLenum texture, GLenum type, GLuint coords);\nextern PFNGLMULTITEXCOORDP2UIVPROC ptr_glMultiTexCoordP2uiv; void glMultiTexCoordP2uiv(GLenum texture, GLenum type, const GLuint *coords);\nextern PFNGLMULTITEXCOORDP3UIPROC ptr_glMultiTexCoordP3ui; void glMultiTexCoordP3ui(GLenum texture, GLenum type, GLuint coords);\nextern PFNGLMULTITEXCOORDP3UIVPROC ptr_glMultiTexCoordP3uiv; void glMultiTexCoordP3uiv(GLenum texture, GLenum type, const GLuint *coords);\nextern PFNGLMULTITEXCOORDP4UIPROC ptr_glMultiTexCoordP4ui; void glMultiTexCoordP4ui(GLenum texture, GLenum type, GLuint coords);\nextern PFNGLMULTITEXCOORDP4UIVPROC ptr_glMultiTexCoordP4uiv; void glMultiTexCoordP4uiv(GLenum texture, GLenum type, const GLuint *coords);\nextern PFNGLNORMALP3UIPROC ptr_glNormalP3ui; void glNormalP3ui(GLenum type, GLuint coords);\nextern PFNGLNORMALP3UIVPROC ptr_glNormalP3uiv; void glNormalP3uiv(GLenum type, const GLuint *coords);\nextern PFNGLCOLORP3UIPROC ptr_glColorP3ui; void glColorP3ui(GLenum type, GLuint color);\nextern PFNGLCOLORP3UIVPROC ptr_glColorP3uiv; void glColorP3uiv(GLenum type, const GLuint *color);\nextern PFNGLCOLORP4UIPROC ptr_glColorP4ui; void glColorP4ui(GLenum type, GLuint color);\nextern PFNGLCOLORP4UIVPROC ptr_glColorP4uiv; void glColorP4uiv(GLenum type, const GLuint *color);\nextern PFNGLSECONDARYCOLORP3UIPROC ptr_glSecondaryColorP3ui; void glSecondaryColorP3ui(GLenum type, GLuint color);\nextern PFNGLSECONDARYCOLORP3UIVPROC ptr_glSecondaryColorP3uiv; void glSecondaryColorP3uiv(GLenum type, const GLuint *color);\nextern PFNGLMINSAMPLESHADINGPROC ptr_glMinSampleShading; void glMinSampleShading(GLfloat value);\nextern PFNGLBLENDEQUATIONIPROC ptr_glBlendEquationi; void glBlendEquationi(GLuint buf, GLenum mode);\nextern PFNGLBLENDEQUATIONSEPARATEIPROC ptr_glBlendEquationSeparatei; void glBlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeAlpha);\nextern PFNGLBLENDFUNCIPROC ptr_glBlendFunci; void glBlendFunci(GLuint buf, GLenum src, GLenum dst);\nextern PFNGLBLENDFUNCSEPARATEIPROC ptr_glBlendFuncSeparatei; void glBlendFuncSeparatei(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\nextern PFNGLDRAWARRAYSINDIRECTPROC ptr_glDrawArraysIndirect; void glDrawArraysIndirect(GLenum mode, const void *indirect);\nextern PFNGLDRAWELEMENTSINDIRECTPROC ptr_glDrawElementsIndirect; void glDrawElementsIndirect(GLenum mode, GLenum type, const void *indirect);\nextern PFNGLUNIFORM1DPROC ptr_glUniform1d; void glUniform1d(GLint location, GLdouble x);\nextern PFNGLUNIFORM2DPROC ptr_glUniform2d; void glUniform2d(GLint location, GLdouble x, GLdouble y);\nextern PFNGLUNIFORM3DPROC ptr_glUniform3d; void glUniform3d(GLint location, GLdouble x, GLdouble y, GLdouble z);\nextern PFNGLUNIFORM4DPROC ptr_glUniform4d; void glUniform4d(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern PFNGLUNIFORM1DVPROC ptr_glUniform1dv; void glUniform1dv(GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLUNIFORM2DVPROC ptr_glUniform2dv; void glUniform2dv(GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLUNIFORM3DVPROC ptr_glUniform3dv; void glUniform3dv(GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLUNIFORM4DVPROC ptr_glUniform4dv; void glUniform4dv(GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX2DVPROC ptr_glUniformMatrix2dv; void glUniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX3DVPROC ptr_glUniformMatrix3dv; void glUniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX4DVPROC ptr_glUniformMatrix4dv; void glUniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX2X3DVPROC ptr_glUniformMatrix2x3dv; void glUniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX2X4DVPROC ptr_glUniformMatrix2x4dv; void glUniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX3X2DVPROC ptr_glUniformMatrix3x2dv; void glUniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX3X4DVPROC ptr_glUniformMatrix3x4dv; void glUniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX4X2DVPROC ptr_glUniformMatrix4x2dv; void glUniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLUNIFORMMATRIX4X3DVPROC ptr_glUniformMatrix4x3dv; void glUniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLGETUNIFORMDVPROC ptr_glGetUniformdv; void glGetUniformdv(GLuint program, GLint location, GLdouble *params);\nextern PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC ptr_glGetSubroutineUniformLocation; GLint glGetSubroutineUniformLocation(GLuint program, GLenum shadertype, const GLchar *name);\nextern PFNGLGETSUBROUTINEINDEXPROC ptr_glGetSubroutineIndex; GLuint glGetSubroutineIndex(GLuint program, GLenum shadertype, const GLchar *name);\nextern PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC ptr_glGetActiveSubroutineUniformiv; void glGetActiveSubroutineUniformiv(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);\nextern PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC ptr_glGetActiveSubroutineUniformName; void glGetActiveSubroutineUniformName(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);\nextern PFNGLGETACTIVESUBROUTINENAMEPROC ptr_glGetActiveSubroutineName; void glGetActiveSubroutineName(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);\nextern PFNGLUNIFORMSUBROUTINESUIVPROC ptr_glUniformSubroutinesuiv; void glUniformSubroutinesuiv(GLenum shadertype, GLsizei count, const GLuint *indices);\nextern PFNGLGETUNIFORMSUBROUTINEUIVPROC ptr_glGetUniformSubroutineuiv; void glGetUniformSubroutineuiv(GLenum shadertype, GLint location, GLuint *params);\nextern PFNGLGETPROGRAMSTAGEIVPROC ptr_glGetProgramStageiv; void glGetProgramStageiv(GLuint program, GLenum shadertype, GLenum pname, GLint *values);\nextern PFNGLPATCHPARAMETERIPROC ptr_glPatchParameteri; void glPatchParameteri(GLenum pname, GLint value);\nextern PFNGLPATCHPARAMETERFVPROC ptr_glPatchParameterfv; void glPatchParameterfv(GLenum pname, const GLfloat *values);\nextern PFNGLBINDTRANSFORMFEEDBACKPROC ptr_glBindTransformFeedback; void glBindTransformFeedback(GLenum target, GLuint id);\nextern PFNGLDELETETRANSFORMFEEDBACKSPROC ptr_glDeleteTransformFeedbacks; void glDeleteTransformFeedbacks(GLsizei n, const GLuint *ids);\nextern PFNGLGENTRANSFORMFEEDBACKSPROC ptr_glGenTransformFeedbacks; void glGenTransformFeedbacks(GLsizei n, GLuint *ids);\nextern PFNGLISTRANSFORMFEEDBACKPROC ptr_glIsTransformFeedback; GLboolean glIsTransformFeedback(GLuint id);\nextern PFNGLPAUSETRANSFORMFEEDBACKPROC ptr_glPauseTransformFeedback; void glPauseTransformFeedback(void);\nextern PFNGLRESUMETRANSFORMFEEDBACKPROC ptr_glResumeTransformFeedback; void glResumeTransformFeedback(void);\nextern PFNGLDRAWTRANSFORMFEEDBACKPROC ptr_glDrawTransformFeedback; void glDrawTransformFeedback(GLenum mode, GLuint id);\nextern PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC ptr_glDrawTransformFeedbackStream; void glDrawTransformFeedbackStream(GLenum mode, GLuint id, GLuint stream);\nextern PFNGLBEGINQUERYINDEXEDPROC ptr_glBeginQueryIndexed; void glBeginQueryIndexed(GLenum target, GLuint index, GLuint id);\nextern PFNGLENDQUERYINDEXEDPROC ptr_glEndQueryIndexed; void glEndQueryIndexed(GLenum target, GLuint index);\nextern PFNGLGETQUERYINDEXEDIVPROC ptr_glGetQueryIndexediv; void glGetQueryIndexediv(GLenum target, GLuint index, GLenum pname, GLint *params);\nextern PFNGLRELEASESHADERCOMPILERPROC ptr_glReleaseShaderCompiler; void glReleaseShaderCompiler(void);\nextern PFNGLSHADERBINARYPROC ptr_glShaderBinary; void glShaderBinary(GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length);\nextern PFNGLGETSHADERPRECISIONFORMATPROC ptr_glGetShaderPrecisionFormat; void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);\nextern PFNGLDEPTHRANGEFPROC ptr_glDepthRangef; void glDepthRangef(GLfloat n, GLfloat f);\nextern PFNGLCLEARDEPTHFPROC ptr_glClearDepthf; void glClearDepthf(GLfloat d);\nextern PFNGLGETPROGRAMBINARYPROC ptr_glGetProgramBinary; void glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);\nextern PFNGLPROGRAMBINARYPROC ptr_glProgramBinary; void glProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);\nextern PFNGLPROGRAMPARAMETERIPROC ptr_glProgramParameteri; void glProgramParameteri(GLuint program, GLenum pname, GLint value);\nextern PFNGLUSEPROGRAMSTAGESPROC ptr_glUseProgramStages; void glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program);\nextern PFNGLACTIVESHADERPROGRAMPROC ptr_glActiveShaderProgram; void glActiveShaderProgram(GLuint pipeline, GLuint program);\nextern PFNGLCREATESHADERPROGRAMVPROC ptr_glCreateShaderProgramv; GLuint glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const*strings);\nextern PFNGLBINDPROGRAMPIPELINEPROC ptr_glBindProgramPipeline; void glBindProgramPipeline(GLuint pipeline);\nextern PFNGLDELETEPROGRAMPIPELINESPROC ptr_glDeleteProgramPipelines; void glDeleteProgramPipelines(GLsizei n, const GLuint *pipelines);\nextern PFNGLGENPROGRAMPIPELINESPROC ptr_glGenProgramPipelines; void glGenProgramPipelines(GLsizei n, GLuint *pipelines);\nextern PFNGLISPROGRAMPIPELINEPROC ptr_glIsProgramPipeline; GLboolean glIsProgramPipeline(GLuint pipeline);\nextern PFNGLGETPROGRAMPIPELINEIVPROC ptr_glGetProgramPipelineiv; void glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params);\nextern PFNGLPROGRAMUNIFORM1IPROC ptr_glProgramUniform1i; void glProgramUniform1i(GLuint program, GLint location, GLint v0);\nextern PFNGLPROGRAMUNIFORM1IVPROC ptr_glProgramUniform1iv; void glProgramUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value);\nextern PFNGLPROGRAMUNIFORM1FPROC ptr_glProgramUniform1f; void glProgramUniform1f(GLuint program, GLint location, GLfloat v0);\nextern PFNGLPROGRAMUNIFORM1FVPROC ptr_glProgramUniform1fv; void glProgramUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORM1DPROC ptr_glProgramUniform1d; void glProgramUniform1d(GLuint program, GLint location, GLdouble v0);\nextern PFNGLPROGRAMUNIFORM1DVPROC ptr_glProgramUniform1dv; void glProgramUniform1dv(GLuint program, GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORM1UIPROC ptr_glProgramUniform1ui; void glProgramUniform1ui(GLuint program, GLint location, GLuint v0);\nextern PFNGLPROGRAMUNIFORM1UIVPROC ptr_glProgramUniform1uiv; void glProgramUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value);\nextern PFNGLPROGRAMUNIFORM2IPROC ptr_glProgramUniform2i; void glProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1);\nextern PFNGLPROGRAMUNIFORM2IVPROC ptr_glProgramUniform2iv; void glProgramUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value);\nextern PFNGLPROGRAMUNIFORM2FPROC ptr_glProgramUniform2f; void glProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1);\nextern PFNGLPROGRAMUNIFORM2FVPROC ptr_glProgramUniform2fv; void glProgramUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORM2DPROC ptr_glProgramUniform2d; void glProgramUniform2d(GLuint program, GLint location, GLdouble v0, GLdouble v1);\nextern PFNGLPROGRAMUNIFORM2DVPROC ptr_glProgramUniform2dv; void glProgramUniform2dv(GLuint program, GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORM2UIPROC ptr_glProgramUniform2ui; void glProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1);\nextern PFNGLPROGRAMUNIFORM2UIVPROC ptr_glProgramUniform2uiv; void glProgramUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value);\nextern PFNGLPROGRAMUNIFORM3IPROC ptr_glProgramUniform3i; void glProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\nextern PFNGLPROGRAMUNIFORM3IVPROC ptr_glProgramUniform3iv; void glProgramUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value);\nextern PFNGLPROGRAMUNIFORM3FPROC ptr_glProgramUniform3f; void glProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nextern PFNGLPROGRAMUNIFORM3FVPROC ptr_glProgramUniform3fv; void glProgramUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORM3DPROC ptr_glProgramUniform3d; void glProgramUniform3d(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);\nextern PFNGLPROGRAMUNIFORM3DVPROC ptr_glProgramUniform3dv; void glProgramUniform3dv(GLuint program, GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORM3UIPROC ptr_glProgramUniform3ui; void glProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\nextern PFNGLPROGRAMUNIFORM3UIVPROC ptr_glProgramUniform3uiv; void glProgramUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value);\nextern PFNGLPROGRAMUNIFORM4IPROC ptr_glProgramUniform4i; void glProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nextern PFNGLPROGRAMUNIFORM4IVPROC ptr_glProgramUniform4iv; void glProgramUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value);\nextern PFNGLPROGRAMUNIFORM4FPROC ptr_glProgramUniform4f; void glProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nextern PFNGLPROGRAMUNIFORM4FVPROC ptr_glProgramUniform4fv; void glProgramUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORM4DPROC ptr_glProgramUniform4d; void glProgramUniform4d(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);\nextern PFNGLPROGRAMUNIFORM4DVPROC ptr_glProgramUniform4dv; void glProgramUniform4dv(GLuint program, GLint location, GLsizei count, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORM4UIPROC ptr_glProgramUniform4ui; void glProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nextern PFNGLPROGRAMUNIFORM4UIVPROC ptr_glProgramUniform4uiv; void glProgramUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2FVPROC ptr_glProgramUniformMatrix2fv; void glProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3FVPROC ptr_glProgramUniformMatrix3fv; void glProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4FVPROC ptr_glProgramUniformMatrix4fv; void glProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2DVPROC ptr_glProgramUniformMatrix2dv; void glProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3DVPROC ptr_glProgramUniformMatrix3dv; void glProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4DVPROC ptr_glProgramUniformMatrix4dv; void glProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC ptr_glProgramUniformMatrix2x3fv; void glProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC ptr_glProgramUniformMatrix3x2fv; void glProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC ptr_glProgramUniformMatrix2x4fv; void glProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC ptr_glProgramUniformMatrix4x2fv; void glProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC ptr_glProgramUniformMatrix3x4fv; void glProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC ptr_glProgramUniformMatrix4x3fv; void glProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC ptr_glProgramUniformMatrix2x3dv; void glProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC ptr_glProgramUniformMatrix3x2dv; void glProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC ptr_glProgramUniformMatrix2x4dv; void glProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC ptr_glProgramUniformMatrix4x2dv; void glProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC ptr_glProgramUniformMatrix3x4dv; void glProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC ptr_glProgramUniformMatrix4x3dv; void glProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nextern PFNGLVALIDATEPROGRAMPIPELINEPROC ptr_glValidateProgramPipeline; void glValidateProgramPipeline(GLuint pipeline);\nextern PFNGLGETPROGRAMPIPELINEINFOLOGPROC ptr_glGetProgramPipelineInfoLog; void glGetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nextern PFNGLVERTEXATTRIBL1DPROC ptr_glVertexAttribL1d; void glVertexAttribL1d(GLuint index, GLdouble x);\nextern PFNGLVERTEXATTRIBL2DPROC ptr_glVertexAttribL2d; void glVertexAttribL2d(GLuint index, GLdouble x, GLdouble y);\nextern PFNGLVERTEXATTRIBL3DPROC ptr_glVertexAttribL3d; void glVertexAttribL3d(GLuint index, GLdouble x, GLdouble y, GLdouble z);\nextern PFNGLVERTEXATTRIBL4DPROC ptr_glVertexAttribL4d; void glVertexAttribL4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern PFNGLVERTEXATTRIBL1DVPROC ptr_glVertexAttribL1dv; void glVertexAttribL1dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIBL2DVPROC ptr_glVertexAttribL2dv; void glVertexAttribL2dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIBL3DVPROC ptr_glVertexAttribL3dv; void glVertexAttribL3dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIBL4DVPROC ptr_glVertexAttribL4dv; void glVertexAttribL4dv(GLuint index, const GLdouble *v);\nextern PFNGLVERTEXATTRIBLPOINTERPROC ptr_glVertexAttribLPointer; void glVertexAttribLPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nextern PFNGLGETVERTEXATTRIBLDVPROC ptr_glGetVertexAttribLdv; void glGetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);\nextern PFNGLVIEWPORTARRAYVPROC ptr_glViewportArrayv; void glViewportArrayv(GLuint first, GLsizei count, const GLfloat *v);\nextern PFNGLVIEWPORTINDEXEDFPROC ptr_glViewportIndexedf; void glViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);\nextern PFNGLVIEWPORTINDEXEDFVPROC ptr_glViewportIndexedfv; void glViewportIndexedfv(GLuint index, const GLfloat *v);\nextern PFNGLSCISSORARRAYVPROC ptr_glScissorArrayv; void glScissorArrayv(GLuint first, GLsizei count, const GLint *v);\nextern PFNGLSCISSORINDEXEDPROC ptr_glScissorIndexed; void glScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);\nextern PFNGLSCISSORINDEXEDVPROC ptr_glScissorIndexedv; void glScissorIndexedv(GLuint index, const GLint *v);\nextern PFNGLDEPTHRANGEARRAYVPROC ptr_glDepthRangeArrayv; void glDepthRangeArrayv(GLuint first, GLsizei count, const GLdouble *v);\nextern PFNGLDEPTHRANGEINDEXEDPROC ptr_glDepthRangeIndexed; void glDepthRangeIndexed(GLuint index, GLdouble n, GLdouble f);\nextern PFNGLGETFLOATI_VPROC ptr_glGetFloati_v; void glGetFloati_v(GLenum target, GLuint index, GLfloat *data);\nextern PFNGLGETDOUBLEI_VPROC ptr_glGetDoublei_v; void glGetDoublei_v(GLenum target, GLuint index, GLdouble *data);\nextern PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC ptr_glDrawArraysInstancedBaseInstance; void glDrawArraysInstancedBaseInstance(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);\nextern PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC ptr_glDrawElementsInstancedBaseInstance; void glDrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);\nextern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC ptr_glDrawElementsInstancedBaseVertexBaseInstance; void glDrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);\nextern PFNGLGETINTERNALFORMATIVPROC ptr_glGetInternalformativ; void glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params);\nextern PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC ptr_glGetActiveAtomicCounterBufferiv; void glGetActiveAtomicCounterBufferiv(GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);\nextern PFNGLBINDIMAGETEXTUREPROC ptr_glBindImageTexture; void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);\nextern PFNGLMEMORYBARRIERPROC ptr_glMemoryBarrier; void glMemoryBarrier(GLbitfield barriers);\nextern PFNGLTEXSTORAGE1DPROC ptr_glTexStorage1D; void glTexStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\nextern PFNGLTEXSTORAGE2DPROC ptr_glTexStorage2D; void glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLTEXSTORAGE3DPROC ptr_glTexStorage3D; void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\nextern PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC ptr_glDrawTransformFeedbackInstanced; void glDrawTransformFeedbackInstanced(GLenum mode, GLuint id, GLsizei instancecount);\nextern PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC ptr_glDrawTransformFeedbackStreamInstanced; void glDrawTransformFeedbackStreamInstanced(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);\nextern PFNGLCLEARBUFFERDATAPROC ptr_glClearBufferData; void glClearBufferData(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);\nextern PFNGLCLEARBUFFERSUBDATAPROC ptr_glClearBufferSubData; void glClearBufferSubData(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\nextern PFNGLDISPATCHCOMPUTEPROC ptr_glDispatchCompute; void glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);\nextern PFNGLDISPATCHCOMPUTEINDIRECTPROC ptr_glDispatchComputeIndirect; void glDispatchComputeIndirect(GLintptr indirect);\nextern PFNGLCOPYIMAGESUBDATAPROC ptr_glCopyImageSubData; void glCopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);\nextern PFNGLFRAMEBUFFERPARAMETERIPROC ptr_glFramebufferParameteri; void glFramebufferParameteri(GLenum target, GLenum pname, GLint param);\nextern PFNGLGETFRAMEBUFFERPARAMETERIVPROC ptr_glGetFramebufferParameteriv; void glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params);\nextern PFNGLGETINTERNALFORMATI64VPROC ptr_glGetInternalformati64v; void glGetInternalformati64v(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params);\nextern PFNGLINVALIDATETEXSUBIMAGEPROC ptr_glInvalidateTexSubImage; void glInvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);\nextern PFNGLINVALIDATETEXIMAGEPROC ptr_glInvalidateTexImage; void glInvalidateTexImage(GLuint texture, GLint level);\nextern PFNGLINVALIDATEBUFFERSUBDATAPROC ptr_glInvalidateBufferSubData; void glInvalidateBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr length);\nextern PFNGLINVALIDATEBUFFERDATAPROC ptr_glInvalidateBufferData; void glInvalidateBufferData(GLuint buffer);\nextern PFNGLINVALIDATEFRAMEBUFFERPROC ptr_glInvalidateFramebuffer; void glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments);\nextern PFNGLINVALIDATESUBFRAMEBUFFERPROC ptr_glInvalidateSubFramebuffer; void glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\nextern PFNGLMULTIDRAWARRAYSINDIRECTPROC ptr_glMultiDrawArraysIndirect; void glMultiDrawArraysIndirect(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);\nextern PFNGLMULTIDRAWELEMENTSINDIRECTPROC ptr_glMultiDrawElementsIndirect; void glMultiDrawElementsIndirect(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);\nextern PFNGLGETPROGRAMINTERFACEIVPROC ptr_glGetProgramInterfaceiv; void glGetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint *params);\nextern PFNGLGETPROGRAMRESOURCEINDEXPROC ptr_glGetProgramResourceIndex; GLuint glGetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name);\nextern PFNGLGETPROGRAMRESOURCENAMEPROC ptr_glGetProgramResourceName; void glGetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);\nextern PFNGLGETPROGRAMRESOURCEIVPROC ptr_glGetProgramResourceiv; void glGetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params);\nextern PFNGLGETPROGRAMRESOURCELOCATIONPROC ptr_glGetProgramResourceLocation; GLint glGetProgramResourceLocation(GLuint program, GLenum programInterface, const GLchar *name);\nextern PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC ptr_glGetProgramResourceLocationIndex; GLint glGetProgramResourceLocationIndex(GLuint program, GLenum programInterface, const GLchar *name);\nextern PFNGLSHADERSTORAGEBLOCKBINDINGPROC ptr_glShaderStorageBlockBinding; void glShaderStorageBlockBinding(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);\nextern PFNGLTEXBUFFERRANGEPROC ptr_glTexBufferRange; void glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\nextern PFNGLTEXSTORAGE2DMULTISAMPLEPROC ptr_glTexStorage2DMultisample; void glTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nextern PFNGLTEXSTORAGE3DMULTISAMPLEPROC ptr_glTexStorage3DMultisample; void glTexStorage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nextern PFNGLTEXTUREVIEWPROC ptr_glTextureView; void glTextureView(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);\nextern PFNGLBINDVERTEXBUFFERPROC ptr_glBindVertexBuffer; void glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\nextern PFNGLVERTEXATTRIBFORMATPROC ptr_glVertexAttribFormat; void glVertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\nextern PFNGLVERTEXATTRIBIFORMATPROC ptr_glVertexAttribIFormat; void glVertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nextern PFNGLVERTEXATTRIBLFORMATPROC ptr_glVertexAttribLFormat; void glVertexAttribLFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nextern PFNGLVERTEXATTRIBBINDINGPROC ptr_glVertexAttribBinding; void glVertexAttribBinding(GLuint attribindex, GLuint bindingindex);\nextern PFNGLVERTEXBINDINGDIVISORPROC ptr_glVertexBindingDivisor; void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor);\nextern PFNGLDEBUGMESSAGECONTROLPROC ptr_glDebugMessageControl; void glDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\nextern PFNGLDEBUGMESSAGEINSERTPROC ptr_glDebugMessageInsert; void glDebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);\nextern PFNGLDEBUGMESSAGECALLBACKPROC ptr_glDebugMessageCallback; void glDebugMessageCallback(GLDEBUGPROC callback, const void *userParam);\nextern PFNGLGETDEBUGMESSAGELOGPROC ptr_glGetDebugMessageLog; GLuint glGetDebugMessageLog(GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);\nextern PFNGLPUSHDEBUGGROUPPROC ptr_glPushDebugGroup; void glPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message);\nextern PFNGLPOPDEBUGGROUPPROC ptr_glPopDebugGroup; void glPopDebugGroup(void);\nextern PFNGLOBJECTLABELPROC ptr_glObjectLabel; void glObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label);\nextern PFNGLGETOBJECTLABELPROC ptr_glGetObjectLabel; void glGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);\nextern PFNGLOBJECTPTRLABELPROC ptr_glObjectPtrLabel; void glObjectPtrLabel(const void *ptr, GLsizei length, const GLchar *label);\nextern PFNGLGETOBJECTPTRLABELPROC ptr_glGetObjectPtrLabel; void glGetObjectPtrLabel(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);\nextern PFNGLBUFFERSTORAGEPROC ptr_glBufferStorage; void glBufferStorage(GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);\nextern PFNGLCLEARTEXIMAGEPROC ptr_glClearTexImage; void glClearTexImage(GLuint texture, GLint level, GLenum format, GLenum type, const void *data);\nextern PFNGLCLEARTEXSUBIMAGEPROC ptr_glClearTexSubImage; void glClearTexSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);\nextern PFNGLBINDBUFFERSBASEPROC ptr_glBindBuffersBase; void glBindBuffersBase(GLenum target, GLuint first, GLsizei count, const GLuint *buffers);\nextern PFNGLBINDBUFFERSRANGEPROC ptr_glBindBuffersRange; void glBindBuffersRange(GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);\nextern PFNGLBINDTEXTURESPROC ptr_glBindTextures; void glBindTextures(GLuint first, GLsizei count, const GLuint *textures);\nextern PFNGLBINDSAMPLERSPROC ptr_glBindSamplers; void glBindSamplers(GLuint first, GLsizei count, const GLuint *samplers);\nextern PFNGLBINDIMAGETEXTURESPROC ptr_glBindImageTextures; void glBindImageTextures(GLuint first, GLsizei count, const GLuint *textures);\nextern PFNGLBINDVERTEXBUFFERSPROC ptr_glBindVertexBuffers; void glBindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\nextern PFNGLCLIPCONTROLPROC ptr_glClipControl; void glClipControl(GLenum origin, GLenum depth);\nextern PFNGLCREATETRANSFORMFEEDBACKSPROC ptr_glCreateTransformFeedbacks; void glCreateTransformFeedbacks(GLsizei n, GLuint *ids);\nextern PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC ptr_glTransformFeedbackBufferBase; void glTransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer);\nextern PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC ptr_glTransformFeedbackBufferRange; void glTransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\nextern PFNGLGETTRANSFORMFEEDBACKIVPROC ptr_glGetTransformFeedbackiv; void glGetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param);\nextern PFNGLGETTRANSFORMFEEDBACKI_VPROC ptr_glGetTransformFeedbacki_v; void glGetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, GLint *param);\nextern PFNGLGETTRANSFORMFEEDBACKI64_VPROC ptr_glGetTransformFeedbacki64_v; void glGetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, GLint64 *param);\nextern PFNGLCREATEBUFFERSPROC ptr_glCreateBuffers; void glCreateBuffers(GLsizei n, GLuint *buffers);\nextern PFNGLNAMEDBUFFERSTORAGEPROC ptr_glNamedBufferStorage; void glNamedBufferStorage(GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);\nextern PFNGLNAMEDBUFFERDATAPROC ptr_glNamedBufferData; void glNamedBufferData(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);\nextern PFNGLNAMEDBUFFERSUBDATAPROC ptr_glNamedBufferSubData; void glNamedBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);\nextern PFNGLCOPYNAMEDBUFFERSUBDATAPROC ptr_glCopyNamedBufferSubData; void glCopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\nextern PFNGLCLEARNAMEDBUFFERDATAPROC ptr_glClearNamedBufferData; void glClearNamedBufferData(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\nextern PFNGLCLEARNAMEDBUFFERSUBDATAPROC ptr_glClearNamedBufferSubData; void glClearNamedBufferSubData(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\nextern PFNGLMAPNAMEDBUFFERPROC ptr_glMapNamedBuffer; void * glMapNamedBuffer(GLuint buffer, GLenum access);\nextern PFNGLMAPNAMEDBUFFERRANGEPROC ptr_glMapNamedBufferRange; void * glMapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\nextern PFNGLUNMAPNAMEDBUFFERPROC ptr_glUnmapNamedBuffer; GLboolean glUnmapNamedBuffer(GLuint buffer);\nextern PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC ptr_glFlushMappedNamedBufferRange; void glFlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length);\nextern PFNGLGETNAMEDBUFFERPARAMETERIVPROC ptr_glGetNamedBufferParameteriv; void glGetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params);\nextern PFNGLGETNAMEDBUFFERPARAMETERI64VPROC ptr_glGetNamedBufferParameteri64v; void glGetNamedBufferParameteri64v(GLuint buffer, GLenum pname, GLint64 *params);\nextern PFNGLGETNAMEDBUFFERPOINTERVPROC ptr_glGetNamedBufferPointerv; void glGetNamedBufferPointerv(GLuint buffer, GLenum pname, void **params);\nextern PFNGLGETNAMEDBUFFERSUBDATAPROC ptr_glGetNamedBufferSubData; void glGetNamedBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);\nextern PFNGLCREATEFRAMEBUFFERSPROC ptr_glCreateFramebuffers; void glCreateFramebuffers(GLsizei n, GLuint *framebuffers);\nextern PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC ptr_glNamedFramebufferRenderbuffer; void glNamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nextern PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC ptr_glNamedFramebufferParameteri; void glNamedFramebufferParameteri(GLuint framebuffer, GLenum pname, GLint param);\nextern PFNGLNAMEDFRAMEBUFFERTEXTUREPROC ptr_glNamedFramebufferTexture; void glNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\nextern PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC ptr_glNamedFramebufferTextureLayer; void glNamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\nextern PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC ptr_glNamedFramebufferDrawBuffer; void glNamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);\nextern PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC ptr_glNamedFramebufferDrawBuffers; void glNamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n, const GLenum *bufs);\nextern PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC ptr_glNamedFramebufferReadBuffer; void glNamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);\nextern PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC ptr_glInvalidateNamedFramebufferData; void glInvalidateNamedFramebufferData(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments);\nextern PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC ptr_glInvalidateNamedFramebufferSubData; void glInvalidateNamedFramebufferSubData(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\nextern PFNGLCLEARNAMEDFRAMEBUFFERIVPROC ptr_glClearNamedFramebufferiv; void glClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);\nextern PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC ptr_glClearNamedFramebufferuiv; void glClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value);\nextern PFNGLCLEARNAMEDFRAMEBUFFERFVPROC ptr_glClearNamedFramebufferfv; void glClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);\nextern PFNGLCLEARNAMEDFRAMEBUFFERFIPROC ptr_glClearNamedFramebufferfi; void glClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);\nextern PFNGLBLITNAMEDFRAMEBUFFERPROC ptr_glBlitNamedFramebuffer; void glBlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\nextern PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC ptr_glCheckNamedFramebufferStatus; GLenum glCheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);\nextern PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC ptr_glGetNamedFramebufferParameteriv; void glGetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname, GLint *param);\nextern PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC ptr_glGetNamedFramebufferAttachmentParameteriv; void glGetNamedFramebufferAttachmentParameteriv(GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);\nextern PFNGLCREATERENDERBUFFERSPROC ptr_glCreateRenderbuffers; void glCreateRenderbuffers(GLsizei n, GLuint *renderbuffers);\nextern PFNGLNAMEDRENDERBUFFERSTORAGEPROC ptr_glNamedRenderbufferStorage; void glNamedRenderbufferStorage(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC ptr_glNamedRenderbufferStorageMultisample; void glNamedRenderbufferStorageMultisample(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC ptr_glGetNamedRenderbufferParameteriv; void glGetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname, GLint *params);\nextern PFNGLCREATETEXTURESPROC ptr_glCreateTextures; void glCreateTextures(GLenum target, GLsizei n, GLuint *textures);\nextern PFNGLTEXTUREBUFFERPROC ptr_glTextureBuffer; void glTextureBuffer(GLuint texture, GLenum internalformat, GLuint buffer);\nextern PFNGLTEXTUREBUFFERRANGEPROC ptr_glTextureBufferRange; void glTextureBufferRange(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\nextern PFNGLTEXTURESTORAGE1DPROC ptr_glTextureStorage1D; void glTextureStorage1D(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);\nextern PFNGLTEXTURESTORAGE2DPROC ptr_glTextureStorage2D; void glTextureStorage2D(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\nextern PFNGLTEXTURESTORAGE3DPROC ptr_glTextureStorage3D; void glTextureStorage3D(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\nextern PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC ptr_glTextureStorage2DMultisample; void glTextureStorage2DMultisample(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nextern PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC ptr_glTextureStorage3DMultisample; void glTextureStorage3DMultisample(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nextern PFNGLTEXTURESUBIMAGE1DPROC ptr_glTextureSubImage1D; void glTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\nextern PFNGLTEXTURESUBIMAGE2DPROC ptr_glTextureSubImage2D; void glTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\nextern PFNGLTEXTURESUBIMAGE3DPROC ptr_glTextureSubImage3D; void glTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nextern PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC ptr_glCompressedTextureSubImage1D; void glCompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC ptr_glCompressedTextureSubImage2D; void glCompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC ptr_glCompressedTextureSubImage3D; void glCompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\nextern PFNGLCOPYTEXTURESUBIMAGE1DPROC ptr_glCopyTextureSubImage1D; void glCopyTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nextern PFNGLCOPYTEXTURESUBIMAGE2DPROC ptr_glCopyTextureSubImage2D; void glCopyTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nextern PFNGLCOPYTEXTURESUBIMAGE3DPROC ptr_glCopyTextureSubImage3D; void glCopyTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nextern PFNGLTEXTUREPARAMETERFPROC ptr_glTextureParameterf; void glTextureParameterf(GLuint texture, GLenum pname, GLfloat param);\nextern PFNGLTEXTUREPARAMETERFVPROC ptr_glTextureParameterfv; void glTextureParameterfv(GLuint texture, GLenum pname, const GLfloat *param);\nextern PFNGLTEXTUREPARAMETERIPROC ptr_glTextureParameteri; void glTextureParameteri(GLuint texture, GLenum pname, GLint param);\nextern PFNGLTEXTUREPARAMETERIIVPROC ptr_glTextureParameterIiv; void glTextureParameterIiv(GLuint texture, GLenum pname, const GLint *params);\nextern PFNGLTEXTUREPARAMETERIUIVPROC ptr_glTextureParameterIuiv; void glTextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params);\nextern PFNGLTEXTUREPARAMETERIVPROC ptr_glTextureParameteriv; void glTextureParameteriv(GLuint texture, GLenum pname, const GLint *param);\nextern PFNGLGENERATETEXTUREMIPMAPPROC ptr_glGenerateTextureMipmap; void glGenerateTextureMipmap(GLuint texture);\nextern PFNGLBINDTEXTUREUNITPROC ptr_glBindTextureUnit; void glBindTextureUnit(GLuint unit, GLuint texture);\nextern PFNGLGETTEXTUREIMAGEPROC ptr_glGetTextureImage; void glGetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nextern PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC ptr_glGetCompressedTextureImage; void glGetCompressedTextureImage(GLuint texture, GLint level, GLsizei bufSize, void *pixels);\nextern PFNGLGETTEXTURELEVELPARAMETERFVPROC ptr_glGetTextureLevelParameterfv; void glGetTextureLevelParameterfv(GLuint texture, GLint level, GLenum pname, GLfloat *params);\nextern PFNGLGETTEXTURELEVELPARAMETERIVPROC ptr_glGetTextureLevelParameteriv; void glGetTextureLevelParameteriv(GLuint texture, GLint level, GLenum pname, GLint *params);\nextern PFNGLGETTEXTUREPARAMETERFVPROC ptr_glGetTextureParameterfv; void glGetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params);\nextern PFNGLGETTEXTUREPARAMETERIIVPROC ptr_glGetTextureParameterIiv; void glGetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params);\nextern PFNGLGETTEXTUREPARAMETERIUIVPROC ptr_glGetTextureParameterIuiv; void glGetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params);\nextern PFNGLGETTEXTUREPARAMETERIVPROC ptr_glGetTextureParameteriv; void glGetTextureParameteriv(GLuint texture, GLenum pname, GLint *params);\nextern PFNGLCREATEVERTEXARRAYSPROC ptr_glCreateVertexArrays; void glCreateVertexArrays(GLsizei n, GLuint *arrays);\nextern PFNGLDISABLEVERTEXARRAYATTRIBPROC ptr_glDisableVertexArrayAttrib; void glDisableVertexArrayAttrib(GLuint vaobj, GLuint index);\nextern PFNGLENABLEVERTEXARRAYATTRIBPROC ptr_glEnableVertexArrayAttrib; void glEnableVertexArrayAttrib(GLuint vaobj, GLuint index);\nextern PFNGLVERTEXARRAYELEMENTBUFFERPROC ptr_glVertexArrayElementBuffer; void glVertexArrayElementBuffer(GLuint vaobj, GLuint buffer);\nextern PFNGLVERTEXARRAYVERTEXBUFFERPROC ptr_glVertexArrayVertexBuffer; void glVertexArrayVertexBuffer(GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\nextern PFNGLVERTEXARRAYVERTEXBUFFERSPROC ptr_glVertexArrayVertexBuffers; void glVertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\nextern PFNGLVERTEXARRAYATTRIBBINDINGPROC ptr_glVertexArrayAttribBinding; void glVertexArrayAttribBinding(GLuint vaobj, GLuint attribindex, GLuint bindingindex);\nextern PFNGLVERTEXARRAYATTRIBFORMATPROC ptr_glVertexArrayAttribFormat; void glVertexArrayAttribFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\nextern PFNGLVERTEXARRAYATTRIBIFORMATPROC ptr_glVertexArrayAttribIFormat; void glVertexArrayAttribIFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nextern PFNGLVERTEXARRAYATTRIBLFORMATPROC ptr_glVertexArrayAttribLFormat; void glVertexArrayAttribLFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nextern PFNGLVERTEXARRAYBINDINGDIVISORPROC ptr_glVertexArrayBindingDivisor; void glVertexArrayBindingDivisor(GLuint vaobj, GLuint bindingindex, GLuint divisor);\nextern PFNGLGETVERTEXARRAYIVPROC ptr_glGetVertexArrayiv; void glGetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param);\nextern PFNGLGETVERTEXARRAYINDEXEDIVPROC ptr_glGetVertexArrayIndexediv; void glGetVertexArrayIndexediv(GLuint vaobj, GLuint index, GLenum pname, GLint *param);\nextern PFNGLGETVERTEXARRAYINDEXED64IVPROC ptr_glGetVertexArrayIndexed64iv; void glGetVertexArrayIndexed64iv(GLuint vaobj, GLuint index, GLenum pname, GLint64 *param);\nextern PFNGLCREATESAMPLERSPROC ptr_glCreateSamplers; void glCreateSamplers(GLsizei n, GLuint *samplers);\nextern PFNGLCREATEPROGRAMPIPELINESPROC ptr_glCreateProgramPipelines; void glCreateProgramPipelines(GLsizei n, GLuint *pipelines);\nextern PFNGLCREATEQUERIESPROC ptr_glCreateQueries; void glCreateQueries(GLenum target, GLsizei n, GLuint *ids);\nextern PFNGLGETQUERYBUFFEROBJECTI64VPROC ptr_glGetQueryBufferObjecti64v; void glGetQueryBufferObjecti64v(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);\nextern PFNGLGETQUERYBUFFEROBJECTIVPROC ptr_glGetQueryBufferObjectiv; void glGetQueryBufferObjectiv(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);\nextern PFNGLGETQUERYBUFFEROBJECTUI64VPROC ptr_glGetQueryBufferObjectui64v; void glGetQueryBufferObjectui64v(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);\nextern PFNGLGETQUERYBUFFEROBJECTUIVPROC ptr_glGetQueryBufferObjectuiv; void glGetQueryBufferObjectuiv(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);\nextern PFNGLMEMORYBARRIERBYREGIONPROC ptr_glMemoryBarrierByRegion; void glMemoryBarrierByRegion(GLbitfield barriers);\nextern PFNGLGETTEXTURESUBIMAGEPROC ptr_glGetTextureSubImage; void glGetTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nextern PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC ptr_glGetCompressedTextureSubImage; void glGetCompressedTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);\nextern PFNGLGETGRAPHICSRESETSTATUSPROC ptr_glGetGraphicsResetStatus; GLenum glGetGraphicsResetStatus(void);\nextern PFNGLGETNCOMPRESSEDTEXIMAGEPROC ptr_glGetnCompressedTexImage; void glGetnCompressedTexImage(GLenum target, GLint lod, GLsizei bufSize, void *pixels);\nextern PFNGLGETNTEXIMAGEPROC ptr_glGetnTexImage; void glGetnTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nextern PFNGLGETNUNIFORMDVPROC ptr_glGetnUniformdv; void glGetnUniformdv(GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\nextern PFNGLGETNUNIFORMFVPROC ptr_glGetnUniformfv; void glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);\nextern PFNGLGETNUNIFORMIVPROC ptr_glGetnUniformiv; void glGetnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params);\nextern PFNGLGETNUNIFORMUIVPROC ptr_glGetnUniformuiv; void glGetnUniformuiv(GLuint program, GLint location, GLsizei bufSize, GLuint *params);\nextern PFNGLREADNPIXELSPROC ptr_glReadnPixels; void glReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\nextern PFNGLGETNMAPDVPROC ptr_glGetnMapdv; void glGetnMapdv(GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);\nextern PFNGLGETNMAPFVPROC ptr_glGetnMapfv; void glGetnMapfv(GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);\nextern PFNGLGETNMAPIVPROC ptr_glGetnMapiv; void glGetnMapiv(GLenum target, GLenum query, GLsizei bufSize, GLint *v);\nextern PFNGLGETNPIXELMAPFVPROC ptr_glGetnPixelMapfv; void glGetnPixelMapfv(GLenum map, GLsizei bufSize, GLfloat *values);\nextern PFNGLGETNPIXELMAPUIVPROC ptr_glGetnPixelMapuiv; void glGetnPixelMapuiv(GLenum map, GLsizei bufSize, GLuint *values);\nextern PFNGLGETNPIXELMAPUSVPROC ptr_glGetnPixelMapusv; void glGetnPixelMapusv(GLenum map, GLsizei bufSize, GLushort *values);\nextern PFNGLGETNPOLYGONSTIPPLEPROC ptr_glGetnPolygonStipple; void glGetnPolygonStipple(GLsizei bufSize, GLubyte *pattern);\nextern PFNGLGETNCOLORTABLEPROC ptr_glGetnColorTable; void glGetnColorTable(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);\nextern PFNGLGETNCONVOLUTIONFILTERPROC ptr_glGetnConvolutionFilter; void glGetnConvolutionFilter(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);\nextern PFNGLGETNSEPARABLEFILTERPROC ptr_glGetnSeparableFilter; void glGetnSeparableFilter(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);\nextern PFNGLGETNHISTOGRAMPROC ptr_glGetnHistogram; void glGetnHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\nextern PFNGLGETNMINMAXPROC ptr_glGetnMinmax; void glGetnMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\nextern PFNGLTEXTUREBARRIERPROC ptr_glTextureBarrier; void glTextureBarrier(void);\nextern PFNGLSPECIALIZESHADERPROC ptr_glSpecializeShader; void glSpecializeShader(GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue);\nextern PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC ptr_glMultiDrawArraysIndirectCount; void glMultiDrawArraysIndirectCount(GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\nextern PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC ptr_glMultiDrawElementsIndirectCount; void glMultiDrawElementsIndirectCount(GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\nextern PFNGLPOLYGONOFFSETCLAMPPROC ptr_glPolygonOffsetClamp; void glPolygonOffsetClamp(GLfloat factor, GLfloat units, GLfloat clamp);\nextern PFNGLGETTEXTUREHANDLEARBPROC ptr_glGetTextureHandle; GLuint64 glGetTextureHandle(GLuint texture);\nextern PFNGLGETTEXTURESAMPLERHANDLEARBPROC ptr_glGetTextureSamplerHandle; GLuint64 glGetTextureSamplerHandle(GLuint texture, GLuint sampler);\nextern PFNGLMAKETEXTUREHANDLERESIDENTARBPROC ptr_glMakeTextureHandleResident; void glMakeTextureHandleResident(GLuint64 handle);\nextern PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC ptr_glMakeTextureHandleNonResident; void glMakeTextureHandleNonResident(GLuint64 handle);\nextern PFNGLGETIMAGEHANDLEARBPROC ptr_glGetImageHandle; GLuint64 glGetImageHandle(GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\nextern PFNGLMAKEIMAGEHANDLERESIDENTARBPROC ptr_glMakeImageHandleResident; void glMakeImageHandleResident(GLuint64 handle, GLenum access);\nextern PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC ptr_glMakeImageHandleNonResident; void glMakeImageHandleNonResident(GLuint64 handle);\nextern PFNGLUNIFORMHANDLEUI64ARBPROC ptr_glUniformHandleui64; void glUniformHandleui64(GLint location, GLuint64 value);\nextern PFNGLUNIFORMHANDLEUI64VARBPROC ptr_glUniformHandleui64v; void glUniformHandleui64v(GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC ptr_glProgramUniformHandleui64; void glProgramUniformHandleui64(GLuint program, GLint location, GLuint64 value);\nextern PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC ptr_glProgramUniformHandleui64v; void glProgramUniformHandleui64v(GLuint program, GLint location, GLsizei count, const GLuint64 *values);\nextern PFNGLISTEXTUREHANDLERESIDENTARBPROC ptr_glIsTextureHandleResident; GLboolean glIsTextureHandleResident(GLuint64 handle);\nextern PFNGLISIMAGEHANDLERESIDENTARBPROC ptr_glIsImageHandleResident; GLboolean glIsImageHandleResident(GLuint64 handle);\nextern PFNGLVERTEXATTRIBL1UI64ARBPROC ptr_glVertexAttribL1ui64; void glVertexAttribL1ui64(GLuint index, GLuint64EXT x);\nextern PFNGLVERTEXATTRIBL1UI64VARBPROC ptr_glVertexAttribL1ui64v; void glVertexAttribL1ui64v(GLuint index, const GLuint64EXT *v);\nextern PFNGLGETVERTEXATTRIBLUI64VARBPROC ptr_glGetVertexAttribLui64v; void glGetVertexAttribLui64v(GLuint index, GLenum pname, GLuint64EXT *params);\nextern PFNGLUNIFORM1I64ARBPROC ptr_glUniform1i64; void glUniform1i64(GLint location, GLint64 x);\nextern PFNGLUNIFORM2I64ARBPROC ptr_glUniform2i64; void glUniform2i64(GLint location, GLint64 x, GLint64 y);\nextern PFNGLUNIFORM3I64ARBPROC ptr_glUniform3i64; void glUniform3i64(GLint location, GLint64 x, GLint64 y, GLint64 z);\nextern PFNGLUNIFORM4I64ARBPROC ptr_glUniform4i64; void glUniform4i64(GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);\nextern PFNGLUNIFORM1I64VARBPROC ptr_glUniform1i64v; void glUniform1i64v(GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLUNIFORM2I64VARBPROC ptr_glUniform2i64v; void glUniform2i64v(GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLUNIFORM3I64VARBPROC ptr_glUniform3i64v; void glUniform3i64v(GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLUNIFORM4I64VARBPROC ptr_glUniform4i64v; void glUniform4i64v(GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLUNIFORM1UI64ARBPROC ptr_glUniform1ui64; void glUniform1ui64(GLint location, GLuint64 x);\nextern PFNGLUNIFORM2UI64ARBPROC ptr_glUniform2ui64; void glUniform2ui64(GLint location, GLuint64 x, GLuint64 y);\nextern PFNGLUNIFORM3UI64ARBPROC ptr_glUniform3ui64; void glUniform3ui64(GLint location, GLuint64 x, GLuint64 y, GLuint64 z);\nextern PFNGLUNIFORM4UI64ARBPROC ptr_glUniform4ui64; void glUniform4ui64(GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);\nextern PFNGLUNIFORM1UI64VARBPROC ptr_glUniform1ui64v; void glUniform1ui64v(GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLUNIFORM2UI64VARBPROC ptr_glUniform2ui64v; void glUniform2ui64v(GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLUNIFORM3UI64VARBPROC ptr_glUniform3ui64v; void glUniform3ui64v(GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLUNIFORM4UI64VARBPROC ptr_glUniform4ui64v; void glUniform4ui64v(GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLGETUNIFORMI64VARBPROC ptr_glGetUniformi64v; void glGetUniformi64v(GLuint program, GLint location, GLint64 *params);\nextern PFNGLGETUNIFORMUI64VARBPROC ptr_glGetUniformui64v; void glGetUniformui64v(GLuint program, GLint location, GLuint64 *params);\nextern PFNGLGETNUNIFORMI64VARBPROC ptr_glGetnUniformi64v; void glGetnUniformi64v(GLuint program, GLint location, GLsizei bufSize, GLint64 *params);\nextern PFNGLGETNUNIFORMUI64VARBPROC ptr_glGetnUniformui64v; void glGetnUniformui64v(GLuint program, GLint location, GLsizei bufSize, GLuint64 *params);\nextern PFNGLPROGRAMUNIFORM1I64ARBPROC ptr_glProgramUniform1i64; void glProgramUniform1i64(GLuint program, GLint location, GLint64 x);\nextern PFNGLPROGRAMUNIFORM2I64ARBPROC ptr_glProgramUniform2i64; void glProgramUniform2i64(GLuint program, GLint location, GLint64 x, GLint64 y);\nextern PFNGLPROGRAMUNIFORM3I64ARBPROC ptr_glProgramUniform3i64; void glProgramUniform3i64(GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z);\nextern PFNGLPROGRAMUNIFORM4I64ARBPROC ptr_glProgramUniform4i64; void glProgramUniform4i64(GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);\nextern PFNGLPROGRAMUNIFORM1I64VARBPROC ptr_glProgramUniform1i64v; void glProgramUniform1i64v(GLuint program, GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLPROGRAMUNIFORM2I64VARBPROC ptr_glProgramUniform2i64v; void glProgramUniform2i64v(GLuint program, GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLPROGRAMUNIFORM3I64VARBPROC ptr_glProgramUniform3i64v; void glProgramUniform3i64v(GLuint program, GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLPROGRAMUNIFORM4I64VARBPROC ptr_glProgramUniform4i64v; void glProgramUniform4i64v(GLuint program, GLint location, GLsizei count, const GLint64 *value);\nextern PFNGLPROGRAMUNIFORM1UI64ARBPROC ptr_glProgramUniform1ui64; void glProgramUniform1ui64(GLuint program, GLint location, GLuint64 x);\nextern PFNGLPROGRAMUNIFORM2UI64ARBPROC ptr_glProgramUniform2ui64; void glProgramUniform2ui64(GLuint program, GLint location, GLuint64 x, GLuint64 y);\nextern PFNGLPROGRAMUNIFORM3UI64ARBPROC ptr_glProgramUniform3ui64; void glProgramUniform3ui64(GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z);\nextern PFNGLPROGRAMUNIFORM4UI64ARBPROC ptr_glProgramUniform4ui64; void glProgramUniform4ui64(GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);\nextern PFNGLPROGRAMUNIFORM1UI64VARBPROC ptr_glProgramUniform1ui64v; void glProgramUniform1ui64v(GLuint program, GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLPROGRAMUNIFORM2UI64VARBPROC ptr_glProgramUniform2ui64v; void glProgramUniform2ui64v(GLuint program, GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLPROGRAMUNIFORM3UI64VARBPROC ptr_glProgramUniform3ui64v; void glProgramUniform3ui64v(GLuint program, GLint location, GLsizei count, const GLuint64 *value);\nextern PFNGLPROGRAMUNIFORM4UI64VARBPROC ptr_glProgramUniform4ui64v; void glProgramUniform4ui64v(GLuint program, GLint location, GLsizei count, const GLuint64 *value);\n"}, {"path": "utils/mesh.cpp", "language": "cpp", "loc": 215, "comment_density": 0.019, "code": "\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \"mesh.h\"\n#include \"math_helpers.h\"\n\nstruct ind_type { uint32_t position, uv, normal, material; };\n\nbool operator==(const ind_type& a, const ind_type& b) {\n\treturn a.position == b.position && a.uv == b.uv && a.normal == b.normal && a.material == b.material;\n}\n\nnamespace std {\n\ttemplate<>\n\tstruct hash {\n\t\tsize_t operator()(const ind_type& i) const {\n\t\t\tsize_t result = 0;\n\t\t\tfor (uint32_t k : {i.position, i.uv, i.normal, i.material}) {\n\t\t\t\tsrnd(k); rnd();\n\t\t\t\tresult ^= rnd_seed + 0x9e3779b9 + (result << 6) + (result >> 2);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t};\n}\n\nvoid get_mesh(const char* filename, void* meshPtr, bool smooth_shaded) {\n\t\n\tusing namespace std;\n\t\n\tstruct binary_header {\n\t\tuint32_t position_count, uv_count, normal_count, material_count, triangle_count;\n\t};\n\n\tvector positions;\n\tvector uvs;\n\tvector normals;\n\tvector material_albedos;\n\tvector indices;\n\t\n\tfilesystem::path path(filename);\n\t\n\tpath.replace_extension(\".bin\");\n\tif (!filesystem::exists(path)) {\n\n\t\tpath.replace_extension(\".mtl\");\n\t\tFILE* mtlFile = fopen(path.string().c_str(), \"rb\");\n\t\tfseek(mtlFile, 0, SEEK_END);\n\t\tconst size_t mtlSize = size_t(ftell(mtlFile)) + 1;\n\n\t\tvector mtlContents(mtlSize);\n\t\tmtlContents.back() = '\\0';\n\t\tfseek(mtlFile, 0, SEEK_SET);\n\t\tfread(mtlContents.data(), 1, mtlSize - 1, mtlFile);\n\t\tfclose(mtlFile);\n\n\t\tvector mtlNameIndices;\n\t\tvec3 color(1.f);\n\t\tint i = 0;\n\t\twhile (i < mtlSize - 1) {\n\t\t\tif (mtlContents[i] == 'n') {\n\t\t\t\ti += 7; // skip \"newmtl \"\n\t\t\t\twhile (mtlContents[i] == ' ' || mtlContents[i] == '\\t') i++;\n\n\t\t\t\tif (mtlNameIndices.size() > 0)\n\t\t\t\t\tmaterial_albedos.push_back(color);\n\t\t\t\tmtlNameIndices.push_back(i);\n\t\t\t}\n\t\t\telse if (mtlContents[i] == 'K' && mtlContents[i+1] == 'd')\n\t\t\t\tsscanf(mtlContents.data() + i + 2, \" %g %g %g\", color.data, color.data+1, color.data+2);\n\t\t\twhile (i < mtlSize - 1 && mtlContents[i++] != '\\n');\n\t\t}\n\t\tmaterial_albedos.push_back(color);\n\t\n\t\tpath.replace_extension(\".obj\");\n\n\t\tFILE* objFile = fopen(path.string().c_str(), \"rb\");\n\t\tfseek(objFile, 0, SEEK_END);\n\t\tconst size_t objSize = size_t(ftell(objFile)) + 1;\n\n\t\tvector objContents(objSize);\n\t\tobjContents.back() = '\\0';\n\t\tfseek(objFile, 0, SEEK_SET);\n\t\tfread(objContents.data(), 1, objSize - 1, objFile);\n\t\tfclose(objFile);\n\n\t\tint use_mtl_index = 0;\n\t\ti = 0;\n\t\twhile (i= 2)\n\t\t\t\t\t\tfor(int k = 0; k<3; ++k)\n\t\t\t\t\t\t\tindices.push_back(sweep_inds[k]);\n\n\t\t\t\t\tsweep_inds[1] = sweep_inds[2];\n\t\t\t\t\tj++; write_index = 2;\n\n\t\t\t\t\twhile (objContents[i] == ' ' || objContents[i] == '\\t') i++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (objContents[i] == 'u' && objContents[i+1] == 's') {\n\t\t\t\tuse_mtl_index = -1;\n\t\t\t\ti += 7; // skip \"usemtl \"\n\t\t\t\twhile (objContents[i] == ' ' || objContents[i] == '\\t') i++;\n\t\t\t\tfor (auto j: mtlNameIndices) {\n\t\t\t\t\tuse_mtl_index++;\n\t\t\t\t\tint k = i;\n\t\t\t\t\tbool match = false;\n\t\t\t\t\twhile (objContents[k] == mtlContents[j] && objContents[k] != '\\0') {\n\t\t\t\t\t\tif (objContents[k] == ' ' || objContents[k] == '\\t' || objContents[k] == '\\n' || objContents[k] == '\\0') {\n\t\t\t\t\t\t\tmatch = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tk++; j++;\n\t\t\t\t\t}\n\t\t\t\t\tif (match) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (i < objSize - 1 && objContents[i] != '\\n') i++;\n\t\t\ti++;\n\t\t}\n\t\tpath.replace_extension(\".bin\");\n\t\tFILE* binFile = fopen(path.string().c_str(), \"wb\");\n\t\tbinary_header header = { uint32_t(positions.size()), uint32_t(uvs.size()), uint32_t(normals.size()), uint32_t(material_albedos.size()), uint32_t(indices.size()) };\n\t\tfwrite(&header, sizeof(header), 1, binFile);\n\t\tfwrite(positions.data(), sizeof(positions[0]), positions.size(), binFile);\n\t\tfwrite(uvs.data(), sizeof(uvs[0]), uvs.size(), binFile);\n\t\tfwrite(normals.data(), sizeof(normals[0]), normals.size(), binFile);\n\t\tfwrite(material_albedos.data(), sizeof(material_albedos[0]), material_albedos.size(), binFile);\n\t\tfwrite(indices.data(), sizeof(indices[0]), indices.size(), binFile);\n\t\tfclose(binFile);\n\t}\n\telse {\n\t\tFILE* binFile = fopen(path.string().c_str(), \"rb\");\n\t\tbinary_header header;\n\t\tfread(&header, sizeof(header), 1, binFile);\n\t\tpositions.resize(header.position_count); uvs.resize(header.uv_count); normals.resize(header.normal_count);\n\t\tmaterial_albedos.resize(header.material_count); indices.resize(header.triangle_count);\n\t\tfread(positions.data(), sizeof(positions[0]), positions.size(), binFile);\n\t\tfread(uvs.data(), sizeof(uvs[0]), uvs.size(), binFile);\n\t\tfread(normals.data(), sizeof(normals[0]), normals.size(), binFile);\n\t\tfread(material_albedos.data(), sizeof(material_albedos[0]), material_albedos.size(), binFile);\n\t\tfread(indices.data(), sizeof(indices[0]), indices.size(), binFile);\n\t\tfclose(binFile);\n\t}\n\n\tif (!smooth_shaded) {\n\t\tFlatMesh* mesh = (FlatMesh*)meshPtr;\n\t\tmesh->triangle_count = int(indices.size()/3);\n#ifdef _WIN32\n\t\tmesh->triangles = (FlatMesh::triangle*)_aligned_malloc(mesh->triangle_count * sizeof(FlatMesh::triangle), 16);\n#else\t\t\t\t\t\t\t\t\t\t\t// see how the arguments are flipped? pretty funny joke by whoever defined these :)\n\t\tmesh->triangles = (FlatMesh::triangle*)aligned_alloc(16, mesh->triangle_count * sizeof(FlatMesh::triangle));\n#endif\n\t\tfor (int i = 0; i < mesh->triangle_count; ++i) {\n\t\t\tvec3 color = material_albedos[indices[i * 3].material];\n\t\t\tfor (int j = 0; j < 3; ++j) {\n\t\t\t\tconst auto ind = indices[i * 3 + j];\n\t\t\t\tvec3 position = positions[ind.position];\n\t\t\t\t\n\t\t\t\tmesh->triangles[i].vertices[j].position = _mm_setr_ps(position.x, position.y, position.z, 1.f);\n\t\t\t\tvec3 normal = normals[ind.normal];\n\t\t\t\tmesh->triangles[i].vertices[j].normal = _mm_setr_ps(normal.x, normal.y, normal.z, 1.f);\n\t\t\t\tmesh->triangles[i].vertices[j].color = _mm_setr_ps(color.r, color.g, color.b, 1.f);\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tMesh* mesh = (Mesh*)meshPtr;\n\t\tmesh->triangle_count = int(indices.size() / 3);\n\t\tmesh->vertex_count = int(positions.size());\n\n\t\tstd::unordered_map ind_to_vert;\n\t\tstd::vector verts;\n\t\tstd::vector inds;\n\n\t\tfor (ind_type i : indices) {\n\t\t\tif(i.position > mesh->vertex_count) continue;\n\t\t\tif (!ind_to_vert.count(i)) {\n\t\t\t\tind_to_vert[i] = verts.size();\n\t\t\t\tverts.push_back({});\n\t\t\t\tverts.back().position = vec4(positions[i.position], 1.f);\n\t\t\t\tverts.back().normal = i.normal < normals.size() ? vec4(normals[i.normal], 1.f) : vec4(.0f);\n\t\t\t\tverts.back().uv = i.uvvertex_count = verts.size();\n\t\tmesh->verts = new Mesh::vertex[mesh->vertex_count];\n\t\tmemcpy(mesh->verts, verts.data(), sizeof(Mesh::vertex)*verts.size());\n\t\tmesh->indices = new uint32_t[mesh->triangle_count * 3];\n\t\tmemcpy(mesh->indices, inds.data(), sizeof(uint32_t)*inds.size());\n\t}\n}\n\n"}, {"path": "utils/mesh.h", "language": "c", "loc": 35, "comment_density": 0.0, "code": "#pragma once\n\n\n#include \n\nvoid get_mesh(const char* filename, void* mesh, bool smooth_shaded);\n\nstruct FlatMesh {\n\tstruct vertex {\n\t\t__m128 position, normal, color;\n\t};\n\tstruct triangle {\n\t\tvertex vertices[3];\n\t} *triangles = nullptr;\n\tint triangle_count = 0;\n\n\tFlatMesh(const char* filename) {\n\t\tget_mesh(filename, this, false);\n\t}\n\t~FlatMesh() {\n#ifdef _WIN32\n\t\t_aligned_free(triangles);\n#else\n\t\tfree(triangles);\n#endif\n\t}\n};\n\n#include \"glsl.h\"\n\nstruct Mesh {\n\tstruct vertex {\n\t\tvec4 position, normal, color;\n\t\tvec2 uv;\n\t} *verts = nullptr;\n\tuint32_t* indices = nullptr;\n\tint vertex_count = 0, triangle_count = 0;\n\n\tMesh(const char* filename) {\n\t\tget_mesh(filename, this, true);\n\t}\n\t~Mesh() { delete[] verts; delete[] indices; }\n};\n"}, {"path": "utils/wglext.h", "language": "c", "loc": 788, "comment_density": 0.115, "code": "#ifndef __wglext_h_\n#define __wglext_h_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\t/*\n\t** Copyright (c) 2013-2017 The Khronos Group Inc.\n\t**\n\t** Permission is hereby granted, free of charge, to any person obtaining a\n\t** copy of this software and/or associated documentation files (the\n\t** \"Materials\"), to deal in the Materials without restriction, including\n\t** without limitation the rights to use, copy, modify, merge, publish,\n\t** distribute, sublicense, and/or sell copies of the Materials, and to\n\t** permit persons to whom the Materials are furnished to do so, subject to\n\t** the following conditions:\n\t**\n\t** The above copyright notice and this permission notice shall be included\n\t** in all copies or substantial portions of the Materials.\n\t**\n\t** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n\t** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\t** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n\t** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n\t** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n\t** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n\t** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n\t*/\n\t/*\n\t** This header is generated from the Khronos OpenGL / OpenGL ES XML\n\t** API Registry. The current version of the Registry, generator scripts\n\t** used to make the header, and the header can be found at\n\t** https://github.com/KhronosGroup/OpenGL-Registry\n\t*/\n\n#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)\n#define WIN32_LEAN_AND_MEAN 1\n#include \n#endif\n\n#define WGL_WGLEXT_VERSION 20170817\n\n\t/* Generated C header for:\n\t* API: wgl\n\t* Versions considered: .*\n\t* Versions emitted: _nomatch_^\n\t* Default extensions included: wgl\n\t* Additional extensions included: _nomatch_^\n\t* Extensions removed: _nomatch_^\n\t*/\n\n#ifndef WGL_ARB_buffer_region\n#define WGL_ARB_buffer_region 1\n#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001\n#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002\n#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004\n#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008\n\ttypedef HANDLE(WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);\n\ttypedef VOID(WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);\n\ttypedef BOOL(WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);\n\ttypedef BOOL(WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tHANDLE WINAPI wglCreateBufferRegionARB(HDC hDC, int iLayerPlane, UINT uType);\n\tVOID WINAPI wglDeleteBufferRegionARB(HANDLE hRegion);\n\tBOOL WINAPI wglSaveBufferRegionARB(HANDLE hRegion, int x, int y, int width, int height);\n\tBOOL WINAPI wglRestoreBufferRegionARB(HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\n#endif\n#endif /* WGL_ARB_buffer_region */\n\n#ifndef WGL_ARB_context_flush_control\n#define WGL_ARB_context_flush_control 1\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098\n#endif /* WGL_ARB_context_flush_control */\n\n#ifndef WGL_ARB_create_context\n#define WGL_ARB_create_context 1\n#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001\n#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002\n#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091\n#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092\n#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093\n#define WGL_CONTEXT_FLAGS_ARB 0x2094\n#define ERROR_INVALID_VERSION_ARB 0x2095\n\ttypedef HGLRC(WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tHGLRC WINAPI wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList);\n#endif\n#endif /* WGL_ARB_create_context */\n\n#ifndef WGL_ARB_create_context_no_error\n#define WGL_ARB_create_context_no_error 1\n#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3\n#endif /* WGL_ARB_create_context_no_error */\n\n#ifndef WGL_ARB_create_context_profile\n#define WGL_ARB_create_context_profile 1\n#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126\n#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\n#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define ERROR_INVALID_PROFILE_ARB 0x2096\n#endif /* WGL_ARB_create_context_profile */\n\n#ifndef WGL_ARB_create_context_robustness\n#define WGL_ARB_create_context_robustness 1\n#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252\n#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261\n#endif /* WGL_ARB_create_context_robustness */\n\n#ifndef WGL_ARB_extensions_string\n#define WGL_ARB_extensions_string 1\n\ttypedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tconst char *WINAPI wglGetExtensionsStringARB(HDC hdc);\n#endif\n#endif /* WGL_ARB_extensions_string */\n\n#ifndef WGL_ARB_framebuffer_sRGB\n#define WGL_ARB_framebuffer_sRGB 1\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9\n#endif /* WGL_ARB_framebuffer_sRGB */\n\n#ifndef WGL_ARB_make_current_read\n#define WGL_ARB_make_current_read 1\n#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043\n#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054\n\ttypedef BOOL(WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\ttypedef HDC(WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglMakeContextCurrentARB(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\tHDC WINAPI wglGetCurrentReadDCARB(void);\n#endif\n#endif /* WGL_ARB_make_current_read */\n\n#ifndef WGL_ARB_multisample\n#define WGL_ARB_multisample 1\n#define WGL_SAMPLE_BUFFERS_ARB 0x2041\n#define WGL_SAMPLES_ARB 0x2042\n#endif /* WGL_ARB_multisample */\n\n#ifndef WGL_ARB_pbuffer\n#define WGL_ARB_pbuffer 1\n\tDECLARE_HANDLE(HPBUFFERARB);\n#define WGL_DRAW_TO_PBUFFER_ARB 0x202D\n#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E\n#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030\n#define WGL_PBUFFER_LARGEST_ARB 0x2033\n#define WGL_PBUFFER_WIDTH_ARB 0x2034\n#define WGL_PBUFFER_HEIGHT_ARB 0x2035\n#define WGL_PBUFFER_LOST_ARB 0x2036\n\ttypedef HPBUFFERARB(WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\n\ttypedef HDC(WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);\n\ttypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);\n\ttypedef BOOL(WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tHPBUFFERARB WINAPI wglCreatePbufferARB(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\n\tHDC WINAPI wglGetPbufferDCARB(HPBUFFERARB hPbuffer);\n\tint WINAPI wglReleasePbufferDCARB(HPBUFFERARB hPbuffer, HDC hDC);\n\tBOOL WINAPI wglDestroyPbufferARB(HPBUFFERARB hPbuffer);\n\tBOOL WINAPI wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAttribute, int *piValue);\n#endif\n#endif /* WGL_ARB_pbuffer */\n\n#ifndef WGL_ARB_pixel_format\n#define WGL_ARB_pixel_format 1\n#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000\n#define WGL_DRAW_TO_WINDOW_ARB 0x2001\n#define WGL_DRAW_TO_BITMAP_ARB 0x2002\n#define WGL_ACCELERATION_ARB 0x2003\n#define WGL_NEED_PALETTE_ARB 0x2004\n#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005\n#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006\n#define WGL_SWAP_METHOD_ARB 0x2007\n#define WGL_NUMBER_OVERLAYS_ARB 0x2008\n#define WGL_NUMBER_UNDERLAYS_ARB 0x2009\n#define WGL_TRANSPARENT_ARB 0x200A\n#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037\n#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038\n#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039\n#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A\n#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B\n#define WGL_SHARE_DEPTH_ARB 0x200C\n#define WGL_SHARE_STENCIL_ARB 0x200D\n#define WGL_SHARE_ACCUM_ARB 0x200E\n#define WGL_SUPPORT_GDI_ARB 0x200F\n#define WGL_SUPPORT_OPENGL_ARB 0x2010\n#define WGL_DOUBLE_BUFFER_ARB 0x2011\n#define WGL_STEREO_ARB 0x2012\n#define WGL_PIXEL_TYPE_ARB 0x2013\n#define WGL_COLOR_BITS_ARB 0x2014\n#define WGL_RED_BITS_ARB 0x2015\n#define WGL_RED_SHIFT_ARB 0x2016\n#define WGL_GREEN_BITS_ARB 0x2017\n#define WGL_GREEN_SHIFT_ARB 0x2018\n#define WGL_BLUE_BITS_ARB 0x2019\n#define WGL_BLUE_SHIFT_ARB 0x201A\n#define WGL_ALPHA_BITS_ARB 0x201B\n#define WGL_ALPHA_SHIFT_ARB 0x201C\n#define WGL_ACCUM_BITS_ARB 0x201D\n#define WGL_ACCUM_RED_BITS_ARB 0x201E\n#define WGL_ACCUM_GREEN_BITS_ARB 0x201F\n#define WGL_ACCUM_BLUE_BITS_ARB 0x2020\n#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021\n#define WGL_DEPTH_BITS_ARB 0x2022\n#define WGL_STENCIL_BITS_ARB 0x2023\n#define WGL_AUX_BUFFERS_ARB 0x2024\n#define WGL_NO_ACCELERATION_ARB 0x2025\n#define WGL_GENERIC_ACCELERATION_ARB 0x2026\n#define WGL_FULL_ACCELERATION_ARB 0x2027\n#define WGL_SWAP_EXCHANGE_ARB 0x2028\n#define WGL_SWAP_COPY_ARB 0x2029\n#define WGL_SWAP_UNDEFINED_ARB 0x202A\n#define WGL_TYPE_RGBA_ARB 0x202B\n#define WGL_TYPE_COLORINDEX_ARB 0x202C\n\ttypedef BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);\n\ttypedef BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);\n\ttypedef BOOL(WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetPixelFormatAttribivARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);\n\tBOOL WINAPI wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);\n\tBOOL WINAPI wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#endif\n#endif /* WGL_ARB_pixel_format */\n\n#ifndef WGL_ARB_pixel_format_float\n#define WGL_ARB_pixel_format_float 1\n#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0\n#endif /* WGL_ARB_pixel_format_float */\n\n#ifndef WGL_ARB_render_texture\n#define WGL_ARB_render_texture 1\n#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070\n#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071\n#define WGL_TEXTURE_FORMAT_ARB 0x2072\n#define WGL_TEXTURE_TARGET_ARB 0x2073\n#define WGL_MIPMAP_TEXTURE_ARB 0x2074\n#define WGL_TEXTURE_RGB_ARB 0x2075\n#define WGL_TEXTURE_RGBA_ARB 0x2076\n#define WGL_NO_TEXTURE_ARB 0x2077\n#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078\n#define WGL_TEXTURE_1D_ARB 0x2079\n#define WGL_TEXTURE_2D_ARB 0x207A\n#define WGL_MIPMAP_LEVEL_ARB 0x207B\n#define WGL_CUBE_MAP_FACE_ARB 0x207C\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082\n#define WGL_FRONT_LEFT_ARB 0x2083\n#define WGL_FRONT_RIGHT_ARB 0x2084\n#define WGL_BACK_LEFT_ARB 0x2085\n#define WGL_BACK_RIGHT_ARB 0x2086\n#define WGL_AUX0_ARB 0x2087\n#define WGL_AUX1_ARB 0x2088\n#define WGL_AUX2_ARB 0x2089\n#define WGL_AUX3_ARB 0x208A\n#define WGL_AUX4_ARB 0x208B\n#define WGL_AUX5_ARB 0x208C\n#define WGL_AUX6_ARB 0x208D\n#define WGL_AUX7_ARB 0x208E\n#define WGL_AUX8_ARB 0x208F\n#define WGL_AUX9_ARB 0x2090\n\ttypedef BOOL(WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\n\ttypedef BOOL(WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\n\ttypedef BOOL(WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer);\n\tBOOL WINAPI wglReleaseTexImageARB(HPBUFFERARB hPbuffer, int iBuffer);\n\tBOOL WINAPI wglSetPbufferAttribARB(HPBUFFERARB hPbuffer, const int *piAttribList);\n#endif\n#endif /* WGL_ARB_render_texture */\n\n#ifndef WGL_ARB_robustness_application_isolation\n#define WGL_ARB_robustness_application_isolation 1\n#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\n#endif /* WGL_ARB_robustness_application_isolation */\n\n#ifndef WGL_ARB_robustness_share_group_isolation\n#define WGL_ARB_robustness_share_group_isolation 1\n#endif /* WGL_ARB_robustness_share_group_isolation */\n\n#ifndef WGL_3DFX_multisample\n#define WGL_3DFX_multisample 1\n#define WGL_SAMPLE_BUFFERS_3DFX 0x2060\n#define WGL_SAMPLES_3DFX 0x2061\n#endif /* WGL_3DFX_multisample */\n\n#ifndef WGL_3DL_stereo_control\n#define WGL_3DL_stereo_control 1\n#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055\n#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056\n#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057\n#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058\n\ttypedef BOOL(WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglSetStereoEmitterState3DL(HDC hDC, UINT uState);\n#endif\n#endif /* WGL_3DL_stereo_control */\n\n#ifndef WGL_AMD_gpu_association\n#define WGL_AMD_gpu_association 1\n#define WGL_GPU_VENDOR_AMD 0x1F00\n#define WGL_GPU_RENDERER_STRING_AMD 0x1F01\n#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\n#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2\n#define WGL_GPU_RAM_AMD 0x21A3\n#define WGL_GPU_CLOCK_AMD 0x21A4\n#define WGL_GPU_NUM_PIPES_AMD 0x21A5\n#define WGL_GPU_NUM_SIMD_AMD 0x21A6\n#define WGL_GPU_NUM_RB_AMD 0x21A7\n#define WGL_GPU_NUM_SPI_AMD 0x21A8\n\ttypedef UINT(WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);\n\ttypedef INT(WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);\n\ttypedef UINT(WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);\n\ttypedef HGLRC(WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);\n\ttypedef HGLRC(WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);\n\ttypedef BOOL(WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);\n\ttypedef BOOL(WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);\n\ttypedef HGLRC(WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);\n\ttypedef VOID(WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tUINT WINAPI wglGetGPUIDsAMD(UINT maxCount, UINT *ids);\n\tINT WINAPI wglGetGPUInfoAMD(UINT id, int property, GLenum dataType, UINT size, void *data);\n\tUINT WINAPI wglGetContextGPUIDAMD(HGLRC hglrc);\n\tHGLRC WINAPI wglCreateAssociatedContextAMD(UINT id);\n\tHGLRC WINAPI wglCreateAssociatedContextAttribsAMD(UINT id, HGLRC hShareContext, const int *attribList);\n\tBOOL WINAPI wglDeleteAssociatedContextAMD(HGLRC hglrc);\n\tBOOL WINAPI wglMakeAssociatedContextCurrentAMD(HGLRC hglrc);\n\tHGLRC WINAPI wglGetCurrentAssociatedContextAMD(void);\n\tVOID WINAPI wglBlitContextFramebufferAMD(HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#endif\n#endif /* WGL_AMD_gpu_association */\n\n#ifndef WGL_ATI_pixel_format_float\n#define WGL_ATI_pixel_format_float 1\n#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0\n#endif /* WGL_ATI_pixel_format_float */\n\n#ifndef WGL_EXT_colorspace\n#define WGL_EXT_colorspace 1\n#define WGL_COLORSPACE_EXT 0x3087\n#define WGL_COLORSPACE_SRGB_EXT 0x3089\n#define WGL_COLORSPACE_LINEAR_EXT 0x308A\n#endif /* WGL_EXT_colorspace */\n\n#ifndef WGL_EXT_create_context_es2_profile\n#define WGL_EXT_create_context_es2_profile 1\n#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004\n#endif /* WGL_EXT_create_context_es2_profile */\n\n#ifndef WGL_EXT_create_context_es_profile\n#define WGL_EXT_create_context_es_profile 1\n#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004\n#endif /* WGL_EXT_create_context_es_profile */\n\n#ifndef WGL_EXT_depth_float\n#define WGL_EXT_depth_float 1\n#define WGL_DEPTH_FLOAT_EXT 0x2040\n#endif /* WGL_EXT_depth_float */\n\n#ifndef WGL_EXT_display_color_table\n#define WGL_EXT_display_color_table 1\n\ttypedef GLboolean(WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);\n\ttypedef GLboolean(WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);\n\ttypedef GLboolean(WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);\n\ttypedef VOID(WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tGLboolean WINAPI wglCreateDisplayColorTableEXT(GLushort id);\n\tGLboolean WINAPI wglLoadDisplayColorTableEXT(const GLushort *table, GLuint length);\n\tGLboolean WINAPI wglBindDisplayColorTableEXT(GLushort id);\n\tVOID WINAPI wglDestroyDisplayColorTableEXT(GLushort id);\n#endif\n#endif /* WGL_EXT_display_color_table */\n\n#ifndef WGL_EXT_extensions_string\n#define WGL_EXT_extensions_string 1\n\ttypedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tconst char *WINAPI wglGetExtensionsStringEXT(void);\n#endif\n#endif /* WGL_EXT_extensions_string */\n\n#ifndef WGL_EXT_framebuffer_sRGB\n#define WGL_EXT_framebuffer_sRGB 1\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9\n#endif /* WGL_EXT_framebuffer_sRGB */\n\n#ifndef WGL_EXT_make_current_read\n#define WGL_EXT_make_current_read 1\n#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043\n\ttypedef BOOL(WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\ttypedef HDC(WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglMakeContextCurrentEXT(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\tHDC WINAPI wglGetCurrentReadDCEXT(void);\n#endif\n#endif /* WGL_EXT_make_current_read */\n\n#ifndef WGL_EXT_multisample\n#define WGL_EXT_multisample 1\n#define WGL_SAMPLE_BUFFERS_EXT 0x2041\n#define WGL_SAMPLES_EXT 0x2042\n#endif /* WGL_EXT_multisample */\n\n#ifndef WGL_EXT_pbuffer\n#define WGL_EXT_pbuffer 1\n\tDECLARE_HANDLE(HPBUFFEREXT);\n#define WGL_DRAW_TO_PBUFFER_EXT 0x202D\n#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E\n#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030\n#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031\n#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032\n#define WGL_PBUFFER_LARGEST_EXT 0x2033\n#define WGL_PBUFFER_WIDTH_EXT 0x2034\n#define WGL_PBUFFER_HEIGHT_EXT 0x2035\n\ttypedef HPBUFFEREXT(WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\n\ttypedef HDC(WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);\n\ttypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);\n\ttypedef BOOL(WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tHPBUFFEREXT WINAPI wglCreatePbufferEXT(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\n\tHDC WINAPI wglGetPbufferDCEXT(HPBUFFEREXT hPbuffer);\n\tint WINAPI wglReleasePbufferDCEXT(HPBUFFEREXT hPbuffer, HDC hDC);\n\tBOOL WINAPI wglDestroyPbufferEXT(HPBUFFEREXT hPbuffer);\n\tBOOL WINAPI wglQueryPbufferEXT(HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);\n#endif\n#endif /* WGL_EXT_pbuffer */\n\n#ifndef WGL_EXT_pixel_format\n#define WGL_EXT_pixel_format 1\n#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000\n#define WGL_DRAW_TO_WINDOW_EXT 0x2001\n#define WGL_DRAW_TO_BITMAP_EXT 0x2002\n#define WGL_ACCELERATION_EXT 0x2003\n#define WGL_NEED_PALETTE_EXT 0x2004\n#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005\n#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006\n#define WGL_SWAP_METHOD_EXT 0x2007\n#define WGL_NUMBER_OVERLAYS_EXT 0x2008\n#define WGL_NUMBER_UNDERLAYS_EXT 0x2009\n#define WGL_TRANSPARENT_EXT 0x200A\n#define WGL_TRANSPARENT_VALUE_EXT 0x200B\n#define WGL_SHARE_DEPTH_EXT 0x200C\n#define WGL_SHARE_STENCIL_EXT 0x200D\n#define WGL_SHARE_ACCUM_EXT 0x200E\n#define WGL_SUPPORT_GDI_EXT 0x200F\n#define WGL_SUPPORT_OPENGL_EXT 0x2010\n#define WGL_DOUBLE_BUFFER_EXT 0x2011\n#define WGL_STEREO_EXT 0x2012\n#define WGL_PIXEL_TYPE_EXT 0x2013\n#define WGL_COLOR_BITS_EXT 0x2014\n#define WGL_RED_BITS_EXT 0x2015\n#define WGL_RED_SHIFT_EXT 0x2016\n#define WGL_GREEN_BITS_EXT 0x2017\n#define WGL_GREEN_SHIFT_EXT 0x2018\n#define WGL_BLUE_BITS_EXT 0x2019\n#define WGL_BLUE_SHIFT_EXT 0x201A\n#define WGL_ALPHA_BITS_EXT 0x201B\n#define WGL_ALPHA_SHIFT_EXT 0x201C\n#define WGL_ACCUM_BITS_EXT 0x201D\n#define WGL_ACCUM_RED_BITS_EXT 0x201E\n#define WGL_ACCUM_GREEN_BITS_EXT 0x201F\n#define WGL_ACCUM_BLUE_BITS_EXT 0x2020\n#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021\n#define WGL_DEPTH_BITS_EXT 0x2022\n#define WGL_STENCIL_BITS_EXT 0x2023\n#define WGL_AUX_BUFFERS_EXT 0x2024\n#define WGL_NO_ACCELERATION_EXT 0x2025\n#define WGL_GENERIC_ACCELERATION_EXT 0x2026\n#define WGL_FULL_ACCELERATION_EXT 0x2027\n#define WGL_SWAP_EXCHANGE_EXT 0x2028\n#define WGL_SWAP_COPY_EXT 0x2029\n#define WGL_SWAP_UNDEFINED_EXT 0x202A\n#define WGL_TYPE_RGBA_EXT 0x202B\n#define WGL_TYPE_COLORINDEX_EXT 0x202C\n\ttypedef BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);\n\ttypedef BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);\n\ttypedef BOOL(WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetPixelFormatAttribivEXT(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);\n\tBOOL WINAPI wglGetPixelFormatAttribfvEXT(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);\n\tBOOL WINAPI wglChoosePixelFormatEXT(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#endif\n#endif /* WGL_EXT_pixel_format */\n\n#ifndef WGL_EXT_pixel_format_packed_float\n#define WGL_EXT_pixel_format_packed_float 1\n#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8\n#endif /* WGL_EXT_pixel_format_packed_float */\n\n#ifndef WGL_EXT_swap_control\n#define WGL_EXT_swap_control 1\n\ttypedef BOOL(WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);\n\ttypedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglSwapIntervalEXT(int interval);\n\tint WINAPI wglGetSwapIntervalEXT(void);\n#endif\n#endif /* WGL_EXT_swap_control */\n\n#ifndef WGL_EXT_swap_control_tear\n#define WGL_EXT_swap_control_tear 1\n#endif /* WGL_EXT_swap_control_tear */\n\n#ifndef WGL_I3D_digital_video_control\n#define WGL_I3D_digital_video_control 1\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051\n#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052\n#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053\n\ttypedef BOOL(WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);\n\ttypedef BOOL(WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetDigitalVideoParametersI3D(HDC hDC, int iAttribute, int *piValue);\n\tBOOL WINAPI wglSetDigitalVideoParametersI3D(HDC hDC, int iAttribute, const int *piValue);\n#endif\n#endif /* WGL_I3D_digital_video_control */\n\n#ifndef WGL_I3D_gamma\n#define WGL_I3D_gamma 1\n#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E\n#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F\n\ttypedef BOOL(WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);\n\ttypedef BOOL(WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);\n\ttypedef BOOL(WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);\n\ttypedef BOOL(WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetGammaTableParametersI3D(HDC hDC, int iAttribute, int *piValue);\n\tBOOL WINAPI wglSetGammaTableParametersI3D(HDC hDC, int iAttribute, const int *piValue);\n\tBOOL WINAPI wglGetGammaTableI3D(HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);\n\tBOOL WINAPI wglSetGammaTableI3D(HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);\n#endif\n#endif /* WGL_I3D_gamma */\n\n#ifndef WGL_I3D_genlock\n#define WGL_I3D_genlock 1\n#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044\n#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045\n#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046\n#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047\n#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048\n#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049\n#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A\n#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B\n#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C\n\ttypedef BOOL(WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);\n\ttypedef BOOL(WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);\n\ttypedef BOOL(WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);\n\ttypedef BOOL(WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);\n\ttypedef BOOL(WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);\n\ttypedef BOOL(WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);\n\ttypedef BOOL(WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);\n\ttypedef BOOL(WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);\n\ttypedef BOOL(WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);\n\ttypedef BOOL(WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);\n\ttypedef BOOL(WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglEnableGenlockI3D(HDC hDC);\n\tBOOL WINAPI wglDisableGenlockI3D(HDC hDC);\n\tBOOL WINAPI wglIsEnabledGenlockI3D(HDC hDC, BOOL *pFlag);\n\tBOOL WINAPI wglGenlockSourceI3D(HDC hDC, UINT uSource);\n\tBOOL WINAPI wglGetGenlockSourceI3D(HDC hDC, UINT *uSource);\n\tBOOL WINAPI wglGenlockSourceEdgeI3D(HDC hDC, UINT uEdge);\n\tBOOL WINAPI wglGetGenlockSourceEdgeI3D(HDC hDC, UINT *uEdge);\n\tBOOL WINAPI wglGenlockSampleRateI3D(HDC hDC, UINT uRate);\n\tBOOL WINAPI wglGetGenlockSampleRateI3D(HDC hDC, UINT *uRate);\n\tBOOL WINAPI wglGenlockSourceDelayI3D(HDC hDC, UINT uDelay);\n\tBOOL WINAPI wglGetGenlockSourceDelayI3D(HDC hDC, UINT *uDelay);\n\tBOOL WINAPI wglQueryGenlockMaxSourceDelayI3D(HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);\n#endif\n#endif /* WGL_I3D_genlock */\n\n#ifndef WGL_I3D_image_buffer\n#define WGL_I3D_image_buffer 1\n#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001\n#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002\n\ttypedef LPVOID(WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);\n\ttypedef BOOL(WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);\n\ttypedef BOOL(WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);\n\ttypedef BOOL(WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tLPVOID WINAPI wglCreateImageBufferI3D(HDC hDC, DWORD dwSize, UINT uFlags);\n\tBOOL WINAPI wglDestroyImageBufferI3D(HDC hDC, LPVOID pAddress);\n\tBOOL WINAPI wglAssociateImageBufferEventsI3D(HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);\n\tBOOL WINAPI wglReleaseImageBufferEventsI3D(HDC hDC, const LPVOID *pAddress, UINT count);\n#endif\n#endif /* WGL_I3D_image_buffer */\n\n#ifndef WGL_I3D_swap_frame_lock\n#define WGL_I3D_swap_frame_lock 1\n\ttypedef BOOL(WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);\n\ttypedef BOOL(WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);\n\ttypedef BOOL(WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglEnableFrameLockI3D(void);\n\tBOOL WINAPI wglDisableFrameLockI3D(void);\n\tBOOL WINAPI wglIsEnabledFrameLockI3D(BOOL *pFlag);\n\tBOOL WINAPI wglQueryFrameLockMasterI3D(BOOL *pFlag);\n#endif\n#endif /* WGL_I3D_swap_frame_lock */\n\n#ifndef WGL_I3D_swap_frame_usage\n#define WGL_I3D_swap_frame_usage 1\n\ttypedef BOOL(WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);\n\ttypedef BOOL(WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);\n\ttypedef BOOL(WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetFrameUsageI3D(float *pUsage);\n\tBOOL WINAPI wglBeginFrameTrackingI3D(void);\n\tBOOL WINAPI wglEndFrameTrackingI3D(void);\n\tBOOL WINAPI wglQueryFrameTrackingI3D(DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\n#endif\n#endif /* WGL_I3D_swap_frame_usage */\n\n#ifndef WGL_NV_DX_interop\n#define WGL_NV_DX_interop 1\n#define WGL_ACCESS_READ_ONLY_NV 0x00000000\n#define WGL_ACCESS_READ_WRITE_NV 0x00000001\n#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002\n\ttypedef BOOL(WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);\n\ttypedef HANDLE(WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);\n\ttypedef BOOL(WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);\n\ttypedef HANDLE(WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);\n\ttypedef BOOL(WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);\n\ttypedef BOOL(WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);\n\ttypedef BOOL(WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);\n\ttypedef BOOL(WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglDXSetResourceShareHandleNV(void *dxObject, HANDLE shareHandle);\n\tHANDLE WINAPI wglDXOpenDeviceNV(void *dxDevice);\n\tBOOL WINAPI wglDXCloseDeviceNV(HANDLE hDevice);\n\tHANDLE WINAPI wglDXRegisterObjectNV(HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);\n\tBOOL WINAPI wglDXUnregisterObjectNV(HANDLE hDevice, HANDLE hObject);\n\tBOOL WINAPI wglDXObjectAccessNV(HANDLE hObject, GLenum access);\n\tBOOL WINAPI wglDXLockObjectsNV(HANDLE hDevice, GLint count, HANDLE *hObjects);\n\tBOOL WINAPI wglDXUnlockObjectsNV(HANDLE hDevice, GLint count, HANDLE *hObjects);\n#endif\n#endif /* WGL_NV_DX_interop */\n\n#ifndef WGL_NV_DX_interop2\n#define WGL_NV_DX_interop2 1\n#endif /* WGL_NV_DX_interop2 */\n\n#ifndef WGL_NV_copy_image\n#define WGL_NV_copy_image 1\n\ttypedef BOOL(WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglCopyImageSubDataNV(HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#endif\n#endif /* WGL_NV_copy_image */\n\n#ifndef WGL_NV_delay_before_swap\n#define WGL_NV_delay_before_swap 1\n\ttypedef BOOL(WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglDelayBeforeSwapNV(HDC hDC, GLfloat seconds);\n#endif\n#endif /* WGL_NV_delay_before_swap */\n\n#ifndef WGL_NV_float_buffer\n#define WGL_NV_float_buffer 1\n#define WGL_FLOAT_COMPONENTS_NV 0x20B0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4\n#define WGL_TEXTURE_FLOAT_R_NV 0x20B5\n#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6\n#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7\n#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8\n#endif /* WGL_NV_float_buffer */\n\n#ifndef WGL_NV_gpu_affinity\n#define WGL_NV_gpu_affinity 1\n\tDECLARE_HANDLE(HGPUNV);\n\tstruct _GPU_DEVICE {\n\t\tDWORD cb;\n\t\tCHAR DeviceName[32];\n\t\tCHAR DeviceString[128];\n\t\tDWORD Flags;\n\t\tRECT rcVirtualScreen;\n\t};\n\ttypedef struct _GPU_DEVICE *PGPU_DEVICE;\n#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0\n#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1\n\ttypedef BOOL(WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);\n\ttypedef BOOL(WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\n\ttypedef HDC(WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);\n\ttypedef BOOL(WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\n\ttypedef BOOL(WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglEnumGpusNV(UINT iGpuIndex, HGPUNV *phGpu);\n\tBOOL WINAPI wglEnumGpuDevicesNV(HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\n\tHDC WINAPI wglCreateAffinityDCNV(const HGPUNV *phGpuList);\n\tBOOL WINAPI wglEnumGpusFromAffinityDCNV(HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\n\tBOOL WINAPI wglDeleteDCNV(HDC hdc);\n#endif\n#endif /* WGL_NV_gpu_affinity */\n\n#ifndef WGL_NV_multisample_coverage\n#define WGL_NV_multisample_coverage 1\n#define WGL_COVERAGE_SAMPLES_NV 0x2042\n#define WGL_COLOR_SAMPLES_NV 0x20B9\n#endif /* WGL_NV_multisample_coverage */\n\n#ifndef WGL_NV_present_video\n#define WGL_NV_present_video 1\n\tDECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);\n#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0\n\ttypedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);\n\ttypedef BOOL(WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tint WINAPI wglEnumerateVideoDevicesNV(HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);\n\tBOOL WINAPI wglBindVideoDeviceNV(HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);\n\tBOOL WINAPI wglQueryCurrentContextNV(int iAttribute, int *piValue);\n#endif\n#endif /* WGL_NV_present_video */\n\n#ifndef WGL_NV_render_depth_texture\n#define WGL_NV_render_depth_texture 1\n#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4\n#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5\n#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6\n#define WGL_DEPTH_COMPONENT_NV 0x20A7\n#endif /* WGL_NV_render_depth_texture */\n\n#ifndef WGL_NV_render_texture_rectangle\n#define WGL_NV_render_texture_rectangle 1\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1\n#define WGL_TEXTURE_RECTANGLE_NV 0x20A2\n#endif /* WGL_NV_render_texture_rectangle */\n\n#ifndef WGL_NV_swap_group\n#define WGL_NV_swap_group 1\n\ttypedef BOOL(WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);\n\ttypedef BOOL(WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);\n\ttypedef BOOL(WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglJoinSwapGroupNV(HDC hDC, GLuint group);\n\tBOOL WINAPI wglBindSwapBarrierNV(GLuint group, GLuint barrier);\n\tBOOL WINAPI wglQuerySwapGroupNV(HDC hDC, GLuint *group, GLuint *barrier);\n\tBOOL WINAPI wglQueryMaxSwapGroupsNV(HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);\n\tBOOL WINAPI wglQueryFrameCountNV(HDC hDC, GLuint *count);\n\tBOOL WINAPI wglResetFrameCountNV(HDC hDC);\n#endif\n#endif /* WGL_NV_swap_group */\n\n#ifndef WGL_NV_vertex_array_range\n#define WGL_NV_vertex_array_range 1\n\ttypedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);\n\ttypedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tvoid *WINAPI wglAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);\n\tvoid WINAPI wglFreeMemoryNV(void *pointer);\n#endif\n#endif /* WGL_NV_vertex_array_range */\n\n#ifndef WGL_NV_video_capture\n#define WGL_NV_video_capture 1\n\tDECLARE_HANDLE(HVIDEOINPUTDEVICENV);\n#define WGL_UNIQUE_ID_NV 0x20CE\n#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF\n\ttypedef BOOL(WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\n\ttypedef UINT(WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);\n\ttypedef BOOL(WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n\ttypedef BOOL(WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);\n\ttypedef BOOL(WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglBindVideoCaptureDeviceNV(UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\n\tUINT WINAPI wglEnumerateVideoCaptureDevicesNV(HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);\n\tBOOL WINAPI wglLockVideoCaptureDeviceNV(HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n\tBOOL WINAPI wglQueryVideoCaptureDeviceNV(HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);\n\tBOOL WINAPI wglReleaseVideoCaptureDeviceNV(HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n#endif\n#endif /* WGL_NV_video_capture */\n\n#ifndef WGL_NV_video_output\n#define WGL_NV_video_output 1\n\tDECLARE_HANDLE(HPVIDEODEV);\n#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0\n#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1\n#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2\n#define WGL_VIDEO_OUT_COLOR_NV 0x20C3\n#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4\n#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5\n#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6\n#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7\n#define WGL_VIDEO_OUT_FRAME 0x20C8\n#define WGL_VIDEO_OUT_FIELD_1 0x20C9\n#define WGL_VIDEO_OUT_FIELD_2 0x20CA\n#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB\n#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC\n\ttypedef BOOL(WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);\n\ttypedef BOOL(WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);\n\ttypedef BOOL(WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\n\ttypedef BOOL(WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);\n\ttypedef BOOL(WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);\n\ttypedef BOOL(WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetVideoDeviceNV(HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);\n\tBOOL WINAPI wglReleaseVideoDeviceNV(HPVIDEODEV hVideoDevice);\n\tBOOL WINAPI wglBindVideoImageNV(HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\n\tBOOL WINAPI wglReleaseVideoImageNV(HPBUFFERARB hPbuffer, int iVideoBuffer);\n\tBOOL WINAPI wglSendPbufferToVideoNV(HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);\n\tBOOL WINAPI wglGetVideoInfoNV(HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#endif\n#endif /* WGL_NV_video_output */\n\n#ifndef WGL_OML_sync_control\n#define WGL_OML_sync_control 1\n\ttypedef BOOL(WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);\n\ttypedef BOOL(WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);\n\ttypedef INT64(WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\n\ttypedef INT64(WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\n\ttypedef BOOL(WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);\n\ttypedef BOOL(WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);\n#ifdef WGL_WGLEXT_PROTOTYPES\n\tBOOL WINAPI wglGetSyncValuesOML(HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);\n\tBOOL WINAPI wglGetMscRateOML(HDC hdc, INT32 *numerator, INT32 *denominator);\n\tINT64 WINAPI wglSwapBuffersMscOML(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\n\tINT64 WINAPI wglSwapLayerBuffersMscOML(HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\n\tBOOL WINAPI wglWaitForMscOML(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);\n\tBOOL WINAPI wglWaitForSbcOML(HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);\n#endif\n#endif /* WGL_OML_sync_control */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif"}, {"path": "utils/window.cpp", "language": "cpp", "loc": 371, "comment_density": 0.065, "code": "\n#include \"window.h\"\n\n#ifndef _WIN32\n#include \n#endif\n\nvoid APIENTRY glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, void*) {\n\n\t// format the message nicely\n\tauto output = printf(\"OpenGL \");\n\n\tswitch (type) {\n\tcase GL_DEBUG_TYPE_ERROR:\t\t\t\t\tprintf(\"error\");\t\t\t\t\t\t\tbreak;\n\tcase GL_DEBUG_TYPE_PORTABILITY:\t\t\t\tprintf(\"portability issue\");\t\t\t\tbreak;\n\tcase GL_DEBUG_TYPE_PERFORMANCE:\t\t\t\tprintf(\"performance issue\");\t\t\t\tbreak;\n\tcase GL_DEBUG_TYPE_OTHER:\t\t\t\t\tprintf(\"issue\");\t\t\t\t\t\t\tbreak;\n\tcase GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:\t\tprintf(\"undefined behavior\");\t\t\t\tbreak;\n\tcase GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:\t\tprintf(\"deprecated behavior\");\t\t\t\tbreak;\n\tdefault:\t\t\t\t\t\t\t\t\tprintf(\"issue(?)\");\t\t\t\t\t\t\tbreak;\n\t}\n\tswitch (source) {\n\tcase GL_DEBUG_SOURCE_API:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\tcase GL_DEBUG_SOURCE_WINDOW_SYSTEM:\t\t\tprintf(\" in the window system\");\t\t\tbreak;\n\tcase GL_DEBUG_SOURCE_SHADER_COMPILER:\t\tprintf(\" in the shader compiler\");\t\t\tbreak;\n\tcase GL_DEBUG_SOURCE_THIRD_PARTY:\t\t\tprintf(\" in third party code\");\t\t\t\tbreak;\n\tcase GL_DEBUG_SOURCE_APPLICATION:\t\t\tprintf(\" in this program\");\t\t\t\t\tbreak;\n\tcase GL_DEBUG_SOURCE_OTHER:\t\t\t\t\tprintf(\" in an undefined source\");\t\t\tbreak;\n\tdefault:\t\t\t\t\t\t\t\t\tprintf(\" nowhere(?)\");\t\t\t\t\t\tbreak;\n\t}\n\n\tprintf(\", id %u:\\n%.*s\\n\", id, length, message);\n\t// this is invaluable; you can directly see where any opengl error originated by checking the call stack at this breakpoint\n\tif (type == GL_DEBUG_TYPE_ERROR)\n#ifdef _WIN32\n\t\t__debugbreak();\n#else\n\t\traise(SIGTRAP);\n#endif\n}\n\nvoid setupDebug() {\n\t// enable debug output\n\tglEnable(GL_DEBUG_OUTPUT);\n\t// debug output from main thread: get the correct stack frame when breaking\n\tglEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);\n\n\tglDebugMessageCallback((GLDEBUGPROC)glDebugCallback, 0);\n\n\t// query everything about errors, deprecated and undefined things\n\tglDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, 0, GL_TRUE);\n\tglDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, GL_DONT_CARE, 0, 0, GL_TRUE);\n\tglDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DONT_CARE, 0, 0, GL_TRUE);\n\n\t// disable misc info. might want to check these from time to time!\n\tglDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, 0, 0, GL_FALSE);\n\tglDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE, GL_DONT_CARE, 0, 0, GL_FALSE);\n}\n\n#ifdef _WIN32\n\n#include \"wglext.h\"\n\n#pragma comment(lib, \"opengl32.lib\")\n\nconst int GL_WINDOW_ATTRIBUTES[] = {\n\tWGL_DRAW_TO_WINDOW_ARB, GL_TRUE,\n\tWGL_SUPPORT_OPENGL_ARB, GL_TRUE,\n\tWGL_DOUBLE_BUFFER_ARB, GL_TRUE,\n\tWGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_TRUE,\n\t//WGL_SAMPLES_ARB, 8, // MSAA\n\n\tWGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,\n\tWGL_COLOR_BITS_ARB, 32,\n\tWGL_DEPTH_BITS_ARB, 24,\n0 };\n\nconst int GL_CONTEXT_ATTRIBUTES[] = {\n\tWGL_CONTEXT_MAJOR_VERSION_ARB, 4,\n\tWGL_CONTEXT_MINOR_VERSION_ARB, 6,\n\tWGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,\n\t//WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,\n0 };\n\nHWND wnd = nullptr;\nHDC dc;\nHGLRC rc;\n\n// update the frame onto screen\nvoid swapBuffers() {\n\tSwapBuffers(dc);\n}\n\nvoid setTitle(const char* title) {\n\tSetWindowTextA(wnd, title);\n}\n\nivec2 getMouse() {\n\tPOINT mouse;\n\tGetCursorPos(&mouse);\n\tScreenToClient(wnd, &mouse);\n\treturn ivec2(mouse.x, mouse.y);\n}\n\nvoid setMouse(ivec2 p) {\n\tPOINT p_{ p.x, p.y };\n\tClientToScreen(wnd, &p_);\n\tSetCursorPos(p_.x, p_.y);\n}\n\nivec2 windowSize() {\n\tRECT r;\n\tGetClientRect(wnd, &r);\n\treturn { r.right - r.left, r.bottom - r.top };\n}\n\nWPARAM down[256]; int downptr = 0;\nWPARAM hit[256]; int hitptr = 0;\n\nbool keyDown(uint vk_code) {\n\tfor (int i = 0; i < downptr; ++i)\n\t\tif (vk_code == down[i])\n\t\t\treturn true;\n\treturn false;\n}\n\nbool keyHit(uint vk_code) {\n\tfor (int i = 0; i < hitptr; ++i)\n\t\tif (vk_code == hit[i])\n\t\t\treturn true;\n\treturn false;\n}\n\nvoid resetHits() {\n\thitptr = 0;\n}\n\ninline WPARAM mapExtended(WPARAM wParam, LPARAM lParam) {\n\tint ext = (lParam>>24)&1;\n\tswitch(wParam) {\n\t\tcase VK_SHIFT: return MapVirtualKeyEx((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX, GetKeyboardLayout(0));\n\t\tcase VK_CONTROL: return VK_LCONTROL+ext;\n\t\tcase VK_MENU: return VK_LMENU+ext;\n\t\tcase VK_RETURN: return VK_RETURN + ext*(VK_SEPARATOR-VK_RETURN);\n\t\tdefault: return wParam;\n\t}\n}\n\nLRESULT CALLBACK wndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {\n\tswitch (uMsg) {\n\tcase WM_CLOSE:\n\t\tPostQuitMessage(0);\n\t\treturn 0;\n\tcase WM_SYSKEYDOWN:\n\tcase WM_KEYDOWN:\n\t\twParam = mapExtended(wParam, lParam);\n\t\tif (!keyDown((UINT)wParam))\n\t\t\tdown[downptr++] = hit[hitptr++] = wParam; // todo: if mapNarrowed(wParam)!=wParam: also add mapNarrowed()\n\t\tif (wParam == VK_ESCAPE)\n\t\t\tPostQuitMessage(0);\n\t\treturn 0;\n\tcase WM_SYSKEYUP:\n\tcase WM_KEYUP:\n\t\twParam = mapExtended(wParam, lParam);\n\t\tfor (int i = 0; i < downptr - 1; ++i) // todo: if mapNarrowed(wParam)!=wParam: also remove mapNarrowed()\n\t\t\tif (wParam == down[i]) {\n\t\t\t\tdown[i] = down[downptr-1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (downptr > 0) downptr--;\n\t\treturn 0;\n\tcase WM_KILLFOCUS:\n\t//\thitptr = downptr = 0;\n\t\treturn 0;\n\t}\n\treturn DefWindowProc(hwnd, uMsg, wParam, lParam);\n}\n\nbool loop() {\n\thitptr = 0;\n\tMSG msg;\n\tbool result = true;\n\twhile (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {\n\t\tTranslateMessage(&msg);\n\t\tDispatchMessage(&msg);\n\t\tif (msg.message == WM_QUIT) {\n\t\t\tresult = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn result;\n}\n\nvoid setupGL(int width, int height, const char* title, bool fullscreen, bool show) {\n\n\tif (glOpen()) return;\n\n\tWNDCLASSEX windowClass = { 0 };\n\twindowClass.cbSize = sizeof(windowClass);\n\twindowClass.hInstance = GetModuleHandle(nullptr);\n\twindowClass.lpszClassName = TEXT(\"classy class\");\n\twindowClass.hCursor = LoadCursor(nullptr, IDC_ARROW);\n\twindowClass.style = CS_OWNDC;\n\twindowClass.lpfnWndProc = wndProc;\n\tRegisterClassEx(&windowClass);\n\n\tPIXELFORMATDESCRIPTOR formatDesc = { 0 };\n\tformatDesc.nVersion = 1;\n\tformatDesc.nSize = sizeof(formatDesc);\n\tformatDesc.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;\n\tformatDesc.iLayerType = PFD_MAIN_PLANE;\n\tformatDesc.iPixelType = PFD_TYPE_RGBA;\n\tformatDesc.cColorBits = 32;\n\tformatDesc.cDepthBits = 24;\n\tformatDesc.cStencilBits = 8;\n\n\t// create a temporary window to have a functional opengl context in order to get some extension function pointers\n\tHWND tempWnd = CreateWindow(TEXT(\"classy class\"), TEXT(\"windy window\"), WS_POPUP, 0, 0, width, height, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);\n\tHDC tempDC = GetDC(tempWnd);\n\tSetPixelFormat(tempDC, ChoosePixelFormat(tempDC, &formatDesc), &formatDesc);\n\tHGLRC tempRC = wglCreateContext(tempDC);\n\twglMakeCurrent(tempDC, tempRC);\n\n\t// these are why we made the temporary context; can set more pixel format attributes (multisample, floating point etc.) and create debug/core/etc contexts\n\tauto wglChoosePixelFormat = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress(\"wglChoosePixelFormatARB\");\n\tauto wglCreateContextAttribs = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress(\"wglCreateContextAttribsARB\");\n\n\t// adjust the window borders away, center the window\n\tRECT area = { 0, 0, width, height };\n\tconst DWORD style = (fullscreen ? WS_POPUP : (WS_SYSMENU|WS_CAPTION|WS_MINIMIZEBOX)) | ((fullscreen||show)?WS_VISIBLE:0);\n\tif (fullscreen) {\n\t\tDEVMODE mode = { 0 };\n\t\tmode.dmSize = sizeof(mode);\n\t\tmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;\n\t\tmode.dmPelsWidth = width; mode.dmPelsHeight = height;\n\t\tmode.dmBitsPerPel = 32;\n\t\tChangeDisplaySettings(&mode, CDS_FULLSCREEN);\n\t}\n\n\tAdjustWindowRect(&area, style, false);\n\tint adjustedWidth = fullscreen ? width : area.right - area.left, adjustedHeight = fullscreen ? height : area.bottom - area.top;\n\tint centerX = (GetSystemMetrics(SM_CXSCREEN) - adjustedWidth) / 2, centerY = (GetSystemMetrics(SM_CYSCREEN) - adjustedHeight) / 2;\n\tif (fullscreen)\n\t\tcenterX = centerY = 0;\n\n\t// create the final window and context\n\tdc = GetDC(wnd = CreateWindowA(\"classy class\", title, style, centerX, centerY, adjustedWidth, adjustedHeight, nullptr, nullptr, GetModuleHandle(nullptr), nullptr));\n\n\tint format; UINT numFormats;\n\twglChoosePixelFormat(dc, GL_WINDOW_ATTRIBUTES, nullptr, 1, &format, &numFormats);\n\n\tSetPixelFormat(dc, format, &formatDesc);\n\n\trc = wglCreateContextAttribs(dc, 0, GL_CONTEXT_ATTRIBUTES);\n\n\twglMakeCurrent(dc, rc);\n\tglViewport(0, 0, width, height);\n\n\t// release the temporary window and context\n\twglDeleteContext(tempRC);\n\tReleaseDC(tempWnd, tempDC);\n\tDestroyWindow(tempWnd);\n\n\t// what GL did we get?\n\tprintf(\"gl %s\\non %s\\nby %s\\nsl %s\\n\", glGetString(GL_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR), glGetString(GL_SHADING_LANGUAGE_VERSION));\n\n\tloadgl();\n\n\tsetupDebug();\n\tglEnable(GL_FRAMEBUFFER_SRGB);\n\t((PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress(\"wglSwapIntervalEXT\"))(-1); // freesync\n}\n\n#include \nvoid closeGL() {\n\tif (!glOpen()) return;\n\n\t// release context, window\n\tChangeDisplaySettings(nullptr, CDS_FULLSCREEN);\n\twglMakeCurrent(0, 0);\n\twglDeleteContext(rc);\n\tReleaseDC(wnd, dc);\n\tDestroyWindow(wnd);\n\twnd = nullptr;\n\tUnregisterClass(TEXT(\"classy class\"), GetModuleHandle(nullptr));\n\t_CrtDumpMemoryLeaks();\n}\n\nbool glOpen() {\n\treturn wnd != nullptr;\n}\n\nvoid showWindow() {\n\tShowWindow(wnd, SW_SHOW);\n}\n\nvoid hideWindow() {\n\tShowWindow(wnd, SW_HIDE);\n}\n\n#else\n\n#ifdef HEADLESS\n#define EGL_NO_X11\n#define MESA_EGL_NO_X11_HEADERS\n#else\n#include \nDisplay* xdisplay = nullptr;\nWindow xwindow;\n#endif\n\n#include \n#include \n\n#define GLAPIENTRY\n\n#include \n\nEGLDisplay display;\nEGLContext context;\n\nEGLSurface surface = EGL_NO_SURFACE;\n\nivec2 windowsize{};\n\nvoid setupGL(int width, int height, const char* title, bool fullscreen, bool show) {\n\twindowsize = ivec2(width, height);\n#ifndef HEADLESS\n\txdisplay = XOpenDisplay(nullptr);\n\tXSetWindowAttributes window_attributes = {0};\n\twindow_attributes.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;\n\txwindow = XCreateWindow(xdisplay, DefaultRootWindow(xdisplay), 0, 0, width, height, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &window_attributes);\n\tXStoreName(xdisplay, xwindow, title);\n\tXMapWindow(xdisplay, xwindow);\n\tdisplay = eglGetDisplay((EGLNativeDisplayType)xdisplay);\n#else\n\tdisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);\n#endif\n\tEGLint major, minor;\n\teglInitialize(display, &major, &minor);\n\tconst EGLint config_attributes[] = {\n\t\tEGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,\n\t\tEGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,\n\t\tEGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,\n#ifdef HEADLESS\n\t\tEGL_SURFACE_TYPE, EGL_PBUFFER_BIT,\n#endif\n\t\tEGL_NONE\n\t};\n\n\teglBindAPI(EGL_OPENGL_API);\n\n\tEGLConfig config; EGLint configCount;\n\teglChooseConfig(display, config_attributes, &config, 1, &configCount);\n\n\tconst EGLint context_attributes[] = {\n\t\tEGL_CONTEXT_MAJOR_VERSION, 4,\n\t\tEGL_CONTEXT_MINOR_VERSION, 6,\n\t\tEGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,\n\t\tEGL_NONE\n\t};\n\tcontext = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attributes);\n#ifndef HEADLESS\n\tEGLint surface_attributes[] = {\n\t\tEGL_GL_COLORSPACE, EGL_GL_COLORSPACE_LINEAR,\n\t\tEGL_RENDER_BUFFER, EGL_BACK_BUFFER,\n\t\tEGL_NONE\n\t};\n\tsurface = eglCreateWindowSurface(display, config, xwindow, surface_attributes);\n#else\n\tEGLint surface_attributes[] = {\n\t\t//EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_LINEAR,\n\t\t//EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,\n\t\t//EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,\n\t\tEGL_WIDTH, width, EGL_HEIGHT, height,\n\t\tEGL_NONE\n\t};\n\tsurface = eglCreatePbufferSurface(display, config, surface_attributes);\n#endif\n\teglMakeCurrent(display, surface, surface, context);\n\tloadgl();\n\n\tsetupDebug();\n\tglEnable(GL_FRAMEBUFFER_SRGB);\n}\nvoid closeGL() {\n\teglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);\n\teglDestroySurface(display, surface);\n\teglDestroyContext(display, context);\n\teglTerminate(display);\n#ifndef HEADLESS\n\tXDestroyWindow(xdisplay, xwindow);\n\tXCloseDisplay(xdisplay);\n#endif\n}\nbool loop() {\n#ifdef HEADLESS\n\treturn false;\n#else\n\treturn true;\n#endif\n}\nbool glOpen() {\n\treturn surface!=EGL_NO_SURFACE;\n}\nvoid swapBuffers() {\n\t//printf(\"oh lord is it this\\n\");\n\teglSwapBuffers(display, surface);\n}\nvoid setTitle(const char* title) {}\nvoid showWindow() {}\nvoid hideWindow() {}\n\nint down[256]; int downptr = 0;\nint hit[256]; int hitptr = 0;\n\nbool keyDown(uint vk_code) {\n\tfor (int i = 0; i < downptr; ++i)\n\t\tif (vk_code == down[i])\n\t\t\treturn true;\n\treturn false;\n}\n\nbool keyHit(uint vk_code) {\n\tfor (int i = 0; i < hitptr; ++i)\n\t\tif (vk_code == hit[i])\n\t\t\treturn true;\n\treturn false;\n}\n\nvoid resetHits() {\n\thitptr = 0;\n}\n\nivec2 getMouse() { return {};}\nvoid setMouse(ivec2) {}\n\nivec2 windowSize() {\n\treturn windowsize;\n}\n\n#endif\n"}, {"path": "utils/window.h", "language": "c", "loc": 48, "comment_density": 0.062, "code": "\n#pragma once\n\n#ifdef _WIN32\n\n#define VC_EXTRALEAN\n#define WIN32_LEAN_AND_MEAN\n#define NOMINMAX\n#include \n#endif\n#include \n\n#define GL_GLEXT_LEGACY\n#include \n#undef GL_VERSION_1_3\n#include \"glext.h\"\n#include \"loadgl46.h\"\n\nvoid setupGL(int width, int height, const char* title, bool fullscreen, bool show);\nvoid closeGL();\nbool loop();\nbool glOpen();\nvoid swapBuffers();\nvoid setTitle(const char* title);\nvoid showWindow();\nvoid hideWindow();\n\n#include \"glsl.h\"\n\nbool keyDown(uint vk_code);\nbool keyHit(uint vk_code);\nvoid resetHits();\n\nivec2 getMouse();\nvoid setMouse(ivec2);\n\nivec2 windowSize();\n\n// todo: make this a true class? or use some kind of \"finally\" for the close?\n// possible reasoning: don't really want singleton, but don't really want to support multiple contexts either\n// why not just global functions: to be nice, we want to free all RAII objects before closing the GL context, so this has to be RAII as well\nstruct OpenGL {\n\tOpenGL(\n\t\tint width, int height,\n\t\tconst char* title = \"\",\n\t\tbool fullscreen = false,\n\t\tbool show = true)\n\t{\n\t\tif (glOpen()) return;\n\t\tisOwning = true;\n\t\tsetupGL(width, height, title, fullscreen, show);\n\t}\n\t~OpenGL() {\n\t\tif(isOwning)\n\t\t\tcloseGL();\n\t}\n\tbool isOwning = false;\n};\n"}], "validation": {"glslang_valid": 0, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "MIT", "non_commercial": false, "comment_density": 0.054, "dedup_hash": "33c86aeadedeffdd", "has_readme": true, "build_system": "make", "dependency_count": 40, "has_demo": false} -{"id": "webgl_examples_bumpmapping", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:31+00:00", "source_type": "repo", "title": "Bumpmapping", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "lighting/texturing/bumpmapping/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "bumpmapping/bumpmapping.html", "language": "html", "loc": 20, "comment_density": 0.0, "code": "\n\n\n\nCamera height: \n\n\n\n\n
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "bumpmapping/bumpmapping.js", "language": "javascript", "loc": 95, "comment_density": 0.105, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\n\nvar cam_height = 5;\nvar position_cam = [-5.0, cam_height, 0];\n\nvar light_pos_radius = 5;\nvar light_pos = [-1, 5.0, 0];\n\nvar plane = new Plane;\nvar normal_map_size = 512;\nvar texture_gen_bumps = new Texture_generation_bumps;\nvar texture_gen_triangles = new Texture_generation_triangles;\n\nvar last_time = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if(gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n //needed to be able to have floating point textures in webgl1\n if(gl.getExtension('OES_texture_float') == null){\n alert(\"cannot have floating point textures\");\n return;\n }\n\n if(gl.getExtension('OES_texture_float_linear') == null){\n alert(\"cannot have linear floating point textures\");\n return;\n }\n\n plane.setup(gl);\n\n texture_gen_bumps.generate_normal_map(normal_map_size);\n texture_gen_triangles.generate_normal_map(normal_map_size);\n\n plane.set_normal_map(texture_gen_bumps.array_texture, normal_map_size);\n\n //model matrix for the plane\n mat4.scale(model_matrix_plane, model_matrix_plane, [2, 0, 2]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n\n model_matrix_plane = mat4.rotate(model_matrix_plane, model_matrix_plane, 0.1*Math.PI, [0,1,0]);\n}\n\nfunction change_selection(){\n var bump_selection = document.getElementById(\"bumps\");\n var triangles_selection = document.getElementById(\"triangles\");\n\n if(bump_selection.checked == true){\n plane.set_normal_map(texture_gen_bumps.array_texture, normal_map_size);\n }\n if(triangles_selection.checked == true){\n plane.set_normal_map(texture_gen_triangles.array_texture, normal_map_size);\n }\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n d = new Date();\n time = d.getTime()/100000.0;\n\n //so that first time we do the loop, time_diff does not contain crazy value\n if(last_time == 0){\n last_time = time;\n }\n\n //make it framerate independent\n time_diff = time-last_time;\n\n var camera_height = document.getElementById(\"slider_height\").value;\n\n var light_speed = 80;\n\n //apply a rotation matrix on the light pos to make it rotate around the origin\n light_pos[0] = light_pos[0]*Math.cos(time_diff*light_speed)-light_pos[2]*Math.sin(time_diff*light_speed);\n light_pos[1] = 5;\n light_pos[2] = light_pos[0]*Math.sin(time_diff*light_speed)+light_pos[2]*Math.cos(time_diff*light_speed);\n\n //renormalize the rotating bit of the light position, to not lose precision\n var vec_rot_length = light_pos[0]*light_pos[0]+light_pos[2]*light_pos[2];\n light_pos[0] = light_pos[0]/vec_rot_length;\n light_pos[2] = light_pos[2]/vec_rot_length;\n\n var light_pos_scaled = [light_pos[0]*light_pos_radius, light_pos[1], light_pos[2]*light_pos_radius];\n plane.set_light_pos(light_pos_scaled)\n\n position_cam[1] = camera_height/10;\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "bumpmapping/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 12, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n varying vec3 pixel_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n pixel_pos = vec3(model*vertex_pos);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "bumpmapping/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 15, "comment_density": 0.2, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n varying vec3 pixel_pos;\n\n uniform vec3 light_pos;\n\n uniform sampler2D texture;\n\n void main() {\n vec3 pixel_normal = texture2D(texture, frag_uv).xyz;\n\n //calculate phong according to the normal map\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n //have white plane affected by light\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "bumpmapping/plane.js", "language": "javascript", "loc": 138, "comment_density": 0.058, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n //texture coordinate buffer\n this.tex_coord_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, this.tex_coord_buffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.text_coord), gl.STATIC_DRAW);\n\n //prepare buffer for texture\n this.texture_id = gl.createTexture();\n }\n\n set_normal_map(normal_map_float, size){\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, size, size, 0, gl.RGB, gl.FLOAT, new Float32Array(normal_map_float));\n\n // gl.generateMipmap(gl.TEXTURE_2D);\n // or\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); //do not forget this for float textures\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n gl.activeTexture(gl.TEXTURE0);\n\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"texture\"), 0);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n varying vec3 pixel_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n pixel_pos = vec3(model*vertex_pos);\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n varying vec3 pixel_pos;\n\n uniform vec3 light_pos;\n\n uniform sampler2D texture;\n\n void main() {\n vec3 pixel_normal = texture2D(texture, frag_uv).xyz;\n\n //calculate phong according to the normal map\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n //have white plane affected by light\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n ];\n}\n"}, {"path": "bumpmapping/texture_generation.js", "language": "javascript", "loc": 90, "comment_density": 0.111, "code": "class Texture_generation{\n\n normalize3(vec){\n var length = Math.sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2])\n return [vec[0]/length, vec[1]/length, vec[2]/length]\n }\n\n cross(vec_a, vec_b){\n return [vec_a[1]*vec_b[2]-vec_a[2]*vec_b[1], vec_a[2]*vec_b[0]-vec_a[0]*vec_b[2], vec_a[0]*vec_b[1]-vec_a[1]*vec_b[0]];\n }\n\n //default flat normal map\n generate_value(x, y, size){\n return 0;\n }\n\n //generate a normal map from the texture values\n generate_normal_map(size){\n this.array_texture = [];\n\n for (var i = 0; i < size; i++) {\n for (var j = 0; j < size; j++) {\n var EPSILON = 0.001;\n\n //find derivatives in both direction\n var ddi = this.generate_value(i+EPSILON, j, size)-this.generate_value(i, j, size);\n var ddj = this.generate_value(i, j+EPSILON, size)-this.generate_value(i, j, size);\n\n //make vectors from derivatives\n var der_x = [EPSILON, ddi, 0];\n var der_y = [0, ddj, EPSILON];\n\n der_x = this.normalize3(der_x)\n der_y = this.normalize3(der_y)\n\n //cross should be the normal\n var normal = this.cross(der_y, der_x);\n\n normal = this.normalize3(normal);\n\n this.array_texture.push( normal[2] ); //X\n this.array_texture.push( normal[1] ); //Y\n this.array_texture.push( normal[0] ); //Z\n }\n }\n }\n}\n\n//returns pixel for a \"bumpy\" normal map\nclass Texture_generation_bumps extends Texture_generation{\n\n generate_value(x, y, size){\n //have a flat surface with only shallow holes in it\n var sine_frequency = 8*3.1415/size;\n var val = Math.sin(sine_frequency*x)*Math.sin(sine_frequency*y);\n if (val < 0.5){\n return 0;\n }\n\n return -(val-0.5)*8;\n }\n}\n\nclass Texture_generation_triangles extends Texture_generation{\n\n generate_value_sub(x, y, center_x, center_y, size){\n var relative_x = Math.abs(x-center_x);\n var relative_y = Math.abs(y-center_y);\n\n var depth = size/4;\n\n var x_min = center_x-size;\n var x_max = center_x+size;\n var y_min = center_y-size;\n var y_max = center_y+size;\n\n if(x > x_min && x < x_max){\n if(y > y_min && y < y_max){\n if(y <= center_y && relative_y >= relative_x){\n return (y-y_min)/depth;\n }\n if(y > center_y && relative_y > relative_x){\n return (y_max-y)/depth;\n }\n if(x < center_x){\n return (x-x_min)/depth;\n }\n if(x > center_x){\n return (x_max-x)/depth;\n }\n\n }\n }\n\n return 0;\n }\n\n generate_value(x, y, size){\n var sub_div = 64;\n var square_size = 32;\n\n for (var i = 0; i < size; i+=sub_div) {\n for (var j = 0; j < size; j+=sub_div) {\n if(x > i && x < (i+sub_div)){\n if(y > j && y < (j+sub_div)){\n return this.generate_value_sub(x ,y , i+square_size, j+square_size, square_size/2);\n }\n }\n }\n }\n return 0;\n }\n}"}], "validation": {"glslang_valid": 2, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 1, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "none-found", "non_commercial": false, "comment_density": 0.079, "dedup_hash": "150c45cd54df3d87", "has_readme": true, "build_system": null, "dependency_count": 5, "has_demo": true} -{"id": "webgl_examples_cube_rotation", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:31+00:00", "source_type": "repo", "title": "Cube Rotation", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "texturing/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "cube_rotation/cube.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 10, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n frag_colour = colour;\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "cube_rotation/cube.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 5, "comment_density": 0.2, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "cube_rotation/cube.js", "language": "javascript", "loc": 206, "comment_density": 0.155, "code": "class Cube{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n mat4.translate(this.model, this.model, [0, 1, 0]);\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n //buffers for colours\n this.col_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.col_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.colours), this.gl.STATIC_DRAW);\n\n }\n\n //sets model view projection matrix\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.col_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"colour\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"colour\"));\n\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n //draw the cube\n this.gl.drawElements(this.gl.TRIANGLES, 36, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n frag_colour = colour;\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }\n `;\n\n positions = [\n // Front face\n -1.0, -1.0, 1.0,\n 1.0, -1.0, 1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0,\n\n // Back face\n -1.0, -1.0, -1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, -1.0, -1.0,\n\n // Top face\n -1.0, 1.0, -1.0,\n -1.0, 1.0, 1.0,\n 1.0, 1.0, 1.0,\n 1.0, 1.0, -1.0,\n\n // Bottom face\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n\n // Right face\n 1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, 1.0,\n\n // Left face\n -1.0, -1.0, -1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, 1.0,\n -1.0, 1.0, -1.0,\n ];\n\n indices = [\n 0, 1, 2, 0, 2, 3, // front\n 4, 5, 6, 4, 6, 7, // back\n 8, 9, 10, 8, 10, 11, // top\n 12, 13, 14, 12, 14, 15, // bottom\n 16, 17, 18, 16, 18, 19, // right\n 20, 21, 22, 20, 22, 23, // left\n ];\n\n text_coord = [\n // Front\n 0.0, 1.0,\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n // Back\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n 0.0, 1.0,\n // Top\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n // Bottom\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n // right\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n 0.0, 1.0,\n // Left\n 0.0, 1.0,\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n ];\n\n colours = [\n // Front face\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n\n // Back face\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n\n // Top face\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n\n // Bottom face\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n\n // Right face\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n\n // Left face\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n ];\n}\n"}, {"path": "cube_rotation/cube_rotation.html", "language": "html", "loc": 15, "comment_density": 0.0, "code": "\n\n\n\nRotation Speed:
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "cube_rotation/cube_rotation.js", "language": "javascript", "loc": 59, "comment_density": 0.119, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\n\nvar cam_height = 5;\nvar position_cam = [-6.0, cam_height, 0];\n\nvar cube = new Cube;\nvar plane = new Plane;\n\nvar last_time = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n cube.setup(gl);\n\n plane.setup(gl);\n\n //model matrix for the plane\n mat4.scale(model_matrix_plane, model_matrix_plane, [2, 0, 2]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n cube.set_vp(view_matrix, proj_matrix);\n cube.draw();\n\n d = new Date();\n time = d.getTime()/100000.0;\n //make it framerate independant\n time_diff = time-last_time;\n\n var rotation_speed = document.getElementById(\"slider_speed\").value;\n\n //rotate the model matrix of the cube by a little bit\n var model = cube.get_model_matrix();\n model = mat4.rotate(model, model, -2*Math.PI*time_diff*rotation_speed, [0,1,0]);\n cube.set_model_matrix(model);\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "cube_rotation/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 10, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "cube_rotation/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 6, "comment_density": 0.167, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "cube_rotation/plane.js", "language": "javascript", "loc": 86, "comment_density": 0.012, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n ];\n}\n"}], "validation": {"glslang_valid": 4, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 1, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "none-found", "non_commercial": false, "comment_density": 0.082, "dedup_hash": "1739cc2d304a11cf", "has_readme": true, "build_system": null, "dependency_count": 5, "has_demo": true} -{"id": "webgl_examples_framebuffer", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:31+00:00", "source_type": "repo", "title": "Framebuffer", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "postprocessing/texturing/framebuffer/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "framebuffer/cube.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 10, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n frag_colour = colour;\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/cube.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 5, "comment_density": 0.2, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/cube.js", "language": "javascript", "loc": 206, "comment_density": 0.155, "code": "class Cube{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n mat4.translate(this.model, this.model, [0, 1, 0]);\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n //buffers for colours\n this.col_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.col_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.colours), this.gl.STATIC_DRAW);\n\n }\n\n //sets model view projection matrix\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.col_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"colour\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"colour\"));\n\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n //draw the cube\n this.gl.drawElements(this.gl.TRIANGLES, 36, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n frag_colour = colour;\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }\n `;\n\n positions = [\n // Front face\n -1.0, -1.0, 1.0,\n 1.0, -1.0, 1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0,\n\n // Back face\n -1.0, -1.0, -1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, -1.0, -1.0,\n\n // Top face\n -1.0, 1.0, -1.0,\n -1.0, 1.0, 1.0,\n 1.0, 1.0, 1.0,\n 1.0, 1.0, -1.0,\n\n // Bottom face\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n\n // Right face\n 1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, 1.0,\n\n // Left face\n -1.0, -1.0, -1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, 1.0,\n -1.0, 1.0, -1.0,\n ];\n\n indices = [\n 0, 1, 2, 0, 2, 3, // front\n 4, 5, 6, 4, 6, 7, // back\n 8, 9, 10, 8, 10, 11, // top\n 12, 13, 14, 12, 14, 15, // bottom\n 16, 17, 18, 16, 18, 19, // right\n 20, 21, 22, 20, 22, 23, // left\n ];\n\n text_coord = [\n // Front\n 0.0, 1.0,\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n // Back\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n 0.0, 1.0,\n // Top\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n // Bottom\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n // right\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n 0.0, 1.0,\n // Left\n 0.0, 1.0,\n 1.0, 1.0,\n 1.0, 0.0,\n 0.0, 0.0,\n ];\n\n colours = [\n // Front face\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n\n // Back face\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n 1.0, 1.0, 0.0,\n\n // Top face\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n\n // Bottom face\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n\n // Right face\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n 0.0, 1.0, 1.0,\n\n // Left face\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n 1.0, 0.0, 1.0,\n ];\n}\n"}, {"path": "framebuffer/framebuffer.html", "language": "html", "loc": 29, "comment_density": 0.0, "code": "\n\n\n\nRotation Speed:
\nEffect:\n\n\n\n\n\n\n\n\n\n\n
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "framebuffer/framebuffer.js", "language": "javascript", "loc": 38, "comment_density": 0.158, "code": "class Framebuffer{\n\n setup(gl, image_width, image_height) {\n this.gl = gl;\n\n this.image_width = image_width;\n this.image_height = image_height;\n\n this.fb_tex = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.fb_tex);\n\n //allocate space for the texture, but feed nothing to it (null)\n //will be filled later by rendering in the framebuffer\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.image_width, this.image_height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\n this.fb = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb);\n\n //key part, we associate the texture with the framebuffer\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.fb_tex, 0);\n\n //create a depth buffer for the framebuffer, otherwise 3d rendering will be weird\n this.depth_buffer = gl.createRenderbuffer();\n gl.bindRenderbuffer(gl.RENDERBUFFER, this.depth_buffer);\n\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.image_width, this.image_height);\n\n //associate the render buffer with the framebuffer\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.depth_buffer);\n\n //unbind everything to avoid pollution\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n\n bind(){\n this.gl.viewport(0, 0, this.image_width, this.image_height);\n this.gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb);\n }\n\n unbind(){\n this.gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n\n get_texture(){\n return this.fb_tex;\n }\n\n}"}, {"path": "framebuffer/main.js", "language": "javascript", "loc": 91, "comment_density": 0.099, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\n\nvar cam_height = 5;\nvar position_cam = [-6.0, cam_height, 0];\n\nvar cube = new Cube;\nvar plane = new Plane;\n\nvar quad_screen = new Quad_screen;\n\nvar framebuffer = new Framebuffer;\n\nvar last_time = 0;\n\nvar canvas_width = 1600;\nvar canvas_height = 900;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n canvas_width = gl.canvas.width;\n canvas_height = gl.canvas.height;\n\n cube.setup(gl);\n\n plane.setup(gl);\n\n quad_screen.setup(gl, canvas_width, canvas_height);\n\n framebuffer.setup(gl, canvas_width, canvas_height);\n\n quad_screen.set_framebuffer_texture(framebuffer.get_texture());\n\n //model matrix for the plane\n mat4.scale(model_matrix_plane, model_matrix_plane, [2, 0, 2]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n\n change_selection();\n}\n\nfunction change_selection(){\n\n if(document.getElementById(\"nothing\").checked == true){\n quad_screen.set_effect_active(0);\n }\n if(document.getElementById(\"invert\").checked == true){\n quad_screen.set_effect_active(1);\n }\n if(document.getElementById(\"gaussian\").checked == true){\n quad_screen.set_effect_active(2);\n }\n if(document.getElementById(\"sobel\").checked == true){\n quad_screen.set_effect_active(3);\n }\n if(document.getElementById(\"glass\").checked == true){\n quad_screen.set_effect_active(4);\n }\n}\n\nfunction draw(){\n //will render in frambuffer\n framebuffer.bind();\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n cube.set_vp(view_matrix, proj_matrix);\n cube.draw();\n\n d = new Date();\n time = d.getTime()/100000.0;\n //make it framerate independant\n time_diff = time-last_time;\n\n var rotation_speed = document.getElementById(\"slider_speed\").value;\n\n //rotate the model matrix of the cube by a little bit\n var model = cube.get_model_matrix();\n model = mat4.rotate(model, model, -2*Math.PI*time_diff*rotation_speed, [0,1,0]);\n cube.set_model_matrix(model);\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n //everything after that will be rendered in the canvas\n framebuffer.unbind();\n\n quad_screen.draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "framebuffer/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 10, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 6, "comment_density": 0.167, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/plane.js", "language": "javascript", "loc": 86, "comment_density": 0.012, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n ];\n}\n"}, {"path": "framebuffer/quad_screen.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 7, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n void main() {\n gl_Position = vertex_pos;\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/quad_screen.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 93, "comment_density": 0.054, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n uniform int effect_select;\n\n uniform float tex_width;\n uniform float tex_height;\n\n //grayscale\n float col_to_gs(vec3 vec){\n return 0.21*vec.x + 0.72*vec.y + 0.07*vec.z;\n }\n\n void main() {\n vec3 color_out = vec3(0.0, 0.0, 0.0);\n\n if(effect_select == 0){\n gl_FragColor = texture2D(texture, frag_uv);\n }\n else if(effect_select == 1){\n gl_FragColor = vec4(vec3(1.0)-texture2D(texture, frag_uv).rgb, 1.0);\n }\n else if(effect_select == 2){\n\n const int gauss_mat_size = 12;\n float variance = 10.0;\n float mean = float(gauss_mat_size)/2.0;\n float gauss_mat[gauss_mat_size];\n float gauss_mat_coef = 0.0;\n\n //init the blurring mat\n for(int i = 0; i < gauss_mat_size; i++){\n float val = 1.0/sqrt(2.0*3.1415*variance);\n val = val*pow(2.7182818, -pow((float(i)-mean), 2.0)/(2.0*variance));\n gauss_mat[i] = val;\n gauss_mat_coef += val;\n }\n\n gauss_mat_coef = 1.0/(gauss_mat_coef*gauss_mat_coef);\n\n for(int i = 0; i < gauss_mat_size; i++){\n float rel_i = float(i-(gauss_mat_size-1)/2);\n float sum = 0.0;\n for(int j = 0; j < gauss_mat_size; j++){\n float rel_j = float(j-(gauss_mat_size-1)/2);\n float matrix_val = gauss_mat[i]*gauss_mat[j];\n color_out += matrix_val*texture2D(texture, frag_uv+vec2(rel_i/tex_width,rel_j/tex_height)).rgb;\n }\n }\n\n color_out = color_out*gauss_mat_coef;\n gl_FragColor = vec4(color_out, 1.0);\n }\n else if(effect_select == 3){\n\n const int sobel_x_size = 3;\n // float sobel_x[sobel_x_size*sobel_x_size] = float[](1, 0, -1, 2, 0, -2, 1, 0, -1); //only glsl3.0\n float sobel_x[sobel_x_size*sobel_x_size];\n sobel_x[0] = 1.0;\n sobel_x[1] = 0.0;\n sobel_x[2] = -1.0;\n sobel_x[3] = 2.0;\n sobel_x[4] = 0.0;\n sobel_x[5] = -2.0;\n sobel_x[6] = 1.0;\n sobel_x[7] = 0.0;\n sobel_x[8] = -1.0;\n\n const int sobel_y_size = 3;\n // float sobel_y[sobel_y_size*sobel_y_size] = float[](1, 2, 1, 0, 0, 0, -1, -2, -1); //only glsl3.0\n float sobel_y[sobel_y_size*sobel_y_size];\n sobel_y[0] = 1.0;\n sobel_y[1] = 2.0;\n sobel_y[2] = 1.0;\n sobel_y[3] = 0.0;\n sobel_y[4] = 0.0;\n sobel_y[5] = 0.0;\n sobel_y[6] = -1.0;\n sobel_y[7] = -2.0;\n sobel_y[8] = -1.0;\n\n float edge_x = 0.0;\n float edge_y = 0.0;\n\n for(int i = 0; i < sobel_x_size; i++){\n float rel_i = float(i)-(float(sobel_x_size)-1.0)/2.0;\n\n for(int j = 0; j < sobel_y_size; j++){\n float rel_j = float(j)-(float(sobel_y_size)-1.0)/2.0;\n float grayscale_pixel = col_to_gs(texture2D(texture, frag_uv+vec2(rel_i/tex_width,rel_j/tex_height)).rgb);\n edge_x += sobel_x[j*3+i]*grayscale_pixel;\n edge_y += sobel_y[j*3+i]*grayscale_pixel;\n }\n }\n\n color_out = vec3(sqrt(edge_x*edge_x+edge_y*edge_y));\n gl_FragColor = vec4(color_out, 1.0);\n }\n else if(effect_select == 4){\n float move_x = sin(frag_uv.x*500.0)*10.0;\n float move_y = sin(frag_uv.y*500.0)*10.0;\n\n color_out = texture2D(texture, frag_uv+vec2(move_x/tex_width,move_y/tex_height)).rgb;\n gl_FragColor = vec4(color_out, 1.0);\n }\n else{\n gl_FragColor = texture2D(texture, frag_uv);\n }\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "framebuffer/quad_screen.js", "language": "javascript", "loc": 175, "comment_density": 0.034, "code": "\nclass Quad_screen{\n\n setup(gl, screen_width, screen_height){\n this.gl = gl;\n\n this.screen_width = screen_width;\n this.screen_height = screen_height;\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //texture coordinate buffer\n this.tex_coord_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, this.tex_coord_buffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.text_coord), gl.STATIC_DRAW);\n\n this.effect_active = 0;\n }\n\n set_framebuffer_texture(tex){\n this.fb_texture_id = tex;\n }\n\n set_effect_active(effect){\n this.effect_active = effect;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.useProgram(this.shader_program);\n\n gl.activeTexture(gl.TEXTURE0);\n\n gl.bindTexture(gl.TEXTURE_2D, this.fb_texture_id);\n\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"texture\"), 0);\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"effect_select\"), this.effect_active);\n gl.uniform1f(gl.getUniformLocation(this.shader_program, \"tex_width\"), this.screen_width);\n gl.uniform1f(gl.getUniformLocation(this.shader_program, \"tex_height\"), this.screen_height);\n\n\n this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n void main() {\n gl_Position = vertex_pos;\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n uniform int effect_select;\n\n uniform float tex_width;\n uniform float tex_height;\n\n //grayscale\n float col_to_gs(vec3 vec){\n return 0.21*vec.x + 0.72*vec.y + 0.07*vec.z;\n }\n\n void main() {\n vec3 color_out = vec3(0.0, 0.0, 0.0);\n\n if(effect_select == 0){\n gl_FragColor = texture2D(texture, frag_uv);\n }\n else if(effect_select == 1){\n gl_FragColor = vec4(vec3(1.0)-texture2D(texture, frag_uv).rgb, 1.0);\n }\n else if(effect_select == 2){\n\n const int gauss_mat_size = 12;\n float variance = 10.0;\n float mean = float(gauss_mat_size)/2.0;\n float gauss_mat[gauss_mat_size];\n float gauss_mat_coef = 0.0;\n\n //init the blurring mat\n for(int i = 0; i < gauss_mat_size; i++){\n float val = 1.0/sqrt(2.0*3.1415*variance);\n val = val*pow(2.7182818, -pow((float(i)-mean), 2.0)/(2.0*variance));\n gauss_mat[i] = val;\n gauss_mat_coef += val;\n }\n\n gauss_mat_coef = 1.0/(gauss_mat_coef*gauss_mat_coef);\n\n for(int i = 0; i < gauss_mat_size; i++){\n float rel_i = float(i-(gauss_mat_size-1)/2);\n float sum = 0.0;\n for(int j = 0; j < gauss_mat_size; j++){\n float rel_j = float(j-(gauss_mat_size-1)/2);\n float matrix_val = gauss_mat[i]*gauss_mat[j];\n color_out += matrix_val*texture2D(texture, frag_uv+vec2(rel_i/tex_width,rel_j/tex_height)).rgb;\n }\n }\n\n color_out = color_out*gauss_mat_coef;\n gl_FragColor = vec4(color_out, 1.0);\n }\n else if(effect_select == 3){\n\n const int sobel_x_size = 3;\n // float sobel_x[sobel_x_size*sobel_x_size] = float[](1, 0, -1, 2, 0, -2, 1, 0, -1); //only glsl3.0\n float sobel_x[sobel_x_size*sobel_x_size];\n sobel_x[0] = 1.0;\n sobel_x[1] = 0.0;\n sobel_x[2] = -1.0;\n sobel_x[3] = 2.0;\n sobel_x[4] = 0.0;\n sobel_x[5] = -2.0;\n sobel_x[6] = 1.0;\n sobel_x[7] = 0.0;\n sobel_x[8] = -1.0;\n\n const int sobel_y_size = 3;\n // float sobel_y[sobel_y_size*sobel_y_size] = float[](1, 2, 1, 0, 0, 0, -1, -2, -1); //only glsl3.0\n float sobel_y[sobel_y_size*sobel_y_size];\n sobel_y[0] = 1.0;\n sobel_y[1] = 2.0;\n sobel_y[2] = 1.0;\n sobel_y[3] = 0.0;\n sobel_y[4] = 0.0;\n sobel_y[5] = 0.0;\n sobel_y[6] = -1.0;\n sobel_y[7] = -2.0;\n sobel_y[8] = -1.0;\n\n float edge_x = 0.0;\n float edge_y = 0.0;\n\n for(int i = 0; i < sobel_x_size; i++){\n float rel_i = float(i)-(float(sobel_x_size)-1.0)/2.0;\n\n for(int j = 0; j < sobel_y_size; j++){\n float rel_j = float(j)-(float(sobel_y_size)-1.0)/2.0;\n float grayscale_pixel = col_to_gs(texture2D(texture, frag_uv+vec2(rel_i/tex_width,rel_j/tex_height)).rgb);\n edge_x += sobel_x[j*3+i]*grayscale_pixel;\n edge_y += sobel_y[j*3+i]*grayscale_pixel;\n }\n }\n\n color_out = vec3(sqrt(edge_x*edge_x+edge_y*edge_y));\n gl_FragColor = vec4(color_out, 1.0);\n }\n else if(effect_select == 4){\n float move_x = sin(frag_uv.x*500.0)*10.0;\n float move_y = sin(frag_uv.y*500.0)*10.0;\n\n color_out = texture2D(texture, frag_uv+vec2(move_x/tex_width,move_y/tex_height)).rgb;\n gl_FragColor = vec4(color_out, 1.0);\n }\n else{\n gl_FragColor = texture2D(texture, frag_uv);\n }\n }\n `;\n\n positions = [\n -1.0, -1.0, 0.0,\n +1.0, -1.0, 0.0,\n -1.0, +1.0, 0.0,\n +1.0, +1.0, 0.0,\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 0.0, 1.0,\n 1.0, 1.0,\n ];\n}\n"}], "validation": {"glslang_valid": 6, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 2, "has_compute_barriers": false, "has_instancing": false}, "preview_image": "images/webgl_examples_framebuffer.png", "license": "none-found", "non_commercial": false, "comment_density": 0.073, "dedup_hash": "030154224714a88c", "has_readme": true, "build_system": null, "dependency_count": 7, "has_demo": true} -{"id": "webgl_examples_grass", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Grass", "api": "OpenGL/WebGL", "glsl_version": "300 es", "topic": "instancing/texturing/vegetation/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "grass/grass.html", "language": "html", "loc": 24, "comment_density": 0.0, "code": "\n\n\n\nWind speed: \nCamera position:
\nNumber of grass blades:\n\n\n\n\n\n\n
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "grass/grass_manager.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 51, "comment_density": 0.039, "code": "#version 300 es\n precision mediump float;\n in vec4 vertex_pos;\n\n in mat4 mat_model;\n in vec2 uv;\n\n out vec3 pixel_pos;\n out vec2 global_uv;\n out vec2 frag_uv;\n out vec2 rel_tex_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n uniform float time;\n\n uniform sampler2D tex_wind;\n\n void main() {\n pixel_pos = vec3(mat_model*vertex_pos);\n\n vec2 relative_tex_pos = vec2(pixel_pos.x/100.0+0.5, pixel_pos.z/100.0+0.5);\n global_uv = relative_tex_pos;\n\n frag_uv = uv;\n\n vec2 wind_dir = vec2(time, time);\n float wind_x = texture(tex_wind, relative_tex_pos+wind_dir ).r-0.5;\n float wind_z = texture(tex_wind, relative_tex_pos+vec2(0.5, 0.5)+wind_dir ).r-0.5;\n\n //make wind a bit more dramatic\n wind_x *= 2.0;\n wind_z *= 2.0;\n\n rel_tex_pos = relative_tex_pos;\n\n vec3 new_pos = vec3(mat_model*vertex_pos);\n\n //move the top vertex of the grass move more than the lower ones\n if(gl_VertexID == 0){\n wind_x *= 3.0;\n wind_z *= 3.0;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n if(gl_VertexID == 1 || gl_VertexID == 2 ){\n wind_x *= 1.5;\n wind_z *= 1.5;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n if(gl_VertexID == 3 || gl_VertexID == 4 ){\n wind_x *= 0.5;\n wind_z *= 0.5;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n\n gl_Position = proj*view*vec4(new_pos, 1.0);\n }", "glsl_version": "300 es", "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "grass/grass_manager.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 19, "comment_density": 0.158, "code": "#version 300 es\n precision mediump float;\n\n in vec3 pixel_pos;\n in vec2 global_uv;\n in vec2 frag_uv;\n in vec2 rel_tex_pos;\n\n out vec4 color;\n\n uniform vec3 light_pos;\n uniform sampler2D tex_wind;\n\n uniform float time;\n\n void main() {\n //get a random value for this blade from its position, will be used to vary the colour a bit from grass to grass\n float rand_val = mod((global_uv.x*global_uv.x)+(0.13-global_uv.x*global_uv.y), 0.01)/0.01;\n\n //make the edges of the blade lighter\n float dist_to_centre = pow(distance(frag_uv, vec2(0.5, 0.5)), 2.0);\n\n //make the base a bit darker\n float dist_to_ground = clamp((1.0-frag_uv.y)*1.0, 0.0, 1.0);\n\n color = vec4( (0.1+rand_val/6.0+dist_to_centre)*dist_to_ground, (0.3+dist_to_centre)*dist_to_ground, (0.0+dist_to_centre)*dist_to_ground, 1.0);\n }", "glsl_version": "300 es", "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "grass/grass_manager.js", "language": "javascript", "loc": 256, "comment_density": 0.105, "code": "class Grass_manager{\n\n setup(gl, plane){\n this.gl = gl;\n\n this.base = plane;\n\n this.max_grass = 16000;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.vao = this.gl.createVertexArray();\n\n this.gl.bindVertexArray(this.vao);\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n this.tex_coord_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, this.tex_coord_buffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.tex_coord), gl.STATIC_DRAW);\n\n //generate a model matrix for each grass blade, that will be put in a buffer, to be drawn with instanced rendering\n this.lst_transforms = []\n\n for (let i = 0; i < this.max_grass; i++) {\n var pos_x = 100*(Math.random()-0.5)\n var pos_y = 100*(Math.random()-0.5)\n this.lst_transforms[i] = this.get_grass_matrix(pos_x, pos_y);\n }\n\n this.transforms_list = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n //put all the model matrices in a buffer, need the mat4 in a flat structure, a list\n var lst_model_flat = this.lst_transforms.map(a=>[...a]).flat();\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(lst_model_flat), this.gl.STATIC_DRAW);\n\n //generate the wind texture\n var wind_tex_size = 512;\n\n this.generate_wind_texture(wind_tex_size);\n\n this.texture_id = gl.createTexture();\n\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, wind_tex_size, wind_tex_size, 0, gl.RGB, gl.UNSIGNED_BYTE, new Uint8Array(this.wind_array_texture));\n\n //mirrored repeat as we will pan over the texture multiple times\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); //do not forget this for float textures\n\n this.time = 0;\n }\n\n set_max_grass(mg){\n this.max_grass = mg;\n }\n\n //do a bit of matrix rotations (with randomness) to get a blade of grass standing up\n get_grass_matrix(pos_x, pos_y){\n var model_matrix_grass = mat4.create();\n\n mat4.translate(model_matrix_grass, model_matrix_grass, [0, this.base.get_height(pos_x,pos_y), 0]);\n mat4.translate(model_matrix_grass, model_matrix_grass, [pos_x, 0, pos_y]);\n mat4.scale(model_matrix_grass, model_matrix_grass, [0.3, 1.7, 0.3]);\n mat4.scale(model_matrix_grass, model_matrix_grass, [1, 1+Math.random(), 1]);\n mat4.translate(model_matrix_grass, model_matrix_grass, [0, 2, 0]);\n mat4.rotate(model_matrix_grass, model_matrix_grass, 3.1415/4.0*pos_x*pos_y*5.244 ,[0, 1, 0]);\n mat4.rotate(model_matrix_grass, model_matrix_grass, 3.1415/2.0 ,[1, 0, 0]);\n\n return model_matrix_grass;\n }\n\n //generate wind texture, which will impact the position of the grass\n //only R component of the texture will be used\n generate_wind_texture(size){\n this.wind_array_texture = [];\n\n for (var i = 0; i < size; i++) {\n for (var j = 0; j < size; j++) {\n var val = Math.sin(i/size*16)*Math.cos(j/size*8);\n val += 0.25*Math.sin(i/size*32)*Math.cos(j/size*64);\n this.wind_array_texture.push( val*64+128 ); //R\n this.wind_array_texture.push( 0.0 ); //G useless\n this.wind_array_texture.push( 0.0 ); //B useless\n }\n }\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n set_time(t){\n this.time = t;\n }\n\n draw(){\n this.gl.bindVertexArray(this.vao);\n this.gl.useProgram(this.shader_program);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n //setup the buffer to tell webgl to use a single mat4 matrix per instanced rendering, a bit wordy$\n //webgl2 was needed for the instanced rendering\n var uniform_loc = this.gl.getAttribLocation(this.shader_program, \"mat_model\");\n\n this.gl.enableVertexAttribArray(uniform_loc);\n this.gl.vertexAttribPointer(uniform_loc, 4, this.gl.FLOAT, this.gl.FALSE, 64, 0);\n\n this.gl.enableVertexAttribArray(uniform_loc+1);\n this.gl.vertexAttribPointer(uniform_loc+1, 4, this.gl.FLOAT, this.gl.FALSE, 64, 16);\n\n this.gl.enableVertexAttribArray(uniform_loc+2);\n this.gl.vertexAttribPointer(uniform_loc+2, 4, this.gl.FLOAT, this.gl.FALSE, 64, 32);\n\n this.gl.enableVertexAttribArray(uniform_loc+3);\n this.gl.vertexAttribPointer(uniform_loc+3, 4, this.gl.FLOAT, this.gl.FALSE, 64, 48);\n\n this.gl.vertexAttribDivisor(uniform_loc, 1);\n this.gl.vertexAttribDivisor(uniform_loc+1, 1);\n this.gl.vertexAttribDivisor(uniform_loc+2, 1);\n this.gl.vertexAttribDivisor(uniform_loc+3, 1);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.lst_transforms[0] );\n\n this.gl.uniform1f( this.gl.getUniformLocation(this.shader_program, \"time\"), this.time );\n\n this.gl.activeTexture(gl.TEXTURE0);\n\n this.gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n this.gl.uniform1i(gl.getUniformLocation(this.shader_program, \"tex_wind\"), 0);\n\n\n this.gl.disable(this.gl.CULL_FACE);\n\n //tell webgl we will draw max_grass blades that each contains 15 vertices\n this.gl.drawElementsInstanced(this.gl.TRIANGLES, 15, this.gl.UNSIGNED_SHORT, 0, this.max_grass);\n\n this.gl.enable(this.gl.CULL_FACE);\n\n this.gl.vertexAttribDivisor(uniform_loc, 0);\n }\n\n //needed glsl 3 for gl_VertexID\n vertex_shader_code = `#version 300 es\n precision mediump float;\n in vec4 vertex_pos;\n\n in mat4 mat_model;\n in vec2 uv;\n\n out vec3 pixel_pos;\n out vec2 global_uv;\n out vec2 frag_uv;\n out vec2 rel_tex_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n uniform float time;\n\n uniform sampler2D tex_wind;\n\n void main() {\n pixel_pos = vec3(mat_model*vertex_pos);\n\n vec2 relative_tex_pos = vec2(pixel_pos.x/100.0+0.5, pixel_pos.z/100.0+0.5);\n global_uv = relative_tex_pos;\n\n frag_uv = uv;\n\n vec2 wind_dir = vec2(time, time);\n float wind_x = texture(tex_wind, relative_tex_pos+wind_dir ).r-0.5;\n float wind_z = texture(tex_wind, relative_tex_pos+vec2(0.5, 0.5)+wind_dir ).r-0.5;\n\n //make wind a bit more dramatic\n wind_x *= 2.0;\n wind_z *= 2.0;\n\n rel_tex_pos = relative_tex_pos;\n\n vec3 new_pos = vec3(mat_model*vertex_pos);\n\n //move the top vertex of the grass move more than the lower ones\n if(gl_VertexID == 0){\n wind_x *= 3.0;\n wind_z *= 3.0;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n if(gl_VertexID == 1 || gl_VertexID == 2 ){\n wind_x *= 1.5;\n wind_z *= 1.5;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n if(gl_VertexID == 3 || gl_VertexID == 4 ){\n wind_x *= 0.5;\n wind_z *= 0.5;\n new_pos.x += wind_x;\n new_pos.y -= (abs(wind_x)+abs(wind_z))*0.5;\n new_pos.z += wind_z;\n }\n\n gl_Position = proj*view*vec4(new_pos, 1.0);\n }\n `;\n\n fragment_shader_code = `#version 300 es\n precision mediump float;\n\n in vec3 pixel_pos;\n in vec2 global_uv;\n in vec2 frag_uv;\n in vec2 rel_tex_pos;\n\n out vec4 color;\n\n uniform vec3 light_pos;\n uniform sampler2D tex_wind;\n\n uniform float time;\n\n void main() {\n //get a random value for this blade from its position, will be used to vary the colour a bit from grass to grass\n float rand_val = mod((global_uv.x*global_uv.x)+(0.13-global_uv.x*global_uv.y), 0.01)/0.01;\n\n //make the edges of the blade lighter\n float dist_to_centre = pow(distance(frag_uv, vec2(0.5, 0.5)), 2.0);\n\n //make the base a bit darker\n float dist_to_ground = clamp((1.0-frag_uv.y)*1.0, 0.0, 1.0);\n\n color = vec4( (0.1+rand_val/6.0+dist_to_centre)*dist_to_ground, (0.3+dist_to_centre)*dist_to_ground, (0.0+dist_to_centre)*dist_to_ground, 1.0);\n }\n `;\n\n positions = [\n 0.0, 0.0, -2.0, // 0\n -1.0, 0.0, 0.0, // 1\n 1.0, 0.0, 0.0, // 2\n -1.0, 0.0, 1.0, // 3\n 1.0, 0.0, 1.0, // 4\n -1.0, 0.0, 2.0, // 5\n 1.0, 0.0, 2.0, // 6\n ];\n\n indices = [\n 0, 1, 2,\n 2, 1, 3,\n 2, 3, 4,\n 4, 3, 5,\n 4, 5, 6,\n ];\n\n tex_coord = [\n 0.5, 0.0,\n 0.0, 0.5,\n 1.0, 0.5,\n 0.0, 0.75,\n 1.0, 0.75,\n 0.0, 1.0,\n 1.0, 1.0,\n ];\n}\n\n"}, {"path": "grass/main.js", "language": "javascript", "loc": 69, "comment_density": 0.087, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\nvar model_matrix_grass_manager = mat4.create();\n\nvar cam_height = 25;\nvar position_cam = [-70.0, cam_height, 0];\n\nvar plane = new Plane_sine;\nvar grass_manager = new Grass_manager;\n\nvar last_time = 0;\n\nvar time_wind = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl2\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL2\");\n return;\n }\n\n plane.setup(gl);\n\n mat4.scale(model_matrix_plane, model_matrix_plane, [50, 3, 50]);\n mat4.scale(model_matrix_grass_manager, model_matrix_grass_manager, [1, 1, 1]);\n mat4.translate(model_matrix_grass_manager, model_matrix_grass_manager, [0, 0, 0]);\n\n plane.set_model_matrix(model_matrix_plane);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n\n grass_manager.setup(gl, plane);\n}\n\nfunction draw(){\n var cam_pos = document.getElementById(\"camera_position\").value;\n\n position_cam[0] = -cam_pos;\n\n mat4.lookAt(view_matrix, position_cam, [70-cam_pos, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n d = new Date();\n time = d.getTime()/100000.0;\n //make it framerate independent\n time_diff = time-last_time;\n\n var wind_speed = document.getElementById(\"slider_speed\").value;\n // wind_speed = wind_speed/50.0;\n time_wind += wind_speed/70000.0;\n\n if(document.getElementById(\"16000\").checked == true){\n grass_manager.set_max_grass(16000);\n }\n else if(document.getElementById(\"8000\").checked == true){\n grass_manager.set_max_grass(8000);\n }\n else if(document.getElementById(\"4000\").checked == true){\n grass_manager.set_max_grass(4000);\n }\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n grass_manager.set_time( time_wind);\n grass_manager.set_mvp(model_matrix_grass_manager, view_matrix, proj_matrix);\n grass_manager.draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "grass/plane_sine.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 7, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "grass/plane_sine.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 5, "comment_density": 0.2, "code": "precision mediump float;\n\n void main() {\n // just output some brown color\n gl_FragColor = vec4(0.3, 0.14, 0.07, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "grass/plane_sine.js", "language": "javascript", "loc": 137, "comment_density": 0.226, "code": "class Plane_sine{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n\n this.nb_vertices_side = 48;//default\n\n this.generate_geometry();\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.vertices), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n }\n\n //the shape of the plane\n get_height_priv(x, z){\n return Math.sin(x*5)+Math.sin(z*5);\n }\n\n generate_geometry()\n {\n var increment = 1.0/(this.nb_vertices_side-1);\n\n this.vertices = [];\n\n //the vertices\n for (let y = 0; y < this.nb_vertices_side; y++) {\n for (let x = 0; x < this.nb_vertices_side; x++) {\n this.vertices.push(-1.0+2*increment*x);\n this.vertices.push(this.get_height_priv(-1.0+2*increment*x, -1.0+2*increment*y));\n this.vertices.push(-1.0+2*increment*y);\n }\n }\n\n this.indices = [];\n\n //generate the indices\n for (let y = 0; y < this.nb_vertices_side-1; y++) {\n for (let x = 0; x < this.nb_vertices_side-1; x++) {\n var this_vertice = y*this.nb_vertices_side+x;\n //one of the triangle\n this.indices.push(this_vertice+1); //top right\n this.indices.push(this_vertice);\n this.indices.push(this_vertice+this.nb_vertices_side);\n\n this.indices.push(this_vertice+this.nb_vertices_side);\n this.indices.push(this_vertice+this.nb_vertices_side+1);\n this.indices.push(this_vertice+1);\n }\n }\n }\n\n //get the height of the plane from position, but taking into account a model matrix for the shape (ex scale)\n get_height(pos_x, pos_y){\n //just assume a simple scale matrix, to simplify the matrix manipulations\n\n var pos_x_transf = pos_x/this.model[0]; // [0][0];\n var pos_y_transf = pos_y/this.model[10]; // [2][2] as mat4 is a 1D array\n\n var height = this.get_height_priv(pos_x_transf, pos_y_transf);\n\n return height*this.model[5] //[1][1];\n }\n\n //old version with any type of model matrix, annoying\n // get_height_old(pos_x, pos_y){\n // var vec = vec4.create();\n // vec[0] = pos_x;\n // vec[1] = 0;\n // vec[2] = pos_y;\n // vec[3] = 1.0;\n\n // var vec_transf = vec4.create();\n // vec4.transformMat4(vec_transf, vec, this.model);\n\n // var height = this.get_height_priv(vec_transf[0], vec_transf[2]);\n\n // var vec_height = vec4.create();\n // vec[0] = 0;\n // vec[1] = height;\n // vec[2] = 0;\n // vec[3] = 1.0;\n\n // var model_height = vec4.create();\n // vec4.transformMat4(model_height, vec_height, this.model);\n\n // return model_height[1];\n // }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n var nb_squares = this.nb_vertices_side-1;\n var nb_vertices_to_draw = nb_squares*nb_squares*6;\n\n this.gl.drawElements(this.gl.TRIANGLES, nb_vertices_to_draw, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float;\n\n void main() {\n // just output some brown color\n gl_FragColor = vec4(0.3, 0.14, 0.07, 1.0);\n }\n `;\n}\n"}], "validation": {"glslang_valid": 4, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 2, "has_compute_barriers": false, "has_instancing": false}, "preview_image": "images/webgl_examples_grass.png", "license": "none-found", "non_commercial": false, "comment_density": 0.102, "dedup_hash": "4a699a3f1c50ebec", "has_readme": true, "build_system": null, "dependency_count": 5, "has_demo": true} -{"id": "webgl_examples_shading", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Shading", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "shading/cube.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 17, "comment_density": 0.235, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "shading/cube.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 11, "comment_density": 0.091, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "shading/cube.js", "language": "javascript", "loc": 193, "comment_density": 0.155, "code": "class Cube{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n mat4.translate(this.model, this.model, [0, 1, 0]);\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //buffer containings the normals\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW)\n\n }\n\n //sets model view projection matrix\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n //draw the cube\n this.gl.drawElements(this.gl.TRIANGLES, 36, this.gl.UNSIGNED_SHORT, 0);\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n // Front face\n -1.0, -1.0, 1.0,\n 1.0, -1.0, 1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0,\n\n // Back face\n -1.0, -1.0, -1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, -1.0, -1.0,\n\n // Top face\n -1.0, 1.0, -1.0,\n -1.0, 1.0, 1.0,\n 1.0, 1.0, 1.0,\n 1.0, 1.0, -1.0,\n\n // Bottom face\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n\n // Right face\n 1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, 1.0,\n\n // Left face\n -1.0, -1.0, -1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, 1.0,\n -1.0, 1.0, -1.0,\n ];\n\n indices = [\n 0, 1, 2, 0, 2, 3, // front\n 4, 5, 6, 4, 6, 7, // back\n 8, 9, 10, 8, 10, 11, // top\n 12, 13, 14, 12, 14, 15, // bottom\n 16, 17, 18, 16, 18, 19, // right\n 20, 21, 22, 20, 22, 23, // left\n ];\n\n normals = [\n // Front face\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n\n // Back face\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n\n // Top face\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n\n // Bottom face\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n\n // Right face\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n\n // Left face\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n ];\n}\n"}, {"path": "shading/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 12, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "shading/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 11, "comment_density": 0.091, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "shading/plane.js", "language": "javascript", "loc": 112, "comment_density": 0.009, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n normals = [\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n ];\n}\n"}, {"path": "shading/shading.html", "language": "html", "loc": 16, "comment_density": 0.0, "code": "\n\n\n\nLight Speed: \nLight Height:
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "shading/shading.js", "language": "javascript", "loc": 91, "comment_density": 0.11, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\nvar model_matrix_cubes = [mat4.create(), mat4.create()];\n\nvar cam_height = 5;\nvar position_cam = [-20.0, cam_height, -20.0];\n\nvar rotating_cube = new Cube;\n\nvar cubes = [new Cube, new Cube];\nvar plane = new Plane;\n\nvar light_pos_radius = 10;\nvar light_pos = [-1, 5.0, 0];\n\n\nvar last_time = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n rotating_cube.setup(gl);\n cubes[0].setup(gl);\n cubes[1].setup(gl);\n\n plane.setup(gl);\n\n //model matrix for the plane\n mat4.scale(model_matrix_plane, model_matrix_plane, [10, 1, 10]);\n\n mat4.translate(model_matrix_cubes[0], model_matrix_cubes[0], [0, 1, 5]);\n mat4.translate(model_matrix_cubes[1], model_matrix_cubes[1], [5, 1, -5]);\n\n cubes[0].set_model_matrix(model_matrix_cubes[0]);\n cubes[1].set_model_matrix(model_matrix_cubes[1]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\n d = new Date();\n time = d.getTime()/100000.0;\n\n //so that first time we do the loop, time_diff does not contain crazy value\n if(last_time == 0){\n last_time = time;\n }\n\n //make it framerate independant\n time_diff = time-last_time;\n\n var light_speed = document.getElementById(\"slider_speed\").value;\n var light_height = document.getElementById(\"slider_height\").value;\n\n //apply a rotation matrix on the light pos to make it rotate around the origin\n light_pos[0] = light_pos[0]*Math.cos(time_diff*light_speed)-light_pos[2]*Math.sin(time_diff*light_speed);\n light_pos[1] = 11.0-light_height;\n light_pos[2] = light_pos[0]*Math.sin(time_diff*light_speed)+light_pos[2]*Math.cos(time_diff*light_speed);\n\n //renormalize the rotating bit of the light position, to not lose precision\n var vec_rot_length = light_pos[0]*light_pos[0]+light_pos[2]*light_pos[2];\n light_pos[0] = light_pos[0]/vec_rot_length;\n light_pos[2] = light_pos[2]/vec_rot_length;\n\n var light_pos_scaled = [light_pos[0]*light_pos_radius, light_pos[1], light_pos[2]*light_pos_radius];\n plane.set_light_pos(light_pos_scaled);\n rotating_cube.set_light_pos(light_pos_scaled);\n cubes[0].set_light_pos(light_pos_scaled);\n cubes[1].set_light_pos(light_pos_scaled);\n\n //rotate the model matrix of the cube by a little bit\n var model = rotating_cube.get_model_matrix();\n model = mat4.rotate(model, model, 2*Math.PI*time_diff*10, [0,1,0]);\n rotating_cube.set_model_matrix(model);\n\n rotating_cube.set_vp(view_matrix, proj_matrix);\n rotating_cube.draw();\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n cubes[0].set_mvp(model_matrix_cubes[0], view_matrix, proj_matrix);\n cubes[0].draw();\n\n cubes[1].set_mvp(model_matrix_cubes[1], view_matrix, proj_matrix);\n cubes[1].draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}], "validation": {"glslang_valid": 4, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "none-found", "non_commercial": false, "comment_density": 0.086, "dedup_hash": "bbda8f24a4fd9735", "has_readme": true, "build_system": null, "dependency_count": 5, "has_demo": true} -{"id": "webgl_examples_texturing", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Texturing", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "texturing/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "texturing/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 10, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "texturing/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 7, "comment_density": 0.286, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = texture2D(texture, frag_uv);\n // gl_FragColor = vec4(frag_uv, 0.0, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "texturing/plane.js", "language": "javascript", "loc": 134, "comment_density": 0.082, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n //texture coordinate buffer\n this.tex_coord_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, this.tex_coord_buffer);\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.text_coord), gl.STATIC_DRAW);\n\n //generate texture\n this.size_texture = 8;\n this.generate_texture(this.size_texture)\n\n //prepare buffer for texture\n this.texture_id = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, this.size_texture, this.size_texture, 0, gl.RGB, gl.UNSIGNED_BYTE, new Uint8Array(this.array_texture));\n\n // gl.generateMipmap(gl.TEXTURE_2D);\n //or\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n\n }\n\n generate_texture(size){\n this.array_texture = [];\n\n //for normalization\n var max_size = size*size;\n\n for (var i = 0; i < size; i++) {\n for (var j = 0; j < size; j++) {\n this.array_texture.push( (i*j)/max_size*255 ); //R\n this.array_texture.push( (size-i)*j/max_size*255 ); //G\n this.array_texture.push( i*(size-j)/max_size*255 ); //B\n }\n }\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n gl.activeTexture(gl.TEXTURE0);\n\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"texture\"), 0);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n varying vec2 frag_uv;\n\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = texture2D(texture, frag_uv);\n // gl_FragColor = vec4(frag_uv, 0.0, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n ];\n}\n"}, {"path": "texturing/texturing.html", "language": "html", "loc": 14, "comment_density": 0.0, "code": "\n\n\n\nRotation Speed:
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n"}, {"path": "texturing/texturing.js", "language": "javascript", "loc": 55, "comment_density": 0.127, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar model_matrix_plane = mat4.create();\n\nvar cam_height = 5;\nvar position_cam = [-6.0, cam_height, 0];\n\nvar plane = new Plane;\n\nvar last_time = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n plane.setup(gl);\n\n //model matrix for the plane\n mat4.scale(model_matrix_plane, model_matrix_plane, [2, 0, 2]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n d = new Date();\n time = d.getTime()/100000.0;\n //make it framerate independant\n time_diff = time-last_time;\n\n var rotation_speed = document.getElementById(\"slider_speed\").value;\n\n //rotate the model matrix of the plane by a little bit\n var model = plane.get_model_matrix();\n model = mat4.rotate(model, model, -2*Math.PI*time_diff*rotation_speed, [0,1,0]);\n plane.set_model_matrix(model);\n\n plane.set_mvp(model_matrix_plane, view_matrix, proj_matrix);\n plane.draw();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}], "validation": {"glslang_valid": 2, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 1, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "none-found", "non_commercial": false, "comment_density": 0.099, "dedup_hash": "9b7ee98367e2a266", "has_readme": true, "build_system": null, "dependency_count": 4, "has_demo": true} -{"id": "webgl_examples_tree", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Tree", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "lighting/texturing/vegetation/basics/camera", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "tree/cube.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 17, "comment_density": 0.235, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/cube.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 11, "comment_density": 0.0, "code": "precision highp float;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/500.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/cube.js", "language": "javascript", "loc": 197, "comment_density": 0.147, "code": "class Cube{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n mat4.translate(this.model, this.model, [0, 1, 0]);\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.vao = this.gl.createVertexArray();\n\n this.gl.bindVertexArray(this.vao);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //buffer containings the normals\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW)\n\n this.light_pos = [0,0,0];\n }\n\n //sets model view projection matrix\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.useProgram(this.shader_program);\n this.gl.bindVertexArray(this.vao);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n //draw the cube\n this.gl.drawElements(this.gl.TRIANGLES, 36, this.gl.UNSIGNED_SHORT, 0);\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision highp float;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/500.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n // Front face\n -1.0, -1.0, 1.0,\n 1.0, -1.0, 1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0,\n\n // Back face\n -1.0, -1.0, -1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, -1.0, -1.0,\n\n // Top face\n -1.0, 1.0, -1.0,\n -1.0, 1.0, 1.0,\n 1.0, 1.0, 1.0,\n 1.0, 1.0, -1.0,\n\n // Bottom face\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n\n // Right face\n 1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, 1.0,\n\n // Left face\n -1.0, -1.0, -1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, 1.0,\n -1.0, 1.0, -1.0,\n ];\n\n indices = [\n 0, 1, 2, 0, 2, 3, // front\n 4, 5, 6, 4, 6, 7, // back\n 8, 9, 10, 8, 10, 11, // top\n 12, 13, 14, 12, 14, 15, // bottom\n 16, 17, 18, 16, 18, 19, // right\n 20, 21, 22, 20, 22, 23, // left\n ];\n\n normals = [\n // Front face\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n\n // Back face\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n\n // Top face\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n\n // Bottom face\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n\n // Right face\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n\n // Left face\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n ];\n}\n"}, {"path": "tree/leaves.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 44, "comment_density": 0.159, "code": "precision mediump float;\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n attribute vec2 uv;\n attribute mat4 model_mat;\n attribute vec3 raw_position;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n varying float frag_relative_ground_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n uniform vec2 wind_offset;\n\n uniform sampler2D tex_wind;\n\n void main() {\n mat4 global_model = model*model_mat;\n\n vec3 new_pos_tex = vec3(global_model*vertex_pos);\n\n //rotate a bit the leaves according to a wind texture map\n vec2 relative_tex_pos = vec2(new_pos_tex.x/40.0+0.5, new_pos_tex.z/40.0+0.5);\n\n float wind_x = texture2D(tex_wind, (relative_tex_pos+wind_offset) ).r;\n float wind_z = texture2D(tex_wind, (relative_tex_pos+vec2(0.5, 0.5)+wind_offset) ).r;\n\n //rotation around x axis\n mat4 rot_mat_x = mat4(1, 0, 0, 0,\n 0, cos(wind_x), -sin(wind_x), 0,\n 0, sin(wind_x), cos(wind_x), 0,\n 0, 0, 0, 1);\n\n //rotation around z axis\n mat4 rot_mat_z = mat4(cos(wind_z), -sin(wind_z), 0, 0,\n sin(wind_z), cos(wind_x), 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1);\n\n vec4 new_pos = (global_model*rot_mat_x*rot_mat_z*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(global_model)));\n mat3 normal_mat = mat3(global_model);\n\n pixel_pos = vec3(new_pos);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*new_pos;\n\n frag_relative_ground_pos = raw_position.y;\n\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/leaves.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 22, "comment_density": 0.182, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n varying float frag_relative_ground_pos;\n\n uniform vec3 light_pos;\n uniform vec2 wind_offset;\n\n void main() {\n\n float distance_to_middle = distance(frag_uv, vec2(0.5, 0.5));\n\n //have some sort of leaf shape instead of a rough triangle\n if(distance_to_middle > 0.5 ){\n discard;\n }\n\n //have a repeatable random value according to relative position of the leaf to the centre of the batch\n float rand_val = sin(pixel_pos.x*pixel_pos.z/10.0)+cos( (0.13-pixel_pos.x*pixel_pos.y) / 10.0 );\n\n gl_FragColor.a = 1.0;\n\n //if the leaf is under the \"centre\" of the batch, draw it darker (to have a canopy effect)\n float light_intensity = (frag_relative_ground_pos+0.6)*1.5;\n light_intensity = clamp(light_intensity, 0.0, 1.0);\n float reverse_dist_to_middle = 1.0-distance_to_middle;\n\n gl_FragColor.rgb = vec3(0.1+rand_val/6.0, 0.4, 0.05)*light_intensity*reverse_dist_to_middle;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/leaves.js", "language": "javascript", "loc": 284, "comment_density": 0.12, "code": "class Leaves{\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.vao = this.gl.createVertexArray();\n\n this.gl.bindVertexArray(this.vao);\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //buffer containings the normals\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW)\n\n // indices for the texture pos\n this.texcoord_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoord_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.tex_coord), this.gl.STATIC_DRAW)\n\n this.transforms_list = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n //put all the model matrices in a buffer, need the mat4 in a flat structure, a list\n var lst_model_flat = this.mat_vector.map(a=>[...a]).flat();\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(lst_model_flat), this.gl.STATIC_DRAW);\n\n this.rel_pos_list = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.rel_pos_list);\n\n var pos_vec_flat = this.pos_vector.map(a=>[...a]).flat();\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(pos_vec_flat), this.gl.STATIC_DRAW);\n\n this.nb_leaves = this.mat_vector.length;\n this.light_pos = [0, 0, 0];\n\n //generate the wind texture\n var wind_tex_size = 512;\n\n this.generate_wind_texture(wind_tex_size);\n\n this.texture_id = gl.createTexture();\n\n gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, wind_tex_size, wind_tex_size, 0, gl.RGB, gl.UNSIGNED_BYTE, new Uint8Array(this.wind_array_texture));\n\n //mirrored repeat as we will pan over the texture multiple times\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); //do not forget this for float textures\n\n this.wind_offset = [1,1];\n }\n\n generate(end_point_matrices){\n this.mat_vector = []\n this.pos_vector = []\n\n var leaves_scale = 1.0/32.0;\n\n for (let i = 0; i < end_point_matrices.length; i++) {\n var incr = 0.4;\n for (let x = -1.0; x < 1.0; x+=incr) {\n for (let y = -1.0; y < 1.0; y+=incr) {\n for (let z = -1.0; z < 1.0; z+=incr) {\n var dist_to_centre = Math.sqrt(x*x+y*y+z*z);\n if(dist_to_centre < 1.0){\n var t = mat4.create();\n var random_rot = mat4.create();\n //add a bit of randomness to not have a grid of leaves\n mat4.rotate(random_rot, random_rot, Math.random(), [1.0, 0.0, 0.0] );\n mat4.rotate(random_rot, random_rot, Math.random(), [0.0, 1.0, 0.0] );\n mat4.rotate(random_rot, random_rot, Math.random(), [0.0, 0.0, 1.0] );\n\n mat4.multiply(t, t, random_rot);\n mat4.translate(t, t, [x*leaves_scale*4, y*leaves_scale*4, z*leaves_scale*4]);\n mat4.multiply(t, t, random_rot);//rotates again the leaves so they don't have the same orientation\n mat4.scale(t, t, [leaves_scale, leaves_scale, leaves_scale]);\n\n var end_mat = mat4.create();\n mat4.multiply(end_mat, end_point_matrices[i], t);\n this.mat_vector.push(end_mat);\n\n var val = vec4.create();\n val[0] = x;\n val[1] = y;\n val[2] = z;\n val[3] = 1;\n var val_transf = vec4.create();\n vec4.transformMat4(val_transf, val, random_rot);\n var val_transf3 = [val_transf[0], val_transf[1], val_transf[2]];\n this.pos_vector.push(val_transf3);\n }\n }\n }\n }\n\n }\n }\n\n //generate wind texture, which will impact the position of the grass\n //only R component of the texture will be used\n generate_wind_texture(size){\n this.wind_array_texture = [];\n\n for (var i = 0; i < size; i++) {\n for (var j = 0; j < size; j++) {\n var val = Math.sin(i/size*16)*Math.cos(j/size*8);\n this.wind_array_texture.push( val*64+128 ); //R\n this.wind_array_texture.push( 0.0 ); //G useless\n this.wind_array_texture.push( 0.0 ); //B useless\n }\n }\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_time(t){\n var time_delta = t-this.time;\n this.wind_offset[0] = (t*16)%10\n this.wind_offset[1] = (t*8)%10\n this.time = t;\n }\n\n draw(){\n this.gl.bindVertexArray(this.vao);\n this.gl.useProgram(this.shader_program);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.uniform2fv(\n this.gl.getUniformLocation(this.shader_program, \"wind_offset\"),\n this.wind_offset);\n\n var uniform_loc = this.gl.getAttribLocation(this.shader_program, \"model_mat\");\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n this.gl.enableVertexAttribArray(uniform_loc);\n this.gl.vertexAttribPointer(uniform_loc, 4, this.gl.FLOAT, this.gl.FALSE, 64, 0);\n\n this.gl.enableVertexAttribArray(uniform_loc+1);\n this.gl.vertexAttribPointer(uniform_loc+1, 4, this.gl.FLOAT, this.gl.FALSE, 64, 16);\n\n this.gl.enableVertexAttribArray(uniform_loc+2);\n this.gl.vertexAttribPointer(uniform_loc+2, 4, this.gl.FLOAT, this.gl.FALSE, 64, 32);\n\n this.gl.enableVertexAttribArray(uniform_loc+3);\n this.gl.vertexAttribPointer(uniform_loc+3, 4, this.gl.FLOAT, this.gl.FALSE, 64, 48);\n\n this.gl.vertexAttribDivisor(uniform_loc, 1);\n this.gl.vertexAttribDivisor(uniform_loc+1, 1);\n this.gl.vertexAttribDivisor(uniform_loc+2, 1);\n this.gl.vertexAttribDivisor(uniform_loc+3, 1);\n\n var uniform_loc = this.gl.getAttribLocation(this.shader_program, \"raw_position\");\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.rel_pos_list);\n\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"raw_position\"));\n this.gl.vertexAttribPointer(this.gl.getAttribLocation(this.shader_program, \"raw_position\"), 3, this.gl.FLOAT, this.gl.FALSE, 12, 0);\n\n this.gl.vertexAttribDivisor(this.gl.getAttribLocation(this.shader_program, \"raw_position\"), 1);\n\n\n this.gl.activeTexture(gl.TEXTURE0);\n\n this.gl.bindTexture(gl.TEXTURE_2D, this.texture_id);\n\n this.gl.uniform1i(gl.getUniformLocation(this.shader_program, \"tex_wind\"), 0);\n\n this.gl.disable(this.gl.CULL_FACE);\n\n // this.gl.drawElements(this.gl.TRIANGLES, this.nb_indices, this.gl.UNSIGNED_SHORT, 0);\n\n //this.transf.length\n // this.gl.drawElements(this.gl.TRIANGLES, this.nb_indices, this.gl.UNSIGNED_SHORT, 0);\n this.gl.drawElementsInstanced(this.gl.TRIANGLES, 3, this.gl.UNSIGNED_SHORT, 0, this.nb_leaves);\n\n this.gl.enable(this.gl.CULL_FACE);\n\n this.gl.vertexAttribDivisor(uniform_loc, 0);\n }\n\n vertex_shader_code = `\n precision mediump float;\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n attribute vec2 uv;\n attribute mat4 model_mat;\n attribute vec3 raw_position;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n varying float frag_relative_ground_pos;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n uniform vec2 wind_offset;\n\n uniform sampler2D tex_wind;\n\n void main() {\n mat4 global_model = model*model_mat;\n\n vec3 new_pos_tex = vec3(global_model*vertex_pos);\n\n //rotate a bit the leaves according to a wind texture map\n vec2 relative_tex_pos = vec2(new_pos_tex.x/40.0+0.5, new_pos_tex.z/40.0+0.5);\n\n float wind_x = texture2D(tex_wind, (relative_tex_pos+wind_offset) ).r;\n float wind_z = texture2D(tex_wind, (relative_tex_pos+vec2(0.5, 0.5)+wind_offset) ).r;\n\n //rotation around x axis\n mat4 rot_mat_x = mat4(1, 0, 0, 0,\n 0, cos(wind_x), -sin(wind_x), 0,\n 0, sin(wind_x), cos(wind_x), 0,\n 0, 0, 0, 1);\n\n //rotation around z axis\n mat4 rot_mat_z = mat4(cos(wind_z), -sin(wind_z), 0, 0,\n sin(wind_z), cos(wind_x), 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1);\n\n vec4 new_pos = (global_model*rot_mat_x*rot_mat_z*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(global_model)));\n mat3 normal_mat = mat3(global_model);\n\n pixel_pos = vec3(new_pos);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*new_pos;\n\n frag_relative_ground_pos = raw_position.y;\n\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n varying float frag_relative_ground_pos;\n\n uniform vec3 light_pos;\n uniform vec2 wind_offset;\n\n void main() {\n\n float distance_to_middle = distance(frag_uv, vec2(0.5, 0.5));\n\n //have some sort of leaf shape instead of a rough triangle\n if(distance_to_middle > 0.5 ){\n discard;\n }\n\n //have a repeatable random value according to relative position of the leaf to the centre of the batch\n float rand_val = sin(pixel_pos.x*pixel_pos.z/10.0)+cos( (0.13-pixel_pos.x*pixel_pos.y) / 10.0 );\n\n gl_FragColor.a = 1.0;\n\n //if the leaf is under the \"centre\" of the batch, draw it darker (to have a canopy effect)\n float light_intensity = (frag_relative_ground_pos+0.6)*1.5;\n light_intensity = clamp(light_intensity, 0.0, 1.0);\n float reverse_dist_to_middle = 1.0-distance_to_middle;\n\n gl_FragColor.rgb = vec3(0.1+rand_val/6.0, 0.4, 0.05)*light_intensity*reverse_dist_to_middle;\n }\n `;\n\n positions = [\n -1.0, -1.0, 0.0, // 0 bottom left\n 1.0, -1.0, 0.0, // 1 bottom right\n 0.0, 1.0, 0.0, // 2 top\n ];\n\n indices = [\n 0, 1, 2,\n ];\n\n normals = [\n 0, 1, 0,\n 0, 1, 0,\n ];\n\n tex_coord = [\n 0.0, 1.0,\n 1.0, 1.0,\n 0.5, 0.0,\n ];\n}"}, {"path": "tree/main.js", "language": "javascript", "loc": 72, "comment_density": 0.139, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\n\nvar cam_height = 15;\nvar position_cam = [-28.0, cam_height, 0];\n\nvar light_pos = [-10, 5.0, 20];\n\nvar cube = new Cube;\nvar cube_transf = mat4.create();\n\nvar tree = new Tree;\nvar tree_transf = mat4.create();\n\nvar last_time = 0;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl2\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n // plane.setup(gl);\n cube.setup(gl);\n\n tree.setup(gl);\n\n //base platform for the tree\n mat4.scale(cube_transf, cube_transf, [20, 0.5, 20]);\n\n mat4.scale(tree_transf, tree_transf, [5, 5, 5]);\n mat4.translate(tree_transf, tree_transf, [0, 0.5, 0]);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n}\n\nfunction reload_tree(){\n tree = new Tree;\n tree.setup(gl);\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 10, 0], [0, 1, 0]);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n d = new Date();\n time = d.getTime()/100000.0;\n //make it framerate independant\n time_diff = time-last_time;\n\n var rotation_active = document.getElementById(\"rotation\").checked;\n var draw_leaves_active = document.getElementById(\"leaves\").checked;\n\n //rotate the model matrix of the plane by a little bit\n var model = mat4.create();\n if(rotation_active){\n model = mat4.rotate(model, model, -2*Math.PI*time_diff*10, [0,1,0]);\n }\n\n mat4.multiply(tree_transf, tree_transf, model);\n mat4.multiply(cube_transf, cube_transf, model);\n\n cube.set_light_pos(light_pos);\n cube.set_mvp(cube_transf, view_matrix, proj_matrix);\n cube.draw();\n\n //wind effect not that nice, leave it for now\n // tree.set_time(d.getTime()/10000.0);\n tree.set_light_pos(light_pos);\n tree.set_mvp(tree_transf, view_matrix, proj_matrix);\n tree.draw(draw_leaves_active);\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "tree/tree.html", "language": "html", "loc": 21, "comment_density": 0.048, "code": "\n\n\n\n\n\n\n\n
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "tree/tree.js", "language": "javascript", "loc": 33, "comment_density": 0.0, "code": "class Tree{\n setup(gl){\n this.gl = gl;\n\n this.trunk = new Trunk\n this.trunk.setup(gl);\n\n this.leaves = new Leaves;\n\n this.leaves.generate(this.trunk.get_end_point_matrices());\n\n this.leaves.setup(gl);\n }\n\n set_time(t){\n this.leaves.set_time(t);\n }\n\n draw_trunks(){\n this.trunk.draw();\n }\n\n set_mvp(model, view, proj){\n this.trunk.set_mvp(model, view, proj);\n this.leaves.set_mvp(model, view, proj);\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.trunk.set_light_pos(light_pos);\n this.light_pos = light_pos;\n }\n\n draw(draw_leaves_active){\n this.trunk.draw();\n if(draw_leaves_active){\n this.leaves.draw();\n }\n }\n}"}, {"path": "tree/trunk.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 22, "comment_density": 0.182, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n attribute vec2 uv;\n attribute mat4 model_mat;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n mat4 model_global = model*model_mat;\n pixel_pos = vec3(model_global*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model_global);\n\n frag_uv = uv;\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model_global*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/trunk.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 34, "comment_density": 0.059, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n\n uniform vec3 light_pos;\n\n vec3 bark_high = vec3(0.6, 0.4, 0.2);\n vec3 bark_low = vec3(0.4, 0.25, 0.2);\n\n vec3 get_billin(vec2 pos, vec3 min, vec3 max);\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float diffuse_light = dot(light_dir, pixel_normal);\n\n vec3 texture_col = get_billin(frag_uv*4.0, bark_low, bark_high);\n\n vec3 color_trunk = texture_col*diffuse_light;\n\n gl_FragColor = vec4( color_trunk , 1.0);;\n }\n\n float rand(vec2 pt)\n {\n float x = pt.x*3.13;\n float y = pt.y*7.17;\n return fract(x*y/17.0);\n }\n\n vec3 get_billin(vec2 pos, vec3 min, vec3 max)\n {\n\n float val00 = rand((pos));\n float val10 = rand((vec2(pos.x, pos.y+1.0)));\n float val01 = rand((vec2(pos.x+1.0, pos.y)));\n float val11 = rand((vec2(pos.x+1.0, pos.y+1.0)));\n\n vec2 pos_fract = fract(pos);\n\n //2d linear interpolation\n float val_x0 = mix(val00, val01, pos_fract.x);\n float val_x1 = mix(val10, val11, pos_fract.x);\n\n float final_val = mix(val_x0, val_x1, pos_fract.y);\n\n return mix(max, min, final_val);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "tree/trunk.js", "language": "javascript", "loc": 349, "comment_density": 0.112, "code": "class Trunk{\n setup(gl){\n this.gl = gl;\n\n this.create_positions();\n\n this.transf = [];\n\n this.rand_vals = [];\n this.end_point_matrices = [];\n\n //have fixed random values for each iteration of the trunks\n for (let i = 0; i < 32; i++) {\n this.rand_vals.push( Math.random());\n }\n\n //first trunk (axiom or root of the lsystem)\n var trunk_initial_transf = mat4.create();\n mat4.translate(trunk_initial_transf, trunk_initial_transf, [0, 0.5, 0]);\n mat4.scale(trunk_initial_transf, trunk_initial_transf, [1.5/14, 1, 1.5/14]);\n\n this.add_sub_trunks_lsystem_random(trunk_initial_transf, 0, 5, true);\n\n this.model = mat4.create();\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.vao = this.gl.createVertexArray();\n\n this.gl.bindVertexArray(this.vao);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //buffer containings the normals\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW)\n\n //indices for the texture pos\n this.texcoord_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoord_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.tex_coord), this.gl.STATIC_DRAW)\n\n //this.transf\n this.transforms_list = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n //put all the model matrices in a buffer, need the mat4 in a flat structure, a list\n var lst_model_flat = this.transf.map(a=>[...a]).flat();\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(lst_model_flat), this.gl.STATIC_DRAW);\n\n this.nb_trunks = this.transf.length;\n this.light_pos = [0, 0, 0];\n }\n\n get_end_point_matrices(){\n return this.end_point_matrices;\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n draw(){\n this.gl.bindVertexArray(this.vao);\n this.gl.useProgram(this.shader_program);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n var uniform_loc = this.gl.getAttribLocation(this.shader_program, \"model_mat\");\n\n const ext = this.gl.getExtension(\"ANGLE_instanced_arrays\");\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.transforms_list);\n\n this.gl.enableVertexAttribArray(uniform_loc);\n this.gl.vertexAttribPointer(uniform_loc, 4, this.gl.FLOAT, this.gl.FALSE, 64, 0);\n\n this.gl.enableVertexAttribArray(uniform_loc+1);\n this.gl.vertexAttribPointer(uniform_loc+1, 4, this.gl.FLOAT, this.gl.FALSE, 64, 16);\n\n this.gl.enableVertexAttribArray(uniform_loc+2);\n this.gl.vertexAttribPointer(uniform_loc+2, 4, this.gl.FLOAT, this.gl.FALSE, 64, 32);\n\n this.gl.enableVertexAttribArray(uniform_loc+3);\n this.gl.vertexAttribPointer(uniform_loc+3, 4, this.gl.FLOAT, this.gl.FALSE, 64, 48);\n\n this.gl.vertexAttribDivisor(uniform_loc, 1);\n this.gl.vertexAttribDivisor(uniform_loc+1, 1);\n this.gl.vertexAttribDivisor(uniform_loc+2, 1);\n this.gl.vertexAttribDivisor(uniform_loc+3, 1);\n\n this.gl.drawElementsInstanced(this.gl.TRIANGLES, this.nb_indices, this.gl.UNSIGNED_SHORT, 0, this.nb_trunks);\n // gl.drawElementsInstancedANGLE(this.gl.TRIANGLES, this.nb_indices, this.gl.UNSIGNED_SHORT, 0, this.nb_trunksindices, this.nb_trunks);\n\n this.gl.vertexAttribDivisor(uniform_loc, 0);\n this.gl.useProgram(null);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n attribute vec2 uv;\n attribute mat4 model_mat;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n mat4 model_global = model*model_mat;\n pixel_pos = vec3(model_global*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model_global);\n\n frag_uv = uv;\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model_global*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n varying vec2 frag_uv;\n\n uniform vec3 light_pos;\n\n vec3 bark_high = vec3(0.6, 0.4, 0.2);\n vec3 bark_low = vec3(0.4, 0.25, 0.2);\n\n vec3 get_billin(vec2 pos, vec3 min, vec3 max);\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float diffuse_light = dot(light_dir, pixel_normal);\n\n vec3 texture_col = get_billin(frag_uv*4.0, bark_low, bark_high);\n\n vec3 color_trunk = texture_col*diffuse_light;\n\n gl_FragColor = vec4( color_trunk , 1.0);;\n }\n\n float rand(vec2 pt)\n {\n float x = pt.x*3.13;\n float y = pt.y*7.17;\n return fract(x*y/17.0);\n }\n\n vec3 get_billin(vec2 pos, vec3 min, vec3 max)\n {\n\n float val00 = rand((pos));\n float val10 = rand((vec2(pos.x, pos.y+1.0)));\n float val01 = rand((vec2(pos.x+1.0, pos.y)));\n float val11 = rand((vec2(pos.x+1.0, pos.y+1.0)));\n\n vec2 pos_fract = fract(pos);\n\n //2d linear interpolation\n float val_x0 = mix(val00, val01, pos_fract.x);\n float val_x1 = mix(val10, val11, pos_fract.x);\n\n float final_val = mix(val_x0, val_x1, pos_fract.y);\n\n return mix(max, min, final_val);\n }\n `;\n\n lerp(val, min, max){\n return (1-val)*min+val*max;\n }\n\n //recursive function for generating a l-system tree structure\n add_sub_trunks_lsystem_random(t, level, max_level, is_end_point){\n\n //if this trunk section is the last one, generate the matrix and end point for this bit\n //and add them in a list\n if(level >= max_level){\n //model matrix for the trunk model\n this.transf.push(t);\n\n //model matrix for the leaves\n if(is_end_point){\n var point = vec4.create();\n point[0] = 0;\n point[1] = 0.5;\n point[2] = 0;\n point[3] = 1.0;\n vec4.transformMat4(point, point, t);\n var end_point_translation = mat4.create();\n mat4.translate(end_point_translation, end_point_translation, [point[0], point[1], point[2]]);\n\n this.end_point_matrices.push(end_point_translation);\n }\n return;\n }\n\n //base trunk\n var t0 = mat4.create();\n mat4.translate(t0, t0, [0, 0, 0]);\n mat4.scale(t0, t0, [1, 1, 1]);\n mat4.multiply(t0, t0, t);\n this.add_sub_trunks_lsystem_random(t0, level+1000, max_level, false);\n\n //top trunk\n var t1 = mat4.create();\n mat4.translate(t1, t1, [0, 0.98, 0]);\n mat4.rotate(t1, t1, this.lerp(this.rand_vals[2], 0, 2*3.1415), [0.0, 1.0, 0.0])\n mat4.rotate(t1, t1, this.lerp(this.rand_vals[0], 3.1415/14.0, 3.1415/10.0), [0.0, 0.0, 1.0])\n mat4.rotate(t1, t1, this.lerp(this.rand_vals[1], 3.1415/14.0, 3.1415/10.0), [1.0, 0.0, 0.0])\n mat4.scale(t1, t1, [0.8, 0.8, 0.8]);\n mat4.multiply(t1, t1, t);\n this.add_sub_trunks_lsystem_random(t1, level+1, max_level, true);\n\n //side trunks / twigs\n var b0 = mat4.create();\n mat4.translate(b0, b0, [0, this.lerp(this.rand_vals[16], 0.5, 0.9), 0] );\n mat4.rotate(b0, b0, this.lerp(this.rand_vals[8], 0, 2*3.1415), [0.0, 1.0, 0.0])\n mat4.rotate(b0, b0, this.lerp(this.rand_vals[6], 3.1415/4.0, 3.1415/10.0), [0.0, 0.0, 1.0])\n mat4.rotate(b0, b0, this.lerp(this.rand_vals[7], 3.1415/4.0, 3.1415/10.0), [1.0, 0.0, 0.0])\n mat4.scale(b0, b0, [0.6, 0.6, 0.6]);\n mat4.multiply(b0, b0, t);\n this.add_sub_trunks_lsystem_random(b0, level+1, max_level, true);\n\n var b1 = mat4.create();\n mat4.translate(b1, b1, [0, this.lerp(this.rand_vals[17], 0.5, 0.9), 0] );\n mat4.rotate(b1, b1, this.lerp(this.rand_vals[11], 0, 2*3.1415), [0.0, 1.0, 0.0])\n mat4.rotate(b1, b1, this.lerp(this.rand_vals[9], 3.1415/3.0, 3.1415/10.0), [0.0, 0.0, 1.0])\n mat4.rotate(b1, b1, this.lerp(this.rand_vals[10], 3.1415/3.0, 3.1415/10.0), [1.0, 0.0, 0.0])\n mat4.scale(b1, b1, [0.5, 0.5, 0.5]);\n mat4.multiply(b1, b1, t);\n this.add_sub_trunks_lsystem_random(b1, level+1, max_level, true);\n\n var b2 = mat4.create();\n mat4.translate(b2, b2, [0, this.lerp(this.rand_vals[18], 0.5, 0.9), 0] );\n mat4.rotate(b2, b2, this.lerp(this.rand_vals[14], 0, 2*3.1415), [0.0, 1.0, 0.0])\n mat4.rotate(b2, b2, this.lerp(this.rand_vals[12], 3.1415/2.0, 3.1415/10.0), [0.0, 0.0, 1.0])\n mat4.rotate(b2, b2, this.lerp(this.rand_vals[13], 3.1415/2.0, 3.1415/10.0), [1.0, 0.0, 0.0])\n mat4.scale(b2, b2, [0.4, 0.4, 0.4]);\n mat4.multiply(b2, b2, t);\n this.add_sub_trunks_lsystem_random(b2, level+1, max_level, true);\n }\n\n //create vertices, normals, indices for a cylinder that would represent a trunk section\n create_positions(){\n var nb_vertices = 6;\n\n this.positions = [];\n\n this.positions.push(0);\n this.positions.push(-1.0/2.0);\n this.positions.push(0);\n this.positions.push(0);\n this.positions.push(1.0/2.0);\n this.positions.push(0);\n\n //to make base of trunk slightly larger\n var bigger_base = 1.1;\n\n for (let i = 0; i < nb_vertices; i++) {\n var angle_val = 3.1415*2.0*(1.0/nb_vertices)*i;\n this.positions.push((Math.sin(angle_val)/2.0)*bigger_base);\n this.positions.push(-1.0/2.0);\n this.positions.push((Math.cos(angle_val)/2.0)*bigger_base);\n this.positions.push((Math.sin(angle_val)/2.0)*(1.0/bigger_base));\n this.positions.push(1.0/2.0);\n this.positions.push((Math.cos(angle_val)/2.0)*(1.0/bigger_base));\n }\n\n\n this.nb_indices = 3*nb_vertices*2+3*nb_vertices*2;\n this.indices = [];\n for (let i = 0; i < nb_vertices; i++) {\n var start_idx_face = 2+2*i; // 12 points per face\n var up_left = start_idx_face+1; //may be another one\n var up_right = start_idx_face+3;\n if(up_right >= 2+2*nb_vertices){\n up_right = 2+1;\n }\n var down_left = start_idx_face+0;\n var down_right = start_idx_face+2;\n if(down_right >= 2+2*nb_vertices){\n down_right = 2;\n }\n\n //top\n this.indices.push(1);\n this.indices.push(up_left);\n this.indices.push(up_right);\n //side\n this.indices.push( up_left);\n this.indices.push(down_left);\n this.indices.push(down_right);\n\n this.indices.push(up_right);\n this.indices.push( up_left);\n this.indices.push(down_right);\n\n //bottom\n this.indices.push( 0);\n this.indices.push(down_right);\n this.indices.push(down_left);\n }\n\n //per vertex textcoord\n this.tex_coord = [];\n\n this.tex_coord.push(1);\n this.tex_coord.push(1);\n this.tex_coord.push(0);\n this.tex_coord.push(0);\n\n for (let i = 0; i < nb_vertices; i++) {\n // i: 0 -> 0.5 == 0 -> 1\n // i: 0.5 -> 1.0 == 1 -> 0\n var relative_pos = i/nb_vertices;\n\n if ( relative_pos < 0.5){\n relative_pos = relative_pos*2;\n }\n else{ //relative_pos > 0.5f (0.5=1, 1.0=0)\n relative_pos = relative_pos*(-2)+2;\n }\n\n this.tex_coord.push(relative_pos); //bottom\n this.tex_coord.push(1.0);\n\n this.tex_coord.push(relative_pos); //top\n this.tex_coord.push(0.0);\n }\n\n //per vertex normal\n\n this.normals = []\n\n this.normals.push(0.0);\n this.normals.push(-1.0);\n this.normals.push(0.0);\n\n this.normals.push(0.0);\n this.normals.push(1.0);\n this.normals.push(0.0);\n\n for (let i = 0; i < nb_vertices; i++) {\n var angle_val = 3.1415*2.0*(1.0/nb_vertices)*i;\n this.normals.push(Math.sin(angle_val));\n this.normals.push(0.0);\n this.normals.push(Math.cos(angle_val));\n\n this.normals.push(Math.sin(angle_val));\n this.normals.push(0.0);\n this.normals.push(Math.cos(angle_val));\n }\n }\n}"}], "validation": {"glslang_valid": 6, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 1, "has_compute_barriers": false, "has_instancing": false}, "preview_image": "images/webgl_examples_tree.png", "license": "none-found", "non_commercial": false, "comment_density": 0.115, "dedup_hash": "4deb9b0cb20007af", "has_readme": true, "build_system": null, "dependency_count": 7, "has_demo": true} -{"id": "webgl_examples_triangle", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Triangle", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "basics", "difficulty": "beginner", "source_quality": "educational", "files": [{"path": "triangle/triangle.html", "language": "html", "loc": 11, "comment_density": 0.0, "code": "\n\n\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n"}, {"path": "triangle/triangle.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 7, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n void main() {\n frag_colour = colour;\n gl_Position = vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "triangle/triangle.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 5, "comment_density": 0.2, "code": "precision mediump float; //this is necessary in webgl glsl\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "triangle/triangle.js", "language": "javascript", "loc": 93, "comment_density": 0.14, "code": "var canvas;\nvar gl;\n\nvar shader_program;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\")\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"Cannot init WebGL\");\n return;\n }\n\n init_triangle();\n}\n\n//init the shaders and the buffers\nfunction init_triangle(){\n vertex_shader_glsl = `\n attribute vec4 vertex_pos;\n attribute vec3 colour;\n\n varying vec3 frag_colour;\n void main() {\n frag_colour = colour;\n gl_Position = vertex_pos;\n }\n `;\n\n fragment_shader_glsl = `\n precision mediump float; //this is necessary in webgl glsl\n varying vec3 frag_colour;\n\n void main() {\n gl_FragColor = vec4(frag_colour, 1.0);\n }\n `;\n\n const vertex_shader = loadShader(gl, gl.VERTEX_SHADER, vertex_shader_glsl);\n const fragment_shader = loadShader(gl, gl.FRAGMENT_SHADER, fragment_shader_glsl);\n\n shader_program = gl.createProgram();\n gl.attachShader(shader_program, vertex_shader);\n gl.attachShader(shader_program, fragment_shader);\n gl.linkProgram(shader_program);\n\n if (!gl.getProgramParameter(shader_program, gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + gl.getProgramInfoLog(shader_program));\n return null;\n }\n\n //create buffers and populate them for the triangle\n\n pos_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, pos_buffer);\n //position for each vertex of the triangle\n var triangle_points = new Float32Array([\n -1.0, -1.0, 0.0,\n 1.0, -1.0, 0.0,\n 0.0, 1.0, 0.0]);\n gl.bufferData(gl.ARRAY_BUFFER, triangle_points, gl.STATIC_DRAW);\n\n col_buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, col_buffer);\n //the colours for each points in RGB\n var triangle_colours = new Float32Array([\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0]);\n gl.bufferData(gl.ARRAY_BUFFER, triangle_colours, gl.STATIC_DRAW);\n}\n\nfunction draw(){\n\n gl.clearColor(0.0, 0.0, 0.2, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n gl.useProgram(shader_program);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, pos_buffer);\n gl.vertexAttribPointer(\n gl.getAttribLocation(shader_program, \"vertex_pos\"), //the name of the attribute\n 3, //how many data per vertex point\n gl.FLOAT, //type\n true, //normalize, no effect for float\n 0, //stride\n 0); //offset\n\n gl.enableVertexAttribArray(gl.getAttribLocation(shader_program, \"vertex_pos\"));\n\n gl.bindBuffer(gl.ARRAY_BUFFER, col_buffer);\n gl.vertexAttribPointer(\n gl.getAttribLocation(shader_program, \"colour\"),\n 3,\n gl.FLOAT,\n true,\n 0,\n 0);\n\n gl.enableVertexAttribArray(gl.getAttribLocation(shader_program, \"colour\"));\n\n //will draw 3 points\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}], "validation": {"glslang_valid": 2, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "none-found", "non_commercial": false, "comment_density": 0.085, "dedup_hash": "ff1d839d47d87d6d", "has_readme": true, "build_system": null, "dependency_count": 2, "has_demo": true} -{"id": "webgl_examples_water", "source": "https://github.com/local/webgl_examples", "source_commit": "b2c0c5339a94083480a77fcc75a5578639918805", "collected_at": "2026-08-17T14:37:32+00:00", "source_type": "repo", "title": "Water", "api": "OpenGL/WebGL", "glsl_version": null, "topic": "water/lighting/texturing/framebuffer/basics", "difficulty": "intermediate", "source_quality": "educational", "files": [{"path": "water/cube.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 17, "comment_density": 0.235, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/cube.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 17, "comment_density": 0.118, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n uniform int active_clip;\n uniform float clip_height;\n\n void main() {\n\n //do not draw anything under the clip height\n if(active_clip != 0 && pixel_pos.y < clip_height){\n discard;\n }\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/500.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/cube.js", "language": "javascript", "loc": 208, "comment_density": 0.149, "code": "class Cube{\n\n setup(gl){\n this.gl = gl;\n\n this.model = mat4.create();\n mat4.translate(this.model, this.model, [0, 1, 0]);\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n //create shader\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n //buffer for the vertices pos of the cube\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n //buffer containings the normals\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n //indices for the vertices\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW)\n\n this.light_pos = [0,0,0];\n\n this.active_clip = 0;\n this.clip_height = 0;\n }\n\n //sets model view projection matrix\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n set_clip(active_clip, clip_height){\n this.active_clip = active_clip;\n this.clip_height = clip_height;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n this.gl.uniform1i(this.gl.getUniformLocation(this.shader_program, \"active_clip\"), this.active_clip);\n this.gl.uniform1f(this.gl.getUniformLocation(this.shader_program, \"clip_height\"), this.clip_height);\n\n //send the matrices to the shader via the uniformMatrix\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n //draw the cube\n this.gl.drawElements(this.gl.TRIANGLES, 36, this.gl.UNSIGNED_SHORT, 0);\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n\n //normally the model matrix for normals should be different to keep orientation of normals\n //but it is a pain in webgl as we dont seem to have the inverse and transpose, so i don't do it\n // mat3 normal_mat = mat3(transpose(inverse(model)));\n mat3 normal_mat = mat3(model);\n\n //also transform the normals according to the model matrix\n pixel_normal = normalize(normal_mat*normal);\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n uniform int active_clip;\n uniform float clip_height;\n\n void main() {\n\n //do not draw anything under the clip height\n if(active_clip != 0 && pixel_pos.y < clip_height){\n discard;\n }\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/500.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n // Front face\n -1.0, -1.0, 1.0,\n 1.0, -1.0, 1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0,\n\n // Back face\n -1.0, -1.0, -1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, -1.0, -1.0,\n\n // Top face\n -1.0, 1.0, -1.0,\n -1.0, 1.0, 1.0,\n 1.0, 1.0, 1.0,\n 1.0, 1.0, -1.0,\n\n // Bottom face\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n\n // Right face\n 1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, 1.0,\n\n // Left face\n -1.0, -1.0, -1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, 1.0,\n -1.0, 1.0, -1.0,\n ];\n\n indices = [\n 0, 1, 2, 0, 2, 3, // front\n 4, 5, 6, 4, 6, 7, // back\n 8, 9, 10, 8, 10, 11, // top\n 12, 13, 14, 12, 14, 15, // bottom\n 16, 17, 18, 16, 18, 19, // right\n 20, 21, 22, 20, 22, 23, // left\n ];\n\n normals = [\n // Front face\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n 0.0, 0.0, 1.0,\n\n // Back face\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n 0.0, 0.0, -1.0,\n\n // Top face\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n\n // Bottom face\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n 0.0, -1.0, 0.0,\n\n // Right face\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n 1.0, 0.0, 0.0,\n\n // Left face\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n -1.0, 0.0, 0.0,\n ];\n}\n"}, {"path": "water/framebuffer.js", "language": "javascript", "loc": 38, "comment_density": 0.158, "code": "class Framebuffer{\n\n setup(gl, image_width, image_height) {\n this.gl = gl;\n\n this.image_width = image_width;\n this.image_height = image_height;\n\n this.fb_tex = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, this.fb_tex);\n\n //allocate space for the texture, but feed nothing to it (null)\n //will be filled later by rendering in the framebuffer\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.image_width, this.image_height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\n this.fb = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb);\n\n //key part, we associate the texture with the framebuffer\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.fb_tex, 0);\n\n //create a depth buffer for the framebuffer, otherwise 3d rendering will be weird\n this.depth_buffer = gl.createRenderbuffer();\n gl.bindRenderbuffer(gl.RENDERBUFFER, this.depth_buffer);\n\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.image_width, this.image_height);\n\n //associate the render buffer with the framebuffer\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.depth_buffer);\n\n //unbind everything to avoid pollution\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n\n bind(){\n this.gl.viewport(0, 0, this.image_width, this.image_height);\n this.gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb);\n }\n\n unbind(){\n this.gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n\n get_texture(){\n return this.fb_tex;\n }\n\n}"}, {"path": "water/main.js", "language": "javascript", "loc": 162, "comment_density": 0.099, "code": "var canvas;\n// Initialize the GL context\nvar gl;\n\nvar shaderProgram;\nvar indexBuffer;\nvar pos_buffer;\nvar col_buffer;\n\nvar proj_matrix = mat4.create();\nvar view_matrix = mat4.create();\nvar view_matrix_reflection = mat4.create();\n\nvar cam_height = 10;\nvar cam_radius = 20;\nvar position_cam = [cam_radius, cam_height, 0.0];\n\nvar water = new Water;\nvar water_transf = mat4.create();\n\nvar cubes_base = [new Cube, new Cube, new Cube, new Cube, new Cube];\nvar model_matrix_cubes_base = [mat4.create(), mat4.create(), mat4.create(), mat4.create(), mat4.create()];\n\nvar cubes_decoration = [new Cube, new Cube];\nvar model_matrix_cubes_decoration = [mat4.create(), mat4.create()]\n\nvar light_pos_radius = 15;\nvar light_pos = [-1, 5.0, 0];\n\nvar framebuffer_reflection = new Framebuffer;\nvar framebuffer_refraction = new Framebuffer;\n\nvar canvas_width = 1600;\nvar canvas_height = 900;\n\nvar last_time = 0;\n\n//needed for reflection matrix calculation\nvar water_height = 2;\n\nfunction main() {\n canvas = document.querySelector(\"#glCanvas\");\n gl = canvas.getContext(\"webgl\");\n // Only continue if WebGL is available and working\n if (gl === null) {\n alert(\"cannot init WebGL\");\n return;\n }\n\n canvas_width = gl.canvas.width;\n canvas_height = gl.canvas.height;\n\n\n framebuffer_reflection.setup(gl, canvas_width, canvas_height);\n framebuffer_refraction.setup(gl, canvas_width, canvas_height);\n\n water.setup(gl);\n\n water.set_reflection_texture(framebuffer_reflection.get_texture());;\n water.set_refraction_texture(framebuffer_refraction.get_texture());;\n\n mat4.translate(model_matrix_cubes_base[0], model_matrix_cubes_base[0], [15, 0, 0]);\n mat4.scale(model_matrix_cubes_base[0], model_matrix_cubes_base[0], [5, 2.5, 20]);\n\n mat4.translate(model_matrix_cubes_base[1], model_matrix_cubes_base[1], [-5, 0, -15]);\n mat4.scale(model_matrix_cubes_base[1], model_matrix_cubes_base[1], [15, 2.5, 5]);\n\n mat4.translate(model_matrix_cubes_base[2], model_matrix_cubes_base[2], [-5, 0, 15]);\n mat4.scale(model_matrix_cubes_base[2], model_matrix_cubes_base[2], [15, 2.5, 5]);\n\n mat4.translate(model_matrix_cubes_base[3], model_matrix_cubes_base[3], [-15, 0, 0]);\n mat4.scale(model_matrix_cubes_base[3], model_matrix_cubes_base[3], [5, 2.5, 10]);\n\n mat4.translate(model_matrix_cubes_base[4], model_matrix_cubes_base[4], [0, -2.5, 0]);\n mat4.scale(model_matrix_cubes_base[4], model_matrix_cubes_base[4], [20, 0.5, 20]);\n\n for (let i = 0; i < cubes_base.length; i++) {\n cubes_base[i].setup(gl);\n cubes_base[i].set_model_matrix(model_matrix_cubes_base[i]);\n }\n\n mat4.translate(model_matrix_cubes_decoration[0], model_matrix_cubes_decoration[0], [0, 0, -4]);\n mat4.scale(model_matrix_cubes_decoration[0], model_matrix_cubes_decoration[0], [2.5, 2.5, 2.5]);\n\n mat4.translate(model_matrix_cubes_decoration[1], model_matrix_cubes_decoration[1], [-15, 5, 4]);\n mat4.scale(model_matrix_cubes_decoration[1], model_matrix_cubes_decoration[1], [2.5, 2.5, 2.5]);\n\n for (let i = 0; i < cubes_decoration.length; i++) {\n cubes_decoration[i].setup(gl);\n cubes_decoration[i].set_model_matrix(model_matrix_cubes_decoration[i]);\n }\n\n\n mat4.translate(water_transf, water_transf, [0, water_height, 0]);\n mat4.scale(water_transf, water_transf, [20, 20, 20]);\n\n water.set_model_matrix(water_transf);\n\n //setup camera\n const fieldOfView = 45 * Math.PI / 180; // in radians\n const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;\n const zNear = 0.1;\n const zFar = 1000.0;\n\n mat4.perspective(proj_matrix, fieldOfView, aspect, zNear, zFar);\n}\n\nfunction draw(){\n\n mat4.lookAt(view_matrix, position_cam, [0, 0, 0], [0, 1, 0]);\n\n var pos_cam_from_underneath = [...position_cam]; //clone array\n pos_cam_from_underneath[1] = -position_cam[1]+water_height*2;\n mat4.lookAt(view_matrix_reflection, pos_cam_from_underneath, [0, water_height*2, 0], [0, 1, 0]);\n\n this.gl.viewport(0, 0, canvas_width, canvas_height);\n\n gl.clearColor(0.5, 0.7, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.enable(gl.DEPTH_TEST);\n gl.depthFunc(gl.LEQUAL);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\n d = new Date();\n time = d.getTime()/100000.0;\n\n //so that first time we do the loop, time_diff does not contain crazy value\n if(last_time == 0){\n last_time = time;\n }\n\n //make it framerate independant\n time_diff = time-last_time;\n\n var light_speed = document.getElementById(\"slider_speed\").value;\n var light_height = document.getElementById(\"slider_height\").value;\n var cam_height = document.getElementById(\"cam_height\").value;\n var cam_rotation = -document.getElementById(\"cam_rotation\").value;\n\n //apply a rotation matrix on the light pos to make it rotate around the origin\n light_pos[0] = light_pos[0]*Math.cos(time_diff*light_speed)-light_pos[2]*Math.sin(time_diff*light_speed);\n light_pos[1] = 11.0-light_height;\n light_pos[2] = light_pos[0]*Math.sin(time_diff*light_speed)+light_pos[2]*Math.cos(time_diff*light_speed);\n\n //renormalize the rotating bit of the light position, to not lose precision\n var vec_rot_length = light_pos[0]*light_pos[0]+light_pos[2]*light_pos[2];\n light_pos[0] = light_pos[0]/vec_rot_length;\n light_pos[2] = light_pos[2]/vec_rot_length;\n\n var light_pos_scaled = [light_pos[0]*light_pos_radius, light_pos[1], light_pos[2]*light_pos_radius];\n\n position_cam[0] = cam_radius*Math.cos(cam_rotation/10);\n position_cam[1] = cam_height;\n position_cam[2] = cam_radius*Math.sin(cam_rotation/10);\n\n for (let i = 0; i < cubes_base.length; i++) {\n cubes_base[i].set_light_pos(light_pos_scaled);\n cubes_base[i].set_vp(view_matrix, proj_matrix);\n cubes_base[i].draw();\n }\n\n for (let i = 0; i < cubes_decoration.length; i++) {\n cubes_decoration[i].set_light_pos(light_pos_scaled);\n cubes_decoration[i].set_vp(view_matrix, proj_matrix);\n cubes_decoration[i].draw();\n }\n\n water.set_time( (d.getTime()/500.0)%1000);\n water.set_vp(view_matrix, proj_matrix);\n water.set_light_pos(light_pos_scaled); //for specularity on the water\n water.set_camera_pos(position_cam); //for specularity on the water\n water.draw();\n\n //refraction step is just drawing the normal shapes again, but in a framebuffer\n framebuffer_refraction.bind();\n\n gl.clearColor(0.7, 0.8, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\n //we need to clip everything underwater when rendering the reflection framebuffer\n for (let i = 0; i < cubes_base.length; i++) {\n cubes_base[i].draw();\n }\n\n for (let i = 0; i < cubes_decoration.length; i++) {\n cubes_decoration[i].draw();\n }\n\n framebuffer_refraction.unbind();\n\n //for reflection step we draw every thing from underneath\n framebuffer_reflection.bind();\n\n gl.clearColor(0.7, 0.8, 0.9, 1.0);\n gl.clearDepth(1.0);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\n //we need to clip everything underwater when rendering the reflection framebuffer\n for (let i = 0; i < cubes_base.length; i++) {\n cubes_base[i].set_clip(1, water_height);\n cubes_base[i].set_vp(view_matrix_reflection, proj_matrix);\n cubes_base[i].draw();\n cubes_base[i].set_clip(0, 0);\n }\n\n for (let i = 0; i < cubes_decoration.length; i++) {\n cubes_decoration[i].set_clip(1, water_height);\n cubes_decoration[i].set_vp(view_matrix_reflection, proj_matrix);\n cubes_decoration[i].draw();\n cubes_decoration[i].set_clip(0, 0);\n }\n\n framebuffer_reflection.unbind();\n\n last_time = time;\n\n requestAnimationFrame(draw);\n}\n\nmain();\nrequestAnimationFrame(draw);\n"}, {"path": "water/plane.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 12, "comment_density": 0.0, "code": "attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/plane.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 11, "comment_density": 0.091, "code": "precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/plane.js", "language": "javascript", "loc": 118, "comment_density": 0.008, "code": "class Plane{\n\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n draw(){\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.useProgram(this.shader_program);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n }\n `;\n\n fragment_shader_code = `\n precision mediump float; //necessary in webgl glsl, medium precision for performance?\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 light_pos;\n\n void main() {\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float angle_light = dot(light_dir, pixel_normal);\n float dist_light = distance(pixel_pos, light_pos);\n\n float light_amount = angle_light-dist_light/50.0;\n\n gl_FragColor = vec4(1.0*light_amount, 1.0*light_amount, 1.0*light_amount, 1.0);\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n normals = [\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n ];\n}\n"}, {"path": "water/water.html", "language": "html", "loc": 20, "comment_density": 0.0, "code": "\n\n\n\nLight Speed: \nLight Height: \nCam Height: \nCam Rotation:
\n\n\nYour browser does not support the canvas element.\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"path": "water/water.js#[inline_1_vertex]", "language": "glsl", "stage": "vertex", "loc": 16, "comment_density": 0.062, "code": "precision highp float; //high precision needed in mobile for light to display correctly\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/water.js#[inline_2_fragment]", "language": "glsl", "stage": "fragment", "loc": 52, "comment_density": 0.115, "code": "precision highp float; //high precision needed in mobile for light to display correctly\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 camera_pos;\n uniform vec3 light_pos;\n\n varying vec2 frag_uv;\n\n uniform sampler2D texture_reflection;\n uniform sampler2D texture_refraction;\n\n uniform mat4 view;\n uniform mat4 proj;\n\n uniform float time;\n\n float get_wave_1(float x, float y){\n float wave = 0.01*sin( dot(normalize(vec2(1,0)), vec2(x, y)) *128.0+time);\n wave += 0.01*sin( dot(normalize(vec2(15,1)), vec2(x, y)) *128.0+time);\n wave += 0.01*sin( dot(normalize(vec2(10,-1)), vec2(x, y)) *256.0+time*1.5);\n wave += 0.01*sin( dot(normalize(vec2(3,1)), vec2(x, y)) *256.0+time*1.5);\n wave += 0.02*sin( dot(normalize(vec2(6,-1)), vec2(x, y)) *64.0+time*0.8);\n wave += 0.015*sin( dot(normalize(vec2(8,1)), vec2(x, y)) *128.0+time*0.7);\n return wave/24.0;\n }\n\n void main() {\n\n float wave = get_wave_1(frag_uv.x, frag_uv.y);\n\n //interestingly the normal_wave would not be calculated correctly on mobile\n //if the float precision was only medium\n vec3 pos_before_x = vec3(frag_uv.x-0.001, get_wave_1(frag_uv.x-0.001, frag_uv.y), frag_uv.y);\n vec3 pos_after_x = vec3(frag_uv.x+0.001, get_wave_1(frag_uv.x+0.001, frag_uv.y), frag_uv.y);\n vec3 pos_before_y = vec3(frag_uv.x, get_wave_1(frag_uv.x, frag_uv.y-0.001), frag_uv.y-0.001);\n vec3 pos_after_y = vec3(frag_uv.x, get_wave_1(frag_uv.x, frag_uv.y+0.001), frag_uv.y+0.001);\n\n //get normal of wave, for lighting purpose\n vec3 normal_wave = normalize(cross( pos_after_x-pos_before_x, pos_after_y-pos_before_y));\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float diffuse_light = 0.0;\n\n diffuse_light = dot(normal_wave, light_dir);\n float light_dist = length(light_pos-pixel_pos);\n diffuse_light /= (1.0+pow(light_dist, -0.5));\n\n //reflexion of light for specular light calculation, not the image reflexion\n vec3 reflexion = 2.0*normal_wave*dot(normal_wave, light_dir)-light_dir;\n reflexion = normalize(reflexion);\n vec3 view_dir = normalize(camera_pos-pixel_pos);\n\n float spec_light = pow(max(dot(reflexion, view_dir), 0.0), 256.0);\n spec_light = clamp(spec_light, 0.0, 1.0);\n\n float lum = 0.5*diffuse_light+spec_light;\n\n vec4 screen_pos = proj*view*vec4(pixel_pos, 1.0);\n vec2 corr_screen_pos_refraction = screen_pos.xy*0.5/screen_pos.w+vec2(0.5, 0.5);\n vec2 corr_screen_pos_reflection = vec2(corr_screen_pos_refraction.x, 1.0-corr_screen_pos_refraction.y); //must invert y\n\n corr_screen_pos_refraction += vec2(wave, wave);\n corr_screen_pos_reflection += vec2(wave, wave);\n\n vec3 colour_refraction = texture2D( texture_refraction, corr_screen_pos_refraction ).rgb;\n vec3 colour_reflection = texture2D( texture_reflection, corr_screen_pos_reflection ).rgb;\n vec4 lighting = vec4(lum, lum, lum, 1.0);\n gl_FragColor = vec4(0.25*colour_refraction, 1.0)+vec4(0.75*colour_reflection, 1.0)+ lighting;\n }", "glsl_version": null, "validation_status": "valid", "extraction_type": "js_template_literal"}, {"path": "water/water.js", "language": "javascript", "loc": 209, "comment_density": 0.038, "code": "class Water{\n\n setup(gl){\n this.gl = gl;\n\n const vertexShader = loadShader(this.gl, this.gl.VERTEX_SHADER, this.vertex_shader_code);\n const fragmentShader = loadShader(this.gl, this.gl.FRAGMENT_SHADER, this.fragment_shader_code);\n\n this.shader_program = this.gl.createProgram();\n this.gl.attachShader(this.shader_program, vertexShader);\n this.gl.attachShader(this.shader_program, fragmentShader);\n this.gl.linkProgram(this.shader_program);\n\n if (!this.gl.getProgramParameter(this.shader_program, this.gl.LINK_STATUS)) {\n alert('Unable to initialize the shader program: ' + this.gl.getProgramInfoLog(this.shader_program));\n return null;\n }\n\n this.pos_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.positions), this.gl.STATIC_DRAW);\n\n this.normal_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(this.normals), this.gl.STATIC_DRAW);\n\n this.idx_buffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.indices), this.gl.STATIC_DRAW);\n\n //texture coordinate buffer\n this.tex_coord_buffer = gl.createBuffer();\n this.gl.bindBuffer(gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.text_coord), gl.STATIC_DRAW);\n\n this.time = 0;\n }\n\n set_mvp(model, view, proj){\n this.model = model;\n this.view = view;\n this.proj = proj;\n }\n\n set_vp(view, proj){\n this.view = view;\n this.proj = proj;\n }\n\n set_light_pos(light_pos){\n this.light_pos = light_pos;\n }\n\n set_camera_pos(cam_pos){\n this.cam_pos = cam_pos;\n }\n\n set_model_matrix(model){\n this.model = model;\n }\n\n get_model_matrix(){\n return this.model;\n }\n\n set_reflection_texture(tex){\n this.reflection_texture_id = tex;\n }\n\n set_refraction_texture(tex){\n this.refraction_texture_id = tex;\n }\n\n set_time(time){\n this.time = time;\n }\n\n draw(){\n this.gl.useProgram(this.shader_program);\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.pos_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"vertex_pos\"));\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.normal_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"normal\"),\n 3,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"normal\"));\n\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.tex_coord_buffer);\n this.gl.vertexAttribPointer(\n this.gl.getAttribLocation(this.shader_program, \"uv\"),\n 2,\n this.gl.FLOAT,\n true,\n 0,\n 0);\n this.gl.enableVertexAttribArray(this.gl.getAttribLocation(this.shader_program, \"uv\"));\n\n gl.activeTexture(gl.TEXTURE0);\n\n gl.bindTexture(gl.TEXTURE_2D, this.reflection_texture_id);\n\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"texture_reflection\"), 0);\n\n gl.activeTexture(gl.TEXTURE1);\n\n gl.bindTexture(gl.TEXTURE_2D, this.refraction_texture_id);\n\n gl.uniform1i(gl.getUniformLocation(this.shader_program, \"texture_refraction\"), 1);\n gl.uniform1f(gl.getUniformLocation(this.shader_program, \"time\"), this.time);\n\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.idx_buffer);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"light_pos\"),\n this.light_pos);\n\n this.gl.uniform3fv(\n this.gl.getUniformLocation(this.shader_program, \"camera_pos\"),\n this.cam_pos);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"proj\"),\n false,\n this.proj);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"view\"),\n false,\n this.view);\n\n this.gl.uniformMatrix4fv(\n this.gl.getUniformLocation(this.shader_program, \"model\"),\n false,\n this.model);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n }\n\n vertex_shader_code = `\n precision highp float; //high precision needed in mobile for light to display correctly\n attribute vec4 vertex_pos;\n attribute vec3 normal;\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform mat4 model;\n uniform mat4 view;\n uniform mat4 proj;\n\n attribute vec2 uv;\n\n varying vec2 frag_uv;\n\n void main() {\n pixel_pos = vec3(model*vertex_pos);\n pixel_normal = normalize(vec3(model*vec4(normal, 0.0)));\n gl_Position = proj*view*model*vertex_pos;\n frag_uv = uv;\n }\n `;\n\n fragment_shader_code = `\n precision highp float; //high precision needed in mobile for light to display correctly\n\n varying vec3 pixel_pos;\n varying vec3 pixel_normal;\n\n uniform vec3 camera_pos;\n uniform vec3 light_pos;\n\n varying vec2 frag_uv;\n\n uniform sampler2D texture_reflection;\n uniform sampler2D texture_refraction;\n\n uniform mat4 view;\n uniform mat4 proj;\n\n uniform float time;\n\n float get_wave_1(float x, float y){\n float wave = 0.01*sin( dot(normalize(vec2(1,0)), vec2(x, y)) *128.0+time);\n wave += 0.01*sin( dot(normalize(vec2(15,1)), vec2(x, y)) *128.0+time);\n wave += 0.01*sin( dot(normalize(vec2(10,-1)), vec2(x, y)) *256.0+time*1.5);\n wave += 0.01*sin( dot(normalize(vec2(3,1)), vec2(x, y)) *256.0+time*1.5);\n wave += 0.02*sin( dot(normalize(vec2(6,-1)), vec2(x, y)) *64.0+time*0.8);\n wave += 0.015*sin( dot(normalize(vec2(8,1)), vec2(x, y)) *128.0+time*0.7);\n return wave/24.0;\n }\n\n void main() {\n\n float wave = get_wave_1(frag_uv.x, frag_uv.y);\n\n //interestingly the normal_wave would not be calculated correctly on mobile\n //if the float precision was only medium\n vec3 pos_before_x = vec3(frag_uv.x-0.001, get_wave_1(frag_uv.x-0.001, frag_uv.y), frag_uv.y);\n vec3 pos_after_x = vec3(frag_uv.x+0.001, get_wave_1(frag_uv.x+0.001, frag_uv.y), frag_uv.y);\n vec3 pos_before_y = vec3(frag_uv.x, get_wave_1(frag_uv.x, frag_uv.y-0.001), frag_uv.y-0.001);\n vec3 pos_after_y = vec3(frag_uv.x, get_wave_1(frag_uv.x, frag_uv.y+0.001), frag_uv.y+0.001);\n\n //get normal of wave, for lighting purpose\n vec3 normal_wave = normalize(cross( pos_after_x-pos_before_x, pos_after_y-pos_before_y));\n\n vec3 light_dir = normalize(light_pos-pixel_pos);\n float diffuse_light = 0.0;\n\n diffuse_light = dot(normal_wave, light_dir);\n float light_dist = length(light_pos-pixel_pos);\n diffuse_light /= (1.0+pow(light_dist, -0.5));\n\n //reflexion of light for specular light calculation, not the image reflexion\n vec3 reflexion = 2.0*normal_wave*dot(normal_wave, light_dir)-light_dir;\n reflexion = normalize(reflexion);\n vec3 view_dir = normalize(camera_pos-pixel_pos);\n\n float spec_light = pow(max(dot(reflexion, view_dir), 0.0), 256.0);\n spec_light = clamp(spec_light, 0.0, 1.0);\n\n float lum = 0.5*diffuse_light+spec_light;\n\n vec4 screen_pos = proj*view*vec4(pixel_pos, 1.0);\n vec2 corr_screen_pos_refraction = screen_pos.xy*0.5/screen_pos.w+vec2(0.5, 0.5);\n vec2 corr_screen_pos_reflection = vec2(corr_screen_pos_refraction.x, 1.0-corr_screen_pos_refraction.y); //must invert y\n\n corr_screen_pos_refraction += vec2(wave, wave);\n corr_screen_pos_reflection += vec2(wave, wave);\n\n vec3 colour_refraction = texture2D( texture_refraction, corr_screen_pos_refraction ).rgb;\n vec3 colour_reflection = texture2D( texture_reflection, corr_screen_pos_reflection ).rgb;\n vec4 lighting = vec4(lum, lum, lum, 1.0);\n gl_FragColor = vec4(0.25*colour_refraction, 1.0)+vec4(0.75*colour_reflection, 1.0)+ lighting;\n }\n `;\n\n positions = [\n -1.0, 0.0, -1.0,\n 1.0, 0.0, -1.0,\n 1.0, 0.0, 1.0,\n -1.0, 0.0, 1.0,\n ];\n\n indices = [\n 0, 2, 1, 0, 3, 2\n ];\n\n normals = [\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 1.0, 0.0,\n ];\n\n text_coord = [\n 0.0, 0.0,\n 1.0, 0.0,\n 1.0, 1.0,\n 0.0, 1.0,\n ];\n}\n"}], "validation": {"glslang_valid": 6, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "has_ubo": false, "has_ssbo": false, "texture_samplers": 2, "has_compute_barriers": false, "has_instancing": false}, "preview_image": "images/webgl_examples_water.png", "license": "none-found", "non_commercial": false, "comment_density": 0.089, "dedup_hash": "efc55ff0924657c7", "has_readme": true, "build_system": null, "dependency_count": 7, "has_demo": true} -{"id": "shadertoy_4dfgzs", "source": "https://www.shadertoy.com/view/4dfGzs", "source_commit": null, "collected_at": "2026-08-17T14:37:36+00:00", "source_type": "shadertoy", "title": "Raymarching Primitives", "author": "iquilezles", "description": "Raymarching distance fields (primitives, operations, lighting, soft shadows, ambient occlusion).", "api": "WebGL2", "glsl_version": "300 es", "topic": "raymarching/lighting/gi/basics", "difficulty": "intermediate", "source_quality": "curated_gallery", "files": [{"path": "image.frag", "language": "glsl", "stage": "fragment", "loc": 37, "comment_density": 0.027, "code": "// Inigo Quilez - Raymarching Primitives\nfloat sdSphere(vec3 p, float s) { return length(p) - s; }\nfloat sdBox(vec3 p, vec3 b) { vec3 d = abs(p) - b; return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)); }\n\nfloat map(vec3 p) {\n float d1 = sdSphere(p - vec3(0.0, 0.25, 0.0), 0.75);\n float d2 = sdBox(p - vec3(0.0, -0.5, 0.0), vec3(1.5, 0.1, 1.5));\n return min(d1, d2);\n}\n\nvec3 calcNormal(vec3 p) {\n const float h = 0.001;\n const vec2 k = vec2(1, -1);\n return normalize(k.xyy*map(p + k.xyy*h) + \n k.yyx*map(p + k.yyx*h) + \n k.yxy*map(p + k.yxy*h) + \n k.xxx*map(p + k.xxx*h));\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n vec2 p = (2.0 * fragCoord - iResolution.xy) / iResolution.y;\n vec3 ro = vec3(0.0, 1.5, 3.0);\n vec3 rd = normalize(vec3(p, -1.5));\n\n float t = 0.0;\n for (int i = 0; i < 64; i++) {\n vec3 pos = ro + t * rd;\n float h = map(pos);\n if (h < 0.001 || t > 20.0) break;\n t += h;\n }\n\n vec3 col = vec3(0.1, 0.1, 0.15);\n if (t < 20.0) {\n vec3 pos = ro + t * rd;\n vec3 nor = calcNormal(pos);\n vec3 lig = normalize(vec3(0.8, 0.7, 0.6));\n float dif = clamp(dot(nor, lig), 0.0, 1.0);\n col = vec3(0.9, 0.6, 0.3) * dif + vec3(0.05, 0.1, 0.15);\n }\n\n fragColor = vec4(col, 1.0);\n}", "glsl_version": "300 es", "validation_status": "valid", "pass_type": "image"}], "validation": {"glslang_valid": 1, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "CC-BY-NC-SA-3.0", "non_commercial": true, "comment_density": 0.027, "dedup_hash": "77b7ba394cac7613", "has_readme": true, "build_system": null, "dependency_count": 0, "has_demo": true, "views": 182400, "likes": 1420, "tags": ["raymarching", "sdf", "distancefields", "lighting", "shadows", "primitives"]} -{"id": "shadertoy_lsf3rh", "source": "https://www.shadertoy.com/view/lsf3RH", "source_commit": null, "collected_at": "2026-08-17T14:37:36+00:00", "source_type": "shadertoy", "title": "Procedural Simplex Noise 2D/3D", "author": "ashima", "description": "Procedural cellular and simplex noise functions in pure GLSL.", "api": "WebGL2", "glsl_version": "300 es", "topic": "procedural/basics", "difficulty": "intermediate", "source_quality": "curated_gallery", "files": [{"path": "image.frag", "language": "glsl", "stage": "fragment", "loc": 31, "comment_density": 0.0, "code": "vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }\n\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod289(i);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m;\n m = m*m;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h);\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n float n = snoise(uv * 6.0 + iTime * 0.5);\n vec3 col = vec3(0.5 + 0.5 * n);\n fragColor = vec4(col, 1.0);\n}", "glsl_version": "300 es", "validation_status": "valid", "pass_type": "image"}], "validation": {"glslang_valid": 1, "invalid": 0, "unverified": 0, "has_ubo_or_ssbo": false, "texture_samplers": 0, "has_compute_barriers": false, "has_instancing": false}, "preview_image": null, "license": "CC-BY-NC-SA-3.0", "non_commercial": true, "comment_density": 0.0, "dedup_hash": "c855c26862ff313f", "has_readme": true, "build_system": null, "dependency_count": 0, "has_demo": true, "views": 94300, "likes": 560, "tags": ["noise", "procedural", "simplex", "fbm", "texture"]} +version https://git-lfs.github.com/spec/v1 +oid sha256:6963c4a443363bce6e552183d5d74fe61f2252d4b6ced5293449c0906c2b2cf8 +size 152394616