diff --git a/fggl/CMakeLists.txt b/fggl/CMakeLists.txt index a5bf05fe3ae6900023ae3fc39e9d99d5a5d2b51f..a62f5fcb5b4a0ba73e7ab21f237690796cb01edf 100644 --- a/fggl/CMakeLists.txt +++ b/fggl/CMakeLists.txt @@ -7,10 +7,10 @@ add_library(fggl ${HEADER_LIST}) # we need to tell people using the library about our headers target_include_directories(fggl - PUBLIC + PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> -) + ) # users of this library need at least C++20 target_compile_features(fggl PUBLIC cxx_std_20) @@ -39,7 +39,7 @@ add_subdirectory(assets) add_subdirectory(phys) target_sources(${PROJECT_NAME} - PRIVATE + PRIVATE app.cpp data/model.cpp @@ -58,7 +58,7 @@ target_sources(${PROJECT_NAME} gui/widgets.cpp gui/containers.cpp gui/fonts.cpp -) + ) # yaml-cpp for configs and storage find_package(yaml-cpp) @@ -66,11 +66,11 @@ target_link_libraries(fggl PUBLIC yaml-cpp) # model loading find_package(assimp CONFIG) -if ( MSVC ) +if (MSVC) target_link_libraries(${PROJECT_NAME} PUBLIC assimp::assimp) -else() +else () target_link_libraries(${PROJECT_NAME} PUBLIC assimp) -endif() +endif () find_package(Freetype) target_link_libraries(${PROJECT_NAME} PUBLIC Freetype::Freetype) @@ -91,7 +91,7 @@ add_subdirectory(entity) ## # begin windows support ## -if(MSVC) - target_compile_options(${PROJECT_NAME} PUBLIC "/ZI") - target_link_options(${PROJECT_NAME} PUBLIC "/INCREMENTAL") -endif() +if (MSVC) + target_compile_options(${PROJECT_NAME} PUBLIC "/ZI") + target_link_options(${PROJECT_NAME} PUBLIC "/INCREMENTAL") +endif () diff --git a/fggl/app.cpp b/fggl/app.cpp index 406fbc757a50bb42246e045b46c7587052d84e63..59684c8432776ee51601b84608a76f09aadfc287 100644 --- a/fggl/app.cpp +++ b/fggl/app.cpp @@ -20,67 +20,67 @@ namespace fggl { - App::App(modules::Manager* services, const Identifer& name) : App::App( services, name, name ) { - } + App::App(modules::Manager *services, const Identifer &name) : App::App(services, name, name) { + } - App::App(modules::Manager* services, const Identifer& /*name*/, const Identifer& /*folder*/ ) : - m_running(true), + App::App(modules::Manager *services, const Identifer & /*name*/, const Identifer & /*folder*/ ) : + m_running(true), m_window(nullptr), - m_states(), - m_subsystems(services){} + m_states(), + m_subsystems(services) {} - int App::run(int argc, const char** argv) { - auto* windowing = m_subsystems->get<display::WindowService>(); + int App::run(int argc, const char **argv) { + auto *windowing = m_subsystems->get<display::WindowService>(); - { - // activate the first state - auto& state = m_states.active(); + { + // activate the first state + auto &state = m_states.active(); m_expectedScene = m_states.activeID(); - state.activate(); - } + state.activate(); + } - while ( m_running ) { + while (m_running) { // trigger a state change if expected - if ( m_expectedScene != m_states.activeID() ) { + if (m_expectedScene != m_states.activeID()) { auto result = m_states.change(m_expectedScene); - if ( !result ) { + if (!result) { m_expectedScene = m_states.activeID(); } } // process window events - if ( windowing != nullptr) { + if (windowing != nullptr) { windowing->pollEvents(); } - //m_modules->onUpdate(); + //m_modules->onUpdate(); - auto& state = m_states.active(); + auto &state = m_states.active(); state.update(); - // window rendering to frame buffer - if ( m_window != nullptr ) { - // m_modules->onFrameStart(); + // window rendering to frame buffer + if (m_window != nullptr) { + // m_modules->onFrameStart(); m_window->frameStart(); - // get draw instructions - auto& graphics = m_window->graphics(); - state.render(graphics); + // get draw instructions + auto &graphics = m_window->graphics(); + state.render(graphics); - m_window->frameEnd(); - // m_modules->onFrameEnd(); + m_window->frameEnd(); + // m_modules->onFrameEnd(); m_running = m_running && !m_window->wantClose(); - } - } + } + } - { - // shutdown last state - auto& state = m_states.active(); - state.deactivate(); - } + { + // shutdown last state + auto &state = m_states.active(); + state.deactivate(); + } - return EXIT_SUCCESS; - } + return EXIT_SUCCESS; + } } //namespace fggl diff --git a/fggl/assets/CMakeLists.txt b/fggl/assets/CMakeLists.txt index 4f1eb0dc847b7f7917ca668d357680aa7a7b720a..d057f9945c730f3879fbdacfca19c020cf456921 100644 --- a/fggl/assets/CMakeLists.txt +++ b/fggl/assets/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources(fggl PRIVATE - module.cpp -) \ No newline at end of file + module.cpp + ) \ No newline at end of file diff --git a/fggl/assets/module.cpp b/fggl/assets/module.cpp index 73034f5ac43381bc2e3eef6f462f112f263c484e..5c25dacde21d820fb5bd9a2f9b0f6da1b4fdf1ae 100644 --- a/fggl/assets/module.cpp +++ b/fggl/assets/module.cpp @@ -20,8 +20,8 @@ namespace fggl::assets { - bool AssetFolders::factory(modules::ModuleService service, modules::Services& services) { - if ( service == Loader::service) { + bool AssetFolders::factory(modules::ModuleService service, modules::Services &services) { + if (service == Loader::service) { auto storage = services.get<data::Storage>(); services.create<Loader>(storage); return true; diff --git a/fggl/audio/CMakeLists.txt b/fggl/audio/CMakeLists.txt index 49787dd47d9d0ff99bc14ecaee89e0fef43f3c08..f6e277605f520658e06bdc9cd222c771f4922d52 100644 --- a/fggl/audio/CMakeLists.txt +++ b/fggl/audio/CMakeLists.txt @@ -1,6 +1,6 @@ target_sources(fggl PRIVATE - types.cpp -) + types.cpp + ) add_subdirectory(openal) \ No newline at end of file diff --git a/fggl/audio/openal/CMakeLists.txt b/fggl/audio/openal/CMakeLists.txt index 9f9ff76d26b8dc73a2a6f94971b8d1c785cd18cd..8c1882fb094701aa3a180ec57005b08fb0ed5c78 100644 --- a/fggl/audio/openal/CMakeLists.txt +++ b/fggl/audio/openal/CMakeLists.txt @@ -1,24 +1,24 @@ -find_package( OpenAL CONFIG ) -if ( NOT OpenAL_FOUND ) +find_package(OpenAL CONFIG) +if (NOT OpenAL_FOUND) # ubuntu/debian openal-soft package doesn't seem to have a config file # it's probably falling back to findOpenAL.cmake - message( STATUS "OpenAL-Soft config missing - falling back" ) - find_package( OpenAL REQUIRED ) - target_link_libraries( fggl PUBLIC ${OPENAL_LIBRARY} ) - target_include_directories( fggl PUBLIC ${OPENAL_INCLUDE_DIR} ) -else() + message(STATUS "OpenAL-Soft config missing - falling back") + find_package(OpenAL REQUIRED) + target_link_libraries(fggl PUBLIC ${OPENAL_LIBRARY}) + target_include_directories(fggl PUBLIC ${OPENAL_INCLUDE_DIR}) +else () # we're using target-based - message( STATUS "Using OpenAL-Soft config file" ) - if ( TARGET OpenAL::OpenAL ) - target_link_libraries( fggl PUBLIC OpenAL::OpenAL ) - else() - target_link_libraries( fggl PUBLIC OpenAL ) - endif() + message(STATUS "Using OpenAL-Soft config file") + if (TARGET OpenAL::OpenAL) + target_link_libraries(fggl PUBLIC OpenAL::OpenAL) + else () + target_link_libraries(fggl PUBLIC OpenAL) + endif () -endif() +endif () target_sources(fggl - PRIVATE + PRIVATE audio.cpp -) + ) diff --git a/fggl/audio/openal/audio.cpp b/fggl/audio/openal/audio.cpp index 3a64cd0d469de3941368c07eb934e5e47efc87a8..3b1eea06fe770b461539df26e9de9c7a22c0c0a5 100644 --- a/fggl/audio/openal/audio.cpp +++ b/fggl/audio/openal/audio.cpp @@ -36,7 +36,7 @@ namespace fggl::audio::openal { // load audio clip into temp storage AudioClip clip; bool result = m_storage->load(data::StorageType::Data, filename, &clip); - if ( !result ) { + if (!result) { std::cerr << "error: can't load audio data" << std::endl; return; } @@ -46,7 +46,7 @@ namespace fggl::audio::openal { void AudioServiceOAL::play(AudioClip &clip, bool looping) { // play the audio on the default (non-positioned) source - if ( m_defaultSource != nullptr ) { + if (m_defaultSource != nullptr) { m_defaultSource->play(clip, looping); } } diff --git a/fggl/audio/types.cpp b/fggl/audio/types.cpp index 7de8e0a11404cf1a787b19e043263abedc688e2b..485a900bb87a2223a1d4dd24398eef75bfd15311 100644 --- a/fggl/audio/types.cpp +++ b/fggl/audio/types.cpp @@ -19,17 +19,16 @@ namespace fggl::audio { - } // namespace fggl::audio namespace fggl::data { template<> - bool fggl_deserialize<audio::AudioClip>(std::filesystem::path &data, audio::AudioClip* out) { + bool fggl_deserialize<audio::AudioClip>(std::filesystem::path &data, audio::AudioClip *out) { out->sampleCount = stb_vorbis_decode_filename(data.string().c_str(), - &out->channels, - &out->sampleRate, - &out->data); + &out->channels, + &out->sampleRate, + &out->data); return out->sampleCount != -1; } diff --git a/fggl/data/heightmap.cpp b/fggl/data/heightmap.cpp index 2122f081b0d16cf2003434f76d409a340cb283b6..04735b4e7530be2fd62dfb70710734878f885c3e 100644 --- a/fggl/data/heightmap.cpp +++ b/fggl/data/heightmap.cpp @@ -23,103 +23,104 @@ namespace fggl::data { - void gridVertexNormals(data::Vertex *locations) { - const int sizeX = data::heightMaxX; - const int sizeY = data::heightMaxZ; - const int gridOffset = sizeX * sizeY; - - // calculate normals for each triangle - math::vec3* triNormals = new math::vec3[sizeX * sizeY * 2]; - for (int i = 0; i < sizeX - 1; i++) { - for (int j = 0; j < sizeY - 1; j++) { - // calculate vertex - const auto &a = locations[i * sizeY + j].posititon; - const auto &b = locations[(i + 1) * sizeY + j].posititon; - const auto &c = locations[i * sizeY + (j + 1)].posititon; - const auto &d = locations[(i + 1) * sizeY + (j + 1)].posititon; - - const auto normalA = glm::cross(b - a, a - d); - const auto normalB = glm::cross(d - c, c - b); - - // store the normals - int idx1 = idx(i, j, sizeY); - int idx2 = idx1 + gridOffset; - triNormals[idx1] = glm::normalize(normalA); - triNormals[idx2] = glm::normalize(normalB); - } - } - - // calculate normals for each vertex - for (int i = 0; i < sizeX; i++) { - for (int j = 0; j < sizeY; j++) { - const auto firstRow = (i == 0); - const auto firstCol = (j == 0); - const auto lastRow = (i == sizeX - 1); - const auto lastCol = (i == sizeY - 1); - - auto finalNormal = glm::vec3(0.0f, 0.0f, 0.0f); - - if (!firstRow && !firstCol) { - finalNormal += triNormals[idx(i - 1, j - 1, sizeY)]; - } - - if (!lastRow && !lastCol) { - finalNormal += triNormals[idx(i, j, sizeY)]; - } - - if (!firstRow && lastCol) { - finalNormal += triNormals[idx(i - 1, j, sizeY)]; - finalNormal += triNormals[idx(i - 1, j, sizeY) + gridOffset]; - } - - if (!lastRow && !firstCol) { - finalNormal += triNormals[idx(i, j - 1, sizeY)]; - finalNormal += triNormals[idx(i, j - 1, sizeY) + gridOffset]; - } - - locations[idx(i, j, sizeY)].normal = glm::normalize(finalNormal) * -1.0f; //FIXME the normals seem wrong. - } - } - delete[] triNormals; - } - - void generateHeightMesh(const data::HeightMap& heights, data::Mesh &mesh) { - - // step 1: convert height data into vertex locations - const int numElms = data::heightMaxX * data::heightMaxZ; + void gridVertexNormals(data::Vertex *locations) { + const int sizeX = data::heightMaxX; + const int sizeY = data::heightMaxZ; + const int gridOffset = sizeX * sizeY; + + // calculate normals for each triangle + math::vec3 *triNormals = new math::vec3[sizeX * sizeY * 2]; + for (int i = 0; i < sizeX - 1; i++) { + for (int j = 0; j < sizeY - 1; j++) { + // calculate vertex + const auto &a = locations[i * sizeY + j].posititon; + const auto &b = locations[(i + 1) * sizeY + j].posititon; + const auto &c = locations[i * sizeY + (j + 1)].posititon; + const auto &d = locations[(i + 1) * sizeY + (j + 1)].posititon; + + const auto normalA = glm::cross(b - a, a - d); + const auto normalB = glm::cross(d - c, c - b); + + // store the normals + int idx1 = idx(i, j, sizeY); + int idx2 = idx1 + gridOffset; + triNormals[idx1] = glm::normalize(normalA); + triNormals[idx2] = glm::normalize(normalB); + } + } + + // calculate normals for each vertex + for (int i = 0; i < sizeX; i++) { + for (int j = 0; j < sizeY; j++) { + const auto firstRow = (i == 0); + const auto firstCol = (j == 0); + const auto lastRow = (i == sizeX - 1); + const auto lastCol = (i == sizeY - 1); + + auto finalNormal = glm::vec3(0.0f, 0.0f, 0.0f); + + if (!firstRow && !firstCol) { + finalNormal += triNormals[idx(i - 1, j - 1, sizeY)]; + } + + if (!lastRow && !lastCol) { + finalNormal += triNormals[idx(i, j, sizeY)]; + } + + if (!firstRow && lastCol) { + finalNormal += triNormals[idx(i - 1, j, sizeY)]; + finalNormal += triNormals[idx(i - 1, j, sizeY) + gridOffset]; + } + + if (!lastRow && !firstCol) { + finalNormal += triNormals[idx(i, j - 1, sizeY)]; + finalNormal += triNormals[idx(i, j - 1, sizeY) + gridOffset]; + } + + locations[idx(i, j, sizeY)].normal = + glm::normalize(finalNormal) * -1.0f; //FIXME the normals seem wrong. + } + } + delete[] triNormals; + } + + void generateHeightMesh(const data::HeightMap &heights, data::Mesh &mesh) { + + // step 1: convert height data into vertex locations + const int numElms = data::heightMaxX * data::heightMaxZ; std::array<data::Vertex, numElms> locations{}; // iterate the - for (std::size_t x = 0; x < data::heightMaxX; x++) { - for (std::size_t z = 0; z < data::heightMaxZ; z++) { - float level = heights.getValue(x, z); - auto xPos = float(x); - auto zPos = float(z); - - std::size_t idx1 = idx(x, z, data::heightMaxZ); - locations[idx1].colour = fggl::math::vec3(1.0f, 1.0f, 1.0f); - locations[idx1].posititon = math::vec3(-0.5f + xPos, level, -0.5f - zPos); - } - } - gridVertexNormals(locations.data()); - - mesh.restartVertex = data::heightMaxZ * data::heightMaxX; - - // populate mesh - for (auto i = 0; i < numElms; i++) { - mesh.pushVertex(locations[i]); - } - - for (std::size_t x = 0; x < data::heightMaxX - 1; x++) { - for (std::size_t z = 0; z < data::heightMaxZ; z++) { - for (int k=0; k < 2; k++) { - auto idx = (x+k) * data::heightMaxZ + z; - mesh.pushIndex(idx); - } - } - mesh.pushIndex(mesh.restartVertex); - } - - } + for (std::size_t x = 0; x < data::heightMaxX; x++) { + for (std::size_t z = 0; z < data::heightMaxZ; z++) { + float level = heights.getValue(x, z); + auto xPos = float(x); + auto zPos = float(z); + + std::size_t idx1 = idx(x, z, data::heightMaxZ); + locations[idx1].colour = fggl::math::vec3(1.0f, 1.0f, 1.0f); + locations[idx1].posititon = math::vec3(-0.5f + xPos, level, -0.5f - zPos); + } + } + gridVertexNormals(locations.data()); + + mesh.restartVertex = data::heightMaxZ * data::heightMaxX; + + // populate mesh + for (auto i = 0; i < numElms; i++) { + mesh.pushVertex(locations[i]); + } + + for (std::size_t x = 0; x < data::heightMaxX - 1; x++) { + for (std::size_t z = 0; z < data::heightMaxZ; z++) { + for (int k = 0; k < 2; k++) { + auto idx = (x + k) * data::heightMaxZ + z; + mesh.pushIndex(idx); + } + } + mesh.pushIndex(mesh.restartVertex); + } + + } } diff --git a/fggl/data/model.cpp b/fggl/data/model.cpp index 2c7d466bbb01c07dda4376c412f3bd534346848e..c3c843f0ae06481892f4382f37a65f1c33d2c07a 100644 --- a/fggl/data/model.cpp +++ b/fggl/data/model.cpp @@ -24,19 +24,19 @@ Mesh::Mesh() : restartVertex(Mesh::INVALID_IDX), m_verts(0), m_index(0) { } void Mesh::pushIndex(unsigned int idx) { - assert( idx < m_verts.size() || idx == this->restartVertex ); + assert(idx < m_verts.size() || idx == this->restartVertex); m_index.push_back(idx); } Mesh::IndexType Mesh::pushVertex(Vertex vert) { auto idx = m_verts.size(); - m_verts.push_back( vert ); + m_verts.push_back(vert); return idx; } Mesh::IndexType Mesh::indexOf(Vertex term) { auto itr = std::find(m_verts.begin(), m_verts.end(), term); - if ( itr == m_verts.end() ){ + if (itr == m_verts.end()) { return INVALID_IDX; } return itr - m_verts.begin(); @@ -47,24 +47,24 @@ void Mesh::removeDups() { std::map<Vertex, unsigned int> mapping; // new data - std::vector< Vertex > newVerts; - std::vector< unsigned int > newIndexes; - newIndexes.reserve( m_index.size() ); // newIndex will be same size as oldIndex + std::vector<Vertex> newVerts; + std::vector<unsigned int> newIndexes; + newIndexes.reserve(m_index.size()); // newIndex will be same size as oldIndex unsigned int nextID = 0; - for ( auto& idx : m_index ) { - auto& vertex = m_verts[idx]; + for (auto &idx : m_index) { + auto &vertex = m_verts[idx]; auto newID = nextID; // if the vertex is known, use the existing ID, else allocate a new ID try { - newID = mapping.at( vertex ); - } catch ( std::out_of_range& e ){ - mapping[ vertex ] = newID; - newVerts.push_back( vertex ); + newID = mapping.at(vertex); + } catch (std::out_of_range &e) { + mapping[vertex] = newID; + newVerts.push_back(vertex); ++nextID; } - newIndexes.push_back( newID ); + newIndexes.push_back(newID); } // assign the replacement lists diff --git a/fggl/data/module.cpp b/fggl/data/module.cpp index d621707af9f3669d5433ccbf05ed8de47d53b5b1..883e1d916f92b56b6e4de0d6444690e692e06453 100644 --- a/fggl/data/module.cpp +++ b/fggl/data/module.cpp @@ -20,7 +20,7 @@ namespace fggl::data { - bool LocalStorage::factory(modules::ModuleService service, modules::Services& data) { + bool LocalStorage::factory(modules::ModuleService service, modules::Services &data) { if (service == SERVICE_STORAGE) { // FIXME: no easy way to set the application name auto pathConfig = fggl::platform::calc_engine_paths("fggl-demo"); diff --git a/fggl/data/procedural.cpp b/fggl/data/procedural.cpp index 4b6c46e5b7e197e7d743e877d44c666c4ddc87d9..34d9a2e68094bc89d6cddd349e835427983fbe7c 100644 --- a/fggl/data/procedural.cpp +++ b/fggl/data/procedural.cpp @@ -30,47 +30,47 @@ using namespace fggl::data; static glm::vec3 calcSurfaceNormal(glm::vec3 vert1, glm::vec3 vert2, glm::vec3 vert3) { const glm::vec3 edge1 = vert2 - vert1; const glm::vec3 edge2 = vert3 - vert1; - return glm::normalize( glm::cross( edge1, edge2 ) ); + return glm::normalize(glm::cross(edge1, edge2)); } -static void computeNormalsDirect( fggl::data::Mesh& mesh, const fggl::data::Mesh::IndexType * colIdx, int nPoints) { +static void computeNormalsDirect(fggl::data::Mesh &mesh, const fggl::data::Mesh::IndexType *colIdx, int nPoints) { // we're assuming all the normals are zero... - for ( int i=0; i<nPoints; i++ ) { - auto& vertex = mesh.vertex( colIdx[i] ); + for (int i = 0; i < nPoints; i++) { + auto &vertex = mesh.vertex(colIdx[i]); vertex.normal = glm::vec3(0.0F); } // We're assuming each vertex appears only once (because we're not indexed) - for (int i=0; i<nPoints; i += 3) { - auto& v1 = mesh.vertex( colIdx[ i ] ); - auto& v2 = mesh.vertex( colIdx[ i + 1 ] ); - auto& v3 = mesh.vertex( colIdx[ i + 2 ] ); + for (int i = 0; i < nPoints; i += 3) { + auto &v1 = mesh.vertex(colIdx[i]); + auto &v2 = mesh.vertex(colIdx[i + 1]); + auto &v3 = mesh.vertex(colIdx[i + 2]); - const glm::vec3 normal = glm::normalize( calcSurfaceNormal( v1.posititon, v2.posititon, v3.posititon ) ); + const glm::vec3 normal = glm::normalize(calcSurfaceNormal(v1.posititon, v2.posititon, v3.posititon)); v1.normal = normal; v2.normal = normal; v3.normal = normal; } } -static void compute_normals(fggl::data::Mesh& mesh, - const std::vector<Mesh::IndexType>& idxList, // source index - const std::vector<Mesh::IndexType>& idxMapping // source-to-mesh lookup - ) { +static void compute_normals(fggl::data::Mesh &mesh, + const std::vector<Mesh::IndexType> &idxList, // source index + const std::vector<Mesh::IndexType> &idxMapping // source-to-mesh lookup +) { // clear the normals, so the summation below works correctly for (auto vertexIndex : idxMapping) { - auto& vertex = mesh.vertex( vertexIndex ); + auto &vertex = mesh.vertex(vertexIndex); vertex.normal = ILLEGAL_NORMAL; } // we need to calculate the contribution for each vertex // this assumes IDXList describes a raw triangle list (ie, not quads and not a strip) - for ( std::size_t i=0; i < idxList.size(); i += 3) { - auto& v1 = mesh.vertex( idxMapping[idxList[i]] ); - auto& v2 = mesh.vertex( idxMapping[idxList[i + 1]] ); - auto& v3 = mesh.vertex( idxMapping[idxList[i + 2]] ); + for (std::size_t i = 0; i < idxList.size(); i += 3) { + auto &v1 = mesh.vertex(idxMapping[idxList[i]]); + auto &v2 = mesh.vertex(idxMapping[idxList[i + 1]]); + auto &v3 = mesh.vertex(idxMapping[idxList[i + 2]]); // calculate the normal and area (formula for area the math textbook) float area = glm::length(glm::cross(v3.posititon - v2.posititon, v1.posititon - v3.posititon)) / 2; @@ -84,32 +84,32 @@ static void compute_normals(fggl::data::Mesh& mesh, // re-normalise the normals for (unsigned int vertexIndex : idxMapping) { - auto& vertex = mesh.vertex( vertexIndex ); + auto &vertex = mesh.vertex(vertexIndex); vertex.normal = glm::normalize(vertex.normal); } } -static void populateMesh(fggl::data::Mesh& mesh, const fggl::math::mat4 transform, - const int nIdx, const fggl::math::vec3* pos, const Mesh::IndexType* idx ) { +static void populateMesh(fggl::data::Mesh &mesh, const fggl::math::mat4 transform, + const int nIdx, const fggl::math::vec3 *pos, const Mesh::IndexType *idx) { - auto* colIdx = new fggl::data::Mesh::IndexType[nIdx]; + auto *colIdx = new fggl::data::Mesh::IndexType[nIdx]; // generate mesh - for (int i=0; i<nIdx; i++) { - glm::vec3 rawPos = transform * glm::vec4( pos[ idx[i] ], 1.0 ); - colIdx[ i ] = mesh.pushVertex( Vertex::from_pos(rawPos) ); - mesh.pushIndex( colIdx[i] ); + for (int i = 0; i < nIdx; i++) { + glm::vec3 rawPos = transform * glm::vec4(pos[idx[i]], 1.0); + colIdx[i] = mesh.pushVertex(Vertex::from_pos(rawPos)); + mesh.pushIndex(colIdx[i]); } - computeNormalsDirect( mesh, colIdx, nIdx ); + computeNormalsDirect(mesh, colIdx, nIdx); delete[] colIdx; } -static void populateMesh(fggl::data::Mesh& mesh, +static void populateMesh(fggl::data::Mesh &mesh, const fggl::math::mat4 transform, - const std::vector<fggl::math::vec3>& posList, - const std::vector<fggl::data::Mesh::IndexType>& idxList) { + const std::vector<fggl::math::vec3> &posList, + const std::vector<fggl::data::Mesh::IndexType> &idxList) { // tmp store the resulting mesh indexes (incase the mesh has multiple primatives) std::vector<unsigned int> colIdx; @@ -118,12 +118,12 @@ static void populateMesh(fggl::data::Mesh& mesh, // clion this thinks this loop is infinite, my assumption is it's gone bananas for (std::size_t i = 0; i < posList.size(); ++i) { glm::vec3 position = transform * fggl::math::vec4(posList[i], 1.0F); - colIdx[i] = mesh.pushVertex( Vertex::from_pos(position) ); + colIdx[i] = mesh.pushVertex(Vertex::from_pos(position)); } // use the remapped indexes for the mesh for (auto idx : idxList) { - mesh.pushIndex( colIdx[idx] ); + mesh.pushIndex(colIdx[idx]); } compute_normals(mesh, idxList, colIdx); @@ -131,7 +131,7 @@ static void populateMesh(fggl::data::Mesh& mesh, namespace fggl::data { - static void quads2Tris(std::vector<Mesh::IndexType>& indexList, uint32_t stacks, uint32_t slices) { + static void quads2Tris(std::vector<Mesh::IndexType> &indexList, uint32_t stacks, uint32_t slices) { const auto HORZ_SIZE = slices + 1; for (uint32_t vertical = 0; vertical < stacks; vertical++) { @@ -152,19 +152,19 @@ namespace fggl::data { } } - void make_sphere(Mesh &mesh, const math::mat4& offset, uint32_t slices, uint32_t stacks) { + void make_sphere(Mesh &mesh, const math::mat4 &offset, uint32_t slices, uint32_t stacks) { std::vector<math::vec3> positions; - float verticalAngularStride = math::PI / (float)stacks; - float horizontalAngularStride = math::TAU / (float)slices; + float verticalAngularStride = math::PI / (float) stacks; + float horizontalAngularStride = math::TAU / (float) slices; // calculate vertex positions for (uint32_t vertical = 0; vertical < (stacks + 1); vertical++) { - float theta = (math::HALF_PI) - verticalAngularStride * (float)vertical; - for ( uint32_t horz = 0; horz < (slices + 1); horz++ ) { - float phi = horizontalAngularStride * (float)horz; - math::vec3 position { + float theta = (math::HALF_PI) - verticalAngularStride * (float) vertical; + for (uint32_t horz = 0; horz < (slices + 1); horz++) { + float phi = horizontalAngularStride * (float) horz; + math::vec3 position{ cosf(theta) * cosf(phi), cosf(theta) * sinf(phi), sinf(theta) @@ -180,131 +180,127 @@ namespace fggl::data { populateMesh(mesh, offset, positions, indexList); } - } // namespace fggl::data fggl::data::Mesh fggl::data::make_triangle() { - constexpr fggl::math::vec3 pos[]{ - {-0.5F, -0.5F, 0.0F}, - {0.5F, -0.5F, 0.0F}, - {0.0F, 0.5F, 0.0F} - }; - - // add points - fggl::data::Mesh mesh; - for (auto po : pos) { - mesh.push( Vertex::from_pos(po) ); - } - - // mesh - for (int i = 0; i < 3; ++i) { - mesh.pushIndex(i); - } - - return mesh; + constexpr fggl::math::vec3 pos[]{ + {-0.5F, -0.5F, 0.0F}, + {0.5F, -0.5F, 0.0F}, + {0.0F, 0.5F, 0.0F} + }; + + // add points + fggl::data::Mesh mesh; + for (auto po : pos) { + mesh.push(Vertex::from_pos(po)); + } + + // mesh + for (int i = 0; i < 3; ++i) { + mesh.pushIndex(i); + } + + return mesh; } fggl::data::Mesh fggl::data::make_quad_xy() { - constexpr fggl::math::vec3 pos[] { + constexpr fggl::math::vec3 pos[]{ {-0.5F, -0.5F, 0.0F}, - { 0.5F, -0.5F, 0.0F}, - { 0.5F, 0.5F, 0.0F}, - {-0.5F, 0.5F, 0.0F} + {0.5F, -0.5F, 0.0F}, + {0.5F, 0.5F, 0.0F}, + {-0.5F, 0.5F, 0.0F} }; - constexpr int idx[] { + constexpr int idx[]{ 0, 1, 3, 3, 1, 2 }; fggl::data::Mesh mesh; - std::array<int,4> colIdx{}; - for (int i = 0; i < 4; ++i){ - colIdx[ i ] = mesh.pushVertex( Vertex::from_pos(pos[i])); + std::array<int, 4> colIdx{}; + for (int i = 0; i < 4; ++i) { + colIdx[i] = mesh.pushVertex(Vertex::from_pos(pos[i])); } - for( auto i : idx ) { - mesh.pushIndex( colIdx[ i ] ); + for (auto i : idx) { + mesh.pushIndex(colIdx[i]); } return mesh; } fggl::data::Mesh fggl::data::make_quad_xz() { - constexpr std::array<fggl::math::vec3, 4> pos {{ - {-0.5F, 0.0F, -0.5F}, - {0.5F, 0.0F, -0.5F}, - {0.5F, 0.0F, 0.5F}, - {-0.5F, 0.0F, 0.5F} - }}; - constexpr std::array<int, 6> idx {{ - 0, 1, 3, - 3, 1, 2 - }}; + constexpr std::array<fggl::math::vec3, 4> pos{{ + {-0.5F, 0.0F, -0.5F}, + {0.5F, 0.0F, -0.5F}, + {0.5F, 0.0F, 0.5F}, + {-0.5F, 0.0F, 0.5F} + }}; + constexpr std::array<int, 6> idx{{ + 0, 1, 3, + 3, 1, 2 + }}; fggl::data::Mesh mesh; std::array<int, 4> colIdx{}; - for (int i = 0; i < 4; ++i){ - colIdx[ i ] = mesh.pushVertex( Vertex::from_pos(pos[i]) ); + for (int i = 0; i < 4; ++i) { + colIdx[i] = mesh.pushVertex(Vertex::from_pos(pos[i])); } - for( auto i : idx ) { - mesh.pushIndex(colIdx.at( i )); + for (auto i : idx) { + mesh.pushIndex(colIdx.at(i)); } return mesh; } - - - -fggl::data::Mesh fggl::data::make_cube(fggl::data::Mesh& mesh, const fggl::math::mat4& transform) { +fggl::data::Mesh fggl::data::make_cube(fggl::data::Mesh &mesh, const fggl::math::mat4 &transform) { // done as two loops, top loop is 0,1,2,3, bottom loop is 4,5,6,7 - constexpr std::array<fggl::math::vec3, 8> pos {{ - {-0.5, 0.5, -0.5}, // 0 TOP LOOP - {0.5, 0.5, -0.5}, // 1 - {0.5, 0.5, 0.5}, // 2 - {-0.5, 0.5, 0.5}, // 3 - {-0.5, -0.5, -0.5}, // 4 BOTTOM LOOP - {0.5, -0.5, -0.5}, // 5 - {0.5, -0.5, 0.5}, // 6 - {-0.5, -0.5, 0.5} // 7 - }}; - - constexpr std::array<Mesh::IndexType, 36> idx {{ - 0, 3, 1, // top - 3, 2, 1, - 0, 1, 4, // side 0 - 1 - 5, 4, 1, - 1, 2, 5, // side 1 - 2 - 2, 6, 5, - 3, 7, 2, // side 2 - 3 - 2, 7, 6, - 0, 4, 3, // side 3 - 0 - 4, 7, 3, - 4, 5, 7, // bottom - 7, 5, 6, - }}; + constexpr std::array<fggl::math::vec3, 8> pos{{ + {-0.5, 0.5, -0.5}, // 0 TOP LOOP + {0.5, 0.5, -0.5}, // 1 + {0.5, 0.5, 0.5}, // 2 + {-0.5, 0.5, 0.5}, // 3 + {-0.5, -0.5, -0.5}, // 4 BOTTOM LOOP + {0.5, -0.5, -0.5}, // 5 + {0.5, -0.5, 0.5}, // 6 + {-0.5, -0.5, 0.5} // 7 + }}; + + constexpr std::array<Mesh::IndexType, 36> idx{{ + 0, 3, 1, // top + 3, 2, 1, + 0, 1, 4, // side 0 - 1 + 5, 4, 1, + 1, 2, 5, // side 1 - 2 + 2, 6, 5, + 3, 7, 2, // side 2 - 3 + 2, 7, 6, + 0, 4, 3, // side 3 - 0 + 4, 7, 3, + 4, 5, 7, // bottom + 7, 5, 6, + }}; populateMesh(mesh, transform, idx.size(), pos.data(), idx.data()); return mesh; } -fggl::data::Mesh fggl::data::make_slope(fggl::data::Mesh& mesh, const fggl::math::mat4& transform) { +fggl::data::Mesh fggl::data::make_slope(fggl::data::Mesh &mesh, const fggl::math::mat4 &transform) { // done as two loops, top loop is 0,1,2,3, bottom loop is 4,5,6,7 // FIXME remove 2 and 3 and renumber the index list accordingly - constexpr fggl::math::vec3 pos[] { - {-0.5, 0.5, -0.5}, // 0 TOP LOOP - { 0.5, 0.5, -0.5}, // 1 - { 0.5, 0.5, 0.5}, // 2 - {-0.5, 0.5, 0.5}, // 3 + constexpr fggl::math::vec3 pos[]{ + {-0.5, 0.5, -0.5}, // 0 TOP LOOP + {0.5, 0.5, -0.5}, // 1 + {0.5, 0.5, 0.5}, // 2 + {-0.5, 0.5, 0.5}, // 3 {-0.5, -0.5, -0.5}, // 4 BOTTOM LOOP - { 0.5, -0.5, -0.5}, // 5 - { 0.5, -0.5, 0.5}, // 6 - {-0.5, -0.5, 0.5} // 7 + {0.5, -0.5, -0.5}, // 5 + {0.5, -0.5, 0.5}, // 6 + {-0.5, -0.5, 0.5} // 7 }; - constexpr Mesh::IndexType idx[] { + constexpr Mesh::IndexType idx[]{ 0, 7, 1, // ramp 7, 6, 1, 0, 1, 4, // side 0 - 1 @@ -320,23 +316,22 @@ fggl::data::Mesh fggl::data::make_slope(fggl::data::Mesh& mesh, const fggl::math return mesh; } - -fggl::data::Mesh fggl::data::make_ditch(fggl::data::Mesh& mesh, const fggl::math::mat4& transform) { +fggl::data::Mesh fggl::data::make_ditch(fggl::data::Mesh &mesh, const fggl::math::mat4 &transform) { // done as two loops, top loop is 0,1,2,3, bottom loop is 4,5,6,7 // FIXME remove 2 and renumber the index list accordingly - constexpr fggl::math::vec3 pos[] { - {-0.5, 0.5, -0.5}, // 0 TOP LOOP - { 0.5, 0.5, -0.5}, // 1 - { 0.5, 0.5, 0.5}, // 2 - {-0.5, 0.5, 0.5}, // 3 + constexpr fggl::math::vec3 pos[]{ + {-0.5, 0.5, -0.5}, // 0 TOP LOOP + {0.5, 0.5, -0.5}, // 1 + {0.5, 0.5, 0.5}, // 2 + {-0.5, 0.5, 0.5}, // 3 {-0.5, -0.5, -0.5}, // 4 BOTTOM LOOP - { 0.5, -0.5, -0.5}, // 5 - { 0.5, -0.5, 0.5}, // 6 - {-0.5, -0.5, 0.5} // 7 + {0.5, -0.5, -0.5}, // 5 + {0.5, -0.5, 0.5}, // 6 + {-0.5, -0.5, 0.5} // 7 }; - constexpr Mesh::IndexType idx[] { + constexpr Mesh::IndexType idx[]{ 0, 3, 1, // top 3, 6, 1, 0, 1, 4, // side 0 - 1 @@ -354,21 +349,21 @@ fggl::data::Mesh fggl::data::make_ditch(fggl::data::Mesh& mesh, const fggl::math return mesh; } -fggl::data::Mesh fggl::data::make_point(fggl::data::Mesh& mesh, const fggl::math::mat4& transform) { +fggl::data::Mesh fggl::data::make_point(fggl::data::Mesh &mesh, const fggl::math::mat4 &transform) { // done as two loops, top loop is 0,1,2,3, bottom loop is 4,5,6,7 - constexpr fggl::math::vec3 pos[] { - {-0.5, 0.5, -0.5}, // 0 TOP LOOP - { 0.5, 0.5, -0.5}, // 1 - { 0.5, 0.5, 0.5}, // 2 - {-0.5, 0.5, 0.5}, // 3 + constexpr fggl::math::vec3 pos[]{ + {-0.5, 0.5, -0.5}, // 0 TOP LOOP + {0.5, 0.5, -0.5}, // 1 + {0.5, 0.5, 0.5}, // 2 + {-0.5, 0.5, 0.5}, // 3 {-0.5, -0.5, -0.5}, // 4 BOTTOM LOOP - { 0.5, -0.5, -0.5}, // 5 - { 0.5, -0.5, 0.5}, // 6 - {-0.5, -0.5, 0.5} // 7 + {0.5, -0.5, -0.5}, // 5 + {0.5, -0.5, 0.5}, // 6 + {-0.5, -0.5, 0.5} // 7 }; - constexpr Mesh::IndexType idx[] { + constexpr Mesh::IndexType idx[]{ 0, 7, 5, // top 7, 6, 5, 0, 5, 4, // side 0 - 1 diff --git a/fggl/debug/CMakeLists.txt b/fggl/debug/CMakeLists.txt index 10fb3421bb6f13ab353af3acdbe881373a1abee6..d2d4e1ce2dce81e01e0539aa91045b3782dec460 100644 --- a/fggl/debug/CMakeLists.txt +++ b/fggl/debug/CMakeLists.txt @@ -1,8 +1,8 @@ target_sources(fggl - PRIVATE - debug.cpp - debug_draw.cpp -) + PRIVATE + debug.cpp + debug_draw.cpp + ) # spdlog for cleaner logging find_package(spdlog) diff --git a/fggl/debug/debug.cpp b/fggl/debug/debug.cpp index c516435d29d22876530f67e23ff8ce2991f3bae2..b6e2a317e611fef42e52108cafb0970e12a27fa8 100644 --- a/fggl/debug/debug.cpp +++ b/fggl/debug/debug.cpp @@ -20,11 +20,11 @@ using fggl::debug::DebugUI; -DebugUI::DebugUI(std::shared_ptr<fggl::display::glfw::Window>& win) : m_visible(false) { +DebugUI::DebugUI(std::shared_ptr<fggl::display::glfw::Window> &win) : m_visible(false) { IMGUI_CHECKVERSION(); ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO &io = ImGui::GetIO(); io.IniFilename = nullptr; ImGui_ImplGlfw_InitForOpenGL(win->handle(), true); @@ -45,14 +45,14 @@ void DebugUI::frameStart() { } void DebugUI::draw() { - for ( auto& [name, data] : m_windows) { - if ( data.m_visible ) { - data.m_callback( &data.m_visible ); + for (auto &[name, data] : m_windows) { + if (data.m_visible) { + data.m_callback(&data.m_visible); } } ImGui::Render(); - if ( m_visible ) { + if (m_visible) { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); } } diff --git a/fggl/debug/imgui/CMakeLists.txt b/fggl/debug/imgui/CMakeLists.txt index bf16014476d66bb74c63074be23998c42a13085c..ee681de921960a310d4cb09bca0259cde30840d5 100644 --- a/fggl/debug/imgui/CMakeLists.txt +++ b/fggl/debug/imgui/CMakeLists.txt @@ -1,12 +1,12 @@ target_link_libraries(fggl PRIVATE imgui) -target_sources( fggl - PRIVATE +target_sources(fggl + PRIVATE imgui_impl_glfw.cpp imgui_impl_opengl3.cpp -) + ) -target_include_directories( fggl - PRIVATE +target_include_directories(fggl + PRIVATE include/ -) \ No newline at end of file + ) \ No newline at end of file diff --git a/fggl/debug/imgui/imgui_impl_glfw.cpp b/fggl/debug/imgui/imgui_impl_glfw.cpp index 072b66a3c62eb61941e93ff4f687e5a9617a5f41..e4a652a18999c59e3222d7cd2c25c5bfb9beb83f 100644 --- a/fggl/debug/imgui/imgui_impl_glfw.cpp +++ b/fggl/debug/imgui/imgui_impl_glfw.cpp @@ -42,6 +42,7 @@ // GLFW #include <GLFW/glfw3.h> + #ifdef _WIN32 #undef APIENTRY #define GLFW_EXPOSE_NATIVE_WIN32 @@ -59,319 +60,296 @@ #endif // Data -enum GlfwClientApi -{ - GlfwClientApi_Unknown, - GlfwClientApi_OpenGL, - GlfwClientApi_Vulkan +enum GlfwClientApi { + GlfwClientApi_Unknown, + GlfwClientApi_OpenGL, + GlfwClientApi_Vulkan }; -static GLFWwindow* g_Window = NULL; // Main window -static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown; -static double g_Time = 0.0; -static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {}; -static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {}; -static bool g_InstalledCallbacks = false; +static GLFWwindow *g_Window = NULL; // Main window +static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown; +static double g_Time = 0.0; +static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {}; +static GLFWcursor *g_MouseCursors[ImGuiMouseCursor_COUNT] = {}; +static bool g_InstalledCallbacks = false; // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. -static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL; -static GLFWscrollfun g_PrevUserCallbackScroll = NULL; -static GLFWkeyfun g_PrevUserCallbackKey = NULL; -static GLFWcharfun g_PrevUserCallbackChar = NULL; - -static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data) -{ - return glfwGetClipboardString((GLFWwindow*)user_data); +static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL; +static GLFWscrollfun g_PrevUserCallbackScroll = NULL; +static GLFWkeyfun g_PrevUserCallbackKey = NULL; +static GLFWcharfun g_PrevUserCallbackChar = NULL; + +static const char *ImGui_ImplGlfw_GetClipboardText(void *user_data) { + return glfwGetClipboardString((GLFWwindow *) user_data); } -static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text) -{ - glfwSetClipboardString((GLFWwindow*)user_data, text); +static void ImGui_ImplGlfw_SetClipboardText(void *user_data, const char *text) { + glfwSetClipboardString((GLFWwindow *) user_data, text); } -void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) -{ - if (g_PrevUserCallbackMousebutton != NULL) - g_PrevUserCallbackMousebutton(window, button, action, mods); +void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { + if (g_PrevUserCallbackMousebutton != NULL) + g_PrevUserCallbackMousebutton(window, button, action, mods); - if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed)) - g_MouseJustPressed[button] = true; + if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed)) + g_MouseJustPressed[button] = true; } -void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) -{ - if (g_PrevUserCallbackScroll != NULL) - g_PrevUserCallbackScroll(window, xoffset, yoffset); +void ImGui_ImplGlfw_ScrollCallback(GLFWwindow *window, double xoffset, double yoffset) { + if (g_PrevUserCallbackScroll != NULL) + g_PrevUserCallbackScroll(window, xoffset, yoffset); - ImGuiIO& io = ImGui::GetIO(); - io.MouseWheelH += (float)xoffset; - io.MouseWheel += (float)yoffset; + ImGuiIO &io = ImGui::GetIO(); + io.MouseWheelH += (float) xoffset; + io.MouseWheel += (float) yoffset; } -void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - ImGuiIO& io = ImGui::GetIO(); - if (g_PrevUserCallbackKey != NULL && !io.WantCaptureKeyboard) - g_PrevUserCallbackKey(window, key, scancode, action, mods); - - if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)) - { - if (action == GLFW_PRESS) - io.KeysDown[key] = true; - if (action == GLFW_RELEASE) - io.KeysDown[key] = false; - } - - // Modifiers are not reliable across systems - io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; - io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; - io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; +void ImGui_ImplGlfw_KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { + ImGuiIO &io = ImGui::GetIO(); + if (g_PrevUserCallbackKey != NULL && !io.WantCaptureKeyboard) + g_PrevUserCallbackKey(window, key, scancode, action, mods); + + if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)) { + if (action == GLFW_PRESS) + io.KeysDown[key] = true; + if (action == GLFW_RELEASE) + io.KeysDown[key] = false; + } + + // Modifiers are not reliable across systems + io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; + io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; + io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; #ifdef _WIN32 - io.KeySuper = false; + io.KeySuper = false; #else - io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; + io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; #endif } -void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c) -{ - if (g_PrevUserCallbackChar != NULL) - g_PrevUserCallbackChar(window, c); +void ImGui_ImplGlfw_CharCallback(GLFWwindow *window, unsigned int c) { + if (g_PrevUserCallbackChar != NULL) + g_PrevUserCallbackChar(window, c); - ImGuiIO& io = ImGui::GetIO(); - io.AddInputCharacter(c); + ImGuiIO &io = ImGui::GetIO(); + io.AddInputCharacter(c); } -static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api) -{ - g_Window = window; - g_Time = 0.0; - - // Setup backend capabilities flags - ImGuiIO& io = ImGui::GetIO(); - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) - io.BackendPlatformName = "imgui_impl_glfw"; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. - io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; - io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; - io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; - io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; - io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; - io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; - io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; - io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; - io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; - io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; - io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; - io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; - io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; - io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; - io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; - io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; - io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; - io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; - - io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText; - io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText; - io.ClipboardUserData = g_Window; +static bool ImGui_ImplGlfw_Init(GLFWwindow *window, bool install_callbacks, GlfwClientApi client_api) { + g_Window = window; + g_Time = 0.0; + + // Setup backend capabilities flags + ImGuiIO &io = ImGui::GetIO(); + io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) + io.BackendFlags |= + ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) + io.BackendPlatformName = "imgui_impl_glfw"; + + // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. + io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; + io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; + io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; + io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; + io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; + io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; + io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; + io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; + io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; + io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; + io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; + io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; + io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; + io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; + io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; + io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; + io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; + io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; + io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; + io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; + io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; + io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; + + io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText; + io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText; + io.ClipboardUserData = g_Window; #if defined(_WIN32) - io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window); + io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window); #endif - // Create mouse cursors - // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist, - // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting. - // Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.) - GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL); - g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); - g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); + // Create mouse cursors + // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist, + // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting. + // Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.) + GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL); + g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); + g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); #if GLFW_HAS_NEW_CURSORS - g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR); - g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR); + g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR); #else - g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); + g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); #endif - glfwSetErrorCallback(prev_error_callback); - - // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. - g_PrevUserCallbackMousebutton = NULL; - g_PrevUserCallbackScroll = NULL; - g_PrevUserCallbackKey = NULL; - g_PrevUserCallbackChar = NULL; - if (install_callbacks) - { - g_InstalledCallbacks = true; - g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback); - g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback); - g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback); - g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); - } - - g_ClientApi = client_api; - return true; + glfwSetErrorCallback(prev_error_callback); + + // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. + g_PrevUserCallbackMousebutton = NULL; + g_PrevUserCallbackScroll = NULL; + g_PrevUserCallbackKey = NULL; + g_PrevUserCallbackChar = NULL; + if (install_callbacks) { + g_InstalledCallbacks = true; + g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback); + g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback); + g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback); + g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); + } + + g_ClientApi = client_api; + return true; } -bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL); +bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow *window, bool install_callbacks) { + return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL); } -bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); +bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow *window, bool install_callbacks) { + return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); } -bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown); +bool ImGui_ImplGlfw_InitForOther(GLFWwindow *window, bool install_callbacks) { + return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown); } -void ImGui_ImplGlfw_Shutdown() -{ - if (g_InstalledCallbacks) - { - glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton); - glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll); - glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey); - glfwSetCharCallback(g_Window, g_PrevUserCallbackChar); - g_InstalledCallbacks = false; - } - - for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) - { - glfwDestroyCursor(g_MouseCursors[cursor_n]); - g_MouseCursors[cursor_n] = NULL; - } - g_ClientApi = GlfwClientApi_Unknown; +void ImGui_ImplGlfw_Shutdown() { + if (g_InstalledCallbacks) { + glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton); + glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll); + glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey); + glfwSetCharCallback(g_Window, g_PrevUserCallbackChar); + g_InstalledCallbacks = false; + } + + for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) { + glfwDestroyCursor(g_MouseCursors[cursor_n]); + g_MouseCursors[cursor_n] = NULL; + } + g_ClientApi = GlfwClientApi_Unknown; } -static void ImGui_ImplGlfw_UpdateMousePosAndButtons() -{ - // Update buttons - ImGuiIO& io = ImGui::GetIO(); - for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) - { - // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. - io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0; - g_MouseJustPressed[i] = false; - } - - // Update mouse position - const ImVec2 mouse_pos_backup = io.MousePos; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); +static void ImGui_ImplGlfw_UpdateMousePosAndButtons() { + // Update buttons + ImGuiIO &io = ImGui::GetIO(); + for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) { + // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. + io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0; + g_MouseJustPressed[i] = false; + } + + // Update mouse position + const ImVec2 mouse_pos_backup = io.MousePos; + io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); #ifdef __EMSCRIPTEN__ - const bool focused = true; // Emscripten + const bool focused = true; // Emscripten #else - const bool focused = glfwGetWindowAttrib(g_Window, GLFW_FOCUSED) != 0; + const bool focused = glfwGetWindowAttrib(g_Window, GLFW_FOCUSED) != 0; #endif - if (focused) - { - if (io.WantSetMousePos) - { - glfwSetCursorPos(g_Window, (double)mouse_pos_backup.x, (double)mouse_pos_backup.y); - } - else - { - double mouse_x, mouse_y; - glfwGetCursorPos(g_Window, &mouse_x, &mouse_y); - io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); - } - } + if (focused) { + if (io.WantSetMousePos) { + glfwSetCursorPos(g_Window, (double) mouse_pos_backup.x, (double) mouse_pos_backup.y); + } else { + double mouse_x, mouse_y; + glfwGetCursorPos(g_Window, &mouse_x, &mouse_y); + io.MousePos = ImVec2((float) mouse_x, (float) mouse_y); + } + } } -static void ImGui_ImplGlfw_UpdateMouseCursor() -{ - ImGuiIO& io = ImGui::GetIO(); - if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) - return; - - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - } - else - { - // Show OS mouse cursor - // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. - glfwSetCursor(g_Window, g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]); - glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } +static void ImGui_ImplGlfw_UpdateMouseCursor() { + ImGuiIO &io = ImGui::GetIO(); + if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) + || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) + return; + + ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); + if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) { + // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + } else { + // Show OS mouse cursor + // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. + glfwSetCursor(g_Window, + g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] + : g_MouseCursors[ImGuiMouseCursor_Arrow]); + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } } -static void ImGui_ImplGlfw_UpdateGamepads() -{ - ImGuiIO& io = ImGui::GetIO(); - memset(io.NavInputs, 0, sizeof(io.NavInputs)); - if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) - return; - - // Update gamepad inputs - #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; } - #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; } - int axes_count = 0, buttons_count = 0; - const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count); - const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count); - MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A - MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B - MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X - MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y - MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left - MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right - MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up - MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down - MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB - MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB - MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB - MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB - MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f); - MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f); - MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f); - MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f); - #undef MAP_BUTTON - #undef MAP_ANALOG - if (axes_count > 0 && buttons_count > 0) - io.BackendFlags |= ImGuiBackendFlags_HasGamepad; - else - io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; +static void ImGui_ImplGlfw_UpdateGamepads() { + ImGuiIO &io = ImGui::GetIO(); + memset(io.NavInputs, 0, sizeof(io.NavInputs)); + if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) + return; + + // Update gamepad inputs + #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; } + #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; } + int axes_count = 0, buttons_count = 0; + const float *axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count); + const unsigned char *buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count); + MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A + MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B + MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X + MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y + MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left + MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right + MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up + MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down + MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB + MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB + MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB + MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB + MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f); + MAP_ANALOG(ImGuiNavInput_LStickRight, 0, +0.3f, +0.9f); + MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f); + MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f); + #undef MAP_BUTTON + #undef MAP_ANALOG + if (axes_count > 0 && buttons_count > 0) + io.BackendFlags |= ImGuiBackendFlags_HasGamepad; + else + io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; } -void ImGui_ImplGlfw_NewFrame() -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); - - // Setup display size (every frame to accommodate for window resizing) - int w, h; - int display_w, display_h; - glfwGetWindowSize(g_Window, &w, &h); - glfwGetFramebufferSize(g_Window, &display_w, &display_h); - io.DisplaySize = ImVec2((float)w, (float)h); - if (w > 0 && h > 0) - io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); - - // Setup time step - double current_time = glfwGetTime(); - io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f); - g_Time = current_time; - - ImGui_ImplGlfw_UpdateMousePosAndButtons(); - ImGui_ImplGlfw_UpdateMouseCursor(); - - // Update game controllers (if enabled and available) - ImGui_ImplGlfw_UpdateGamepads(); +void ImGui_ImplGlfw_NewFrame() { + ImGuiIO &io = ImGui::GetIO(); + IM_ASSERT(io.Fonts->IsBuilt() + && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); + + // Setup display size (every frame to accommodate for window resizing) + int w, h; + int display_w, display_h; + glfwGetWindowSize(g_Window, &w, &h); + glfwGetFramebufferSize(g_Window, &display_w, &display_h); + io.DisplaySize = ImVec2((float) w, (float) h); + if (w > 0 && h > 0) + io.DisplayFramebufferScale = ImVec2((float) display_w / w, (float) display_h / h); + + // Setup time step + double current_time = glfwGetTime(); + io.DeltaTime = g_Time > 0.0 ? (float) (current_time - g_Time) : (float) (1.0f / 60.0f); + g_Time = current_time; + + ImGui_ImplGlfw_UpdateMousePosAndButtons(); + ImGui_ImplGlfw_UpdateMouseCursor(); + + // Update game controllers (if enabled and available) + ImGui_ImplGlfw_UpdateGamepads(); } diff --git a/fggl/debug/imgui/imgui_impl_opengl3.cpp b/fggl/debug/imgui/imgui_impl_opengl3.cpp index 790c2087c91fd26f0ce853497417466e6dcccee7..f5daed6a304cc467e947d8aad163ad468c1affa9 100644 --- a/fggl/debug/imgui/imgui_impl_opengl3.cpp +++ b/fggl/debug/imgui/imgui_impl_opengl3.cpp @@ -85,10 +85,12 @@ #include "imgui.h" #include "include/imgui_impl_opengl3.h" #include <stdio.h> + #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier #include <stddef.h> // intptr_t #else #include <stdint.h> // intptr_t + #endif // GL includes @@ -111,6 +113,7 @@ #include <GL/glew.h> // Needs to be initialized with glewInit() in user's code. #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) #include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code. + #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2) #include <glad/gl.h> // Needs to be initialized with gladLoadGL(...) or gladLoaderLoadGL() in user's code. #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) @@ -148,581 +151,657 @@ using namespace gl; #endif // OpenGL Data -static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2) -static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings. -static GLuint g_FontTexture = 0; -static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; -static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location -static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location +static GLuint g_GlVersion = + 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2) +static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings. +static GLuint g_FontTexture = 0; +static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; +static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location +static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, + g_AttribLocationVtxColor = 0; // Vertex attributes location static unsigned int g_VboHandle = 0, g_ElementsHandle = 0; // Functions -bool ImGui_ImplOpenGL3_Init(const char* glsl_version) -{ - // Query for GL version (e.g. 320 for GL 3.2) +bool ImGui_ImplOpenGL3_Init(const char *glsl_version) { + // Query for GL version (e.g. 320 for GL 3.2) #if !defined(IMGUI_IMPL_OPENGL_ES2) - GLint major = 0; - GLint minor = 0; - glGetIntegerv(GL_MAJOR_VERSION, &major); - glGetIntegerv(GL_MINOR_VERSION, &minor); - if (major == 0 && minor == 0) - { - // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>" - const char* gl_version = (const char*)glGetString(GL_VERSION); - sscanf(gl_version, "%d.%d", &major, &minor); - } - g_GlVersion = (GLuint)(major * 100 + minor * 10); + GLint major = 0; + GLint minor = 0; + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + if (major == 0 && minor == 0) { + // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>" + const char *gl_version = (const char *) glGetString(GL_VERSION); + sscanf(gl_version, "%d.%d", &major, &minor); + } + g_GlVersion = (GLuint) (major * 100 + minor * 10); #else - g_GlVersion = 200; // GLES 2 + g_GlVersion = 200; // GLES 2 #endif - // Setup backend capabilities flags - ImGuiIO& io = ImGui::GetIO(); - io.BackendRendererName = "imgui_impl_opengl3"; + // Setup backend capabilities flags + ImGuiIO &io = ImGui::GetIO(); + io.BackendRendererName = "imgui_impl_opengl3"; #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET - if (g_GlVersion >= 320) - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. + if (g_GlVersion >= 320) + io.BackendFlags |= + ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. #endif - // Store GLSL version string so we can refer to it later in case we recreate shaders. - // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure. + // Store GLSL version string so we can refer to it later in case we recreate shaders. + // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure. #if defined(IMGUI_IMPL_OPENGL_ES2) - if (glsl_version == NULL) - glsl_version = "#version 100"; + if (glsl_version == NULL) + glsl_version = "#version 100"; #elif defined(IMGUI_IMPL_OPENGL_ES3) - if (glsl_version == NULL) - glsl_version = "#version 300 es"; + if (glsl_version == NULL) + glsl_version = "#version 300 es"; #elif defined(__APPLE__) - if (glsl_version == NULL) - glsl_version = "#version 150"; + if (glsl_version == NULL) + glsl_version = "#version 150"; #else - if (glsl_version == NULL) - glsl_version = "#version 130"; -#endif - IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString)); - strcpy(g_GlslVersionString, glsl_version); - strcat(g_GlslVersionString, "\n"); - - // Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected. - // The code actually never uses the 'gl_loader' variable! It is only here so you can read it! - // If auto-detection fails or doesn't select the same GL loader file as used by your application, - // you are likely to get a crash below. - // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. - const char* gl_loader = "Unknown"; - IM_UNUSED(gl_loader); + if (glsl_version == NULL) + glsl_version = "#version 130"; +#endif + IM_ASSERT((int) strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString)); + strcpy(g_GlslVersionString, glsl_version); + strcat(g_GlslVersionString, "\n"); + + // Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected. + // The code actually never uses the 'gl_loader' variable! It is only here so you can read it! + // If auto-detection fails or doesn't select the same GL loader file as used by your application, + // you are likely to get a crash below. + // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. + const char *gl_loader = "Unknown"; + IM_UNUSED(gl_loader); #if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) - gl_loader = "GL3W"; + gl_loader = "GL3W"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) - gl_loader = "GLEW"; + gl_loader = "GLEW"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) - gl_loader = "GLAD"; + gl_loader = "GLAD"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2) - gl_loader = "GLAD2"; + gl_loader = "GLAD2"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) - gl_loader = "glbinding2"; + gl_loader = "glbinding2"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) - gl_loader = "glbinding3"; + gl_loader = "glbinding3"; #elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) - gl_loader = "custom"; + gl_loader = "custom"; #else - gl_loader = "none"; + gl_loader = "none"; #endif - // Make an arbitrary GL call (we don't actually need the result) - // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code. - // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above. - GLint current_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); + // Make an arbitrary GL call (we don't actually need the result) + // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code. + // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above. + GLint current_texture; + glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); - return true; + return true; } -void ImGui_ImplOpenGL3_Shutdown() -{ - ImGui_ImplOpenGL3_DestroyDeviceObjects(); +void ImGui_ImplOpenGL3_Shutdown() { + ImGui_ImplOpenGL3_DestroyDeviceObjects(); } -void ImGui_ImplOpenGL3_NewFrame() -{ - if (!g_ShaderHandle) - ImGui_ImplOpenGL3_CreateDeviceObjects(); +void ImGui_ImplOpenGL3_NewFrame() { + if (!g_ShaderHandle) + ImGui_ImplOpenGL3_CreateDeviceObjects(); } -static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object) -{ - // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glEnable(GL_SCISSOR_TEST); +static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData *draw_data, + int fb_width, + int fb_height, + GLuint vertex_array_object) { + // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glEnable(GL_SCISSOR_TEST); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - if (g_GlVersion >= 310) - glDisable(GL_PRIMITIVE_RESTART); + if (g_GlVersion >= 310) + glDisable(GL_PRIMITIVE_RESTART); #endif #ifdef GL_POLYGON_MODE - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); #endif - // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT) + // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT) #if defined(GL_CLIP_ORIGIN) - bool clip_origin_lower_left = true; - if (g_GlVersion >= 450) - { - GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin); - if (current_clip_origin == GL_UPPER_LEFT) - clip_origin_lower_left = false; - } -#endif - - // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; + bool clip_origin_lower_left = true; + if (g_GlVersion >= 450) { + GLenum current_clip_origin = 0; + glGetIntegerv(GL_CLIP_ORIGIN, (GLint *) ¤t_clip_origin); + if (current_clip_origin == GL_UPPER_LEFT) + clip_origin_lower_left = false; + } +#endif + + // Setup viewport, orthographic projection matrix + // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. + glViewport(0, 0, (GLsizei) fb_width, (GLsizei) fb_height); + float L = draw_data->DisplayPos.x; + float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; + float T = draw_data->DisplayPos.y; + float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; #if defined(GL_CLIP_ORIGIN) - if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left -#endif - const float ortho_projection[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, -1.0f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f }, - }; - glUseProgram(g_ShaderHandle); - glUniform1i(g_AttribLocationTex, 0); - glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); + if (!clip_origin_lower_left) { + float tmp = T; + T = B; + B = tmp; + } // Swap top and bottom if origin is upper left +#endif + const float ortho_projection[4][4] = + { + {2.0f / (R - L), 0.0f, 0.0f, 0.0f}, + {0.0f, 2.0f / (T - B), 0.0f, 0.0f}, + {0.0f, 0.0f, -1.0f, 0.0f}, + {(R + L) / (L - R), (T + B) / (B - T), 0.0f, 1.0f}, + }; + glUseProgram(g_ShaderHandle); + glUniform1i(g_AttribLocationTex, 0); + glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - if (g_GlVersion >= 330) - glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise. + if (g_GlVersion >= 330) + glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise. #endif - (void)vertex_array_object; + (void) vertex_array_object; #ifndef IMGUI_IMPL_OPENGL_ES2 - glBindVertexArray(vertex_array_object); -#endif - - // Bind vertex/index buffers and setup attributes for ImDrawVert - glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle); - glEnableVertexAttribArray(g_AttribLocationVtxPos); - glEnableVertexAttribArray(g_AttribLocationVtxUV); - glEnableVertexAttribArray(g_AttribLocationVtxColor); - glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos)); - glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv)); - glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col)); + glBindVertexArray(vertex_array_object); +#endif + + // Bind vertex/index buffers and setup attributes for ImDrawVert + glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle); + glEnableVertexAttribArray(g_AttribLocationVtxPos); + glEnableVertexAttribArray(g_AttribLocationVtxUV); + glEnableVertexAttribArray(g_AttribLocationVtxColor); + glVertexAttribPointer(g_AttribLocationVtxPos, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(ImDrawVert), + (GLvoid *) IM_OFFSETOF(ImDrawVert, pos)); + glVertexAttribPointer(g_AttribLocationVtxUV, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(ImDrawVert), + (GLvoid *) IM_OFFSETOF(ImDrawVert, uv)); + glVertexAttribPointer(g_AttribLocationVtxColor, + 4, + GL_UNSIGNED_BYTE, + GL_TRUE, + sizeof(ImDrawVert), + (GLvoid *) IM_OFFSETOF(ImDrawVert, col)); } // OpenGL3 Render function. // Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. // This is in order to be able to run within an OpenGL engine that doesn't do so. -void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); - int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); - if (fb_width <= 0 || fb_height <= 0) - return; - - // Backup GL state - GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture); - glActiveTexture(GL_TEXTURE0); - GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program); - GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture); +void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData *draw_data) { + // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) + int fb_width = (int) (draw_data->DisplaySize.x * draw_data->FramebufferScale.x); + int fb_height = (int) (draw_data->DisplaySize.y * draw_data->FramebufferScale.y); + if (fb_width <= 0 || fb_height <= 0) + return; + + // Backup GL state + GLenum last_active_texture; + glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *) &last_active_texture); + glActiveTexture(GL_TEXTURE0); + GLuint last_program; + glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *) &last_program); + GLuint last_texture; + glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *) &last_texture); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - GLuint last_sampler; if (g_GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; } -#endif - GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer); + GLuint last_sampler; + if (g_GlVersion >= 330) { + glGetIntegerv(GL_SAMPLER_BINDING, (GLint *) &last_sampler); + } else { + last_sampler = 0; + } +#endif + GLuint last_array_buffer; + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint *) &last_array_buffer); #ifndef IMGUI_IMPL_OPENGL_ES2 - GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object); + GLuint last_vertex_array_object; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint *) &last_vertex_array_object); #endif #ifdef GL_POLYGON_MODE - GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); -#endif - GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); - GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); - GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb); - GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb); - GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha); - GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha); - GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb); - GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha); - GLboolean last_enable_blend = glIsEnabled(GL_BLEND); - GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE); - GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST); - GLboolean last_enable_stencil_test = glIsEnabled(GL_STENCIL_TEST); - GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST); + GLint last_polygon_mode[2]; + glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); +#endif + GLint last_viewport[4]; + glGetIntegerv(GL_VIEWPORT, last_viewport); + GLint last_scissor_box[4]; + glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); + GLenum last_blend_src_rgb; + glGetIntegerv(GL_BLEND_SRC_RGB, (GLint *) &last_blend_src_rgb); + GLenum last_blend_dst_rgb; + glGetIntegerv(GL_BLEND_DST_RGB, (GLint *) &last_blend_dst_rgb); + GLenum last_blend_src_alpha; + glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint *) &last_blend_src_alpha); + GLenum last_blend_dst_alpha; + glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint *) &last_blend_dst_alpha); + GLenum last_blend_equation_rgb; + glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint *) &last_blend_equation_rgb); + GLenum last_blend_equation_alpha; + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint *) &last_blend_equation_alpha); + GLboolean last_enable_blend = glIsEnabled(GL_BLEND); + GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE); + GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST); + GLboolean last_enable_stencil_test = glIsEnabled(GL_STENCIL_TEST); + GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - GLboolean last_enable_primitive_restart = (g_GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE; + GLboolean last_enable_primitive_restart = (g_GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE; #endif - // Setup desired GL state - // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts) - // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound. - GLuint vertex_array_object = 0; + // Setup desired GL state + // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts) + // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound. + GLuint vertex_array_object = 0; #ifndef IMGUI_IMPL_OPENGL_ES2 - glGenVertexArrays(1, &vertex_array_object); -#endif - ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - - // Render command lists - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - - // Upload vertex/index buffers - glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec4 clip_rect; - clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x; - clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y; - clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x; - clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y; - - if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) - { - // Apply scissor/clipping rectangle - glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y)); - - // Bind texture, Draw - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()); + glGenVertexArrays(1, &vertex_array_object); +#endif + ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); + + // Will project scissor/clipping rectangles into framebuffer space + ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports + ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) + + // Render command lists + for (int n = 0; n < draw_data->CmdListsCount; n++) { + const ImDrawList *cmd_list = draw_data->CmdLists[n]; + + // Upload vertex/index buffers + glBufferData(GL_ARRAY_BUFFER, + (GLsizeiptr) cmd_list->VtxBuffer.Size * (int) sizeof(ImDrawVert), + (const GLvoid *) cmd_list->VtxBuffer.Data, + GL_STREAM_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, + (GLsizeiptr) cmd_list->IdxBuffer.Size * (int) sizeof(ImDrawIdx), + (const GLvoid *) cmd_list->IdxBuffer.Data, + GL_STREAM_DRAW); + + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) { + const ImDrawCmd *pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback != NULL) { + // User callback, registered via ImDrawList::AddCallback() + // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) + if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) + ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); + else + pcmd->UserCallback(cmd_list, pcmd); + } else { + // Project scissor/clipping rectangles into framebuffer space + ImVec4 clip_rect; + clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x; + clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y; + clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x; + clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y; + + if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) { + // Apply scissor/clipping rectangle + glScissor((int) clip_rect.x, + (int) (fb_height - clip_rect.w), + (int) (clip_rect.z - clip_rect.x), + (int) (clip_rect.w - clip_rect.y)); + + // Bind texture, Draw + glBindTexture(GL_TEXTURE_2D, (GLuint) (intptr_t) pcmd->GetTexID()); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET - if (g_GlVersion >= 320) - glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset); - else -#endif - glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))); - } - } - } - } - - // Destroy the temporary VAO + if (g_GlVersion >= 320) + glDrawElementsBaseVertex(GL_TRIANGLES, + (GLsizei) pcmd->ElemCount, + sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, + (void *) (intptr_t) (pcmd->IdxOffset * sizeof(ImDrawIdx)), + (GLint) pcmd->VtxOffset); + else +#endif + glDrawElements(GL_TRIANGLES, + (GLsizei) pcmd->ElemCount, + sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, + (void *) (intptr_t) (pcmd->IdxOffset * sizeof(ImDrawIdx))); + } + } + } + } + + // Destroy the temporary VAO #ifndef IMGUI_IMPL_OPENGL_ES2 - glDeleteVertexArrays(1, &vertex_array_object); + glDeleteVertexArrays(1, &vertex_array_object); #endif - // Restore modified GL state - glUseProgram(last_program); - glBindTexture(GL_TEXTURE_2D, last_texture); + // Restore modified GL state + glUseProgram(last_program); + glBindTexture(GL_TEXTURE_2D, last_texture); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - if (g_GlVersion >= 330) - glBindSampler(0, last_sampler); + if (g_GlVersion >= 330) + glBindSampler(0, last_sampler); #endif - glActiveTexture(last_active_texture); + glActiveTexture(last_active_texture); #ifndef IMGUI_IMPL_OPENGL_ES2 - glBindVertexArray(last_vertex_array_object); -#endif - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); - glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); - glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha); - if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); - if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); - if (last_enable_stencil_test) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); - if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); + glBindVertexArray(last_vertex_array_object); +#endif + glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); + glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); + glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha); + if (last_enable_blend) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + if (last_enable_cull_face) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + if (last_enable_depth_test) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + if (last_enable_stencil_test) + glEnable(GL_STENCIL_TEST); + else + glDisable(GL_STENCIL_TEST); + if (last_enable_scissor_test) + glEnable(GL_SCISSOR_TEST); + else + glDisable(GL_SCISSOR_TEST); #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - if (g_GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); } + if (g_GlVersion >= 310) { + if (last_enable_primitive_restart) + glEnable(GL_PRIMITIVE_RESTART); + else + glDisable(GL_PRIMITIVE_RESTART); + } #endif #ifdef GL_POLYGON_MODE - glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); + glPolygonMode(GL_FRONT_AND_BACK, (GLenum) last_polygon_mode[0]); #endif - glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); - glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); + glViewport(last_viewport[0], last_viewport[1], (GLsizei) last_viewport[2], (GLsizei) last_viewport[3]); + glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei) last_scissor_box[2], (GLsizei) last_scissor_box[3]); } -bool ImGui_ImplOpenGL3_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. - - // Upload texture to graphics system - GLint last_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGenTextures(1, &g_FontTexture); - glBindTexture(GL_TEXTURE_2D, g_FontTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +bool ImGui_ImplOpenGL3_CreateFontsTexture() { + // Build texture atlas + ImGuiIO &io = ImGui::GetIO(); + unsigned char *pixels; + int width, height; + io.Fonts->GetTexDataAsRGBA32(&pixels, + &width, + &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. + + // Upload texture to graphics system + GLint last_texture; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); + glGenTextures(1, &g_FontTexture); + glBindTexture(GL_TEXTURE_2D, g_FontTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); #ifdef GL_UNPACK_ROW_LENGTH - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #endif - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - // Store our identifier - io.Fonts->SetTexID((ImTextureID)(intptr_t)g_FontTexture); + // Store our identifier + io.Fonts->SetTexID((ImTextureID) (intptr_t) g_FontTexture); - // Restore state - glBindTexture(GL_TEXTURE_2D, last_texture); + // Restore state + glBindTexture(GL_TEXTURE_2D, last_texture); - return true; + return true; } -void ImGui_ImplOpenGL3_DestroyFontsTexture() -{ - if (g_FontTexture) - { - ImGuiIO& io = ImGui::GetIO(); - glDeleteTextures(1, &g_FontTexture); - io.Fonts->SetTexID(0); - g_FontTexture = 0; - } +void ImGui_ImplOpenGL3_DestroyFontsTexture() { + if (g_FontTexture) { + ImGuiIO &io = ImGui::GetIO(); + glDeleteTextures(1, &g_FontTexture); + io.Fonts->SetTexID(0); + g_FontTexture = 0; + } } // If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file. -static bool CheckShader(GLuint handle, const char* desc) -{ - GLint status = 0, log_length = 0; - glGetShaderiv(handle, GL_COMPILE_STATUS, &status); - glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length); - if ((GLboolean)status == GL_FALSE) - fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc); - if (log_length > 1) - { - ImVector<char> buf; - buf.resize((int)(log_length + 1)); - glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - fprintf(stderr, "%s\n", buf.begin()); - } - return (GLboolean)status == GL_TRUE; +static bool CheckShader(GLuint handle, const char *desc) { + GLint status = 0, log_length = 0; + glGetShaderiv(handle, GL_COMPILE_STATUS, &status); + glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length); + if ((GLboolean) status == GL_FALSE) + fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc); + if (log_length > 1) { + ImVector<char> buf; + buf.resize((int) (log_length + 1)); + glGetShaderInfoLog(handle, log_length, NULL, (GLchar *) buf.begin()); + fprintf(stderr, "%s\n", buf.begin()); + } + return (GLboolean) status == GL_TRUE; } // If you get an error please report on GitHub. You may try different GL context version or GLSL version. -static bool CheckProgram(GLuint handle, const char* desc) -{ - GLint status = 0, log_length = 0; - glGetProgramiv(handle, GL_LINK_STATUS, &status); - glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length); - if ((GLboolean)status == GL_FALSE) - fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString); - if (log_length > 1) - { - ImVector<char> buf; - buf.resize((int)(log_length + 1)); - glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - fprintf(stderr, "%s\n", buf.begin()); - } - return (GLboolean)status == GL_TRUE; +static bool CheckProgram(GLuint handle, const char *desc) { + GLint status = 0, log_length = 0; + glGetProgramiv(handle, GL_LINK_STATUS, &status); + glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length); + if ((GLboolean) status == GL_FALSE) + fprintf(stderr, + "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", + desc, + g_GlslVersionString); + if (log_length > 1) { + ImVector<char> buf; + buf.resize((int) (log_length + 1)); + glGetProgramInfoLog(handle, log_length, NULL, (GLchar *) buf.begin()); + fprintf(stderr, "%s\n", buf.begin()); + } + return (GLboolean) status == GL_TRUE; } -bool ImGui_ImplOpenGL3_CreateDeviceObjects() -{ - // Backup GL state - GLint last_texture, last_array_buffer; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); +bool ImGui_ImplOpenGL3_CreateDeviceObjects() { + // Backup GL state + GLint last_texture, last_array_buffer; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); #ifndef IMGUI_IMPL_OPENGL_ES2 - GLint last_vertex_array; - glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); -#endif - - // Parse GLSL version string - int glsl_version = 130; - sscanf(g_GlslVersionString, "#version %d", &glsl_version); - - const GLchar* vertex_shader_glsl_120 = - "uniform mat4 ProjMtx;\n" - "attribute vec2 Position;\n" - "attribute vec2 UV;\n" - "attribute vec4 Color;\n" - "varying vec2 Frag_UV;\n" - "varying vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_130 = - "uniform mat4 ProjMtx;\n" - "in vec2 Position;\n" - "in vec2 UV;\n" - "in vec4 Color;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_300_es = - "precision mediump float;\n" - "layout (location = 0) in vec2 Position;\n" - "layout (location = 1) in vec2 UV;\n" - "layout (location = 2) in vec4 Color;\n" - "uniform mat4 ProjMtx;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_410_core = - "layout (location = 0) in vec2 Position;\n" - "layout (location = 1) in vec2 UV;\n" - "layout (location = 2) in vec4 Color;\n" - "uniform mat4 ProjMtx;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_120 = - "#ifdef GL_ES\n" - " precision mediump float;\n" - "#endif\n" - "uniform sampler2D Texture;\n" - "varying vec2 Frag_UV;\n" - "varying vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_130 = - "uniform sampler2D Texture;\n" - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_300_es = - "precision mediump float;\n" - "uniform sampler2D Texture;\n" - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "layout (location = 0) out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_410_core = - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "uniform sampler2D Texture;\n" - "layout (location = 0) out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - // Select shaders matching our GLSL versions - const GLchar* vertex_shader = NULL; - const GLchar* fragment_shader = NULL; - if (glsl_version < 130) - { - vertex_shader = vertex_shader_glsl_120; - fragment_shader = fragment_shader_glsl_120; - } - else if (glsl_version >= 410) - { - vertex_shader = vertex_shader_glsl_410_core; - fragment_shader = fragment_shader_glsl_410_core; - } - else if (glsl_version == 300) - { - vertex_shader = vertex_shader_glsl_300_es; - fragment_shader = fragment_shader_glsl_300_es; - } - else - { - vertex_shader = vertex_shader_glsl_130; - fragment_shader = fragment_shader_glsl_130; - } - - // Create shaders - const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader }; - g_VertHandle = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL); - glCompileShader(g_VertHandle); - CheckShader(g_VertHandle, "vertex shader"); - - const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader }; - g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL); - glCompileShader(g_FragHandle); - CheckShader(g_FragHandle, "fragment shader"); - - g_ShaderHandle = glCreateProgram(); - glAttachShader(g_ShaderHandle, g_VertHandle); - glAttachShader(g_ShaderHandle, g_FragHandle); - glLinkProgram(g_ShaderHandle); - CheckProgram(g_ShaderHandle, "shader program"); - - g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture"); - g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx"); - g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position"); - g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV"); - g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color"); - - // Create buffers - glGenBuffers(1, &g_VboHandle); - glGenBuffers(1, &g_ElementsHandle); - - ImGui_ImplOpenGL3_CreateFontsTexture(); - - // Restore modified GL state - glBindTexture(GL_TEXTURE_2D, last_texture); - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); + GLint last_vertex_array; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); +#endif + + // Parse GLSL version string + int glsl_version = 130; + sscanf(g_GlslVersionString, "#version %d", &glsl_version); + + const GLchar *vertex_shader_glsl_120 = + "uniform mat4 ProjMtx;\n" + "attribute vec2 Position;\n" + "attribute vec2 UV;\n" + "attribute vec4 Color;\n" + "varying vec2 Frag_UV;\n" + "varying vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" + "}\n"; + + const GLchar *vertex_shader_glsl_130 = + "uniform mat4 ProjMtx;\n" + "in vec2 Position;\n" + "in vec2 UV;\n" + "in vec4 Color;\n" + "out vec2 Frag_UV;\n" + "out vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" + "}\n"; + + const GLchar *vertex_shader_glsl_300_es = + "precision mediump float;\n" + "layout (location = 0) in vec2 Position;\n" + "layout (location = 1) in vec2 UV;\n" + "layout (location = 2) in vec4 Color;\n" + "uniform mat4 ProjMtx;\n" + "out vec2 Frag_UV;\n" + "out vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" + "}\n"; + + const GLchar *vertex_shader_glsl_410_core = + "layout (location = 0) in vec2 Position;\n" + "layout (location = 1) in vec2 UV;\n" + "layout (location = 2) in vec4 Color;\n" + "uniform mat4 ProjMtx;\n" + "out vec2 Frag_UV;\n" + "out vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" + "}\n"; + + const GLchar *fragment_shader_glsl_120 = + "#ifdef GL_ES\n" + " precision mediump float;\n" + "#endif\n" + "uniform sampler2D Texture;\n" + "varying vec2 Frag_UV;\n" + "varying vec4 Frag_Color;\n" + "void main()\n" + "{\n" + " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n" + "}\n"; + + const GLchar *fragment_shader_glsl_130 = + "uniform sampler2D Texture;\n" + "in vec2 Frag_UV;\n" + "in vec4 Frag_Color;\n" + "out vec4 Out_Color;\n" + "void main()\n" + "{\n" + " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" + "}\n"; + + const GLchar *fragment_shader_glsl_300_es = + "precision mediump float;\n" + "uniform sampler2D Texture;\n" + "in vec2 Frag_UV;\n" + "in vec4 Frag_Color;\n" + "layout (location = 0) out vec4 Out_Color;\n" + "void main()\n" + "{\n" + " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" + "}\n"; + + const GLchar *fragment_shader_glsl_410_core = + "in vec2 Frag_UV;\n" + "in vec4 Frag_Color;\n" + "uniform sampler2D Texture;\n" + "layout (location = 0) out vec4 Out_Color;\n" + "void main()\n" + "{\n" + " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" + "}\n"; + + // Select shaders matching our GLSL versions + const GLchar *vertex_shader = NULL; + const GLchar *fragment_shader = NULL; + if (glsl_version < 130) { + vertex_shader = vertex_shader_glsl_120; + fragment_shader = fragment_shader_glsl_120; + } else if (glsl_version >= 410) { + vertex_shader = vertex_shader_glsl_410_core; + fragment_shader = fragment_shader_glsl_410_core; + } else if (glsl_version == 300) { + vertex_shader = vertex_shader_glsl_300_es; + fragment_shader = fragment_shader_glsl_300_es; + } else { + vertex_shader = vertex_shader_glsl_130; + fragment_shader = fragment_shader_glsl_130; + } + + // Create shaders + const GLchar *vertex_shader_with_version[2] = {g_GlslVersionString, vertex_shader}; + g_VertHandle = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL); + glCompileShader(g_VertHandle); + CheckShader(g_VertHandle, "vertex shader"); + + const GLchar *fragment_shader_with_version[2] = {g_GlslVersionString, fragment_shader}; + g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL); + glCompileShader(g_FragHandle); + CheckShader(g_FragHandle, "fragment shader"); + + g_ShaderHandle = glCreateProgram(); + glAttachShader(g_ShaderHandle, g_VertHandle); + glAttachShader(g_ShaderHandle, g_FragHandle); + glLinkProgram(g_ShaderHandle); + CheckProgram(g_ShaderHandle, "shader program"); + + g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture"); + g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx"); + g_AttribLocationVtxPos = (GLuint) glGetAttribLocation(g_ShaderHandle, "Position"); + g_AttribLocationVtxUV = (GLuint) glGetAttribLocation(g_ShaderHandle, "UV"); + g_AttribLocationVtxColor = (GLuint) glGetAttribLocation(g_ShaderHandle, "Color"); + + // Create buffers + glGenBuffers(1, &g_VboHandle); + glGenBuffers(1, &g_ElementsHandle); + + ImGui_ImplOpenGL3_CreateFontsTexture(); + + // Restore modified GL state + glBindTexture(GL_TEXTURE_2D, last_texture); + glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); #ifndef IMGUI_IMPL_OPENGL_ES2 - glBindVertexArray(last_vertex_array); + glBindVertexArray(last_vertex_array); #endif - return true; + return true; } -void ImGui_ImplOpenGL3_DestroyDeviceObjects() -{ - if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; } - if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; } - if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); } - if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); } - if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; } - if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; } - if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; } - - ImGui_ImplOpenGL3_DestroyFontsTexture(); +void ImGui_ImplOpenGL3_DestroyDeviceObjects() { + if (g_VboHandle) { + glDeleteBuffers(1, &g_VboHandle); + g_VboHandle = 0; + } + if (g_ElementsHandle) { + glDeleteBuffers(1, &g_ElementsHandle); + g_ElementsHandle = 0; + } + if (g_ShaderHandle && g_VertHandle) { + glDetachShader(g_ShaderHandle, g_VertHandle); + } + if (g_ShaderHandle && g_FragHandle) { + glDetachShader(g_ShaderHandle, g_FragHandle); + } + if (g_VertHandle) { + glDeleteShader(g_VertHandle); + g_VertHandle = 0; + } + if (g_FragHandle) { + glDeleteShader(g_FragHandle); + g_FragHandle = 0; + } + if (g_ShaderHandle) { + glDeleteProgram(g_ShaderHandle); + g_ShaderHandle = 0; + } + + ImGui_ImplOpenGL3_DestroyFontsTexture(); } diff --git a/fggl/debug/imgui/include/imgui_impl_glfw.h b/fggl/debug/imgui/include/imgui_impl_glfw.h index 018f1a1ee6c316b8f8d6e2379ea2299a072f37c2..20348cc36320c3d8b2ae6f2a5a6fe82d53fbf3b1 100644 --- a/fggl/debug/imgui/include/imgui_impl_glfw.h +++ b/fggl/debug/imgui/include/imgui_impl_glfw.h @@ -21,16 +21,16 @@ struct GLFWwindow; -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); +IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow *window, bool install_callbacks); +IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow *window, bool install_callbacks); +IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow *window, bool install_callbacks); +IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); // GLFW callbacks // - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any. // - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks. -IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); -IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); -IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); -IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); +IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); +IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow *window, double xoffset, double yoffset); +IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); +IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow *window, unsigned int c); diff --git a/fggl/debug/imgui/include/imgui_impl_opengl3.h b/fggl/debug/imgui/include/imgui_impl_opengl3.h index 8c0126d865bc29d902f3fb1cd3ca84a58f1bd802..90fa1ad5e4ffe068e8865b1e1a270aad4cfb9e37 100644 --- a/fggl/debug/imgui/include/imgui_impl_opengl3.h +++ b/fggl/debug/imgui/include/imgui_impl_opengl3.h @@ -25,16 +25,16 @@ #include "imgui.h" // IMGUI_IMPL_API // Backend API -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); +IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char *glsl_version = NULL); +IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); +IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData *draw_data); // (Optional) Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); +IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); +IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); +IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); +IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); // Specific OpenGL ES versions //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten @@ -66,22 +66,22 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); // Otherwise try to detect supported Desktop OpenGL loaders.. #elif defined(__has_include) #if __has_include(<GL/glew.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GLEW + #define IMGUI_IMPL_OPENGL_LOADER_GLEW #elif __has_include(<glad/glad.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GLAD + #define IMGUI_IMPL_OPENGL_LOADER_GLAD #elif __has_include(<glad/gl.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GLAD2 + #define IMGUI_IMPL_OPENGL_LOADER_GLAD2 #elif __has_include(<GL/gl3w.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GL3W + #define IMGUI_IMPL_OPENGL_LOADER_GL3W #elif __has_include(<glbinding/glbinding.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3 + #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3 #elif __has_include(<glbinding/Binding.h>) - #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2 + #define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2 #else - #error "Cannot detect OpenGL loader!" + #error "Cannot detect OpenGL loader!" #endif #else - #define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository + #define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository #endif #endif diff --git a/fggl/entity/CMakeLists.txt b/fggl/entity/CMakeLists.txt index d1ab8fe68c683cb013bf9878117713459d9eb81c..3e8f1858a17b4cd077dc72874f1180060724a70b 100644 --- a/fggl/entity/CMakeLists.txt +++ b/fggl/entity/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(fggl - PRIVATE + PRIVATE loader/loader.cpp module.cpp -) + ) diff --git a/fggl/entity/loader/loader.cpp b/fggl/entity/loader/loader.cpp index 362e1cca1065117def19e32c7e1ea30797b971f9..316aae5a809e9a090584b2d49461d3a0af180008 100644 --- a/fggl/entity/loader/loader.cpp +++ b/fggl/entity/loader/loader.cpp @@ -21,26 +21,26 @@ namespace fggl::entity { - assets::AssetRefRaw load_prototype(EntityFactory* factory, const assets::AssetGUID& guid, assets::AssetData data) { - auto* filePath = std::get<assets::AssetPath*>(data); + assets::AssetRefRaw load_prototype(EntityFactory *factory, const assets::AssetGUID &guid, assets::AssetData data) { + auto *filePath = std::get<assets::AssetPath *>(data); // We need to process the prototypes, and load them into the asset system. - auto nodes = YAML::LoadAllFromFile( filePath->c_str() ); - for (const auto& node : nodes) { + auto nodes = YAML::LoadAllFromFile(filePath->c_str()); + for (const auto &node : nodes) { auto prefabs = node["prefabs"]; - for ( const auto& prefab : prefabs ) { + for (const auto &prefab : prefabs) { auto name = prefab["name"].as<fggl::util::GUID>(); #ifndef NDEBUG - debug::info("found prefab: {}", fggl::util::guidToString(name) ); + debug::info("found prefab: {}", fggl::util::guidToString(name)); #endif // set up the components EntitySpec entity{}; entity.parent = prefab["parent"].as<fggl::util::GUID>(NO_PARENT); - for (const auto& compEntry : prefab["components"]) { + for (const auto &compEntry : prefab["components"]) { auto compId = compEntry.first.as<fggl::util::GUID>(); ComponentSpec compSpec{}; @@ -49,11 +49,13 @@ namespace fggl::entity { entity.ordering.push_back(compId); #ifndef NDEBUG - debug::trace("{} has component {}", fggl::util::guidToString(name), fggl::util::guidToString(compId)); + debug::trace("{} has component {}", + fggl::util::guidToString(name), + fggl::util::guidToString(compId)); #endif } - factory->define( name, entity ); + factory->define(name, entity); } } diff --git a/fggl/entity/module.cpp b/fggl/entity/module.cpp index 7efd1ec871460f68a12e165000224d24f847059d..c2936f4845db8d90227f61bb14b61212efe4a6fd 100644 --- a/fggl/entity/module.cpp +++ b/fggl/entity/module.cpp @@ -21,28 +21,29 @@ namespace fggl::entity { - void make_transform(const entity::ComponentSpec& spec, EntityManager& manager, const entity::EntityID entity){ - auto& transform = manager.add<math::Transform>(entity); - transform.origin( spec.get<math::vec3>( "origin", math::VEC3_ZERO ) ); - transform.euler( spec.get<math::vec3>( "rotation", math::VEC3_ZERO ) ); - transform.scale( spec.get<math::vec3>( "scale", math::VEC3_ONES ) ); + void make_transform(const entity::ComponentSpec &spec, EntityManager &manager, const entity::EntityID entity) { + auto &transform = manager.add<math::Transform>(entity); + transform.origin(spec.get<math::vec3>("origin", math::VEC3_ZERO)); + transform.euler(spec.get<math::vec3>("rotation", math::VEC3_ZERO)); + transform.scale(spec.get<math::vec3>("scale", math::VEC3_ONES)); - debug::trace("created transform for entity {}", (uint64_t)entity); + debug::trace("created transform for entity {}", (uint64_t) entity); } - void install_component_factories(entity::EntityFactory* factory) { + void install_component_factories(entity::EntityFactory *factory) { factory->bind(math::Transform::guid, make_transform); } - bool ECS::factory(modules::ModuleService service, modules::Services& services) { - if ( service == EntityFactory::service) { - auto* factory = services.create<EntityFactory>(); + bool ECS::factory(modules::ModuleService service, modules::Services &services) { + if (service == EntityFactory::service) { + auto *factory = services.create<EntityFactory>(); install_component_factories(factory); // we are responsible for prefabs... - auto* assetLoader = services.get<assets::Loader>(); - assetLoader->setFactory(PROTOTYPE_ASSET, [factory](const assets::AssetGUID& a, assets::AssetData b) { - return load_prototype(factory, a, b); }, assets::LoadType::PATH ); + auto *assetLoader = services.get<assets::Loader>(); + assetLoader->setFactory(PROTOTYPE_ASSET, [factory](const assets::AssetGUID &a, assets::AssetData b) { + return load_prototype(factory, a, b); + }, assets::LoadType::PATH); return true; } diff --git a/fggl/gfx/CMakeLists.txt b/fggl/gfx/CMakeLists.txt index cfc7512c40558f6bf0f6a43fdd31953c429597bd..44428bb61043052738e309a9f0a498ab9fbb310c 100644 --- a/fggl/gfx/CMakeLists.txt +++ b/fggl/gfx/CMakeLists.txt @@ -1,6 +1,6 @@ # Sources -find_package( glfw3 REQUIRED ) +find_package(glfw3 REQUIRED) include(CMakePrintHelpers) cmake_print_variables(GLFW_TARGETS) @@ -8,11 +8,11 @@ cmake_print_variables(GLFW_TARGETS) target_link_libraries(fggl PUBLIC glfw fggl-glad) target_sources(fggl - PRIVATE - window.cpp - input.cpp + PRIVATE + window.cpp + input.cpp atlas.cpp -) + ) # OpenGL backend add_subdirectory(ogl) diff --git a/fggl/gfx/atlas.cpp b/fggl/gfx/atlas.cpp index 22d9a4f5d65f43359312a5b21f9cf72e730664ca..a8a7132073d586f45846664bbc7eb4deb6457908 100644 --- a/fggl/gfx/atlas.cpp +++ b/fggl/gfx/atlas.cpp @@ -25,57 +25,56 @@ using Query = std::vector<fggl::gfx::Bounds2D>; -static void populate_stbrp_query(Query& query, std::vector<stbrp_rect>& data) { - for ( std::size_t i = 0; i < query.size(); i++ ) { - data.push_back({ - (int)i, - query[i].size.x, - query[i].size.y, - 0, - 0, - 0 - }); - } +static void populate_stbrp_query(Query &query, std::vector<stbrp_rect> &data) { + for (std::size_t i = 0; i < query.size(); i++) { + data.push_back({ + (int) i, + query[i].size.x, + query[i].size.y, + 0, + 0, + 0 + }); + } } -static void unpack_stbrp_query(Query& query, std::vector<stbrp_rect>& data) { - for( const auto& rect : data ) { - query[ rect.id ].pos = { rect.x, rect.y }; - } +static void unpack_stbrp_query(Query &query, std::vector<stbrp_rect> &data) { + for (const auto &rect : data) { + query[rect.id].pos = {rect.x, rect.y}; + } } -bool pack_iter(int width, int height, std::vector<stbrp_rect>& query) { - stbrp_node* tmp = new stbrp_node[width]; +bool pack_iter(int width, int height, std::vector<stbrp_rect> &query) { + stbrp_node *tmp = new stbrp_node[width]; - // setup context - stbrp_context context; - stbrp_init_target( &context, width, height, tmp, width ); + // setup context + stbrp_context context; + stbrp_init_target(&context, width, height, tmp, width); - // see if it worked - auto result = stbrp_pack_rects( &context, query.data(), query.size() ); - return result == 1; + // see if it worked + auto result = stbrp_pack_rects(&context, query.data(), query.size()); + return result == 1; } namespace fggl::gfx { - - bool pack(std::vector<Bounds2D>& pack){ - // setup query structure - std::vector<stbrp_rect> query; - query.reserve( pack.size() ); - populate_stbrp_query(pack, query); - - // try packing into powers of 2, starting with 32, up to 4096 - for ( int i=5; i <= 12; i++ ) { - int dim = i * i; - if ( pack_iter(dim, dim, query) ) { - unpack_stbrp_query(pack, query); - return true; - } - } - - return false; - } + bool pack(std::vector<Bounds2D> &pack) { + // setup query structure + std::vector<stbrp_rect> query; + query.reserve(pack.size()); + populate_stbrp_query(pack, query); + + // try packing into powers of 2, starting with 32, up to 4096 + for (int i = 5; i <= 12; i++) { + int dim = i * i; + if (pack_iter(dim, dim, query)) { + unpack_stbrp_query(pack, query); + return true; + } + } + + return false; + } } // namespace fggl::gfx diff --git a/fggl/gfx/input.cpp b/fggl/gfx/input.cpp index 3ec89409690764764449fc22c69026793f555654..ac35a9aef013b492cddf8a1d794e682f75fa12fd 100644 --- a/fggl/gfx/input.cpp +++ b/fggl/gfx/input.cpp @@ -34,10 +34,10 @@ void Input::clear() { m_mouse_last = m_mouse_curr; // reset pad data - for ( auto& pad : m_pad_curr ) { + for (auto &pad : m_pad_curr) { pad.present = false; pad.buttons.reset(); - for (float & axe : pad.axes){ + for (float &axe : pad.axes) { axe = 0.0F; } } @@ -65,7 +65,7 @@ double Input::cursorDeltaY() const { return m_mouse_last.cursor[1] - m_mouse_curr.cursor[1]; } -const double* Input::mousePos() const { +const double *Input::mousePos() const { return m_mouse_curr.scroll.data(); } @@ -74,7 +74,7 @@ void Input::mouseScroll(double deltaX, double deltaY) { m_mouse_curr.scroll[1] = deltaY; } -const double* Input::mouseScroll() const { +const double *Input::mouseScroll() const { return m_mouse_curr.scroll.data(); } @@ -87,7 +87,7 @@ double Input::scrollDeltaY() const { } void Input::mouseBtn(const MouseButton btn, bool state) { - if ( state ) { + if (state) { m_mouse_curr.buttons |= btn; } else { m_mouse_curr.buttons &= ~btn; @@ -106,13 +106,13 @@ bool Input::mouseReleased(const MouseButton btn) const { return !(m_mouse_curr.buttons & btn) && (m_mouse_last.buttons & btn); } -void Input::joystickConnect(int id, Joystick &data){ +void Input::joystickConnect(int id, Joystick &data) { // joystick data is polled, so we need to call this every frame >.< m_joysticks[id] = true; m_joydata[id] = data; } -void Input::joystickDisconnect( int id ){ +void Input::joystickDisconnect(int id) { // reset to empty joystick m_joysticks[id] = false; m_joydata[id] = Joystick(); @@ -122,30 +122,30 @@ bool Input::hasJoystick(int id) const { return m_joysticks[id]; } -const fggl::gfx::Joystick& Input::joystick(int id) const { +const fggl::gfx::Joystick &Input::joystick(int id) const { return m_joydata[id]; } -void Input::padState(int id, const PadState& state) { +void Input::padState(int id, const PadState &state) { m_pad_curr[id] = state; } bool Input::padDown(int id, PadButton btn) { - return m_pad_curr[id].buttons[(int)btn]; + return m_pad_curr[id].buttons[(int) btn]; } bool Input::padPressed(int id, PadButton btn) { - return m_pad_curr[id].buttons[(int)btn] && !m_pad_last[id].buttons[(int)btn]; + return m_pad_curr[id].buttons[(int) btn] && !m_pad_last[id].buttons[(int) btn]; } bool Input::padReleased(int id, PadButton btn) { - return !m_pad_curr[id].buttons[(int)btn] && m_pad_last[id].buttons[(int)btn]; + return !m_pad_curr[id].buttons[(int) btn] && m_pad_last[id].buttons[(int) btn]; } float Input::padAxis(int id, PadAxis axis) { - return m_pad_curr[id].axes[(int)axis]; + return m_pad_curr[id].axes[(int) axis]; } float Input::padAxisDelta(int id, PadAxis axis) { - return m_pad_last[id].axes[(int)axis] - m_pad_curr[id].axes[(int)axis]; + return m_pad_last[id].axes[(int) axis] - m_pad_curr[id].axes[(int) axis]; } diff --git a/fggl/gfx/ogl/CMakeLists.txt b/fggl/gfx/ogl/CMakeLists.txt index da1e4ad74501bc8acdea889cd3782d400ec1f048..02180aec41dcd3b4f5781d17217abe7c9802775a 100644 --- a/fggl/gfx/ogl/CMakeLists.txt +++ b/fggl/gfx/ogl/CMakeLists.txt @@ -1,21 +1,21 @@ # Sources target_sources(fggl - PRIVATE - glad.c - backend.cpp - shader.cpp - renderer.cpp - types.cpp -) + PRIVATE + glad.c + backend.cpp + shader.cpp + renderer.cpp + types.cpp + ) # OpenGL Backend -find_package( OpenGL REQUIRED ) -if ( MSVC ) - target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::GL) -else() - target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::OpenGL) -endif() +find_package(OpenGL REQUIRED) +if (MSVC) + target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::GL) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::OpenGL) +endif () # FreeType diff --git a/fggl/gfx/ogl/glad.c b/fggl/gfx/ogl/glad.c index 8c77df344b1b418d0d99445ada3f83c0413cab0a..5c315dcdc0ac90eeb37bce84d4ff71724f51e8ee 100644 --- a/fggl/gfx/ogl/glad.c +++ b/fggl/gfx/ogl/glad.c @@ -26,44 +26,48 @@ #include <glad/glad.h> void _pre_call_callback_default_gl(const char *name, void *funcptr, int len_args, ...) { - (void) name; - (void) funcptr; - (void) len_args; + (void) name; + (void) funcptr; + (void) len_args; } + void _post_call_callback_default_gl(const char *name, void *funcptr, int len_args, ...) { - GLenum error_code; + GLenum error_code; - (void) funcptr; - (void) len_args; + (void) funcptr; + (void) len_args; - error_code = glad_glGetError(); + error_code = glad_glGetError(); - if (error_code != GL_NO_ERROR) { - fprintf(stderr, "ERROR %d in %s\n", error_code, name); - } + if (error_code != GL_NO_ERROR) { + fprintf(stderr, "ERROR %d in %s\n", error_code, name); + } } static GLADcallback _pre_call_callback_gl = _pre_call_callback_default_gl; + void glad_set_pre_callback_gl(GLADcallback cb) { - _pre_call_callback_gl = cb; + _pre_call_callback_gl = cb; } static GLADcallback _post_call_callback_gl = _post_call_callback_default_gl; + void glad_set_post_callback_gl(GLADcallback cb) { - _post_call_callback_gl = cb; + _post_call_callback_gl = cb; } void glad_set_pre_callback(GLADcallback cb) { - glad_set_pre_callback_gl(cb); + glad_set_pre_callback_gl(cb); } + void glad_set_post_callback(GLADcallback cb) { - glad_set_post_callback_gl(cb); + glad_set_post_callback_gl(cb); } -static void* get_proc(const char *namez); +static void *get_proc(const char *namez); #if defined(_WIN32) || defined(__CYGWIN__) -#ifndef _WINDOWS_ + #ifndef _WINDOWS_ #undef APIENTRY #endif #include <windows.h> @@ -113,86 +117,89 @@ void close_gl(void) { } #else #include <dlfcn.h> -static void* libGL; + +static void *libGL; #if !defined(__APPLE__) && !defined(__HAIKU__) -typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*); +typedef void *(APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char *); static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; #endif static int open_gl(void) { #ifdef __APPLE__ - static const char *NAMES[] = { + static const char *NAMES[] = { "../Frameworks/OpenGL.framework/OpenGL", "/Library/Frameworks/OpenGL.framework/OpenGL", "/System/Library/Frameworks/OpenGL.framework/OpenGL", "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL" }; #else - static const char *NAMES[] = {"libGL.so.1", "libGL.so"}; + static const char *NAMES[] = {"libGL.so.1", "libGL.so"}; #endif - unsigned int index = 0; - for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) { - libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL); + unsigned int index = 0; + for (index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) { + libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL); - if(libGL != NULL) { + if (libGL != NULL) { #if defined(__APPLE__) || defined(__HAIKU__) - return 1; + return 1; #else - gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL, - "glXGetProcAddressARB"); - return gladGetProcAddressPtr != NULL; + gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE) dlsym(libGL, + "glXGetProcAddressARB"); + return gladGetProcAddressPtr != NULL; #endif - } - } + } + } - return 0; + return 0; } static void close_gl(void) { - if(libGL != NULL) { - dlclose(libGL); - libGL = NULL; - } + if (libGL != NULL) { + dlclose(libGL); + libGL = NULL; + } } + #endif static -void* get_proc(const char *namez) { - void* result = NULL; - if(libGL == NULL) return NULL; +void *get_proc(const char *namez) { + void *result = NULL; + if (libGL == NULL) + return NULL; #if !defined(__APPLE__) && !defined(__HAIKU__) - if(gladGetProcAddressPtr != NULL) { - result = gladGetProcAddressPtr(namez); - } + if (gladGetProcAddressPtr != NULL) { + result = gladGetProcAddressPtr(namez); + } #endif - if(result == NULL) { + if (result == NULL) { #if defined(_WIN32) || defined(__CYGWIN__) - result = (void*)GetProcAddress((HMODULE) libGL, namez); + result = (void*)GetProcAddress((HMODULE) libGL, namez); #else - result = dlsym(libGL, namez); + result = dlsym(libGL, namez); #endif - } + } - return result; + return result; } int gladLoadGL(void) { - int status = 0; + int status = 0; - if(open_gl()) { - status = gladLoadGLLoader(&get_proc); - close_gl(); - } + if (open_gl()) { + status = gladLoadGLLoader(&get_proc); + close_gl(); + } - return status; + return status; } -struct gladGLversionStruct GLVersion = { 0, 0 }; +struct gladGLversionStruct GLVersion = {0, 0}; #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) #define _GLAD_IS_SOME_NEW_VERSION 1 @@ -207,90 +214,92 @@ static char **exts_i = NULL; static int get_exts(void) { #ifdef _GLAD_IS_SOME_NEW_VERSION - if(max_loaded_major < 3) { + if (max_loaded_major < 3) { #endif - exts = (const char *)glGetString(GL_EXTENSIONS); + exts = (const char *) glGetString(GL_EXTENSIONS); #ifdef _GLAD_IS_SOME_NEW_VERSION - } else { - unsigned int index; - - num_exts_i = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i); - if (num_exts_i > 0) { - exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i)); - } - - if (exts_i == NULL) { - return 0; - } - - for(index = 0; index < (unsigned)num_exts_i; index++) { - const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index); - size_t len = strlen(gl_str_tmp); - - char *local_str = (char*)malloc((len+1) * sizeof(char)); - if(local_str != NULL) { - memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char)); - } - exts_i[index] = local_str; - } - } + } else { + unsigned int index; + + num_exts_i = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i); + if (num_exts_i > 0) { + exts_i = (char **) malloc((size_t) num_exts_i * (sizeof *exts_i)); + } + + if (exts_i == NULL) { + return 0; + } + + for (index = 0; index < (unsigned) num_exts_i; index++) { + const char *gl_str_tmp = (const char *) glGetStringi(GL_EXTENSIONS, index); + size_t len = strlen(gl_str_tmp); + + char *local_str = (char *) malloc((len + 1) * sizeof(char)); + if (local_str != NULL) { + memcpy(local_str, gl_str_tmp, (len + 1) * sizeof(char)); + } + exts_i[index] = local_str; + } + } #endif - return 1; + return 1; } static void free_exts(void) { - if (exts_i != NULL) { - int index; - for(index = 0; index < num_exts_i; index++) { - free((char *)exts_i[index]); - } - free((void *)exts_i); - exts_i = NULL; - } + if (exts_i != NULL) { + int index; + for (index = 0; index < num_exts_i; index++) { + free((char *) exts_i[index]); + } + free((void *) exts_i); + exts_i = NULL; + } } static int has_ext(const char *ext) { #ifdef _GLAD_IS_SOME_NEW_VERSION - if(max_loaded_major < 3) { + if (max_loaded_major < 3) { #endif - const char *extensions; - const char *loc; - const char *terminator; - extensions = exts; - if(extensions == NULL || ext == NULL) { - return 0; - } - - while(1) { - loc = strstr(extensions, ext); - if(loc == NULL) { - return 0; - } - - terminator = loc + strlen(ext); - if((loc == extensions || *(loc - 1) == ' ') && - (*terminator == ' ' || *terminator == '\0')) { - return 1; - } - extensions = terminator; - } + const char *extensions; + const char *loc; + const char *terminator; + extensions = exts; + if (extensions == NULL || ext == NULL) { + return 0; + } + + while (1) { + loc = strstr(extensions, ext); + if (loc == NULL) { + return 0; + } + + terminator = loc + strlen(ext); + if ((loc == extensions || *(loc - 1) == ' ') && + (*terminator == ' ' || *terminator == '\0')) { + return 1; + } + extensions = terminator; + } #ifdef _GLAD_IS_SOME_NEW_VERSION - } else { - int index; - if(exts_i == NULL) return 0; - for(index = 0; index < num_exts_i; index++) { - const char *e = exts_i[index]; - - if(exts_i[index] != NULL && strcmp(e, ext) == 0) { - return 1; - } - } - } + } else { + int index; + if (exts_i == NULL) + return 0; + for (index = 0; index < num_exts_i; index++) { + const char *e = exts_i[index]; + + if (exts_i[index] != NULL && strcmp(e, ext) == 0) { + return 1; + } + } + } #endif - return 0; + return 0; } + int GLAD_GL_VERSION_1_0 = 0; int GLAD_GL_VERSION_1_1 = 0; int GLAD_GL_VERSION_1_2 = 0; @@ -310,6428 +319,10617 @@ int GLAD_GL_VERSION_4_3 = 0; int GLAD_GL_VERSION_4_4 = 0; int GLAD_GL_VERSION_4_5 = 0; PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram; -void APIENTRY glad_debug_impl_glActiveShaderProgram(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glActiveShaderProgram", (void*)glActiveShaderProgram, 2, arg0, arg1); - glad_glActiveShaderProgram(arg0, arg1); - _post_call_callback_gl("glActiveShaderProgram", (void*)glActiveShaderProgram, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glActiveShaderProgram(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glActiveShaderProgram", (void *) glActiveShaderProgram, 2, arg0, arg1); + glad_glActiveShaderProgram(arg0, arg1); + _post_call_callback_gl("glActiveShaderProgram", (void *) glActiveShaderProgram, 2, arg0, arg1); + } + PFNGLACTIVESHADERPROGRAMPROC glad_debug_glActiveShaderProgram = glad_debug_impl_glActiveShaderProgram; PFNGLACTIVETEXTUREPROC glad_glActiveTexture; -void APIENTRY glad_debug_impl_glActiveTexture(GLenum arg0) { - _pre_call_callback_gl("glActiveTexture", (void*)glActiveTexture, 1, arg0); - glad_glActiveTexture(arg0); - _post_call_callback_gl("glActiveTexture", (void*)glActiveTexture, 1, arg0); - + +void APIENTRY glad_debug_impl_glActiveTexture(GLenum arg0) { + _pre_call_callback_gl("glActiveTexture", (void *) glActiveTexture, 1, arg0); + glad_glActiveTexture(arg0); + _post_call_callback_gl("glActiveTexture", (void *) glActiveTexture, 1, arg0); + } + PFNGLACTIVETEXTUREPROC glad_debug_glActiveTexture = glad_debug_impl_glActiveTexture; PFNGLATTACHSHADERPROC glad_glAttachShader; -void APIENTRY glad_debug_impl_glAttachShader(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glAttachShader", (void*)glAttachShader, 2, arg0, arg1); - glad_glAttachShader(arg0, arg1); - _post_call_callback_gl("glAttachShader", (void*)glAttachShader, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glAttachShader(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glAttachShader", (void *) glAttachShader, 2, arg0, arg1); + glad_glAttachShader(arg0, arg1); + _post_call_callback_gl("glAttachShader", (void *) glAttachShader, 2, arg0, arg1); + } + PFNGLATTACHSHADERPROC glad_debug_glAttachShader = glad_debug_impl_glAttachShader; PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender; -void APIENTRY glad_debug_impl_glBeginConditionalRender(GLuint arg0, GLenum arg1) { - _pre_call_callback_gl("glBeginConditionalRender", (void*)glBeginConditionalRender, 2, arg0, arg1); - glad_glBeginConditionalRender(arg0, arg1); - _post_call_callback_gl("glBeginConditionalRender", (void*)glBeginConditionalRender, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBeginConditionalRender(GLuint arg0, GLenum arg1) { + _pre_call_callback_gl("glBeginConditionalRender", (void *) glBeginConditionalRender, 2, arg0, arg1); + glad_glBeginConditionalRender(arg0, arg1); + _post_call_callback_gl("glBeginConditionalRender", (void *) glBeginConditionalRender, 2, arg0, arg1); + } + PFNGLBEGINCONDITIONALRENDERPROC glad_debug_glBeginConditionalRender = glad_debug_impl_glBeginConditionalRender; PFNGLBEGINQUERYPROC glad_glBeginQuery; -void APIENTRY glad_debug_impl_glBeginQuery(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBeginQuery", (void*)glBeginQuery, 2, arg0, arg1); - glad_glBeginQuery(arg0, arg1); - _post_call_callback_gl("glBeginQuery", (void*)glBeginQuery, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBeginQuery(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBeginQuery", (void *) glBeginQuery, 2, arg0, arg1); + glad_glBeginQuery(arg0, arg1); + _post_call_callback_gl("glBeginQuery", (void *) glBeginQuery, 2, arg0, arg1); + } + PFNGLBEGINQUERYPROC glad_debug_glBeginQuery = glad_debug_impl_glBeginQuery; PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed; -void APIENTRY glad_debug_impl_glBeginQueryIndexed(GLenum arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glBeginQueryIndexed", (void*)glBeginQueryIndexed, 3, arg0, arg1, arg2); - glad_glBeginQueryIndexed(arg0, arg1, arg2); - _post_call_callback_gl("glBeginQueryIndexed", (void*)glBeginQueryIndexed, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBeginQueryIndexed(GLenum arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glBeginQueryIndexed", (void *) glBeginQueryIndexed, 3, arg0, arg1, arg2); + glad_glBeginQueryIndexed(arg0, arg1, arg2); + _post_call_callback_gl("glBeginQueryIndexed", (void *) glBeginQueryIndexed, 3, arg0, arg1, arg2); + } + PFNGLBEGINQUERYINDEXEDPROC glad_debug_glBeginQueryIndexed = glad_debug_impl_glBeginQueryIndexed; PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback; -void APIENTRY glad_debug_impl_glBeginTransformFeedback(GLenum arg0) { - _pre_call_callback_gl("glBeginTransformFeedback", (void*)glBeginTransformFeedback, 1, arg0); - glad_glBeginTransformFeedback(arg0); - _post_call_callback_gl("glBeginTransformFeedback", (void*)glBeginTransformFeedback, 1, arg0); - + +void APIENTRY glad_debug_impl_glBeginTransformFeedback(GLenum arg0) { + _pre_call_callback_gl("glBeginTransformFeedback", (void *) glBeginTransformFeedback, 1, arg0); + glad_glBeginTransformFeedback(arg0); + _post_call_callback_gl("glBeginTransformFeedback", (void *) glBeginTransformFeedback, 1, arg0); + } + PFNGLBEGINTRANSFORMFEEDBACKPROC glad_debug_glBeginTransformFeedback = glad_debug_impl_glBeginTransformFeedback; PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation; -void APIENTRY glad_debug_impl_glBindAttribLocation(GLuint arg0, GLuint arg1, const GLchar * arg2) { - _pre_call_callback_gl("glBindAttribLocation", (void*)glBindAttribLocation, 3, arg0, arg1, arg2); - glad_glBindAttribLocation(arg0, arg1, arg2); - _post_call_callback_gl("glBindAttribLocation", (void*)glBindAttribLocation, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindAttribLocation(GLuint arg0, GLuint arg1, const GLchar *arg2) { + _pre_call_callback_gl("glBindAttribLocation", (void *) glBindAttribLocation, 3, arg0, arg1, arg2); + glad_glBindAttribLocation(arg0, arg1, arg2); + _post_call_callback_gl("glBindAttribLocation", (void *) glBindAttribLocation, 3, arg0, arg1, arg2); + } + PFNGLBINDATTRIBLOCATIONPROC glad_debug_glBindAttribLocation = glad_debug_impl_glBindAttribLocation; PFNGLBINDBUFFERPROC glad_glBindBuffer; -void APIENTRY glad_debug_impl_glBindBuffer(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBindBuffer", (void*)glBindBuffer, 2, arg0, arg1); - glad_glBindBuffer(arg0, arg1); - _post_call_callback_gl("glBindBuffer", (void*)glBindBuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindBuffer(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBindBuffer", (void *) glBindBuffer, 2, arg0, arg1); + glad_glBindBuffer(arg0, arg1); + _post_call_callback_gl("glBindBuffer", (void *) glBindBuffer, 2, arg0, arg1); + } + PFNGLBINDBUFFERPROC glad_debug_glBindBuffer = glad_debug_impl_glBindBuffer; PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase; -void APIENTRY glad_debug_impl_glBindBufferBase(GLenum arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glBindBufferBase", (void*)glBindBufferBase, 3, arg0, arg1, arg2); - glad_glBindBufferBase(arg0, arg1, arg2); - _post_call_callback_gl("glBindBufferBase", (void*)glBindBufferBase, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindBufferBase(GLenum arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glBindBufferBase", (void *) glBindBufferBase, 3, arg0, arg1, arg2); + glad_glBindBufferBase(arg0, arg1, arg2); + _post_call_callback_gl("glBindBufferBase", (void *) glBindBufferBase, 3, arg0, arg1, arg2); + } + PFNGLBINDBUFFERBASEPROC glad_debug_glBindBufferBase = glad_debug_impl_glBindBufferBase; PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange; -void APIENTRY glad_debug_impl_glBindBufferRange(GLenum arg0, GLuint arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glBindBufferRange", (void*)glBindBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - glad_glBindBufferRange(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glBindBufferRange", (void*)glBindBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glBindBufferRange(GLenum arg0, GLuint arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { + _pre_call_callback_gl("glBindBufferRange", (void *) glBindBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + glad_glBindBufferRange(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glBindBufferRange", (void *) glBindBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLBINDBUFFERRANGEPROC glad_debug_glBindBufferRange = glad_debug_impl_glBindBufferRange; PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase; -void APIENTRY glad_debug_impl_glBindBuffersBase(GLenum arg0, GLuint arg1, GLsizei arg2, const GLuint * arg3) { - _pre_call_callback_gl("glBindBuffersBase", (void*)glBindBuffersBase, 4, arg0, arg1, arg2, arg3); - glad_glBindBuffersBase(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBindBuffersBase", (void*)glBindBuffersBase, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBindBuffersBase(GLenum arg0, GLuint arg1, GLsizei arg2, const GLuint *arg3) { + _pre_call_callback_gl("glBindBuffersBase", (void *) glBindBuffersBase, 4, arg0, arg1, arg2, arg3); + glad_glBindBuffersBase(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBindBuffersBase", (void *) glBindBuffersBase, 4, arg0, arg1, arg2, arg3); + } + PFNGLBINDBUFFERSBASEPROC glad_debug_glBindBuffersBase = glad_debug_impl_glBindBuffersBase; PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange; -void APIENTRY glad_debug_impl_glBindBuffersRange(GLenum arg0, GLuint arg1, GLsizei arg2, const GLuint * arg3, const GLintptr * arg4, const GLsizeiptr * arg5) { - _pre_call_callback_gl("glBindBuffersRange", (void*)glBindBuffersRange, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glBindBuffersRange(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glBindBuffersRange", (void*)glBindBuffersRange, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glBindBuffersRange(GLenum arg0, + GLuint arg1, + GLsizei arg2, + const GLuint *arg3, + const GLintptr *arg4, + const GLsizeiptr *arg5) { + _pre_call_callback_gl("glBindBuffersRange", (void *) glBindBuffersRange, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glBindBuffersRange(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glBindBuffersRange", (void *) glBindBuffersRange, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLBINDBUFFERSRANGEPROC glad_debug_glBindBuffersRange = glad_debug_impl_glBindBuffersRange; PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation; -void APIENTRY glad_debug_impl_glBindFragDataLocation(GLuint arg0, GLuint arg1, const GLchar * arg2) { - _pre_call_callback_gl("glBindFragDataLocation", (void*)glBindFragDataLocation, 3, arg0, arg1, arg2); - glad_glBindFragDataLocation(arg0, arg1, arg2); - _post_call_callback_gl("glBindFragDataLocation", (void*)glBindFragDataLocation, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindFragDataLocation(GLuint arg0, GLuint arg1, const GLchar *arg2) { + _pre_call_callback_gl("glBindFragDataLocation", (void *) glBindFragDataLocation, 3, arg0, arg1, arg2); + glad_glBindFragDataLocation(arg0, arg1, arg2); + _post_call_callback_gl("glBindFragDataLocation", (void *) glBindFragDataLocation, 3, arg0, arg1, arg2); + } + PFNGLBINDFRAGDATALOCATIONPROC glad_debug_glBindFragDataLocation = glad_debug_impl_glBindFragDataLocation; PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed; -void APIENTRY glad_debug_impl_glBindFragDataLocationIndexed(GLuint arg0, GLuint arg1, GLuint arg2, const GLchar * arg3) { - _pre_call_callback_gl("glBindFragDataLocationIndexed", (void*)glBindFragDataLocationIndexed, 4, arg0, arg1, arg2, arg3); - glad_glBindFragDataLocationIndexed(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBindFragDataLocationIndexed", (void*)glBindFragDataLocationIndexed, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBindFragDataLocationIndexed(GLuint arg0, GLuint arg1, GLuint arg2, const GLchar *arg3) { + _pre_call_callback_gl("glBindFragDataLocationIndexed", + (void *) glBindFragDataLocationIndexed, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glBindFragDataLocationIndexed(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBindFragDataLocationIndexed", + (void *) glBindFragDataLocationIndexed, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_debug_glBindFragDataLocationIndexed = glad_debug_impl_glBindFragDataLocationIndexed; + +PFNGLBINDFRAGDATALOCATIONINDEXEDPROC + glad_debug_glBindFragDataLocationIndexed = glad_debug_impl_glBindFragDataLocationIndexed; PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer; -void APIENTRY glad_debug_impl_glBindFramebuffer(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBindFramebuffer", (void*)glBindFramebuffer, 2, arg0, arg1); - glad_glBindFramebuffer(arg0, arg1); - _post_call_callback_gl("glBindFramebuffer", (void*)glBindFramebuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindFramebuffer(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBindFramebuffer", (void *) glBindFramebuffer, 2, arg0, arg1); + glad_glBindFramebuffer(arg0, arg1); + _post_call_callback_gl("glBindFramebuffer", (void *) glBindFramebuffer, 2, arg0, arg1); + } + PFNGLBINDFRAMEBUFFERPROC glad_debug_glBindFramebuffer = glad_debug_impl_glBindFramebuffer; PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture; -void APIENTRY glad_debug_impl_glBindImageTexture(GLuint arg0, GLuint arg1, GLint arg2, GLboolean arg3, GLint arg4, GLenum arg5, GLenum arg6) { - _pre_call_callback_gl("glBindImageTexture", (void*)glBindImageTexture, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glBindImageTexture(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glBindImageTexture", (void*)glBindImageTexture, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glBindImageTexture(GLuint arg0, + GLuint arg1, + GLint arg2, + GLboolean arg3, + GLint arg4, + GLenum arg5, + GLenum arg6) { + _pre_call_callback_gl("glBindImageTexture", + (void *) glBindImageTexture, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glBindImageTexture(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glBindImageTexture", + (void *) glBindImageTexture, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLBINDIMAGETEXTUREPROC glad_debug_glBindImageTexture = glad_debug_impl_glBindImageTexture; PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures; -void APIENTRY glad_debug_impl_glBindImageTextures(GLuint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glBindImageTextures", (void*)glBindImageTextures, 3, arg0, arg1, arg2); - glad_glBindImageTextures(arg0, arg1, arg2); - _post_call_callback_gl("glBindImageTextures", (void*)glBindImageTextures, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindImageTextures(GLuint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glBindImageTextures", (void *) glBindImageTextures, 3, arg0, arg1, arg2); + glad_glBindImageTextures(arg0, arg1, arg2); + _post_call_callback_gl("glBindImageTextures", (void *) glBindImageTextures, 3, arg0, arg1, arg2); + } + PFNGLBINDIMAGETEXTURESPROC glad_debug_glBindImageTextures = glad_debug_impl_glBindImageTextures; PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline; -void APIENTRY glad_debug_impl_glBindProgramPipeline(GLuint arg0) { - _pre_call_callback_gl("glBindProgramPipeline", (void*)glBindProgramPipeline, 1, arg0); - glad_glBindProgramPipeline(arg0); - _post_call_callback_gl("glBindProgramPipeline", (void*)glBindProgramPipeline, 1, arg0); - + +void APIENTRY glad_debug_impl_glBindProgramPipeline(GLuint arg0) { + _pre_call_callback_gl("glBindProgramPipeline", (void *) glBindProgramPipeline, 1, arg0); + glad_glBindProgramPipeline(arg0); + _post_call_callback_gl("glBindProgramPipeline", (void *) glBindProgramPipeline, 1, arg0); + } + PFNGLBINDPROGRAMPIPELINEPROC glad_debug_glBindProgramPipeline = glad_debug_impl_glBindProgramPipeline; PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer; -void APIENTRY glad_debug_impl_glBindRenderbuffer(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBindRenderbuffer", (void*)glBindRenderbuffer, 2, arg0, arg1); - glad_glBindRenderbuffer(arg0, arg1); - _post_call_callback_gl("glBindRenderbuffer", (void*)glBindRenderbuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindRenderbuffer(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBindRenderbuffer", (void *) glBindRenderbuffer, 2, arg0, arg1); + glad_glBindRenderbuffer(arg0, arg1); + _post_call_callback_gl("glBindRenderbuffer", (void *) glBindRenderbuffer, 2, arg0, arg1); + } + PFNGLBINDRENDERBUFFERPROC glad_debug_glBindRenderbuffer = glad_debug_impl_glBindRenderbuffer; PFNGLBINDSAMPLERPROC glad_glBindSampler; -void APIENTRY glad_debug_impl_glBindSampler(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glBindSampler", (void*)glBindSampler, 2, arg0, arg1); - glad_glBindSampler(arg0, arg1); - _post_call_callback_gl("glBindSampler", (void*)glBindSampler, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindSampler(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glBindSampler", (void *) glBindSampler, 2, arg0, arg1); + glad_glBindSampler(arg0, arg1); + _post_call_callback_gl("glBindSampler", (void *) glBindSampler, 2, arg0, arg1); + } + PFNGLBINDSAMPLERPROC glad_debug_glBindSampler = glad_debug_impl_glBindSampler; PFNGLBINDSAMPLERSPROC glad_glBindSamplers; -void APIENTRY glad_debug_impl_glBindSamplers(GLuint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glBindSamplers", (void*)glBindSamplers, 3, arg0, arg1, arg2); - glad_glBindSamplers(arg0, arg1, arg2); - _post_call_callback_gl("glBindSamplers", (void*)glBindSamplers, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindSamplers(GLuint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glBindSamplers", (void *) glBindSamplers, 3, arg0, arg1, arg2); + glad_glBindSamplers(arg0, arg1, arg2); + _post_call_callback_gl("glBindSamplers", (void *) glBindSamplers, 3, arg0, arg1, arg2); + } + PFNGLBINDSAMPLERSPROC glad_debug_glBindSamplers = glad_debug_impl_glBindSamplers; PFNGLBINDTEXTUREPROC glad_glBindTexture; -void APIENTRY glad_debug_impl_glBindTexture(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBindTexture", (void*)glBindTexture, 2, arg0, arg1); - glad_glBindTexture(arg0, arg1); - _post_call_callback_gl("glBindTexture", (void*)glBindTexture, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindTexture(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBindTexture", (void *) glBindTexture, 2, arg0, arg1); + glad_glBindTexture(arg0, arg1); + _post_call_callback_gl("glBindTexture", (void *) glBindTexture, 2, arg0, arg1); + } + PFNGLBINDTEXTUREPROC glad_debug_glBindTexture = glad_debug_impl_glBindTexture; PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit; -void APIENTRY glad_debug_impl_glBindTextureUnit(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glBindTextureUnit", (void*)glBindTextureUnit, 2, arg0, arg1); - glad_glBindTextureUnit(arg0, arg1); - _post_call_callback_gl("glBindTextureUnit", (void*)glBindTextureUnit, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindTextureUnit(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glBindTextureUnit", (void *) glBindTextureUnit, 2, arg0, arg1); + glad_glBindTextureUnit(arg0, arg1); + _post_call_callback_gl("glBindTextureUnit", (void *) glBindTextureUnit, 2, arg0, arg1); + } + PFNGLBINDTEXTUREUNITPROC glad_debug_glBindTextureUnit = glad_debug_impl_glBindTextureUnit; PFNGLBINDTEXTURESPROC glad_glBindTextures; -void APIENTRY glad_debug_impl_glBindTextures(GLuint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glBindTextures", (void*)glBindTextures, 3, arg0, arg1, arg2); - glad_glBindTextures(arg0, arg1, arg2); - _post_call_callback_gl("glBindTextures", (void*)glBindTextures, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBindTextures(GLuint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glBindTextures", (void *) glBindTextures, 3, arg0, arg1, arg2); + glad_glBindTextures(arg0, arg1, arg2); + _post_call_callback_gl("glBindTextures", (void *) glBindTextures, 3, arg0, arg1, arg2); + } + PFNGLBINDTEXTURESPROC glad_debug_glBindTextures = glad_debug_impl_glBindTextures; PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback; -void APIENTRY glad_debug_impl_glBindTransformFeedback(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glBindTransformFeedback", (void*)glBindTransformFeedback, 2, arg0, arg1); - glad_glBindTransformFeedback(arg0, arg1); - _post_call_callback_gl("glBindTransformFeedback", (void*)glBindTransformFeedback, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBindTransformFeedback(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glBindTransformFeedback", (void *) glBindTransformFeedback, 2, arg0, arg1); + glad_glBindTransformFeedback(arg0, arg1); + _post_call_callback_gl("glBindTransformFeedback", (void *) glBindTransformFeedback, 2, arg0, arg1); + } + PFNGLBINDTRANSFORMFEEDBACKPROC glad_debug_glBindTransformFeedback = glad_debug_impl_glBindTransformFeedback; PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray; -void APIENTRY glad_debug_impl_glBindVertexArray(GLuint arg0) { - _pre_call_callback_gl("glBindVertexArray", (void*)glBindVertexArray, 1, arg0); - glad_glBindVertexArray(arg0); - _post_call_callback_gl("glBindVertexArray", (void*)glBindVertexArray, 1, arg0); - + +void APIENTRY glad_debug_impl_glBindVertexArray(GLuint arg0) { + _pre_call_callback_gl("glBindVertexArray", (void *) glBindVertexArray, 1, arg0); + glad_glBindVertexArray(arg0); + _post_call_callback_gl("glBindVertexArray", (void *) glBindVertexArray, 1, arg0); + } + PFNGLBINDVERTEXARRAYPROC glad_debug_glBindVertexArray = glad_debug_impl_glBindVertexArray; PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer; -void APIENTRY glad_debug_impl_glBindVertexBuffer(GLuint arg0, GLuint arg1, GLintptr arg2, GLsizei arg3) { - _pre_call_callback_gl("glBindVertexBuffer", (void*)glBindVertexBuffer, 4, arg0, arg1, arg2, arg3); - glad_glBindVertexBuffer(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBindVertexBuffer", (void*)glBindVertexBuffer, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBindVertexBuffer(GLuint arg0, GLuint arg1, GLintptr arg2, GLsizei arg3) { + _pre_call_callback_gl("glBindVertexBuffer", (void *) glBindVertexBuffer, 4, arg0, arg1, arg2, arg3); + glad_glBindVertexBuffer(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBindVertexBuffer", (void *) glBindVertexBuffer, 4, arg0, arg1, arg2, arg3); + } + PFNGLBINDVERTEXBUFFERPROC glad_debug_glBindVertexBuffer = glad_debug_impl_glBindVertexBuffer; PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers; -void APIENTRY glad_debug_impl_glBindVertexBuffers(GLuint arg0, GLsizei arg1, const GLuint * arg2, const GLintptr * arg3, const GLsizei * arg4) { - _pre_call_callback_gl("glBindVertexBuffers", (void*)glBindVertexBuffers, 5, arg0, arg1, arg2, arg3, arg4); - glad_glBindVertexBuffers(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glBindVertexBuffers", (void*)glBindVertexBuffers, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glBindVertexBuffers(GLuint arg0, + GLsizei arg1, + const GLuint *arg2, + const GLintptr *arg3, + const GLsizei *arg4) { + _pre_call_callback_gl("glBindVertexBuffers", (void *) glBindVertexBuffers, 5, arg0, arg1, arg2, arg3, arg4); + glad_glBindVertexBuffers(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glBindVertexBuffers", (void *) glBindVertexBuffers, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLBINDVERTEXBUFFERSPROC glad_debug_glBindVertexBuffers = glad_debug_impl_glBindVertexBuffers; PFNGLBLENDCOLORPROC glad_glBlendColor; -void APIENTRY glad_debug_impl_glBlendColor(GLfloat arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { - _pre_call_callback_gl("glBlendColor", (void*)glBlendColor, 4, arg0, arg1, arg2, arg3); - glad_glBlendColor(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBlendColor", (void*)glBlendColor, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBlendColor(GLfloat arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { + _pre_call_callback_gl("glBlendColor", (void *) glBlendColor, 4, arg0, arg1, arg2, arg3); + glad_glBlendColor(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBlendColor", (void *) glBlendColor, 4, arg0, arg1, arg2, arg3); + } + PFNGLBLENDCOLORPROC glad_debug_glBlendColor = glad_debug_impl_glBlendColor; PFNGLBLENDEQUATIONPROC glad_glBlendEquation; -void APIENTRY glad_debug_impl_glBlendEquation(GLenum arg0) { - _pre_call_callback_gl("glBlendEquation", (void*)glBlendEquation, 1, arg0); - glad_glBlendEquation(arg0); - _post_call_callback_gl("glBlendEquation", (void*)glBlendEquation, 1, arg0); - + +void APIENTRY glad_debug_impl_glBlendEquation(GLenum arg0) { + _pre_call_callback_gl("glBlendEquation", (void *) glBlendEquation, 1, arg0); + glad_glBlendEquation(arg0); + _post_call_callback_gl("glBlendEquation", (void *) glBlendEquation, 1, arg0); + } + PFNGLBLENDEQUATIONPROC glad_debug_glBlendEquation = glad_debug_impl_glBlendEquation; PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate; -void APIENTRY glad_debug_impl_glBlendEquationSeparate(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glBlendEquationSeparate", (void*)glBlendEquationSeparate, 2, arg0, arg1); - glad_glBlendEquationSeparate(arg0, arg1); - _post_call_callback_gl("glBlendEquationSeparate", (void*)glBlendEquationSeparate, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBlendEquationSeparate(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glBlendEquationSeparate", (void *) glBlendEquationSeparate, 2, arg0, arg1); + glad_glBlendEquationSeparate(arg0, arg1); + _post_call_callback_gl("glBlendEquationSeparate", (void *) glBlendEquationSeparate, 2, arg0, arg1); + } + PFNGLBLENDEQUATIONSEPARATEPROC glad_debug_glBlendEquationSeparate = glad_debug_impl_glBlendEquationSeparate; PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei; -void APIENTRY glad_debug_impl_glBlendEquationSeparatei(GLuint arg0, GLenum arg1, GLenum arg2) { - _pre_call_callback_gl("glBlendEquationSeparatei", (void*)glBlendEquationSeparatei, 3, arg0, arg1, arg2); - glad_glBlendEquationSeparatei(arg0, arg1, arg2); - _post_call_callback_gl("glBlendEquationSeparatei", (void*)glBlendEquationSeparatei, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBlendEquationSeparatei(GLuint arg0, GLenum arg1, GLenum arg2) { + _pre_call_callback_gl("glBlendEquationSeparatei", (void *) glBlendEquationSeparatei, 3, arg0, arg1, arg2); + glad_glBlendEquationSeparatei(arg0, arg1, arg2); + _post_call_callback_gl("glBlendEquationSeparatei", (void *) glBlendEquationSeparatei, 3, arg0, arg1, arg2); + } + PFNGLBLENDEQUATIONSEPARATEIPROC glad_debug_glBlendEquationSeparatei = glad_debug_impl_glBlendEquationSeparatei; PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi; -void APIENTRY glad_debug_impl_glBlendEquationi(GLuint arg0, GLenum arg1) { - _pre_call_callback_gl("glBlendEquationi", (void*)glBlendEquationi, 2, arg0, arg1); - glad_glBlendEquationi(arg0, arg1); - _post_call_callback_gl("glBlendEquationi", (void*)glBlendEquationi, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBlendEquationi(GLuint arg0, GLenum arg1) { + _pre_call_callback_gl("glBlendEquationi", (void *) glBlendEquationi, 2, arg0, arg1); + glad_glBlendEquationi(arg0, arg1); + _post_call_callback_gl("glBlendEquationi", (void *) glBlendEquationi, 2, arg0, arg1); + } + PFNGLBLENDEQUATIONIPROC glad_debug_glBlendEquationi = glad_debug_impl_glBlendEquationi; PFNGLBLENDFUNCPROC glad_glBlendFunc; -void APIENTRY glad_debug_impl_glBlendFunc(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glBlendFunc", (void*)glBlendFunc, 2, arg0, arg1); - glad_glBlendFunc(arg0, arg1); - _post_call_callback_gl("glBlendFunc", (void*)glBlendFunc, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glBlendFunc(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glBlendFunc", (void *) glBlendFunc, 2, arg0, arg1); + glad_glBlendFunc(arg0, arg1); + _post_call_callback_gl("glBlendFunc", (void *) glBlendFunc, 2, arg0, arg1); + } + PFNGLBLENDFUNCPROC glad_debug_glBlendFunc = glad_debug_impl_glBlendFunc; PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate; -void APIENTRY glad_debug_impl_glBlendFuncSeparate(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3) { - _pre_call_callback_gl("glBlendFuncSeparate", (void*)glBlendFuncSeparate, 4, arg0, arg1, arg2, arg3); - glad_glBlendFuncSeparate(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBlendFuncSeparate", (void*)glBlendFuncSeparate, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBlendFuncSeparate(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3) { + _pre_call_callback_gl("glBlendFuncSeparate", (void *) glBlendFuncSeparate, 4, arg0, arg1, arg2, arg3); + glad_glBlendFuncSeparate(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBlendFuncSeparate", (void *) glBlendFuncSeparate, 4, arg0, arg1, arg2, arg3); + } + PFNGLBLENDFUNCSEPARATEPROC glad_debug_glBlendFuncSeparate = glad_debug_impl_glBlendFuncSeparate; PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei; -void APIENTRY glad_debug_impl_glBlendFuncSeparatei(GLuint arg0, GLenum arg1, GLenum arg2, GLenum arg3, GLenum arg4) { - _pre_call_callback_gl("glBlendFuncSeparatei", (void*)glBlendFuncSeparatei, 5, arg0, arg1, arg2, arg3, arg4); - glad_glBlendFuncSeparatei(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glBlendFuncSeparatei", (void*)glBlendFuncSeparatei, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glBlendFuncSeparatei(GLuint arg0, GLenum arg1, GLenum arg2, GLenum arg3, GLenum arg4) { + _pre_call_callback_gl("glBlendFuncSeparatei", (void *) glBlendFuncSeparatei, 5, arg0, arg1, arg2, arg3, arg4); + glad_glBlendFuncSeparatei(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glBlendFuncSeparatei", (void *) glBlendFuncSeparatei, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLBLENDFUNCSEPARATEIPROC glad_debug_glBlendFuncSeparatei = glad_debug_impl_glBlendFuncSeparatei; PFNGLBLENDFUNCIPROC glad_glBlendFunci; -void APIENTRY glad_debug_impl_glBlendFunci(GLuint arg0, GLenum arg1, GLenum arg2) { - _pre_call_callback_gl("glBlendFunci", (void*)glBlendFunci, 3, arg0, arg1, arg2); - glad_glBlendFunci(arg0, arg1, arg2); - _post_call_callback_gl("glBlendFunci", (void*)glBlendFunci, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glBlendFunci(GLuint arg0, GLenum arg1, GLenum arg2) { + _pre_call_callback_gl("glBlendFunci", (void *) glBlendFunci, 3, arg0, arg1, arg2); + glad_glBlendFunci(arg0, arg1, arg2); + _post_call_callback_gl("glBlendFunci", (void *) glBlendFunci, 3, arg0, arg1, arg2); + } + PFNGLBLENDFUNCIPROC glad_debug_glBlendFunci = glad_debug_impl_glBlendFunci; PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer; -void APIENTRY glad_debug_impl_glBlitFramebuffer(GLint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLint arg6, GLint arg7, GLbitfield arg8, GLenum arg9) { - _pre_call_callback_gl("glBlitFramebuffer", (void*)glBlitFramebuffer, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - glad_glBlitFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - _post_call_callback_gl("glBlitFramebuffer", (void*)glBlitFramebuffer, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - + +void APIENTRY glad_debug_impl_glBlitFramebuffer(GLint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLint arg6, + GLint arg7, + GLbitfield arg8, + GLenum arg9) { + _pre_call_callback_gl("glBlitFramebuffer", + (void *) glBlitFramebuffer, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + glad_glBlitFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + _post_call_callback_gl("glBlitFramebuffer", + (void *) glBlitFramebuffer, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + } + PFNGLBLITFRAMEBUFFERPROC glad_debug_glBlitFramebuffer = glad_debug_impl_glBlitFramebuffer; PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer; -void APIENTRY glad_debug_impl_glBlitNamedFramebuffer(GLuint arg0, GLuint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLint arg6, GLint arg7, GLint arg8, GLint arg9, GLbitfield arg10, GLenum arg11) { - _pre_call_callback_gl("glBlitNamedFramebuffer", (void*)glBlitNamedFramebuffer, 12, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - glad_glBlitNamedFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - _post_call_callback_gl("glBlitNamedFramebuffer", (void*)glBlitNamedFramebuffer, 12, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - + +void APIENTRY glad_debug_impl_glBlitNamedFramebuffer(GLuint arg0, + GLuint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLint arg6, + GLint arg7, + GLint arg8, + GLint arg9, + GLbitfield arg10, + GLenum arg11) { + _pre_call_callback_gl("glBlitNamedFramebuffer", + (void *) glBlitNamedFramebuffer, + 12, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11); + glad_glBlitNamedFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); + _post_call_callback_gl("glBlitNamedFramebuffer", + (void *) glBlitNamedFramebuffer, + 12, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11); + } + PFNGLBLITNAMEDFRAMEBUFFERPROC glad_debug_glBlitNamedFramebuffer = glad_debug_impl_glBlitNamedFramebuffer; PFNGLBUFFERDATAPROC glad_glBufferData; -void APIENTRY glad_debug_impl_glBufferData(GLenum arg0, GLsizeiptr arg1, const void * arg2, GLenum arg3) { - _pre_call_callback_gl("glBufferData", (void*)glBufferData, 4, arg0, arg1, arg2, arg3); - glad_glBufferData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBufferData", (void*)glBufferData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBufferData(GLenum arg0, GLsizeiptr arg1, const void *arg2, GLenum arg3) { + _pre_call_callback_gl("glBufferData", (void *) glBufferData, 4, arg0, arg1, arg2, arg3); + glad_glBufferData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBufferData", (void *) glBufferData, 4, arg0, arg1, arg2, arg3); + } + PFNGLBUFFERDATAPROC glad_debug_glBufferData = glad_debug_impl_glBufferData; PFNGLBUFFERSTORAGEPROC glad_glBufferStorage; -void APIENTRY glad_debug_impl_glBufferStorage(GLenum arg0, GLsizeiptr arg1, const void * arg2, GLbitfield arg3) { - _pre_call_callback_gl("glBufferStorage", (void*)glBufferStorage, 4, arg0, arg1, arg2, arg3); - glad_glBufferStorage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBufferStorage", (void*)glBufferStorage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBufferStorage(GLenum arg0, GLsizeiptr arg1, const void *arg2, GLbitfield arg3) { + _pre_call_callback_gl("glBufferStorage", (void *) glBufferStorage, 4, arg0, arg1, arg2, arg3); + glad_glBufferStorage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBufferStorage", (void *) glBufferStorage, 4, arg0, arg1, arg2, arg3); + } + PFNGLBUFFERSTORAGEPROC glad_debug_glBufferStorage = glad_debug_impl_glBufferStorage; PFNGLBUFFERSUBDATAPROC glad_glBufferSubData; -void APIENTRY glad_debug_impl_glBufferSubData(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, const void * arg3) { - _pre_call_callback_gl("glBufferSubData", (void*)glBufferSubData, 4, arg0, arg1, arg2, arg3); - glad_glBufferSubData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glBufferSubData", (void*)glBufferSubData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glBufferSubData(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, const void *arg3) { + _pre_call_callback_gl("glBufferSubData", (void *) glBufferSubData, 4, arg0, arg1, arg2, arg3); + glad_glBufferSubData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glBufferSubData", (void *) glBufferSubData, 4, arg0, arg1, arg2, arg3); + } + PFNGLBUFFERSUBDATAPROC glad_debug_glBufferSubData = glad_debug_impl_glBufferSubData; PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus; -GLenum APIENTRY glad_debug_impl_glCheckFramebufferStatus(GLenum arg0) { - GLenum ret; - _pre_call_callback_gl("glCheckFramebufferStatus", (void*)glCheckFramebufferStatus, 1, arg0); - ret = glad_glCheckFramebufferStatus(arg0); - _post_call_callback_gl("glCheckFramebufferStatus", (void*)glCheckFramebufferStatus, 1, arg0); - return ret; + +GLenum APIENTRY glad_debug_impl_glCheckFramebufferStatus(GLenum arg0) { + GLenum ret; + _pre_call_callback_gl("glCheckFramebufferStatus", (void *) glCheckFramebufferStatus, 1, arg0); + ret = glad_glCheckFramebufferStatus(arg0); + _post_call_callback_gl("glCheckFramebufferStatus", (void *) glCheckFramebufferStatus, 1, arg0); + return ret; } + PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_debug_glCheckFramebufferStatus = glad_debug_impl_glCheckFramebufferStatus; PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus; -GLenum APIENTRY glad_debug_impl_glCheckNamedFramebufferStatus(GLuint arg0, GLenum arg1) { - GLenum ret; - _pre_call_callback_gl("glCheckNamedFramebufferStatus", (void*)glCheckNamedFramebufferStatus, 2, arg0, arg1); - ret = glad_glCheckNamedFramebufferStatus(arg0, arg1); - _post_call_callback_gl("glCheckNamedFramebufferStatus", (void*)glCheckNamedFramebufferStatus, 2, arg0, arg1); - return ret; -} -PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_debug_glCheckNamedFramebufferStatus = glad_debug_impl_glCheckNamedFramebufferStatus; + +GLenum APIENTRY glad_debug_impl_glCheckNamedFramebufferStatus(GLuint arg0, GLenum arg1) { + GLenum ret; + _pre_call_callback_gl("glCheckNamedFramebufferStatus", (void *) glCheckNamedFramebufferStatus, 2, arg0, arg1); + ret = glad_glCheckNamedFramebufferStatus(arg0, arg1); + _post_call_callback_gl("glCheckNamedFramebufferStatus", (void *) glCheckNamedFramebufferStatus, 2, arg0, arg1); + return ret; +} + +PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC + glad_debug_glCheckNamedFramebufferStatus = glad_debug_impl_glCheckNamedFramebufferStatus; PFNGLCLAMPCOLORPROC glad_glClampColor; -void APIENTRY glad_debug_impl_glClampColor(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glClampColor", (void*)glClampColor, 2, arg0, arg1); - glad_glClampColor(arg0, arg1); - _post_call_callback_gl("glClampColor", (void*)glClampColor, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glClampColor(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glClampColor", (void *) glClampColor, 2, arg0, arg1); + glad_glClampColor(arg0, arg1); + _post_call_callback_gl("glClampColor", (void *) glClampColor, 2, arg0, arg1); + } + PFNGLCLAMPCOLORPROC glad_debug_glClampColor = glad_debug_impl_glClampColor; PFNGLCLEARPROC glad_glClear; -void APIENTRY glad_debug_impl_glClear(GLbitfield arg0) { - _pre_call_callback_gl("glClear", (void*)glClear, 1, arg0); - glad_glClear(arg0); - _post_call_callback_gl("glClear", (void*)glClear, 1, arg0); - + +void APIENTRY glad_debug_impl_glClear(GLbitfield arg0) { + _pre_call_callback_gl("glClear", (void *) glClear, 1, arg0); + glad_glClear(arg0); + _post_call_callback_gl("glClear", (void *) glClear, 1, arg0); + } + PFNGLCLEARPROC glad_debug_glClear = glad_debug_impl_glClear; PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData; -void APIENTRY glad_debug_impl_glClearBufferData(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3, const void * arg4) { - _pre_call_callback_gl("glClearBufferData", (void*)glClearBufferData, 5, arg0, arg1, arg2, arg3, arg4); - glad_glClearBufferData(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glClearBufferData", (void*)glClearBufferData, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glClearBufferData(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3, const void *arg4) { + _pre_call_callback_gl("glClearBufferData", (void *) glClearBufferData, 5, arg0, arg1, arg2, arg3, arg4); + glad_glClearBufferData(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glClearBufferData", (void *) glClearBufferData, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLCLEARBUFFERDATAPROC glad_debug_glClearBufferData = glad_debug_impl_glClearBufferData; PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData; -void APIENTRY glad_debug_impl_glClearBufferSubData(GLenum arg0, GLenum arg1, GLintptr arg2, GLsizeiptr arg3, GLenum arg4, GLenum arg5, const void * arg6) { - _pre_call_callback_gl("glClearBufferSubData", (void*)glClearBufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glClearBufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glClearBufferSubData", (void*)glClearBufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glClearBufferSubData(GLenum arg0, + GLenum arg1, + GLintptr arg2, + GLsizeiptr arg3, + GLenum arg4, + GLenum arg5, + const void *arg6) { + _pre_call_callback_gl("glClearBufferSubData", + (void *) glClearBufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glClearBufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glClearBufferSubData", + (void *) glClearBufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLCLEARBUFFERSUBDATAPROC glad_debug_glClearBufferSubData = glad_debug_impl_glClearBufferSubData; PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi; -void APIENTRY glad_debug_impl_glClearBufferfi(GLenum arg0, GLint arg1, GLfloat arg2, GLint arg3) { - _pre_call_callback_gl("glClearBufferfi", (void*)glClearBufferfi, 4, arg0, arg1, arg2, arg3); - glad_glClearBufferfi(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glClearBufferfi", (void*)glClearBufferfi, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glClearBufferfi(GLenum arg0, GLint arg1, GLfloat arg2, GLint arg3) { + _pre_call_callback_gl("glClearBufferfi", (void *) glClearBufferfi, 4, arg0, arg1, arg2, arg3); + glad_glClearBufferfi(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glClearBufferfi", (void *) glClearBufferfi, 4, arg0, arg1, arg2, arg3); + } + PFNGLCLEARBUFFERFIPROC glad_debug_glClearBufferfi = glad_debug_impl_glClearBufferfi; PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv; -void APIENTRY glad_debug_impl_glClearBufferfv(GLenum arg0, GLint arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glClearBufferfv", (void*)glClearBufferfv, 3, arg0, arg1, arg2); - glad_glClearBufferfv(arg0, arg1, arg2); - _post_call_callback_gl("glClearBufferfv", (void*)glClearBufferfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glClearBufferfv(GLenum arg0, GLint arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glClearBufferfv", (void *) glClearBufferfv, 3, arg0, arg1, arg2); + glad_glClearBufferfv(arg0, arg1, arg2); + _post_call_callback_gl("glClearBufferfv", (void *) glClearBufferfv, 3, arg0, arg1, arg2); + } + PFNGLCLEARBUFFERFVPROC glad_debug_glClearBufferfv = glad_debug_impl_glClearBufferfv; PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv; -void APIENTRY glad_debug_impl_glClearBufferiv(GLenum arg0, GLint arg1, const GLint * arg2) { - _pre_call_callback_gl("glClearBufferiv", (void*)glClearBufferiv, 3, arg0, arg1, arg2); - glad_glClearBufferiv(arg0, arg1, arg2); - _post_call_callback_gl("glClearBufferiv", (void*)glClearBufferiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glClearBufferiv(GLenum arg0, GLint arg1, const GLint *arg2) { + _pre_call_callback_gl("glClearBufferiv", (void *) glClearBufferiv, 3, arg0, arg1, arg2); + glad_glClearBufferiv(arg0, arg1, arg2); + _post_call_callback_gl("glClearBufferiv", (void *) glClearBufferiv, 3, arg0, arg1, arg2); + } + PFNGLCLEARBUFFERIVPROC glad_debug_glClearBufferiv = glad_debug_impl_glClearBufferiv; PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv; -void APIENTRY glad_debug_impl_glClearBufferuiv(GLenum arg0, GLint arg1, const GLuint * arg2) { - _pre_call_callback_gl("glClearBufferuiv", (void*)glClearBufferuiv, 3, arg0, arg1, arg2); - glad_glClearBufferuiv(arg0, arg1, arg2); - _post_call_callback_gl("glClearBufferuiv", (void*)glClearBufferuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glClearBufferuiv(GLenum arg0, GLint arg1, const GLuint *arg2) { + _pre_call_callback_gl("glClearBufferuiv", (void *) glClearBufferuiv, 3, arg0, arg1, arg2); + glad_glClearBufferuiv(arg0, arg1, arg2); + _post_call_callback_gl("glClearBufferuiv", (void *) glClearBufferuiv, 3, arg0, arg1, arg2); + } + PFNGLCLEARBUFFERUIVPROC glad_debug_glClearBufferuiv = glad_debug_impl_glClearBufferuiv; PFNGLCLEARCOLORPROC glad_glClearColor; -void APIENTRY glad_debug_impl_glClearColor(GLfloat arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { - _pre_call_callback_gl("glClearColor", (void*)glClearColor, 4, arg0, arg1, arg2, arg3); - glad_glClearColor(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glClearColor", (void*)glClearColor, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glClearColor(GLfloat arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { + _pre_call_callback_gl("glClearColor", (void *) glClearColor, 4, arg0, arg1, arg2, arg3); + glad_glClearColor(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glClearColor", (void *) glClearColor, 4, arg0, arg1, arg2, arg3); + } + PFNGLCLEARCOLORPROC glad_debug_glClearColor = glad_debug_impl_glClearColor; PFNGLCLEARDEPTHPROC glad_glClearDepth; -void APIENTRY glad_debug_impl_glClearDepth(GLdouble arg0) { - _pre_call_callback_gl("glClearDepth", (void*)glClearDepth, 1, arg0); - glad_glClearDepth(arg0); - _post_call_callback_gl("glClearDepth", (void*)glClearDepth, 1, arg0); - + +void APIENTRY glad_debug_impl_glClearDepth(GLdouble arg0) { + _pre_call_callback_gl("glClearDepth", (void *) glClearDepth, 1, arg0); + glad_glClearDepth(arg0); + _post_call_callback_gl("glClearDepth", (void *) glClearDepth, 1, arg0); + } + PFNGLCLEARDEPTHPROC glad_debug_glClearDepth = glad_debug_impl_glClearDepth; PFNGLCLEARDEPTHFPROC glad_glClearDepthf; -void APIENTRY glad_debug_impl_glClearDepthf(GLfloat arg0) { - _pre_call_callback_gl("glClearDepthf", (void*)glClearDepthf, 1, arg0); - glad_glClearDepthf(arg0); - _post_call_callback_gl("glClearDepthf", (void*)glClearDepthf, 1, arg0); - + +void APIENTRY glad_debug_impl_glClearDepthf(GLfloat arg0) { + _pre_call_callback_gl("glClearDepthf", (void *) glClearDepthf, 1, arg0); + glad_glClearDepthf(arg0); + _post_call_callback_gl("glClearDepthf", (void *) glClearDepthf, 1, arg0); + } + PFNGLCLEARDEPTHFPROC glad_debug_glClearDepthf = glad_debug_impl_glClearDepthf; PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData; -void APIENTRY glad_debug_impl_glClearNamedBufferData(GLuint arg0, GLenum arg1, GLenum arg2, GLenum arg3, const void * arg4) { - _pre_call_callback_gl("glClearNamedBufferData", (void*)glClearNamedBufferData, 5, arg0, arg1, arg2, arg3, arg4); - glad_glClearNamedBufferData(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glClearNamedBufferData", (void*)glClearNamedBufferData, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glClearNamedBufferData(GLuint arg0, + GLenum arg1, + GLenum arg2, + GLenum arg3, + const void *arg4) { + _pre_call_callback_gl("glClearNamedBufferData", (void *) glClearNamedBufferData, 5, arg0, arg1, arg2, arg3, arg4); + glad_glClearNamedBufferData(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glClearNamedBufferData", (void *) glClearNamedBufferData, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLCLEARNAMEDBUFFERDATAPROC glad_debug_glClearNamedBufferData = glad_debug_impl_glClearNamedBufferData; PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData; -void APIENTRY glad_debug_impl_glClearNamedBufferSubData(GLuint arg0, GLenum arg1, GLintptr arg2, GLsizeiptr arg3, GLenum arg4, GLenum arg5, const void * arg6) { - _pre_call_callback_gl("glClearNamedBufferSubData", (void*)glClearNamedBufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glClearNamedBufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glClearNamedBufferSubData", (void*)glClearNamedBufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glClearNamedBufferSubData(GLuint arg0, + GLenum arg1, + GLintptr arg2, + GLsizeiptr arg3, + GLenum arg4, + GLenum arg5, + const void *arg6) { + _pre_call_callback_gl("glClearNamedBufferSubData", + (void *) glClearNamedBufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glClearNamedBufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glClearNamedBufferSubData", + (void *) glClearNamedBufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_debug_glClearNamedBufferSubData = glad_debug_impl_glClearNamedBufferSubData; PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi; -void APIENTRY glad_debug_impl_glClearNamedFramebufferfi(GLuint arg0, GLenum arg1, GLint arg2, GLfloat arg3, GLint arg4) { - _pre_call_callback_gl("glClearNamedFramebufferfi", (void*)glClearNamedFramebufferfi, 5, arg0, arg1, arg2, arg3, arg4); - glad_glClearNamedFramebufferfi(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glClearNamedFramebufferfi", (void*)glClearNamedFramebufferfi, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glClearNamedFramebufferfi(GLuint arg0, + GLenum arg1, + GLint arg2, + GLfloat arg3, + GLint arg4) { + _pre_call_callback_gl("glClearNamedFramebufferfi", + (void *) glClearNamedFramebufferfi, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glClearNamedFramebufferfi(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glClearNamedFramebufferfi", + (void *) glClearNamedFramebufferfi, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_debug_glClearNamedFramebufferfi = glad_debug_impl_glClearNamedFramebufferfi; PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv; -void APIENTRY glad_debug_impl_glClearNamedFramebufferfv(GLuint arg0, GLenum arg1, GLint arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glClearNamedFramebufferfv", (void*)glClearNamedFramebufferfv, 4, arg0, arg1, arg2, arg3); - glad_glClearNamedFramebufferfv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glClearNamedFramebufferfv", (void*)glClearNamedFramebufferfv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glClearNamedFramebufferfv(GLuint arg0, GLenum arg1, GLint arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glClearNamedFramebufferfv", (void *) glClearNamedFramebufferfv, 4, arg0, arg1, arg2, arg3); + glad_glClearNamedFramebufferfv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glClearNamedFramebufferfv", (void *) glClearNamedFramebufferfv, 4, arg0, arg1, arg2, arg3); + } + PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_debug_glClearNamedFramebufferfv = glad_debug_impl_glClearNamedFramebufferfv; PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv; -void APIENTRY glad_debug_impl_glClearNamedFramebufferiv(GLuint arg0, GLenum arg1, GLint arg2, const GLint * arg3) { - _pre_call_callback_gl("glClearNamedFramebufferiv", (void*)glClearNamedFramebufferiv, 4, arg0, arg1, arg2, arg3); - glad_glClearNamedFramebufferiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glClearNamedFramebufferiv", (void*)glClearNamedFramebufferiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glClearNamedFramebufferiv(GLuint arg0, GLenum arg1, GLint arg2, const GLint *arg3) { + _pre_call_callback_gl("glClearNamedFramebufferiv", (void *) glClearNamedFramebufferiv, 4, arg0, arg1, arg2, arg3); + glad_glClearNamedFramebufferiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glClearNamedFramebufferiv", (void *) glClearNamedFramebufferiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_debug_glClearNamedFramebufferiv = glad_debug_impl_glClearNamedFramebufferiv; PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv; -void APIENTRY glad_debug_impl_glClearNamedFramebufferuiv(GLuint arg0, GLenum arg1, GLint arg2, const GLuint * arg3) { - _pre_call_callback_gl("glClearNamedFramebufferuiv", (void*)glClearNamedFramebufferuiv, 4, arg0, arg1, arg2, arg3); - glad_glClearNamedFramebufferuiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glClearNamedFramebufferuiv", (void*)glClearNamedFramebufferuiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glClearNamedFramebufferuiv(GLuint arg0, GLenum arg1, GLint arg2, const GLuint *arg3) { + _pre_call_callback_gl("glClearNamedFramebufferuiv", (void *) glClearNamedFramebufferuiv, 4, arg0, arg1, arg2, arg3); + glad_glClearNamedFramebufferuiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glClearNamedFramebufferuiv", + (void *) glClearNamedFramebufferuiv, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_debug_glClearNamedFramebufferuiv = glad_debug_impl_glClearNamedFramebufferuiv; PFNGLCLEARSTENCILPROC glad_glClearStencil; -void APIENTRY glad_debug_impl_glClearStencil(GLint arg0) { - _pre_call_callback_gl("glClearStencil", (void*)glClearStencil, 1, arg0); - glad_glClearStencil(arg0); - _post_call_callback_gl("glClearStencil", (void*)glClearStencil, 1, arg0); - + +void APIENTRY glad_debug_impl_glClearStencil(GLint arg0) { + _pre_call_callback_gl("glClearStencil", (void *) glClearStencil, 1, arg0); + glad_glClearStencil(arg0); + _post_call_callback_gl("glClearStencil", (void *) glClearStencil, 1, arg0); + } + PFNGLCLEARSTENCILPROC glad_debug_glClearStencil = glad_debug_impl_glClearStencil; PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage; -void APIENTRY glad_debug_impl_glClearTexImage(GLuint arg0, GLint arg1, GLenum arg2, GLenum arg3, const void * arg4) { - _pre_call_callback_gl("glClearTexImage", (void*)glClearTexImage, 5, arg0, arg1, arg2, arg3, arg4); - glad_glClearTexImage(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glClearTexImage", (void*)glClearTexImage, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glClearTexImage(GLuint arg0, GLint arg1, GLenum arg2, GLenum arg3, const void *arg4) { + _pre_call_callback_gl("glClearTexImage", (void *) glClearTexImage, 5, arg0, arg1, arg2, arg3, arg4); + glad_glClearTexImage(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glClearTexImage", (void *) glClearTexImage, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLCLEARTEXIMAGEPROC glad_debug_glClearTexImage = glad_debug_impl_glClearTexImage; PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage; -void APIENTRY glad_debug_impl_glClearTexSubImage(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLenum arg9, const void * arg10) { - _pre_call_callback_gl("glClearTexSubImage", (void*)glClearTexSubImage, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - glad_glClearTexSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - _post_call_callback_gl("glClearTexSubImage", (void*)glClearTexSubImage, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - + +void APIENTRY glad_debug_impl_glClearTexSubImage(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLenum arg9, + const void *arg10) { + _pre_call_callback_gl("glClearTexSubImage", + (void *) glClearTexSubImage, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + glad_glClearTexSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + _post_call_callback_gl("glClearTexSubImage", + (void *) glClearTexSubImage, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } + PFNGLCLEARTEXSUBIMAGEPROC glad_debug_glClearTexSubImage = glad_debug_impl_glClearTexSubImage; PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync; -GLenum APIENTRY glad_debug_impl_glClientWaitSync(GLsync arg0, GLbitfield arg1, GLuint64 arg2) { - GLenum ret; - _pre_call_callback_gl("glClientWaitSync", (void*)glClientWaitSync, 3, arg0, arg1, arg2); - ret = glad_glClientWaitSync(arg0, arg1, arg2); - _post_call_callback_gl("glClientWaitSync", (void*)glClientWaitSync, 3, arg0, arg1, arg2); - return ret; + +GLenum APIENTRY glad_debug_impl_glClientWaitSync(GLsync arg0, GLbitfield arg1, GLuint64 arg2) { + GLenum ret; + _pre_call_callback_gl("glClientWaitSync", (void *) glClientWaitSync, 3, arg0, arg1, arg2); + ret = glad_glClientWaitSync(arg0, arg1, arg2); + _post_call_callback_gl("glClientWaitSync", (void *) glClientWaitSync, 3, arg0, arg1, arg2); + return ret; } + PFNGLCLIENTWAITSYNCPROC glad_debug_glClientWaitSync = glad_debug_impl_glClientWaitSync; PFNGLCLIPCONTROLPROC glad_glClipControl; -void APIENTRY glad_debug_impl_glClipControl(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glClipControl", (void*)glClipControl, 2, arg0, arg1); - glad_glClipControl(arg0, arg1); - _post_call_callback_gl("glClipControl", (void*)glClipControl, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glClipControl(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glClipControl", (void *) glClipControl, 2, arg0, arg1); + glad_glClipControl(arg0, arg1); + _post_call_callback_gl("glClipControl", (void *) glClipControl, 2, arg0, arg1); + } + PFNGLCLIPCONTROLPROC glad_debug_glClipControl = glad_debug_impl_glClipControl; PFNGLCOLORMASKPROC glad_glColorMask; -void APIENTRY glad_debug_impl_glColorMask(GLboolean arg0, GLboolean arg1, GLboolean arg2, GLboolean arg3) { - _pre_call_callback_gl("glColorMask", (void*)glColorMask, 4, arg0, arg1, arg2, arg3); - glad_glColorMask(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glColorMask", (void*)glColorMask, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glColorMask(GLboolean arg0, GLboolean arg1, GLboolean arg2, GLboolean arg3) { + _pre_call_callback_gl("glColorMask", (void *) glColorMask, 4, arg0, arg1, arg2, arg3); + glad_glColorMask(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glColorMask", (void *) glColorMask, 4, arg0, arg1, arg2, arg3); + } + PFNGLCOLORMASKPROC glad_debug_glColorMask = glad_debug_impl_glColorMask; PFNGLCOLORMASKIPROC glad_glColorMaski; -void APIENTRY glad_debug_impl_glColorMaski(GLuint arg0, GLboolean arg1, GLboolean arg2, GLboolean arg3, GLboolean arg4) { - _pre_call_callback_gl("glColorMaski", (void*)glColorMaski, 5, arg0, arg1, arg2, arg3, arg4); - glad_glColorMaski(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glColorMaski", (void*)glColorMaski, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glColorMaski(GLuint arg0, + GLboolean arg1, + GLboolean arg2, + GLboolean arg3, + GLboolean arg4) { + _pre_call_callback_gl("glColorMaski", (void *) glColorMaski, 5, arg0, arg1, arg2, arg3, arg4); + glad_glColorMaski(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glColorMaski", (void *) glColorMaski, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLCOLORMASKIPROC glad_debug_glColorMaski = glad_debug_impl_glColorMaski; PFNGLCOLORP3UIPROC glad_glColorP3ui; -void APIENTRY glad_debug_impl_glColorP3ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glColorP3ui", (void*)glColorP3ui, 2, arg0, arg1); - glad_glColorP3ui(arg0, arg1); - _post_call_callback_gl("glColorP3ui", (void*)glColorP3ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glColorP3ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glColorP3ui", (void *) glColorP3ui, 2, arg0, arg1); + glad_glColorP3ui(arg0, arg1); + _post_call_callback_gl("glColorP3ui", (void *) glColorP3ui, 2, arg0, arg1); + } + PFNGLCOLORP3UIPROC glad_debug_glColorP3ui = glad_debug_impl_glColorP3ui; PFNGLCOLORP3UIVPROC glad_glColorP3uiv; -void APIENTRY glad_debug_impl_glColorP3uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glColorP3uiv", (void*)glColorP3uiv, 2, arg0, arg1); - glad_glColorP3uiv(arg0, arg1); - _post_call_callback_gl("glColorP3uiv", (void*)glColorP3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glColorP3uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glColorP3uiv", (void *) glColorP3uiv, 2, arg0, arg1); + glad_glColorP3uiv(arg0, arg1); + _post_call_callback_gl("glColorP3uiv", (void *) glColorP3uiv, 2, arg0, arg1); + } + PFNGLCOLORP3UIVPROC glad_debug_glColorP3uiv = glad_debug_impl_glColorP3uiv; PFNGLCOLORP4UIPROC glad_glColorP4ui; -void APIENTRY glad_debug_impl_glColorP4ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glColorP4ui", (void*)glColorP4ui, 2, arg0, arg1); - glad_glColorP4ui(arg0, arg1); - _post_call_callback_gl("glColorP4ui", (void*)glColorP4ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glColorP4ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glColorP4ui", (void *) glColorP4ui, 2, arg0, arg1); + glad_glColorP4ui(arg0, arg1); + _post_call_callback_gl("glColorP4ui", (void *) glColorP4ui, 2, arg0, arg1); + } + PFNGLCOLORP4UIPROC glad_debug_glColorP4ui = glad_debug_impl_glColorP4ui; PFNGLCOLORP4UIVPROC glad_glColorP4uiv; -void APIENTRY glad_debug_impl_glColorP4uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glColorP4uiv", (void*)glColorP4uiv, 2, arg0, arg1); - glad_glColorP4uiv(arg0, arg1); - _post_call_callback_gl("glColorP4uiv", (void*)glColorP4uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glColorP4uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glColorP4uiv", (void *) glColorP4uiv, 2, arg0, arg1); + glad_glColorP4uiv(arg0, arg1); + _post_call_callback_gl("glColorP4uiv", (void *) glColorP4uiv, 2, arg0, arg1); + } + PFNGLCOLORP4UIVPROC glad_debug_glColorP4uiv = glad_debug_impl_glColorP4uiv; PFNGLCOMPILESHADERPROC glad_glCompileShader; -void APIENTRY glad_debug_impl_glCompileShader(GLuint arg0) { - _pre_call_callback_gl("glCompileShader", (void*)glCompileShader, 1, arg0); - glad_glCompileShader(arg0); - _post_call_callback_gl("glCompileShader", (void*)glCompileShader, 1, arg0); - + +void APIENTRY glad_debug_impl_glCompileShader(GLuint arg0) { + _pre_call_callback_gl("glCompileShader", (void *) glCompileShader, 1, arg0); + glad_glCompileShader(arg0); + _post_call_callback_gl("glCompileShader", (void *) glCompileShader, 1, arg0); + } + PFNGLCOMPILESHADERPROC glad_debug_glCompileShader = glad_debug_impl_glCompileShader; PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D; -void APIENTRY glad_debug_impl_glCompressedTexImage1D(GLenum arg0, GLint arg1, GLenum arg2, GLsizei arg3, GLint arg4, GLsizei arg5, const void * arg6) { - _pre_call_callback_gl("glCompressedTexImage1D", (void*)glCompressedTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glCompressedTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glCompressedTexImage1D", (void*)glCompressedTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glCompressedTexImage1D(GLenum arg0, + GLint arg1, + GLenum arg2, + GLsizei arg3, + GLint arg4, + GLsizei arg5, + const void *arg6) { + _pre_call_callback_gl("glCompressedTexImage1D", + (void *) glCompressedTexImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glCompressedTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glCompressedTexImage1D", + (void *) glCompressedTexImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_debug_glCompressedTexImage1D = glad_debug_impl_glCompressedTexImage1D; PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D; -void APIENTRY glad_debug_impl_glCompressedTexImage2D(GLenum arg0, GLint arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLint arg5, GLsizei arg6, const void * arg7) { - _pre_call_callback_gl("glCompressedTexImage2D", (void*)glCompressedTexImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glCompressedTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glCompressedTexImage2D", (void*)glCompressedTexImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glCompressedTexImage2D(GLenum arg0, + GLint arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLint arg5, + GLsizei arg6, + const void *arg7) { + _pre_call_callback_gl("glCompressedTexImage2D", + (void *) glCompressedTexImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glCompressedTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glCompressedTexImage2D", + (void *) glCompressedTexImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_debug_glCompressedTexImage2D = glad_debug_impl_glCompressedTexImage2D; PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D; -void APIENTRY glad_debug_impl_glCompressedTexImage3D(GLenum arg0, GLint arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5, GLint arg6, GLsizei arg7, const void * arg8) { - _pre_call_callback_gl("glCompressedTexImage3D", (void*)glCompressedTexImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glCompressedTexImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glCompressedTexImage3D", (void*)glCompressedTexImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glCompressedTexImage3D(GLenum arg0, + GLint arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5, + GLint arg6, + GLsizei arg7, + const void *arg8) { + _pre_call_callback_gl("glCompressedTexImage3D", + (void *) glCompressedTexImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glCompressedTexImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glCompressedTexImage3D", + (void *) glCompressedTexImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_debug_glCompressedTexImage3D = glad_debug_impl_glCompressedTexImage3D; PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D; -void APIENTRY glad_debug_impl_glCompressedTexSubImage1D(GLenum arg0, GLint arg1, GLint arg2, GLsizei arg3, GLenum arg4, GLsizei arg5, const void * arg6) { - _pre_call_callback_gl("glCompressedTexSubImage1D", (void*)glCompressedTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glCompressedTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glCompressedTexSubImage1D", (void*)glCompressedTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glCompressedTexSubImage1D(GLenum arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLenum arg4, + GLsizei arg5, + const void *arg6) { + _pre_call_callback_gl("glCompressedTexSubImage1D", + (void *) glCompressedTexSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glCompressedTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glCompressedTexSubImage1D", + (void *) glCompressedTexSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_debug_glCompressedTexSubImage1D = glad_debug_impl_glCompressedTexSubImage1D; PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D; -void APIENTRY glad_debug_impl_glCompressedTexSubImage2D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLsizei arg4, GLsizei arg5, GLenum arg6, GLsizei arg7, const void * arg8) { - _pre_call_callback_gl("glCompressedTexSubImage2D", (void*)glCompressedTexSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glCompressedTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glCompressedTexSubImage2D", (void*)glCompressedTexSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glCompressedTexSubImage2D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLsizei arg4, + GLsizei arg5, + GLenum arg6, + GLsizei arg7, + const void *arg8) { + _pre_call_callback_gl("glCompressedTexSubImage2D", + (void *) glCompressedTexSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glCompressedTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glCompressedTexSubImage2D", + (void *) glCompressedTexSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_debug_glCompressedTexSubImage2D = glad_debug_impl_glCompressedTexSubImage2D; PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D; -void APIENTRY glad_debug_impl_glCompressedTexSubImage3D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLsizei arg9, const void * arg10) { - _pre_call_callback_gl("glCompressedTexSubImage3D", (void*)glCompressedTexSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - glad_glCompressedTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - _post_call_callback_gl("glCompressedTexSubImage3D", (void*)glCompressedTexSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - + +void APIENTRY glad_debug_impl_glCompressedTexSubImage3D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLsizei arg9, + const void *arg10) { + _pre_call_callback_gl("glCompressedTexSubImage3D", + (void *) glCompressedTexSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + glad_glCompressedTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + _post_call_callback_gl("glCompressedTexSubImage3D", + (void *) glCompressedTexSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } + PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_debug_glCompressedTexSubImage3D = glad_debug_impl_glCompressedTexSubImage3D; PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D; -void APIENTRY glad_debug_impl_glCompressedTextureSubImage1D(GLuint arg0, GLint arg1, GLint arg2, GLsizei arg3, GLenum arg4, GLsizei arg5, const void * arg6) { - _pre_call_callback_gl("glCompressedTextureSubImage1D", (void*)glCompressedTextureSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glCompressedTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glCompressedTextureSubImage1D", (void*)glCompressedTextureSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glCompressedTextureSubImage1D(GLuint arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLenum arg4, + GLsizei arg5, + const void *arg6) { + _pre_call_callback_gl("glCompressedTextureSubImage1D", + (void *) glCompressedTextureSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glCompressedTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glCompressedTextureSubImage1D", + (void *) glCompressedTextureSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_debug_glCompressedTextureSubImage1D = glad_debug_impl_glCompressedTextureSubImage1D; + +PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC + glad_debug_glCompressedTextureSubImage1D = glad_debug_impl_glCompressedTextureSubImage1D; PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D; -void APIENTRY glad_debug_impl_glCompressedTextureSubImage2D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLsizei arg4, GLsizei arg5, GLenum arg6, GLsizei arg7, const void * arg8) { - _pre_call_callback_gl("glCompressedTextureSubImage2D", (void*)glCompressedTextureSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glCompressedTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glCompressedTextureSubImage2D", (void*)glCompressedTextureSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glCompressedTextureSubImage2D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLsizei arg4, + GLsizei arg5, + GLenum arg6, + GLsizei arg7, + const void *arg8) { + _pre_call_callback_gl("glCompressedTextureSubImage2D", + (void *) glCompressedTextureSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glCompressedTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glCompressedTextureSubImage2D", + (void *) glCompressedTextureSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } -PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_debug_glCompressedTextureSubImage2D = glad_debug_impl_glCompressedTextureSubImage2D; + +PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC + glad_debug_glCompressedTextureSubImage2D = glad_debug_impl_glCompressedTextureSubImage2D; PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D; -void APIENTRY glad_debug_impl_glCompressedTextureSubImage3D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLsizei arg9, const void * arg10) { - _pre_call_callback_gl("glCompressedTextureSubImage3D", (void*)glCompressedTextureSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - glad_glCompressedTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - _post_call_callback_gl("glCompressedTextureSubImage3D", (void*)glCompressedTextureSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - + +void APIENTRY glad_debug_impl_glCompressedTextureSubImage3D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLsizei arg9, + const void *arg10) { + _pre_call_callback_gl("glCompressedTextureSubImage3D", + (void *) glCompressedTextureSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + glad_glCompressedTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + _post_call_callback_gl("glCompressedTextureSubImage3D", + (void *) glCompressedTextureSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } -PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_debug_glCompressedTextureSubImage3D = glad_debug_impl_glCompressedTextureSubImage3D; + +PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC + glad_debug_glCompressedTextureSubImage3D = glad_debug_impl_glCompressedTextureSubImage3D; PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData; -void APIENTRY glad_debug_impl_glCopyBufferSubData(GLenum arg0, GLenum arg1, GLintptr arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glCopyBufferSubData", (void*)glCopyBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); - glad_glCopyBufferSubData(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glCopyBufferSubData", (void*)glCopyBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glCopyBufferSubData(GLenum arg0, + GLenum arg1, + GLintptr arg2, + GLintptr arg3, + GLsizeiptr arg4) { + _pre_call_callback_gl("glCopyBufferSubData", (void *) glCopyBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); + glad_glCopyBufferSubData(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glCopyBufferSubData", (void *) glCopyBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLCOPYBUFFERSUBDATAPROC glad_debug_glCopyBufferSubData = glad_debug_impl_glCopyBufferSubData; PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData; -void APIENTRY glad_debug_impl_glCopyImageSubData(GLuint arg0, GLenum arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLuint arg6, GLenum arg7, GLint arg8, GLint arg9, GLint arg10, GLint arg11, GLsizei arg12, GLsizei arg13, GLsizei arg14) { - _pre_call_callback_gl("glCopyImageSubData", (void*)glCopyImageSubData, 15, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); - glad_glCopyImageSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); - _post_call_callback_gl("glCopyImageSubData", (void*)glCopyImageSubData, 15, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); - + +void APIENTRY glad_debug_impl_glCopyImageSubData(GLuint arg0, + GLenum arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLuint arg6, + GLenum arg7, + GLint arg8, + GLint arg9, + GLint arg10, + GLint arg11, + GLsizei arg12, + GLsizei arg13, + GLsizei arg14) { + _pre_call_callback_gl("glCopyImageSubData", + (void *) glCopyImageSubData, + 15, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14); + glad_glCopyImageSubData(arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14); + _post_call_callback_gl("glCopyImageSubData", + (void *) glCopyImageSubData, + 15, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14); + } + PFNGLCOPYIMAGESUBDATAPROC glad_debug_glCopyImageSubData = glad_debug_impl_glCopyImageSubData; PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData; -void APIENTRY glad_debug_impl_glCopyNamedBufferSubData(GLuint arg0, GLuint arg1, GLintptr arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glCopyNamedBufferSubData", (void*)glCopyNamedBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); - glad_glCopyNamedBufferSubData(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glCopyNamedBufferSubData", (void*)glCopyNamedBufferSubData, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glCopyNamedBufferSubData(GLuint arg0, + GLuint arg1, + GLintptr arg2, + GLintptr arg3, + GLsizeiptr arg4) { + _pre_call_callback_gl("glCopyNamedBufferSubData", + (void *) glCopyNamedBufferSubData, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glCopyNamedBufferSubData(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glCopyNamedBufferSubData", + (void *) glCopyNamedBufferSubData, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_debug_glCopyNamedBufferSubData = glad_debug_impl_glCopyNamedBufferSubData; PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D; -void APIENTRY glad_debug_impl_glCopyTexImage1D(GLenum arg0, GLint arg1, GLenum arg2, GLint arg3, GLint arg4, GLsizei arg5, GLint arg6) { - _pre_call_callback_gl("glCopyTexImage1D", (void*)glCopyTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glCopyTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glCopyTexImage1D", (void*)glCopyTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glCopyTexImage1D(GLenum arg0, + GLint arg1, + GLenum arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLint arg6) { + _pre_call_callback_gl("glCopyTexImage1D", (void *) glCopyTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + glad_glCopyTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glCopyTexImage1D", (void *) glCopyTexImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + } + PFNGLCOPYTEXIMAGE1DPROC glad_debug_glCopyTexImage1D = glad_debug_impl_glCopyTexImage1D; PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D; -void APIENTRY glad_debug_impl_glCopyTexImage2D(GLenum arg0, GLint arg1, GLenum arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLint arg7) { - _pre_call_callback_gl("glCopyTexImage2D", (void*)glCopyTexImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glCopyTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glCopyTexImage2D", (void*)glCopyTexImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glCopyTexImage2D(GLenum arg0, + GLint arg1, + GLenum arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLint arg7) { + _pre_call_callback_gl("glCopyTexImage2D", + (void *) glCopyTexImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glCopyTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glCopyTexImage2D", + (void *) glCopyTexImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLCOPYTEXIMAGE2DPROC glad_debug_glCopyTexImage2D = glad_debug_impl_glCopyTexImage2D; PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D; -void APIENTRY glad_debug_impl_glCopyTexSubImage1D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5) { - _pre_call_callback_gl("glCopyTexSubImage1D", (void*)glCopyTexSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glCopyTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glCopyTexSubImage1D", (void*)glCopyTexSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glCopyTexSubImage1D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5) { + _pre_call_callback_gl("glCopyTexSubImage1D", (void *) glCopyTexSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glCopyTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glCopyTexSubImage1D", (void *) glCopyTexSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLCOPYTEXSUBIMAGE1DPROC glad_debug_glCopyTexSubImage1D = glad_debug_impl_glCopyTexSubImage1D; PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D; -void APIENTRY glad_debug_impl_glCopyTexSubImage2D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLsizei arg6, GLsizei arg7) { - _pre_call_callback_gl("glCopyTexSubImage2D", (void*)glCopyTexSubImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glCopyTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glCopyTexSubImage2D", (void*)glCopyTexSubImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glCopyTexSubImage2D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLsizei arg6, + GLsizei arg7) { + _pre_call_callback_gl("glCopyTexSubImage2D", + (void *) glCopyTexSubImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glCopyTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glCopyTexSubImage2D", + (void *) glCopyTexSubImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLCOPYTEXSUBIMAGE2DPROC glad_debug_glCopyTexSubImage2D = glad_debug_impl_glCopyTexSubImage2D; PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D; -void APIENTRY glad_debug_impl_glCopyTexSubImage3D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLint arg6, GLsizei arg7, GLsizei arg8) { - _pre_call_callback_gl("glCopyTexSubImage3D", (void*)glCopyTexSubImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glCopyTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glCopyTexSubImage3D", (void*)glCopyTexSubImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glCopyTexSubImage3D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLint arg6, + GLsizei arg7, + GLsizei arg8) { + _pre_call_callback_gl("glCopyTexSubImage3D", + (void *) glCopyTexSubImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glCopyTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glCopyTexSubImage3D", + (void *) glCopyTexSubImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLCOPYTEXSUBIMAGE3DPROC glad_debug_glCopyTexSubImage3D = glad_debug_impl_glCopyTexSubImage3D; PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D; -void APIENTRY glad_debug_impl_glCopyTextureSubImage1D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5) { - _pre_call_callback_gl("glCopyTextureSubImage1D", (void*)glCopyTextureSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glCopyTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glCopyTextureSubImage1D", (void*)glCopyTextureSubImage1D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glCopyTextureSubImage1D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5) { + _pre_call_callback_gl("glCopyTextureSubImage1D", + (void *) glCopyTextureSubImage1D, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glCopyTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glCopyTextureSubImage1D", + (void *) glCopyTextureSubImage1D, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_debug_glCopyTextureSubImage1D = glad_debug_impl_glCopyTextureSubImage1D; PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D; -void APIENTRY glad_debug_impl_glCopyTextureSubImage2D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLsizei arg6, GLsizei arg7) { - _pre_call_callback_gl("glCopyTextureSubImage2D", (void*)glCopyTextureSubImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glCopyTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glCopyTextureSubImage2D", (void*)glCopyTextureSubImage2D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glCopyTextureSubImage2D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLsizei arg6, + GLsizei arg7) { + _pre_call_callback_gl("glCopyTextureSubImage2D", + (void *) glCopyTextureSubImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glCopyTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glCopyTextureSubImage2D", + (void *) glCopyTextureSubImage2D, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_debug_glCopyTextureSubImage2D = glad_debug_impl_glCopyTextureSubImage2D; PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D; -void APIENTRY glad_debug_impl_glCopyTextureSubImage3D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5, GLint arg6, GLsizei arg7, GLsizei arg8) { - _pre_call_callback_gl("glCopyTextureSubImage3D", (void*)glCopyTextureSubImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glCopyTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glCopyTextureSubImage3D", (void*)glCopyTextureSubImage3D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glCopyTextureSubImage3D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5, + GLint arg6, + GLsizei arg7, + GLsizei arg8) { + _pre_call_callback_gl("glCopyTextureSubImage3D", + (void *) glCopyTextureSubImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glCopyTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glCopyTextureSubImage3D", + (void *) glCopyTextureSubImage3D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_debug_glCopyTextureSubImage3D = glad_debug_impl_glCopyTextureSubImage3D; PFNGLCREATEBUFFERSPROC glad_glCreateBuffers; -void APIENTRY glad_debug_impl_glCreateBuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateBuffers", (void*)glCreateBuffers, 2, arg0, arg1); - glad_glCreateBuffers(arg0, arg1); - _post_call_callback_gl("glCreateBuffers", (void*)glCreateBuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateBuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateBuffers", (void *) glCreateBuffers, 2, arg0, arg1); + glad_glCreateBuffers(arg0, arg1); + _post_call_callback_gl("glCreateBuffers", (void *) glCreateBuffers, 2, arg0, arg1); + } + PFNGLCREATEBUFFERSPROC glad_debug_glCreateBuffers = glad_debug_impl_glCreateBuffers; PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers; -void APIENTRY glad_debug_impl_glCreateFramebuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateFramebuffers", (void*)glCreateFramebuffers, 2, arg0, arg1); - glad_glCreateFramebuffers(arg0, arg1); - _post_call_callback_gl("glCreateFramebuffers", (void*)glCreateFramebuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateFramebuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateFramebuffers", (void *) glCreateFramebuffers, 2, arg0, arg1); + glad_glCreateFramebuffers(arg0, arg1); + _post_call_callback_gl("glCreateFramebuffers", (void *) glCreateFramebuffers, 2, arg0, arg1); + } + PFNGLCREATEFRAMEBUFFERSPROC glad_debug_glCreateFramebuffers = glad_debug_impl_glCreateFramebuffers; PFNGLCREATEPROGRAMPROC glad_glCreateProgram; -GLuint APIENTRY glad_debug_impl_glCreateProgram(void) { - GLuint ret; - _pre_call_callback_gl("glCreateProgram", (void*)glCreateProgram, 0); - ret = glad_glCreateProgram(); - _post_call_callback_gl("glCreateProgram", (void*)glCreateProgram, 0); - return ret; + +GLuint APIENTRY glad_debug_impl_glCreateProgram(void) { + GLuint ret; + _pre_call_callback_gl("glCreateProgram", (void *) glCreateProgram, 0); + ret = glad_glCreateProgram(); + _post_call_callback_gl("glCreateProgram", (void *) glCreateProgram, 0); + return ret; } + PFNGLCREATEPROGRAMPROC glad_debug_glCreateProgram = glad_debug_impl_glCreateProgram; PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines; -void APIENTRY glad_debug_impl_glCreateProgramPipelines(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateProgramPipelines", (void*)glCreateProgramPipelines, 2, arg0, arg1); - glad_glCreateProgramPipelines(arg0, arg1); - _post_call_callback_gl("glCreateProgramPipelines", (void*)glCreateProgramPipelines, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateProgramPipelines(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateProgramPipelines", (void *) glCreateProgramPipelines, 2, arg0, arg1); + glad_glCreateProgramPipelines(arg0, arg1); + _post_call_callback_gl("glCreateProgramPipelines", (void *) glCreateProgramPipelines, 2, arg0, arg1); + } + PFNGLCREATEPROGRAMPIPELINESPROC glad_debug_glCreateProgramPipelines = glad_debug_impl_glCreateProgramPipelines; PFNGLCREATEQUERIESPROC glad_glCreateQueries; -void APIENTRY glad_debug_impl_glCreateQueries(GLenum arg0, GLsizei arg1, GLuint * arg2) { - _pre_call_callback_gl("glCreateQueries", (void*)glCreateQueries, 3, arg0, arg1, arg2); - glad_glCreateQueries(arg0, arg1, arg2); - _post_call_callback_gl("glCreateQueries", (void*)glCreateQueries, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glCreateQueries(GLenum arg0, GLsizei arg1, GLuint *arg2) { + _pre_call_callback_gl("glCreateQueries", (void *) glCreateQueries, 3, arg0, arg1, arg2); + glad_glCreateQueries(arg0, arg1, arg2); + _post_call_callback_gl("glCreateQueries", (void *) glCreateQueries, 3, arg0, arg1, arg2); + } + PFNGLCREATEQUERIESPROC glad_debug_glCreateQueries = glad_debug_impl_glCreateQueries; PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers; -void APIENTRY glad_debug_impl_glCreateRenderbuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateRenderbuffers", (void*)glCreateRenderbuffers, 2, arg0, arg1); - glad_glCreateRenderbuffers(arg0, arg1); - _post_call_callback_gl("glCreateRenderbuffers", (void*)glCreateRenderbuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateRenderbuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateRenderbuffers", (void *) glCreateRenderbuffers, 2, arg0, arg1); + glad_glCreateRenderbuffers(arg0, arg1); + _post_call_callback_gl("glCreateRenderbuffers", (void *) glCreateRenderbuffers, 2, arg0, arg1); + } + PFNGLCREATERENDERBUFFERSPROC glad_debug_glCreateRenderbuffers = glad_debug_impl_glCreateRenderbuffers; PFNGLCREATESAMPLERSPROC glad_glCreateSamplers; -void APIENTRY glad_debug_impl_glCreateSamplers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateSamplers", (void*)glCreateSamplers, 2, arg0, arg1); - glad_glCreateSamplers(arg0, arg1); - _post_call_callback_gl("glCreateSamplers", (void*)glCreateSamplers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateSamplers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateSamplers", (void *) glCreateSamplers, 2, arg0, arg1); + glad_glCreateSamplers(arg0, arg1); + _post_call_callback_gl("glCreateSamplers", (void *) glCreateSamplers, 2, arg0, arg1); + } + PFNGLCREATESAMPLERSPROC glad_debug_glCreateSamplers = glad_debug_impl_glCreateSamplers; PFNGLCREATESHADERPROC glad_glCreateShader; -GLuint APIENTRY glad_debug_impl_glCreateShader(GLenum arg0) { - GLuint ret; - _pre_call_callback_gl("glCreateShader", (void*)glCreateShader, 1, arg0); - ret = glad_glCreateShader(arg0); - _post_call_callback_gl("glCreateShader", (void*)glCreateShader, 1, arg0); - return ret; + +GLuint APIENTRY glad_debug_impl_glCreateShader(GLenum arg0) { + GLuint ret; + _pre_call_callback_gl("glCreateShader", (void *) glCreateShader, 1, arg0); + ret = glad_glCreateShader(arg0); + _post_call_callback_gl("glCreateShader", (void *) glCreateShader, 1, arg0); + return ret; } + PFNGLCREATESHADERPROC glad_debug_glCreateShader = glad_debug_impl_glCreateShader; PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv; -GLuint APIENTRY glad_debug_impl_glCreateShaderProgramv(GLenum arg0, GLsizei arg1, const GLchar *const* arg2) { - GLuint ret; - _pre_call_callback_gl("glCreateShaderProgramv", (void*)glCreateShaderProgramv, 3, arg0, arg1, arg2); - ret = glad_glCreateShaderProgramv(arg0, arg1, arg2); - _post_call_callback_gl("glCreateShaderProgramv", (void*)glCreateShaderProgramv, 3, arg0, arg1, arg2); - return ret; + +GLuint APIENTRY glad_debug_impl_glCreateShaderProgramv(GLenum arg0, GLsizei arg1, const GLchar *const *arg2) { + GLuint ret; + _pre_call_callback_gl("glCreateShaderProgramv", (void *) glCreateShaderProgramv, 3, arg0, arg1, arg2); + ret = glad_glCreateShaderProgramv(arg0, arg1, arg2); + _post_call_callback_gl("glCreateShaderProgramv", (void *) glCreateShaderProgramv, 3, arg0, arg1, arg2); + return ret; } + PFNGLCREATESHADERPROGRAMVPROC glad_debug_glCreateShaderProgramv = glad_debug_impl_glCreateShaderProgramv; PFNGLCREATETEXTURESPROC glad_glCreateTextures; -void APIENTRY glad_debug_impl_glCreateTextures(GLenum arg0, GLsizei arg1, GLuint * arg2) { - _pre_call_callback_gl("glCreateTextures", (void*)glCreateTextures, 3, arg0, arg1, arg2); - glad_glCreateTextures(arg0, arg1, arg2); - _post_call_callback_gl("glCreateTextures", (void*)glCreateTextures, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glCreateTextures(GLenum arg0, GLsizei arg1, GLuint *arg2) { + _pre_call_callback_gl("glCreateTextures", (void *) glCreateTextures, 3, arg0, arg1, arg2); + glad_glCreateTextures(arg0, arg1, arg2); + _post_call_callback_gl("glCreateTextures", (void *) glCreateTextures, 3, arg0, arg1, arg2); + } + PFNGLCREATETEXTURESPROC glad_debug_glCreateTextures = glad_debug_impl_glCreateTextures; PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks; -void APIENTRY glad_debug_impl_glCreateTransformFeedbacks(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateTransformFeedbacks", (void*)glCreateTransformFeedbacks, 2, arg0, arg1); - glad_glCreateTransformFeedbacks(arg0, arg1); - _post_call_callback_gl("glCreateTransformFeedbacks", (void*)glCreateTransformFeedbacks, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateTransformFeedbacks(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateTransformFeedbacks", (void *) glCreateTransformFeedbacks, 2, arg0, arg1); + glad_glCreateTransformFeedbacks(arg0, arg1); + _post_call_callback_gl("glCreateTransformFeedbacks", (void *) glCreateTransformFeedbacks, 2, arg0, arg1); + } + PFNGLCREATETRANSFORMFEEDBACKSPROC glad_debug_glCreateTransformFeedbacks = glad_debug_impl_glCreateTransformFeedbacks; PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays; -void APIENTRY glad_debug_impl_glCreateVertexArrays(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glCreateVertexArrays", (void*)glCreateVertexArrays, 2, arg0, arg1); - glad_glCreateVertexArrays(arg0, arg1); - _post_call_callback_gl("glCreateVertexArrays", (void*)glCreateVertexArrays, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glCreateVertexArrays(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glCreateVertexArrays", (void *) glCreateVertexArrays, 2, arg0, arg1); + glad_glCreateVertexArrays(arg0, arg1); + _post_call_callback_gl("glCreateVertexArrays", (void *) glCreateVertexArrays, 2, arg0, arg1); + } + PFNGLCREATEVERTEXARRAYSPROC glad_debug_glCreateVertexArrays = glad_debug_impl_glCreateVertexArrays; PFNGLCULLFACEPROC glad_glCullFace; -void APIENTRY glad_debug_impl_glCullFace(GLenum arg0) { - _pre_call_callback_gl("glCullFace", (void*)glCullFace, 1, arg0); - glad_glCullFace(arg0); - _post_call_callback_gl("glCullFace", (void*)glCullFace, 1, arg0); - + +void APIENTRY glad_debug_impl_glCullFace(GLenum arg0) { + _pre_call_callback_gl("glCullFace", (void *) glCullFace, 1, arg0); + glad_glCullFace(arg0); + _post_call_callback_gl("glCullFace", (void *) glCullFace, 1, arg0); + } + PFNGLCULLFACEPROC glad_debug_glCullFace = glad_debug_impl_glCullFace; PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback; -void APIENTRY glad_debug_impl_glDebugMessageCallback(GLDEBUGPROC arg0, const void * arg1) { - _pre_call_callback_gl("glDebugMessageCallback", (void*)glDebugMessageCallback, 2, arg0, arg1); - glad_glDebugMessageCallback(arg0, arg1); - _post_call_callback_gl("glDebugMessageCallback", (void*)glDebugMessageCallback, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDebugMessageCallback(GLDEBUGPROC arg0, const void *arg1) { + _pre_call_callback_gl("glDebugMessageCallback", (void *) glDebugMessageCallback, 2, arg0, arg1); + glad_glDebugMessageCallback(arg0, arg1); + _post_call_callback_gl("glDebugMessageCallback", (void *) glDebugMessageCallback, 2, arg0, arg1); + } + PFNGLDEBUGMESSAGECALLBACKPROC glad_debug_glDebugMessageCallback = glad_debug_impl_glDebugMessageCallback; PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl; -void APIENTRY glad_debug_impl_glDebugMessageControl(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, const GLuint * arg4, GLboolean arg5) { - _pre_call_callback_gl("glDebugMessageControl", (void*)glDebugMessageControl, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glDebugMessageControl(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glDebugMessageControl", (void*)glDebugMessageControl, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glDebugMessageControl(GLenum arg0, + GLenum arg1, + GLenum arg2, + GLsizei arg3, + const GLuint *arg4, + GLboolean arg5) { + _pre_call_callback_gl("glDebugMessageControl", + (void *) glDebugMessageControl, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glDebugMessageControl(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glDebugMessageControl", + (void *) glDebugMessageControl, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLDEBUGMESSAGECONTROLPROC glad_debug_glDebugMessageControl = glad_debug_impl_glDebugMessageControl; PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert; -void APIENTRY glad_debug_impl_glDebugMessageInsert(GLenum arg0, GLenum arg1, GLuint arg2, GLenum arg3, GLsizei arg4, const GLchar * arg5) { - _pre_call_callback_gl("glDebugMessageInsert", (void*)glDebugMessageInsert, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glDebugMessageInsert(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glDebugMessageInsert", (void*)glDebugMessageInsert, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glDebugMessageInsert(GLenum arg0, + GLenum arg1, + GLuint arg2, + GLenum arg3, + GLsizei arg4, + const GLchar *arg5) { + _pre_call_callback_gl("glDebugMessageInsert", (void *) glDebugMessageInsert, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glDebugMessageInsert(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glDebugMessageInsert", + (void *) glDebugMessageInsert, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLDEBUGMESSAGEINSERTPROC glad_debug_glDebugMessageInsert = glad_debug_impl_glDebugMessageInsert; PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers; -void APIENTRY glad_debug_impl_glDeleteBuffers(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteBuffers", (void*)glDeleteBuffers, 2, arg0, arg1); - glad_glDeleteBuffers(arg0, arg1); - _post_call_callback_gl("glDeleteBuffers", (void*)glDeleteBuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteBuffers(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteBuffers", (void *) glDeleteBuffers, 2, arg0, arg1); + glad_glDeleteBuffers(arg0, arg1); + _post_call_callback_gl("glDeleteBuffers", (void *) glDeleteBuffers, 2, arg0, arg1); + } + PFNGLDELETEBUFFERSPROC glad_debug_glDeleteBuffers = glad_debug_impl_glDeleteBuffers; PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers; -void APIENTRY glad_debug_impl_glDeleteFramebuffers(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteFramebuffers", (void*)glDeleteFramebuffers, 2, arg0, arg1); - glad_glDeleteFramebuffers(arg0, arg1); - _post_call_callback_gl("glDeleteFramebuffers", (void*)glDeleteFramebuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteFramebuffers(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteFramebuffers", (void *) glDeleteFramebuffers, 2, arg0, arg1); + glad_glDeleteFramebuffers(arg0, arg1); + _post_call_callback_gl("glDeleteFramebuffers", (void *) glDeleteFramebuffers, 2, arg0, arg1); + } + PFNGLDELETEFRAMEBUFFERSPROC glad_debug_glDeleteFramebuffers = glad_debug_impl_glDeleteFramebuffers; PFNGLDELETEPROGRAMPROC glad_glDeleteProgram; -void APIENTRY glad_debug_impl_glDeleteProgram(GLuint arg0) { - _pre_call_callback_gl("glDeleteProgram", (void*)glDeleteProgram, 1, arg0); - glad_glDeleteProgram(arg0); - _post_call_callback_gl("glDeleteProgram", (void*)glDeleteProgram, 1, arg0); - + +void APIENTRY glad_debug_impl_glDeleteProgram(GLuint arg0) { + _pre_call_callback_gl("glDeleteProgram", (void *) glDeleteProgram, 1, arg0); + glad_glDeleteProgram(arg0); + _post_call_callback_gl("glDeleteProgram", (void *) glDeleteProgram, 1, arg0); + } + PFNGLDELETEPROGRAMPROC glad_debug_glDeleteProgram = glad_debug_impl_glDeleteProgram; PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines; -void APIENTRY glad_debug_impl_glDeleteProgramPipelines(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteProgramPipelines", (void*)glDeleteProgramPipelines, 2, arg0, arg1); - glad_glDeleteProgramPipelines(arg0, arg1); - _post_call_callback_gl("glDeleteProgramPipelines", (void*)glDeleteProgramPipelines, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteProgramPipelines(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteProgramPipelines", (void *) glDeleteProgramPipelines, 2, arg0, arg1); + glad_glDeleteProgramPipelines(arg0, arg1); + _post_call_callback_gl("glDeleteProgramPipelines", (void *) glDeleteProgramPipelines, 2, arg0, arg1); + } + PFNGLDELETEPROGRAMPIPELINESPROC glad_debug_glDeleteProgramPipelines = glad_debug_impl_glDeleteProgramPipelines; PFNGLDELETEQUERIESPROC glad_glDeleteQueries; -void APIENTRY glad_debug_impl_glDeleteQueries(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteQueries", (void*)glDeleteQueries, 2, arg0, arg1); - glad_glDeleteQueries(arg0, arg1); - _post_call_callback_gl("glDeleteQueries", (void*)glDeleteQueries, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteQueries(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteQueries", (void *) glDeleteQueries, 2, arg0, arg1); + glad_glDeleteQueries(arg0, arg1); + _post_call_callback_gl("glDeleteQueries", (void *) glDeleteQueries, 2, arg0, arg1); + } + PFNGLDELETEQUERIESPROC glad_debug_glDeleteQueries = glad_debug_impl_glDeleteQueries; PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers; -void APIENTRY glad_debug_impl_glDeleteRenderbuffers(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteRenderbuffers", (void*)glDeleteRenderbuffers, 2, arg0, arg1); - glad_glDeleteRenderbuffers(arg0, arg1); - _post_call_callback_gl("glDeleteRenderbuffers", (void*)glDeleteRenderbuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteRenderbuffers(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteRenderbuffers", (void *) glDeleteRenderbuffers, 2, arg0, arg1); + glad_glDeleteRenderbuffers(arg0, arg1); + _post_call_callback_gl("glDeleteRenderbuffers", (void *) glDeleteRenderbuffers, 2, arg0, arg1); + } + PFNGLDELETERENDERBUFFERSPROC glad_debug_glDeleteRenderbuffers = glad_debug_impl_glDeleteRenderbuffers; PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers; -void APIENTRY glad_debug_impl_glDeleteSamplers(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteSamplers", (void*)glDeleteSamplers, 2, arg0, arg1); - glad_glDeleteSamplers(arg0, arg1); - _post_call_callback_gl("glDeleteSamplers", (void*)glDeleteSamplers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteSamplers(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteSamplers", (void *) glDeleteSamplers, 2, arg0, arg1); + glad_glDeleteSamplers(arg0, arg1); + _post_call_callback_gl("glDeleteSamplers", (void *) glDeleteSamplers, 2, arg0, arg1); + } + PFNGLDELETESAMPLERSPROC glad_debug_glDeleteSamplers = glad_debug_impl_glDeleteSamplers; PFNGLDELETESHADERPROC glad_glDeleteShader; -void APIENTRY glad_debug_impl_glDeleteShader(GLuint arg0) { - _pre_call_callback_gl("glDeleteShader", (void*)glDeleteShader, 1, arg0); - glad_glDeleteShader(arg0); - _post_call_callback_gl("glDeleteShader", (void*)glDeleteShader, 1, arg0); - + +void APIENTRY glad_debug_impl_glDeleteShader(GLuint arg0) { + _pre_call_callback_gl("glDeleteShader", (void *) glDeleteShader, 1, arg0); + glad_glDeleteShader(arg0); + _post_call_callback_gl("glDeleteShader", (void *) glDeleteShader, 1, arg0); + } + PFNGLDELETESHADERPROC glad_debug_glDeleteShader = glad_debug_impl_glDeleteShader; PFNGLDELETESYNCPROC glad_glDeleteSync; -void APIENTRY glad_debug_impl_glDeleteSync(GLsync arg0) { - _pre_call_callback_gl("glDeleteSync", (void*)glDeleteSync, 1, arg0); - glad_glDeleteSync(arg0); - _post_call_callback_gl("glDeleteSync", (void*)glDeleteSync, 1, arg0); - + +void APIENTRY glad_debug_impl_glDeleteSync(GLsync arg0) { + _pre_call_callback_gl("glDeleteSync", (void *) glDeleteSync, 1, arg0); + glad_glDeleteSync(arg0); + _post_call_callback_gl("glDeleteSync", (void *) glDeleteSync, 1, arg0); + } + PFNGLDELETESYNCPROC glad_debug_glDeleteSync = glad_debug_impl_glDeleteSync; PFNGLDELETETEXTURESPROC glad_glDeleteTextures; -void APIENTRY glad_debug_impl_glDeleteTextures(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteTextures", (void*)glDeleteTextures, 2, arg0, arg1); - glad_glDeleteTextures(arg0, arg1); - _post_call_callback_gl("glDeleteTextures", (void*)glDeleteTextures, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteTextures(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteTextures", (void *) glDeleteTextures, 2, arg0, arg1); + glad_glDeleteTextures(arg0, arg1); + _post_call_callback_gl("glDeleteTextures", (void *) glDeleteTextures, 2, arg0, arg1); + } + PFNGLDELETETEXTURESPROC glad_debug_glDeleteTextures = glad_debug_impl_glDeleteTextures; PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks; -void APIENTRY glad_debug_impl_glDeleteTransformFeedbacks(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteTransformFeedbacks", (void*)glDeleteTransformFeedbacks, 2, arg0, arg1); - glad_glDeleteTransformFeedbacks(arg0, arg1); - _post_call_callback_gl("glDeleteTransformFeedbacks", (void*)glDeleteTransformFeedbacks, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteTransformFeedbacks(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteTransformFeedbacks", (void *) glDeleteTransformFeedbacks, 2, arg0, arg1); + glad_glDeleteTransformFeedbacks(arg0, arg1); + _post_call_callback_gl("glDeleteTransformFeedbacks", (void *) glDeleteTransformFeedbacks, 2, arg0, arg1); + } + PFNGLDELETETRANSFORMFEEDBACKSPROC glad_debug_glDeleteTransformFeedbacks = glad_debug_impl_glDeleteTransformFeedbacks; PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays; -void APIENTRY glad_debug_impl_glDeleteVertexArrays(GLsizei arg0, const GLuint * arg1) { - _pre_call_callback_gl("glDeleteVertexArrays", (void*)glDeleteVertexArrays, 2, arg0, arg1); - glad_glDeleteVertexArrays(arg0, arg1); - _post_call_callback_gl("glDeleteVertexArrays", (void*)glDeleteVertexArrays, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteVertexArrays(GLsizei arg0, const GLuint *arg1) { + _pre_call_callback_gl("glDeleteVertexArrays", (void *) glDeleteVertexArrays, 2, arg0, arg1); + glad_glDeleteVertexArrays(arg0, arg1); + _post_call_callback_gl("glDeleteVertexArrays", (void *) glDeleteVertexArrays, 2, arg0, arg1); + } + PFNGLDELETEVERTEXARRAYSPROC glad_debug_glDeleteVertexArrays = glad_debug_impl_glDeleteVertexArrays; PFNGLDEPTHFUNCPROC glad_glDepthFunc; -void APIENTRY glad_debug_impl_glDepthFunc(GLenum arg0) { - _pre_call_callback_gl("glDepthFunc", (void*)glDepthFunc, 1, arg0); - glad_glDepthFunc(arg0); - _post_call_callback_gl("glDepthFunc", (void*)glDepthFunc, 1, arg0); - + +void APIENTRY glad_debug_impl_glDepthFunc(GLenum arg0) { + _pre_call_callback_gl("glDepthFunc", (void *) glDepthFunc, 1, arg0); + glad_glDepthFunc(arg0); + _post_call_callback_gl("glDepthFunc", (void *) glDepthFunc, 1, arg0); + } + PFNGLDEPTHFUNCPROC glad_debug_glDepthFunc = glad_debug_impl_glDepthFunc; PFNGLDEPTHMASKPROC glad_glDepthMask; -void APIENTRY glad_debug_impl_glDepthMask(GLboolean arg0) { - _pre_call_callback_gl("glDepthMask", (void*)glDepthMask, 1, arg0); - glad_glDepthMask(arg0); - _post_call_callback_gl("glDepthMask", (void*)glDepthMask, 1, arg0); - + +void APIENTRY glad_debug_impl_glDepthMask(GLboolean arg0) { + _pre_call_callback_gl("glDepthMask", (void *) glDepthMask, 1, arg0); + glad_glDepthMask(arg0); + _post_call_callback_gl("glDepthMask", (void *) glDepthMask, 1, arg0); + } + PFNGLDEPTHMASKPROC glad_debug_glDepthMask = glad_debug_impl_glDepthMask; PFNGLDEPTHRANGEPROC glad_glDepthRange; -void APIENTRY glad_debug_impl_glDepthRange(GLdouble arg0, GLdouble arg1) { - _pre_call_callback_gl("glDepthRange", (void*)glDepthRange, 2, arg0, arg1); - glad_glDepthRange(arg0, arg1); - _post_call_callback_gl("glDepthRange", (void*)glDepthRange, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDepthRange(GLdouble arg0, GLdouble arg1) { + _pre_call_callback_gl("glDepthRange", (void *) glDepthRange, 2, arg0, arg1); + glad_glDepthRange(arg0, arg1); + _post_call_callback_gl("glDepthRange", (void *) glDepthRange, 2, arg0, arg1); + } + PFNGLDEPTHRANGEPROC glad_debug_glDepthRange = glad_debug_impl_glDepthRange; PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv; -void APIENTRY glad_debug_impl_glDepthRangeArrayv(GLuint arg0, GLsizei arg1, const GLdouble * arg2) { - _pre_call_callback_gl("glDepthRangeArrayv", (void*)glDepthRangeArrayv, 3, arg0, arg1, arg2); - glad_glDepthRangeArrayv(arg0, arg1, arg2); - _post_call_callback_gl("glDepthRangeArrayv", (void*)glDepthRangeArrayv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDepthRangeArrayv(GLuint arg0, GLsizei arg1, const GLdouble *arg2) { + _pre_call_callback_gl("glDepthRangeArrayv", (void *) glDepthRangeArrayv, 3, arg0, arg1, arg2); + glad_glDepthRangeArrayv(arg0, arg1, arg2); + _post_call_callback_gl("glDepthRangeArrayv", (void *) glDepthRangeArrayv, 3, arg0, arg1, arg2); + } + PFNGLDEPTHRANGEARRAYVPROC glad_debug_glDepthRangeArrayv = glad_debug_impl_glDepthRangeArrayv; PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed; -void APIENTRY glad_debug_impl_glDepthRangeIndexed(GLuint arg0, GLdouble arg1, GLdouble arg2) { - _pre_call_callback_gl("glDepthRangeIndexed", (void*)glDepthRangeIndexed, 3, arg0, arg1, arg2); - glad_glDepthRangeIndexed(arg0, arg1, arg2); - _post_call_callback_gl("glDepthRangeIndexed", (void*)glDepthRangeIndexed, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDepthRangeIndexed(GLuint arg0, GLdouble arg1, GLdouble arg2) { + _pre_call_callback_gl("glDepthRangeIndexed", (void *) glDepthRangeIndexed, 3, arg0, arg1, arg2); + glad_glDepthRangeIndexed(arg0, arg1, arg2); + _post_call_callback_gl("glDepthRangeIndexed", (void *) glDepthRangeIndexed, 3, arg0, arg1, arg2); + } + PFNGLDEPTHRANGEINDEXEDPROC glad_debug_glDepthRangeIndexed = glad_debug_impl_glDepthRangeIndexed; PFNGLDEPTHRANGEFPROC glad_glDepthRangef; -void APIENTRY glad_debug_impl_glDepthRangef(GLfloat arg0, GLfloat arg1) { - _pre_call_callback_gl("glDepthRangef", (void*)glDepthRangef, 2, arg0, arg1); - glad_glDepthRangef(arg0, arg1); - _post_call_callback_gl("glDepthRangef", (void*)glDepthRangef, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDepthRangef(GLfloat arg0, GLfloat arg1) { + _pre_call_callback_gl("glDepthRangef", (void *) glDepthRangef, 2, arg0, arg1); + glad_glDepthRangef(arg0, arg1); + _post_call_callback_gl("glDepthRangef", (void *) glDepthRangef, 2, arg0, arg1); + } + PFNGLDEPTHRANGEFPROC glad_debug_glDepthRangef = glad_debug_impl_glDepthRangef; PFNGLDETACHSHADERPROC glad_glDetachShader; -void APIENTRY glad_debug_impl_glDetachShader(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glDetachShader", (void*)glDetachShader, 2, arg0, arg1); - glad_glDetachShader(arg0, arg1); - _post_call_callback_gl("glDetachShader", (void*)glDetachShader, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDetachShader(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glDetachShader", (void *) glDetachShader, 2, arg0, arg1); + glad_glDetachShader(arg0, arg1); + _post_call_callback_gl("glDetachShader", (void *) glDetachShader, 2, arg0, arg1); + } + PFNGLDETACHSHADERPROC glad_debug_glDetachShader = glad_debug_impl_glDetachShader; PFNGLDISABLEPROC glad_glDisable; -void APIENTRY glad_debug_impl_glDisable(GLenum arg0) { - _pre_call_callback_gl("glDisable", (void*)glDisable, 1, arg0); - glad_glDisable(arg0); - _post_call_callback_gl("glDisable", (void*)glDisable, 1, arg0); - + +void APIENTRY glad_debug_impl_glDisable(GLenum arg0) { + _pre_call_callback_gl("glDisable", (void *) glDisable, 1, arg0); + glad_glDisable(arg0); + _post_call_callback_gl("glDisable", (void *) glDisable, 1, arg0); + } + PFNGLDISABLEPROC glad_debug_glDisable = glad_debug_impl_glDisable; PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib; -void APIENTRY glad_debug_impl_glDisableVertexArrayAttrib(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glDisableVertexArrayAttrib", (void*)glDisableVertexArrayAttrib, 2, arg0, arg1); - glad_glDisableVertexArrayAttrib(arg0, arg1); - _post_call_callback_gl("glDisableVertexArrayAttrib", (void*)glDisableVertexArrayAttrib, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDisableVertexArrayAttrib(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glDisableVertexArrayAttrib", (void *) glDisableVertexArrayAttrib, 2, arg0, arg1); + glad_glDisableVertexArrayAttrib(arg0, arg1); + _post_call_callback_gl("glDisableVertexArrayAttrib", (void *) glDisableVertexArrayAttrib, 2, arg0, arg1); + } + PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_debug_glDisableVertexArrayAttrib = glad_debug_impl_glDisableVertexArrayAttrib; PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray; -void APIENTRY glad_debug_impl_glDisableVertexAttribArray(GLuint arg0) { - _pre_call_callback_gl("glDisableVertexAttribArray", (void*)glDisableVertexAttribArray, 1, arg0); - glad_glDisableVertexAttribArray(arg0); - _post_call_callback_gl("glDisableVertexAttribArray", (void*)glDisableVertexAttribArray, 1, arg0); - + +void APIENTRY glad_debug_impl_glDisableVertexAttribArray(GLuint arg0) { + _pre_call_callback_gl("glDisableVertexAttribArray", (void *) glDisableVertexAttribArray, 1, arg0); + glad_glDisableVertexAttribArray(arg0); + _post_call_callback_gl("glDisableVertexAttribArray", (void *) glDisableVertexAttribArray, 1, arg0); + } + PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_debug_glDisableVertexAttribArray = glad_debug_impl_glDisableVertexAttribArray; PFNGLDISABLEIPROC glad_glDisablei; -void APIENTRY glad_debug_impl_glDisablei(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glDisablei", (void*)glDisablei, 2, arg0, arg1); - glad_glDisablei(arg0, arg1); - _post_call_callback_gl("glDisablei", (void*)glDisablei, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDisablei(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glDisablei", (void *) glDisablei, 2, arg0, arg1); + glad_glDisablei(arg0, arg1); + _post_call_callback_gl("glDisablei", (void *) glDisablei, 2, arg0, arg1); + } + PFNGLDISABLEIPROC glad_debug_glDisablei = glad_debug_impl_glDisablei; PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute; -void APIENTRY glad_debug_impl_glDispatchCompute(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glDispatchCompute", (void*)glDispatchCompute, 3, arg0, arg1, arg2); - glad_glDispatchCompute(arg0, arg1, arg2); - _post_call_callback_gl("glDispatchCompute", (void*)glDispatchCompute, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDispatchCompute(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glDispatchCompute", (void *) glDispatchCompute, 3, arg0, arg1, arg2); + glad_glDispatchCompute(arg0, arg1, arg2); + _post_call_callback_gl("glDispatchCompute", (void *) glDispatchCompute, 3, arg0, arg1, arg2); + } + PFNGLDISPATCHCOMPUTEPROC glad_debug_glDispatchCompute = glad_debug_impl_glDispatchCompute; PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect; -void APIENTRY glad_debug_impl_glDispatchComputeIndirect(GLintptr arg0) { - _pre_call_callback_gl("glDispatchComputeIndirect", (void*)glDispatchComputeIndirect, 1, arg0); - glad_glDispatchComputeIndirect(arg0); - _post_call_callback_gl("glDispatchComputeIndirect", (void*)glDispatchComputeIndirect, 1, arg0); - + +void APIENTRY glad_debug_impl_glDispatchComputeIndirect(GLintptr arg0) { + _pre_call_callback_gl("glDispatchComputeIndirect", (void *) glDispatchComputeIndirect, 1, arg0); + glad_glDispatchComputeIndirect(arg0); + _post_call_callback_gl("glDispatchComputeIndirect", (void *) glDispatchComputeIndirect, 1, arg0); + } + PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_debug_glDispatchComputeIndirect = glad_debug_impl_glDispatchComputeIndirect; PFNGLDRAWARRAYSPROC glad_glDrawArrays; -void APIENTRY glad_debug_impl_glDrawArrays(GLenum arg0, GLint arg1, GLsizei arg2) { - _pre_call_callback_gl("glDrawArrays", (void*)glDrawArrays, 3, arg0, arg1, arg2); - glad_glDrawArrays(arg0, arg1, arg2); - _post_call_callback_gl("glDrawArrays", (void*)glDrawArrays, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDrawArrays(GLenum arg0, GLint arg1, GLsizei arg2) { + _pre_call_callback_gl("glDrawArrays", (void *) glDrawArrays, 3, arg0, arg1, arg2); + glad_glDrawArrays(arg0, arg1, arg2); + _post_call_callback_gl("glDrawArrays", (void *) glDrawArrays, 3, arg0, arg1, arg2); + } + PFNGLDRAWARRAYSPROC glad_debug_glDrawArrays = glad_debug_impl_glDrawArrays; PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect; -void APIENTRY glad_debug_impl_glDrawArraysIndirect(GLenum arg0, const void * arg1) { - _pre_call_callback_gl("glDrawArraysIndirect", (void*)glDrawArraysIndirect, 2, arg0, arg1); - glad_glDrawArraysIndirect(arg0, arg1); - _post_call_callback_gl("glDrawArraysIndirect", (void*)glDrawArraysIndirect, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDrawArraysIndirect(GLenum arg0, const void *arg1) { + _pre_call_callback_gl("glDrawArraysIndirect", (void *) glDrawArraysIndirect, 2, arg0, arg1); + glad_glDrawArraysIndirect(arg0, arg1); + _post_call_callback_gl("glDrawArraysIndirect", (void *) glDrawArraysIndirect, 2, arg0, arg1); + } + PFNGLDRAWARRAYSINDIRECTPROC glad_debug_glDrawArraysIndirect = glad_debug_impl_glDrawArraysIndirect; PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced; -void APIENTRY glad_debug_impl_glDrawArraysInstanced(GLenum arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glDrawArraysInstanced", (void*)glDrawArraysInstanced, 4, arg0, arg1, arg2, arg3); - glad_glDrawArraysInstanced(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glDrawArraysInstanced", (void*)glDrawArraysInstanced, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glDrawArraysInstanced(GLenum arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glDrawArraysInstanced", (void *) glDrawArraysInstanced, 4, arg0, arg1, arg2, arg3); + glad_glDrawArraysInstanced(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glDrawArraysInstanced", (void *) glDrawArraysInstanced, 4, arg0, arg1, arg2, arg3); + } + PFNGLDRAWARRAYSINSTANCEDPROC glad_debug_glDrawArraysInstanced = glad_debug_impl_glDrawArraysInstanced; PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance; -void APIENTRY glad_debug_impl_glDrawArraysInstancedBaseInstance(GLenum arg0, GLint arg1, GLsizei arg2, GLsizei arg3, GLuint arg4) { - _pre_call_callback_gl("glDrawArraysInstancedBaseInstance", (void*)glDrawArraysInstancedBaseInstance, 5, arg0, arg1, arg2, arg3, arg4); - glad_glDrawArraysInstancedBaseInstance(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glDrawArraysInstancedBaseInstance", (void*)glDrawArraysInstancedBaseInstance, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glDrawArraysInstancedBaseInstance(GLenum arg0, + GLint arg1, + GLsizei arg2, + GLsizei arg3, + GLuint arg4) { + _pre_call_callback_gl("glDrawArraysInstancedBaseInstance", + (void *) glDrawArraysInstancedBaseInstance, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glDrawArraysInstancedBaseInstance(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glDrawArraysInstancedBaseInstance", + (void *) glDrawArraysInstancedBaseInstance, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_debug_glDrawArraysInstancedBaseInstance = glad_debug_impl_glDrawArraysInstancedBaseInstance; + +PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC + glad_debug_glDrawArraysInstancedBaseInstance = glad_debug_impl_glDrawArraysInstancedBaseInstance; PFNGLDRAWBUFFERPROC glad_glDrawBuffer; -void APIENTRY glad_debug_impl_glDrawBuffer(GLenum arg0) { - _pre_call_callback_gl("glDrawBuffer", (void*)glDrawBuffer, 1, arg0); - glad_glDrawBuffer(arg0); - _post_call_callback_gl("glDrawBuffer", (void*)glDrawBuffer, 1, arg0); - + +void APIENTRY glad_debug_impl_glDrawBuffer(GLenum arg0) { + _pre_call_callback_gl("glDrawBuffer", (void *) glDrawBuffer, 1, arg0); + glad_glDrawBuffer(arg0); + _post_call_callback_gl("glDrawBuffer", (void *) glDrawBuffer, 1, arg0); + } + PFNGLDRAWBUFFERPROC glad_debug_glDrawBuffer = glad_debug_impl_glDrawBuffer; PFNGLDRAWBUFFERSPROC glad_glDrawBuffers; -void APIENTRY glad_debug_impl_glDrawBuffers(GLsizei arg0, const GLenum * arg1) { - _pre_call_callback_gl("glDrawBuffers", (void*)glDrawBuffers, 2, arg0, arg1); - glad_glDrawBuffers(arg0, arg1); - _post_call_callback_gl("glDrawBuffers", (void*)glDrawBuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDrawBuffers(GLsizei arg0, const GLenum *arg1) { + _pre_call_callback_gl("glDrawBuffers", (void *) glDrawBuffers, 2, arg0, arg1); + glad_glDrawBuffers(arg0, arg1); + _post_call_callback_gl("glDrawBuffers", (void *) glDrawBuffers, 2, arg0, arg1); + } + PFNGLDRAWBUFFERSPROC glad_debug_glDrawBuffers = glad_debug_impl_glDrawBuffers; PFNGLDRAWELEMENTSPROC glad_glDrawElements; -void APIENTRY glad_debug_impl_glDrawElements(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3) { - _pre_call_callback_gl("glDrawElements", (void*)glDrawElements, 4, arg0, arg1, arg2, arg3); - glad_glDrawElements(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glDrawElements", (void*)glDrawElements, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glDrawElements(GLenum arg0, GLsizei arg1, GLenum arg2, const void *arg3) { + _pre_call_callback_gl("glDrawElements", (void *) glDrawElements, 4, arg0, arg1, arg2, arg3); + glad_glDrawElements(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glDrawElements", (void *) glDrawElements, 4, arg0, arg1, arg2, arg3); + } + PFNGLDRAWELEMENTSPROC glad_debug_glDrawElements = glad_debug_impl_glDrawElements; PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex; -void APIENTRY glad_debug_impl_glDrawElementsBaseVertex(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3, GLint arg4) { - _pre_call_callback_gl("glDrawElementsBaseVertex", (void*)glDrawElementsBaseVertex, 5, arg0, arg1, arg2, arg3, arg4); - glad_glDrawElementsBaseVertex(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glDrawElementsBaseVertex", (void*)glDrawElementsBaseVertex, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glDrawElementsBaseVertex(GLenum arg0, + GLsizei arg1, + GLenum arg2, + const void *arg3, + GLint arg4) { + _pre_call_callback_gl("glDrawElementsBaseVertex", + (void *) glDrawElementsBaseVertex, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glDrawElementsBaseVertex(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glDrawElementsBaseVertex", + (void *) glDrawElementsBaseVertex, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLDRAWELEMENTSBASEVERTEXPROC glad_debug_glDrawElementsBaseVertex = glad_debug_impl_glDrawElementsBaseVertex; PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect; -void APIENTRY glad_debug_impl_glDrawElementsIndirect(GLenum arg0, GLenum arg1, const void * arg2) { - _pre_call_callback_gl("glDrawElementsIndirect", (void*)glDrawElementsIndirect, 3, arg0, arg1, arg2); - glad_glDrawElementsIndirect(arg0, arg1, arg2); - _post_call_callback_gl("glDrawElementsIndirect", (void*)glDrawElementsIndirect, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDrawElementsIndirect(GLenum arg0, GLenum arg1, const void *arg2) { + _pre_call_callback_gl("glDrawElementsIndirect", (void *) glDrawElementsIndirect, 3, arg0, arg1, arg2); + glad_glDrawElementsIndirect(arg0, arg1, arg2); + _post_call_callback_gl("glDrawElementsIndirect", (void *) glDrawElementsIndirect, 3, arg0, arg1, arg2); + } + PFNGLDRAWELEMENTSINDIRECTPROC glad_debug_glDrawElementsIndirect = glad_debug_impl_glDrawElementsIndirect; PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced; -void APIENTRY glad_debug_impl_glDrawElementsInstanced(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3, GLsizei arg4) { - _pre_call_callback_gl("glDrawElementsInstanced", (void*)glDrawElementsInstanced, 5, arg0, arg1, arg2, arg3, arg4); - glad_glDrawElementsInstanced(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glDrawElementsInstanced", (void*)glDrawElementsInstanced, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glDrawElementsInstanced(GLenum arg0, + GLsizei arg1, + GLenum arg2, + const void *arg3, + GLsizei arg4) { + _pre_call_callback_gl("glDrawElementsInstanced", (void *) glDrawElementsInstanced, 5, arg0, arg1, arg2, arg3, arg4); + glad_glDrawElementsInstanced(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glDrawElementsInstanced", + (void *) glDrawElementsInstanced, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLDRAWELEMENTSINSTANCEDPROC glad_debug_glDrawElementsInstanced = glad_debug_impl_glDrawElementsInstanced; PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance; -void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseInstance(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3, GLsizei arg4, GLuint arg5) { - _pre_call_callback_gl("glDrawElementsInstancedBaseInstance", (void*)glDrawElementsInstancedBaseInstance, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glDrawElementsInstancedBaseInstance(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glDrawElementsInstancedBaseInstance", (void*)glDrawElementsInstancedBaseInstance, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseInstance(GLenum arg0, + GLsizei arg1, + GLenum arg2, + const void *arg3, + GLsizei arg4, + GLuint arg5) { + _pre_call_callback_gl("glDrawElementsInstancedBaseInstance", + (void *) glDrawElementsInstancedBaseInstance, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glDrawElementsInstancedBaseInstance(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glDrawElementsInstancedBaseInstance", + (void *) glDrawElementsInstancedBaseInstance, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } -PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_debug_glDrawElementsInstancedBaseInstance = glad_debug_impl_glDrawElementsInstancedBaseInstance; + +PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC + glad_debug_glDrawElementsInstancedBaseInstance = glad_debug_impl_glDrawElementsInstancedBaseInstance; PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex; -void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseVertex(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3, GLsizei arg4, GLint arg5) { - _pre_call_callback_gl("glDrawElementsInstancedBaseVertex", (void*)glDrawElementsInstancedBaseVertex, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glDrawElementsInstancedBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glDrawElementsInstancedBaseVertex", (void*)glDrawElementsInstancedBaseVertex, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseVertex(GLenum arg0, + GLsizei arg1, + GLenum arg2, + const void *arg3, + GLsizei arg4, + GLint arg5) { + _pre_call_callback_gl("glDrawElementsInstancedBaseVertex", + (void *) glDrawElementsInstancedBaseVertex, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glDrawElementsInstancedBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glDrawElementsInstancedBaseVertex", + (void *) glDrawElementsInstancedBaseVertex, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } -PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_debug_glDrawElementsInstancedBaseVertex = glad_debug_impl_glDrawElementsInstancedBaseVertex; + +PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC + glad_debug_glDrawElementsInstancedBaseVertex = glad_debug_impl_glDrawElementsInstancedBaseVertex; PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance; -void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseVertexBaseInstance(GLenum arg0, GLsizei arg1, GLenum arg2, const void * arg3, GLsizei arg4, GLint arg5, GLuint arg6) { - _pre_call_callback_gl("glDrawElementsInstancedBaseVertexBaseInstance", (void*)glDrawElementsInstancedBaseVertexBaseInstance, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glDrawElementsInstancedBaseVertexBaseInstance(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glDrawElementsInstancedBaseVertexBaseInstance", (void*)glDrawElementsInstancedBaseVertexBaseInstance, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glDrawElementsInstancedBaseVertexBaseInstance(GLenum arg0, + GLsizei arg1, + GLenum arg2, + const void *arg3, + GLsizei arg4, + GLint arg5, + GLuint arg6) { + _pre_call_callback_gl("glDrawElementsInstancedBaseVertexBaseInstance", + (void *) glDrawElementsInstancedBaseVertexBaseInstance, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glDrawElementsInstancedBaseVertexBaseInstance(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glDrawElementsInstancedBaseVertexBaseInstance", + (void *) glDrawElementsInstancedBaseVertexBaseInstance, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_debug_glDrawElementsInstancedBaseVertexBaseInstance = glad_debug_impl_glDrawElementsInstancedBaseVertexBaseInstance; + +PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_debug_glDrawElementsInstancedBaseVertexBaseInstance = + glad_debug_impl_glDrawElementsInstancedBaseVertexBaseInstance; PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements; -void APIENTRY glad_debug_impl_glDrawRangeElements(GLenum arg0, GLuint arg1, GLuint arg2, GLsizei arg3, GLenum arg4, const void * arg5) { - _pre_call_callback_gl("glDrawRangeElements", (void*)glDrawRangeElements, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glDrawRangeElements(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glDrawRangeElements", (void*)glDrawRangeElements, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glDrawRangeElements(GLenum arg0, + GLuint arg1, + GLuint arg2, + GLsizei arg3, + GLenum arg4, + const void *arg5) { + _pre_call_callback_gl("glDrawRangeElements", (void *) glDrawRangeElements, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glDrawRangeElements(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glDrawRangeElements", (void *) glDrawRangeElements, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLDRAWRANGEELEMENTSPROC glad_debug_glDrawRangeElements = glad_debug_impl_glDrawRangeElements; PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex; -void APIENTRY glad_debug_impl_glDrawRangeElementsBaseVertex(GLenum arg0, GLuint arg1, GLuint arg2, GLsizei arg3, GLenum arg4, const void * arg5, GLint arg6) { - _pre_call_callback_gl("glDrawRangeElementsBaseVertex", (void*)glDrawRangeElementsBaseVertex, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glDrawRangeElementsBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glDrawRangeElementsBaseVertex", (void*)glDrawRangeElementsBaseVertex, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glDrawRangeElementsBaseVertex(GLenum arg0, + GLuint arg1, + GLuint arg2, + GLsizei arg3, + GLenum arg4, + const void *arg5, + GLint arg6) { + _pre_call_callback_gl("glDrawRangeElementsBaseVertex", + (void *) glDrawRangeElementsBaseVertex, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glDrawRangeElementsBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glDrawRangeElementsBaseVertex", + (void *) glDrawRangeElementsBaseVertex, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_debug_glDrawRangeElementsBaseVertex = glad_debug_impl_glDrawRangeElementsBaseVertex; + +PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC + glad_debug_glDrawRangeElementsBaseVertex = glad_debug_impl_glDrawRangeElementsBaseVertex; PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback; -void APIENTRY glad_debug_impl_glDrawTransformFeedback(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glDrawTransformFeedback", (void*)glDrawTransformFeedback, 2, arg0, arg1); - glad_glDrawTransformFeedback(arg0, arg1); - _post_call_callback_gl("glDrawTransformFeedback", (void*)glDrawTransformFeedback, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDrawTransformFeedback(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glDrawTransformFeedback", (void *) glDrawTransformFeedback, 2, arg0, arg1); + glad_glDrawTransformFeedback(arg0, arg1); + _post_call_callback_gl("glDrawTransformFeedback", (void *) glDrawTransformFeedback, 2, arg0, arg1); + } + PFNGLDRAWTRANSFORMFEEDBACKPROC glad_debug_glDrawTransformFeedback = glad_debug_impl_glDrawTransformFeedback; PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced; -void APIENTRY glad_debug_impl_glDrawTransformFeedbackInstanced(GLenum arg0, GLuint arg1, GLsizei arg2) { - _pre_call_callback_gl("glDrawTransformFeedbackInstanced", (void*)glDrawTransformFeedbackInstanced, 3, arg0, arg1, arg2); - glad_glDrawTransformFeedbackInstanced(arg0, arg1, arg2); - _post_call_callback_gl("glDrawTransformFeedbackInstanced", (void*)glDrawTransformFeedbackInstanced, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDrawTransformFeedbackInstanced(GLenum arg0, GLuint arg1, GLsizei arg2) { + _pre_call_callback_gl("glDrawTransformFeedbackInstanced", + (void *) glDrawTransformFeedbackInstanced, + 3, + arg0, + arg1, + arg2); + glad_glDrawTransformFeedbackInstanced(arg0, arg1, arg2); + _post_call_callback_gl("glDrawTransformFeedbackInstanced", + (void *) glDrawTransformFeedbackInstanced, + 3, + arg0, + arg1, + arg2); + } -PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_debug_glDrawTransformFeedbackInstanced = glad_debug_impl_glDrawTransformFeedbackInstanced; + +PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC + glad_debug_glDrawTransformFeedbackInstanced = glad_debug_impl_glDrawTransformFeedbackInstanced; PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream; -void APIENTRY glad_debug_impl_glDrawTransformFeedbackStream(GLenum arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glDrawTransformFeedbackStream", (void*)glDrawTransformFeedbackStream, 3, arg0, arg1, arg2); - glad_glDrawTransformFeedbackStream(arg0, arg1, arg2); - _post_call_callback_gl("glDrawTransformFeedbackStream", (void*)glDrawTransformFeedbackStream, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glDrawTransformFeedbackStream(GLenum arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glDrawTransformFeedbackStream", (void *) glDrawTransformFeedbackStream, 3, arg0, arg1, arg2); + glad_glDrawTransformFeedbackStream(arg0, arg1, arg2); + _post_call_callback_gl("glDrawTransformFeedbackStream", + (void *) glDrawTransformFeedbackStream, + 3, + arg0, + arg1, + arg2); + } -PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_debug_glDrawTransformFeedbackStream = glad_debug_impl_glDrawTransformFeedbackStream; + +PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC + glad_debug_glDrawTransformFeedbackStream = glad_debug_impl_glDrawTransformFeedbackStream; PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced; -void APIENTRY glad_debug_impl_glDrawTransformFeedbackStreamInstanced(GLenum arg0, GLuint arg1, GLuint arg2, GLsizei arg3) { - _pre_call_callback_gl("glDrawTransformFeedbackStreamInstanced", (void*)glDrawTransformFeedbackStreamInstanced, 4, arg0, arg1, arg2, arg3); - glad_glDrawTransformFeedbackStreamInstanced(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glDrawTransformFeedbackStreamInstanced", (void*)glDrawTransformFeedbackStreamInstanced, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glDrawTransformFeedbackStreamInstanced(GLenum arg0, + GLuint arg1, + GLuint arg2, + GLsizei arg3) { + _pre_call_callback_gl("glDrawTransformFeedbackStreamInstanced", + (void *) glDrawTransformFeedbackStreamInstanced, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glDrawTransformFeedbackStreamInstanced(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glDrawTransformFeedbackStreamInstanced", + (void *) glDrawTransformFeedbackStreamInstanced, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_debug_glDrawTransformFeedbackStreamInstanced = glad_debug_impl_glDrawTransformFeedbackStreamInstanced; + +PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC + glad_debug_glDrawTransformFeedbackStreamInstanced = glad_debug_impl_glDrawTransformFeedbackStreamInstanced; PFNGLENABLEPROC glad_glEnable; -void APIENTRY glad_debug_impl_glEnable(GLenum arg0) { - _pre_call_callback_gl("glEnable", (void*)glEnable, 1, arg0); - glad_glEnable(arg0); - _post_call_callback_gl("glEnable", (void*)glEnable, 1, arg0); - + +void APIENTRY glad_debug_impl_glEnable(GLenum arg0) { + _pre_call_callback_gl("glEnable", (void *) glEnable, 1, arg0); + glad_glEnable(arg0); + _post_call_callback_gl("glEnable", (void *) glEnable, 1, arg0); + } + PFNGLENABLEPROC glad_debug_glEnable = glad_debug_impl_glEnable; PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib; -void APIENTRY glad_debug_impl_glEnableVertexArrayAttrib(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glEnableVertexArrayAttrib", (void*)glEnableVertexArrayAttrib, 2, arg0, arg1); - glad_glEnableVertexArrayAttrib(arg0, arg1); - _post_call_callback_gl("glEnableVertexArrayAttrib", (void*)glEnableVertexArrayAttrib, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glEnableVertexArrayAttrib(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glEnableVertexArrayAttrib", (void *) glEnableVertexArrayAttrib, 2, arg0, arg1); + glad_glEnableVertexArrayAttrib(arg0, arg1); + _post_call_callback_gl("glEnableVertexArrayAttrib", (void *) glEnableVertexArrayAttrib, 2, arg0, arg1); + } + PFNGLENABLEVERTEXARRAYATTRIBPROC glad_debug_glEnableVertexArrayAttrib = glad_debug_impl_glEnableVertexArrayAttrib; PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray; -void APIENTRY glad_debug_impl_glEnableVertexAttribArray(GLuint arg0) { - _pre_call_callback_gl("glEnableVertexAttribArray", (void*)glEnableVertexAttribArray, 1, arg0); - glad_glEnableVertexAttribArray(arg0); - _post_call_callback_gl("glEnableVertexAttribArray", (void*)glEnableVertexAttribArray, 1, arg0); - + +void APIENTRY glad_debug_impl_glEnableVertexAttribArray(GLuint arg0) { + _pre_call_callback_gl("glEnableVertexAttribArray", (void *) glEnableVertexAttribArray, 1, arg0); + glad_glEnableVertexAttribArray(arg0); + _post_call_callback_gl("glEnableVertexAttribArray", (void *) glEnableVertexAttribArray, 1, arg0); + } + PFNGLENABLEVERTEXATTRIBARRAYPROC glad_debug_glEnableVertexAttribArray = glad_debug_impl_glEnableVertexAttribArray; PFNGLENABLEIPROC glad_glEnablei; -void APIENTRY glad_debug_impl_glEnablei(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glEnablei", (void*)glEnablei, 2, arg0, arg1); - glad_glEnablei(arg0, arg1); - _post_call_callback_gl("glEnablei", (void*)glEnablei, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glEnablei(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glEnablei", (void *) glEnablei, 2, arg0, arg1); + glad_glEnablei(arg0, arg1); + _post_call_callback_gl("glEnablei", (void *) glEnablei, 2, arg0, arg1); + } + PFNGLENABLEIPROC glad_debug_glEnablei = glad_debug_impl_glEnablei; PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender; -void APIENTRY glad_debug_impl_glEndConditionalRender(void) { - _pre_call_callback_gl("glEndConditionalRender", (void*)glEndConditionalRender, 0); - glad_glEndConditionalRender(); - _post_call_callback_gl("glEndConditionalRender", (void*)glEndConditionalRender, 0); - + +void APIENTRY glad_debug_impl_glEndConditionalRender(void) { + _pre_call_callback_gl("glEndConditionalRender", (void *) glEndConditionalRender, 0); + glad_glEndConditionalRender(); + _post_call_callback_gl("glEndConditionalRender", (void *) glEndConditionalRender, 0); + } + PFNGLENDCONDITIONALRENDERPROC glad_debug_glEndConditionalRender = glad_debug_impl_glEndConditionalRender; PFNGLENDQUERYPROC glad_glEndQuery; -void APIENTRY glad_debug_impl_glEndQuery(GLenum arg0) { - _pre_call_callback_gl("glEndQuery", (void*)glEndQuery, 1, arg0); - glad_glEndQuery(arg0); - _post_call_callback_gl("glEndQuery", (void*)glEndQuery, 1, arg0); - + +void APIENTRY glad_debug_impl_glEndQuery(GLenum arg0) { + _pre_call_callback_gl("glEndQuery", (void *) glEndQuery, 1, arg0); + glad_glEndQuery(arg0); + _post_call_callback_gl("glEndQuery", (void *) glEndQuery, 1, arg0); + } + PFNGLENDQUERYPROC glad_debug_glEndQuery = glad_debug_impl_glEndQuery; PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed; -void APIENTRY glad_debug_impl_glEndQueryIndexed(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glEndQueryIndexed", (void*)glEndQueryIndexed, 2, arg0, arg1); - glad_glEndQueryIndexed(arg0, arg1); - _post_call_callback_gl("glEndQueryIndexed", (void*)glEndQueryIndexed, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glEndQueryIndexed(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glEndQueryIndexed", (void *) glEndQueryIndexed, 2, arg0, arg1); + glad_glEndQueryIndexed(arg0, arg1); + _post_call_callback_gl("glEndQueryIndexed", (void *) glEndQueryIndexed, 2, arg0, arg1); + } + PFNGLENDQUERYINDEXEDPROC glad_debug_glEndQueryIndexed = glad_debug_impl_glEndQueryIndexed; PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback; -void APIENTRY glad_debug_impl_glEndTransformFeedback(void) { - _pre_call_callback_gl("glEndTransformFeedback", (void*)glEndTransformFeedback, 0); - glad_glEndTransformFeedback(); - _post_call_callback_gl("glEndTransformFeedback", (void*)glEndTransformFeedback, 0); - + +void APIENTRY glad_debug_impl_glEndTransformFeedback(void) { + _pre_call_callback_gl("glEndTransformFeedback", (void *) glEndTransformFeedback, 0); + glad_glEndTransformFeedback(); + _post_call_callback_gl("glEndTransformFeedback", (void *) glEndTransformFeedback, 0); + } + PFNGLENDTRANSFORMFEEDBACKPROC glad_debug_glEndTransformFeedback = glad_debug_impl_glEndTransformFeedback; PFNGLFENCESYNCPROC glad_glFenceSync; -GLsync APIENTRY glad_debug_impl_glFenceSync(GLenum arg0, GLbitfield arg1) { - GLsync ret; - _pre_call_callback_gl("glFenceSync", (void*)glFenceSync, 2, arg0, arg1); - ret = glad_glFenceSync(arg0, arg1); - _post_call_callback_gl("glFenceSync", (void*)glFenceSync, 2, arg0, arg1); - return ret; + +GLsync APIENTRY glad_debug_impl_glFenceSync(GLenum arg0, GLbitfield arg1) { + GLsync ret; + _pre_call_callback_gl("glFenceSync", (void *) glFenceSync, 2, arg0, arg1); + ret = glad_glFenceSync(arg0, arg1); + _post_call_callback_gl("glFenceSync", (void *) glFenceSync, 2, arg0, arg1); + return ret; } + PFNGLFENCESYNCPROC glad_debug_glFenceSync = glad_debug_impl_glFenceSync; PFNGLFINISHPROC glad_glFinish; -void APIENTRY glad_debug_impl_glFinish(void) { - _pre_call_callback_gl("glFinish", (void*)glFinish, 0); - glad_glFinish(); - _post_call_callback_gl("glFinish", (void*)glFinish, 0); - + +void APIENTRY glad_debug_impl_glFinish(void) { + _pre_call_callback_gl("glFinish", (void *) glFinish, 0); + glad_glFinish(); + _post_call_callback_gl("glFinish", (void *) glFinish, 0); + } + PFNGLFINISHPROC glad_debug_glFinish = glad_debug_impl_glFinish; PFNGLFLUSHPROC glad_glFlush; -void APIENTRY glad_debug_impl_glFlush(void) { - _pre_call_callback_gl("glFlush", (void*)glFlush, 0); - glad_glFlush(); - _post_call_callback_gl("glFlush", (void*)glFlush, 0); - + +void APIENTRY glad_debug_impl_glFlush(void) { + _pre_call_callback_gl("glFlush", (void *) glFlush, 0); + glad_glFlush(); + _post_call_callback_gl("glFlush", (void *) glFlush, 0); + } + PFNGLFLUSHPROC glad_debug_glFlush = glad_debug_impl_glFlush; PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange; -void APIENTRY glad_debug_impl_glFlushMappedBufferRange(GLenum arg0, GLintptr arg1, GLsizeiptr arg2) { - _pre_call_callback_gl("glFlushMappedBufferRange", (void*)glFlushMappedBufferRange, 3, arg0, arg1, arg2); - glad_glFlushMappedBufferRange(arg0, arg1, arg2); - _post_call_callback_gl("glFlushMappedBufferRange", (void*)glFlushMappedBufferRange, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glFlushMappedBufferRange(GLenum arg0, GLintptr arg1, GLsizeiptr arg2) { + _pre_call_callback_gl("glFlushMappedBufferRange", (void *) glFlushMappedBufferRange, 3, arg0, arg1, arg2); + glad_glFlushMappedBufferRange(arg0, arg1, arg2); + _post_call_callback_gl("glFlushMappedBufferRange", (void *) glFlushMappedBufferRange, 3, arg0, arg1, arg2); + } + PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_debug_glFlushMappedBufferRange = glad_debug_impl_glFlushMappedBufferRange; PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange; -void APIENTRY glad_debug_impl_glFlushMappedNamedBufferRange(GLuint arg0, GLintptr arg1, GLsizeiptr arg2) { - _pre_call_callback_gl("glFlushMappedNamedBufferRange", (void*)glFlushMappedNamedBufferRange, 3, arg0, arg1, arg2); - glad_glFlushMappedNamedBufferRange(arg0, arg1, arg2); - _post_call_callback_gl("glFlushMappedNamedBufferRange", (void*)glFlushMappedNamedBufferRange, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glFlushMappedNamedBufferRange(GLuint arg0, GLintptr arg1, GLsizeiptr arg2) { + _pre_call_callback_gl("glFlushMappedNamedBufferRange", (void *) glFlushMappedNamedBufferRange, 3, arg0, arg1, arg2); + glad_glFlushMappedNamedBufferRange(arg0, arg1, arg2); + _post_call_callback_gl("glFlushMappedNamedBufferRange", + (void *) glFlushMappedNamedBufferRange, + 3, + arg0, + arg1, + arg2); + } -PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_debug_glFlushMappedNamedBufferRange = glad_debug_impl_glFlushMappedNamedBufferRange; + +PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC + glad_debug_glFlushMappedNamedBufferRange = glad_debug_impl_glFlushMappedNamedBufferRange; PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri; -void APIENTRY glad_debug_impl_glFramebufferParameteri(GLenum arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glFramebufferParameteri", (void*)glFramebufferParameteri, 3, arg0, arg1, arg2); - glad_glFramebufferParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glFramebufferParameteri", (void*)glFramebufferParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glFramebufferParameteri(GLenum arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glFramebufferParameteri", (void *) glFramebufferParameteri, 3, arg0, arg1, arg2); + glad_glFramebufferParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glFramebufferParameteri", (void *) glFramebufferParameteri, 3, arg0, arg1, arg2); + } + PFNGLFRAMEBUFFERPARAMETERIPROC glad_debug_glFramebufferParameteri = glad_debug_impl_glFramebufferParameteri; PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer; -void APIENTRY glad_debug_impl_glFramebufferRenderbuffer(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3) { - _pre_call_callback_gl("glFramebufferRenderbuffer", (void*)glFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); - glad_glFramebufferRenderbuffer(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glFramebufferRenderbuffer", (void*)glFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glFramebufferRenderbuffer(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3) { + _pre_call_callback_gl("glFramebufferRenderbuffer", (void *) glFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); + glad_glFramebufferRenderbuffer(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glFramebufferRenderbuffer", (void *) glFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); + } + PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_debug_glFramebufferRenderbuffer = glad_debug_impl_glFramebufferRenderbuffer; PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture; -void APIENTRY glad_debug_impl_glFramebufferTexture(GLenum arg0, GLenum arg1, GLuint arg2, GLint arg3) { - _pre_call_callback_gl("glFramebufferTexture", (void*)glFramebufferTexture, 4, arg0, arg1, arg2, arg3); - glad_glFramebufferTexture(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glFramebufferTexture", (void*)glFramebufferTexture, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glFramebufferTexture(GLenum arg0, GLenum arg1, GLuint arg2, GLint arg3) { + _pre_call_callback_gl("glFramebufferTexture", (void *) glFramebufferTexture, 4, arg0, arg1, arg2, arg3); + glad_glFramebufferTexture(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glFramebufferTexture", (void *) glFramebufferTexture, 4, arg0, arg1, arg2, arg3); + } + PFNGLFRAMEBUFFERTEXTUREPROC glad_debug_glFramebufferTexture = glad_debug_impl_glFramebufferTexture; PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D; -void APIENTRY glad_debug_impl_glFramebufferTexture1D(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3, GLint arg4) { - _pre_call_callback_gl("glFramebufferTexture1D", (void*)glFramebufferTexture1D, 5, arg0, arg1, arg2, arg3, arg4); - glad_glFramebufferTexture1D(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glFramebufferTexture1D", (void*)glFramebufferTexture1D, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glFramebufferTexture1D(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3, GLint arg4) { + _pre_call_callback_gl("glFramebufferTexture1D", (void *) glFramebufferTexture1D, 5, arg0, arg1, arg2, arg3, arg4); + glad_glFramebufferTexture1D(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glFramebufferTexture1D", (void *) glFramebufferTexture1D, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLFRAMEBUFFERTEXTURE1DPROC glad_debug_glFramebufferTexture1D = glad_debug_impl_glFramebufferTexture1D; PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D; -void APIENTRY glad_debug_impl_glFramebufferTexture2D(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3, GLint arg4) { - _pre_call_callback_gl("glFramebufferTexture2D", (void*)glFramebufferTexture2D, 5, arg0, arg1, arg2, arg3, arg4); - glad_glFramebufferTexture2D(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glFramebufferTexture2D", (void*)glFramebufferTexture2D, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glFramebufferTexture2D(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3, GLint arg4) { + _pre_call_callback_gl("glFramebufferTexture2D", (void *) glFramebufferTexture2D, 5, arg0, arg1, arg2, arg3, arg4); + glad_glFramebufferTexture2D(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glFramebufferTexture2D", (void *) glFramebufferTexture2D, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLFRAMEBUFFERTEXTURE2DPROC glad_debug_glFramebufferTexture2D = glad_debug_impl_glFramebufferTexture2D; PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D; -void APIENTRY glad_debug_impl_glFramebufferTexture3D(GLenum arg0, GLenum arg1, GLenum arg2, GLuint arg3, GLint arg4, GLint arg5) { - _pre_call_callback_gl("glFramebufferTexture3D", (void*)glFramebufferTexture3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glFramebufferTexture3D(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glFramebufferTexture3D", (void*)glFramebufferTexture3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glFramebufferTexture3D(GLenum arg0, + GLenum arg1, + GLenum arg2, + GLuint arg3, + GLint arg4, + GLint arg5) { + _pre_call_callback_gl("glFramebufferTexture3D", + (void *) glFramebufferTexture3D, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glFramebufferTexture3D(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glFramebufferTexture3D", + (void *) glFramebufferTexture3D, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLFRAMEBUFFERTEXTURE3DPROC glad_debug_glFramebufferTexture3D = glad_debug_impl_glFramebufferTexture3D; PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer; -void APIENTRY glad_debug_impl_glFramebufferTextureLayer(GLenum arg0, GLenum arg1, GLuint arg2, GLint arg3, GLint arg4) { - _pre_call_callback_gl("glFramebufferTextureLayer", (void*)glFramebufferTextureLayer, 5, arg0, arg1, arg2, arg3, arg4); - glad_glFramebufferTextureLayer(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glFramebufferTextureLayer", (void*)glFramebufferTextureLayer, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glFramebufferTextureLayer(GLenum arg0, GLenum arg1, GLuint arg2, GLint arg3, GLint arg4) { + _pre_call_callback_gl("glFramebufferTextureLayer", + (void *) glFramebufferTextureLayer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glFramebufferTextureLayer(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glFramebufferTextureLayer", + (void *) glFramebufferTextureLayer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_debug_glFramebufferTextureLayer = glad_debug_impl_glFramebufferTextureLayer; PFNGLFRONTFACEPROC glad_glFrontFace; -void APIENTRY glad_debug_impl_glFrontFace(GLenum arg0) { - _pre_call_callback_gl("glFrontFace", (void*)glFrontFace, 1, arg0); - glad_glFrontFace(arg0); - _post_call_callback_gl("glFrontFace", (void*)glFrontFace, 1, arg0); - + +void APIENTRY glad_debug_impl_glFrontFace(GLenum arg0) { + _pre_call_callback_gl("glFrontFace", (void *) glFrontFace, 1, arg0); + glad_glFrontFace(arg0); + _post_call_callback_gl("glFrontFace", (void *) glFrontFace, 1, arg0); + } + PFNGLFRONTFACEPROC glad_debug_glFrontFace = glad_debug_impl_glFrontFace; PFNGLGENBUFFERSPROC glad_glGenBuffers; -void APIENTRY glad_debug_impl_glGenBuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenBuffers", (void*)glGenBuffers, 2, arg0, arg1); - glad_glGenBuffers(arg0, arg1); - _post_call_callback_gl("glGenBuffers", (void*)glGenBuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenBuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenBuffers", (void *) glGenBuffers, 2, arg0, arg1); + glad_glGenBuffers(arg0, arg1); + _post_call_callback_gl("glGenBuffers", (void *) glGenBuffers, 2, arg0, arg1); + } + PFNGLGENBUFFERSPROC glad_debug_glGenBuffers = glad_debug_impl_glGenBuffers; PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers; -void APIENTRY glad_debug_impl_glGenFramebuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenFramebuffers", (void*)glGenFramebuffers, 2, arg0, arg1); - glad_glGenFramebuffers(arg0, arg1); - _post_call_callback_gl("glGenFramebuffers", (void*)glGenFramebuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenFramebuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenFramebuffers", (void *) glGenFramebuffers, 2, arg0, arg1); + glad_glGenFramebuffers(arg0, arg1); + _post_call_callback_gl("glGenFramebuffers", (void *) glGenFramebuffers, 2, arg0, arg1); + } + PFNGLGENFRAMEBUFFERSPROC glad_debug_glGenFramebuffers = glad_debug_impl_glGenFramebuffers; PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines; -void APIENTRY glad_debug_impl_glGenProgramPipelines(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenProgramPipelines", (void*)glGenProgramPipelines, 2, arg0, arg1); - glad_glGenProgramPipelines(arg0, arg1); - _post_call_callback_gl("glGenProgramPipelines", (void*)glGenProgramPipelines, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenProgramPipelines(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenProgramPipelines", (void *) glGenProgramPipelines, 2, arg0, arg1); + glad_glGenProgramPipelines(arg0, arg1); + _post_call_callback_gl("glGenProgramPipelines", (void *) glGenProgramPipelines, 2, arg0, arg1); + } + PFNGLGENPROGRAMPIPELINESPROC glad_debug_glGenProgramPipelines = glad_debug_impl_glGenProgramPipelines; PFNGLGENQUERIESPROC glad_glGenQueries; -void APIENTRY glad_debug_impl_glGenQueries(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenQueries", (void*)glGenQueries, 2, arg0, arg1); - glad_glGenQueries(arg0, arg1); - _post_call_callback_gl("glGenQueries", (void*)glGenQueries, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenQueries(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenQueries", (void *) glGenQueries, 2, arg0, arg1); + glad_glGenQueries(arg0, arg1); + _post_call_callback_gl("glGenQueries", (void *) glGenQueries, 2, arg0, arg1); + } + PFNGLGENQUERIESPROC glad_debug_glGenQueries = glad_debug_impl_glGenQueries; PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers; -void APIENTRY glad_debug_impl_glGenRenderbuffers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenRenderbuffers", (void*)glGenRenderbuffers, 2, arg0, arg1); - glad_glGenRenderbuffers(arg0, arg1); - _post_call_callback_gl("glGenRenderbuffers", (void*)glGenRenderbuffers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenRenderbuffers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenRenderbuffers", (void *) glGenRenderbuffers, 2, arg0, arg1); + glad_glGenRenderbuffers(arg0, arg1); + _post_call_callback_gl("glGenRenderbuffers", (void *) glGenRenderbuffers, 2, arg0, arg1); + } + PFNGLGENRENDERBUFFERSPROC glad_debug_glGenRenderbuffers = glad_debug_impl_glGenRenderbuffers; PFNGLGENSAMPLERSPROC glad_glGenSamplers; -void APIENTRY glad_debug_impl_glGenSamplers(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenSamplers", (void*)glGenSamplers, 2, arg0, arg1); - glad_glGenSamplers(arg0, arg1); - _post_call_callback_gl("glGenSamplers", (void*)glGenSamplers, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenSamplers(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenSamplers", (void *) glGenSamplers, 2, arg0, arg1); + glad_glGenSamplers(arg0, arg1); + _post_call_callback_gl("glGenSamplers", (void *) glGenSamplers, 2, arg0, arg1); + } + PFNGLGENSAMPLERSPROC glad_debug_glGenSamplers = glad_debug_impl_glGenSamplers; PFNGLGENTEXTURESPROC glad_glGenTextures; -void APIENTRY glad_debug_impl_glGenTextures(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenTextures", (void*)glGenTextures, 2, arg0, arg1); - glad_glGenTextures(arg0, arg1); - _post_call_callback_gl("glGenTextures", (void*)glGenTextures, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenTextures(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenTextures", (void *) glGenTextures, 2, arg0, arg1); + glad_glGenTextures(arg0, arg1); + _post_call_callback_gl("glGenTextures", (void *) glGenTextures, 2, arg0, arg1); + } + PFNGLGENTEXTURESPROC glad_debug_glGenTextures = glad_debug_impl_glGenTextures; PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks; -void APIENTRY glad_debug_impl_glGenTransformFeedbacks(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenTransformFeedbacks", (void*)glGenTransformFeedbacks, 2, arg0, arg1); - glad_glGenTransformFeedbacks(arg0, arg1); - _post_call_callback_gl("glGenTransformFeedbacks", (void*)glGenTransformFeedbacks, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenTransformFeedbacks(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenTransformFeedbacks", (void *) glGenTransformFeedbacks, 2, arg0, arg1); + glad_glGenTransformFeedbacks(arg0, arg1); + _post_call_callback_gl("glGenTransformFeedbacks", (void *) glGenTransformFeedbacks, 2, arg0, arg1); + } + PFNGLGENTRANSFORMFEEDBACKSPROC glad_debug_glGenTransformFeedbacks = glad_debug_impl_glGenTransformFeedbacks; PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays; -void APIENTRY glad_debug_impl_glGenVertexArrays(GLsizei arg0, GLuint * arg1) { - _pre_call_callback_gl("glGenVertexArrays", (void*)glGenVertexArrays, 2, arg0, arg1); - glad_glGenVertexArrays(arg0, arg1); - _post_call_callback_gl("glGenVertexArrays", (void*)glGenVertexArrays, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGenVertexArrays(GLsizei arg0, GLuint *arg1) { + _pre_call_callback_gl("glGenVertexArrays", (void *) glGenVertexArrays, 2, arg0, arg1); + glad_glGenVertexArrays(arg0, arg1); + _post_call_callback_gl("glGenVertexArrays", (void *) glGenVertexArrays, 2, arg0, arg1); + } + PFNGLGENVERTEXARRAYSPROC glad_debug_glGenVertexArrays = glad_debug_impl_glGenVertexArrays; PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap; -void APIENTRY glad_debug_impl_glGenerateMipmap(GLenum arg0) { - _pre_call_callback_gl("glGenerateMipmap", (void*)glGenerateMipmap, 1, arg0); - glad_glGenerateMipmap(arg0); - _post_call_callback_gl("glGenerateMipmap", (void*)glGenerateMipmap, 1, arg0); - + +void APIENTRY glad_debug_impl_glGenerateMipmap(GLenum arg0) { + _pre_call_callback_gl("glGenerateMipmap", (void *) glGenerateMipmap, 1, arg0); + glad_glGenerateMipmap(arg0); + _post_call_callback_gl("glGenerateMipmap", (void *) glGenerateMipmap, 1, arg0); + } + PFNGLGENERATEMIPMAPPROC glad_debug_glGenerateMipmap = glad_debug_impl_glGenerateMipmap; PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap; -void APIENTRY glad_debug_impl_glGenerateTextureMipmap(GLuint arg0) { - _pre_call_callback_gl("glGenerateTextureMipmap", (void*)glGenerateTextureMipmap, 1, arg0); - glad_glGenerateTextureMipmap(arg0); - _post_call_callback_gl("glGenerateTextureMipmap", (void*)glGenerateTextureMipmap, 1, arg0); - + +void APIENTRY glad_debug_impl_glGenerateTextureMipmap(GLuint arg0) { + _pre_call_callback_gl("glGenerateTextureMipmap", (void *) glGenerateTextureMipmap, 1, arg0); + glad_glGenerateTextureMipmap(arg0); + _post_call_callback_gl("glGenerateTextureMipmap", (void *) glGenerateTextureMipmap, 1, arg0); + } + PFNGLGENERATETEXTUREMIPMAPPROC glad_debug_glGenerateTextureMipmap = glad_debug_impl_glGenerateTextureMipmap; PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv; -void APIENTRY glad_debug_impl_glGetActiveAtomicCounterBufferiv(GLuint arg0, GLuint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetActiveAtomicCounterBufferiv", (void*)glGetActiveAtomicCounterBufferiv, 4, arg0, arg1, arg2, arg3); - glad_glGetActiveAtomicCounterBufferiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetActiveAtomicCounterBufferiv", (void*)glGetActiveAtomicCounterBufferiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetActiveAtomicCounterBufferiv(GLuint arg0, GLuint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetActiveAtomicCounterBufferiv", + (void *) glGetActiveAtomicCounterBufferiv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetActiveAtomicCounterBufferiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetActiveAtomicCounterBufferiv", + (void *) glGetActiveAtomicCounterBufferiv, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_debug_glGetActiveAtomicCounterBufferiv = glad_debug_impl_glGetActiveAtomicCounterBufferiv; + +PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC + glad_debug_glGetActiveAtomicCounterBufferiv = glad_debug_impl_glGetActiveAtomicCounterBufferiv; PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib; -void APIENTRY glad_debug_impl_glGetActiveAttrib(GLuint arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLint * arg4, GLenum * arg5, GLchar * arg6) { - _pre_call_callback_gl("glGetActiveAttrib", (void*)glGetActiveAttrib, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glGetActiveAttrib(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glGetActiveAttrib", (void*)glGetActiveAttrib, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glGetActiveAttrib(GLuint arg0, + GLuint arg1, + GLsizei arg2, + GLsizei *arg3, + GLint *arg4, + GLenum *arg5, + GLchar *arg6) { + _pre_call_callback_gl("glGetActiveAttrib", (void *) glGetActiveAttrib, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + glad_glGetActiveAttrib(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glGetActiveAttrib", + (void *) glGetActiveAttrib, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLGETACTIVEATTRIBPROC glad_debug_glGetActiveAttrib = glad_debug_impl_glGetActiveAttrib; PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName; -void APIENTRY glad_debug_impl_glGetActiveSubroutineName(GLuint arg0, GLenum arg1, GLuint arg2, GLsizei arg3, GLsizei * arg4, GLchar * arg5) { - _pre_call_callback_gl("glGetActiveSubroutineName", (void*)glGetActiveSubroutineName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetActiveSubroutineName(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetActiveSubroutineName", (void*)glGetActiveSubroutineName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetActiveSubroutineName(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLsizei arg3, + GLsizei *arg4, + GLchar *arg5) { + _pre_call_callback_gl("glGetActiveSubroutineName", + (void *) glGetActiveSubroutineName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glGetActiveSubroutineName(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetActiveSubroutineName", + (void *) glGetActiveSubroutineName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLGETACTIVESUBROUTINENAMEPROC glad_debug_glGetActiveSubroutineName = glad_debug_impl_glGetActiveSubroutineName; PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName; -void APIENTRY glad_debug_impl_glGetActiveSubroutineUniformName(GLuint arg0, GLenum arg1, GLuint arg2, GLsizei arg3, GLsizei * arg4, GLchar * arg5) { - _pre_call_callback_gl("glGetActiveSubroutineUniformName", (void*)glGetActiveSubroutineUniformName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetActiveSubroutineUniformName(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetActiveSubroutineUniformName", (void*)glGetActiveSubroutineUniformName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetActiveSubroutineUniformName(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLsizei arg3, + GLsizei *arg4, + GLchar *arg5) { + _pre_call_callback_gl("glGetActiveSubroutineUniformName", + (void *) glGetActiveSubroutineUniformName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glGetActiveSubroutineUniformName(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetActiveSubroutineUniformName", + (void *) glGetActiveSubroutineUniformName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } -PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_debug_glGetActiveSubroutineUniformName = glad_debug_impl_glGetActiveSubroutineUniformName; + +PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC + glad_debug_glGetActiveSubroutineUniformName = glad_debug_impl_glGetActiveSubroutineUniformName; PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv; -void APIENTRY glad_debug_impl_glGetActiveSubroutineUniformiv(GLuint arg0, GLenum arg1, GLuint arg2, GLenum arg3, GLint * arg4) { - _pre_call_callback_gl("glGetActiveSubroutineUniformiv", (void*)glGetActiveSubroutineUniformiv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetActiveSubroutineUniformiv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetActiveSubroutineUniformiv", (void*)glGetActiveSubroutineUniformiv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetActiveSubroutineUniformiv(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLenum arg3, + GLint *arg4) { + _pre_call_callback_gl("glGetActiveSubroutineUniformiv", + (void *) glGetActiveSubroutineUniformiv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glGetActiveSubroutineUniformiv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetActiveSubroutineUniformiv", + (void *) glGetActiveSubroutineUniformiv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_debug_glGetActiveSubroutineUniformiv = glad_debug_impl_glGetActiveSubroutineUniformiv; + +PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC + glad_debug_glGetActiveSubroutineUniformiv = glad_debug_impl_glGetActiveSubroutineUniformiv; PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform; -void APIENTRY glad_debug_impl_glGetActiveUniform(GLuint arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLint * arg4, GLenum * arg5, GLchar * arg6) { - _pre_call_callback_gl("glGetActiveUniform", (void*)glGetActiveUniform, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glGetActiveUniform(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glGetActiveUniform", (void*)glGetActiveUniform, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glGetActiveUniform(GLuint arg0, + GLuint arg1, + GLsizei arg2, + GLsizei *arg3, + GLint *arg4, + GLenum *arg5, + GLchar *arg6) { + _pre_call_callback_gl("glGetActiveUniform", + (void *) glGetActiveUniform, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glGetActiveUniform(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glGetActiveUniform", + (void *) glGetActiveUniform, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLGETACTIVEUNIFORMPROC glad_debug_glGetActiveUniform = glad_debug_impl_glGetActiveUniform; PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName; -void APIENTRY glad_debug_impl_glGetActiveUniformBlockName(GLuint arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLchar * arg4) { - _pre_call_callback_gl("glGetActiveUniformBlockName", (void*)glGetActiveUniformBlockName, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetActiveUniformBlockName(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetActiveUniformBlockName", (void*)glGetActiveUniformBlockName, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetActiveUniformBlockName(GLuint arg0, + GLuint arg1, + GLsizei arg2, + GLsizei *arg3, + GLchar *arg4) { + _pre_call_callback_gl("glGetActiveUniformBlockName", + (void *) glGetActiveUniformBlockName, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glGetActiveUniformBlockName(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetActiveUniformBlockName", + (void *) glGetActiveUniformBlockName, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_debug_glGetActiveUniformBlockName = glad_debug_impl_glGetActiveUniformBlockName; PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv; -void APIENTRY glad_debug_impl_glGetActiveUniformBlockiv(GLuint arg0, GLuint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetActiveUniformBlockiv", (void*)glGetActiveUniformBlockiv, 4, arg0, arg1, arg2, arg3); - glad_glGetActiveUniformBlockiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetActiveUniformBlockiv", (void*)glGetActiveUniformBlockiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetActiveUniformBlockiv(GLuint arg0, GLuint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetActiveUniformBlockiv", (void *) glGetActiveUniformBlockiv, 4, arg0, arg1, arg2, arg3); + glad_glGetActiveUniformBlockiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetActiveUniformBlockiv", (void *) glGetActiveUniformBlockiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_debug_glGetActiveUniformBlockiv = glad_debug_impl_glGetActiveUniformBlockiv; PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName; -void APIENTRY glad_debug_impl_glGetActiveUniformName(GLuint arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLchar * arg4) { - _pre_call_callback_gl("glGetActiveUniformName", (void*)glGetActiveUniformName, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetActiveUniformName(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetActiveUniformName", (void*)glGetActiveUniformName, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetActiveUniformName(GLuint arg0, + GLuint arg1, + GLsizei arg2, + GLsizei *arg3, + GLchar *arg4) { + _pre_call_callback_gl("glGetActiveUniformName", (void *) glGetActiveUniformName, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetActiveUniformName(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetActiveUniformName", (void *) glGetActiveUniformName, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETACTIVEUNIFORMNAMEPROC glad_debug_glGetActiveUniformName = glad_debug_impl_glGetActiveUniformName; PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv; -void APIENTRY glad_debug_impl_glGetActiveUniformsiv(GLuint arg0, GLsizei arg1, const GLuint * arg2, GLenum arg3, GLint * arg4) { - _pre_call_callback_gl("glGetActiveUniformsiv", (void*)glGetActiveUniformsiv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetActiveUniformsiv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetActiveUniformsiv", (void*)glGetActiveUniformsiv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetActiveUniformsiv(GLuint arg0, + GLsizei arg1, + const GLuint *arg2, + GLenum arg3, + GLint *arg4) { + _pre_call_callback_gl("glGetActiveUniformsiv", (void *) glGetActiveUniformsiv, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetActiveUniformsiv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetActiveUniformsiv", (void *) glGetActiveUniformsiv, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETACTIVEUNIFORMSIVPROC glad_debug_glGetActiveUniformsiv = glad_debug_impl_glGetActiveUniformsiv; PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders; -void APIENTRY glad_debug_impl_glGetAttachedShaders(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLuint * arg3) { - _pre_call_callback_gl("glGetAttachedShaders", (void*)glGetAttachedShaders, 4, arg0, arg1, arg2, arg3); - glad_glGetAttachedShaders(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetAttachedShaders", (void*)glGetAttachedShaders, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetAttachedShaders(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLuint *arg3) { + _pre_call_callback_gl("glGetAttachedShaders", (void *) glGetAttachedShaders, 4, arg0, arg1, arg2, arg3); + glad_glGetAttachedShaders(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetAttachedShaders", (void *) glGetAttachedShaders, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETATTACHEDSHADERSPROC glad_debug_glGetAttachedShaders = glad_debug_impl_glGetAttachedShaders; PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation; -GLint APIENTRY glad_debug_impl_glGetAttribLocation(GLuint arg0, const GLchar * arg1) { - GLint ret; - _pre_call_callback_gl("glGetAttribLocation", (void*)glGetAttribLocation, 2, arg0, arg1); - ret = glad_glGetAttribLocation(arg0, arg1); - _post_call_callback_gl("glGetAttribLocation", (void*)glGetAttribLocation, 2, arg0, arg1); - return ret; + +GLint APIENTRY glad_debug_impl_glGetAttribLocation(GLuint arg0, const GLchar *arg1) { + GLint ret; + _pre_call_callback_gl("glGetAttribLocation", (void *) glGetAttribLocation, 2, arg0, arg1); + ret = glad_glGetAttribLocation(arg0, arg1); + _post_call_callback_gl("glGetAttribLocation", (void *) glGetAttribLocation, 2, arg0, arg1); + return ret; } + PFNGLGETATTRIBLOCATIONPROC glad_debug_glGetAttribLocation = glad_debug_impl_glGetAttribLocation; PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v; -void APIENTRY glad_debug_impl_glGetBooleani_v(GLenum arg0, GLuint arg1, GLboolean * arg2) { - _pre_call_callback_gl("glGetBooleani_v", (void*)glGetBooleani_v, 3, arg0, arg1, arg2); - glad_glGetBooleani_v(arg0, arg1, arg2); - _post_call_callback_gl("glGetBooleani_v", (void*)glGetBooleani_v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetBooleani_v(GLenum arg0, GLuint arg1, GLboolean *arg2) { + _pre_call_callback_gl("glGetBooleani_v", (void *) glGetBooleani_v, 3, arg0, arg1, arg2); + glad_glGetBooleani_v(arg0, arg1, arg2); + _post_call_callback_gl("glGetBooleani_v", (void *) glGetBooleani_v, 3, arg0, arg1, arg2); + } + PFNGLGETBOOLEANI_VPROC glad_debug_glGetBooleani_v = glad_debug_impl_glGetBooleani_v; PFNGLGETBOOLEANVPROC glad_glGetBooleanv; -void APIENTRY glad_debug_impl_glGetBooleanv(GLenum arg0, GLboolean * arg1) { - _pre_call_callback_gl("glGetBooleanv", (void*)glGetBooleanv, 2, arg0, arg1); - glad_glGetBooleanv(arg0, arg1); - _post_call_callback_gl("glGetBooleanv", (void*)glGetBooleanv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetBooleanv(GLenum arg0, GLboolean *arg1) { + _pre_call_callback_gl("glGetBooleanv", (void *) glGetBooleanv, 2, arg0, arg1); + glad_glGetBooleanv(arg0, arg1); + _post_call_callback_gl("glGetBooleanv", (void *) glGetBooleanv, 2, arg0, arg1); + } + PFNGLGETBOOLEANVPROC glad_debug_glGetBooleanv = glad_debug_impl_glGetBooleanv; PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v; -void APIENTRY glad_debug_impl_glGetBufferParameteri64v(GLenum arg0, GLenum arg1, GLint64 * arg2) { - _pre_call_callback_gl("glGetBufferParameteri64v", (void*)glGetBufferParameteri64v, 3, arg0, arg1, arg2); - glad_glGetBufferParameteri64v(arg0, arg1, arg2); - _post_call_callback_gl("glGetBufferParameteri64v", (void*)glGetBufferParameteri64v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetBufferParameteri64v(GLenum arg0, GLenum arg1, GLint64 *arg2) { + _pre_call_callback_gl("glGetBufferParameteri64v", (void *) glGetBufferParameteri64v, 3, arg0, arg1, arg2); + glad_glGetBufferParameteri64v(arg0, arg1, arg2); + _post_call_callback_gl("glGetBufferParameteri64v", (void *) glGetBufferParameteri64v, 3, arg0, arg1, arg2); + } + PFNGLGETBUFFERPARAMETERI64VPROC glad_debug_glGetBufferParameteri64v = glad_debug_impl_glGetBufferParameteri64v; PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv; -void APIENTRY glad_debug_impl_glGetBufferParameteriv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetBufferParameteriv", (void*)glGetBufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetBufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetBufferParameteriv", (void*)glGetBufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetBufferParameteriv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetBufferParameteriv", (void *) glGetBufferParameteriv, 3, arg0, arg1, arg2); + glad_glGetBufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetBufferParameteriv", (void *) glGetBufferParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETBUFFERPARAMETERIVPROC glad_debug_glGetBufferParameteriv = glad_debug_impl_glGetBufferParameteriv; PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv; -void APIENTRY glad_debug_impl_glGetBufferPointerv(GLenum arg0, GLenum arg1, void ** arg2) { - _pre_call_callback_gl("glGetBufferPointerv", (void*)glGetBufferPointerv, 3, arg0, arg1, arg2); - glad_glGetBufferPointerv(arg0, arg1, arg2); - _post_call_callback_gl("glGetBufferPointerv", (void*)glGetBufferPointerv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetBufferPointerv(GLenum arg0, GLenum arg1, void **arg2) { + _pre_call_callback_gl("glGetBufferPointerv", (void *) glGetBufferPointerv, 3, arg0, arg1, arg2); + glad_glGetBufferPointerv(arg0, arg1, arg2); + _post_call_callback_gl("glGetBufferPointerv", (void *) glGetBufferPointerv, 3, arg0, arg1, arg2); + } + PFNGLGETBUFFERPOINTERVPROC glad_debug_glGetBufferPointerv = glad_debug_impl_glGetBufferPointerv; PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData; -void APIENTRY glad_debug_impl_glGetBufferSubData(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, void * arg3) { - _pre_call_callback_gl("glGetBufferSubData", (void*)glGetBufferSubData, 4, arg0, arg1, arg2, arg3); - glad_glGetBufferSubData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetBufferSubData", (void*)glGetBufferSubData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetBufferSubData(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, void *arg3) { + _pre_call_callback_gl("glGetBufferSubData", (void *) glGetBufferSubData, 4, arg0, arg1, arg2, arg3); + glad_glGetBufferSubData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetBufferSubData", (void *) glGetBufferSubData, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETBUFFERSUBDATAPROC glad_debug_glGetBufferSubData = glad_debug_impl_glGetBufferSubData; PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage; -void APIENTRY glad_debug_impl_glGetCompressedTexImage(GLenum arg0, GLint arg1, void * arg2) { - _pre_call_callback_gl("glGetCompressedTexImage", (void*)glGetCompressedTexImage, 3, arg0, arg1, arg2); - glad_glGetCompressedTexImage(arg0, arg1, arg2); - _post_call_callback_gl("glGetCompressedTexImage", (void*)glGetCompressedTexImage, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetCompressedTexImage(GLenum arg0, GLint arg1, void *arg2) { + _pre_call_callback_gl("glGetCompressedTexImage", (void *) glGetCompressedTexImage, 3, arg0, arg1, arg2); + glad_glGetCompressedTexImage(arg0, arg1, arg2); + _post_call_callback_gl("glGetCompressedTexImage", (void *) glGetCompressedTexImage, 3, arg0, arg1, arg2); + } + PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_debug_glGetCompressedTexImage = glad_debug_impl_glGetCompressedTexImage; PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage; -void APIENTRY glad_debug_impl_glGetCompressedTextureImage(GLuint arg0, GLint arg1, GLsizei arg2, void * arg3) { - _pre_call_callback_gl("glGetCompressedTextureImage", (void*)glGetCompressedTextureImage, 4, arg0, arg1, arg2, arg3); - glad_glGetCompressedTextureImage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetCompressedTextureImage", (void*)glGetCompressedTextureImage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetCompressedTextureImage(GLuint arg0, GLint arg1, GLsizei arg2, void *arg3) { + _pre_call_callback_gl("glGetCompressedTextureImage", + (void *) glGetCompressedTextureImage, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetCompressedTextureImage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetCompressedTextureImage", + (void *) glGetCompressedTextureImage, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_debug_glGetCompressedTextureImage = glad_debug_impl_glGetCompressedTextureImage; PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage; -void APIENTRY glad_debug_impl_glGetCompressedTextureSubImage(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLsizei arg8, void * arg9) { - _pre_call_callback_gl("glGetCompressedTextureSubImage", (void*)glGetCompressedTextureSubImage, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - glad_glGetCompressedTextureSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - _post_call_callback_gl("glGetCompressedTextureSubImage", (void*)glGetCompressedTextureSubImage, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - + +void APIENTRY glad_debug_impl_glGetCompressedTextureSubImage(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLsizei arg8, + void *arg9) { + _pre_call_callback_gl("glGetCompressedTextureSubImage", + (void *) glGetCompressedTextureSubImage, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + glad_glGetCompressedTextureSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + _post_call_callback_gl("glGetCompressedTextureSubImage", + (void *) glGetCompressedTextureSubImage, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + } -PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_debug_glGetCompressedTextureSubImage = glad_debug_impl_glGetCompressedTextureSubImage; + +PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC + glad_debug_glGetCompressedTextureSubImage = glad_debug_impl_glGetCompressedTextureSubImage; PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog; -GLuint APIENTRY glad_debug_impl_glGetDebugMessageLog(GLuint arg0, GLsizei arg1, GLenum * arg2, GLenum * arg3, GLuint * arg4, GLenum * arg5, GLsizei * arg6, GLchar * arg7) { - GLuint ret; - _pre_call_callback_gl("glGetDebugMessageLog", (void*)glGetDebugMessageLog, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - ret = glad_glGetDebugMessageLog(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glGetDebugMessageLog", (void*)glGetDebugMessageLog, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - return ret; + +GLuint APIENTRY glad_debug_impl_glGetDebugMessageLog(GLuint arg0, + GLsizei arg1, + GLenum *arg2, + GLenum *arg3, + GLuint *arg4, + GLenum *arg5, + GLsizei *arg6, + GLchar *arg7) { + GLuint ret; + _pre_call_callback_gl("glGetDebugMessageLog", + (void *) glGetDebugMessageLog, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + ret = glad_glGetDebugMessageLog(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glGetDebugMessageLog", + (void *) glGetDebugMessageLog, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + return ret; } + PFNGLGETDEBUGMESSAGELOGPROC glad_debug_glGetDebugMessageLog = glad_debug_impl_glGetDebugMessageLog; PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v; -void APIENTRY glad_debug_impl_glGetDoublei_v(GLenum arg0, GLuint arg1, GLdouble * arg2) { - _pre_call_callback_gl("glGetDoublei_v", (void*)glGetDoublei_v, 3, arg0, arg1, arg2); - glad_glGetDoublei_v(arg0, arg1, arg2); - _post_call_callback_gl("glGetDoublei_v", (void*)glGetDoublei_v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetDoublei_v(GLenum arg0, GLuint arg1, GLdouble *arg2) { + _pre_call_callback_gl("glGetDoublei_v", (void *) glGetDoublei_v, 3, arg0, arg1, arg2); + glad_glGetDoublei_v(arg0, arg1, arg2); + _post_call_callback_gl("glGetDoublei_v", (void *) glGetDoublei_v, 3, arg0, arg1, arg2); + } + PFNGLGETDOUBLEI_VPROC glad_debug_glGetDoublei_v = glad_debug_impl_glGetDoublei_v; PFNGLGETDOUBLEVPROC glad_glGetDoublev; -void APIENTRY glad_debug_impl_glGetDoublev(GLenum arg0, GLdouble * arg1) { - _pre_call_callback_gl("glGetDoublev", (void*)glGetDoublev, 2, arg0, arg1); - glad_glGetDoublev(arg0, arg1); - _post_call_callback_gl("glGetDoublev", (void*)glGetDoublev, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetDoublev(GLenum arg0, GLdouble *arg1) { + _pre_call_callback_gl("glGetDoublev", (void *) glGetDoublev, 2, arg0, arg1); + glad_glGetDoublev(arg0, arg1); + _post_call_callback_gl("glGetDoublev", (void *) glGetDoublev, 2, arg0, arg1); + } + PFNGLGETDOUBLEVPROC glad_debug_glGetDoublev = glad_debug_impl_glGetDoublev; PFNGLGETERRORPROC glad_glGetError; -GLenum APIENTRY glad_debug_impl_glGetError(void) { - GLenum ret; - _pre_call_callback_gl("glGetError", (void*)glGetError, 0); - ret = glad_glGetError(); - _post_call_callback_gl("glGetError", (void*)glGetError, 0); - return ret; + +GLenum APIENTRY glad_debug_impl_glGetError(void) { + GLenum ret; + _pre_call_callback_gl("glGetError", (void *) glGetError, 0); + ret = glad_glGetError(); + _post_call_callback_gl("glGetError", (void *) glGetError, 0); + return ret; } + PFNGLGETERRORPROC glad_debug_glGetError = glad_debug_impl_glGetError; PFNGLGETFLOATI_VPROC glad_glGetFloati_v; -void APIENTRY glad_debug_impl_glGetFloati_v(GLenum arg0, GLuint arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetFloati_v", (void*)glGetFloati_v, 3, arg0, arg1, arg2); - glad_glGetFloati_v(arg0, arg1, arg2); - _post_call_callback_gl("glGetFloati_v", (void*)glGetFloati_v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetFloati_v(GLenum arg0, GLuint arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetFloati_v", (void *) glGetFloati_v, 3, arg0, arg1, arg2); + glad_glGetFloati_v(arg0, arg1, arg2); + _post_call_callback_gl("glGetFloati_v", (void *) glGetFloati_v, 3, arg0, arg1, arg2); + } + PFNGLGETFLOATI_VPROC glad_debug_glGetFloati_v = glad_debug_impl_glGetFloati_v; PFNGLGETFLOATVPROC glad_glGetFloatv; -void APIENTRY glad_debug_impl_glGetFloatv(GLenum arg0, GLfloat * arg1) { - _pre_call_callback_gl("glGetFloatv", (void*)glGetFloatv, 2, arg0, arg1); - glad_glGetFloatv(arg0, arg1); - _post_call_callback_gl("glGetFloatv", (void*)glGetFloatv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetFloatv(GLenum arg0, GLfloat *arg1) { + _pre_call_callback_gl("glGetFloatv", (void *) glGetFloatv, 2, arg0, arg1); + glad_glGetFloatv(arg0, arg1); + _post_call_callback_gl("glGetFloatv", (void *) glGetFloatv, 2, arg0, arg1); + } + PFNGLGETFLOATVPROC glad_debug_glGetFloatv = glad_debug_impl_glGetFloatv; PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex; -GLint APIENTRY glad_debug_impl_glGetFragDataIndex(GLuint arg0, const GLchar * arg1) { - GLint ret; - _pre_call_callback_gl("glGetFragDataIndex", (void*)glGetFragDataIndex, 2, arg0, arg1); - ret = glad_glGetFragDataIndex(arg0, arg1); - _post_call_callback_gl("glGetFragDataIndex", (void*)glGetFragDataIndex, 2, arg0, arg1); - return ret; + +GLint APIENTRY glad_debug_impl_glGetFragDataIndex(GLuint arg0, const GLchar *arg1) { + GLint ret; + _pre_call_callback_gl("glGetFragDataIndex", (void *) glGetFragDataIndex, 2, arg0, arg1); + ret = glad_glGetFragDataIndex(arg0, arg1); + _post_call_callback_gl("glGetFragDataIndex", (void *) glGetFragDataIndex, 2, arg0, arg1); + return ret; } + PFNGLGETFRAGDATAINDEXPROC glad_debug_glGetFragDataIndex = glad_debug_impl_glGetFragDataIndex; PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation; -GLint APIENTRY glad_debug_impl_glGetFragDataLocation(GLuint arg0, const GLchar * arg1) { - GLint ret; - _pre_call_callback_gl("glGetFragDataLocation", (void*)glGetFragDataLocation, 2, arg0, arg1); - ret = glad_glGetFragDataLocation(arg0, arg1); - _post_call_callback_gl("glGetFragDataLocation", (void*)glGetFragDataLocation, 2, arg0, arg1); - return ret; + +GLint APIENTRY glad_debug_impl_glGetFragDataLocation(GLuint arg0, const GLchar *arg1) { + GLint ret; + _pre_call_callback_gl("glGetFragDataLocation", (void *) glGetFragDataLocation, 2, arg0, arg1); + ret = glad_glGetFragDataLocation(arg0, arg1); + _post_call_callback_gl("glGetFragDataLocation", (void *) glGetFragDataLocation, 2, arg0, arg1); + return ret; } + PFNGLGETFRAGDATALOCATIONPROC glad_debug_glGetFragDataLocation = glad_debug_impl_glGetFragDataLocation; PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv; -void APIENTRY glad_debug_impl_glGetFramebufferAttachmentParameteriv(GLenum arg0, GLenum arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetFramebufferAttachmentParameteriv", (void*)glGetFramebufferAttachmentParameteriv, 4, arg0, arg1, arg2, arg3); - glad_glGetFramebufferAttachmentParameteriv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetFramebufferAttachmentParameteriv", (void*)glGetFramebufferAttachmentParameteriv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetFramebufferAttachmentParameteriv(GLenum arg0, + GLenum arg1, + GLenum arg2, + GLint *arg3) { + _pre_call_callback_gl("glGetFramebufferAttachmentParameteriv", + (void *) glGetFramebufferAttachmentParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetFramebufferAttachmentParameteriv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetFramebufferAttachmentParameteriv", + (void *) glGetFramebufferAttachmentParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_debug_glGetFramebufferAttachmentParameteriv = glad_debug_impl_glGetFramebufferAttachmentParameteriv; + +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC + glad_debug_glGetFramebufferAttachmentParameteriv = glad_debug_impl_glGetFramebufferAttachmentParameteriv; PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv; -void APIENTRY glad_debug_impl_glGetFramebufferParameteriv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetFramebufferParameteriv", (void*)glGetFramebufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetFramebufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetFramebufferParameteriv", (void*)glGetFramebufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetFramebufferParameteriv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetFramebufferParameteriv", (void *) glGetFramebufferParameteriv, 3, arg0, arg1, arg2); + glad_glGetFramebufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetFramebufferParameteriv", (void *) glGetFramebufferParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_debug_glGetFramebufferParameteriv = glad_debug_impl_glGetFramebufferParameteriv; PFNGLGETGRAPHICSRESETSTATUSPROC glad_glGetGraphicsResetStatus; -GLenum APIENTRY glad_debug_impl_glGetGraphicsResetStatus(void) { - GLenum ret; - _pre_call_callback_gl("glGetGraphicsResetStatus", (void*)glGetGraphicsResetStatus, 0); - ret = glad_glGetGraphicsResetStatus(); - _post_call_callback_gl("glGetGraphicsResetStatus", (void*)glGetGraphicsResetStatus, 0); - return ret; + +GLenum APIENTRY glad_debug_impl_glGetGraphicsResetStatus(void) { + GLenum ret; + _pre_call_callback_gl("glGetGraphicsResetStatus", (void *) glGetGraphicsResetStatus, 0); + ret = glad_glGetGraphicsResetStatus(); + _post_call_callback_gl("glGetGraphicsResetStatus", (void *) glGetGraphicsResetStatus, 0); + return ret; } + PFNGLGETGRAPHICSRESETSTATUSPROC glad_debug_glGetGraphicsResetStatus = glad_debug_impl_glGetGraphicsResetStatus; PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v; -void APIENTRY glad_debug_impl_glGetInteger64i_v(GLenum arg0, GLuint arg1, GLint64 * arg2) { - _pre_call_callback_gl("glGetInteger64i_v", (void*)glGetInteger64i_v, 3, arg0, arg1, arg2); - glad_glGetInteger64i_v(arg0, arg1, arg2); - _post_call_callback_gl("glGetInteger64i_v", (void*)glGetInteger64i_v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetInteger64i_v(GLenum arg0, GLuint arg1, GLint64 *arg2) { + _pre_call_callback_gl("glGetInteger64i_v", (void *) glGetInteger64i_v, 3, arg0, arg1, arg2); + glad_glGetInteger64i_v(arg0, arg1, arg2); + _post_call_callback_gl("glGetInteger64i_v", (void *) glGetInteger64i_v, 3, arg0, arg1, arg2); + } + PFNGLGETINTEGER64I_VPROC glad_debug_glGetInteger64i_v = glad_debug_impl_glGetInteger64i_v; PFNGLGETINTEGER64VPROC glad_glGetInteger64v; -void APIENTRY glad_debug_impl_glGetInteger64v(GLenum arg0, GLint64 * arg1) { - _pre_call_callback_gl("glGetInteger64v", (void*)glGetInteger64v, 2, arg0, arg1); - glad_glGetInteger64v(arg0, arg1); - _post_call_callback_gl("glGetInteger64v", (void*)glGetInteger64v, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetInteger64v(GLenum arg0, GLint64 *arg1) { + _pre_call_callback_gl("glGetInteger64v", (void *) glGetInteger64v, 2, arg0, arg1); + glad_glGetInteger64v(arg0, arg1); + _post_call_callback_gl("glGetInteger64v", (void *) glGetInteger64v, 2, arg0, arg1); + } + PFNGLGETINTEGER64VPROC glad_debug_glGetInteger64v = glad_debug_impl_glGetInteger64v; PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v; -void APIENTRY glad_debug_impl_glGetIntegeri_v(GLenum arg0, GLuint arg1, GLint * arg2) { - _pre_call_callback_gl("glGetIntegeri_v", (void*)glGetIntegeri_v, 3, arg0, arg1, arg2); - glad_glGetIntegeri_v(arg0, arg1, arg2); - _post_call_callback_gl("glGetIntegeri_v", (void*)glGetIntegeri_v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetIntegeri_v(GLenum arg0, GLuint arg1, GLint *arg2) { + _pre_call_callback_gl("glGetIntegeri_v", (void *) glGetIntegeri_v, 3, arg0, arg1, arg2); + glad_glGetIntegeri_v(arg0, arg1, arg2); + _post_call_callback_gl("glGetIntegeri_v", (void *) glGetIntegeri_v, 3, arg0, arg1, arg2); + } + PFNGLGETINTEGERI_VPROC glad_debug_glGetIntegeri_v = glad_debug_impl_glGetIntegeri_v; PFNGLGETINTEGERVPROC glad_glGetIntegerv; -void APIENTRY glad_debug_impl_glGetIntegerv(GLenum arg0, GLint * arg1) { - _pre_call_callback_gl("glGetIntegerv", (void*)glGetIntegerv, 2, arg0, arg1); - glad_glGetIntegerv(arg0, arg1); - _post_call_callback_gl("glGetIntegerv", (void*)glGetIntegerv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetIntegerv(GLenum arg0, GLint *arg1) { + _pre_call_callback_gl("glGetIntegerv", (void *) glGetIntegerv, 2, arg0, arg1); + glad_glGetIntegerv(arg0, arg1); + _post_call_callback_gl("glGetIntegerv", (void *) glGetIntegerv, 2, arg0, arg1); + } + PFNGLGETINTEGERVPROC glad_debug_glGetIntegerv = glad_debug_impl_glGetIntegerv; PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v; -void APIENTRY glad_debug_impl_glGetInternalformati64v(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, GLint64 * arg4) { - _pre_call_callback_gl("glGetInternalformati64v", (void*)glGetInternalformati64v, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetInternalformati64v(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetInternalformati64v", (void*)glGetInternalformati64v, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetInternalformati64v(GLenum arg0, + GLenum arg1, + GLenum arg2, + GLsizei arg3, + GLint64 *arg4) { + _pre_call_callback_gl("glGetInternalformati64v", (void *) glGetInternalformati64v, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetInternalformati64v(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetInternalformati64v", + (void *) glGetInternalformati64v, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLGETINTERNALFORMATI64VPROC glad_debug_glGetInternalformati64v = glad_debug_impl_glGetInternalformati64v; PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ; -void APIENTRY glad_debug_impl_glGetInternalformativ(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, GLint * arg4) { - _pre_call_callback_gl("glGetInternalformativ", (void*)glGetInternalformativ, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetInternalformativ(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetInternalformativ", (void*)glGetInternalformativ, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetInternalformativ(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, GLint *arg4) { + _pre_call_callback_gl("glGetInternalformativ", (void *) glGetInternalformativ, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetInternalformativ(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetInternalformativ", (void *) glGetInternalformativ, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETINTERNALFORMATIVPROC glad_debug_glGetInternalformativ = glad_debug_impl_glGetInternalformativ; PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv; -void APIENTRY glad_debug_impl_glGetMultisamplefv(GLenum arg0, GLuint arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetMultisamplefv", (void*)glGetMultisamplefv, 3, arg0, arg1, arg2); - glad_glGetMultisamplefv(arg0, arg1, arg2); - _post_call_callback_gl("glGetMultisamplefv", (void*)glGetMultisamplefv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetMultisamplefv(GLenum arg0, GLuint arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetMultisamplefv", (void *) glGetMultisamplefv, 3, arg0, arg1, arg2); + glad_glGetMultisamplefv(arg0, arg1, arg2); + _post_call_callback_gl("glGetMultisamplefv", (void *) glGetMultisamplefv, 3, arg0, arg1, arg2); + } + PFNGLGETMULTISAMPLEFVPROC glad_debug_glGetMultisamplefv = glad_debug_impl_glGetMultisamplefv; PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v; -void APIENTRY glad_debug_impl_glGetNamedBufferParameteri64v(GLuint arg0, GLenum arg1, GLint64 * arg2) { - _pre_call_callback_gl("glGetNamedBufferParameteri64v", (void*)glGetNamedBufferParameteri64v, 3, arg0, arg1, arg2); - glad_glGetNamedBufferParameteri64v(arg0, arg1, arg2); - _post_call_callback_gl("glGetNamedBufferParameteri64v", (void*)glGetNamedBufferParameteri64v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetNamedBufferParameteri64v(GLuint arg0, GLenum arg1, GLint64 *arg2) { + _pre_call_callback_gl("glGetNamedBufferParameteri64v", (void *) glGetNamedBufferParameteri64v, 3, arg0, arg1, arg2); + glad_glGetNamedBufferParameteri64v(arg0, arg1, arg2); + _post_call_callback_gl("glGetNamedBufferParameteri64v", + (void *) glGetNamedBufferParameteri64v, + 3, + arg0, + arg1, + arg2); + } -PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_debug_glGetNamedBufferParameteri64v = glad_debug_impl_glGetNamedBufferParameteri64v; + +PFNGLGETNAMEDBUFFERPARAMETERI64VPROC + glad_debug_glGetNamedBufferParameteri64v = glad_debug_impl_glGetNamedBufferParameteri64v; PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv; -void APIENTRY glad_debug_impl_glGetNamedBufferParameteriv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetNamedBufferParameteriv", (void*)glGetNamedBufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetNamedBufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetNamedBufferParameteriv", (void*)glGetNamedBufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetNamedBufferParameteriv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetNamedBufferParameteriv", (void *) glGetNamedBufferParameteriv, 3, arg0, arg1, arg2); + glad_glGetNamedBufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetNamedBufferParameteriv", (void *) glGetNamedBufferParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_debug_glGetNamedBufferParameteriv = glad_debug_impl_glGetNamedBufferParameteriv; PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv; -void APIENTRY glad_debug_impl_glGetNamedBufferPointerv(GLuint arg0, GLenum arg1, void ** arg2) { - _pre_call_callback_gl("glGetNamedBufferPointerv", (void*)glGetNamedBufferPointerv, 3, arg0, arg1, arg2); - glad_glGetNamedBufferPointerv(arg0, arg1, arg2); - _post_call_callback_gl("glGetNamedBufferPointerv", (void*)glGetNamedBufferPointerv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetNamedBufferPointerv(GLuint arg0, GLenum arg1, void **arg2) { + _pre_call_callback_gl("glGetNamedBufferPointerv", (void *) glGetNamedBufferPointerv, 3, arg0, arg1, arg2); + glad_glGetNamedBufferPointerv(arg0, arg1, arg2); + _post_call_callback_gl("glGetNamedBufferPointerv", (void *) glGetNamedBufferPointerv, 3, arg0, arg1, arg2); + } + PFNGLGETNAMEDBUFFERPOINTERVPROC glad_debug_glGetNamedBufferPointerv = glad_debug_impl_glGetNamedBufferPointerv; PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData; -void APIENTRY glad_debug_impl_glGetNamedBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, void * arg3) { - _pre_call_callback_gl("glGetNamedBufferSubData", (void*)glGetNamedBufferSubData, 4, arg0, arg1, arg2, arg3); - glad_glGetNamedBufferSubData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetNamedBufferSubData", (void*)glGetNamedBufferSubData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetNamedBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, void *arg3) { + _pre_call_callback_gl("glGetNamedBufferSubData", (void *) glGetNamedBufferSubData, 4, arg0, arg1, arg2, arg3); + glad_glGetNamedBufferSubData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetNamedBufferSubData", (void *) glGetNamedBufferSubData, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNAMEDBUFFERSUBDATAPROC glad_debug_glGetNamedBufferSubData = glad_debug_impl_glGetNamedBufferSubData; PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv; -void APIENTRY glad_debug_impl_glGetNamedFramebufferAttachmentParameteriv(GLuint arg0, GLenum arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetNamedFramebufferAttachmentParameteriv", (void*)glGetNamedFramebufferAttachmentParameteriv, 4, arg0, arg1, arg2, arg3); - glad_glGetNamedFramebufferAttachmentParameteriv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetNamedFramebufferAttachmentParameteriv", (void*)glGetNamedFramebufferAttachmentParameteriv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetNamedFramebufferAttachmentParameteriv(GLuint arg0, + GLenum arg1, + GLenum arg2, + GLint *arg3) { + _pre_call_callback_gl("glGetNamedFramebufferAttachmentParameteriv", + (void *) glGetNamedFramebufferAttachmentParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetNamedFramebufferAttachmentParameteriv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetNamedFramebufferAttachmentParameteriv", + (void *) glGetNamedFramebufferAttachmentParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_debug_glGetNamedFramebufferAttachmentParameteriv = glad_debug_impl_glGetNamedFramebufferAttachmentParameteriv; + +PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC + glad_debug_glGetNamedFramebufferAttachmentParameteriv = glad_debug_impl_glGetNamedFramebufferAttachmentParameteriv; PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv; -void APIENTRY glad_debug_impl_glGetNamedFramebufferParameteriv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetNamedFramebufferParameteriv", (void*)glGetNamedFramebufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetNamedFramebufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetNamedFramebufferParameteriv", (void*)glGetNamedFramebufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetNamedFramebufferParameteriv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetNamedFramebufferParameteriv", + (void *) glGetNamedFramebufferParameteriv, + 3, + arg0, + arg1, + arg2); + glad_glGetNamedFramebufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetNamedFramebufferParameteriv", + (void *) glGetNamedFramebufferParameteriv, + 3, + arg0, + arg1, + arg2); + } -PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_debug_glGetNamedFramebufferParameteriv = glad_debug_impl_glGetNamedFramebufferParameteriv; + +PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC + glad_debug_glGetNamedFramebufferParameteriv = glad_debug_impl_glGetNamedFramebufferParameteriv; PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv; -void APIENTRY glad_debug_impl_glGetNamedRenderbufferParameteriv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetNamedRenderbufferParameteriv", (void*)glGetNamedRenderbufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetNamedRenderbufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetNamedRenderbufferParameteriv", (void*)glGetNamedRenderbufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetNamedRenderbufferParameteriv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetNamedRenderbufferParameteriv", + (void *) glGetNamedRenderbufferParameteriv, + 3, + arg0, + arg1, + arg2); + glad_glGetNamedRenderbufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetNamedRenderbufferParameteriv", + (void *) glGetNamedRenderbufferParameteriv, + 3, + arg0, + arg1, + arg2); + } -PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_debug_glGetNamedRenderbufferParameteriv = glad_debug_impl_glGetNamedRenderbufferParameteriv; + +PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC + glad_debug_glGetNamedRenderbufferParameteriv = glad_debug_impl_glGetNamedRenderbufferParameteriv; PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel; -void APIENTRY glad_debug_impl_glGetObjectLabel(GLenum arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLchar * arg4) { - _pre_call_callback_gl("glGetObjectLabel", (void*)glGetObjectLabel, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetObjectLabel(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetObjectLabel", (void*)glGetObjectLabel, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetObjectLabel(GLenum arg0, GLuint arg1, GLsizei arg2, GLsizei *arg3, GLchar *arg4) { + _pre_call_callback_gl("glGetObjectLabel", (void *) glGetObjectLabel, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetObjectLabel(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetObjectLabel", (void *) glGetObjectLabel, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETOBJECTLABELPROC glad_debug_glGetObjectLabel = glad_debug_impl_glGetObjectLabel; PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel; -void APIENTRY glad_debug_impl_glGetObjectPtrLabel(const void * arg0, GLsizei arg1, GLsizei * arg2, GLchar * arg3) { - _pre_call_callback_gl("glGetObjectPtrLabel", (void*)glGetObjectPtrLabel, 4, arg0, arg1, arg2, arg3); - glad_glGetObjectPtrLabel(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetObjectPtrLabel", (void*)glGetObjectPtrLabel, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetObjectPtrLabel(const void *arg0, GLsizei arg1, GLsizei *arg2, GLchar *arg3) { + _pre_call_callback_gl("glGetObjectPtrLabel", (void *) glGetObjectPtrLabel, 4, arg0, arg1, arg2, arg3); + glad_glGetObjectPtrLabel(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetObjectPtrLabel", (void *) glGetObjectPtrLabel, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETOBJECTPTRLABELPROC glad_debug_glGetObjectPtrLabel = glad_debug_impl_glGetObjectPtrLabel; PFNGLGETPOINTERVPROC glad_glGetPointerv; -void APIENTRY glad_debug_impl_glGetPointerv(GLenum arg0, void ** arg1) { - _pre_call_callback_gl("glGetPointerv", (void*)glGetPointerv, 2, arg0, arg1); - glad_glGetPointerv(arg0, arg1); - _post_call_callback_gl("glGetPointerv", (void*)glGetPointerv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetPointerv(GLenum arg0, void **arg1) { + _pre_call_callback_gl("glGetPointerv", (void *) glGetPointerv, 2, arg0, arg1); + glad_glGetPointerv(arg0, arg1); + _post_call_callback_gl("glGetPointerv", (void *) glGetPointerv, 2, arg0, arg1); + } + PFNGLGETPOINTERVPROC glad_debug_glGetPointerv = glad_debug_impl_glGetPointerv; PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary; -void APIENTRY glad_debug_impl_glGetProgramBinary(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLenum * arg3, void * arg4) { - _pre_call_callback_gl("glGetProgramBinary", (void*)glGetProgramBinary, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetProgramBinary(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetProgramBinary", (void*)glGetProgramBinary, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetProgramBinary(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLenum *arg3, void *arg4) { + _pre_call_callback_gl("glGetProgramBinary", (void *) glGetProgramBinary, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetProgramBinary(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetProgramBinary", (void *) glGetProgramBinary, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETPROGRAMBINARYPROC glad_debug_glGetProgramBinary = glad_debug_impl_glGetProgramBinary; PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog; -void APIENTRY glad_debug_impl_glGetProgramInfoLog(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLchar * arg3) { - _pre_call_callback_gl("glGetProgramInfoLog", (void*)glGetProgramInfoLog, 4, arg0, arg1, arg2, arg3); - glad_glGetProgramInfoLog(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetProgramInfoLog", (void*)glGetProgramInfoLog, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetProgramInfoLog(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLchar *arg3) { + _pre_call_callback_gl("glGetProgramInfoLog", (void *) glGetProgramInfoLog, 4, arg0, arg1, arg2, arg3); + glad_glGetProgramInfoLog(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetProgramInfoLog", (void *) glGetProgramInfoLog, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETPROGRAMINFOLOGPROC glad_debug_glGetProgramInfoLog = glad_debug_impl_glGetProgramInfoLog; PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv; -void APIENTRY glad_debug_impl_glGetProgramInterfaceiv(GLuint arg0, GLenum arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetProgramInterfaceiv", (void*)glGetProgramInterfaceiv, 4, arg0, arg1, arg2, arg3); - glad_glGetProgramInterfaceiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetProgramInterfaceiv", (void*)glGetProgramInterfaceiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetProgramInterfaceiv(GLuint arg0, GLenum arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetProgramInterfaceiv", (void *) glGetProgramInterfaceiv, 4, arg0, arg1, arg2, arg3); + glad_glGetProgramInterfaceiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetProgramInterfaceiv", (void *) glGetProgramInterfaceiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETPROGRAMINTERFACEIVPROC glad_debug_glGetProgramInterfaceiv = glad_debug_impl_glGetProgramInterfaceiv; PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog; -void APIENTRY glad_debug_impl_glGetProgramPipelineInfoLog(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLchar * arg3) { - _pre_call_callback_gl("glGetProgramPipelineInfoLog", (void*)glGetProgramPipelineInfoLog, 4, arg0, arg1, arg2, arg3); - glad_glGetProgramPipelineInfoLog(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetProgramPipelineInfoLog", (void*)glGetProgramPipelineInfoLog, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetProgramPipelineInfoLog(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLchar *arg3) { + _pre_call_callback_gl("glGetProgramPipelineInfoLog", + (void *) glGetProgramPipelineInfoLog, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetProgramPipelineInfoLog(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetProgramPipelineInfoLog", + (void *) glGetProgramPipelineInfoLog, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_debug_glGetProgramPipelineInfoLog = glad_debug_impl_glGetProgramPipelineInfoLog; PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv; -void APIENTRY glad_debug_impl_glGetProgramPipelineiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetProgramPipelineiv", (void*)glGetProgramPipelineiv, 3, arg0, arg1, arg2); - glad_glGetProgramPipelineiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetProgramPipelineiv", (void*)glGetProgramPipelineiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetProgramPipelineiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetProgramPipelineiv", (void *) glGetProgramPipelineiv, 3, arg0, arg1, arg2); + glad_glGetProgramPipelineiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetProgramPipelineiv", (void *) glGetProgramPipelineiv, 3, arg0, arg1, arg2); + } + PFNGLGETPROGRAMPIPELINEIVPROC glad_debug_glGetProgramPipelineiv = glad_debug_impl_glGetProgramPipelineiv; PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex; -GLuint APIENTRY glad_debug_impl_glGetProgramResourceIndex(GLuint arg0, GLenum arg1, const GLchar * arg2) { - GLuint ret; - _pre_call_callback_gl("glGetProgramResourceIndex", (void*)glGetProgramResourceIndex, 3, arg0, arg1, arg2); - ret = glad_glGetProgramResourceIndex(arg0, arg1, arg2); - _post_call_callback_gl("glGetProgramResourceIndex", (void*)glGetProgramResourceIndex, 3, arg0, arg1, arg2); - return ret; + +GLuint APIENTRY glad_debug_impl_glGetProgramResourceIndex(GLuint arg0, GLenum arg1, const GLchar *arg2) { + GLuint ret; + _pre_call_callback_gl("glGetProgramResourceIndex", (void *) glGetProgramResourceIndex, 3, arg0, arg1, arg2); + ret = glad_glGetProgramResourceIndex(arg0, arg1, arg2); + _post_call_callback_gl("glGetProgramResourceIndex", (void *) glGetProgramResourceIndex, 3, arg0, arg1, arg2); + return ret; } + PFNGLGETPROGRAMRESOURCEINDEXPROC glad_debug_glGetProgramResourceIndex = glad_debug_impl_glGetProgramResourceIndex; PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation; -GLint APIENTRY glad_debug_impl_glGetProgramResourceLocation(GLuint arg0, GLenum arg1, const GLchar * arg2) { - GLint ret; - _pre_call_callback_gl("glGetProgramResourceLocation", (void*)glGetProgramResourceLocation, 3, arg0, arg1, arg2); - ret = glad_glGetProgramResourceLocation(arg0, arg1, arg2); - _post_call_callback_gl("glGetProgramResourceLocation", (void*)glGetProgramResourceLocation, 3, arg0, arg1, arg2); - return ret; -} -PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_debug_glGetProgramResourceLocation = glad_debug_impl_glGetProgramResourceLocation; + +GLint APIENTRY glad_debug_impl_glGetProgramResourceLocation(GLuint arg0, GLenum arg1, const GLchar *arg2) { + GLint ret; + _pre_call_callback_gl("glGetProgramResourceLocation", (void *) glGetProgramResourceLocation, 3, arg0, arg1, arg2); + ret = glad_glGetProgramResourceLocation(arg0, arg1, arg2); + _post_call_callback_gl("glGetProgramResourceLocation", (void *) glGetProgramResourceLocation, 3, arg0, arg1, arg2); + return ret; +} + +PFNGLGETPROGRAMRESOURCELOCATIONPROC + glad_debug_glGetProgramResourceLocation = glad_debug_impl_glGetProgramResourceLocation; PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex; -GLint APIENTRY glad_debug_impl_glGetProgramResourceLocationIndex(GLuint arg0, GLenum arg1, const GLchar * arg2) { - GLint ret; - _pre_call_callback_gl("glGetProgramResourceLocationIndex", (void*)glGetProgramResourceLocationIndex, 3, arg0, arg1, arg2); - ret = glad_glGetProgramResourceLocationIndex(arg0, arg1, arg2); - _post_call_callback_gl("glGetProgramResourceLocationIndex", (void*)glGetProgramResourceLocationIndex, 3, arg0, arg1, arg2); - return ret; -} -PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_debug_glGetProgramResourceLocationIndex = glad_debug_impl_glGetProgramResourceLocationIndex; + +GLint APIENTRY glad_debug_impl_glGetProgramResourceLocationIndex(GLuint arg0, GLenum arg1, const GLchar *arg2) { + GLint ret; + _pre_call_callback_gl("glGetProgramResourceLocationIndex", + (void *) glGetProgramResourceLocationIndex, + 3, + arg0, + arg1, + arg2); + ret = glad_glGetProgramResourceLocationIndex(arg0, arg1, arg2); + _post_call_callback_gl("glGetProgramResourceLocationIndex", + (void *) glGetProgramResourceLocationIndex, + 3, + arg0, + arg1, + arg2); + return ret; +} + +PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC + glad_debug_glGetProgramResourceLocationIndex = glad_debug_impl_glGetProgramResourceLocationIndex; PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName; -void APIENTRY glad_debug_impl_glGetProgramResourceName(GLuint arg0, GLenum arg1, GLuint arg2, GLsizei arg3, GLsizei * arg4, GLchar * arg5) { - _pre_call_callback_gl("glGetProgramResourceName", (void*)glGetProgramResourceName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetProgramResourceName(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetProgramResourceName", (void*)glGetProgramResourceName, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetProgramResourceName(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLsizei arg3, + GLsizei *arg4, + GLchar *arg5) { + _pre_call_callback_gl("glGetProgramResourceName", + (void *) glGetProgramResourceName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glGetProgramResourceName(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetProgramResourceName", + (void *) glGetProgramResourceName, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLGETPROGRAMRESOURCENAMEPROC glad_debug_glGetProgramResourceName = glad_debug_impl_glGetProgramResourceName; PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv; -void APIENTRY glad_debug_impl_glGetProgramResourceiv(GLuint arg0, GLenum arg1, GLuint arg2, GLsizei arg3, const GLenum * arg4, GLsizei arg5, GLsizei * arg6, GLint * arg7) { - _pre_call_callback_gl("glGetProgramResourceiv", (void*)glGetProgramResourceiv, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glGetProgramResourceiv(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glGetProgramResourceiv", (void*)glGetProgramResourceiv, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glGetProgramResourceiv(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLsizei arg3, + const GLenum *arg4, + GLsizei arg5, + GLsizei *arg6, + GLint *arg7) { + _pre_call_callback_gl("glGetProgramResourceiv", + (void *) glGetProgramResourceiv, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glGetProgramResourceiv(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glGetProgramResourceiv", + (void *) glGetProgramResourceiv, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLGETPROGRAMRESOURCEIVPROC glad_debug_glGetProgramResourceiv = glad_debug_impl_glGetProgramResourceiv; PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv; -void APIENTRY glad_debug_impl_glGetProgramStageiv(GLuint arg0, GLenum arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetProgramStageiv", (void*)glGetProgramStageiv, 4, arg0, arg1, arg2, arg3); - glad_glGetProgramStageiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetProgramStageiv", (void*)glGetProgramStageiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetProgramStageiv(GLuint arg0, GLenum arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetProgramStageiv", (void *) glGetProgramStageiv, 4, arg0, arg1, arg2, arg3); + glad_glGetProgramStageiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetProgramStageiv", (void *) glGetProgramStageiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETPROGRAMSTAGEIVPROC glad_debug_glGetProgramStageiv = glad_debug_impl_glGetProgramStageiv; PFNGLGETPROGRAMIVPROC glad_glGetProgramiv; -void APIENTRY glad_debug_impl_glGetProgramiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetProgramiv", (void*)glGetProgramiv, 3, arg0, arg1, arg2); - glad_glGetProgramiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetProgramiv", (void*)glGetProgramiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetProgramiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetProgramiv", (void *) glGetProgramiv, 3, arg0, arg1, arg2); + glad_glGetProgramiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetProgramiv", (void *) glGetProgramiv, 3, arg0, arg1, arg2); + } + PFNGLGETPROGRAMIVPROC glad_debug_glGetProgramiv = glad_debug_impl_glGetProgramiv; PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v; -void APIENTRY glad_debug_impl_glGetQueryBufferObjecti64v(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { - _pre_call_callback_gl("glGetQueryBufferObjecti64v", (void*)glGetQueryBufferObjecti64v, 4, arg0, arg1, arg2, arg3); - glad_glGetQueryBufferObjecti64v(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetQueryBufferObjecti64v", (void*)glGetQueryBufferObjecti64v, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetQueryBufferObjecti64v(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { + _pre_call_callback_gl("glGetQueryBufferObjecti64v", (void *) glGetQueryBufferObjecti64v, 4, arg0, arg1, arg2, arg3); + glad_glGetQueryBufferObjecti64v(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetQueryBufferObjecti64v", + (void *) glGetQueryBufferObjecti64v, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_debug_glGetQueryBufferObjecti64v = glad_debug_impl_glGetQueryBufferObjecti64v; PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv; -void APIENTRY glad_debug_impl_glGetQueryBufferObjectiv(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { - _pre_call_callback_gl("glGetQueryBufferObjectiv", (void*)glGetQueryBufferObjectiv, 4, arg0, arg1, arg2, arg3); - glad_glGetQueryBufferObjectiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetQueryBufferObjectiv", (void*)glGetQueryBufferObjectiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetQueryBufferObjectiv(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { + _pre_call_callback_gl("glGetQueryBufferObjectiv", (void *) glGetQueryBufferObjectiv, 4, arg0, arg1, arg2, arg3); + glad_glGetQueryBufferObjectiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetQueryBufferObjectiv", (void *) glGetQueryBufferObjectiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETQUERYBUFFEROBJECTIVPROC glad_debug_glGetQueryBufferObjectiv = glad_debug_impl_glGetQueryBufferObjectiv; PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v; -void APIENTRY glad_debug_impl_glGetQueryBufferObjectui64v(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { - _pre_call_callback_gl("glGetQueryBufferObjectui64v", (void*)glGetQueryBufferObjectui64v, 4, arg0, arg1, arg2, arg3); - glad_glGetQueryBufferObjectui64v(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetQueryBufferObjectui64v", (void*)glGetQueryBufferObjectui64v, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetQueryBufferObjectui64v(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { + _pre_call_callback_gl("glGetQueryBufferObjectui64v", + (void *) glGetQueryBufferObjectui64v, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetQueryBufferObjectui64v(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetQueryBufferObjectui64v", + (void *) glGetQueryBufferObjectui64v, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_debug_glGetQueryBufferObjectui64v = glad_debug_impl_glGetQueryBufferObjectui64v; PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv; -void APIENTRY glad_debug_impl_glGetQueryBufferObjectuiv(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { - _pre_call_callback_gl("glGetQueryBufferObjectuiv", (void*)glGetQueryBufferObjectuiv, 4, arg0, arg1, arg2, arg3); - glad_glGetQueryBufferObjectuiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetQueryBufferObjectuiv", (void*)glGetQueryBufferObjectuiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetQueryBufferObjectuiv(GLuint arg0, GLuint arg1, GLenum arg2, GLintptr arg3) { + _pre_call_callback_gl("glGetQueryBufferObjectuiv", (void *) glGetQueryBufferObjectuiv, 4, arg0, arg1, arg2, arg3); + glad_glGetQueryBufferObjectuiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetQueryBufferObjectuiv", (void *) glGetQueryBufferObjectuiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_debug_glGetQueryBufferObjectuiv = glad_debug_impl_glGetQueryBufferObjectuiv; PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv; -void APIENTRY glad_debug_impl_glGetQueryIndexediv(GLenum arg0, GLuint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetQueryIndexediv", (void*)glGetQueryIndexediv, 4, arg0, arg1, arg2, arg3); - glad_glGetQueryIndexediv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetQueryIndexediv", (void*)glGetQueryIndexediv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetQueryIndexediv(GLenum arg0, GLuint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetQueryIndexediv", (void *) glGetQueryIndexediv, 4, arg0, arg1, arg2, arg3); + glad_glGetQueryIndexediv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetQueryIndexediv", (void *) glGetQueryIndexediv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETQUERYINDEXEDIVPROC glad_debug_glGetQueryIndexediv = glad_debug_impl_glGetQueryIndexediv; PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v; -void APIENTRY glad_debug_impl_glGetQueryObjecti64v(GLuint arg0, GLenum arg1, GLint64 * arg2) { - _pre_call_callback_gl("glGetQueryObjecti64v", (void*)glGetQueryObjecti64v, 3, arg0, arg1, arg2); - glad_glGetQueryObjecti64v(arg0, arg1, arg2); - _post_call_callback_gl("glGetQueryObjecti64v", (void*)glGetQueryObjecti64v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetQueryObjecti64v(GLuint arg0, GLenum arg1, GLint64 *arg2) { + _pre_call_callback_gl("glGetQueryObjecti64v", (void *) glGetQueryObjecti64v, 3, arg0, arg1, arg2); + glad_glGetQueryObjecti64v(arg0, arg1, arg2); + _post_call_callback_gl("glGetQueryObjecti64v", (void *) glGetQueryObjecti64v, 3, arg0, arg1, arg2); + } + PFNGLGETQUERYOBJECTI64VPROC glad_debug_glGetQueryObjecti64v = glad_debug_impl_glGetQueryObjecti64v; PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv; -void APIENTRY glad_debug_impl_glGetQueryObjectiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetQueryObjectiv", (void*)glGetQueryObjectiv, 3, arg0, arg1, arg2); - glad_glGetQueryObjectiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetQueryObjectiv", (void*)glGetQueryObjectiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetQueryObjectiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetQueryObjectiv", (void *) glGetQueryObjectiv, 3, arg0, arg1, arg2); + glad_glGetQueryObjectiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetQueryObjectiv", (void *) glGetQueryObjectiv, 3, arg0, arg1, arg2); + } + PFNGLGETQUERYOBJECTIVPROC glad_debug_glGetQueryObjectiv = glad_debug_impl_glGetQueryObjectiv; PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v; -void APIENTRY glad_debug_impl_glGetQueryObjectui64v(GLuint arg0, GLenum arg1, GLuint64 * arg2) { - _pre_call_callback_gl("glGetQueryObjectui64v", (void*)glGetQueryObjectui64v, 3, arg0, arg1, arg2); - glad_glGetQueryObjectui64v(arg0, arg1, arg2); - _post_call_callback_gl("glGetQueryObjectui64v", (void*)glGetQueryObjectui64v, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetQueryObjectui64v(GLuint arg0, GLenum arg1, GLuint64 *arg2) { + _pre_call_callback_gl("glGetQueryObjectui64v", (void *) glGetQueryObjectui64v, 3, arg0, arg1, arg2); + glad_glGetQueryObjectui64v(arg0, arg1, arg2); + _post_call_callback_gl("glGetQueryObjectui64v", (void *) glGetQueryObjectui64v, 3, arg0, arg1, arg2); + } + PFNGLGETQUERYOBJECTUI64VPROC glad_debug_glGetQueryObjectui64v = glad_debug_impl_glGetQueryObjectui64v; PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv; -void APIENTRY glad_debug_impl_glGetQueryObjectuiv(GLuint arg0, GLenum arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetQueryObjectuiv", (void*)glGetQueryObjectuiv, 3, arg0, arg1, arg2); - glad_glGetQueryObjectuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetQueryObjectuiv", (void*)glGetQueryObjectuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetQueryObjectuiv(GLuint arg0, GLenum arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetQueryObjectuiv", (void *) glGetQueryObjectuiv, 3, arg0, arg1, arg2); + glad_glGetQueryObjectuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetQueryObjectuiv", (void *) glGetQueryObjectuiv, 3, arg0, arg1, arg2); + } + PFNGLGETQUERYOBJECTUIVPROC glad_debug_glGetQueryObjectuiv = glad_debug_impl_glGetQueryObjectuiv; PFNGLGETQUERYIVPROC glad_glGetQueryiv; -void APIENTRY glad_debug_impl_glGetQueryiv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetQueryiv", (void*)glGetQueryiv, 3, arg0, arg1, arg2); - glad_glGetQueryiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetQueryiv", (void*)glGetQueryiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetQueryiv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetQueryiv", (void *) glGetQueryiv, 3, arg0, arg1, arg2); + glad_glGetQueryiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetQueryiv", (void *) glGetQueryiv, 3, arg0, arg1, arg2); + } + PFNGLGETQUERYIVPROC glad_debug_glGetQueryiv = glad_debug_impl_glGetQueryiv; PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv; -void APIENTRY glad_debug_impl_glGetRenderbufferParameteriv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetRenderbufferParameteriv", (void*)glGetRenderbufferParameteriv, 3, arg0, arg1, arg2); - glad_glGetRenderbufferParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetRenderbufferParameteriv", (void*)glGetRenderbufferParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetRenderbufferParameteriv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetRenderbufferParameteriv", (void *) glGetRenderbufferParameteriv, 3, arg0, arg1, arg2); + glad_glGetRenderbufferParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetRenderbufferParameteriv", (void *) glGetRenderbufferParameteriv, 3, arg0, arg1, arg2); + } -PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_debug_glGetRenderbufferParameteriv = glad_debug_impl_glGetRenderbufferParameteriv; + +PFNGLGETRENDERBUFFERPARAMETERIVPROC + glad_debug_glGetRenderbufferParameteriv = glad_debug_impl_glGetRenderbufferParameteriv; PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv; -void APIENTRY glad_debug_impl_glGetSamplerParameterIiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetSamplerParameterIiv", (void*)glGetSamplerParameterIiv, 3, arg0, arg1, arg2); - glad_glGetSamplerParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetSamplerParameterIiv", (void*)glGetSamplerParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetSamplerParameterIiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetSamplerParameterIiv", (void *) glGetSamplerParameterIiv, 3, arg0, arg1, arg2); + glad_glGetSamplerParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetSamplerParameterIiv", (void *) glGetSamplerParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLGETSAMPLERPARAMETERIIVPROC glad_debug_glGetSamplerParameterIiv = glad_debug_impl_glGetSamplerParameterIiv; PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv; -void APIENTRY glad_debug_impl_glGetSamplerParameterIuiv(GLuint arg0, GLenum arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetSamplerParameterIuiv", (void*)glGetSamplerParameterIuiv, 3, arg0, arg1, arg2); - glad_glGetSamplerParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetSamplerParameterIuiv", (void*)glGetSamplerParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetSamplerParameterIuiv(GLuint arg0, GLenum arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetSamplerParameterIuiv", (void *) glGetSamplerParameterIuiv, 3, arg0, arg1, arg2); + glad_glGetSamplerParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetSamplerParameterIuiv", (void *) glGetSamplerParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLGETSAMPLERPARAMETERIUIVPROC glad_debug_glGetSamplerParameterIuiv = glad_debug_impl_glGetSamplerParameterIuiv; PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv; -void APIENTRY glad_debug_impl_glGetSamplerParameterfv(GLuint arg0, GLenum arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetSamplerParameterfv", (void*)glGetSamplerParameterfv, 3, arg0, arg1, arg2); - glad_glGetSamplerParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetSamplerParameterfv", (void*)glGetSamplerParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetSamplerParameterfv(GLuint arg0, GLenum arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetSamplerParameterfv", (void *) glGetSamplerParameterfv, 3, arg0, arg1, arg2); + glad_glGetSamplerParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetSamplerParameterfv", (void *) glGetSamplerParameterfv, 3, arg0, arg1, arg2); + } + PFNGLGETSAMPLERPARAMETERFVPROC glad_debug_glGetSamplerParameterfv = glad_debug_impl_glGetSamplerParameterfv; PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv; -void APIENTRY glad_debug_impl_glGetSamplerParameteriv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetSamplerParameteriv", (void*)glGetSamplerParameteriv, 3, arg0, arg1, arg2); - glad_glGetSamplerParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetSamplerParameteriv", (void*)glGetSamplerParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetSamplerParameteriv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetSamplerParameteriv", (void *) glGetSamplerParameteriv, 3, arg0, arg1, arg2); + glad_glGetSamplerParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetSamplerParameteriv", (void *) glGetSamplerParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETSAMPLERPARAMETERIVPROC glad_debug_glGetSamplerParameteriv = glad_debug_impl_glGetSamplerParameteriv; PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog; -void APIENTRY glad_debug_impl_glGetShaderInfoLog(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLchar * arg3) { - _pre_call_callback_gl("glGetShaderInfoLog", (void*)glGetShaderInfoLog, 4, arg0, arg1, arg2, arg3); - glad_glGetShaderInfoLog(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetShaderInfoLog", (void*)glGetShaderInfoLog, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetShaderInfoLog(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLchar *arg3) { + _pre_call_callback_gl("glGetShaderInfoLog", (void *) glGetShaderInfoLog, 4, arg0, arg1, arg2, arg3); + glad_glGetShaderInfoLog(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetShaderInfoLog", (void *) glGetShaderInfoLog, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETSHADERINFOLOGPROC glad_debug_glGetShaderInfoLog = glad_debug_impl_glGetShaderInfoLog; PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat; -void APIENTRY glad_debug_impl_glGetShaderPrecisionFormat(GLenum arg0, GLenum arg1, GLint * arg2, GLint * arg3) { - _pre_call_callback_gl("glGetShaderPrecisionFormat", (void*)glGetShaderPrecisionFormat, 4, arg0, arg1, arg2, arg3); - glad_glGetShaderPrecisionFormat(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetShaderPrecisionFormat", (void*)glGetShaderPrecisionFormat, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetShaderPrecisionFormat(GLenum arg0, GLenum arg1, GLint *arg2, GLint *arg3) { + _pre_call_callback_gl("glGetShaderPrecisionFormat", (void *) glGetShaderPrecisionFormat, 4, arg0, arg1, arg2, arg3); + glad_glGetShaderPrecisionFormat(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetShaderPrecisionFormat", + (void *) glGetShaderPrecisionFormat, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETSHADERPRECISIONFORMATPROC glad_debug_glGetShaderPrecisionFormat = glad_debug_impl_glGetShaderPrecisionFormat; PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource; -void APIENTRY glad_debug_impl_glGetShaderSource(GLuint arg0, GLsizei arg1, GLsizei * arg2, GLchar * arg3) { - _pre_call_callback_gl("glGetShaderSource", (void*)glGetShaderSource, 4, arg0, arg1, arg2, arg3); - glad_glGetShaderSource(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetShaderSource", (void*)glGetShaderSource, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetShaderSource(GLuint arg0, GLsizei arg1, GLsizei *arg2, GLchar *arg3) { + _pre_call_callback_gl("glGetShaderSource", (void *) glGetShaderSource, 4, arg0, arg1, arg2, arg3); + glad_glGetShaderSource(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetShaderSource", (void *) glGetShaderSource, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETSHADERSOURCEPROC glad_debug_glGetShaderSource = glad_debug_impl_glGetShaderSource; PFNGLGETSHADERIVPROC glad_glGetShaderiv; -void APIENTRY glad_debug_impl_glGetShaderiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetShaderiv", (void*)glGetShaderiv, 3, arg0, arg1, arg2); - glad_glGetShaderiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetShaderiv", (void*)glGetShaderiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetShaderiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetShaderiv", (void *) glGetShaderiv, 3, arg0, arg1, arg2); + glad_glGetShaderiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetShaderiv", (void *) glGetShaderiv, 3, arg0, arg1, arg2); + } + PFNGLGETSHADERIVPROC glad_debug_glGetShaderiv = glad_debug_impl_glGetShaderiv; PFNGLGETSTRINGPROC glad_glGetString; -const GLubyte * APIENTRY glad_debug_impl_glGetString(GLenum arg0) { - const GLubyte * ret; - _pre_call_callback_gl("glGetString", (void*)glGetString, 1, arg0); - ret = glad_glGetString(arg0); - _post_call_callback_gl("glGetString", (void*)glGetString, 1, arg0); - return ret; + +const GLubyte *APIENTRY glad_debug_impl_glGetString(GLenum arg0) { + const GLubyte *ret; + _pre_call_callback_gl("glGetString", (void *) glGetString, 1, arg0); + ret = glad_glGetString(arg0); + _post_call_callback_gl("glGetString", (void *) glGetString, 1, arg0); + return ret; } + PFNGLGETSTRINGPROC glad_debug_glGetString = glad_debug_impl_glGetString; PFNGLGETSTRINGIPROC glad_glGetStringi; -const GLubyte * APIENTRY glad_debug_impl_glGetStringi(GLenum arg0, GLuint arg1) { - const GLubyte * ret; - _pre_call_callback_gl("glGetStringi", (void*)glGetStringi, 2, arg0, arg1); - ret = glad_glGetStringi(arg0, arg1); - _post_call_callback_gl("glGetStringi", (void*)glGetStringi, 2, arg0, arg1); - return ret; + +const GLubyte *APIENTRY glad_debug_impl_glGetStringi(GLenum arg0, GLuint arg1) { + const GLubyte *ret; + _pre_call_callback_gl("glGetStringi", (void *) glGetStringi, 2, arg0, arg1); + ret = glad_glGetStringi(arg0, arg1); + _post_call_callback_gl("glGetStringi", (void *) glGetStringi, 2, arg0, arg1); + return ret; } + PFNGLGETSTRINGIPROC glad_debug_glGetStringi = glad_debug_impl_glGetStringi; PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex; -GLuint APIENTRY glad_debug_impl_glGetSubroutineIndex(GLuint arg0, GLenum arg1, const GLchar * arg2) { - GLuint ret; - _pre_call_callback_gl("glGetSubroutineIndex", (void*)glGetSubroutineIndex, 3, arg0, arg1, arg2); - ret = glad_glGetSubroutineIndex(arg0, arg1, arg2); - _post_call_callback_gl("glGetSubroutineIndex", (void*)glGetSubroutineIndex, 3, arg0, arg1, arg2); - return ret; + +GLuint APIENTRY glad_debug_impl_glGetSubroutineIndex(GLuint arg0, GLenum arg1, const GLchar *arg2) { + GLuint ret; + _pre_call_callback_gl("glGetSubroutineIndex", (void *) glGetSubroutineIndex, 3, arg0, arg1, arg2); + ret = glad_glGetSubroutineIndex(arg0, arg1, arg2); + _post_call_callback_gl("glGetSubroutineIndex", (void *) glGetSubroutineIndex, 3, arg0, arg1, arg2); + return ret; } + PFNGLGETSUBROUTINEINDEXPROC glad_debug_glGetSubroutineIndex = glad_debug_impl_glGetSubroutineIndex; PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation; -GLint APIENTRY glad_debug_impl_glGetSubroutineUniformLocation(GLuint arg0, GLenum arg1, const GLchar * arg2) { - GLint ret; - _pre_call_callback_gl("glGetSubroutineUniformLocation", (void*)glGetSubroutineUniformLocation, 3, arg0, arg1, arg2); - ret = glad_glGetSubroutineUniformLocation(arg0, arg1, arg2); - _post_call_callback_gl("glGetSubroutineUniformLocation", (void*)glGetSubroutineUniformLocation, 3, arg0, arg1, arg2); - return ret; -} -PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_debug_glGetSubroutineUniformLocation = glad_debug_impl_glGetSubroutineUniformLocation; + +GLint APIENTRY glad_debug_impl_glGetSubroutineUniformLocation(GLuint arg0, GLenum arg1, const GLchar *arg2) { + GLint ret; + _pre_call_callback_gl("glGetSubroutineUniformLocation", + (void *) glGetSubroutineUniformLocation, + 3, + arg0, + arg1, + arg2); + ret = glad_glGetSubroutineUniformLocation(arg0, arg1, arg2); + _post_call_callback_gl("glGetSubroutineUniformLocation", + (void *) glGetSubroutineUniformLocation, + 3, + arg0, + arg1, + arg2); + return ret; +} + +PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC + glad_debug_glGetSubroutineUniformLocation = glad_debug_impl_glGetSubroutineUniformLocation; PFNGLGETSYNCIVPROC glad_glGetSynciv; -void APIENTRY glad_debug_impl_glGetSynciv(GLsync arg0, GLenum arg1, GLsizei arg2, GLsizei * arg3, GLint * arg4) { - _pre_call_callback_gl("glGetSynciv", (void*)glGetSynciv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetSynciv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetSynciv", (void*)glGetSynciv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetSynciv(GLsync arg0, GLenum arg1, GLsizei arg2, GLsizei *arg3, GLint *arg4) { + _pre_call_callback_gl("glGetSynciv", (void *) glGetSynciv, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetSynciv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetSynciv", (void *) glGetSynciv, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETSYNCIVPROC glad_debug_glGetSynciv = glad_debug_impl_glGetSynciv; PFNGLGETTEXIMAGEPROC glad_glGetTexImage; -void APIENTRY glad_debug_impl_glGetTexImage(GLenum arg0, GLint arg1, GLenum arg2, GLenum arg3, void * arg4) { - _pre_call_callback_gl("glGetTexImage", (void*)glGetTexImage, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetTexImage(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetTexImage", (void*)glGetTexImage, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetTexImage(GLenum arg0, GLint arg1, GLenum arg2, GLenum arg3, void *arg4) { + _pre_call_callback_gl("glGetTexImage", (void *) glGetTexImage, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetTexImage(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetTexImage", (void *) glGetTexImage, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETTEXIMAGEPROC glad_debug_glGetTexImage = glad_debug_impl_glGetTexImage; PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv; -void APIENTRY glad_debug_impl_glGetTexLevelParameterfv(GLenum arg0, GLint arg1, GLenum arg2, GLfloat * arg3) { - _pre_call_callback_gl("glGetTexLevelParameterfv", (void*)glGetTexLevelParameterfv, 4, arg0, arg1, arg2, arg3); - glad_glGetTexLevelParameterfv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTexLevelParameterfv", (void*)glGetTexLevelParameterfv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTexLevelParameterfv(GLenum arg0, GLint arg1, GLenum arg2, GLfloat *arg3) { + _pre_call_callback_gl("glGetTexLevelParameterfv", (void *) glGetTexLevelParameterfv, 4, arg0, arg1, arg2, arg3); + glad_glGetTexLevelParameterfv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTexLevelParameterfv", (void *) glGetTexLevelParameterfv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETTEXLEVELPARAMETERFVPROC glad_debug_glGetTexLevelParameterfv = glad_debug_impl_glGetTexLevelParameterfv; PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv; -void APIENTRY glad_debug_impl_glGetTexLevelParameteriv(GLenum arg0, GLint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetTexLevelParameteriv", (void*)glGetTexLevelParameteriv, 4, arg0, arg1, arg2, arg3); - glad_glGetTexLevelParameteriv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTexLevelParameteriv", (void*)glGetTexLevelParameteriv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTexLevelParameteriv(GLenum arg0, GLint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetTexLevelParameteriv", (void *) glGetTexLevelParameteriv, 4, arg0, arg1, arg2, arg3); + glad_glGetTexLevelParameteriv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTexLevelParameteriv", (void *) glGetTexLevelParameteriv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETTEXLEVELPARAMETERIVPROC glad_debug_glGetTexLevelParameteriv = glad_debug_impl_glGetTexLevelParameteriv; PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv; -void APIENTRY glad_debug_impl_glGetTexParameterIiv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetTexParameterIiv", (void*)glGetTexParameterIiv, 3, arg0, arg1, arg2); - glad_glGetTexParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTexParameterIiv", (void*)glGetTexParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTexParameterIiv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetTexParameterIiv", (void *) glGetTexParameterIiv, 3, arg0, arg1, arg2); + glad_glGetTexParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTexParameterIiv", (void *) glGetTexParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXPARAMETERIIVPROC glad_debug_glGetTexParameterIiv = glad_debug_impl_glGetTexParameterIiv; PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv; -void APIENTRY glad_debug_impl_glGetTexParameterIuiv(GLenum arg0, GLenum arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetTexParameterIuiv", (void*)glGetTexParameterIuiv, 3, arg0, arg1, arg2); - glad_glGetTexParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTexParameterIuiv", (void*)glGetTexParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTexParameterIuiv(GLenum arg0, GLenum arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetTexParameterIuiv", (void *) glGetTexParameterIuiv, 3, arg0, arg1, arg2); + glad_glGetTexParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTexParameterIuiv", (void *) glGetTexParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXPARAMETERIUIVPROC glad_debug_glGetTexParameterIuiv = glad_debug_impl_glGetTexParameterIuiv; PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv; -void APIENTRY glad_debug_impl_glGetTexParameterfv(GLenum arg0, GLenum arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetTexParameterfv", (void*)glGetTexParameterfv, 3, arg0, arg1, arg2); - glad_glGetTexParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTexParameterfv", (void*)glGetTexParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTexParameterfv(GLenum arg0, GLenum arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetTexParameterfv", (void *) glGetTexParameterfv, 3, arg0, arg1, arg2); + glad_glGetTexParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTexParameterfv", (void *) glGetTexParameterfv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXPARAMETERFVPROC glad_debug_glGetTexParameterfv = glad_debug_impl_glGetTexParameterfv; PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv; -void APIENTRY glad_debug_impl_glGetTexParameteriv(GLenum arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetTexParameteriv", (void*)glGetTexParameteriv, 3, arg0, arg1, arg2); - glad_glGetTexParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTexParameteriv", (void*)glGetTexParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTexParameteriv(GLenum arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetTexParameteriv", (void *) glGetTexParameteriv, 3, arg0, arg1, arg2); + glad_glGetTexParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTexParameteriv", (void *) glGetTexParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXPARAMETERIVPROC glad_debug_glGetTexParameteriv = glad_debug_impl_glGetTexParameteriv; PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage; -void APIENTRY glad_debug_impl_glGetTextureImage(GLuint arg0, GLint arg1, GLenum arg2, GLenum arg3, GLsizei arg4, void * arg5) { - _pre_call_callback_gl("glGetTextureImage", (void*)glGetTextureImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetTextureImage(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetTextureImage", (void*)glGetTextureImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetTextureImage(GLuint arg0, + GLint arg1, + GLenum arg2, + GLenum arg3, + GLsizei arg4, + void *arg5) { + _pre_call_callback_gl("glGetTextureImage", (void *) glGetTextureImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glGetTextureImage(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetTextureImage", (void *) glGetTextureImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLGETTEXTUREIMAGEPROC glad_debug_glGetTextureImage = glad_debug_impl_glGetTextureImage; PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv; -void APIENTRY glad_debug_impl_glGetTextureLevelParameterfv(GLuint arg0, GLint arg1, GLenum arg2, GLfloat * arg3) { - _pre_call_callback_gl("glGetTextureLevelParameterfv", (void*)glGetTextureLevelParameterfv, 4, arg0, arg1, arg2, arg3); - glad_glGetTextureLevelParameterfv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTextureLevelParameterfv", (void*)glGetTextureLevelParameterfv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTextureLevelParameterfv(GLuint arg0, GLint arg1, GLenum arg2, GLfloat *arg3) { + _pre_call_callback_gl("glGetTextureLevelParameterfv", + (void *) glGetTextureLevelParameterfv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetTextureLevelParameterfv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTextureLevelParameterfv", + (void *) glGetTextureLevelParameterfv, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_debug_glGetTextureLevelParameterfv = glad_debug_impl_glGetTextureLevelParameterfv; + +PFNGLGETTEXTURELEVELPARAMETERFVPROC + glad_debug_glGetTextureLevelParameterfv = glad_debug_impl_glGetTextureLevelParameterfv; PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv; -void APIENTRY glad_debug_impl_glGetTextureLevelParameteriv(GLuint arg0, GLint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetTextureLevelParameteriv", (void*)glGetTextureLevelParameteriv, 4, arg0, arg1, arg2, arg3); - glad_glGetTextureLevelParameteriv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTextureLevelParameteriv", (void*)glGetTextureLevelParameteriv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTextureLevelParameteriv(GLuint arg0, GLint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetTextureLevelParameteriv", + (void *) glGetTextureLevelParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetTextureLevelParameteriv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTextureLevelParameteriv", + (void *) glGetTextureLevelParameteriv, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_debug_glGetTextureLevelParameteriv = glad_debug_impl_glGetTextureLevelParameteriv; + +PFNGLGETTEXTURELEVELPARAMETERIVPROC + glad_debug_glGetTextureLevelParameteriv = glad_debug_impl_glGetTextureLevelParameteriv; PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv; -void APIENTRY glad_debug_impl_glGetTextureParameterIiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetTextureParameterIiv", (void*)glGetTextureParameterIiv, 3, arg0, arg1, arg2); - glad_glGetTextureParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTextureParameterIiv", (void*)glGetTextureParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTextureParameterIiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetTextureParameterIiv", (void *) glGetTextureParameterIiv, 3, arg0, arg1, arg2); + glad_glGetTextureParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTextureParameterIiv", (void *) glGetTextureParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXTUREPARAMETERIIVPROC glad_debug_glGetTextureParameterIiv = glad_debug_impl_glGetTextureParameterIiv; PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv; -void APIENTRY glad_debug_impl_glGetTextureParameterIuiv(GLuint arg0, GLenum arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetTextureParameterIuiv", (void*)glGetTextureParameterIuiv, 3, arg0, arg1, arg2); - glad_glGetTextureParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTextureParameterIuiv", (void*)glGetTextureParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTextureParameterIuiv(GLuint arg0, GLenum arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetTextureParameterIuiv", (void *) glGetTextureParameterIuiv, 3, arg0, arg1, arg2); + glad_glGetTextureParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTextureParameterIuiv", (void *) glGetTextureParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXTUREPARAMETERIUIVPROC glad_debug_glGetTextureParameterIuiv = glad_debug_impl_glGetTextureParameterIuiv; PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv; -void APIENTRY glad_debug_impl_glGetTextureParameterfv(GLuint arg0, GLenum arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetTextureParameterfv", (void*)glGetTextureParameterfv, 3, arg0, arg1, arg2); - glad_glGetTextureParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTextureParameterfv", (void*)glGetTextureParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTextureParameterfv(GLuint arg0, GLenum arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetTextureParameterfv", (void *) glGetTextureParameterfv, 3, arg0, arg1, arg2); + glad_glGetTextureParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTextureParameterfv", (void *) glGetTextureParameterfv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXTUREPARAMETERFVPROC glad_debug_glGetTextureParameterfv = glad_debug_impl_glGetTextureParameterfv; PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv; -void APIENTRY glad_debug_impl_glGetTextureParameteriv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetTextureParameteriv", (void*)glGetTextureParameteriv, 3, arg0, arg1, arg2); - glad_glGetTextureParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTextureParameteriv", (void*)glGetTextureParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTextureParameteriv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetTextureParameteriv", (void *) glGetTextureParameteriv, 3, arg0, arg1, arg2); + glad_glGetTextureParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTextureParameteriv", (void *) glGetTextureParameteriv, 3, arg0, arg1, arg2); + } + PFNGLGETTEXTUREPARAMETERIVPROC glad_debug_glGetTextureParameteriv = glad_debug_impl_glGetTextureParameteriv; PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage; -void APIENTRY glad_debug_impl_glGetTextureSubImage(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLenum arg9, GLsizei arg10, void * arg11) { - _pre_call_callback_gl("glGetTextureSubImage", (void*)glGetTextureSubImage, 12, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - glad_glGetTextureSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - _post_call_callback_gl("glGetTextureSubImage", (void*)glGetTextureSubImage, 12, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); - + +void APIENTRY glad_debug_impl_glGetTextureSubImage(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLenum arg9, + GLsizei arg10, + void *arg11) { + _pre_call_callback_gl("glGetTextureSubImage", + (void *) glGetTextureSubImage, + 12, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11); + glad_glGetTextureSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); + _post_call_callback_gl("glGetTextureSubImage", + (void *) glGetTextureSubImage, + 12, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11); + } + PFNGLGETTEXTURESUBIMAGEPROC glad_debug_glGetTextureSubImage = glad_debug_impl_glGetTextureSubImage; PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying; -void APIENTRY glad_debug_impl_glGetTransformFeedbackVarying(GLuint arg0, GLuint arg1, GLsizei arg2, GLsizei * arg3, GLsizei * arg4, GLenum * arg5, GLchar * arg6) { - _pre_call_callback_gl("glGetTransformFeedbackVarying", (void*)glGetTransformFeedbackVarying, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glGetTransformFeedbackVarying(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glGetTransformFeedbackVarying", (void*)glGetTransformFeedbackVarying, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glGetTransformFeedbackVarying(GLuint arg0, + GLuint arg1, + GLsizei arg2, + GLsizei *arg3, + GLsizei *arg4, + GLenum *arg5, + GLchar *arg6) { + _pre_call_callback_gl("glGetTransformFeedbackVarying", + (void *) glGetTransformFeedbackVarying, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glGetTransformFeedbackVarying(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glGetTransformFeedbackVarying", + (void *) glGetTransformFeedbackVarying, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_debug_glGetTransformFeedbackVarying = glad_debug_impl_glGetTransformFeedbackVarying; + +PFNGLGETTRANSFORMFEEDBACKVARYINGPROC + glad_debug_glGetTransformFeedbackVarying = glad_debug_impl_glGetTransformFeedbackVarying; PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v; -void APIENTRY glad_debug_impl_glGetTransformFeedbacki64_v(GLuint arg0, GLenum arg1, GLuint arg2, GLint64 * arg3) { - _pre_call_callback_gl("glGetTransformFeedbacki64_v", (void*)glGetTransformFeedbacki64_v, 4, arg0, arg1, arg2, arg3); - glad_glGetTransformFeedbacki64_v(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTransformFeedbacki64_v", (void*)glGetTransformFeedbacki64_v, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTransformFeedbacki64_v(GLuint arg0, GLenum arg1, GLuint arg2, GLint64 *arg3) { + _pre_call_callback_gl("glGetTransformFeedbacki64_v", + (void *) glGetTransformFeedbacki64_v, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetTransformFeedbacki64_v(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTransformFeedbacki64_v", + (void *) glGetTransformFeedbacki64_v, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_debug_glGetTransformFeedbacki64_v = glad_debug_impl_glGetTransformFeedbacki64_v; PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v; -void APIENTRY glad_debug_impl_glGetTransformFeedbacki_v(GLuint arg0, GLenum arg1, GLuint arg2, GLint * arg3) { - _pre_call_callback_gl("glGetTransformFeedbacki_v", (void*)glGetTransformFeedbacki_v, 4, arg0, arg1, arg2, arg3); - glad_glGetTransformFeedbacki_v(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetTransformFeedbacki_v", (void*)glGetTransformFeedbacki_v, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetTransformFeedbacki_v(GLuint arg0, GLenum arg1, GLuint arg2, GLint *arg3) { + _pre_call_callback_gl("glGetTransformFeedbacki_v", (void *) glGetTransformFeedbacki_v, 4, arg0, arg1, arg2, arg3); + glad_glGetTransformFeedbacki_v(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetTransformFeedbacki_v", (void *) glGetTransformFeedbacki_v, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_debug_glGetTransformFeedbacki_v = glad_debug_impl_glGetTransformFeedbacki_v; PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv; -void APIENTRY glad_debug_impl_glGetTransformFeedbackiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetTransformFeedbackiv", (void*)glGetTransformFeedbackiv, 3, arg0, arg1, arg2); - glad_glGetTransformFeedbackiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetTransformFeedbackiv", (void*)glGetTransformFeedbackiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetTransformFeedbackiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetTransformFeedbackiv", (void *) glGetTransformFeedbackiv, 3, arg0, arg1, arg2); + glad_glGetTransformFeedbackiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetTransformFeedbackiv", (void *) glGetTransformFeedbackiv, 3, arg0, arg1, arg2); + } + PFNGLGETTRANSFORMFEEDBACKIVPROC glad_debug_glGetTransformFeedbackiv = glad_debug_impl_glGetTransformFeedbackiv; PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex; -GLuint APIENTRY glad_debug_impl_glGetUniformBlockIndex(GLuint arg0, const GLchar * arg1) { - GLuint ret; - _pre_call_callback_gl("glGetUniformBlockIndex", (void*)glGetUniformBlockIndex, 2, arg0, arg1); - ret = glad_glGetUniformBlockIndex(arg0, arg1); - _post_call_callback_gl("glGetUniformBlockIndex", (void*)glGetUniformBlockIndex, 2, arg0, arg1); - return ret; + +GLuint APIENTRY glad_debug_impl_glGetUniformBlockIndex(GLuint arg0, const GLchar *arg1) { + GLuint ret; + _pre_call_callback_gl("glGetUniformBlockIndex", (void *) glGetUniformBlockIndex, 2, arg0, arg1); + ret = glad_glGetUniformBlockIndex(arg0, arg1); + _post_call_callback_gl("glGetUniformBlockIndex", (void *) glGetUniformBlockIndex, 2, arg0, arg1); + return ret; } + PFNGLGETUNIFORMBLOCKINDEXPROC glad_debug_glGetUniformBlockIndex = glad_debug_impl_glGetUniformBlockIndex; PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices; -void APIENTRY glad_debug_impl_glGetUniformIndices(GLuint arg0, GLsizei arg1, const GLchar *const* arg2, GLuint * arg3) { - _pre_call_callback_gl("glGetUniformIndices", (void*)glGetUniformIndices, 4, arg0, arg1, arg2, arg3); - glad_glGetUniformIndices(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetUniformIndices", (void*)glGetUniformIndices, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetUniformIndices(GLuint arg0, GLsizei arg1, const GLchar *const *arg2, GLuint *arg3) { + _pre_call_callback_gl("glGetUniformIndices", (void *) glGetUniformIndices, 4, arg0, arg1, arg2, arg3); + glad_glGetUniformIndices(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetUniformIndices", (void *) glGetUniformIndices, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETUNIFORMINDICESPROC glad_debug_glGetUniformIndices = glad_debug_impl_glGetUniformIndices; PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation; -GLint APIENTRY glad_debug_impl_glGetUniformLocation(GLuint arg0, const GLchar * arg1) { - GLint ret; - _pre_call_callback_gl("glGetUniformLocation", (void*)glGetUniformLocation, 2, arg0, arg1); - ret = glad_glGetUniformLocation(arg0, arg1); - _post_call_callback_gl("glGetUniformLocation", (void*)glGetUniformLocation, 2, arg0, arg1); - return ret; + +GLint APIENTRY glad_debug_impl_glGetUniformLocation(GLuint arg0, const GLchar *arg1) { + GLint ret; + _pre_call_callback_gl("glGetUniformLocation", (void *) glGetUniformLocation, 2, arg0, arg1); + ret = glad_glGetUniformLocation(arg0, arg1); + _post_call_callback_gl("glGetUniformLocation", (void *) glGetUniformLocation, 2, arg0, arg1); + return ret; } + PFNGLGETUNIFORMLOCATIONPROC glad_debug_glGetUniformLocation = glad_debug_impl_glGetUniformLocation; PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv; -void APIENTRY glad_debug_impl_glGetUniformSubroutineuiv(GLenum arg0, GLint arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetUniformSubroutineuiv", (void*)glGetUniformSubroutineuiv, 3, arg0, arg1, arg2); - glad_glGetUniformSubroutineuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetUniformSubroutineuiv", (void*)glGetUniformSubroutineuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetUniformSubroutineuiv(GLenum arg0, GLint arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetUniformSubroutineuiv", (void *) glGetUniformSubroutineuiv, 3, arg0, arg1, arg2); + glad_glGetUniformSubroutineuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetUniformSubroutineuiv", (void *) glGetUniformSubroutineuiv, 3, arg0, arg1, arg2); + } + PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_debug_glGetUniformSubroutineuiv = glad_debug_impl_glGetUniformSubroutineuiv; PFNGLGETUNIFORMDVPROC glad_glGetUniformdv; -void APIENTRY glad_debug_impl_glGetUniformdv(GLuint arg0, GLint arg1, GLdouble * arg2) { - _pre_call_callback_gl("glGetUniformdv", (void*)glGetUniformdv, 3, arg0, arg1, arg2); - glad_glGetUniformdv(arg0, arg1, arg2); - _post_call_callback_gl("glGetUniformdv", (void*)glGetUniformdv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetUniformdv(GLuint arg0, GLint arg1, GLdouble *arg2) { + _pre_call_callback_gl("glGetUniformdv", (void *) glGetUniformdv, 3, arg0, arg1, arg2); + glad_glGetUniformdv(arg0, arg1, arg2); + _post_call_callback_gl("glGetUniformdv", (void *) glGetUniformdv, 3, arg0, arg1, arg2); + } + PFNGLGETUNIFORMDVPROC glad_debug_glGetUniformdv = glad_debug_impl_glGetUniformdv; PFNGLGETUNIFORMFVPROC glad_glGetUniformfv; -void APIENTRY glad_debug_impl_glGetUniformfv(GLuint arg0, GLint arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetUniformfv", (void*)glGetUniformfv, 3, arg0, arg1, arg2); - glad_glGetUniformfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetUniformfv", (void*)glGetUniformfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetUniformfv(GLuint arg0, GLint arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetUniformfv", (void *) glGetUniformfv, 3, arg0, arg1, arg2); + glad_glGetUniformfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetUniformfv", (void *) glGetUniformfv, 3, arg0, arg1, arg2); + } + PFNGLGETUNIFORMFVPROC glad_debug_glGetUniformfv = glad_debug_impl_glGetUniformfv; PFNGLGETUNIFORMIVPROC glad_glGetUniformiv; -void APIENTRY glad_debug_impl_glGetUniformiv(GLuint arg0, GLint arg1, GLint * arg2) { - _pre_call_callback_gl("glGetUniformiv", (void*)glGetUniformiv, 3, arg0, arg1, arg2); - glad_glGetUniformiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetUniformiv", (void*)glGetUniformiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetUniformiv(GLuint arg0, GLint arg1, GLint *arg2) { + _pre_call_callback_gl("glGetUniformiv", (void *) glGetUniformiv, 3, arg0, arg1, arg2); + glad_glGetUniformiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetUniformiv", (void *) glGetUniformiv, 3, arg0, arg1, arg2); + } + PFNGLGETUNIFORMIVPROC glad_debug_glGetUniformiv = glad_debug_impl_glGetUniformiv; PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv; -void APIENTRY glad_debug_impl_glGetUniformuiv(GLuint arg0, GLint arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetUniformuiv", (void*)glGetUniformuiv, 3, arg0, arg1, arg2); - glad_glGetUniformuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetUniformuiv", (void*)glGetUniformuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetUniformuiv(GLuint arg0, GLint arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetUniformuiv", (void *) glGetUniformuiv, 3, arg0, arg1, arg2); + glad_glGetUniformuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetUniformuiv", (void *) glGetUniformuiv, 3, arg0, arg1, arg2); + } + PFNGLGETUNIFORMUIVPROC glad_debug_glGetUniformuiv = glad_debug_impl_glGetUniformuiv; PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv; -void APIENTRY glad_debug_impl_glGetVertexArrayIndexed64iv(GLuint arg0, GLuint arg1, GLenum arg2, GLint64 * arg3) { - _pre_call_callback_gl("glGetVertexArrayIndexed64iv", (void*)glGetVertexArrayIndexed64iv, 4, arg0, arg1, arg2, arg3); - glad_glGetVertexArrayIndexed64iv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetVertexArrayIndexed64iv", (void*)glGetVertexArrayIndexed64iv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetVertexArrayIndexed64iv(GLuint arg0, GLuint arg1, GLenum arg2, GLint64 *arg3) { + _pre_call_callback_gl("glGetVertexArrayIndexed64iv", + (void *) glGetVertexArrayIndexed64iv, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glGetVertexArrayIndexed64iv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetVertexArrayIndexed64iv", + (void *) glGetVertexArrayIndexed64iv, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_debug_glGetVertexArrayIndexed64iv = glad_debug_impl_glGetVertexArrayIndexed64iv; PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv; -void APIENTRY glad_debug_impl_glGetVertexArrayIndexediv(GLuint arg0, GLuint arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetVertexArrayIndexediv", (void*)glGetVertexArrayIndexediv, 4, arg0, arg1, arg2, arg3); - glad_glGetVertexArrayIndexediv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetVertexArrayIndexediv", (void*)glGetVertexArrayIndexediv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetVertexArrayIndexediv(GLuint arg0, GLuint arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetVertexArrayIndexediv", (void *) glGetVertexArrayIndexediv, 4, arg0, arg1, arg2, arg3); + glad_glGetVertexArrayIndexediv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetVertexArrayIndexediv", (void *) glGetVertexArrayIndexediv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_debug_glGetVertexArrayIndexediv = glad_debug_impl_glGetVertexArrayIndexediv; PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv; -void APIENTRY glad_debug_impl_glGetVertexArrayiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetVertexArrayiv", (void*)glGetVertexArrayiv, 3, arg0, arg1, arg2); - glad_glGetVertexArrayiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexArrayiv", (void*)glGetVertexArrayiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexArrayiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetVertexArrayiv", (void *) glGetVertexArrayiv, 3, arg0, arg1, arg2); + glad_glGetVertexArrayiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexArrayiv", (void *) glGetVertexArrayiv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXARRAYIVPROC glad_debug_glGetVertexArrayiv = glad_debug_impl_glGetVertexArrayiv; PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv; -void APIENTRY glad_debug_impl_glGetVertexAttribIiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetVertexAttribIiv", (void*)glGetVertexAttribIiv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribIiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribIiv", (void*)glGetVertexAttribIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribIiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetVertexAttribIiv", (void *) glGetVertexAttribIiv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribIiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribIiv", (void *) glGetVertexAttribIiv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBIIVPROC glad_debug_glGetVertexAttribIiv = glad_debug_impl_glGetVertexAttribIiv; PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv; -void APIENTRY glad_debug_impl_glGetVertexAttribIuiv(GLuint arg0, GLenum arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetVertexAttribIuiv", (void*)glGetVertexAttribIuiv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribIuiv", (void*)glGetVertexAttribIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribIuiv(GLuint arg0, GLenum arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetVertexAttribIuiv", (void *) glGetVertexAttribIuiv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribIuiv", (void *) glGetVertexAttribIuiv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBIUIVPROC glad_debug_glGetVertexAttribIuiv = glad_debug_impl_glGetVertexAttribIuiv; PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv; -void APIENTRY glad_debug_impl_glGetVertexAttribLdv(GLuint arg0, GLenum arg1, GLdouble * arg2) { - _pre_call_callback_gl("glGetVertexAttribLdv", (void*)glGetVertexAttribLdv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribLdv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribLdv", (void*)glGetVertexAttribLdv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribLdv(GLuint arg0, GLenum arg1, GLdouble *arg2) { + _pre_call_callback_gl("glGetVertexAttribLdv", (void *) glGetVertexAttribLdv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribLdv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribLdv", (void *) glGetVertexAttribLdv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBLDVPROC glad_debug_glGetVertexAttribLdv = glad_debug_impl_glGetVertexAttribLdv; PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv; -void APIENTRY glad_debug_impl_glGetVertexAttribPointerv(GLuint arg0, GLenum arg1, void ** arg2) { - _pre_call_callback_gl("glGetVertexAttribPointerv", (void*)glGetVertexAttribPointerv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribPointerv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribPointerv", (void*)glGetVertexAttribPointerv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribPointerv(GLuint arg0, GLenum arg1, void **arg2) { + _pre_call_callback_gl("glGetVertexAttribPointerv", (void *) glGetVertexAttribPointerv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribPointerv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribPointerv", (void *) glGetVertexAttribPointerv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBPOINTERVPROC glad_debug_glGetVertexAttribPointerv = glad_debug_impl_glGetVertexAttribPointerv; PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv; -void APIENTRY glad_debug_impl_glGetVertexAttribdv(GLuint arg0, GLenum arg1, GLdouble * arg2) { - _pre_call_callback_gl("glGetVertexAttribdv", (void*)glGetVertexAttribdv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribdv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribdv", (void*)glGetVertexAttribdv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribdv(GLuint arg0, GLenum arg1, GLdouble *arg2) { + _pre_call_callback_gl("glGetVertexAttribdv", (void *) glGetVertexAttribdv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribdv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribdv", (void *) glGetVertexAttribdv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBDVPROC glad_debug_glGetVertexAttribdv = glad_debug_impl_glGetVertexAttribdv; PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv; -void APIENTRY glad_debug_impl_glGetVertexAttribfv(GLuint arg0, GLenum arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetVertexAttribfv", (void*)glGetVertexAttribfv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribfv", (void*)glGetVertexAttribfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribfv(GLuint arg0, GLenum arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetVertexAttribfv", (void *) glGetVertexAttribfv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribfv", (void *) glGetVertexAttribfv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBFVPROC glad_debug_glGetVertexAttribfv = glad_debug_impl_glGetVertexAttribfv; PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv; -void APIENTRY glad_debug_impl_glGetVertexAttribiv(GLuint arg0, GLenum arg1, GLint * arg2) { - _pre_call_callback_gl("glGetVertexAttribiv", (void*)glGetVertexAttribiv, 3, arg0, arg1, arg2); - glad_glGetVertexAttribiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetVertexAttribiv", (void*)glGetVertexAttribiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetVertexAttribiv(GLuint arg0, GLenum arg1, GLint *arg2) { + _pre_call_callback_gl("glGetVertexAttribiv", (void *) glGetVertexAttribiv, 3, arg0, arg1, arg2); + glad_glGetVertexAttribiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetVertexAttribiv", (void *) glGetVertexAttribiv, 3, arg0, arg1, arg2); + } + PFNGLGETVERTEXATTRIBIVPROC glad_debug_glGetVertexAttribiv = glad_debug_impl_glGetVertexAttribiv; PFNGLGETNCOLORTABLEPROC glad_glGetnColorTable; -void APIENTRY glad_debug_impl_glGetnColorTable(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, void * arg4) { - _pre_call_callback_gl("glGetnColorTable", (void*)glGetnColorTable, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetnColorTable(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetnColorTable", (void*)glGetnColorTable, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetnColorTable(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, void *arg4) { + _pre_call_callback_gl("glGetnColorTable", (void *) glGetnColorTable, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetnColorTable(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetnColorTable", (void *) glGetnColorTable, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETNCOLORTABLEPROC glad_debug_glGetnColorTable = glad_debug_impl_glGetnColorTable; PFNGLGETNCOMPRESSEDTEXIMAGEPROC glad_glGetnCompressedTexImage; -void APIENTRY glad_debug_impl_glGetnCompressedTexImage(GLenum arg0, GLint arg1, GLsizei arg2, void * arg3) { - _pre_call_callback_gl("glGetnCompressedTexImage", (void*)glGetnCompressedTexImage, 4, arg0, arg1, arg2, arg3); - glad_glGetnCompressedTexImage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnCompressedTexImage", (void*)glGetnCompressedTexImage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnCompressedTexImage(GLenum arg0, GLint arg1, GLsizei arg2, void *arg3) { + _pre_call_callback_gl("glGetnCompressedTexImage", (void *) glGetnCompressedTexImage, 4, arg0, arg1, arg2, arg3); + glad_glGetnCompressedTexImage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnCompressedTexImage", (void *) glGetnCompressedTexImage, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNCOMPRESSEDTEXIMAGEPROC glad_debug_glGetnCompressedTexImage = glad_debug_impl_glGetnCompressedTexImage; PFNGLGETNCONVOLUTIONFILTERPROC glad_glGetnConvolutionFilter; -void APIENTRY glad_debug_impl_glGetnConvolutionFilter(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, void * arg4) { - _pre_call_callback_gl("glGetnConvolutionFilter", (void*)glGetnConvolutionFilter, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetnConvolutionFilter(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetnConvolutionFilter", (void*)glGetnConvolutionFilter, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetnConvolutionFilter(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, void *arg4) { + _pre_call_callback_gl("glGetnConvolutionFilter", (void *) glGetnConvolutionFilter, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetnConvolutionFilter(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetnConvolutionFilter", + (void *) glGetnConvolutionFilter, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLGETNCONVOLUTIONFILTERPROC glad_debug_glGetnConvolutionFilter = glad_debug_impl_glGetnConvolutionFilter; PFNGLGETNHISTOGRAMPROC glad_glGetnHistogram; -void APIENTRY glad_debug_impl_glGetnHistogram(GLenum arg0, GLboolean arg1, GLenum arg2, GLenum arg3, GLsizei arg4, void * arg5) { - _pre_call_callback_gl("glGetnHistogram", (void*)glGetnHistogram, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetnHistogram(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetnHistogram", (void*)glGetnHistogram, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetnHistogram(GLenum arg0, + GLboolean arg1, + GLenum arg2, + GLenum arg3, + GLsizei arg4, + void *arg5) { + _pre_call_callback_gl("glGetnHistogram", (void *) glGetnHistogram, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glGetnHistogram(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetnHistogram", (void *) glGetnHistogram, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLGETNHISTOGRAMPROC glad_debug_glGetnHistogram = glad_debug_impl_glGetnHistogram; PFNGLGETNMAPDVPROC glad_glGetnMapdv; -void APIENTRY glad_debug_impl_glGetnMapdv(GLenum arg0, GLenum arg1, GLsizei arg2, GLdouble * arg3) { - _pre_call_callback_gl("glGetnMapdv", (void*)glGetnMapdv, 4, arg0, arg1, arg2, arg3); - glad_glGetnMapdv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnMapdv", (void*)glGetnMapdv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnMapdv(GLenum arg0, GLenum arg1, GLsizei arg2, GLdouble *arg3) { + _pre_call_callback_gl("glGetnMapdv", (void *) glGetnMapdv, 4, arg0, arg1, arg2, arg3); + glad_glGetnMapdv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnMapdv", (void *) glGetnMapdv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNMAPDVPROC glad_debug_glGetnMapdv = glad_debug_impl_glGetnMapdv; PFNGLGETNMAPFVPROC glad_glGetnMapfv; -void APIENTRY glad_debug_impl_glGetnMapfv(GLenum arg0, GLenum arg1, GLsizei arg2, GLfloat * arg3) { - _pre_call_callback_gl("glGetnMapfv", (void*)glGetnMapfv, 4, arg0, arg1, arg2, arg3); - glad_glGetnMapfv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnMapfv", (void*)glGetnMapfv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnMapfv(GLenum arg0, GLenum arg1, GLsizei arg2, GLfloat *arg3) { + _pre_call_callback_gl("glGetnMapfv", (void *) glGetnMapfv, 4, arg0, arg1, arg2, arg3); + glad_glGetnMapfv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnMapfv", (void *) glGetnMapfv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNMAPFVPROC glad_debug_glGetnMapfv = glad_debug_impl_glGetnMapfv; PFNGLGETNMAPIVPROC glad_glGetnMapiv; -void APIENTRY glad_debug_impl_glGetnMapiv(GLenum arg0, GLenum arg1, GLsizei arg2, GLint * arg3) { - _pre_call_callback_gl("glGetnMapiv", (void*)glGetnMapiv, 4, arg0, arg1, arg2, arg3); - glad_glGetnMapiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnMapiv", (void*)glGetnMapiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnMapiv(GLenum arg0, GLenum arg1, GLsizei arg2, GLint *arg3) { + _pre_call_callback_gl("glGetnMapiv", (void *) glGetnMapiv, 4, arg0, arg1, arg2, arg3); + glad_glGetnMapiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnMapiv", (void *) glGetnMapiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNMAPIVPROC glad_debug_glGetnMapiv = glad_debug_impl_glGetnMapiv; PFNGLGETNMINMAXPROC glad_glGetnMinmax; -void APIENTRY glad_debug_impl_glGetnMinmax(GLenum arg0, GLboolean arg1, GLenum arg2, GLenum arg3, GLsizei arg4, void * arg5) { - _pre_call_callback_gl("glGetnMinmax", (void*)glGetnMinmax, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetnMinmax(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetnMinmax", (void*)glGetnMinmax, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetnMinmax(GLenum arg0, + GLboolean arg1, + GLenum arg2, + GLenum arg3, + GLsizei arg4, + void *arg5) { + _pre_call_callback_gl("glGetnMinmax", (void *) glGetnMinmax, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glGetnMinmax(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetnMinmax", (void *) glGetnMinmax, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLGETNMINMAXPROC glad_debug_glGetnMinmax = glad_debug_impl_glGetnMinmax; PFNGLGETNPIXELMAPFVPROC glad_glGetnPixelMapfv; -void APIENTRY glad_debug_impl_glGetnPixelMapfv(GLenum arg0, GLsizei arg1, GLfloat * arg2) { - _pre_call_callback_gl("glGetnPixelMapfv", (void*)glGetnPixelMapfv, 3, arg0, arg1, arg2); - glad_glGetnPixelMapfv(arg0, arg1, arg2); - _post_call_callback_gl("glGetnPixelMapfv", (void*)glGetnPixelMapfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetnPixelMapfv(GLenum arg0, GLsizei arg1, GLfloat *arg2) { + _pre_call_callback_gl("glGetnPixelMapfv", (void *) glGetnPixelMapfv, 3, arg0, arg1, arg2); + glad_glGetnPixelMapfv(arg0, arg1, arg2); + _post_call_callback_gl("glGetnPixelMapfv", (void *) glGetnPixelMapfv, 3, arg0, arg1, arg2); + } + PFNGLGETNPIXELMAPFVPROC glad_debug_glGetnPixelMapfv = glad_debug_impl_glGetnPixelMapfv; PFNGLGETNPIXELMAPUIVPROC glad_glGetnPixelMapuiv; -void APIENTRY glad_debug_impl_glGetnPixelMapuiv(GLenum arg0, GLsizei arg1, GLuint * arg2) { - _pre_call_callback_gl("glGetnPixelMapuiv", (void*)glGetnPixelMapuiv, 3, arg0, arg1, arg2); - glad_glGetnPixelMapuiv(arg0, arg1, arg2); - _post_call_callback_gl("glGetnPixelMapuiv", (void*)glGetnPixelMapuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetnPixelMapuiv(GLenum arg0, GLsizei arg1, GLuint *arg2) { + _pre_call_callback_gl("glGetnPixelMapuiv", (void *) glGetnPixelMapuiv, 3, arg0, arg1, arg2); + glad_glGetnPixelMapuiv(arg0, arg1, arg2); + _post_call_callback_gl("glGetnPixelMapuiv", (void *) glGetnPixelMapuiv, 3, arg0, arg1, arg2); + } + PFNGLGETNPIXELMAPUIVPROC glad_debug_glGetnPixelMapuiv = glad_debug_impl_glGetnPixelMapuiv; PFNGLGETNPIXELMAPUSVPROC glad_glGetnPixelMapusv; -void APIENTRY glad_debug_impl_glGetnPixelMapusv(GLenum arg0, GLsizei arg1, GLushort * arg2) { - _pre_call_callback_gl("glGetnPixelMapusv", (void*)glGetnPixelMapusv, 3, arg0, arg1, arg2); - glad_glGetnPixelMapusv(arg0, arg1, arg2); - _post_call_callback_gl("glGetnPixelMapusv", (void*)glGetnPixelMapusv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glGetnPixelMapusv(GLenum arg0, GLsizei arg1, GLushort *arg2) { + _pre_call_callback_gl("glGetnPixelMapusv", (void *) glGetnPixelMapusv, 3, arg0, arg1, arg2); + glad_glGetnPixelMapusv(arg0, arg1, arg2); + _post_call_callback_gl("glGetnPixelMapusv", (void *) glGetnPixelMapusv, 3, arg0, arg1, arg2); + } + PFNGLGETNPIXELMAPUSVPROC glad_debug_glGetnPixelMapusv = glad_debug_impl_glGetnPixelMapusv; PFNGLGETNPOLYGONSTIPPLEPROC glad_glGetnPolygonStipple; -void APIENTRY glad_debug_impl_glGetnPolygonStipple(GLsizei arg0, GLubyte * arg1) { - _pre_call_callback_gl("glGetnPolygonStipple", (void*)glGetnPolygonStipple, 2, arg0, arg1); - glad_glGetnPolygonStipple(arg0, arg1); - _post_call_callback_gl("glGetnPolygonStipple", (void*)glGetnPolygonStipple, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glGetnPolygonStipple(GLsizei arg0, GLubyte *arg1) { + _pre_call_callback_gl("glGetnPolygonStipple", (void *) glGetnPolygonStipple, 2, arg0, arg1); + glad_glGetnPolygonStipple(arg0, arg1); + _post_call_callback_gl("glGetnPolygonStipple", (void *) glGetnPolygonStipple, 2, arg0, arg1); + } + PFNGLGETNPOLYGONSTIPPLEPROC glad_debug_glGetnPolygonStipple = glad_debug_impl_glGetnPolygonStipple; PFNGLGETNSEPARABLEFILTERPROC glad_glGetnSeparableFilter; -void APIENTRY glad_debug_impl_glGetnSeparableFilter(GLenum arg0, GLenum arg1, GLenum arg2, GLsizei arg3, void * arg4, GLsizei arg5, void * arg6, void * arg7) { - _pre_call_callback_gl("glGetnSeparableFilter", (void*)glGetnSeparableFilter, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glGetnSeparableFilter(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glGetnSeparableFilter", (void*)glGetnSeparableFilter, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glGetnSeparableFilter(GLenum arg0, + GLenum arg1, + GLenum arg2, + GLsizei arg3, + void *arg4, + GLsizei arg5, + void *arg6, + void *arg7) { + _pre_call_callback_gl("glGetnSeparableFilter", + (void *) glGetnSeparableFilter, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glGetnSeparableFilter(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glGetnSeparableFilter", + (void *) glGetnSeparableFilter, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLGETNSEPARABLEFILTERPROC glad_debug_glGetnSeparableFilter = glad_debug_impl_glGetnSeparableFilter; PFNGLGETNTEXIMAGEPROC glad_glGetnTexImage; -void APIENTRY glad_debug_impl_glGetnTexImage(GLenum arg0, GLint arg1, GLenum arg2, GLenum arg3, GLsizei arg4, void * arg5) { - _pre_call_callback_gl("glGetnTexImage", (void*)glGetnTexImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glGetnTexImage(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glGetnTexImage", (void*)glGetnTexImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glGetnTexImage(GLenum arg0, + GLint arg1, + GLenum arg2, + GLenum arg3, + GLsizei arg4, + void *arg5) { + _pre_call_callback_gl("glGetnTexImage", (void *) glGetnTexImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glGetnTexImage(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glGetnTexImage", (void *) glGetnTexImage, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLGETNTEXIMAGEPROC glad_debug_glGetnTexImage = glad_debug_impl_glGetnTexImage; PFNGLGETNUNIFORMDVPROC glad_glGetnUniformdv; -void APIENTRY glad_debug_impl_glGetnUniformdv(GLuint arg0, GLint arg1, GLsizei arg2, GLdouble * arg3) { - _pre_call_callback_gl("glGetnUniformdv", (void*)glGetnUniformdv, 4, arg0, arg1, arg2, arg3); - glad_glGetnUniformdv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnUniformdv", (void*)glGetnUniformdv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnUniformdv(GLuint arg0, GLint arg1, GLsizei arg2, GLdouble *arg3) { + _pre_call_callback_gl("glGetnUniformdv", (void *) glGetnUniformdv, 4, arg0, arg1, arg2, arg3); + glad_glGetnUniformdv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnUniformdv", (void *) glGetnUniformdv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNUNIFORMDVPROC glad_debug_glGetnUniformdv = glad_debug_impl_glGetnUniformdv; PFNGLGETNUNIFORMFVPROC glad_glGetnUniformfv; -void APIENTRY glad_debug_impl_glGetnUniformfv(GLuint arg0, GLint arg1, GLsizei arg2, GLfloat * arg3) { - _pre_call_callback_gl("glGetnUniformfv", (void*)glGetnUniformfv, 4, arg0, arg1, arg2, arg3); - glad_glGetnUniformfv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnUniformfv", (void*)glGetnUniformfv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnUniformfv(GLuint arg0, GLint arg1, GLsizei arg2, GLfloat *arg3) { + _pre_call_callback_gl("glGetnUniformfv", (void *) glGetnUniformfv, 4, arg0, arg1, arg2, arg3); + glad_glGetnUniformfv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnUniformfv", (void *) glGetnUniformfv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNUNIFORMFVPROC glad_debug_glGetnUniformfv = glad_debug_impl_glGetnUniformfv; PFNGLGETNUNIFORMIVPROC glad_glGetnUniformiv; -void APIENTRY glad_debug_impl_glGetnUniformiv(GLuint arg0, GLint arg1, GLsizei arg2, GLint * arg3) { - _pre_call_callback_gl("glGetnUniformiv", (void*)glGetnUniformiv, 4, arg0, arg1, arg2, arg3); - glad_glGetnUniformiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnUniformiv", (void*)glGetnUniformiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnUniformiv(GLuint arg0, GLint arg1, GLsizei arg2, GLint *arg3) { + _pre_call_callback_gl("glGetnUniformiv", (void *) glGetnUniformiv, 4, arg0, arg1, arg2, arg3); + glad_glGetnUniformiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnUniformiv", (void *) glGetnUniformiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNUNIFORMIVPROC glad_debug_glGetnUniformiv = glad_debug_impl_glGetnUniformiv; PFNGLGETNUNIFORMUIVPROC glad_glGetnUniformuiv; -void APIENTRY glad_debug_impl_glGetnUniformuiv(GLuint arg0, GLint arg1, GLsizei arg2, GLuint * arg3) { - _pre_call_callback_gl("glGetnUniformuiv", (void*)glGetnUniformuiv, 4, arg0, arg1, arg2, arg3); - glad_glGetnUniformuiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetnUniformuiv", (void*)glGetnUniformuiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetnUniformuiv(GLuint arg0, GLint arg1, GLsizei arg2, GLuint *arg3) { + _pre_call_callback_gl("glGetnUniformuiv", (void *) glGetnUniformuiv, 4, arg0, arg1, arg2, arg3); + glad_glGetnUniformuiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetnUniformuiv", (void *) glGetnUniformuiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNUNIFORMUIVPROC glad_debug_glGetnUniformuiv = glad_debug_impl_glGetnUniformuiv; PFNGLHINTPROC glad_glHint; -void APIENTRY glad_debug_impl_glHint(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glHint", (void*)glHint, 2, arg0, arg1); - glad_glHint(arg0, arg1); - _post_call_callback_gl("glHint", (void*)glHint, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glHint(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glHint", (void *) glHint, 2, arg0, arg1); + glad_glHint(arg0, arg1); + _post_call_callback_gl("glHint", (void *) glHint, 2, arg0, arg1); + } + PFNGLHINTPROC glad_debug_glHint = glad_debug_impl_glHint; PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData; -void APIENTRY glad_debug_impl_glInvalidateBufferData(GLuint arg0) { - _pre_call_callback_gl("glInvalidateBufferData", (void*)glInvalidateBufferData, 1, arg0); - glad_glInvalidateBufferData(arg0); - _post_call_callback_gl("glInvalidateBufferData", (void*)glInvalidateBufferData, 1, arg0); - + +void APIENTRY glad_debug_impl_glInvalidateBufferData(GLuint arg0) { + _pre_call_callback_gl("glInvalidateBufferData", (void *) glInvalidateBufferData, 1, arg0); + glad_glInvalidateBufferData(arg0); + _post_call_callback_gl("glInvalidateBufferData", (void *) glInvalidateBufferData, 1, arg0); + } + PFNGLINVALIDATEBUFFERDATAPROC glad_debug_glInvalidateBufferData = glad_debug_impl_glInvalidateBufferData; PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData; -void APIENTRY glad_debug_impl_glInvalidateBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2) { - _pre_call_callback_gl("glInvalidateBufferSubData", (void*)glInvalidateBufferSubData, 3, arg0, arg1, arg2); - glad_glInvalidateBufferSubData(arg0, arg1, arg2); - _post_call_callback_gl("glInvalidateBufferSubData", (void*)glInvalidateBufferSubData, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glInvalidateBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2) { + _pre_call_callback_gl("glInvalidateBufferSubData", (void *) glInvalidateBufferSubData, 3, arg0, arg1, arg2); + glad_glInvalidateBufferSubData(arg0, arg1, arg2); + _post_call_callback_gl("glInvalidateBufferSubData", (void *) glInvalidateBufferSubData, 3, arg0, arg1, arg2); + } + PFNGLINVALIDATEBUFFERSUBDATAPROC glad_debug_glInvalidateBufferSubData = glad_debug_impl_glInvalidateBufferSubData; PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer; -void APIENTRY glad_debug_impl_glInvalidateFramebuffer(GLenum arg0, GLsizei arg1, const GLenum * arg2) { - _pre_call_callback_gl("glInvalidateFramebuffer", (void*)glInvalidateFramebuffer, 3, arg0, arg1, arg2); - glad_glInvalidateFramebuffer(arg0, arg1, arg2); - _post_call_callback_gl("glInvalidateFramebuffer", (void*)glInvalidateFramebuffer, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glInvalidateFramebuffer(GLenum arg0, GLsizei arg1, const GLenum *arg2) { + _pre_call_callback_gl("glInvalidateFramebuffer", (void *) glInvalidateFramebuffer, 3, arg0, arg1, arg2); + glad_glInvalidateFramebuffer(arg0, arg1, arg2); + _post_call_callback_gl("glInvalidateFramebuffer", (void *) glInvalidateFramebuffer, 3, arg0, arg1, arg2); + } + PFNGLINVALIDATEFRAMEBUFFERPROC glad_debug_glInvalidateFramebuffer = glad_debug_impl_glInvalidateFramebuffer; PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData; -void APIENTRY glad_debug_impl_glInvalidateNamedFramebufferData(GLuint arg0, GLsizei arg1, const GLenum * arg2) { - _pre_call_callback_gl("glInvalidateNamedFramebufferData", (void*)glInvalidateNamedFramebufferData, 3, arg0, arg1, arg2); - glad_glInvalidateNamedFramebufferData(arg0, arg1, arg2); - _post_call_callback_gl("glInvalidateNamedFramebufferData", (void*)glInvalidateNamedFramebufferData, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glInvalidateNamedFramebufferData(GLuint arg0, GLsizei arg1, const GLenum *arg2) { + _pre_call_callback_gl("glInvalidateNamedFramebufferData", + (void *) glInvalidateNamedFramebufferData, + 3, + arg0, + arg1, + arg2); + glad_glInvalidateNamedFramebufferData(arg0, arg1, arg2); + _post_call_callback_gl("glInvalidateNamedFramebufferData", + (void *) glInvalidateNamedFramebufferData, + 3, + arg0, + arg1, + arg2); + } -PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_debug_glInvalidateNamedFramebufferData = glad_debug_impl_glInvalidateNamedFramebufferData; + +PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC + glad_debug_glInvalidateNamedFramebufferData = glad_debug_impl_glInvalidateNamedFramebufferData; PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData; -void APIENTRY glad_debug_impl_glInvalidateNamedFramebufferSubData(GLuint arg0, GLsizei arg1, const GLenum * arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6) { - _pre_call_callback_gl("glInvalidateNamedFramebufferSubData", (void*)glInvalidateNamedFramebufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glInvalidateNamedFramebufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glInvalidateNamedFramebufferSubData", (void*)glInvalidateNamedFramebufferSubData, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glInvalidateNamedFramebufferSubData(GLuint arg0, + GLsizei arg1, + const GLenum *arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6) { + _pre_call_callback_gl("glInvalidateNamedFramebufferSubData", + (void *) glInvalidateNamedFramebufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glInvalidateNamedFramebufferSubData(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glInvalidateNamedFramebufferSubData", + (void *) glInvalidateNamedFramebufferSubData, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_debug_glInvalidateNamedFramebufferSubData = glad_debug_impl_glInvalidateNamedFramebufferSubData; + +PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC + glad_debug_glInvalidateNamedFramebufferSubData = glad_debug_impl_glInvalidateNamedFramebufferSubData; PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer; -void APIENTRY glad_debug_impl_glInvalidateSubFramebuffer(GLenum arg0, GLsizei arg1, const GLenum * arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6) { - _pre_call_callback_gl("glInvalidateSubFramebuffer", (void*)glInvalidateSubFramebuffer, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glInvalidateSubFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glInvalidateSubFramebuffer", (void*)glInvalidateSubFramebuffer, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glInvalidateSubFramebuffer(GLenum arg0, + GLsizei arg1, + const GLenum *arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6) { + _pre_call_callback_gl("glInvalidateSubFramebuffer", + (void *) glInvalidateSubFramebuffer, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glInvalidateSubFramebuffer(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glInvalidateSubFramebuffer", + (void *) glInvalidateSubFramebuffer, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_debug_glInvalidateSubFramebuffer = glad_debug_impl_glInvalidateSubFramebuffer; PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage; -void APIENTRY glad_debug_impl_glInvalidateTexImage(GLuint arg0, GLint arg1) { - _pre_call_callback_gl("glInvalidateTexImage", (void*)glInvalidateTexImage, 2, arg0, arg1); - glad_glInvalidateTexImage(arg0, arg1); - _post_call_callback_gl("glInvalidateTexImage", (void*)glInvalidateTexImage, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glInvalidateTexImage(GLuint arg0, GLint arg1) { + _pre_call_callback_gl("glInvalidateTexImage", (void *) glInvalidateTexImage, 2, arg0, arg1); + glad_glInvalidateTexImage(arg0, arg1); + _post_call_callback_gl("glInvalidateTexImage", (void *) glInvalidateTexImage, 2, arg0, arg1); + } + PFNGLINVALIDATETEXIMAGEPROC glad_debug_glInvalidateTexImage = glad_debug_impl_glInvalidateTexImage; PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage; -void APIENTRY glad_debug_impl_glInvalidateTexSubImage(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7) { - _pre_call_callback_gl("glInvalidateTexSubImage", (void*)glInvalidateTexSubImage, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glInvalidateTexSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glInvalidateTexSubImage", (void*)glInvalidateTexSubImage, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glInvalidateTexSubImage(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7) { + _pre_call_callback_gl("glInvalidateTexSubImage", + (void *) glInvalidateTexSubImage, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + glad_glInvalidateTexSubImage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glInvalidateTexSubImage", + (void *) glInvalidateTexSubImage, + 8, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } + PFNGLINVALIDATETEXSUBIMAGEPROC glad_debug_glInvalidateTexSubImage = glad_debug_impl_glInvalidateTexSubImage; PFNGLISBUFFERPROC glad_glIsBuffer; -GLboolean APIENTRY glad_debug_impl_glIsBuffer(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsBuffer", (void*)glIsBuffer, 1, arg0); - ret = glad_glIsBuffer(arg0); - _post_call_callback_gl("glIsBuffer", (void*)glIsBuffer, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsBuffer(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsBuffer", (void *) glIsBuffer, 1, arg0); + ret = glad_glIsBuffer(arg0); + _post_call_callback_gl("glIsBuffer", (void *) glIsBuffer, 1, arg0); + return ret; } + PFNGLISBUFFERPROC glad_debug_glIsBuffer = glad_debug_impl_glIsBuffer; PFNGLISENABLEDPROC glad_glIsEnabled; -GLboolean APIENTRY glad_debug_impl_glIsEnabled(GLenum arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsEnabled", (void*)glIsEnabled, 1, arg0); - ret = glad_glIsEnabled(arg0); - _post_call_callback_gl("glIsEnabled", (void*)glIsEnabled, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsEnabled(GLenum arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsEnabled", (void *) glIsEnabled, 1, arg0); + ret = glad_glIsEnabled(arg0); + _post_call_callback_gl("glIsEnabled", (void *) glIsEnabled, 1, arg0); + return ret; } + PFNGLISENABLEDPROC glad_debug_glIsEnabled = glad_debug_impl_glIsEnabled; PFNGLISENABLEDIPROC glad_glIsEnabledi; -GLboolean APIENTRY glad_debug_impl_glIsEnabledi(GLenum arg0, GLuint arg1) { - GLboolean ret; - _pre_call_callback_gl("glIsEnabledi", (void*)glIsEnabledi, 2, arg0, arg1); - ret = glad_glIsEnabledi(arg0, arg1); - _post_call_callback_gl("glIsEnabledi", (void*)glIsEnabledi, 2, arg0, arg1); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsEnabledi(GLenum arg0, GLuint arg1) { + GLboolean ret; + _pre_call_callback_gl("glIsEnabledi", (void *) glIsEnabledi, 2, arg0, arg1); + ret = glad_glIsEnabledi(arg0, arg1); + _post_call_callback_gl("glIsEnabledi", (void *) glIsEnabledi, 2, arg0, arg1); + return ret; } + PFNGLISENABLEDIPROC glad_debug_glIsEnabledi = glad_debug_impl_glIsEnabledi; PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer; -GLboolean APIENTRY glad_debug_impl_glIsFramebuffer(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsFramebuffer", (void*)glIsFramebuffer, 1, arg0); - ret = glad_glIsFramebuffer(arg0); - _post_call_callback_gl("glIsFramebuffer", (void*)glIsFramebuffer, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsFramebuffer(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsFramebuffer", (void *) glIsFramebuffer, 1, arg0); + ret = glad_glIsFramebuffer(arg0); + _post_call_callback_gl("glIsFramebuffer", (void *) glIsFramebuffer, 1, arg0); + return ret; } + PFNGLISFRAMEBUFFERPROC glad_debug_glIsFramebuffer = glad_debug_impl_glIsFramebuffer; PFNGLISPROGRAMPROC glad_glIsProgram; -GLboolean APIENTRY glad_debug_impl_glIsProgram(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsProgram", (void*)glIsProgram, 1, arg0); - ret = glad_glIsProgram(arg0); - _post_call_callback_gl("glIsProgram", (void*)glIsProgram, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsProgram(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsProgram", (void *) glIsProgram, 1, arg0); + ret = glad_glIsProgram(arg0); + _post_call_callback_gl("glIsProgram", (void *) glIsProgram, 1, arg0); + return ret; } + PFNGLISPROGRAMPROC glad_debug_glIsProgram = glad_debug_impl_glIsProgram; PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline; -GLboolean APIENTRY glad_debug_impl_glIsProgramPipeline(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsProgramPipeline", (void*)glIsProgramPipeline, 1, arg0); - ret = glad_glIsProgramPipeline(arg0); - _post_call_callback_gl("glIsProgramPipeline", (void*)glIsProgramPipeline, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsProgramPipeline(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsProgramPipeline", (void *) glIsProgramPipeline, 1, arg0); + ret = glad_glIsProgramPipeline(arg0); + _post_call_callback_gl("glIsProgramPipeline", (void *) glIsProgramPipeline, 1, arg0); + return ret; } + PFNGLISPROGRAMPIPELINEPROC glad_debug_glIsProgramPipeline = glad_debug_impl_glIsProgramPipeline; PFNGLISQUERYPROC glad_glIsQuery; -GLboolean APIENTRY glad_debug_impl_glIsQuery(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsQuery", (void*)glIsQuery, 1, arg0); - ret = glad_glIsQuery(arg0); - _post_call_callback_gl("glIsQuery", (void*)glIsQuery, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsQuery(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsQuery", (void *) glIsQuery, 1, arg0); + ret = glad_glIsQuery(arg0); + _post_call_callback_gl("glIsQuery", (void *) glIsQuery, 1, arg0); + return ret; } + PFNGLISQUERYPROC glad_debug_glIsQuery = glad_debug_impl_glIsQuery; PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer; -GLboolean APIENTRY glad_debug_impl_glIsRenderbuffer(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsRenderbuffer", (void*)glIsRenderbuffer, 1, arg0); - ret = glad_glIsRenderbuffer(arg0); - _post_call_callback_gl("glIsRenderbuffer", (void*)glIsRenderbuffer, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsRenderbuffer(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsRenderbuffer", (void *) glIsRenderbuffer, 1, arg0); + ret = glad_glIsRenderbuffer(arg0); + _post_call_callback_gl("glIsRenderbuffer", (void *) glIsRenderbuffer, 1, arg0); + return ret; } + PFNGLISRENDERBUFFERPROC glad_debug_glIsRenderbuffer = glad_debug_impl_glIsRenderbuffer; PFNGLISSAMPLERPROC glad_glIsSampler; -GLboolean APIENTRY glad_debug_impl_glIsSampler(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsSampler", (void*)glIsSampler, 1, arg0); - ret = glad_glIsSampler(arg0); - _post_call_callback_gl("glIsSampler", (void*)glIsSampler, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsSampler(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsSampler", (void *) glIsSampler, 1, arg0); + ret = glad_glIsSampler(arg0); + _post_call_callback_gl("glIsSampler", (void *) glIsSampler, 1, arg0); + return ret; } + PFNGLISSAMPLERPROC glad_debug_glIsSampler = glad_debug_impl_glIsSampler; PFNGLISSHADERPROC glad_glIsShader; -GLboolean APIENTRY glad_debug_impl_glIsShader(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsShader", (void*)glIsShader, 1, arg0); - ret = glad_glIsShader(arg0); - _post_call_callback_gl("glIsShader", (void*)glIsShader, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsShader(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsShader", (void *) glIsShader, 1, arg0); + ret = glad_glIsShader(arg0); + _post_call_callback_gl("glIsShader", (void *) glIsShader, 1, arg0); + return ret; } + PFNGLISSHADERPROC glad_debug_glIsShader = glad_debug_impl_glIsShader; PFNGLISSYNCPROC glad_glIsSync; -GLboolean APIENTRY glad_debug_impl_glIsSync(GLsync arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsSync", (void*)glIsSync, 1, arg0); - ret = glad_glIsSync(arg0); - _post_call_callback_gl("glIsSync", (void*)glIsSync, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsSync(GLsync arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsSync", (void *) glIsSync, 1, arg0); + ret = glad_glIsSync(arg0); + _post_call_callback_gl("glIsSync", (void *) glIsSync, 1, arg0); + return ret; } + PFNGLISSYNCPROC glad_debug_glIsSync = glad_debug_impl_glIsSync; PFNGLISTEXTUREPROC glad_glIsTexture; -GLboolean APIENTRY glad_debug_impl_glIsTexture(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsTexture", (void*)glIsTexture, 1, arg0); - ret = glad_glIsTexture(arg0); - _post_call_callback_gl("glIsTexture", (void*)glIsTexture, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsTexture(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsTexture", (void *) glIsTexture, 1, arg0); + ret = glad_glIsTexture(arg0); + _post_call_callback_gl("glIsTexture", (void *) glIsTexture, 1, arg0); + return ret; } + PFNGLISTEXTUREPROC glad_debug_glIsTexture = glad_debug_impl_glIsTexture; PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback; -GLboolean APIENTRY glad_debug_impl_glIsTransformFeedback(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsTransformFeedback", (void*)glIsTransformFeedback, 1, arg0); - ret = glad_glIsTransformFeedback(arg0); - _post_call_callback_gl("glIsTransformFeedback", (void*)glIsTransformFeedback, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsTransformFeedback(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsTransformFeedback", (void *) glIsTransformFeedback, 1, arg0); + ret = glad_glIsTransformFeedback(arg0); + _post_call_callback_gl("glIsTransformFeedback", (void *) glIsTransformFeedback, 1, arg0); + return ret; } + PFNGLISTRANSFORMFEEDBACKPROC glad_debug_glIsTransformFeedback = glad_debug_impl_glIsTransformFeedback; PFNGLISVERTEXARRAYPROC glad_glIsVertexArray; -GLboolean APIENTRY glad_debug_impl_glIsVertexArray(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glIsVertexArray", (void*)glIsVertexArray, 1, arg0); - ret = glad_glIsVertexArray(arg0); - _post_call_callback_gl("glIsVertexArray", (void*)glIsVertexArray, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsVertexArray(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glIsVertexArray", (void *) glIsVertexArray, 1, arg0); + ret = glad_glIsVertexArray(arg0); + _post_call_callback_gl("glIsVertexArray", (void *) glIsVertexArray, 1, arg0); + return ret; } + PFNGLISVERTEXARRAYPROC glad_debug_glIsVertexArray = glad_debug_impl_glIsVertexArray; PFNGLLINEWIDTHPROC glad_glLineWidth; -void APIENTRY glad_debug_impl_glLineWidth(GLfloat arg0) { - _pre_call_callback_gl("glLineWidth", (void*)glLineWidth, 1, arg0); - glad_glLineWidth(arg0); - _post_call_callback_gl("glLineWidth", (void*)glLineWidth, 1, arg0); - + +void APIENTRY glad_debug_impl_glLineWidth(GLfloat arg0) { + _pre_call_callback_gl("glLineWidth", (void *) glLineWidth, 1, arg0); + glad_glLineWidth(arg0); + _post_call_callback_gl("glLineWidth", (void *) glLineWidth, 1, arg0); + } + PFNGLLINEWIDTHPROC glad_debug_glLineWidth = glad_debug_impl_glLineWidth; PFNGLLINKPROGRAMPROC glad_glLinkProgram; -void APIENTRY glad_debug_impl_glLinkProgram(GLuint arg0) { - _pre_call_callback_gl("glLinkProgram", (void*)glLinkProgram, 1, arg0); - glad_glLinkProgram(arg0); - _post_call_callback_gl("glLinkProgram", (void*)glLinkProgram, 1, arg0); - + +void APIENTRY glad_debug_impl_glLinkProgram(GLuint arg0) { + _pre_call_callback_gl("glLinkProgram", (void *) glLinkProgram, 1, arg0); + glad_glLinkProgram(arg0); + _post_call_callback_gl("glLinkProgram", (void *) glLinkProgram, 1, arg0); + } + PFNGLLINKPROGRAMPROC glad_debug_glLinkProgram = glad_debug_impl_glLinkProgram; PFNGLLOGICOPPROC glad_glLogicOp; -void APIENTRY glad_debug_impl_glLogicOp(GLenum arg0) { - _pre_call_callback_gl("glLogicOp", (void*)glLogicOp, 1, arg0); - glad_glLogicOp(arg0); - _post_call_callback_gl("glLogicOp", (void*)glLogicOp, 1, arg0); - + +void APIENTRY glad_debug_impl_glLogicOp(GLenum arg0) { + _pre_call_callback_gl("glLogicOp", (void *) glLogicOp, 1, arg0); + glad_glLogicOp(arg0); + _post_call_callback_gl("glLogicOp", (void *) glLogicOp, 1, arg0); + } + PFNGLLOGICOPPROC glad_debug_glLogicOp = glad_debug_impl_glLogicOp; PFNGLMAPBUFFERPROC glad_glMapBuffer; -void * APIENTRY glad_debug_impl_glMapBuffer(GLenum arg0, GLenum arg1) { - void * ret; - _pre_call_callback_gl("glMapBuffer", (void*)glMapBuffer, 2, arg0, arg1); - ret = glad_glMapBuffer(arg0, arg1); - _post_call_callback_gl("glMapBuffer", (void*)glMapBuffer, 2, arg0, arg1); - return ret; + +void *APIENTRY glad_debug_impl_glMapBuffer(GLenum arg0, GLenum arg1) { + void *ret; + _pre_call_callback_gl("glMapBuffer", (void *) glMapBuffer, 2, arg0, arg1); + ret = glad_glMapBuffer(arg0, arg1); + _post_call_callback_gl("glMapBuffer", (void *) glMapBuffer, 2, arg0, arg1); + return ret; } + PFNGLMAPBUFFERPROC glad_debug_glMapBuffer = glad_debug_impl_glMapBuffer; PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange; -void * APIENTRY glad_debug_impl_glMapBufferRange(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, GLbitfield arg3) { - void * ret; - _pre_call_callback_gl("glMapBufferRange", (void*)glMapBufferRange, 4, arg0, arg1, arg2, arg3); - ret = glad_glMapBufferRange(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glMapBufferRange", (void*)glMapBufferRange, 4, arg0, arg1, arg2, arg3); - return ret; + +void *APIENTRY glad_debug_impl_glMapBufferRange(GLenum arg0, GLintptr arg1, GLsizeiptr arg2, GLbitfield arg3) { + void *ret; + _pre_call_callback_gl("glMapBufferRange", (void *) glMapBufferRange, 4, arg0, arg1, arg2, arg3); + ret = glad_glMapBufferRange(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glMapBufferRange", (void *) glMapBufferRange, 4, arg0, arg1, arg2, arg3); + return ret; } + PFNGLMAPBUFFERRANGEPROC glad_debug_glMapBufferRange = glad_debug_impl_glMapBufferRange; PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer; -void * APIENTRY glad_debug_impl_glMapNamedBuffer(GLuint arg0, GLenum arg1) { - void * ret; - _pre_call_callback_gl("glMapNamedBuffer", (void*)glMapNamedBuffer, 2, arg0, arg1); - ret = glad_glMapNamedBuffer(arg0, arg1); - _post_call_callback_gl("glMapNamedBuffer", (void*)glMapNamedBuffer, 2, arg0, arg1); - return ret; + +void *APIENTRY glad_debug_impl_glMapNamedBuffer(GLuint arg0, GLenum arg1) { + void *ret; + _pre_call_callback_gl("glMapNamedBuffer", (void *) glMapNamedBuffer, 2, arg0, arg1); + ret = glad_glMapNamedBuffer(arg0, arg1); + _post_call_callback_gl("glMapNamedBuffer", (void *) glMapNamedBuffer, 2, arg0, arg1); + return ret; } + PFNGLMAPNAMEDBUFFERPROC glad_debug_glMapNamedBuffer = glad_debug_impl_glMapNamedBuffer; PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange; -void * APIENTRY glad_debug_impl_glMapNamedBufferRange(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, GLbitfield arg3) { - void * ret; - _pre_call_callback_gl("glMapNamedBufferRange", (void*)glMapNamedBufferRange, 4, arg0, arg1, arg2, arg3); - ret = glad_glMapNamedBufferRange(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glMapNamedBufferRange", (void*)glMapNamedBufferRange, 4, arg0, arg1, arg2, arg3); - return ret; + +void *APIENTRY glad_debug_impl_glMapNamedBufferRange(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, GLbitfield arg3) { + void *ret; + _pre_call_callback_gl("glMapNamedBufferRange", (void *) glMapNamedBufferRange, 4, arg0, arg1, arg2, arg3); + ret = glad_glMapNamedBufferRange(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glMapNamedBufferRange", (void *) glMapNamedBufferRange, 4, arg0, arg1, arg2, arg3); + return ret; } + PFNGLMAPNAMEDBUFFERRANGEPROC glad_debug_glMapNamedBufferRange = glad_debug_impl_glMapNamedBufferRange; PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier; -void APIENTRY glad_debug_impl_glMemoryBarrier(GLbitfield arg0) { - _pre_call_callback_gl("glMemoryBarrier", (void*)glMemoryBarrier, 1, arg0); - glad_glMemoryBarrier(arg0); - _post_call_callback_gl("glMemoryBarrier", (void*)glMemoryBarrier, 1, arg0); - + +void APIENTRY glad_debug_impl_glMemoryBarrier(GLbitfield arg0) { + _pre_call_callback_gl("glMemoryBarrier", (void *) glMemoryBarrier, 1, arg0); + glad_glMemoryBarrier(arg0); + _post_call_callback_gl("glMemoryBarrier", (void *) glMemoryBarrier, 1, arg0); + } + PFNGLMEMORYBARRIERPROC glad_debug_glMemoryBarrier = glad_debug_impl_glMemoryBarrier; PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion; -void APIENTRY glad_debug_impl_glMemoryBarrierByRegion(GLbitfield arg0) { - _pre_call_callback_gl("glMemoryBarrierByRegion", (void*)glMemoryBarrierByRegion, 1, arg0); - glad_glMemoryBarrierByRegion(arg0); - _post_call_callback_gl("glMemoryBarrierByRegion", (void*)glMemoryBarrierByRegion, 1, arg0); - + +void APIENTRY glad_debug_impl_glMemoryBarrierByRegion(GLbitfield arg0) { + _pre_call_callback_gl("glMemoryBarrierByRegion", (void *) glMemoryBarrierByRegion, 1, arg0); + glad_glMemoryBarrierByRegion(arg0); + _post_call_callback_gl("glMemoryBarrierByRegion", (void *) glMemoryBarrierByRegion, 1, arg0); + } + PFNGLMEMORYBARRIERBYREGIONPROC glad_debug_glMemoryBarrierByRegion = glad_debug_impl_glMemoryBarrierByRegion; PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading; -void APIENTRY glad_debug_impl_glMinSampleShading(GLfloat arg0) { - _pre_call_callback_gl("glMinSampleShading", (void*)glMinSampleShading, 1, arg0); - glad_glMinSampleShading(arg0); - _post_call_callback_gl("glMinSampleShading", (void*)glMinSampleShading, 1, arg0); - + +void APIENTRY glad_debug_impl_glMinSampleShading(GLfloat arg0) { + _pre_call_callback_gl("glMinSampleShading", (void *) glMinSampleShading, 1, arg0); + glad_glMinSampleShading(arg0); + _post_call_callback_gl("glMinSampleShading", (void *) glMinSampleShading, 1, arg0); + } + PFNGLMINSAMPLESHADINGPROC glad_debug_glMinSampleShading = glad_debug_impl_glMinSampleShading; PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays; -void APIENTRY glad_debug_impl_glMultiDrawArrays(GLenum arg0, const GLint * arg1, const GLsizei * arg2, GLsizei arg3) { - _pre_call_callback_gl("glMultiDrawArrays", (void*)glMultiDrawArrays, 4, arg0, arg1, arg2, arg3); - glad_glMultiDrawArrays(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glMultiDrawArrays", (void*)glMultiDrawArrays, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glMultiDrawArrays(GLenum arg0, const GLint *arg1, const GLsizei *arg2, GLsizei arg3) { + _pre_call_callback_gl("glMultiDrawArrays", (void *) glMultiDrawArrays, 4, arg0, arg1, arg2, arg3); + glad_glMultiDrawArrays(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glMultiDrawArrays", (void *) glMultiDrawArrays, 4, arg0, arg1, arg2, arg3); + } + PFNGLMULTIDRAWARRAYSPROC glad_debug_glMultiDrawArrays = glad_debug_impl_glMultiDrawArrays; PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect; -void APIENTRY glad_debug_impl_glMultiDrawArraysIndirect(GLenum arg0, const void * arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glMultiDrawArraysIndirect", (void*)glMultiDrawArraysIndirect, 4, arg0, arg1, arg2, arg3); - glad_glMultiDrawArraysIndirect(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glMultiDrawArraysIndirect", (void*)glMultiDrawArraysIndirect, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glMultiDrawArraysIndirect(GLenum arg0, const void *arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glMultiDrawArraysIndirect", (void *) glMultiDrawArraysIndirect, 4, arg0, arg1, arg2, arg3); + glad_glMultiDrawArraysIndirect(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glMultiDrawArraysIndirect", (void *) glMultiDrawArraysIndirect, 4, arg0, arg1, arg2, arg3); + } + PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_debug_glMultiDrawArraysIndirect = glad_debug_impl_glMultiDrawArraysIndirect; PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements; -void APIENTRY glad_debug_impl_glMultiDrawElements(GLenum arg0, const GLsizei * arg1, GLenum arg2, const void *const* arg3, GLsizei arg4) { - _pre_call_callback_gl("glMultiDrawElements", (void*)glMultiDrawElements, 5, arg0, arg1, arg2, arg3, arg4); - glad_glMultiDrawElements(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glMultiDrawElements", (void*)glMultiDrawElements, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glMultiDrawElements(GLenum arg0, + const GLsizei *arg1, + GLenum arg2, + const void *const *arg3, + GLsizei arg4) { + _pre_call_callback_gl("glMultiDrawElements", (void *) glMultiDrawElements, 5, arg0, arg1, arg2, arg3, arg4); + glad_glMultiDrawElements(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glMultiDrawElements", (void *) glMultiDrawElements, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLMULTIDRAWELEMENTSPROC glad_debug_glMultiDrawElements = glad_debug_impl_glMultiDrawElements; PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex; -void APIENTRY glad_debug_impl_glMultiDrawElementsBaseVertex(GLenum arg0, const GLsizei * arg1, GLenum arg2, const void *const* arg3, GLsizei arg4, const GLint * arg5) { - _pre_call_callback_gl("glMultiDrawElementsBaseVertex", (void*)glMultiDrawElementsBaseVertex, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glMultiDrawElementsBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glMultiDrawElementsBaseVertex", (void*)glMultiDrawElementsBaseVertex, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glMultiDrawElementsBaseVertex(GLenum arg0, + const GLsizei *arg1, + GLenum arg2, + const void *const *arg3, + GLsizei arg4, + const GLint *arg5) { + _pre_call_callback_gl("glMultiDrawElementsBaseVertex", + (void *) glMultiDrawElementsBaseVertex, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glMultiDrawElementsBaseVertex(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glMultiDrawElementsBaseVertex", + (void *) glMultiDrawElementsBaseVertex, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } -PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_debug_glMultiDrawElementsBaseVertex = glad_debug_impl_glMultiDrawElementsBaseVertex; + +PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC + glad_debug_glMultiDrawElementsBaseVertex = glad_debug_impl_glMultiDrawElementsBaseVertex; PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect; -void APIENTRY glad_debug_impl_glMultiDrawElementsIndirect(GLenum arg0, GLenum arg1, const void * arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glMultiDrawElementsIndirect", (void*)glMultiDrawElementsIndirect, 5, arg0, arg1, arg2, arg3, arg4); - glad_glMultiDrawElementsIndirect(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glMultiDrawElementsIndirect", (void*)glMultiDrawElementsIndirect, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glMultiDrawElementsIndirect(GLenum arg0, + GLenum arg1, + const void *arg2, + GLsizei arg3, + GLsizei arg4) { + _pre_call_callback_gl("glMultiDrawElementsIndirect", + (void *) glMultiDrawElementsIndirect, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glMultiDrawElementsIndirect(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glMultiDrawElementsIndirect", + (void *) glMultiDrawElementsIndirect, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_debug_glMultiDrawElementsIndirect = glad_debug_impl_glMultiDrawElementsIndirect; PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui; -void APIENTRY glad_debug_impl_glMultiTexCoordP1ui(GLenum arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glMultiTexCoordP1ui", (void*)glMultiTexCoordP1ui, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP1ui(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP1ui", (void*)glMultiTexCoordP1ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP1ui(GLenum arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glMultiTexCoordP1ui", (void *) glMultiTexCoordP1ui, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP1ui(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP1ui", (void *) glMultiTexCoordP1ui, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP1UIPROC glad_debug_glMultiTexCoordP1ui = glad_debug_impl_glMultiTexCoordP1ui; PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv; -void APIENTRY glad_debug_impl_glMultiTexCoordP1uiv(GLenum arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glMultiTexCoordP1uiv", (void*)glMultiTexCoordP1uiv, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP1uiv(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP1uiv", (void*)glMultiTexCoordP1uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP1uiv(GLenum arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glMultiTexCoordP1uiv", (void *) glMultiTexCoordP1uiv, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP1uiv(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP1uiv", (void *) glMultiTexCoordP1uiv, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP1UIVPROC glad_debug_glMultiTexCoordP1uiv = glad_debug_impl_glMultiTexCoordP1uiv; PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui; -void APIENTRY glad_debug_impl_glMultiTexCoordP2ui(GLenum arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glMultiTexCoordP2ui", (void*)glMultiTexCoordP2ui, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP2ui(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP2ui", (void*)glMultiTexCoordP2ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP2ui(GLenum arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glMultiTexCoordP2ui", (void *) glMultiTexCoordP2ui, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP2ui(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP2ui", (void *) glMultiTexCoordP2ui, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP2UIPROC glad_debug_glMultiTexCoordP2ui = glad_debug_impl_glMultiTexCoordP2ui; PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv; -void APIENTRY glad_debug_impl_glMultiTexCoordP2uiv(GLenum arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glMultiTexCoordP2uiv", (void*)glMultiTexCoordP2uiv, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP2uiv(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP2uiv", (void*)glMultiTexCoordP2uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP2uiv(GLenum arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glMultiTexCoordP2uiv", (void *) glMultiTexCoordP2uiv, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP2uiv(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP2uiv", (void *) glMultiTexCoordP2uiv, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP2UIVPROC glad_debug_glMultiTexCoordP2uiv = glad_debug_impl_glMultiTexCoordP2uiv; PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui; -void APIENTRY glad_debug_impl_glMultiTexCoordP3ui(GLenum arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glMultiTexCoordP3ui", (void*)glMultiTexCoordP3ui, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP3ui(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP3ui", (void*)glMultiTexCoordP3ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP3ui(GLenum arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glMultiTexCoordP3ui", (void *) glMultiTexCoordP3ui, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP3ui(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP3ui", (void *) glMultiTexCoordP3ui, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP3UIPROC glad_debug_glMultiTexCoordP3ui = glad_debug_impl_glMultiTexCoordP3ui; PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv; -void APIENTRY glad_debug_impl_glMultiTexCoordP3uiv(GLenum arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glMultiTexCoordP3uiv", (void*)glMultiTexCoordP3uiv, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP3uiv(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP3uiv", (void*)glMultiTexCoordP3uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP3uiv(GLenum arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glMultiTexCoordP3uiv", (void *) glMultiTexCoordP3uiv, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP3uiv(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP3uiv", (void *) glMultiTexCoordP3uiv, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP3UIVPROC glad_debug_glMultiTexCoordP3uiv = glad_debug_impl_glMultiTexCoordP3uiv; PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui; -void APIENTRY glad_debug_impl_glMultiTexCoordP4ui(GLenum arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glMultiTexCoordP4ui", (void*)glMultiTexCoordP4ui, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP4ui(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP4ui", (void*)glMultiTexCoordP4ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP4ui(GLenum arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glMultiTexCoordP4ui", (void *) glMultiTexCoordP4ui, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP4ui(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP4ui", (void *) glMultiTexCoordP4ui, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP4UIPROC glad_debug_glMultiTexCoordP4ui = glad_debug_impl_glMultiTexCoordP4ui; PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv; -void APIENTRY glad_debug_impl_glMultiTexCoordP4uiv(GLenum arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glMultiTexCoordP4uiv", (void*)glMultiTexCoordP4uiv, 3, arg0, arg1, arg2); - glad_glMultiTexCoordP4uiv(arg0, arg1, arg2); - _post_call_callback_gl("glMultiTexCoordP4uiv", (void*)glMultiTexCoordP4uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glMultiTexCoordP4uiv(GLenum arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glMultiTexCoordP4uiv", (void *) glMultiTexCoordP4uiv, 3, arg0, arg1, arg2); + glad_glMultiTexCoordP4uiv(arg0, arg1, arg2); + _post_call_callback_gl("glMultiTexCoordP4uiv", (void *) glMultiTexCoordP4uiv, 3, arg0, arg1, arg2); + } + PFNGLMULTITEXCOORDP4UIVPROC glad_debug_glMultiTexCoordP4uiv = glad_debug_impl_glMultiTexCoordP4uiv; PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData; -void APIENTRY glad_debug_impl_glNamedBufferData(GLuint arg0, GLsizeiptr arg1, const void * arg2, GLenum arg3) { - _pre_call_callback_gl("glNamedBufferData", (void*)glNamedBufferData, 4, arg0, arg1, arg2, arg3); - glad_glNamedBufferData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedBufferData", (void*)glNamedBufferData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedBufferData(GLuint arg0, GLsizeiptr arg1, const void *arg2, GLenum arg3) { + _pre_call_callback_gl("glNamedBufferData", (void *) glNamedBufferData, 4, arg0, arg1, arg2, arg3); + glad_glNamedBufferData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedBufferData", (void *) glNamedBufferData, 4, arg0, arg1, arg2, arg3); + } + PFNGLNAMEDBUFFERDATAPROC glad_debug_glNamedBufferData = glad_debug_impl_glNamedBufferData; PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage; -void APIENTRY glad_debug_impl_glNamedBufferStorage(GLuint arg0, GLsizeiptr arg1, const void * arg2, GLbitfield arg3) { - _pre_call_callback_gl("glNamedBufferStorage", (void*)glNamedBufferStorage, 4, arg0, arg1, arg2, arg3); - glad_glNamedBufferStorage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedBufferStorage", (void*)glNamedBufferStorage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedBufferStorage(GLuint arg0, GLsizeiptr arg1, const void *arg2, GLbitfield arg3) { + _pre_call_callback_gl("glNamedBufferStorage", (void *) glNamedBufferStorage, 4, arg0, arg1, arg2, arg3); + glad_glNamedBufferStorage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedBufferStorage", (void *) glNamedBufferStorage, 4, arg0, arg1, arg2, arg3); + } + PFNGLNAMEDBUFFERSTORAGEPROC glad_debug_glNamedBufferStorage = glad_debug_impl_glNamedBufferStorage; PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData; -void APIENTRY glad_debug_impl_glNamedBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, const void * arg3) { - _pre_call_callback_gl("glNamedBufferSubData", (void*)glNamedBufferSubData, 4, arg0, arg1, arg2, arg3); - glad_glNamedBufferSubData(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedBufferSubData", (void*)glNamedBufferSubData, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedBufferSubData(GLuint arg0, GLintptr arg1, GLsizeiptr arg2, const void *arg3) { + _pre_call_callback_gl("glNamedBufferSubData", (void *) glNamedBufferSubData, 4, arg0, arg1, arg2, arg3); + glad_glNamedBufferSubData(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedBufferSubData", (void *) glNamedBufferSubData, 4, arg0, arg1, arg2, arg3); + } + PFNGLNAMEDBUFFERSUBDATAPROC glad_debug_glNamedBufferSubData = glad_debug_impl_glNamedBufferSubData; PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer; -void APIENTRY glad_debug_impl_glNamedFramebufferDrawBuffer(GLuint arg0, GLenum arg1) { - _pre_call_callback_gl("glNamedFramebufferDrawBuffer", (void*)glNamedFramebufferDrawBuffer, 2, arg0, arg1); - glad_glNamedFramebufferDrawBuffer(arg0, arg1); - _post_call_callback_gl("glNamedFramebufferDrawBuffer", (void*)glNamedFramebufferDrawBuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glNamedFramebufferDrawBuffer(GLuint arg0, GLenum arg1) { + _pre_call_callback_gl("glNamedFramebufferDrawBuffer", (void *) glNamedFramebufferDrawBuffer, 2, arg0, arg1); + glad_glNamedFramebufferDrawBuffer(arg0, arg1); + _post_call_callback_gl("glNamedFramebufferDrawBuffer", (void *) glNamedFramebufferDrawBuffer, 2, arg0, arg1); + } -PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_debug_glNamedFramebufferDrawBuffer = glad_debug_impl_glNamedFramebufferDrawBuffer; + +PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC + glad_debug_glNamedFramebufferDrawBuffer = glad_debug_impl_glNamedFramebufferDrawBuffer; PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers; -void APIENTRY glad_debug_impl_glNamedFramebufferDrawBuffers(GLuint arg0, GLsizei arg1, const GLenum * arg2) { - _pre_call_callback_gl("glNamedFramebufferDrawBuffers", (void*)glNamedFramebufferDrawBuffers, 3, arg0, arg1, arg2); - glad_glNamedFramebufferDrawBuffers(arg0, arg1, arg2); - _post_call_callback_gl("glNamedFramebufferDrawBuffers", (void*)glNamedFramebufferDrawBuffers, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glNamedFramebufferDrawBuffers(GLuint arg0, GLsizei arg1, const GLenum *arg2) { + _pre_call_callback_gl("glNamedFramebufferDrawBuffers", (void *) glNamedFramebufferDrawBuffers, 3, arg0, arg1, arg2); + glad_glNamedFramebufferDrawBuffers(arg0, arg1, arg2); + _post_call_callback_gl("glNamedFramebufferDrawBuffers", + (void *) glNamedFramebufferDrawBuffers, + 3, + arg0, + arg1, + arg2); + } -PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_debug_glNamedFramebufferDrawBuffers = glad_debug_impl_glNamedFramebufferDrawBuffers; + +PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC + glad_debug_glNamedFramebufferDrawBuffers = glad_debug_impl_glNamedFramebufferDrawBuffers; PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri; -void APIENTRY glad_debug_impl_glNamedFramebufferParameteri(GLuint arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glNamedFramebufferParameteri", (void*)glNamedFramebufferParameteri, 3, arg0, arg1, arg2); - glad_glNamedFramebufferParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glNamedFramebufferParameteri", (void*)glNamedFramebufferParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glNamedFramebufferParameteri(GLuint arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glNamedFramebufferParameteri", (void *) glNamedFramebufferParameteri, 3, arg0, arg1, arg2); + glad_glNamedFramebufferParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glNamedFramebufferParameteri", (void *) glNamedFramebufferParameteri, 3, arg0, arg1, arg2); + } -PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_debug_glNamedFramebufferParameteri = glad_debug_impl_glNamedFramebufferParameteri; + +PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC + glad_debug_glNamedFramebufferParameteri = glad_debug_impl_glNamedFramebufferParameteri; PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer; -void APIENTRY glad_debug_impl_glNamedFramebufferReadBuffer(GLuint arg0, GLenum arg1) { - _pre_call_callback_gl("glNamedFramebufferReadBuffer", (void*)glNamedFramebufferReadBuffer, 2, arg0, arg1); - glad_glNamedFramebufferReadBuffer(arg0, arg1); - _post_call_callback_gl("glNamedFramebufferReadBuffer", (void*)glNamedFramebufferReadBuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glNamedFramebufferReadBuffer(GLuint arg0, GLenum arg1) { + _pre_call_callback_gl("glNamedFramebufferReadBuffer", (void *) glNamedFramebufferReadBuffer, 2, arg0, arg1); + glad_glNamedFramebufferReadBuffer(arg0, arg1); + _post_call_callback_gl("glNamedFramebufferReadBuffer", (void *) glNamedFramebufferReadBuffer, 2, arg0, arg1); + } -PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_debug_glNamedFramebufferReadBuffer = glad_debug_impl_glNamedFramebufferReadBuffer; + +PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC + glad_debug_glNamedFramebufferReadBuffer = glad_debug_impl_glNamedFramebufferReadBuffer; PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer; -void APIENTRY glad_debug_impl_glNamedFramebufferRenderbuffer(GLuint arg0, GLenum arg1, GLenum arg2, GLuint arg3) { - _pre_call_callback_gl("glNamedFramebufferRenderbuffer", (void*)glNamedFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); - glad_glNamedFramebufferRenderbuffer(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedFramebufferRenderbuffer", (void*)glNamedFramebufferRenderbuffer, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedFramebufferRenderbuffer(GLuint arg0, GLenum arg1, GLenum arg2, GLuint arg3) { + _pre_call_callback_gl("glNamedFramebufferRenderbuffer", + (void *) glNamedFramebufferRenderbuffer, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glNamedFramebufferRenderbuffer(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedFramebufferRenderbuffer", + (void *) glNamedFramebufferRenderbuffer, + 4, + arg0, + arg1, + arg2, + arg3); + } -PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_debug_glNamedFramebufferRenderbuffer = glad_debug_impl_glNamedFramebufferRenderbuffer; + +PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC + glad_debug_glNamedFramebufferRenderbuffer = glad_debug_impl_glNamedFramebufferRenderbuffer; PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture; -void APIENTRY glad_debug_impl_glNamedFramebufferTexture(GLuint arg0, GLenum arg1, GLuint arg2, GLint arg3) { - _pre_call_callback_gl("glNamedFramebufferTexture", (void*)glNamedFramebufferTexture, 4, arg0, arg1, arg2, arg3); - glad_glNamedFramebufferTexture(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedFramebufferTexture", (void*)glNamedFramebufferTexture, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedFramebufferTexture(GLuint arg0, GLenum arg1, GLuint arg2, GLint arg3) { + _pre_call_callback_gl("glNamedFramebufferTexture", (void *) glNamedFramebufferTexture, 4, arg0, arg1, arg2, arg3); + glad_glNamedFramebufferTexture(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedFramebufferTexture", (void *) glNamedFramebufferTexture, 4, arg0, arg1, arg2, arg3); + } + PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_debug_glNamedFramebufferTexture = glad_debug_impl_glNamedFramebufferTexture; PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer; -void APIENTRY glad_debug_impl_glNamedFramebufferTextureLayer(GLuint arg0, GLenum arg1, GLuint arg2, GLint arg3, GLint arg4) { - _pre_call_callback_gl("glNamedFramebufferTextureLayer", (void*)glNamedFramebufferTextureLayer, 5, arg0, arg1, arg2, arg3, arg4); - glad_glNamedFramebufferTextureLayer(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glNamedFramebufferTextureLayer", (void*)glNamedFramebufferTextureLayer, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glNamedFramebufferTextureLayer(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLint arg3, + GLint arg4) { + _pre_call_callback_gl("glNamedFramebufferTextureLayer", + (void *) glNamedFramebufferTextureLayer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glNamedFramebufferTextureLayer(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glNamedFramebufferTextureLayer", + (void *) glNamedFramebufferTextureLayer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_debug_glNamedFramebufferTextureLayer = glad_debug_impl_glNamedFramebufferTextureLayer; + +PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC + glad_debug_glNamedFramebufferTextureLayer = glad_debug_impl_glNamedFramebufferTextureLayer; PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage; -void APIENTRY glad_debug_impl_glNamedRenderbufferStorage(GLuint arg0, GLenum arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glNamedRenderbufferStorage", (void*)glNamedRenderbufferStorage, 4, arg0, arg1, arg2, arg3); - glad_glNamedRenderbufferStorage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glNamedRenderbufferStorage", (void*)glNamedRenderbufferStorage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glNamedRenderbufferStorage(GLuint arg0, GLenum arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glNamedRenderbufferStorage", (void *) glNamedRenderbufferStorage, 4, arg0, arg1, arg2, arg3); + glad_glNamedRenderbufferStorage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glNamedRenderbufferStorage", + (void *) glNamedRenderbufferStorage, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_debug_glNamedRenderbufferStorage = glad_debug_impl_glNamedRenderbufferStorage; PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample; -void APIENTRY glad_debug_impl_glNamedRenderbufferStorageMultisample(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glNamedRenderbufferStorageMultisample", (void*)glNamedRenderbufferStorageMultisample, 5, arg0, arg1, arg2, arg3, arg4); - glad_glNamedRenderbufferStorageMultisample(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glNamedRenderbufferStorageMultisample", (void*)glNamedRenderbufferStorageMultisample, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glNamedRenderbufferStorageMultisample(GLuint arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4) { + _pre_call_callback_gl("glNamedRenderbufferStorageMultisample", + (void *) glNamedRenderbufferStorageMultisample, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glNamedRenderbufferStorageMultisample(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glNamedRenderbufferStorageMultisample", + (void *) glNamedRenderbufferStorageMultisample, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_debug_glNamedRenderbufferStorageMultisample = glad_debug_impl_glNamedRenderbufferStorageMultisample; + +PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC + glad_debug_glNamedRenderbufferStorageMultisample = glad_debug_impl_glNamedRenderbufferStorageMultisample; PFNGLNORMALP3UIPROC glad_glNormalP3ui; -void APIENTRY glad_debug_impl_glNormalP3ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glNormalP3ui", (void*)glNormalP3ui, 2, arg0, arg1); - glad_glNormalP3ui(arg0, arg1); - _post_call_callback_gl("glNormalP3ui", (void*)glNormalP3ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glNormalP3ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glNormalP3ui", (void *) glNormalP3ui, 2, arg0, arg1); + glad_glNormalP3ui(arg0, arg1); + _post_call_callback_gl("glNormalP3ui", (void *) glNormalP3ui, 2, arg0, arg1); + } + PFNGLNORMALP3UIPROC glad_debug_glNormalP3ui = glad_debug_impl_glNormalP3ui; PFNGLNORMALP3UIVPROC glad_glNormalP3uiv; -void APIENTRY glad_debug_impl_glNormalP3uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glNormalP3uiv", (void*)glNormalP3uiv, 2, arg0, arg1); - glad_glNormalP3uiv(arg0, arg1); - _post_call_callback_gl("glNormalP3uiv", (void*)glNormalP3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glNormalP3uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glNormalP3uiv", (void *) glNormalP3uiv, 2, arg0, arg1); + glad_glNormalP3uiv(arg0, arg1); + _post_call_callback_gl("glNormalP3uiv", (void *) glNormalP3uiv, 2, arg0, arg1); + } + PFNGLNORMALP3UIVPROC glad_debug_glNormalP3uiv = glad_debug_impl_glNormalP3uiv; PFNGLOBJECTLABELPROC glad_glObjectLabel; -void APIENTRY glad_debug_impl_glObjectLabel(GLenum arg0, GLuint arg1, GLsizei arg2, const GLchar * arg3) { - _pre_call_callback_gl("glObjectLabel", (void*)glObjectLabel, 4, arg0, arg1, arg2, arg3); - glad_glObjectLabel(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glObjectLabel", (void*)glObjectLabel, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glObjectLabel(GLenum arg0, GLuint arg1, GLsizei arg2, const GLchar *arg3) { + _pre_call_callback_gl("glObjectLabel", (void *) glObjectLabel, 4, arg0, arg1, arg2, arg3); + glad_glObjectLabel(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glObjectLabel", (void *) glObjectLabel, 4, arg0, arg1, arg2, arg3); + } + PFNGLOBJECTLABELPROC glad_debug_glObjectLabel = glad_debug_impl_glObjectLabel; PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel; -void APIENTRY glad_debug_impl_glObjectPtrLabel(const void * arg0, GLsizei arg1, const GLchar * arg2) { - _pre_call_callback_gl("glObjectPtrLabel", (void*)glObjectPtrLabel, 3, arg0, arg1, arg2); - glad_glObjectPtrLabel(arg0, arg1, arg2); - _post_call_callback_gl("glObjectPtrLabel", (void*)glObjectPtrLabel, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glObjectPtrLabel(const void *arg0, GLsizei arg1, const GLchar *arg2) { + _pre_call_callback_gl("glObjectPtrLabel", (void *) glObjectPtrLabel, 3, arg0, arg1, arg2); + glad_glObjectPtrLabel(arg0, arg1, arg2); + _post_call_callback_gl("glObjectPtrLabel", (void *) glObjectPtrLabel, 3, arg0, arg1, arg2); + } + PFNGLOBJECTPTRLABELPROC glad_debug_glObjectPtrLabel = glad_debug_impl_glObjectPtrLabel; PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv; -void APIENTRY glad_debug_impl_glPatchParameterfv(GLenum arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glPatchParameterfv", (void*)glPatchParameterfv, 2, arg0, arg1); - glad_glPatchParameterfv(arg0, arg1); - _post_call_callback_gl("glPatchParameterfv", (void*)glPatchParameterfv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPatchParameterfv(GLenum arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glPatchParameterfv", (void *) glPatchParameterfv, 2, arg0, arg1); + glad_glPatchParameterfv(arg0, arg1); + _post_call_callback_gl("glPatchParameterfv", (void *) glPatchParameterfv, 2, arg0, arg1); + } + PFNGLPATCHPARAMETERFVPROC glad_debug_glPatchParameterfv = glad_debug_impl_glPatchParameterfv; PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri; -void APIENTRY glad_debug_impl_glPatchParameteri(GLenum arg0, GLint arg1) { - _pre_call_callback_gl("glPatchParameteri", (void*)glPatchParameteri, 2, arg0, arg1); - glad_glPatchParameteri(arg0, arg1); - _post_call_callback_gl("glPatchParameteri", (void*)glPatchParameteri, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPatchParameteri(GLenum arg0, GLint arg1) { + _pre_call_callback_gl("glPatchParameteri", (void *) glPatchParameteri, 2, arg0, arg1); + glad_glPatchParameteri(arg0, arg1); + _post_call_callback_gl("glPatchParameteri", (void *) glPatchParameteri, 2, arg0, arg1); + } + PFNGLPATCHPARAMETERIPROC glad_debug_glPatchParameteri = glad_debug_impl_glPatchParameteri; PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback; -void APIENTRY glad_debug_impl_glPauseTransformFeedback(void) { - _pre_call_callback_gl("glPauseTransformFeedback", (void*)glPauseTransformFeedback, 0); - glad_glPauseTransformFeedback(); - _post_call_callback_gl("glPauseTransformFeedback", (void*)glPauseTransformFeedback, 0); - + +void APIENTRY glad_debug_impl_glPauseTransformFeedback(void) { + _pre_call_callback_gl("glPauseTransformFeedback", (void *) glPauseTransformFeedback, 0); + glad_glPauseTransformFeedback(); + _post_call_callback_gl("glPauseTransformFeedback", (void *) glPauseTransformFeedback, 0); + } + PFNGLPAUSETRANSFORMFEEDBACKPROC glad_debug_glPauseTransformFeedback = glad_debug_impl_glPauseTransformFeedback; PFNGLPIXELSTOREFPROC glad_glPixelStoref; -void APIENTRY glad_debug_impl_glPixelStoref(GLenum arg0, GLfloat arg1) { - _pre_call_callback_gl("glPixelStoref", (void*)glPixelStoref, 2, arg0, arg1); - glad_glPixelStoref(arg0, arg1); - _post_call_callback_gl("glPixelStoref", (void*)glPixelStoref, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPixelStoref(GLenum arg0, GLfloat arg1) { + _pre_call_callback_gl("glPixelStoref", (void *) glPixelStoref, 2, arg0, arg1); + glad_glPixelStoref(arg0, arg1); + _post_call_callback_gl("glPixelStoref", (void *) glPixelStoref, 2, arg0, arg1); + } + PFNGLPIXELSTOREFPROC glad_debug_glPixelStoref = glad_debug_impl_glPixelStoref; PFNGLPIXELSTOREIPROC glad_glPixelStorei; -void APIENTRY glad_debug_impl_glPixelStorei(GLenum arg0, GLint arg1) { - _pre_call_callback_gl("glPixelStorei", (void*)glPixelStorei, 2, arg0, arg1); - glad_glPixelStorei(arg0, arg1); - _post_call_callback_gl("glPixelStorei", (void*)glPixelStorei, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPixelStorei(GLenum arg0, GLint arg1) { + _pre_call_callback_gl("glPixelStorei", (void *) glPixelStorei, 2, arg0, arg1); + glad_glPixelStorei(arg0, arg1); + _post_call_callback_gl("glPixelStorei", (void *) glPixelStorei, 2, arg0, arg1); + } + PFNGLPIXELSTOREIPROC glad_debug_glPixelStorei = glad_debug_impl_glPixelStorei; PFNGLPOINTPARAMETERFPROC glad_glPointParameterf; -void APIENTRY glad_debug_impl_glPointParameterf(GLenum arg0, GLfloat arg1) { - _pre_call_callback_gl("glPointParameterf", (void*)glPointParameterf, 2, arg0, arg1); - glad_glPointParameterf(arg0, arg1); - _post_call_callback_gl("glPointParameterf", (void*)glPointParameterf, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPointParameterf(GLenum arg0, GLfloat arg1) { + _pre_call_callback_gl("glPointParameterf", (void *) glPointParameterf, 2, arg0, arg1); + glad_glPointParameterf(arg0, arg1); + _post_call_callback_gl("glPointParameterf", (void *) glPointParameterf, 2, arg0, arg1); + } + PFNGLPOINTPARAMETERFPROC glad_debug_glPointParameterf = glad_debug_impl_glPointParameterf; PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv; -void APIENTRY glad_debug_impl_glPointParameterfv(GLenum arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glPointParameterfv", (void*)glPointParameterfv, 2, arg0, arg1); - glad_glPointParameterfv(arg0, arg1); - _post_call_callback_gl("glPointParameterfv", (void*)glPointParameterfv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPointParameterfv(GLenum arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glPointParameterfv", (void *) glPointParameterfv, 2, arg0, arg1); + glad_glPointParameterfv(arg0, arg1); + _post_call_callback_gl("glPointParameterfv", (void *) glPointParameterfv, 2, arg0, arg1); + } + PFNGLPOINTPARAMETERFVPROC glad_debug_glPointParameterfv = glad_debug_impl_glPointParameterfv; PFNGLPOINTPARAMETERIPROC glad_glPointParameteri; -void APIENTRY glad_debug_impl_glPointParameteri(GLenum arg0, GLint arg1) { - _pre_call_callback_gl("glPointParameteri", (void*)glPointParameteri, 2, arg0, arg1); - glad_glPointParameteri(arg0, arg1); - _post_call_callback_gl("glPointParameteri", (void*)glPointParameteri, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPointParameteri(GLenum arg0, GLint arg1) { + _pre_call_callback_gl("glPointParameteri", (void *) glPointParameteri, 2, arg0, arg1); + glad_glPointParameteri(arg0, arg1); + _post_call_callback_gl("glPointParameteri", (void *) glPointParameteri, 2, arg0, arg1); + } + PFNGLPOINTPARAMETERIPROC glad_debug_glPointParameteri = glad_debug_impl_glPointParameteri; PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv; -void APIENTRY glad_debug_impl_glPointParameteriv(GLenum arg0, const GLint * arg1) { - _pre_call_callback_gl("glPointParameteriv", (void*)glPointParameteriv, 2, arg0, arg1); - glad_glPointParameteriv(arg0, arg1); - _post_call_callback_gl("glPointParameteriv", (void*)glPointParameteriv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPointParameteriv(GLenum arg0, const GLint *arg1) { + _pre_call_callback_gl("glPointParameteriv", (void *) glPointParameteriv, 2, arg0, arg1); + glad_glPointParameteriv(arg0, arg1); + _post_call_callback_gl("glPointParameteriv", (void *) glPointParameteriv, 2, arg0, arg1); + } + PFNGLPOINTPARAMETERIVPROC glad_debug_glPointParameteriv = glad_debug_impl_glPointParameteriv; PFNGLPOINTSIZEPROC glad_glPointSize; -void APIENTRY glad_debug_impl_glPointSize(GLfloat arg0) { - _pre_call_callback_gl("glPointSize", (void*)glPointSize, 1, arg0); - glad_glPointSize(arg0); - _post_call_callback_gl("glPointSize", (void*)glPointSize, 1, arg0); - + +void APIENTRY glad_debug_impl_glPointSize(GLfloat arg0) { + _pre_call_callback_gl("glPointSize", (void *) glPointSize, 1, arg0); + glad_glPointSize(arg0); + _post_call_callback_gl("glPointSize", (void *) glPointSize, 1, arg0); + } + PFNGLPOINTSIZEPROC glad_debug_glPointSize = glad_debug_impl_glPointSize; PFNGLPOLYGONMODEPROC glad_glPolygonMode; -void APIENTRY glad_debug_impl_glPolygonMode(GLenum arg0, GLenum arg1) { - _pre_call_callback_gl("glPolygonMode", (void*)glPolygonMode, 2, arg0, arg1); - glad_glPolygonMode(arg0, arg1); - _post_call_callback_gl("glPolygonMode", (void*)glPolygonMode, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPolygonMode(GLenum arg0, GLenum arg1) { + _pre_call_callback_gl("glPolygonMode", (void *) glPolygonMode, 2, arg0, arg1); + glad_glPolygonMode(arg0, arg1); + _post_call_callback_gl("glPolygonMode", (void *) glPolygonMode, 2, arg0, arg1); + } + PFNGLPOLYGONMODEPROC glad_debug_glPolygonMode = glad_debug_impl_glPolygonMode; PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset; -void APIENTRY glad_debug_impl_glPolygonOffset(GLfloat arg0, GLfloat arg1) { - _pre_call_callback_gl("glPolygonOffset", (void*)glPolygonOffset, 2, arg0, arg1); - glad_glPolygonOffset(arg0, arg1); - _post_call_callback_gl("glPolygonOffset", (void*)glPolygonOffset, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glPolygonOffset(GLfloat arg0, GLfloat arg1) { + _pre_call_callback_gl("glPolygonOffset", (void *) glPolygonOffset, 2, arg0, arg1); + glad_glPolygonOffset(arg0, arg1); + _post_call_callback_gl("glPolygonOffset", (void *) glPolygonOffset, 2, arg0, arg1); + } + PFNGLPOLYGONOFFSETPROC glad_debug_glPolygonOffset = glad_debug_impl_glPolygonOffset; PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup; -void APIENTRY glad_debug_impl_glPopDebugGroup(void) { - _pre_call_callback_gl("glPopDebugGroup", (void*)glPopDebugGroup, 0); - glad_glPopDebugGroup(); - _post_call_callback_gl("glPopDebugGroup", (void*)glPopDebugGroup, 0); - + +void APIENTRY glad_debug_impl_glPopDebugGroup(void) { + _pre_call_callback_gl("glPopDebugGroup", (void *) glPopDebugGroup, 0); + glad_glPopDebugGroup(); + _post_call_callback_gl("glPopDebugGroup", (void *) glPopDebugGroup, 0); + } + PFNGLPOPDEBUGGROUPPROC glad_debug_glPopDebugGroup = glad_debug_impl_glPopDebugGroup; PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex; -void APIENTRY glad_debug_impl_glPrimitiveRestartIndex(GLuint arg0) { - _pre_call_callback_gl("glPrimitiveRestartIndex", (void*)glPrimitiveRestartIndex, 1, arg0); - glad_glPrimitiveRestartIndex(arg0); - _post_call_callback_gl("glPrimitiveRestartIndex", (void*)glPrimitiveRestartIndex, 1, arg0); - + +void APIENTRY glad_debug_impl_glPrimitiveRestartIndex(GLuint arg0) { + _pre_call_callback_gl("glPrimitiveRestartIndex", (void *) glPrimitiveRestartIndex, 1, arg0); + glad_glPrimitiveRestartIndex(arg0); + _post_call_callback_gl("glPrimitiveRestartIndex", (void *) glPrimitiveRestartIndex, 1, arg0); + } + PFNGLPRIMITIVERESTARTINDEXPROC glad_debug_glPrimitiveRestartIndex = glad_debug_impl_glPrimitiveRestartIndex; PFNGLPROGRAMBINARYPROC glad_glProgramBinary; -void APIENTRY glad_debug_impl_glProgramBinary(GLuint arg0, GLenum arg1, const void * arg2, GLsizei arg3) { - _pre_call_callback_gl("glProgramBinary", (void*)glProgramBinary, 4, arg0, arg1, arg2, arg3); - glad_glProgramBinary(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramBinary", (void*)glProgramBinary, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramBinary(GLuint arg0, GLenum arg1, const void *arg2, GLsizei arg3) { + _pre_call_callback_gl("glProgramBinary", (void *) glProgramBinary, 4, arg0, arg1, arg2, arg3); + glad_glProgramBinary(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramBinary", (void *) glProgramBinary, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMBINARYPROC glad_debug_glProgramBinary = glad_debug_impl_glProgramBinary; PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri; -void APIENTRY glad_debug_impl_glProgramParameteri(GLuint arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glProgramParameteri", (void*)glProgramParameteri, 3, arg0, arg1, arg2); - glad_glProgramParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glProgramParameteri", (void*)glProgramParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glProgramParameteri(GLuint arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glProgramParameteri", (void *) glProgramParameteri, 3, arg0, arg1, arg2); + glad_glProgramParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glProgramParameteri", (void *) glProgramParameteri, 3, arg0, arg1, arg2); + } + PFNGLPROGRAMPARAMETERIPROC glad_debug_glProgramParameteri = glad_debug_impl_glProgramParameteri; PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d; -void APIENTRY glad_debug_impl_glProgramUniform1d(GLuint arg0, GLint arg1, GLdouble arg2) { - _pre_call_callback_gl("glProgramUniform1d", (void*)glProgramUniform1d, 3, arg0, arg1, arg2); - glad_glProgramUniform1d(arg0, arg1, arg2); - _post_call_callback_gl("glProgramUniform1d", (void*)glProgramUniform1d, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glProgramUniform1d(GLuint arg0, GLint arg1, GLdouble arg2) { + _pre_call_callback_gl("glProgramUniform1d", (void *) glProgramUniform1d, 3, arg0, arg1, arg2); + glad_glProgramUniform1d(arg0, arg1, arg2); + _post_call_callback_gl("glProgramUniform1d", (void *) glProgramUniform1d, 3, arg0, arg1, arg2); + } + PFNGLPROGRAMUNIFORM1DPROC glad_debug_glProgramUniform1d = glad_debug_impl_glProgramUniform1d; PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv; -void APIENTRY glad_debug_impl_glProgramUniform1dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glProgramUniform1dv", (void*)glProgramUniform1dv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform1dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform1dv", (void*)glProgramUniform1dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform1dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glProgramUniform1dv", (void *) glProgramUniform1dv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform1dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform1dv", (void *) glProgramUniform1dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM1DVPROC glad_debug_glProgramUniform1dv = glad_debug_impl_glProgramUniform1dv; PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f; -void APIENTRY glad_debug_impl_glProgramUniform1f(GLuint arg0, GLint arg1, GLfloat arg2) { - _pre_call_callback_gl("glProgramUniform1f", (void*)glProgramUniform1f, 3, arg0, arg1, arg2); - glad_glProgramUniform1f(arg0, arg1, arg2); - _post_call_callback_gl("glProgramUniform1f", (void*)glProgramUniform1f, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glProgramUniform1f(GLuint arg0, GLint arg1, GLfloat arg2) { + _pre_call_callback_gl("glProgramUniform1f", (void *) glProgramUniform1f, 3, arg0, arg1, arg2); + glad_glProgramUniform1f(arg0, arg1, arg2); + _post_call_callback_gl("glProgramUniform1f", (void *) glProgramUniform1f, 3, arg0, arg1, arg2); + } + PFNGLPROGRAMUNIFORM1FPROC glad_debug_glProgramUniform1f = glad_debug_impl_glProgramUniform1f; PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv; -void APIENTRY glad_debug_impl_glProgramUniform1fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glProgramUniform1fv", (void*)glProgramUniform1fv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform1fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform1fv", (void*)glProgramUniform1fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform1fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glProgramUniform1fv", (void *) glProgramUniform1fv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform1fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform1fv", (void *) glProgramUniform1fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM1FVPROC glad_debug_glProgramUniform1fv = glad_debug_impl_glProgramUniform1fv; PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i; -void APIENTRY glad_debug_impl_glProgramUniform1i(GLuint arg0, GLint arg1, GLint arg2) { - _pre_call_callback_gl("glProgramUniform1i", (void*)glProgramUniform1i, 3, arg0, arg1, arg2); - glad_glProgramUniform1i(arg0, arg1, arg2); - _post_call_callback_gl("glProgramUniform1i", (void*)glProgramUniform1i, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glProgramUniform1i(GLuint arg0, GLint arg1, GLint arg2) { + _pre_call_callback_gl("glProgramUniform1i", (void *) glProgramUniform1i, 3, arg0, arg1, arg2); + glad_glProgramUniform1i(arg0, arg1, arg2); + _post_call_callback_gl("glProgramUniform1i", (void *) glProgramUniform1i, 3, arg0, arg1, arg2); + } + PFNGLPROGRAMUNIFORM1IPROC glad_debug_glProgramUniform1i = glad_debug_impl_glProgramUniform1i; PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv; -void APIENTRY glad_debug_impl_glProgramUniform1iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint * arg3) { - _pre_call_callback_gl("glProgramUniform1iv", (void*)glProgramUniform1iv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform1iv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform1iv", (void*)glProgramUniform1iv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform1iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint *arg3) { + _pre_call_callback_gl("glProgramUniform1iv", (void *) glProgramUniform1iv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform1iv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform1iv", (void *) glProgramUniform1iv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM1IVPROC glad_debug_glProgramUniform1iv = glad_debug_impl_glProgramUniform1iv; PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui; -void APIENTRY glad_debug_impl_glProgramUniform1ui(GLuint arg0, GLint arg1, GLuint arg2) { - _pre_call_callback_gl("glProgramUniform1ui", (void*)glProgramUniform1ui, 3, arg0, arg1, arg2); - glad_glProgramUniform1ui(arg0, arg1, arg2); - _post_call_callback_gl("glProgramUniform1ui", (void*)glProgramUniform1ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glProgramUniform1ui(GLuint arg0, GLint arg1, GLuint arg2) { + _pre_call_callback_gl("glProgramUniform1ui", (void *) glProgramUniform1ui, 3, arg0, arg1, arg2); + glad_glProgramUniform1ui(arg0, arg1, arg2); + _post_call_callback_gl("glProgramUniform1ui", (void *) glProgramUniform1ui, 3, arg0, arg1, arg2); + } + PFNGLPROGRAMUNIFORM1UIPROC glad_debug_glProgramUniform1ui = glad_debug_impl_glProgramUniform1ui; PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv; -void APIENTRY glad_debug_impl_glProgramUniform1uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint * arg3) { - _pre_call_callback_gl("glProgramUniform1uiv", (void*)glProgramUniform1uiv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform1uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform1uiv", (void*)glProgramUniform1uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform1uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint *arg3) { + _pre_call_callback_gl("glProgramUniform1uiv", (void *) glProgramUniform1uiv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform1uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform1uiv", (void *) glProgramUniform1uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM1UIVPROC glad_debug_glProgramUniform1uiv = glad_debug_impl_glProgramUniform1uiv; PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d; -void APIENTRY glad_debug_impl_glProgramUniform2d(GLuint arg0, GLint arg1, GLdouble arg2, GLdouble arg3) { - _pre_call_callback_gl("glProgramUniform2d", (void*)glProgramUniform2d, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2d(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2d", (void*)glProgramUniform2d, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2d(GLuint arg0, GLint arg1, GLdouble arg2, GLdouble arg3) { + _pre_call_callback_gl("glProgramUniform2d", (void *) glProgramUniform2d, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2d(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2d", (void *) glProgramUniform2d, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2DPROC glad_debug_glProgramUniform2d = glad_debug_impl_glProgramUniform2d; PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv; -void APIENTRY glad_debug_impl_glProgramUniform2dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glProgramUniform2dv", (void*)glProgramUniform2dv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2dv", (void*)glProgramUniform2dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glProgramUniform2dv", (void *) glProgramUniform2dv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2dv", (void *) glProgramUniform2dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2DVPROC glad_debug_glProgramUniform2dv = glad_debug_impl_glProgramUniform2dv; PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f; -void APIENTRY glad_debug_impl_glProgramUniform2f(GLuint arg0, GLint arg1, GLfloat arg2, GLfloat arg3) { - _pre_call_callback_gl("glProgramUniform2f", (void*)glProgramUniform2f, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2f(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2f", (void*)glProgramUniform2f, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2f(GLuint arg0, GLint arg1, GLfloat arg2, GLfloat arg3) { + _pre_call_callback_gl("glProgramUniform2f", (void *) glProgramUniform2f, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2f(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2f", (void *) glProgramUniform2f, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2FPROC glad_debug_glProgramUniform2f = glad_debug_impl_glProgramUniform2f; PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv; -void APIENTRY glad_debug_impl_glProgramUniform2fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glProgramUniform2fv", (void*)glProgramUniform2fv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2fv", (void*)glProgramUniform2fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glProgramUniform2fv", (void *) glProgramUniform2fv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2fv", (void *) glProgramUniform2fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2FVPROC glad_debug_glProgramUniform2fv = glad_debug_impl_glProgramUniform2fv; PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i; -void APIENTRY glad_debug_impl_glProgramUniform2i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3) { - _pre_call_callback_gl("glProgramUniform2i", (void*)glProgramUniform2i, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2i(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2i", (void*)glProgramUniform2i, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3) { + _pre_call_callback_gl("glProgramUniform2i", (void *) glProgramUniform2i, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2i(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2i", (void *) glProgramUniform2i, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2IPROC glad_debug_glProgramUniform2i = glad_debug_impl_glProgramUniform2i; PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv; -void APIENTRY glad_debug_impl_glProgramUniform2iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint * arg3) { - _pre_call_callback_gl("glProgramUniform2iv", (void*)glProgramUniform2iv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2iv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2iv", (void*)glProgramUniform2iv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint *arg3) { + _pre_call_callback_gl("glProgramUniform2iv", (void *) glProgramUniform2iv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2iv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2iv", (void *) glProgramUniform2iv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2IVPROC glad_debug_glProgramUniform2iv = glad_debug_impl_glProgramUniform2iv; PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui; -void APIENTRY glad_debug_impl_glProgramUniform2ui(GLuint arg0, GLint arg1, GLuint arg2, GLuint arg3) { - _pre_call_callback_gl("glProgramUniform2ui", (void*)glProgramUniform2ui, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2ui", (void*)glProgramUniform2ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2ui(GLuint arg0, GLint arg1, GLuint arg2, GLuint arg3) { + _pre_call_callback_gl("glProgramUniform2ui", (void *) glProgramUniform2ui, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2ui", (void *) glProgramUniform2ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2UIPROC glad_debug_glProgramUniform2ui = glad_debug_impl_glProgramUniform2ui; PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv; -void APIENTRY glad_debug_impl_glProgramUniform2uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint * arg3) { - _pre_call_callback_gl("glProgramUniform2uiv", (void*)glProgramUniform2uiv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform2uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform2uiv", (void*)glProgramUniform2uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform2uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint *arg3) { + _pre_call_callback_gl("glProgramUniform2uiv", (void *) glProgramUniform2uiv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform2uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform2uiv", (void *) glProgramUniform2uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM2UIVPROC glad_debug_glProgramUniform2uiv = glad_debug_impl_glProgramUniform2uiv; PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d; -void APIENTRY glad_debug_impl_glProgramUniform3d(GLuint arg0, GLint arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { - _pre_call_callback_gl("glProgramUniform3d", (void*)glProgramUniform3d, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniform3d(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniform3d", (void*)glProgramUniform3d, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniform3d(GLuint arg0, GLint arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { + _pre_call_callback_gl("glProgramUniform3d", (void *) glProgramUniform3d, 5, arg0, arg1, arg2, arg3, arg4); + glad_glProgramUniform3d(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniform3d", (void *) glProgramUniform3d, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLPROGRAMUNIFORM3DPROC glad_debug_glProgramUniform3d = glad_debug_impl_glProgramUniform3d; PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv; -void APIENTRY glad_debug_impl_glProgramUniform3dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glProgramUniform3dv", (void*)glProgramUniform3dv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform3dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform3dv", (void*)glProgramUniform3dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform3dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glProgramUniform3dv", (void *) glProgramUniform3dv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform3dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform3dv", (void *) glProgramUniform3dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM3DVPROC glad_debug_glProgramUniform3dv = glad_debug_impl_glProgramUniform3dv; PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f; -void APIENTRY glad_debug_impl_glProgramUniform3f(GLuint arg0, GLint arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { - _pre_call_callback_gl("glProgramUniform3f", (void*)glProgramUniform3f, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniform3f(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniform3f", (void*)glProgramUniform3f, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniform3f(GLuint arg0, GLint arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { + _pre_call_callback_gl("glProgramUniform3f", (void *) glProgramUniform3f, 5, arg0, arg1, arg2, arg3, arg4); + glad_glProgramUniform3f(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniform3f", (void *) glProgramUniform3f, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLPROGRAMUNIFORM3FPROC glad_debug_glProgramUniform3f = glad_debug_impl_glProgramUniform3f; PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv; -void APIENTRY glad_debug_impl_glProgramUniform3fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glProgramUniform3fv", (void*)glProgramUniform3fv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform3fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform3fv", (void*)glProgramUniform3fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform3fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glProgramUniform3fv", (void *) glProgramUniform3fv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform3fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform3fv", (void *) glProgramUniform3fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM3FVPROC glad_debug_glProgramUniform3fv = glad_debug_impl_glProgramUniform3fv; PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i; -void APIENTRY glad_debug_impl_glProgramUniform3i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { - _pre_call_callback_gl("glProgramUniform3i", (void*)glProgramUniform3i, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniform3i(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniform3i", (void*)glProgramUniform3i, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniform3i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { + _pre_call_callback_gl("glProgramUniform3i", (void *) glProgramUniform3i, 5, arg0, arg1, arg2, arg3, arg4); + glad_glProgramUniform3i(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniform3i", (void *) glProgramUniform3i, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLPROGRAMUNIFORM3IPROC glad_debug_glProgramUniform3i = glad_debug_impl_glProgramUniform3i; PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv; -void APIENTRY glad_debug_impl_glProgramUniform3iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint * arg3) { - _pre_call_callback_gl("glProgramUniform3iv", (void*)glProgramUniform3iv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform3iv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform3iv", (void*)glProgramUniform3iv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform3iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint *arg3) { + _pre_call_callback_gl("glProgramUniform3iv", (void *) glProgramUniform3iv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform3iv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform3iv", (void *) glProgramUniform3iv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM3IVPROC glad_debug_glProgramUniform3iv = glad_debug_impl_glProgramUniform3iv; PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui; -void APIENTRY glad_debug_impl_glProgramUniform3ui(GLuint arg0, GLint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { - _pre_call_callback_gl("glProgramUniform3ui", (void*)glProgramUniform3ui, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniform3ui(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniform3ui", (void*)glProgramUniform3ui, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniform3ui(GLuint arg0, GLint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { + _pre_call_callback_gl("glProgramUniform3ui", (void *) glProgramUniform3ui, 5, arg0, arg1, arg2, arg3, arg4); + glad_glProgramUniform3ui(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniform3ui", (void *) glProgramUniform3ui, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLPROGRAMUNIFORM3UIPROC glad_debug_glProgramUniform3ui = glad_debug_impl_glProgramUniform3ui; PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv; -void APIENTRY glad_debug_impl_glProgramUniform3uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint * arg3) { - _pre_call_callback_gl("glProgramUniform3uiv", (void*)glProgramUniform3uiv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform3uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform3uiv", (void*)glProgramUniform3uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform3uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint *arg3) { + _pre_call_callback_gl("glProgramUniform3uiv", (void *) glProgramUniform3uiv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform3uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform3uiv", (void *) glProgramUniform3uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM3UIVPROC glad_debug_glProgramUniform3uiv = glad_debug_impl_glProgramUniform3uiv; PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d; -void APIENTRY glad_debug_impl_glProgramUniform4d(GLuint arg0, GLint arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4, GLdouble arg5) { - _pre_call_callback_gl("glProgramUniform4d", (void*)glProgramUniform4d, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glProgramUniform4d(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glProgramUniform4d", (void*)glProgramUniform4d, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glProgramUniform4d(GLuint arg0, + GLint arg1, + GLdouble arg2, + GLdouble arg3, + GLdouble arg4, + GLdouble arg5) { + _pre_call_callback_gl("glProgramUniform4d", (void *) glProgramUniform4d, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glProgramUniform4d(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glProgramUniform4d", (void *) glProgramUniform4d, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLPROGRAMUNIFORM4DPROC glad_debug_glProgramUniform4d = glad_debug_impl_glProgramUniform4d; PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv; -void APIENTRY glad_debug_impl_glProgramUniform4dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glProgramUniform4dv", (void*)glProgramUniform4dv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform4dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform4dv", (void*)glProgramUniform4dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform4dv(GLuint arg0, GLint arg1, GLsizei arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glProgramUniform4dv", (void *) glProgramUniform4dv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform4dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform4dv", (void *) glProgramUniform4dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM4DVPROC glad_debug_glProgramUniform4dv = glad_debug_impl_glProgramUniform4dv; PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f; -void APIENTRY glad_debug_impl_glProgramUniform4f(GLuint arg0, GLint arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4, GLfloat arg5) { - _pre_call_callback_gl("glProgramUniform4f", (void*)glProgramUniform4f, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glProgramUniform4f(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glProgramUniform4f", (void*)glProgramUniform4f, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glProgramUniform4f(GLuint arg0, + GLint arg1, + GLfloat arg2, + GLfloat arg3, + GLfloat arg4, + GLfloat arg5) { + _pre_call_callback_gl("glProgramUniform4f", (void *) glProgramUniform4f, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glProgramUniform4f(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glProgramUniform4f", (void *) glProgramUniform4f, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLPROGRAMUNIFORM4FPROC glad_debug_glProgramUniform4f = glad_debug_impl_glProgramUniform4f; PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv; -void APIENTRY glad_debug_impl_glProgramUniform4fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glProgramUniform4fv", (void*)glProgramUniform4fv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform4fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform4fv", (void*)glProgramUniform4fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform4fv(GLuint arg0, GLint arg1, GLsizei arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glProgramUniform4fv", (void *) glProgramUniform4fv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform4fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform4fv", (void *) glProgramUniform4fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM4FVPROC glad_debug_glProgramUniform4fv = glad_debug_impl_glProgramUniform4fv; PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i; -void APIENTRY glad_debug_impl_glProgramUniform4i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLint arg5) { - _pre_call_callback_gl("glProgramUniform4i", (void*)glProgramUniform4i, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glProgramUniform4i(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glProgramUniform4i", (void*)glProgramUniform4i, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glProgramUniform4i(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLint arg5) { + _pre_call_callback_gl("glProgramUniform4i", (void *) glProgramUniform4i, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glProgramUniform4i(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glProgramUniform4i", (void *) glProgramUniform4i, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLPROGRAMUNIFORM4IPROC glad_debug_glProgramUniform4i = glad_debug_impl_glProgramUniform4i; PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv; -void APIENTRY glad_debug_impl_glProgramUniform4iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint * arg3) { - _pre_call_callback_gl("glProgramUniform4iv", (void*)glProgramUniform4iv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform4iv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform4iv", (void*)glProgramUniform4iv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform4iv(GLuint arg0, GLint arg1, GLsizei arg2, const GLint *arg3) { + _pre_call_callback_gl("glProgramUniform4iv", (void *) glProgramUniform4iv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform4iv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform4iv", (void *) glProgramUniform4iv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM4IVPROC glad_debug_glProgramUniform4iv = glad_debug_impl_glProgramUniform4iv; PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui; -void APIENTRY glad_debug_impl_glProgramUniform4ui(GLuint arg0, GLint arg1, GLuint arg2, GLuint arg3, GLuint arg4, GLuint arg5) { - _pre_call_callback_gl("glProgramUniform4ui", (void*)glProgramUniform4ui, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glProgramUniform4ui(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glProgramUniform4ui", (void*)glProgramUniform4ui, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glProgramUniform4ui(GLuint arg0, + GLint arg1, + GLuint arg2, + GLuint arg3, + GLuint arg4, + GLuint arg5) { + _pre_call_callback_gl("glProgramUniform4ui", (void *) glProgramUniform4ui, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glProgramUniform4ui(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glProgramUniform4ui", (void *) glProgramUniform4ui, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLPROGRAMUNIFORM4UIPROC glad_debug_glProgramUniform4ui = glad_debug_impl_glProgramUniform4ui; PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv; -void APIENTRY glad_debug_impl_glProgramUniform4uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint * arg3) { - _pre_call_callback_gl("glProgramUniform4uiv", (void*)glProgramUniform4uiv, 4, arg0, arg1, arg2, arg3); - glad_glProgramUniform4uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glProgramUniform4uiv", (void*)glProgramUniform4uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glProgramUniform4uiv(GLuint arg0, GLint arg1, GLsizei arg2, const GLuint *arg3) { + _pre_call_callback_gl("glProgramUniform4uiv", (void *) glProgramUniform4uiv, 4, arg0, arg1, arg2, arg3); + glad_glProgramUniform4uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glProgramUniform4uiv", (void *) glProgramUniform4uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLPROGRAMUNIFORM4UIVPROC glad_debug_glProgramUniform4uiv = glad_debug_impl_glProgramUniform4uiv; PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2dv", (void*)glProgramUniformMatrix2dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2dv", (void*)glProgramUniformMatrix2dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2dv", + (void *) glProgramUniformMatrix2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2dv", + (void *) glProgramUniformMatrix2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_debug_glProgramUniformMatrix2dv = glad_debug_impl_glProgramUniformMatrix2dv; PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2fv", (void*)glProgramUniformMatrix2fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2fv", (void*)glProgramUniformMatrix2fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2fv", + (void *) glProgramUniformMatrix2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2fv", + (void *) glProgramUniformMatrix2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_debug_glProgramUniformMatrix2fv = glad_debug_impl_glProgramUniformMatrix2fv; PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2x3dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2x3dv", (void*)glProgramUniformMatrix2x3dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2x3dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2x3dv", (void*)glProgramUniformMatrix2x3dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2x3dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2x3dv", + (void *) glProgramUniformMatrix2x3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2x3dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2x3dv", + (void *) glProgramUniformMatrix2x3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_debug_glProgramUniformMatrix2x3dv = glad_debug_impl_glProgramUniformMatrix2x3dv; PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2x3fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2x3fv", (void*)glProgramUniformMatrix2x3fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2x3fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2x3fv", (void*)glProgramUniformMatrix2x3fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2x3fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2x3fv", + (void *) glProgramUniformMatrix2x3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2x3fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2x3fv", + (void *) glProgramUniformMatrix2x3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_debug_glProgramUniformMatrix2x3fv = glad_debug_impl_glProgramUniformMatrix2x3fv; PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2x4dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2x4dv", (void*)glProgramUniformMatrix2x4dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2x4dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2x4dv", (void*)glProgramUniformMatrix2x4dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2x4dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2x4dv", + (void *) glProgramUniformMatrix2x4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2x4dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2x4dv", + (void *) glProgramUniformMatrix2x4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_debug_glProgramUniformMatrix2x4dv = glad_debug_impl_glProgramUniformMatrix2x4dv; PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix2x4fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix2x4fv", (void*)glProgramUniformMatrix2x4fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix2x4fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix2x4fv", (void*)glProgramUniformMatrix2x4fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix2x4fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix2x4fv", + (void *) glProgramUniformMatrix2x4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix2x4fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix2x4fv", + (void *) glProgramUniformMatrix2x4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_debug_glProgramUniformMatrix2x4fv = glad_debug_impl_glProgramUniformMatrix2x4fv; PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3dv", (void*)glProgramUniformMatrix3dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3dv", (void*)glProgramUniformMatrix3dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3dv", + (void *) glProgramUniformMatrix3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3dv", + (void *) glProgramUniformMatrix3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_debug_glProgramUniformMatrix3dv = glad_debug_impl_glProgramUniformMatrix3dv; PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3fv", (void*)glProgramUniformMatrix3fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3fv", (void*)glProgramUniformMatrix3fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3fv", + (void *) glProgramUniformMatrix3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3fv", + (void *) glProgramUniformMatrix3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_debug_glProgramUniformMatrix3fv = glad_debug_impl_glProgramUniformMatrix3fv; PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3x2dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3x2dv", (void*)glProgramUniformMatrix3x2dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3x2dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3x2dv", (void*)glProgramUniformMatrix3x2dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3x2dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3x2dv", + (void *) glProgramUniformMatrix3x2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3x2dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3x2dv", + (void *) glProgramUniformMatrix3x2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_debug_glProgramUniformMatrix3x2dv = glad_debug_impl_glProgramUniformMatrix3x2dv; PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3x2fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3x2fv", (void*)glProgramUniformMatrix3x2fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3x2fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3x2fv", (void*)glProgramUniformMatrix3x2fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3x2fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3x2fv", + (void *) glProgramUniformMatrix3x2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3x2fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3x2fv", + (void *) glProgramUniformMatrix3x2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_debug_glProgramUniformMatrix3x2fv = glad_debug_impl_glProgramUniformMatrix3x2fv; PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3x4dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3x4dv", (void*)glProgramUniformMatrix3x4dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3x4dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3x4dv", (void*)glProgramUniformMatrix3x4dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3x4dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3x4dv", + (void *) glProgramUniformMatrix3x4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3x4dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3x4dv", + (void *) glProgramUniformMatrix3x4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_debug_glProgramUniformMatrix3x4dv = glad_debug_impl_glProgramUniformMatrix3x4dv; PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix3x4fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix3x4fv", (void*)glProgramUniformMatrix3x4fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix3x4fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix3x4fv", (void*)glProgramUniformMatrix3x4fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix3x4fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix3x4fv", + (void *) glProgramUniformMatrix3x4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix3x4fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix3x4fv", + (void *) glProgramUniformMatrix3x4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_debug_glProgramUniformMatrix3x4fv = glad_debug_impl_glProgramUniformMatrix3x4fv; PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4dv", (void*)glProgramUniformMatrix4dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4dv", (void*)glProgramUniformMatrix4dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4dv", + (void *) glProgramUniformMatrix4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4dv", + (void *) glProgramUniformMatrix4dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_debug_glProgramUniformMatrix4dv = glad_debug_impl_glProgramUniformMatrix4dv; PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4fv", (void*)glProgramUniformMatrix4fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4fv", (void*)glProgramUniformMatrix4fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4fv", + (void *) glProgramUniformMatrix4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4fv", + (void *) glProgramUniformMatrix4fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_debug_glProgramUniformMatrix4fv = glad_debug_impl_glProgramUniformMatrix4fv; PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4x2dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4x2dv", (void*)glProgramUniformMatrix4x2dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4x2dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4x2dv", (void*)glProgramUniformMatrix4x2dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4x2dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4x2dv", + (void *) glProgramUniformMatrix4x2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4x2dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4x2dv", + (void *) glProgramUniformMatrix4x2dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_debug_glProgramUniformMatrix4x2dv = glad_debug_impl_glProgramUniformMatrix4x2dv; PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4x2fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4x2fv", (void*)glProgramUniformMatrix4x2fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4x2fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4x2fv", (void*)glProgramUniformMatrix4x2fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4x2fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4x2fv", + (void *) glProgramUniformMatrix4x2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4x2fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4x2fv", + (void *) glProgramUniformMatrix4x2fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_debug_glProgramUniformMatrix4x2fv = glad_debug_impl_glProgramUniformMatrix4x2fv; PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4x3dv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLdouble * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4x3dv", (void*)glProgramUniformMatrix4x3dv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4x3dv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4x3dv", (void*)glProgramUniformMatrix4x3dv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4x3dv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLdouble *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4x3dv", + (void *) glProgramUniformMatrix4x3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4x3dv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4x3dv", + (void *) glProgramUniformMatrix4x3dv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_debug_glProgramUniformMatrix4x3dv = glad_debug_impl_glProgramUniformMatrix4x3dv; PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv; -void APIENTRY glad_debug_impl_glProgramUniformMatrix4x3fv(GLuint arg0, GLint arg1, GLsizei arg2, GLboolean arg3, const GLfloat * arg4) { - _pre_call_callback_gl("glProgramUniformMatrix4x3fv", (void*)glProgramUniformMatrix4x3fv, 5, arg0, arg1, arg2, arg3, arg4); - glad_glProgramUniformMatrix4x3fv(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glProgramUniformMatrix4x3fv", (void*)glProgramUniformMatrix4x3fv, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glProgramUniformMatrix4x3fv(GLuint arg0, + GLint arg1, + GLsizei arg2, + GLboolean arg3, + const GLfloat *arg4) { + _pre_call_callback_gl("glProgramUniformMatrix4x3fv", + (void *) glProgramUniformMatrix4x3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glProgramUniformMatrix4x3fv(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glProgramUniformMatrix4x3fv", + (void *) glProgramUniformMatrix4x3fv, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_debug_glProgramUniformMatrix4x3fv = glad_debug_impl_glProgramUniformMatrix4x3fv; PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex; -void APIENTRY glad_debug_impl_glProvokingVertex(GLenum arg0) { - _pre_call_callback_gl("glProvokingVertex", (void*)glProvokingVertex, 1, arg0); - glad_glProvokingVertex(arg0); - _post_call_callback_gl("glProvokingVertex", (void*)glProvokingVertex, 1, arg0); - + +void APIENTRY glad_debug_impl_glProvokingVertex(GLenum arg0) { + _pre_call_callback_gl("glProvokingVertex", (void *) glProvokingVertex, 1, arg0); + glad_glProvokingVertex(arg0); + _post_call_callback_gl("glProvokingVertex", (void *) glProvokingVertex, 1, arg0); + } + PFNGLPROVOKINGVERTEXPROC glad_debug_glProvokingVertex = glad_debug_impl_glProvokingVertex; PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup; -void APIENTRY glad_debug_impl_glPushDebugGroup(GLenum arg0, GLuint arg1, GLsizei arg2, const GLchar * arg3) { - _pre_call_callback_gl("glPushDebugGroup", (void*)glPushDebugGroup, 4, arg0, arg1, arg2, arg3); - glad_glPushDebugGroup(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glPushDebugGroup", (void*)glPushDebugGroup, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glPushDebugGroup(GLenum arg0, GLuint arg1, GLsizei arg2, const GLchar *arg3) { + _pre_call_callback_gl("glPushDebugGroup", (void *) glPushDebugGroup, 4, arg0, arg1, arg2, arg3); + glad_glPushDebugGroup(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glPushDebugGroup", (void *) glPushDebugGroup, 4, arg0, arg1, arg2, arg3); + } + PFNGLPUSHDEBUGGROUPPROC glad_debug_glPushDebugGroup = glad_debug_impl_glPushDebugGroup; PFNGLQUERYCOUNTERPROC glad_glQueryCounter; -void APIENTRY glad_debug_impl_glQueryCounter(GLuint arg0, GLenum arg1) { - _pre_call_callback_gl("glQueryCounter", (void*)glQueryCounter, 2, arg0, arg1); - glad_glQueryCounter(arg0, arg1); - _post_call_callback_gl("glQueryCounter", (void*)glQueryCounter, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glQueryCounter(GLuint arg0, GLenum arg1) { + _pre_call_callback_gl("glQueryCounter", (void *) glQueryCounter, 2, arg0, arg1); + glad_glQueryCounter(arg0, arg1); + _post_call_callback_gl("glQueryCounter", (void *) glQueryCounter, 2, arg0, arg1); + } + PFNGLQUERYCOUNTERPROC glad_debug_glQueryCounter = glad_debug_impl_glQueryCounter; PFNGLREADBUFFERPROC glad_glReadBuffer; -void APIENTRY glad_debug_impl_glReadBuffer(GLenum arg0) { - _pre_call_callback_gl("glReadBuffer", (void*)glReadBuffer, 1, arg0); - glad_glReadBuffer(arg0); - _post_call_callback_gl("glReadBuffer", (void*)glReadBuffer, 1, arg0); - + +void APIENTRY glad_debug_impl_glReadBuffer(GLenum arg0) { + _pre_call_callback_gl("glReadBuffer", (void *) glReadBuffer, 1, arg0); + glad_glReadBuffer(arg0); + _post_call_callback_gl("glReadBuffer", (void *) glReadBuffer, 1, arg0); + } + PFNGLREADBUFFERPROC glad_debug_glReadBuffer = glad_debug_impl_glReadBuffer; PFNGLREADPIXELSPROC glad_glReadPixels; -void APIENTRY glad_debug_impl_glReadPixels(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3, GLenum arg4, GLenum arg5, void * arg6) { - _pre_call_callback_gl("glReadPixels", (void*)glReadPixels, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glReadPixels(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glReadPixels", (void*)glReadPixels, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glReadPixels(GLint arg0, + GLint arg1, + GLsizei arg2, + GLsizei arg3, + GLenum arg4, + GLenum arg5, + void *arg6) { + _pre_call_callback_gl("glReadPixels", (void *) glReadPixels, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + glad_glReadPixels(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glReadPixels", (void *) glReadPixels, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + } + PFNGLREADPIXELSPROC glad_debug_glReadPixels = glad_debug_impl_glReadPixels; PFNGLREADNPIXELSPROC glad_glReadnPixels; -void APIENTRY glad_debug_impl_glReadnPixels(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3, GLenum arg4, GLenum arg5, GLsizei arg6, void * arg7) { - _pre_call_callback_gl("glReadnPixels", (void*)glReadnPixels, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glReadnPixels(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glReadnPixels", (void*)glReadnPixels, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glReadnPixels(GLint arg0, + GLint arg1, + GLsizei arg2, + GLsizei arg3, + GLenum arg4, + GLenum arg5, + GLsizei arg6, + void *arg7) { + _pre_call_callback_gl("glReadnPixels", (void *) glReadnPixels, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + glad_glReadnPixels(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glReadnPixels", (void *) glReadnPixels, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + PFNGLREADNPIXELSPROC glad_debug_glReadnPixels = glad_debug_impl_glReadnPixels; PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler; -void APIENTRY glad_debug_impl_glReleaseShaderCompiler(void) { - _pre_call_callback_gl("glReleaseShaderCompiler", (void*)glReleaseShaderCompiler, 0); - glad_glReleaseShaderCompiler(); - _post_call_callback_gl("glReleaseShaderCompiler", (void*)glReleaseShaderCompiler, 0); - + +void APIENTRY glad_debug_impl_glReleaseShaderCompiler(void) { + _pre_call_callback_gl("glReleaseShaderCompiler", (void *) glReleaseShaderCompiler, 0); + glad_glReleaseShaderCompiler(); + _post_call_callback_gl("glReleaseShaderCompiler", (void *) glReleaseShaderCompiler, 0); + } + PFNGLRELEASESHADERCOMPILERPROC glad_debug_glReleaseShaderCompiler = glad_debug_impl_glReleaseShaderCompiler; PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage; -void APIENTRY glad_debug_impl_glRenderbufferStorage(GLenum arg0, GLenum arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glRenderbufferStorage", (void*)glRenderbufferStorage, 4, arg0, arg1, arg2, arg3); - glad_glRenderbufferStorage(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glRenderbufferStorage", (void*)glRenderbufferStorage, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glRenderbufferStorage(GLenum arg0, GLenum arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glRenderbufferStorage", (void *) glRenderbufferStorage, 4, arg0, arg1, arg2, arg3); + glad_glRenderbufferStorage(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glRenderbufferStorage", (void *) glRenderbufferStorage, 4, arg0, arg1, arg2, arg3); + } + PFNGLRENDERBUFFERSTORAGEPROC glad_debug_glRenderbufferStorage = glad_debug_impl_glRenderbufferStorage; PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample; -void APIENTRY glad_debug_impl_glRenderbufferStorageMultisample(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glRenderbufferStorageMultisample", (void*)glRenderbufferStorageMultisample, 5, arg0, arg1, arg2, arg3, arg4); - glad_glRenderbufferStorageMultisample(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glRenderbufferStorageMultisample", (void*)glRenderbufferStorageMultisample, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glRenderbufferStorageMultisample(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4) { + _pre_call_callback_gl("glRenderbufferStorageMultisample", + (void *) glRenderbufferStorageMultisample, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glRenderbufferStorageMultisample(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glRenderbufferStorageMultisample", + (void *) glRenderbufferStorageMultisample, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_debug_glRenderbufferStorageMultisample = glad_debug_impl_glRenderbufferStorageMultisample; + +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC + glad_debug_glRenderbufferStorageMultisample = glad_debug_impl_glRenderbufferStorageMultisample; PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback; -void APIENTRY glad_debug_impl_glResumeTransformFeedback(void) { - _pre_call_callback_gl("glResumeTransformFeedback", (void*)glResumeTransformFeedback, 0); - glad_glResumeTransformFeedback(); - _post_call_callback_gl("glResumeTransformFeedback", (void*)glResumeTransformFeedback, 0); - + +void APIENTRY glad_debug_impl_glResumeTransformFeedback(void) { + _pre_call_callback_gl("glResumeTransformFeedback", (void *) glResumeTransformFeedback, 0); + glad_glResumeTransformFeedback(); + _post_call_callback_gl("glResumeTransformFeedback", (void *) glResumeTransformFeedback, 0); + } + PFNGLRESUMETRANSFORMFEEDBACKPROC glad_debug_glResumeTransformFeedback = glad_debug_impl_glResumeTransformFeedback; PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage; -void APIENTRY glad_debug_impl_glSampleCoverage(GLfloat arg0, GLboolean arg1) { - _pre_call_callback_gl("glSampleCoverage", (void*)glSampleCoverage, 2, arg0, arg1); - glad_glSampleCoverage(arg0, arg1); - _post_call_callback_gl("glSampleCoverage", (void*)glSampleCoverage, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glSampleCoverage(GLfloat arg0, GLboolean arg1) { + _pre_call_callback_gl("glSampleCoverage", (void *) glSampleCoverage, 2, arg0, arg1); + glad_glSampleCoverage(arg0, arg1); + _post_call_callback_gl("glSampleCoverage", (void *) glSampleCoverage, 2, arg0, arg1); + } + PFNGLSAMPLECOVERAGEPROC glad_debug_glSampleCoverage = glad_debug_impl_glSampleCoverage; PFNGLSAMPLEMASKIPROC glad_glSampleMaski; -void APIENTRY glad_debug_impl_glSampleMaski(GLuint arg0, GLbitfield arg1) { - _pre_call_callback_gl("glSampleMaski", (void*)glSampleMaski, 2, arg0, arg1); - glad_glSampleMaski(arg0, arg1); - _post_call_callback_gl("glSampleMaski", (void*)glSampleMaski, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glSampleMaski(GLuint arg0, GLbitfield arg1) { + _pre_call_callback_gl("glSampleMaski", (void *) glSampleMaski, 2, arg0, arg1); + glad_glSampleMaski(arg0, arg1); + _post_call_callback_gl("glSampleMaski", (void *) glSampleMaski, 2, arg0, arg1); + } + PFNGLSAMPLEMASKIPROC glad_debug_glSampleMaski = glad_debug_impl_glSampleMaski; PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv; -void APIENTRY glad_debug_impl_glSamplerParameterIiv(GLuint arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glSamplerParameterIiv", (void*)glSamplerParameterIiv, 3, arg0, arg1, arg2); - glad_glSamplerParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameterIiv", (void*)glSamplerParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameterIiv(GLuint arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glSamplerParameterIiv", (void *) glSamplerParameterIiv, 3, arg0, arg1, arg2); + glad_glSamplerParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameterIiv", (void *) glSamplerParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERIIVPROC glad_debug_glSamplerParameterIiv = glad_debug_impl_glSamplerParameterIiv; PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv; -void APIENTRY glad_debug_impl_glSamplerParameterIuiv(GLuint arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glSamplerParameterIuiv", (void*)glSamplerParameterIuiv, 3, arg0, arg1, arg2); - glad_glSamplerParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameterIuiv", (void*)glSamplerParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameterIuiv(GLuint arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glSamplerParameterIuiv", (void *) glSamplerParameterIuiv, 3, arg0, arg1, arg2); + glad_glSamplerParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameterIuiv", (void *) glSamplerParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERIUIVPROC glad_debug_glSamplerParameterIuiv = glad_debug_impl_glSamplerParameterIuiv; PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf; -void APIENTRY glad_debug_impl_glSamplerParameterf(GLuint arg0, GLenum arg1, GLfloat arg2) { - _pre_call_callback_gl("glSamplerParameterf", (void*)glSamplerParameterf, 3, arg0, arg1, arg2); - glad_glSamplerParameterf(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameterf", (void*)glSamplerParameterf, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameterf(GLuint arg0, GLenum arg1, GLfloat arg2) { + _pre_call_callback_gl("glSamplerParameterf", (void *) glSamplerParameterf, 3, arg0, arg1, arg2); + glad_glSamplerParameterf(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameterf", (void *) glSamplerParameterf, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERFPROC glad_debug_glSamplerParameterf = glad_debug_impl_glSamplerParameterf; PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv; -void APIENTRY glad_debug_impl_glSamplerParameterfv(GLuint arg0, GLenum arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glSamplerParameterfv", (void*)glSamplerParameterfv, 3, arg0, arg1, arg2); - glad_glSamplerParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameterfv", (void*)glSamplerParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameterfv(GLuint arg0, GLenum arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glSamplerParameterfv", (void *) glSamplerParameterfv, 3, arg0, arg1, arg2); + glad_glSamplerParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameterfv", (void *) glSamplerParameterfv, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERFVPROC glad_debug_glSamplerParameterfv = glad_debug_impl_glSamplerParameterfv; PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri; -void APIENTRY glad_debug_impl_glSamplerParameteri(GLuint arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glSamplerParameteri", (void*)glSamplerParameteri, 3, arg0, arg1, arg2); - glad_glSamplerParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameteri", (void*)glSamplerParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameteri(GLuint arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glSamplerParameteri", (void *) glSamplerParameteri, 3, arg0, arg1, arg2); + glad_glSamplerParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameteri", (void *) glSamplerParameteri, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERIPROC glad_debug_glSamplerParameteri = glad_debug_impl_glSamplerParameteri; PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv; -void APIENTRY glad_debug_impl_glSamplerParameteriv(GLuint arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glSamplerParameteriv", (void*)glSamplerParameteriv, 3, arg0, arg1, arg2); - glad_glSamplerParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glSamplerParameteriv", (void*)glSamplerParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glSamplerParameteriv(GLuint arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glSamplerParameteriv", (void *) glSamplerParameteriv, 3, arg0, arg1, arg2); + glad_glSamplerParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glSamplerParameteriv", (void *) glSamplerParameteriv, 3, arg0, arg1, arg2); + } + PFNGLSAMPLERPARAMETERIVPROC glad_debug_glSamplerParameteriv = glad_debug_impl_glSamplerParameteriv; PFNGLSCISSORPROC glad_glScissor; -void APIENTRY glad_debug_impl_glScissor(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glScissor", (void*)glScissor, 4, arg0, arg1, arg2, arg3); - glad_glScissor(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glScissor", (void*)glScissor, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glScissor(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glScissor", (void *) glScissor, 4, arg0, arg1, arg2, arg3); + glad_glScissor(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glScissor", (void *) glScissor, 4, arg0, arg1, arg2, arg3); + } + PFNGLSCISSORPROC glad_debug_glScissor = glad_debug_impl_glScissor; PFNGLSCISSORARRAYVPROC glad_glScissorArrayv; -void APIENTRY glad_debug_impl_glScissorArrayv(GLuint arg0, GLsizei arg1, const GLint * arg2) { - _pre_call_callback_gl("glScissorArrayv", (void*)glScissorArrayv, 3, arg0, arg1, arg2); - glad_glScissorArrayv(arg0, arg1, arg2); - _post_call_callback_gl("glScissorArrayv", (void*)glScissorArrayv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glScissorArrayv(GLuint arg0, GLsizei arg1, const GLint *arg2) { + _pre_call_callback_gl("glScissorArrayv", (void *) glScissorArrayv, 3, arg0, arg1, arg2); + glad_glScissorArrayv(arg0, arg1, arg2); + _post_call_callback_gl("glScissorArrayv", (void *) glScissorArrayv, 3, arg0, arg1, arg2); + } + PFNGLSCISSORARRAYVPROC glad_debug_glScissorArrayv = glad_debug_impl_glScissorArrayv; PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed; -void APIENTRY glad_debug_impl_glScissorIndexed(GLuint arg0, GLint arg1, GLint arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glScissorIndexed", (void*)glScissorIndexed, 5, arg0, arg1, arg2, arg3, arg4); - glad_glScissorIndexed(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glScissorIndexed", (void*)glScissorIndexed, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glScissorIndexed(GLuint arg0, GLint arg1, GLint arg2, GLsizei arg3, GLsizei arg4) { + _pre_call_callback_gl("glScissorIndexed", (void *) glScissorIndexed, 5, arg0, arg1, arg2, arg3, arg4); + glad_glScissorIndexed(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glScissorIndexed", (void *) glScissorIndexed, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLSCISSORINDEXEDPROC glad_debug_glScissorIndexed = glad_debug_impl_glScissorIndexed; PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv; -void APIENTRY glad_debug_impl_glScissorIndexedv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glScissorIndexedv", (void*)glScissorIndexedv, 2, arg0, arg1); - glad_glScissorIndexedv(arg0, arg1); - _post_call_callback_gl("glScissorIndexedv", (void*)glScissorIndexedv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glScissorIndexedv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glScissorIndexedv", (void *) glScissorIndexedv, 2, arg0, arg1); + glad_glScissorIndexedv(arg0, arg1); + _post_call_callback_gl("glScissorIndexedv", (void *) glScissorIndexedv, 2, arg0, arg1); + } + PFNGLSCISSORINDEXEDVPROC glad_debug_glScissorIndexedv = glad_debug_impl_glScissorIndexedv; PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui; -void APIENTRY glad_debug_impl_glSecondaryColorP3ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glSecondaryColorP3ui", (void*)glSecondaryColorP3ui, 2, arg0, arg1); - glad_glSecondaryColorP3ui(arg0, arg1); - _post_call_callback_gl("glSecondaryColorP3ui", (void*)glSecondaryColorP3ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glSecondaryColorP3ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glSecondaryColorP3ui", (void *) glSecondaryColorP3ui, 2, arg0, arg1); + glad_glSecondaryColorP3ui(arg0, arg1); + _post_call_callback_gl("glSecondaryColorP3ui", (void *) glSecondaryColorP3ui, 2, arg0, arg1); + } + PFNGLSECONDARYCOLORP3UIPROC glad_debug_glSecondaryColorP3ui = glad_debug_impl_glSecondaryColorP3ui; PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv; -void APIENTRY glad_debug_impl_glSecondaryColorP3uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glSecondaryColorP3uiv", (void*)glSecondaryColorP3uiv, 2, arg0, arg1); - glad_glSecondaryColorP3uiv(arg0, arg1); - _post_call_callback_gl("glSecondaryColorP3uiv", (void*)glSecondaryColorP3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glSecondaryColorP3uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glSecondaryColorP3uiv", (void *) glSecondaryColorP3uiv, 2, arg0, arg1); + glad_glSecondaryColorP3uiv(arg0, arg1); + _post_call_callback_gl("glSecondaryColorP3uiv", (void *) glSecondaryColorP3uiv, 2, arg0, arg1); + } + PFNGLSECONDARYCOLORP3UIVPROC glad_debug_glSecondaryColorP3uiv = glad_debug_impl_glSecondaryColorP3uiv; PFNGLSHADERBINARYPROC glad_glShaderBinary; -void APIENTRY glad_debug_impl_glShaderBinary(GLsizei arg0, const GLuint * arg1, GLenum arg2, const void * arg3, GLsizei arg4) { - _pre_call_callback_gl("glShaderBinary", (void*)glShaderBinary, 5, arg0, arg1, arg2, arg3, arg4); - glad_glShaderBinary(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glShaderBinary", (void*)glShaderBinary, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glShaderBinary(GLsizei arg0, + const GLuint *arg1, + GLenum arg2, + const void *arg3, + GLsizei arg4) { + _pre_call_callback_gl("glShaderBinary", (void *) glShaderBinary, 5, arg0, arg1, arg2, arg3, arg4); + glad_glShaderBinary(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glShaderBinary", (void *) glShaderBinary, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLSHADERBINARYPROC glad_debug_glShaderBinary = glad_debug_impl_glShaderBinary; PFNGLSHADERSOURCEPROC glad_glShaderSource; -void APIENTRY glad_debug_impl_glShaderSource(GLuint arg0, GLsizei arg1, const GLchar *const* arg2, const GLint * arg3) { - _pre_call_callback_gl("glShaderSource", (void*)glShaderSource, 4, arg0, arg1, arg2, arg3); - glad_glShaderSource(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glShaderSource", (void*)glShaderSource, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glShaderSource(GLuint arg0, GLsizei arg1, const GLchar *const *arg2, const GLint *arg3) { + _pre_call_callback_gl("glShaderSource", (void *) glShaderSource, 4, arg0, arg1, arg2, arg3); + glad_glShaderSource(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glShaderSource", (void *) glShaderSource, 4, arg0, arg1, arg2, arg3); + } + PFNGLSHADERSOURCEPROC glad_debug_glShaderSource = glad_debug_impl_glShaderSource; PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding; -void APIENTRY glad_debug_impl_glShaderStorageBlockBinding(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glShaderStorageBlockBinding", (void*)glShaderStorageBlockBinding, 3, arg0, arg1, arg2); - glad_glShaderStorageBlockBinding(arg0, arg1, arg2); - _post_call_callback_gl("glShaderStorageBlockBinding", (void*)glShaderStorageBlockBinding, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glShaderStorageBlockBinding(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glShaderStorageBlockBinding", (void *) glShaderStorageBlockBinding, 3, arg0, arg1, arg2); + glad_glShaderStorageBlockBinding(arg0, arg1, arg2); + _post_call_callback_gl("glShaderStorageBlockBinding", (void *) glShaderStorageBlockBinding, 3, arg0, arg1, arg2); + } + PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_debug_glShaderStorageBlockBinding = glad_debug_impl_glShaderStorageBlockBinding; PFNGLSTENCILFUNCPROC glad_glStencilFunc; -void APIENTRY glad_debug_impl_glStencilFunc(GLenum arg0, GLint arg1, GLuint arg2) { - _pre_call_callback_gl("glStencilFunc", (void*)glStencilFunc, 3, arg0, arg1, arg2); - glad_glStencilFunc(arg0, arg1, arg2); - _post_call_callback_gl("glStencilFunc", (void*)glStencilFunc, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glStencilFunc(GLenum arg0, GLint arg1, GLuint arg2) { + _pre_call_callback_gl("glStencilFunc", (void *) glStencilFunc, 3, arg0, arg1, arg2); + glad_glStencilFunc(arg0, arg1, arg2); + _post_call_callback_gl("glStencilFunc", (void *) glStencilFunc, 3, arg0, arg1, arg2); + } + PFNGLSTENCILFUNCPROC glad_debug_glStencilFunc = glad_debug_impl_glStencilFunc; PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate; -void APIENTRY glad_debug_impl_glStencilFuncSeparate(GLenum arg0, GLenum arg1, GLint arg2, GLuint arg3) { - _pre_call_callback_gl("glStencilFuncSeparate", (void*)glStencilFuncSeparate, 4, arg0, arg1, arg2, arg3); - glad_glStencilFuncSeparate(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glStencilFuncSeparate", (void*)glStencilFuncSeparate, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glStencilFuncSeparate(GLenum arg0, GLenum arg1, GLint arg2, GLuint arg3) { + _pre_call_callback_gl("glStencilFuncSeparate", (void *) glStencilFuncSeparate, 4, arg0, arg1, arg2, arg3); + glad_glStencilFuncSeparate(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glStencilFuncSeparate", (void *) glStencilFuncSeparate, 4, arg0, arg1, arg2, arg3); + } + PFNGLSTENCILFUNCSEPARATEPROC glad_debug_glStencilFuncSeparate = glad_debug_impl_glStencilFuncSeparate; PFNGLSTENCILMASKPROC glad_glStencilMask; -void APIENTRY glad_debug_impl_glStencilMask(GLuint arg0) { - _pre_call_callback_gl("glStencilMask", (void*)glStencilMask, 1, arg0); - glad_glStencilMask(arg0); - _post_call_callback_gl("glStencilMask", (void*)glStencilMask, 1, arg0); - + +void APIENTRY glad_debug_impl_glStencilMask(GLuint arg0) { + _pre_call_callback_gl("glStencilMask", (void *) glStencilMask, 1, arg0); + glad_glStencilMask(arg0); + _post_call_callback_gl("glStencilMask", (void *) glStencilMask, 1, arg0); + } + PFNGLSTENCILMASKPROC glad_debug_glStencilMask = glad_debug_impl_glStencilMask; PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate; -void APIENTRY glad_debug_impl_glStencilMaskSeparate(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glStencilMaskSeparate", (void*)glStencilMaskSeparate, 2, arg0, arg1); - glad_glStencilMaskSeparate(arg0, arg1); - _post_call_callback_gl("glStencilMaskSeparate", (void*)glStencilMaskSeparate, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glStencilMaskSeparate(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glStencilMaskSeparate", (void *) glStencilMaskSeparate, 2, arg0, arg1); + glad_glStencilMaskSeparate(arg0, arg1); + _post_call_callback_gl("glStencilMaskSeparate", (void *) glStencilMaskSeparate, 2, arg0, arg1); + } + PFNGLSTENCILMASKSEPARATEPROC glad_debug_glStencilMaskSeparate = glad_debug_impl_glStencilMaskSeparate; PFNGLSTENCILOPPROC glad_glStencilOp; -void APIENTRY glad_debug_impl_glStencilOp(GLenum arg0, GLenum arg1, GLenum arg2) { - _pre_call_callback_gl("glStencilOp", (void*)glStencilOp, 3, arg0, arg1, arg2); - glad_glStencilOp(arg0, arg1, arg2); - _post_call_callback_gl("glStencilOp", (void*)glStencilOp, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glStencilOp(GLenum arg0, GLenum arg1, GLenum arg2) { + _pre_call_callback_gl("glStencilOp", (void *) glStencilOp, 3, arg0, arg1, arg2); + glad_glStencilOp(arg0, arg1, arg2); + _post_call_callback_gl("glStencilOp", (void *) glStencilOp, 3, arg0, arg1, arg2); + } + PFNGLSTENCILOPPROC glad_debug_glStencilOp = glad_debug_impl_glStencilOp; PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate; -void APIENTRY glad_debug_impl_glStencilOpSeparate(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3) { - _pre_call_callback_gl("glStencilOpSeparate", (void*)glStencilOpSeparate, 4, arg0, arg1, arg2, arg3); - glad_glStencilOpSeparate(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glStencilOpSeparate", (void*)glStencilOpSeparate, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glStencilOpSeparate(GLenum arg0, GLenum arg1, GLenum arg2, GLenum arg3) { + _pre_call_callback_gl("glStencilOpSeparate", (void *) glStencilOpSeparate, 4, arg0, arg1, arg2, arg3); + glad_glStencilOpSeparate(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glStencilOpSeparate", (void *) glStencilOpSeparate, 4, arg0, arg1, arg2, arg3); + } + PFNGLSTENCILOPSEPARATEPROC glad_debug_glStencilOpSeparate = glad_debug_impl_glStencilOpSeparate; PFNGLTEXBUFFERPROC glad_glTexBuffer; -void APIENTRY glad_debug_impl_glTexBuffer(GLenum arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glTexBuffer", (void*)glTexBuffer, 3, arg0, arg1, arg2); - glad_glTexBuffer(arg0, arg1, arg2); - _post_call_callback_gl("glTexBuffer", (void*)glTexBuffer, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexBuffer(GLenum arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glTexBuffer", (void *) glTexBuffer, 3, arg0, arg1, arg2); + glad_glTexBuffer(arg0, arg1, arg2); + _post_call_callback_gl("glTexBuffer", (void *) glTexBuffer, 3, arg0, arg1, arg2); + } + PFNGLTEXBUFFERPROC glad_debug_glTexBuffer = glad_debug_impl_glTexBuffer; PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange; -void APIENTRY glad_debug_impl_glTexBufferRange(GLenum arg0, GLenum arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glTexBufferRange", (void*)glTexBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - glad_glTexBufferRange(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glTexBufferRange", (void*)glTexBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glTexBufferRange(GLenum arg0, GLenum arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { + _pre_call_callback_gl("glTexBufferRange", (void *) glTexBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + glad_glTexBufferRange(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glTexBufferRange", (void *) glTexBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLTEXBUFFERRANGEPROC glad_debug_glTexBufferRange = glad_debug_impl_glTexBufferRange; PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui; -void APIENTRY glad_debug_impl_glTexCoordP1ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glTexCoordP1ui", (void*)glTexCoordP1ui, 2, arg0, arg1); - glad_glTexCoordP1ui(arg0, arg1); - _post_call_callback_gl("glTexCoordP1ui", (void*)glTexCoordP1ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP1ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glTexCoordP1ui", (void *) glTexCoordP1ui, 2, arg0, arg1); + glad_glTexCoordP1ui(arg0, arg1); + _post_call_callback_gl("glTexCoordP1ui", (void *) glTexCoordP1ui, 2, arg0, arg1); + } + PFNGLTEXCOORDP1UIPROC glad_debug_glTexCoordP1ui = glad_debug_impl_glTexCoordP1ui; PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv; -void APIENTRY glad_debug_impl_glTexCoordP1uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glTexCoordP1uiv", (void*)glTexCoordP1uiv, 2, arg0, arg1); - glad_glTexCoordP1uiv(arg0, arg1); - _post_call_callback_gl("glTexCoordP1uiv", (void*)glTexCoordP1uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP1uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glTexCoordP1uiv", (void *) glTexCoordP1uiv, 2, arg0, arg1); + glad_glTexCoordP1uiv(arg0, arg1); + _post_call_callback_gl("glTexCoordP1uiv", (void *) glTexCoordP1uiv, 2, arg0, arg1); + } + PFNGLTEXCOORDP1UIVPROC glad_debug_glTexCoordP1uiv = glad_debug_impl_glTexCoordP1uiv; PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui; -void APIENTRY glad_debug_impl_glTexCoordP2ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glTexCoordP2ui", (void*)glTexCoordP2ui, 2, arg0, arg1); - glad_glTexCoordP2ui(arg0, arg1); - _post_call_callback_gl("glTexCoordP2ui", (void*)glTexCoordP2ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP2ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glTexCoordP2ui", (void *) glTexCoordP2ui, 2, arg0, arg1); + glad_glTexCoordP2ui(arg0, arg1); + _post_call_callback_gl("glTexCoordP2ui", (void *) glTexCoordP2ui, 2, arg0, arg1); + } + PFNGLTEXCOORDP2UIPROC glad_debug_glTexCoordP2ui = glad_debug_impl_glTexCoordP2ui; PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv; -void APIENTRY glad_debug_impl_glTexCoordP2uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glTexCoordP2uiv", (void*)glTexCoordP2uiv, 2, arg0, arg1); - glad_glTexCoordP2uiv(arg0, arg1); - _post_call_callback_gl("glTexCoordP2uiv", (void*)glTexCoordP2uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP2uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glTexCoordP2uiv", (void *) glTexCoordP2uiv, 2, arg0, arg1); + glad_glTexCoordP2uiv(arg0, arg1); + _post_call_callback_gl("glTexCoordP2uiv", (void *) glTexCoordP2uiv, 2, arg0, arg1); + } + PFNGLTEXCOORDP2UIVPROC glad_debug_glTexCoordP2uiv = glad_debug_impl_glTexCoordP2uiv; PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui; -void APIENTRY glad_debug_impl_glTexCoordP3ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glTexCoordP3ui", (void*)glTexCoordP3ui, 2, arg0, arg1); - glad_glTexCoordP3ui(arg0, arg1); - _post_call_callback_gl("glTexCoordP3ui", (void*)glTexCoordP3ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP3ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glTexCoordP3ui", (void *) glTexCoordP3ui, 2, arg0, arg1); + glad_glTexCoordP3ui(arg0, arg1); + _post_call_callback_gl("glTexCoordP3ui", (void *) glTexCoordP3ui, 2, arg0, arg1); + } + PFNGLTEXCOORDP3UIPROC glad_debug_glTexCoordP3ui = glad_debug_impl_glTexCoordP3ui; PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv; -void APIENTRY glad_debug_impl_glTexCoordP3uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glTexCoordP3uiv", (void*)glTexCoordP3uiv, 2, arg0, arg1); - glad_glTexCoordP3uiv(arg0, arg1); - _post_call_callback_gl("glTexCoordP3uiv", (void*)glTexCoordP3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP3uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glTexCoordP3uiv", (void *) glTexCoordP3uiv, 2, arg0, arg1); + glad_glTexCoordP3uiv(arg0, arg1); + _post_call_callback_gl("glTexCoordP3uiv", (void *) glTexCoordP3uiv, 2, arg0, arg1); + } + PFNGLTEXCOORDP3UIVPROC glad_debug_glTexCoordP3uiv = glad_debug_impl_glTexCoordP3uiv; PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui; -void APIENTRY glad_debug_impl_glTexCoordP4ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glTexCoordP4ui", (void*)glTexCoordP4ui, 2, arg0, arg1); - glad_glTexCoordP4ui(arg0, arg1); - _post_call_callback_gl("glTexCoordP4ui", (void*)glTexCoordP4ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP4ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glTexCoordP4ui", (void *) glTexCoordP4ui, 2, arg0, arg1); + glad_glTexCoordP4ui(arg0, arg1); + _post_call_callback_gl("glTexCoordP4ui", (void *) glTexCoordP4ui, 2, arg0, arg1); + } + PFNGLTEXCOORDP4UIPROC glad_debug_glTexCoordP4ui = glad_debug_impl_glTexCoordP4ui; PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv; -void APIENTRY glad_debug_impl_glTexCoordP4uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glTexCoordP4uiv", (void*)glTexCoordP4uiv, 2, arg0, arg1); - glad_glTexCoordP4uiv(arg0, arg1); - _post_call_callback_gl("glTexCoordP4uiv", (void*)glTexCoordP4uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glTexCoordP4uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glTexCoordP4uiv", (void *) glTexCoordP4uiv, 2, arg0, arg1); + glad_glTexCoordP4uiv(arg0, arg1); + _post_call_callback_gl("glTexCoordP4uiv", (void *) glTexCoordP4uiv, 2, arg0, arg1); + } + PFNGLTEXCOORDP4UIVPROC glad_debug_glTexCoordP4uiv = glad_debug_impl_glTexCoordP4uiv; PFNGLTEXIMAGE1DPROC glad_glTexImage1D; -void APIENTRY glad_debug_impl_glTexImage1D(GLenum arg0, GLint arg1, GLint arg2, GLsizei arg3, GLint arg4, GLenum arg5, GLenum arg6, const void * arg7) { - _pre_call_callback_gl("glTexImage1D", (void*)glTexImage1D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glTexImage1D", (void*)glTexImage1D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glTexImage1D(GLenum arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLint arg4, + GLenum arg5, + GLenum arg6, + const void *arg7) { + _pre_call_callback_gl("glTexImage1D", (void *) glTexImage1D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + glad_glTexImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glTexImage1D", (void *) glTexImage1D, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + PFNGLTEXIMAGE1DPROC glad_debug_glTexImage1D = glad_debug_impl_glTexImage1D; PFNGLTEXIMAGE2DPROC glad_glTexImage2D; -void APIENTRY glad_debug_impl_glTexImage2D(GLenum arg0, GLint arg1, GLint arg2, GLsizei arg3, GLsizei arg4, GLint arg5, GLenum arg6, GLenum arg7, const void * arg8) { - _pre_call_callback_gl("glTexImage2D", (void*)glTexImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glTexImage2D", (void*)glTexImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glTexImage2D(GLenum arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLsizei arg4, + GLint arg5, + GLenum arg6, + GLenum arg7, + const void *arg8) { + _pre_call_callback_gl("glTexImage2D", + (void *) glTexImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glTexImage2D", + (void *) glTexImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLTEXIMAGE2DPROC glad_debug_glTexImage2D = glad_debug_impl_glTexImage2D; PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample; -void APIENTRY glad_debug_impl_glTexImage2DMultisample(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLboolean arg5) { - _pre_call_callback_gl("glTexImage2DMultisample", (void*)glTexImage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glTexImage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glTexImage2DMultisample", (void*)glTexImage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glTexImage2DMultisample(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLboolean arg5) { + _pre_call_callback_gl("glTexImage2DMultisample", + (void *) glTexImage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glTexImage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glTexImage2DMultisample", + (void *) glTexImage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_debug_glTexImage2DMultisample = glad_debug_impl_glTexImage2DMultisample; PFNGLTEXIMAGE3DPROC glad_glTexImage3D; -void APIENTRY glad_debug_impl_glTexImage3D(GLenum arg0, GLint arg1, GLint arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5, GLint arg6, GLenum arg7, GLenum arg8, const void * arg9) { - _pre_call_callback_gl("glTexImage3D", (void*)glTexImage3D, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - glad_glTexImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - _post_call_callback_gl("glTexImage3D", (void*)glTexImage3D, 10, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - + +void APIENTRY glad_debug_impl_glTexImage3D(GLenum arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5, + GLint arg6, + GLenum arg7, + GLenum arg8, + const void *arg9) { + _pre_call_callback_gl("glTexImage3D", + (void *) glTexImage3D, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + glad_glTexImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + _post_call_callback_gl("glTexImage3D", + (void *) glTexImage3D, + 10, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + } + PFNGLTEXIMAGE3DPROC glad_debug_glTexImage3D = glad_debug_impl_glTexImage3D; PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample; -void APIENTRY glad_debug_impl_glTexImage3DMultisample(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5, GLboolean arg6) { - _pre_call_callback_gl("glTexImage3DMultisample", (void*)glTexImage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glTexImage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glTexImage3DMultisample", (void*)glTexImage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glTexImage3DMultisample(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5, + GLboolean arg6) { + _pre_call_callback_gl("glTexImage3DMultisample", + (void *) glTexImage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glTexImage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glTexImage3DMultisample", + (void *) glTexImage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_debug_glTexImage3DMultisample = glad_debug_impl_glTexImage3DMultisample; PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv; -void APIENTRY glad_debug_impl_glTexParameterIiv(GLenum arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glTexParameterIiv", (void*)glTexParameterIiv, 3, arg0, arg1, arg2); - glad_glTexParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameterIiv", (void*)glTexParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameterIiv(GLenum arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glTexParameterIiv", (void *) glTexParameterIiv, 3, arg0, arg1, arg2); + glad_glTexParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameterIiv", (void *) glTexParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERIIVPROC glad_debug_glTexParameterIiv = glad_debug_impl_glTexParameterIiv; PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv; -void APIENTRY glad_debug_impl_glTexParameterIuiv(GLenum arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glTexParameterIuiv", (void*)glTexParameterIuiv, 3, arg0, arg1, arg2); - glad_glTexParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameterIuiv", (void*)glTexParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameterIuiv(GLenum arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glTexParameterIuiv", (void *) glTexParameterIuiv, 3, arg0, arg1, arg2); + glad_glTexParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameterIuiv", (void *) glTexParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERIUIVPROC glad_debug_glTexParameterIuiv = glad_debug_impl_glTexParameterIuiv; PFNGLTEXPARAMETERFPROC glad_glTexParameterf; -void APIENTRY glad_debug_impl_glTexParameterf(GLenum arg0, GLenum arg1, GLfloat arg2) { - _pre_call_callback_gl("glTexParameterf", (void*)glTexParameterf, 3, arg0, arg1, arg2); - glad_glTexParameterf(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameterf", (void*)glTexParameterf, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameterf(GLenum arg0, GLenum arg1, GLfloat arg2) { + _pre_call_callback_gl("glTexParameterf", (void *) glTexParameterf, 3, arg0, arg1, arg2); + glad_glTexParameterf(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameterf", (void *) glTexParameterf, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERFPROC glad_debug_glTexParameterf = glad_debug_impl_glTexParameterf; PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv; -void APIENTRY glad_debug_impl_glTexParameterfv(GLenum arg0, GLenum arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glTexParameterfv", (void*)glTexParameterfv, 3, arg0, arg1, arg2); - glad_glTexParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameterfv", (void*)glTexParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameterfv(GLenum arg0, GLenum arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glTexParameterfv", (void *) glTexParameterfv, 3, arg0, arg1, arg2); + glad_glTexParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameterfv", (void *) glTexParameterfv, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERFVPROC glad_debug_glTexParameterfv = glad_debug_impl_glTexParameterfv; PFNGLTEXPARAMETERIPROC glad_glTexParameteri; -void APIENTRY glad_debug_impl_glTexParameteri(GLenum arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glTexParameteri", (void*)glTexParameteri, 3, arg0, arg1, arg2); - glad_glTexParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameteri", (void*)glTexParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameteri(GLenum arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glTexParameteri", (void *) glTexParameteri, 3, arg0, arg1, arg2); + glad_glTexParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameteri", (void *) glTexParameteri, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERIPROC glad_debug_glTexParameteri = glad_debug_impl_glTexParameteri; PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv; -void APIENTRY glad_debug_impl_glTexParameteriv(GLenum arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glTexParameteriv", (void*)glTexParameteriv, 3, arg0, arg1, arg2); - glad_glTexParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glTexParameteriv", (void*)glTexParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTexParameteriv(GLenum arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glTexParameteriv", (void *) glTexParameteriv, 3, arg0, arg1, arg2); + glad_glTexParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glTexParameteriv", (void *) glTexParameteriv, 3, arg0, arg1, arg2); + } + PFNGLTEXPARAMETERIVPROC glad_debug_glTexParameteriv = glad_debug_impl_glTexParameteriv; PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D; -void APIENTRY glad_debug_impl_glTexStorage1D(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3) { - _pre_call_callback_gl("glTexStorage1D", (void*)glTexStorage1D, 4, arg0, arg1, arg2, arg3); - glad_glTexStorage1D(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glTexStorage1D", (void*)glTexStorage1D, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glTexStorage1D(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3) { + _pre_call_callback_gl("glTexStorage1D", (void *) glTexStorage1D, 4, arg0, arg1, arg2, arg3); + glad_glTexStorage1D(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glTexStorage1D", (void *) glTexStorage1D, 4, arg0, arg1, arg2, arg3); + } + PFNGLTEXSTORAGE1DPROC glad_debug_glTexStorage1D = glad_debug_impl_glTexStorage1D; PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D; -void APIENTRY glad_debug_impl_glTexStorage2D(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glTexStorage2D", (void*)glTexStorage2D, 5, arg0, arg1, arg2, arg3, arg4); - glad_glTexStorage2D(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glTexStorage2D", (void*)glTexStorage2D, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glTexStorage2D(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { + _pre_call_callback_gl("glTexStorage2D", (void *) glTexStorage2D, 5, arg0, arg1, arg2, arg3, arg4); + glad_glTexStorage2D(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glTexStorage2D", (void *) glTexStorage2D, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLTEXSTORAGE2DPROC glad_debug_glTexStorage2D = glad_debug_impl_glTexStorage2D; PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample; -void APIENTRY glad_debug_impl_glTexStorage2DMultisample(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLboolean arg5) { - _pre_call_callback_gl("glTexStorage2DMultisample", (void*)glTexStorage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glTexStorage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glTexStorage2DMultisample", (void*)glTexStorage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glTexStorage2DMultisample(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLboolean arg5) { + _pre_call_callback_gl("glTexStorage2DMultisample", + (void *) glTexStorage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glTexStorage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glTexStorage2DMultisample", + (void *) glTexStorage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_debug_glTexStorage2DMultisample = glad_debug_impl_glTexStorage2DMultisample; PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D; -void APIENTRY glad_debug_impl_glTexStorage3D(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5) { - _pre_call_callback_gl("glTexStorage3D", (void*)glTexStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glTexStorage3D(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glTexStorage3D", (void*)glTexStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glTexStorage3D(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5) { + _pre_call_callback_gl("glTexStorage3D", (void *) glTexStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glTexStorage3D(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glTexStorage3D", (void *) glTexStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLTEXSTORAGE3DPROC glad_debug_glTexStorage3D = glad_debug_impl_glTexStorage3D; PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample; -void APIENTRY glad_debug_impl_glTexStorage3DMultisample(GLenum arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5, GLboolean arg6) { - _pre_call_callback_gl("glTexStorage3DMultisample", (void*)glTexStorage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glTexStorage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glTexStorage3DMultisample", (void*)glTexStorage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glTexStorage3DMultisample(GLenum arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5, + GLboolean arg6) { + _pre_call_callback_gl("glTexStorage3DMultisample", + (void *) glTexStorage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glTexStorage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glTexStorage3DMultisample", + (void *) glTexStorage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_debug_glTexStorage3DMultisample = glad_debug_impl_glTexStorage3DMultisample; PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D; -void APIENTRY glad_debug_impl_glTexSubImage1D(GLenum arg0, GLint arg1, GLint arg2, GLsizei arg3, GLenum arg4, GLenum arg5, const void * arg6) { - _pre_call_callback_gl("glTexSubImage1D", (void*)glTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glTexSubImage1D", (void*)glTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glTexSubImage1D(GLenum arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLenum arg4, + GLenum arg5, + const void *arg6) { + _pre_call_callback_gl("glTexSubImage1D", (void *) glTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + glad_glTexSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glTexSubImage1D", (void *) glTexSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + } + PFNGLTEXSUBIMAGE1DPROC glad_debug_glTexSubImage1D = glad_debug_impl_glTexSubImage1D; PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D; -void APIENTRY glad_debug_impl_glTexSubImage2D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLsizei arg4, GLsizei arg5, GLenum arg6, GLenum arg7, const void * arg8) { - _pre_call_callback_gl("glTexSubImage2D", (void*)glTexSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glTexSubImage2D", (void*)glTexSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glTexSubImage2D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLsizei arg4, + GLsizei arg5, + GLenum arg6, + GLenum arg7, + const void *arg8) { + _pre_call_callback_gl("glTexSubImage2D", + (void *) glTexSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glTexSubImage2D", + (void *) glTexSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLTEXSUBIMAGE2DPROC glad_debug_glTexSubImage2D = glad_debug_impl_glTexSubImage2D; PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D; -void APIENTRY glad_debug_impl_glTexSubImage3D(GLenum arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLenum arg9, const void * arg10) { - _pre_call_callback_gl("glTexSubImage3D", (void*)glTexSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - glad_glTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - _post_call_callback_gl("glTexSubImage3D", (void*)glTexSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - + +void APIENTRY glad_debug_impl_glTexSubImage3D(GLenum arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLenum arg9, + const void *arg10) { + _pre_call_callback_gl("glTexSubImage3D", + (void *) glTexSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + glad_glTexSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + _post_call_callback_gl("glTexSubImage3D", + (void *) glTexSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } + PFNGLTEXSUBIMAGE3DPROC glad_debug_glTexSubImage3D = glad_debug_impl_glTexSubImage3D; PFNGLTEXTUREBARRIERPROC glad_glTextureBarrier; -void APIENTRY glad_debug_impl_glTextureBarrier(void) { - _pre_call_callback_gl("glTextureBarrier", (void*)glTextureBarrier, 0); - glad_glTextureBarrier(); - _post_call_callback_gl("glTextureBarrier", (void*)glTextureBarrier, 0); - + +void APIENTRY glad_debug_impl_glTextureBarrier(void) { + _pre_call_callback_gl("glTextureBarrier", (void *) glTextureBarrier, 0); + glad_glTextureBarrier(); + _post_call_callback_gl("glTextureBarrier", (void *) glTextureBarrier, 0); + } + PFNGLTEXTUREBARRIERPROC glad_debug_glTextureBarrier = glad_debug_impl_glTextureBarrier; PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer; -void APIENTRY glad_debug_impl_glTextureBuffer(GLuint arg0, GLenum arg1, GLuint arg2) { - _pre_call_callback_gl("glTextureBuffer", (void*)glTextureBuffer, 3, arg0, arg1, arg2); - glad_glTextureBuffer(arg0, arg1, arg2); - _post_call_callback_gl("glTextureBuffer", (void*)glTextureBuffer, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureBuffer(GLuint arg0, GLenum arg1, GLuint arg2) { + _pre_call_callback_gl("glTextureBuffer", (void *) glTextureBuffer, 3, arg0, arg1, arg2); + glad_glTextureBuffer(arg0, arg1, arg2); + _post_call_callback_gl("glTextureBuffer", (void *) glTextureBuffer, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREBUFFERPROC glad_debug_glTextureBuffer = glad_debug_impl_glTextureBuffer; PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange; -void APIENTRY glad_debug_impl_glTextureBufferRange(GLuint arg0, GLenum arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glTextureBufferRange", (void*)glTextureBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - glad_glTextureBufferRange(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glTextureBufferRange", (void*)glTextureBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glTextureBufferRange(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLintptr arg3, + GLsizeiptr arg4) { + _pre_call_callback_gl("glTextureBufferRange", (void *) glTextureBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + glad_glTextureBufferRange(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glTextureBufferRange", (void *) glTextureBufferRange, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLTEXTUREBUFFERRANGEPROC glad_debug_glTextureBufferRange = glad_debug_impl_glTextureBufferRange; PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv; -void APIENTRY glad_debug_impl_glTextureParameterIiv(GLuint arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glTextureParameterIiv", (void*)glTextureParameterIiv, 3, arg0, arg1, arg2); - glad_glTextureParameterIiv(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameterIiv", (void*)glTextureParameterIiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameterIiv(GLuint arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glTextureParameterIiv", (void *) glTextureParameterIiv, 3, arg0, arg1, arg2); + glad_glTextureParameterIiv(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameterIiv", (void *) glTextureParameterIiv, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERIIVPROC glad_debug_glTextureParameterIiv = glad_debug_impl_glTextureParameterIiv; PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv; -void APIENTRY glad_debug_impl_glTextureParameterIuiv(GLuint arg0, GLenum arg1, const GLuint * arg2) { - _pre_call_callback_gl("glTextureParameterIuiv", (void*)glTextureParameterIuiv, 3, arg0, arg1, arg2); - glad_glTextureParameterIuiv(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameterIuiv", (void*)glTextureParameterIuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameterIuiv(GLuint arg0, GLenum arg1, const GLuint *arg2) { + _pre_call_callback_gl("glTextureParameterIuiv", (void *) glTextureParameterIuiv, 3, arg0, arg1, arg2); + glad_glTextureParameterIuiv(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameterIuiv", (void *) glTextureParameterIuiv, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERIUIVPROC glad_debug_glTextureParameterIuiv = glad_debug_impl_glTextureParameterIuiv; PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf; -void APIENTRY glad_debug_impl_glTextureParameterf(GLuint arg0, GLenum arg1, GLfloat arg2) { - _pre_call_callback_gl("glTextureParameterf", (void*)glTextureParameterf, 3, arg0, arg1, arg2); - glad_glTextureParameterf(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameterf", (void*)glTextureParameterf, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameterf(GLuint arg0, GLenum arg1, GLfloat arg2) { + _pre_call_callback_gl("glTextureParameterf", (void *) glTextureParameterf, 3, arg0, arg1, arg2); + glad_glTextureParameterf(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameterf", (void *) glTextureParameterf, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERFPROC glad_debug_glTextureParameterf = glad_debug_impl_glTextureParameterf; PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv; -void APIENTRY glad_debug_impl_glTextureParameterfv(GLuint arg0, GLenum arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glTextureParameterfv", (void*)glTextureParameterfv, 3, arg0, arg1, arg2); - glad_glTextureParameterfv(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameterfv", (void*)glTextureParameterfv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameterfv(GLuint arg0, GLenum arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glTextureParameterfv", (void *) glTextureParameterfv, 3, arg0, arg1, arg2); + glad_glTextureParameterfv(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameterfv", (void *) glTextureParameterfv, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERFVPROC glad_debug_glTextureParameterfv = glad_debug_impl_glTextureParameterfv; PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri; -void APIENTRY glad_debug_impl_glTextureParameteri(GLuint arg0, GLenum arg1, GLint arg2) { - _pre_call_callback_gl("glTextureParameteri", (void*)glTextureParameteri, 3, arg0, arg1, arg2); - glad_glTextureParameteri(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameteri", (void*)glTextureParameteri, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameteri(GLuint arg0, GLenum arg1, GLint arg2) { + _pre_call_callback_gl("glTextureParameteri", (void *) glTextureParameteri, 3, arg0, arg1, arg2); + glad_glTextureParameteri(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameteri", (void *) glTextureParameteri, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERIPROC glad_debug_glTextureParameteri = glad_debug_impl_glTextureParameteri; PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv; -void APIENTRY glad_debug_impl_glTextureParameteriv(GLuint arg0, GLenum arg1, const GLint * arg2) { - _pre_call_callback_gl("glTextureParameteriv", (void*)glTextureParameteriv, 3, arg0, arg1, arg2); - glad_glTextureParameteriv(arg0, arg1, arg2); - _post_call_callback_gl("glTextureParameteriv", (void*)glTextureParameteriv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTextureParameteriv(GLuint arg0, GLenum arg1, const GLint *arg2) { + _pre_call_callback_gl("glTextureParameteriv", (void *) glTextureParameteriv, 3, arg0, arg1, arg2); + glad_glTextureParameteriv(arg0, arg1, arg2); + _post_call_callback_gl("glTextureParameteriv", (void *) glTextureParameteriv, 3, arg0, arg1, arg2); + } + PFNGLTEXTUREPARAMETERIVPROC glad_debug_glTextureParameteriv = glad_debug_impl_glTextureParameteriv; PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D; -void APIENTRY glad_debug_impl_glTextureStorage1D(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3) { - _pre_call_callback_gl("glTextureStorage1D", (void*)glTextureStorage1D, 4, arg0, arg1, arg2, arg3); - glad_glTextureStorage1D(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glTextureStorage1D", (void*)glTextureStorage1D, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glTextureStorage1D(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3) { + _pre_call_callback_gl("glTextureStorage1D", (void *) glTextureStorage1D, 4, arg0, arg1, arg2, arg3); + glad_glTextureStorage1D(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glTextureStorage1D", (void *) glTextureStorage1D, 4, arg0, arg1, arg2, arg3); + } + PFNGLTEXTURESTORAGE1DPROC glad_debug_glTextureStorage1D = glad_debug_impl_glTextureStorage1D; PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D; -void APIENTRY glad_debug_impl_glTextureStorage2D(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { - _pre_call_callback_gl("glTextureStorage2D", (void*)glTextureStorage2D, 5, arg0, arg1, arg2, arg3, arg4); - glad_glTextureStorage2D(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glTextureStorage2D", (void*)glTextureStorage2D, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glTextureStorage2D(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4) { + _pre_call_callback_gl("glTextureStorage2D", (void *) glTextureStorage2D, 5, arg0, arg1, arg2, arg3, arg4); + glad_glTextureStorage2D(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glTextureStorage2D", (void *) glTextureStorage2D, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLTEXTURESTORAGE2DPROC glad_debug_glTextureStorage2D = glad_debug_impl_glTextureStorage2D; PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample; -void APIENTRY glad_debug_impl_glTextureStorage2DMultisample(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLboolean arg5) { - _pre_call_callback_gl("glTextureStorage2DMultisample", (void*)glTextureStorage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glTextureStorage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glTextureStorage2DMultisample", (void*)glTextureStorage2DMultisample, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glTextureStorage2DMultisample(GLuint arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLboolean arg5) { + _pre_call_callback_gl("glTextureStorage2DMultisample", + (void *) glTextureStorage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glTextureStorage2DMultisample(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glTextureStorage2DMultisample", + (void *) glTextureStorage2DMultisample, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } -PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_debug_glTextureStorage2DMultisample = glad_debug_impl_glTextureStorage2DMultisample; + +PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC + glad_debug_glTextureStorage2DMultisample = glad_debug_impl_glTextureStorage2DMultisample; PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D; -void APIENTRY glad_debug_impl_glTextureStorage3D(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5) { - _pre_call_callback_gl("glTextureStorage3D", (void*)glTextureStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glTextureStorage3D(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glTextureStorage3D", (void*)glTextureStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glTextureStorage3D(GLuint arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5) { + _pre_call_callback_gl("glTextureStorage3D", (void *) glTextureStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + glad_glTextureStorage3D(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glTextureStorage3D", (void *) glTextureStorage3D, 6, arg0, arg1, arg2, arg3, arg4, arg5); + } + PFNGLTEXTURESTORAGE3DPROC glad_debug_glTextureStorage3D = glad_debug_impl_glTextureStorage3D; PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample; -void APIENTRY glad_debug_impl_glTextureStorage3DMultisample(GLuint arg0, GLsizei arg1, GLenum arg2, GLsizei arg3, GLsizei arg4, GLsizei arg5, GLboolean arg6) { - _pre_call_callback_gl("glTextureStorage3DMultisample", (void*)glTextureStorage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glTextureStorage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glTextureStorage3DMultisample", (void*)glTextureStorage3DMultisample, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glTextureStorage3DMultisample(GLuint arg0, + GLsizei arg1, + GLenum arg2, + GLsizei arg3, + GLsizei arg4, + GLsizei arg5, + GLboolean arg6) { + _pre_call_callback_gl("glTextureStorage3DMultisample", + (void *) glTextureStorage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glTextureStorage3DMultisample(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glTextureStorage3DMultisample", + (void *) glTextureStorage3DMultisample, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } -PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_debug_glTextureStorage3DMultisample = glad_debug_impl_glTextureStorage3DMultisample; + +PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC + glad_debug_glTextureStorage3DMultisample = glad_debug_impl_glTextureStorage3DMultisample; PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D; -void APIENTRY glad_debug_impl_glTextureSubImage1D(GLuint arg0, GLint arg1, GLint arg2, GLsizei arg3, GLenum arg4, GLenum arg5, const void * arg6) { - _pre_call_callback_gl("glTextureSubImage1D", (void*)glTextureSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - glad_glTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - _post_call_callback_gl("glTextureSubImage1D", (void*)glTextureSubImage1D, 7, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - + +void APIENTRY glad_debug_impl_glTextureSubImage1D(GLuint arg0, + GLint arg1, + GLint arg2, + GLsizei arg3, + GLenum arg4, + GLenum arg5, + const void *arg6) { + _pre_call_callback_gl("glTextureSubImage1D", + (void *) glTextureSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + glad_glTextureSubImage1D(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + _post_call_callback_gl("glTextureSubImage1D", + (void *) glTextureSubImage1D, + 7, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } + PFNGLTEXTURESUBIMAGE1DPROC glad_debug_glTextureSubImage1D = glad_debug_impl_glTextureSubImage1D; PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D; -void APIENTRY glad_debug_impl_glTextureSubImage2D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLsizei arg4, GLsizei arg5, GLenum arg6, GLenum arg7, const void * arg8) { - _pre_call_callback_gl("glTextureSubImage2D", (void*)glTextureSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - glad_glTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - _post_call_callback_gl("glTextureSubImage2D", (void*)glTextureSubImage2D, 9, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - + +void APIENTRY glad_debug_impl_glTextureSubImage2D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLsizei arg4, + GLsizei arg5, + GLenum arg6, + GLenum arg7, + const void *arg8) { + _pre_call_callback_gl("glTextureSubImage2D", + (void *) glTextureSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + glad_glTextureSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + _post_call_callback_gl("glTextureSubImage2D", + (void *) glTextureSubImage2D, + 9, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } + PFNGLTEXTURESUBIMAGE2DPROC glad_debug_glTextureSubImage2D = glad_debug_impl_glTextureSubImage2D; PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D; -void APIENTRY glad_debug_impl_glTextureSubImage3D(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4, GLsizei arg5, GLsizei arg6, GLsizei arg7, GLenum arg8, GLenum arg9, const void * arg10) { - _pre_call_callback_gl("glTextureSubImage3D", (void*)glTextureSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - glad_glTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - _post_call_callback_gl("glTextureSubImage3D", (void*)glTextureSubImage3D, 11, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); - + +void APIENTRY glad_debug_impl_glTextureSubImage3D(GLuint arg0, + GLint arg1, + GLint arg2, + GLint arg3, + GLint arg4, + GLsizei arg5, + GLsizei arg6, + GLsizei arg7, + GLenum arg8, + GLenum arg9, + const void *arg10) { + _pre_call_callback_gl("glTextureSubImage3D", + (void *) glTextureSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + glad_glTextureSubImage3D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + _post_call_callback_gl("glTextureSubImage3D", + (void *) glTextureSubImage3D, + 11, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } + PFNGLTEXTURESUBIMAGE3DPROC glad_debug_glTextureSubImage3D = glad_debug_impl_glTextureSubImage3D; PFNGLTEXTUREVIEWPROC glad_glTextureView; -void APIENTRY glad_debug_impl_glTextureView(GLuint arg0, GLenum arg1, GLuint arg2, GLenum arg3, GLuint arg4, GLuint arg5, GLuint arg6, GLuint arg7) { - _pre_call_callback_gl("glTextureView", (void*)glTextureView, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - glad_glTextureView(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - _post_call_callback_gl("glTextureView", (void*)glTextureView, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - + +void APIENTRY glad_debug_impl_glTextureView(GLuint arg0, + GLenum arg1, + GLuint arg2, + GLenum arg3, + GLuint arg4, + GLuint arg5, + GLuint arg6, + GLuint arg7) { + _pre_call_callback_gl("glTextureView", (void *) glTextureView, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + glad_glTextureView(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + _post_call_callback_gl("glTextureView", (void *) glTextureView, 8, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + PFNGLTEXTUREVIEWPROC glad_debug_glTextureView = glad_debug_impl_glTextureView; PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase; -void APIENTRY glad_debug_impl_glTransformFeedbackBufferBase(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glTransformFeedbackBufferBase", (void*)glTransformFeedbackBufferBase, 3, arg0, arg1, arg2); - glad_glTransformFeedbackBufferBase(arg0, arg1, arg2); - _post_call_callback_gl("glTransformFeedbackBufferBase", (void*)glTransformFeedbackBufferBase, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glTransformFeedbackBufferBase(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glTransformFeedbackBufferBase", (void *) glTransformFeedbackBufferBase, 3, arg0, arg1, arg2); + glad_glTransformFeedbackBufferBase(arg0, arg1, arg2); + _post_call_callback_gl("glTransformFeedbackBufferBase", + (void *) glTransformFeedbackBufferBase, + 3, + arg0, + arg1, + arg2); + } -PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_debug_glTransformFeedbackBufferBase = glad_debug_impl_glTransformFeedbackBufferBase; + +PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC + glad_debug_glTransformFeedbackBufferBase = glad_debug_impl_glTransformFeedbackBufferBase; PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange; -void APIENTRY glad_debug_impl_glTransformFeedbackBufferRange(GLuint arg0, GLuint arg1, GLuint arg2, GLintptr arg3, GLsizeiptr arg4) { - _pre_call_callback_gl("glTransformFeedbackBufferRange", (void*)glTransformFeedbackBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - glad_glTransformFeedbackBufferRange(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glTransformFeedbackBufferRange", (void*)glTransformFeedbackBufferRange, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glTransformFeedbackBufferRange(GLuint arg0, + GLuint arg1, + GLuint arg2, + GLintptr arg3, + GLsizeiptr arg4) { + _pre_call_callback_gl("glTransformFeedbackBufferRange", + (void *) glTransformFeedbackBufferRange, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glTransformFeedbackBufferRange(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glTransformFeedbackBufferRange", + (void *) glTransformFeedbackBufferRange, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } -PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_debug_glTransformFeedbackBufferRange = glad_debug_impl_glTransformFeedbackBufferRange; + +PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC + glad_debug_glTransformFeedbackBufferRange = glad_debug_impl_glTransformFeedbackBufferRange; PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings; -void APIENTRY glad_debug_impl_glTransformFeedbackVaryings(GLuint arg0, GLsizei arg1, const GLchar *const* arg2, GLenum arg3) { - _pre_call_callback_gl("glTransformFeedbackVaryings", (void*)glTransformFeedbackVaryings, 4, arg0, arg1, arg2, arg3); - glad_glTransformFeedbackVaryings(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glTransformFeedbackVaryings", (void*)glTransformFeedbackVaryings, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glTransformFeedbackVaryings(GLuint arg0, + GLsizei arg1, + const GLchar *const *arg2, + GLenum arg3) { + _pre_call_callback_gl("glTransformFeedbackVaryings", + (void *) glTransformFeedbackVaryings, + 4, + arg0, + arg1, + arg2, + arg3); + glad_glTransformFeedbackVaryings(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glTransformFeedbackVaryings", + (void *) glTransformFeedbackVaryings, + 4, + arg0, + arg1, + arg2, + arg3); + } + PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_debug_glTransformFeedbackVaryings = glad_debug_impl_glTransformFeedbackVaryings; PFNGLUNIFORM1DPROC glad_glUniform1d; -void APIENTRY glad_debug_impl_glUniform1d(GLint arg0, GLdouble arg1) { - _pre_call_callback_gl("glUniform1d", (void*)glUniform1d, 2, arg0, arg1); - glad_glUniform1d(arg0, arg1); - _post_call_callback_gl("glUniform1d", (void*)glUniform1d, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glUniform1d(GLint arg0, GLdouble arg1) { + _pre_call_callback_gl("glUniform1d", (void *) glUniform1d, 2, arg0, arg1); + glad_glUniform1d(arg0, arg1); + _post_call_callback_gl("glUniform1d", (void *) glUniform1d, 2, arg0, arg1); + } + PFNGLUNIFORM1DPROC glad_debug_glUniform1d = glad_debug_impl_glUniform1d; PFNGLUNIFORM1DVPROC glad_glUniform1dv; -void APIENTRY glad_debug_impl_glUniform1dv(GLint arg0, GLsizei arg1, const GLdouble * arg2) { - _pre_call_callback_gl("glUniform1dv", (void*)glUniform1dv, 3, arg0, arg1, arg2); - glad_glUniform1dv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform1dv", (void*)glUniform1dv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform1dv(GLint arg0, GLsizei arg1, const GLdouble *arg2) { + _pre_call_callback_gl("glUniform1dv", (void *) glUniform1dv, 3, arg0, arg1, arg2); + glad_glUniform1dv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform1dv", (void *) glUniform1dv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM1DVPROC glad_debug_glUniform1dv = glad_debug_impl_glUniform1dv; PFNGLUNIFORM1FPROC glad_glUniform1f; -void APIENTRY glad_debug_impl_glUniform1f(GLint arg0, GLfloat arg1) { - _pre_call_callback_gl("glUniform1f", (void*)glUniform1f, 2, arg0, arg1); - glad_glUniform1f(arg0, arg1); - _post_call_callback_gl("glUniform1f", (void*)glUniform1f, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glUniform1f(GLint arg0, GLfloat arg1) { + _pre_call_callback_gl("glUniform1f", (void *) glUniform1f, 2, arg0, arg1); + glad_glUniform1f(arg0, arg1); + _post_call_callback_gl("glUniform1f", (void *) glUniform1f, 2, arg0, arg1); + } + PFNGLUNIFORM1FPROC glad_debug_glUniform1f = glad_debug_impl_glUniform1f; PFNGLUNIFORM1FVPROC glad_glUniform1fv; -void APIENTRY glad_debug_impl_glUniform1fv(GLint arg0, GLsizei arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glUniform1fv", (void*)glUniform1fv, 3, arg0, arg1, arg2); - glad_glUniform1fv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform1fv", (void*)glUniform1fv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform1fv(GLint arg0, GLsizei arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glUniform1fv", (void *) glUniform1fv, 3, arg0, arg1, arg2); + glad_glUniform1fv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform1fv", (void *) glUniform1fv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM1FVPROC glad_debug_glUniform1fv = glad_debug_impl_glUniform1fv; PFNGLUNIFORM1IPROC glad_glUniform1i; -void APIENTRY glad_debug_impl_glUniform1i(GLint arg0, GLint arg1) { - _pre_call_callback_gl("glUniform1i", (void*)glUniform1i, 2, arg0, arg1); - glad_glUniform1i(arg0, arg1); - _post_call_callback_gl("glUniform1i", (void*)glUniform1i, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glUniform1i(GLint arg0, GLint arg1) { + _pre_call_callback_gl("glUniform1i", (void *) glUniform1i, 2, arg0, arg1); + glad_glUniform1i(arg0, arg1); + _post_call_callback_gl("glUniform1i", (void *) glUniform1i, 2, arg0, arg1); + } + PFNGLUNIFORM1IPROC glad_debug_glUniform1i = glad_debug_impl_glUniform1i; PFNGLUNIFORM1IVPROC glad_glUniform1iv; -void APIENTRY glad_debug_impl_glUniform1iv(GLint arg0, GLsizei arg1, const GLint * arg2) { - _pre_call_callback_gl("glUniform1iv", (void*)glUniform1iv, 3, arg0, arg1, arg2); - glad_glUniform1iv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform1iv", (void*)glUniform1iv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform1iv(GLint arg0, GLsizei arg1, const GLint *arg2) { + _pre_call_callback_gl("glUniform1iv", (void *) glUniform1iv, 3, arg0, arg1, arg2); + glad_glUniform1iv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform1iv", (void *) glUniform1iv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM1IVPROC glad_debug_glUniform1iv = glad_debug_impl_glUniform1iv; PFNGLUNIFORM1UIPROC glad_glUniform1ui; -void APIENTRY glad_debug_impl_glUniform1ui(GLint arg0, GLuint arg1) { - _pre_call_callback_gl("glUniform1ui", (void*)glUniform1ui, 2, arg0, arg1); - glad_glUniform1ui(arg0, arg1); - _post_call_callback_gl("glUniform1ui", (void*)glUniform1ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glUniform1ui(GLint arg0, GLuint arg1) { + _pre_call_callback_gl("glUniform1ui", (void *) glUniform1ui, 2, arg0, arg1); + glad_glUniform1ui(arg0, arg1); + _post_call_callback_gl("glUniform1ui", (void *) glUniform1ui, 2, arg0, arg1); + } + PFNGLUNIFORM1UIPROC glad_debug_glUniform1ui = glad_debug_impl_glUniform1ui; PFNGLUNIFORM1UIVPROC glad_glUniform1uiv; -void APIENTRY glad_debug_impl_glUniform1uiv(GLint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glUniform1uiv", (void*)glUniform1uiv, 3, arg0, arg1, arg2); - glad_glUniform1uiv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform1uiv", (void*)glUniform1uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform1uiv(GLint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glUniform1uiv", (void *) glUniform1uiv, 3, arg0, arg1, arg2); + glad_glUniform1uiv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform1uiv", (void *) glUniform1uiv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM1UIVPROC glad_debug_glUniform1uiv = glad_debug_impl_glUniform1uiv; PFNGLUNIFORM2DPROC glad_glUniform2d; -void APIENTRY glad_debug_impl_glUniform2d(GLint arg0, GLdouble arg1, GLdouble arg2) { - _pre_call_callback_gl("glUniform2d", (void*)glUniform2d, 3, arg0, arg1, arg2); - glad_glUniform2d(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2d", (void*)glUniform2d, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2d(GLint arg0, GLdouble arg1, GLdouble arg2) { + _pre_call_callback_gl("glUniform2d", (void *) glUniform2d, 3, arg0, arg1, arg2); + glad_glUniform2d(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2d", (void *) glUniform2d, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2DPROC glad_debug_glUniform2d = glad_debug_impl_glUniform2d; PFNGLUNIFORM2DVPROC glad_glUniform2dv; -void APIENTRY glad_debug_impl_glUniform2dv(GLint arg0, GLsizei arg1, const GLdouble * arg2) { - _pre_call_callback_gl("glUniform2dv", (void*)glUniform2dv, 3, arg0, arg1, arg2); - glad_glUniform2dv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2dv", (void*)glUniform2dv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2dv(GLint arg0, GLsizei arg1, const GLdouble *arg2) { + _pre_call_callback_gl("glUniform2dv", (void *) glUniform2dv, 3, arg0, arg1, arg2); + glad_glUniform2dv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2dv", (void *) glUniform2dv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2DVPROC glad_debug_glUniform2dv = glad_debug_impl_glUniform2dv; PFNGLUNIFORM2FPROC glad_glUniform2f; -void APIENTRY glad_debug_impl_glUniform2f(GLint arg0, GLfloat arg1, GLfloat arg2) { - _pre_call_callback_gl("glUniform2f", (void*)glUniform2f, 3, arg0, arg1, arg2); - glad_glUniform2f(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2f", (void*)glUniform2f, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2f(GLint arg0, GLfloat arg1, GLfloat arg2) { + _pre_call_callback_gl("glUniform2f", (void *) glUniform2f, 3, arg0, arg1, arg2); + glad_glUniform2f(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2f", (void *) glUniform2f, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2FPROC glad_debug_glUniform2f = glad_debug_impl_glUniform2f; PFNGLUNIFORM2FVPROC glad_glUniform2fv; -void APIENTRY glad_debug_impl_glUniform2fv(GLint arg0, GLsizei arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glUniform2fv", (void*)glUniform2fv, 3, arg0, arg1, arg2); - glad_glUniform2fv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2fv", (void*)glUniform2fv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2fv(GLint arg0, GLsizei arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glUniform2fv", (void *) glUniform2fv, 3, arg0, arg1, arg2); + glad_glUniform2fv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2fv", (void *) glUniform2fv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2FVPROC glad_debug_glUniform2fv = glad_debug_impl_glUniform2fv; PFNGLUNIFORM2IPROC glad_glUniform2i; -void APIENTRY glad_debug_impl_glUniform2i(GLint arg0, GLint arg1, GLint arg2) { - _pre_call_callback_gl("glUniform2i", (void*)glUniform2i, 3, arg0, arg1, arg2); - glad_glUniform2i(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2i", (void*)glUniform2i, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2i(GLint arg0, GLint arg1, GLint arg2) { + _pre_call_callback_gl("glUniform2i", (void *) glUniform2i, 3, arg0, arg1, arg2); + glad_glUniform2i(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2i", (void *) glUniform2i, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2IPROC glad_debug_glUniform2i = glad_debug_impl_glUniform2i; PFNGLUNIFORM2IVPROC glad_glUniform2iv; -void APIENTRY glad_debug_impl_glUniform2iv(GLint arg0, GLsizei arg1, const GLint * arg2) { - _pre_call_callback_gl("glUniform2iv", (void*)glUniform2iv, 3, arg0, arg1, arg2); - glad_glUniform2iv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2iv", (void*)glUniform2iv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2iv(GLint arg0, GLsizei arg1, const GLint *arg2) { + _pre_call_callback_gl("glUniform2iv", (void *) glUniform2iv, 3, arg0, arg1, arg2); + glad_glUniform2iv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2iv", (void *) glUniform2iv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2IVPROC glad_debug_glUniform2iv = glad_debug_impl_glUniform2iv; PFNGLUNIFORM2UIPROC glad_glUniform2ui; -void APIENTRY glad_debug_impl_glUniform2ui(GLint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glUniform2ui", (void*)glUniform2ui, 3, arg0, arg1, arg2); - glad_glUniform2ui(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2ui", (void*)glUniform2ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2ui(GLint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glUniform2ui", (void *) glUniform2ui, 3, arg0, arg1, arg2); + glad_glUniform2ui(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2ui", (void *) glUniform2ui, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2UIPROC glad_debug_glUniform2ui = glad_debug_impl_glUniform2ui; PFNGLUNIFORM2UIVPROC glad_glUniform2uiv; -void APIENTRY glad_debug_impl_glUniform2uiv(GLint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glUniform2uiv", (void*)glUniform2uiv, 3, arg0, arg1, arg2); - glad_glUniform2uiv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform2uiv", (void*)glUniform2uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform2uiv(GLint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glUniform2uiv", (void *) glUniform2uiv, 3, arg0, arg1, arg2); + glad_glUniform2uiv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform2uiv", (void *) glUniform2uiv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM2UIVPROC glad_debug_glUniform2uiv = glad_debug_impl_glUniform2uiv; PFNGLUNIFORM3DPROC glad_glUniform3d; -void APIENTRY glad_debug_impl_glUniform3d(GLint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { - _pre_call_callback_gl("glUniform3d", (void*)glUniform3d, 4, arg0, arg1, arg2, arg3); - glad_glUniform3d(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniform3d", (void*)glUniform3d, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniform3d(GLint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { + _pre_call_callback_gl("glUniform3d", (void *) glUniform3d, 4, arg0, arg1, arg2, arg3); + glad_glUniform3d(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniform3d", (void *) glUniform3d, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORM3DPROC glad_debug_glUniform3d = glad_debug_impl_glUniform3d; PFNGLUNIFORM3DVPROC glad_glUniform3dv; -void APIENTRY glad_debug_impl_glUniform3dv(GLint arg0, GLsizei arg1, const GLdouble * arg2) { - _pre_call_callback_gl("glUniform3dv", (void*)glUniform3dv, 3, arg0, arg1, arg2); - glad_glUniform3dv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform3dv", (void*)glUniform3dv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform3dv(GLint arg0, GLsizei arg1, const GLdouble *arg2) { + _pre_call_callback_gl("glUniform3dv", (void *) glUniform3dv, 3, arg0, arg1, arg2); + glad_glUniform3dv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform3dv", (void *) glUniform3dv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM3DVPROC glad_debug_glUniform3dv = glad_debug_impl_glUniform3dv; PFNGLUNIFORM3FPROC glad_glUniform3f; -void APIENTRY glad_debug_impl_glUniform3f(GLint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { - _pre_call_callback_gl("glUniform3f", (void*)glUniform3f, 4, arg0, arg1, arg2, arg3); - glad_glUniform3f(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniform3f", (void*)glUniform3f, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniform3f(GLint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { + _pre_call_callback_gl("glUniform3f", (void *) glUniform3f, 4, arg0, arg1, arg2, arg3); + glad_glUniform3f(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniform3f", (void *) glUniform3f, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORM3FPROC glad_debug_glUniform3f = glad_debug_impl_glUniform3f; PFNGLUNIFORM3FVPROC glad_glUniform3fv; -void APIENTRY glad_debug_impl_glUniform3fv(GLint arg0, GLsizei arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glUniform3fv", (void*)glUniform3fv, 3, arg0, arg1, arg2); - glad_glUniform3fv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform3fv", (void*)glUniform3fv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform3fv(GLint arg0, GLsizei arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glUniform3fv", (void *) glUniform3fv, 3, arg0, arg1, arg2); + glad_glUniform3fv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform3fv", (void *) glUniform3fv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM3FVPROC glad_debug_glUniform3fv = glad_debug_impl_glUniform3fv; PFNGLUNIFORM3IPROC glad_glUniform3i; -void APIENTRY glad_debug_impl_glUniform3i(GLint arg0, GLint arg1, GLint arg2, GLint arg3) { - _pre_call_callback_gl("glUniform3i", (void*)glUniform3i, 4, arg0, arg1, arg2, arg3); - glad_glUniform3i(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniform3i", (void*)glUniform3i, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniform3i(GLint arg0, GLint arg1, GLint arg2, GLint arg3) { + _pre_call_callback_gl("glUniform3i", (void *) glUniform3i, 4, arg0, arg1, arg2, arg3); + glad_glUniform3i(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniform3i", (void *) glUniform3i, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORM3IPROC glad_debug_glUniform3i = glad_debug_impl_glUniform3i; PFNGLUNIFORM3IVPROC glad_glUniform3iv; -void APIENTRY glad_debug_impl_glUniform3iv(GLint arg0, GLsizei arg1, const GLint * arg2) { - _pre_call_callback_gl("glUniform3iv", (void*)glUniform3iv, 3, arg0, arg1, arg2); - glad_glUniform3iv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform3iv", (void*)glUniform3iv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform3iv(GLint arg0, GLsizei arg1, const GLint *arg2) { + _pre_call_callback_gl("glUniform3iv", (void *) glUniform3iv, 3, arg0, arg1, arg2); + glad_glUniform3iv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform3iv", (void *) glUniform3iv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM3IVPROC glad_debug_glUniform3iv = glad_debug_impl_glUniform3iv; PFNGLUNIFORM3UIPROC glad_glUniform3ui; -void APIENTRY glad_debug_impl_glUniform3ui(GLint arg0, GLuint arg1, GLuint arg2, GLuint arg3) { - _pre_call_callback_gl("glUniform3ui", (void*)glUniform3ui, 4, arg0, arg1, arg2, arg3); - glad_glUniform3ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniform3ui", (void*)glUniform3ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniform3ui(GLint arg0, GLuint arg1, GLuint arg2, GLuint arg3) { + _pre_call_callback_gl("glUniform3ui", (void *) glUniform3ui, 4, arg0, arg1, arg2, arg3); + glad_glUniform3ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniform3ui", (void *) glUniform3ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORM3UIPROC glad_debug_glUniform3ui = glad_debug_impl_glUniform3ui; PFNGLUNIFORM3UIVPROC glad_glUniform3uiv; -void APIENTRY glad_debug_impl_glUniform3uiv(GLint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glUniform3uiv", (void*)glUniform3uiv, 3, arg0, arg1, arg2); - glad_glUniform3uiv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform3uiv", (void*)glUniform3uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform3uiv(GLint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glUniform3uiv", (void *) glUniform3uiv, 3, arg0, arg1, arg2); + glad_glUniform3uiv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform3uiv", (void *) glUniform3uiv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM3UIVPROC glad_debug_glUniform3uiv = glad_debug_impl_glUniform3uiv; PFNGLUNIFORM4DPROC glad_glUniform4d; -void APIENTRY glad_debug_impl_glUniform4d(GLint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { - _pre_call_callback_gl("glUniform4d", (void*)glUniform4d, 5, arg0, arg1, arg2, arg3, arg4); - glad_glUniform4d(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glUniform4d", (void*)glUniform4d, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glUniform4d(GLint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { + _pre_call_callback_gl("glUniform4d", (void *) glUniform4d, 5, arg0, arg1, arg2, arg3, arg4); + glad_glUniform4d(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glUniform4d", (void *) glUniform4d, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLUNIFORM4DPROC glad_debug_glUniform4d = glad_debug_impl_glUniform4d; PFNGLUNIFORM4DVPROC glad_glUniform4dv; -void APIENTRY glad_debug_impl_glUniform4dv(GLint arg0, GLsizei arg1, const GLdouble * arg2) { - _pre_call_callback_gl("glUniform4dv", (void*)glUniform4dv, 3, arg0, arg1, arg2); - glad_glUniform4dv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform4dv", (void*)glUniform4dv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform4dv(GLint arg0, GLsizei arg1, const GLdouble *arg2) { + _pre_call_callback_gl("glUniform4dv", (void *) glUniform4dv, 3, arg0, arg1, arg2); + glad_glUniform4dv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform4dv", (void *) glUniform4dv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM4DVPROC glad_debug_glUniform4dv = glad_debug_impl_glUniform4dv; PFNGLUNIFORM4FPROC glad_glUniform4f; -void APIENTRY glad_debug_impl_glUniform4f(GLint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { - _pre_call_callback_gl("glUniform4f", (void*)glUniform4f, 5, arg0, arg1, arg2, arg3, arg4); - glad_glUniform4f(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glUniform4f", (void*)glUniform4f, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glUniform4f(GLint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { + _pre_call_callback_gl("glUniform4f", (void *) glUniform4f, 5, arg0, arg1, arg2, arg3, arg4); + glad_glUniform4f(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glUniform4f", (void *) glUniform4f, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLUNIFORM4FPROC glad_debug_glUniform4f = glad_debug_impl_glUniform4f; PFNGLUNIFORM4FVPROC glad_glUniform4fv; -void APIENTRY glad_debug_impl_glUniform4fv(GLint arg0, GLsizei arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glUniform4fv", (void*)glUniform4fv, 3, arg0, arg1, arg2); - glad_glUniform4fv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform4fv", (void*)glUniform4fv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform4fv(GLint arg0, GLsizei arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glUniform4fv", (void *) glUniform4fv, 3, arg0, arg1, arg2); + glad_glUniform4fv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform4fv", (void *) glUniform4fv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM4FVPROC glad_debug_glUniform4fv = glad_debug_impl_glUniform4fv; PFNGLUNIFORM4IPROC glad_glUniform4i; -void APIENTRY glad_debug_impl_glUniform4i(GLint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { - _pre_call_callback_gl("glUniform4i", (void*)glUniform4i, 5, arg0, arg1, arg2, arg3, arg4); - glad_glUniform4i(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glUniform4i", (void*)glUniform4i, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glUniform4i(GLint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { + _pre_call_callback_gl("glUniform4i", (void *) glUniform4i, 5, arg0, arg1, arg2, arg3, arg4); + glad_glUniform4i(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glUniform4i", (void *) glUniform4i, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLUNIFORM4IPROC glad_debug_glUniform4i = glad_debug_impl_glUniform4i; PFNGLUNIFORM4IVPROC glad_glUniform4iv; -void APIENTRY glad_debug_impl_glUniform4iv(GLint arg0, GLsizei arg1, const GLint * arg2) { - _pre_call_callback_gl("glUniform4iv", (void*)glUniform4iv, 3, arg0, arg1, arg2); - glad_glUniform4iv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform4iv", (void*)glUniform4iv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform4iv(GLint arg0, GLsizei arg1, const GLint *arg2) { + _pre_call_callback_gl("glUniform4iv", (void *) glUniform4iv, 3, arg0, arg1, arg2); + glad_glUniform4iv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform4iv", (void *) glUniform4iv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM4IVPROC glad_debug_glUniform4iv = glad_debug_impl_glUniform4iv; PFNGLUNIFORM4UIPROC glad_glUniform4ui; -void APIENTRY glad_debug_impl_glUniform4ui(GLint arg0, GLuint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { - _pre_call_callback_gl("glUniform4ui", (void*)glUniform4ui, 5, arg0, arg1, arg2, arg3, arg4); - glad_glUniform4ui(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glUniform4ui", (void*)glUniform4ui, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glUniform4ui(GLint arg0, GLuint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { + _pre_call_callback_gl("glUniform4ui", (void *) glUniform4ui, 5, arg0, arg1, arg2, arg3, arg4); + glad_glUniform4ui(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glUniform4ui", (void *) glUniform4ui, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLUNIFORM4UIPROC glad_debug_glUniform4ui = glad_debug_impl_glUniform4ui; PFNGLUNIFORM4UIVPROC glad_glUniform4uiv; -void APIENTRY glad_debug_impl_glUniform4uiv(GLint arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glUniform4uiv", (void*)glUniform4uiv, 3, arg0, arg1, arg2); - glad_glUniform4uiv(arg0, arg1, arg2); - _post_call_callback_gl("glUniform4uiv", (void*)glUniform4uiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniform4uiv(GLint arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glUniform4uiv", (void *) glUniform4uiv, 3, arg0, arg1, arg2); + glad_glUniform4uiv(arg0, arg1, arg2); + _post_call_callback_gl("glUniform4uiv", (void *) glUniform4uiv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORM4UIVPROC glad_debug_glUniform4uiv = glad_debug_impl_glUniform4uiv; PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding; -void APIENTRY glad_debug_impl_glUniformBlockBinding(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glUniformBlockBinding", (void*)glUniformBlockBinding, 3, arg0, arg1, arg2); - glad_glUniformBlockBinding(arg0, arg1, arg2); - _post_call_callback_gl("glUniformBlockBinding", (void*)glUniformBlockBinding, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniformBlockBinding(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glUniformBlockBinding", (void *) glUniformBlockBinding, 3, arg0, arg1, arg2); + glad_glUniformBlockBinding(arg0, arg1, arg2); + _post_call_callback_gl("glUniformBlockBinding", (void *) glUniformBlockBinding, 3, arg0, arg1, arg2); + } + PFNGLUNIFORMBLOCKBINDINGPROC glad_debug_glUniformBlockBinding = glad_debug_impl_glUniformBlockBinding; PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv; -void APIENTRY glad_debug_impl_glUniformMatrix2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix2dv", (void*)glUniformMatrix2dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2dv", (void*)glUniformMatrix2dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix2dv", (void *) glUniformMatrix2dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2dv", (void *) glUniformMatrix2dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2DVPROC glad_debug_glUniformMatrix2dv = glad_debug_impl_glUniformMatrix2dv; PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv; -void APIENTRY glad_debug_impl_glUniformMatrix2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix2fv", (void*)glUniformMatrix2fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2fv", (void*)glUniformMatrix2fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix2fv", (void *) glUniformMatrix2fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2fv", (void *) glUniformMatrix2fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2FVPROC glad_debug_glUniformMatrix2fv = glad_debug_impl_glUniformMatrix2fv; PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv; -void APIENTRY glad_debug_impl_glUniformMatrix2x3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix2x3dv", (void*)glUniformMatrix2x3dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2x3dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2x3dv", (void*)glUniformMatrix2x3dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2x3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix2x3dv", (void *) glUniformMatrix2x3dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2x3dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2x3dv", (void *) glUniformMatrix2x3dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2X3DVPROC glad_debug_glUniformMatrix2x3dv = glad_debug_impl_glUniformMatrix2x3dv; PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv; -void APIENTRY glad_debug_impl_glUniformMatrix2x3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix2x3fv", (void*)glUniformMatrix2x3fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2x3fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2x3fv", (void*)glUniformMatrix2x3fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2x3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix2x3fv", (void *) glUniformMatrix2x3fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2x3fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2x3fv", (void *) glUniformMatrix2x3fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2X3FVPROC glad_debug_glUniformMatrix2x3fv = glad_debug_impl_glUniformMatrix2x3fv; PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv; -void APIENTRY glad_debug_impl_glUniformMatrix2x4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix2x4dv", (void*)glUniformMatrix2x4dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2x4dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2x4dv", (void*)glUniformMatrix2x4dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2x4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix2x4dv", (void *) glUniformMatrix2x4dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2x4dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2x4dv", (void *) glUniformMatrix2x4dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2X4DVPROC glad_debug_glUniformMatrix2x4dv = glad_debug_impl_glUniformMatrix2x4dv; PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv; -void APIENTRY glad_debug_impl_glUniformMatrix2x4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix2x4fv", (void*)glUniformMatrix2x4fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix2x4fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix2x4fv", (void*)glUniformMatrix2x4fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix2x4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix2x4fv", (void *) glUniformMatrix2x4fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix2x4fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix2x4fv", (void *) glUniformMatrix2x4fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX2X4FVPROC glad_debug_glUniformMatrix2x4fv = glad_debug_impl_glUniformMatrix2x4fv; PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv; -void APIENTRY glad_debug_impl_glUniformMatrix3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix3dv", (void*)glUniformMatrix3dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3dv", (void*)glUniformMatrix3dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix3dv", (void *) glUniformMatrix3dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3dv", (void *) glUniformMatrix3dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3DVPROC glad_debug_glUniformMatrix3dv = glad_debug_impl_glUniformMatrix3dv; PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv; -void APIENTRY glad_debug_impl_glUniformMatrix3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix3fv", (void*)glUniformMatrix3fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3fv", (void*)glUniformMatrix3fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix3fv", (void *) glUniformMatrix3fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3fv", (void *) glUniformMatrix3fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3FVPROC glad_debug_glUniformMatrix3fv = glad_debug_impl_glUniformMatrix3fv; PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv; -void APIENTRY glad_debug_impl_glUniformMatrix3x2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix3x2dv", (void*)glUniformMatrix3x2dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3x2dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3x2dv", (void*)glUniformMatrix3x2dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3x2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix3x2dv", (void *) glUniformMatrix3x2dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3x2dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3x2dv", (void *) glUniformMatrix3x2dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3X2DVPROC glad_debug_glUniformMatrix3x2dv = glad_debug_impl_glUniformMatrix3x2dv; PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv; -void APIENTRY glad_debug_impl_glUniformMatrix3x2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix3x2fv", (void*)glUniformMatrix3x2fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3x2fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3x2fv", (void*)glUniformMatrix3x2fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3x2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix3x2fv", (void *) glUniformMatrix3x2fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3x2fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3x2fv", (void *) glUniformMatrix3x2fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3X2FVPROC glad_debug_glUniformMatrix3x2fv = glad_debug_impl_glUniformMatrix3x2fv; PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv; -void APIENTRY glad_debug_impl_glUniformMatrix3x4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix3x4dv", (void*)glUniformMatrix3x4dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3x4dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3x4dv", (void*)glUniformMatrix3x4dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3x4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix3x4dv", (void *) glUniformMatrix3x4dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3x4dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3x4dv", (void *) glUniformMatrix3x4dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3X4DVPROC glad_debug_glUniformMatrix3x4dv = glad_debug_impl_glUniformMatrix3x4dv; PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv; -void APIENTRY glad_debug_impl_glUniformMatrix3x4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix3x4fv", (void*)glUniformMatrix3x4fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix3x4fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix3x4fv", (void*)glUniformMatrix3x4fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix3x4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix3x4fv", (void *) glUniformMatrix3x4fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix3x4fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix3x4fv", (void *) glUniformMatrix3x4fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX3X4FVPROC glad_debug_glUniformMatrix3x4fv = glad_debug_impl_glUniformMatrix3x4fv; PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv; -void APIENTRY glad_debug_impl_glUniformMatrix4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix4dv", (void*)glUniformMatrix4dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4dv", (void*)glUniformMatrix4dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix4dv", (void *) glUniformMatrix4dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4dv", (void *) glUniformMatrix4dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4DVPROC glad_debug_glUniformMatrix4dv = glad_debug_impl_glUniformMatrix4dv; PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv; -void APIENTRY glad_debug_impl_glUniformMatrix4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix4fv", (void*)glUniformMatrix4fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4fv", (void*)glUniformMatrix4fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix4fv", (void *) glUniformMatrix4fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4fv", (void *) glUniformMatrix4fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4FVPROC glad_debug_glUniformMatrix4fv = glad_debug_impl_glUniformMatrix4fv; PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv; -void APIENTRY glad_debug_impl_glUniformMatrix4x2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix4x2dv", (void*)glUniformMatrix4x2dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4x2dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4x2dv", (void*)glUniformMatrix4x2dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4x2dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix4x2dv", (void *) glUniformMatrix4x2dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4x2dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4x2dv", (void *) glUniformMatrix4x2dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4X2DVPROC glad_debug_glUniformMatrix4x2dv = glad_debug_impl_glUniformMatrix4x2dv; PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv; -void APIENTRY glad_debug_impl_glUniformMatrix4x2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix4x2fv", (void*)glUniformMatrix4x2fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4x2fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4x2fv", (void*)glUniformMatrix4x2fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4x2fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix4x2fv", (void *) glUniformMatrix4x2fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4x2fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4x2fv", (void *) glUniformMatrix4x2fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4X2FVPROC glad_debug_glUniformMatrix4x2fv = glad_debug_impl_glUniformMatrix4x2fv; PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv; -void APIENTRY glad_debug_impl_glUniformMatrix4x3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble * arg3) { - _pre_call_callback_gl("glUniformMatrix4x3dv", (void*)glUniformMatrix4x3dv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4x3dv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4x3dv", (void*)glUniformMatrix4x3dv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4x3dv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLdouble *arg3) { + _pre_call_callback_gl("glUniformMatrix4x3dv", (void *) glUniformMatrix4x3dv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4x3dv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4x3dv", (void *) glUniformMatrix4x3dv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4X3DVPROC glad_debug_glUniformMatrix4x3dv = glad_debug_impl_glUniformMatrix4x3dv; PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv; -void APIENTRY glad_debug_impl_glUniformMatrix4x3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat * arg3) { - _pre_call_callback_gl("glUniformMatrix4x3fv", (void*)glUniformMatrix4x3fv, 4, arg0, arg1, arg2, arg3); - glad_glUniformMatrix4x3fv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glUniformMatrix4x3fv", (void*)glUniformMatrix4x3fv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glUniformMatrix4x3fv(GLint arg0, GLsizei arg1, GLboolean arg2, const GLfloat *arg3) { + _pre_call_callback_gl("glUniformMatrix4x3fv", (void *) glUniformMatrix4x3fv, 4, arg0, arg1, arg2, arg3); + glad_glUniformMatrix4x3fv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glUniformMatrix4x3fv", (void *) glUniformMatrix4x3fv, 4, arg0, arg1, arg2, arg3); + } + PFNGLUNIFORMMATRIX4X3FVPROC glad_debug_glUniformMatrix4x3fv = glad_debug_impl_glUniformMatrix4x3fv; PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv; -void APIENTRY glad_debug_impl_glUniformSubroutinesuiv(GLenum arg0, GLsizei arg1, const GLuint * arg2) { - _pre_call_callback_gl("glUniformSubroutinesuiv", (void*)glUniformSubroutinesuiv, 3, arg0, arg1, arg2); - glad_glUniformSubroutinesuiv(arg0, arg1, arg2); - _post_call_callback_gl("glUniformSubroutinesuiv", (void*)glUniformSubroutinesuiv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUniformSubroutinesuiv(GLenum arg0, GLsizei arg1, const GLuint *arg2) { + _pre_call_callback_gl("glUniformSubroutinesuiv", (void *) glUniformSubroutinesuiv, 3, arg0, arg1, arg2); + glad_glUniformSubroutinesuiv(arg0, arg1, arg2); + _post_call_callback_gl("glUniformSubroutinesuiv", (void *) glUniformSubroutinesuiv, 3, arg0, arg1, arg2); + } + PFNGLUNIFORMSUBROUTINESUIVPROC glad_debug_glUniformSubroutinesuiv = glad_debug_impl_glUniformSubroutinesuiv; PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer; -GLboolean APIENTRY glad_debug_impl_glUnmapBuffer(GLenum arg0) { - GLboolean ret; - _pre_call_callback_gl("glUnmapBuffer", (void*)glUnmapBuffer, 1, arg0); - ret = glad_glUnmapBuffer(arg0); - _post_call_callback_gl("glUnmapBuffer", (void*)glUnmapBuffer, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glUnmapBuffer(GLenum arg0) { + GLboolean ret; + _pre_call_callback_gl("glUnmapBuffer", (void *) glUnmapBuffer, 1, arg0); + ret = glad_glUnmapBuffer(arg0); + _post_call_callback_gl("glUnmapBuffer", (void *) glUnmapBuffer, 1, arg0); + return ret; } + PFNGLUNMAPBUFFERPROC glad_debug_glUnmapBuffer = glad_debug_impl_glUnmapBuffer; PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer; -GLboolean APIENTRY glad_debug_impl_glUnmapNamedBuffer(GLuint arg0) { - GLboolean ret; - _pre_call_callback_gl("glUnmapNamedBuffer", (void*)glUnmapNamedBuffer, 1, arg0); - ret = glad_glUnmapNamedBuffer(arg0); - _post_call_callback_gl("glUnmapNamedBuffer", (void*)glUnmapNamedBuffer, 1, arg0); - return ret; + +GLboolean APIENTRY glad_debug_impl_glUnmapNamedBuffer(GLuint arg0) { + GLboolean ret; + _pre_call_callback_gl("glUnmapNamedBuffer", (void *) glUnmapNamedBuffer, 1, arg0); + ret = glad_glUnmapNamedBuffer(arg0); + _post_call_callback_gl("glUnmapNamedBuffer", (void *) glUnmapNamedBuffer, 1, arg0); + return ret; } + PFNGLUNMAPNAMEDBUFFERPROC glad_debug_glUnmapNamedBuffer = glad_debug_impl_glUnmapNamedBuffer; PFNGLUSEPROGRAMPROC glad_glUseProgram; -void APIENTRY glad_debug_impl_glUseProgram(GLuint arg0) { - _pre_call_callback_gl("glUseProgram", (void*)glUseProgram, 1, arg0); - glad_glUseProgram(arg0); - _post_call_callback_gl("glUseProgram", (void*)glUseProgram, 1, arg0); - + +void APIENTRY glad_debug_impl_glUseProgram(GLuint arg0) { + _pre_call_callback_gl("glUseProgram", (void *) glUseProgram, 1, arg0); + glad_glUseProgram(arg0); + _post_call_callback_gl("glUseProgram", (void *) glUseProgram, 1, arg0); + } + PFNGLUSEPROGRAMPROC glad_debug_glUseProgram = glad_debug_impl_glUseProgram; PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages; -void APIENTRY glad_debug_impl_glUseProgramStages(GLuint arg0, GLbitfield arg1, GLuint arg2) { - _pre_call_callback_gl("glUseProgramStages", (void*)glUseProgramStages, 3, arg0, arg1, arg2); - glad_glUseProgramStages(arg0, arg1, arg2); - _post_call_callback_gl("glUseProgramStages", (void*)glUseProgramStages, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glUseProgramStages(GLuint arg0, GLbitfield arg1, GLuint arg2) { + _pre_call_callback_gl("glUseProgramStages", (void *) glUseProgramStages, 3, arg0, arg1, arg2); + glad_glUseProgramStages(arg0, arg1, arg2); + _post_call_callback_gl("glUseProgramStages", (void *) glUseProgramStages, 3, arg0, arg1, arg2); + } + PFNGLUSEPROGRAMSTAGESPROC glad_debug_glUseProgramStages = glad_debug_impl_glUseProgramStages; PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram; -void APIENTRY glad_debug_impl_glValidateProgram(GLuint arg0) { - _pre_call_callback_gl("glValidateProgram", (void*)glValidateProgram, 1, arg0); - glad_glValidateProgram(arg0); - _post_call_callback_gl("glValidateProgram", (void*)glValidateProgram, 1, arg0); - + +void APIENTRY glad_debug_impl_glValidateProgram(GLuint arg0) { + _pre_call_callback_gl("glValidateProgram", (void *) glValidateProgram, 1, arg0); + glad_glValidateProgram(arg0); + _post_call_callback_gl("glValidateProgram", (void *) glValidateProgram, 1, arg0); + } + PFNGLVALIDATEPROGRAMPROC glad_debug_glValidateProgram = glad_debug_impl_glValidateProgram; PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline; -void APIENTRY glad_debug_impl_glValidateProgramPipeline(GLuint arg0) { - _pre_call_callback_gl("glValidateProgramPipeline", (void*)glValidateProgramPipeline, 1, arg0); - glad_glValidateProgramPipeline(arg0); - _post_call_callback_gl("glValidateProgramPipeline", (void*)glValidateProgramPipeline, 1, arg0); - + +void APIENTRY glad_debug_impl_glValidateProgramPipeline(GLuint arg0) { + _pre_call_callback_gl("glValidateProgramPipeline", (void *) glValidateProgramPipeline, 1, arg0); + glad_glValidateProgramPipeline(arg0); + _post_call_callback_gl("glValidateProgramPipeline", (void *) glValidateProgramPipeline, 1, arg0); + } + PFNGLVALIDATEPROGRAMPIPELINEPROC glad_debug_glValidateProgramPipeline = glad_debug_impl_glValidateProgramPipeline; PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding; -void APIENTRY glad_debug_impl_glVertexArrayAttribBinding(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glVertexArrayAttribBinding", (void*)glVertexArrayAttribBinding, 3, arg0, arg1, arg2); - glad_glVertexArrayAttribBinding(arg0, arg1, arg2); - _post_call_callback_gl("glVertexArrayAttribBinding", (void*)glVertexArrayAttribBinding, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexArrayAttribBinding(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glVertexArrayAttribBinding", (void *) glVertexArrayAttribBinding, 3, arg0, arg1, arg2); + glad_glVertexArrayAttribBinding(arg0, arg1, arg2); + _post_call_callback_gl("glVertexArrayAttribBinding", (void *) glVertexArrayAttribBinding, 3, arg0, arg1, arg2); + } + PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_debug_glVertexArrayAttribBinding = glad_debug_impl_glVertexArrayAttribBinding; PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat; -void APIENTRY glad_debug_impl_glVertexArrayAttribFormat(GLuint arg0, GLuint arg1, GLint arg2, GLenum arg3, GLboolean arg4, GLuint arg5) { - _pre_call_callback_gl("glVertexArrayAttribFormat", (void*)glVertexArrayAttribFormat, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glVertexArrayAttribFormat(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glVertexArrayAttribFormat", (void*)glVertexArrayAttribFormat, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glVertexArrayAttribFormat(GLuint arg0, + GLuint arg1, + GLint arg2, + GLenum arg3, + GLboolean arg4, + GLuint arg5) { + _pre_call_callback_gl("glVertexArrayAttribFormat", + (void *) glVertexArrayAttribFormat, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glVertexArrayAttribFormat(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glVertexArrayAttribFormat", + (void *) glVertexArrayAttribFormat, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLVERTEXARRAYATTRIBFORMATPROC glad_debug_glVertexArrayAttribFormat = glad_debug_impl_glVertexArrayAttribFormat; PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat; -void APIENTRY glad_debug_impl_glVertexArrayAttribIFormat(GLuint arg0, GLuint arg1, GLint arg2, GLenum arg3, GLuint arg4) { - _pre_call_callback_gl("glVertexArrayAttribIFormat", (void*)glVertexArrayAttribIFormat, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexArrayAttribIFormat(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexArrayAttribIFormat", (void*)glVertexArrayAttribIFormat, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexArrayAttribIFormat(GLuint arg0, + GLuint arg1, + GLint arg2, + GLenum arg3, + GLuint arg4) { + _pre_call_callback_gl("glVertexArrayAttribIFormat", + (void *) glVertexArrayAttribIFormat, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glVertexArrayAttribIFormat(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexArrayAttribIFormat", + (void *) glVertexArrayAttribIFormat, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_debug_glVertexArrayAttribIFormat = glad_debug_impl_glVertexArrayAttribIFormat; PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat; -void APIENTRY glad_debug_impl_glVertexArrayAttribLFormat(GLuint arg0, GLuint arg1, GLint arg2, GLenum arg3, GLuint arg4) { - _pre_call_callback_gl("glVertexArrayAttribLFormat", (void*)glVertexArrayAttribLFormat, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexArrayAttribLFormat(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexArrayAttribLFormat", (void*)glVertexArrayAttribLFormat, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexArrayAttribLFormat(GLuint arg0, + GLuint arg1, + GLint arg2, + GLenum arg3, + GLuint arg4) { + _pre_call_callback_gl("glVertexArrayAttribLFormat", + (void *) glVertexArrayAttribLFormat, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glVertexArrayAttribLFormat(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexArrayAttribLFormat", + (void *) glVertexArrayAttribLFormat, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_debug_glVertexArrayAttribLFormat = glad_debug_impl_glVertexArrayAttribLFormat; PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor; -void APIENTRY glad_debug_impl_glVertexArrayBindingDivisor(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glVertexArrayBindingDivisor", (void*)glVertexArrayBindingDivisor, 3, arg0, arg1, arg2); - glad_glVertexArrayBindingDivisor(arg0, arg1, arg2); - _post_call_callback_gl("glVertexArrayBindingDivisor", (void*)glVertexArrayBindingDivisor, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexArrayBindingDivisor(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glVertexArrayBindingDivisor", (void *) glVertexArrayBindingDivisor, 3, arg0, arg1, arg2); + glad_glVertexArrayBindingDivisor(arg0, arg1, arg2); + _post_call_callback_gl("glVertexArrayBindingDivisor", (void *) glVertexArrayBindingDivisor, 3, arg0, arg1, arg2); + } + PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_debug_glVertexArrayBindingDivisor = glad_debug_impl_glVertexArrayBindingDivisor; PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer; -void APIENTRY glad_debug_impl_glVertexArrayElementBuffer(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexArrayElementBuffer", (void*)glVertexArrayElementBuffer, 2, arg0, arg1); - glad_glVertexArrayElementBuffer(arg0, arg1); - _post_call_callback_gl("glVertexArrayElementBuffer", (void*)glVertexArrayElementBuffer, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexArrayElementBuffer(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexArrayElementBuffer", (void *) glVertexArrayElementBuffer, 2, arg0, arg1); + glad_glVertexArrayElementBuffer(arg0, arg1); + _post_call_callback_gl("glVertexArrayElementBuffer", (void *) glVertexArrayElementBuffer, 2, arg0, arg1); + } + PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_debug_glVertexArrayElementBuffer = glad_debug_impl_glVertexArrayElementBuffer; PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer; -void APIENTRY glad_debug_impl_glVertexArrayVertexBuffer(GLuint arg0, GLuint arg1, GLuint arg2, GLintptr arg3, GLsizei arg4) { - _pre_call_callback_gl("glVertexArrayVertexBuffer", (void*)glVertexArrayVertexBuffer, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexArrayVertexBuffer(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexArrayVertexBuffer", (void*)glVertexArrayVertexBuffer, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexArrayVertexBuffer(GLuint arg0, + GLuint arg1, + GLuint arg2, + GLintptr arg3, + GLsizei arg4) { + _pre_call_callback_gl("glVertexArrayVertexBuffer", + (void *) glVertexArrayVertexBuffer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + glad_glVertexArrayVertexBuffer(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexArrayVertexBuffer", + (void *) glVertexArrayVertexBuffer, + 5, + arg0, + arg1, + arg2, + arg3, + arg4); + } + PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_debug_glVertexArrayVertexBuffer = glad_debug_impl_glVertexArrayVertexBuffer; PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers; -void APIENTRY glad_debug_impl_glVertexArrayVertexBuffers(GLuint arg0, GLuint arg1, GLsizei arg2, const GLuint * arg3, const GLintptr * arg4, const GLsizei * arg5) { - _pre_call_callback_gl("glVertexArrayVertexBuffers", (void*)glVertexArrayVertexBuffers, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glVertexArrayVertexBuffers(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glVertexArrayVertexBuffers", (void*)glVertexArrayVertexBuffers, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glVertexArrayVertexBuffers(GLuint arg0, + GLuint arg1, + GLsizei arg2, + const GLuint *arg3, + const GLintptr *arg4, + const GLsizei *arg5) { + _pre_call_callback_gl("glVertexArrayVertexBuffers", + (void *) glVertexArrayVertexBuffers, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glVertexArrayVertexBuffers(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glVertexArrayVertexBuffers", + (void *) glVertexArrayVertexBuffers, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_debug_glVertexArrayVertexBuffers = glad_debug_impl_glVertexArrayVertexBuffers; PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d; -void APIENTRY glad_debug_impl_glVertexAttrib1d(GLuint arg0, GLdouble arg1) { - _pre_call_callback_gl("glVertexAttrib1d", (void*)glVertexAttrib1d, 2, arg0, arg1); - glad_glVertexAttrib1d(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1d", (void*)glVertexAttrib1d, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1d(GLuint arg0, GLdouble arg1) { + _pre_call_callback_gl("glVertexAttrib1d", (void *) glVertexAttrib1d, 2, arg0, arg1); + glad_glVertexAttrib1d(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1d", (void *) glVertexAttrib1d, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1DPROC glad_debug_glVertexAttrib1d = glad_debug_impl_glVertexAttrib1d; PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv; -void APIENTRY glad_debug_impl_glVertexAttrib1dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttrib1dv", (void*)glVertexAttrib1dv, 2, arg0, arg1); - glad_glVertexAttrib1dv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1dv", (void*)glVertexAttrib1dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttrib1dv", (void *) glVertexAttrib1dv, 2, arg0, arg1); + glad_glVertexAttrib1dv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1dv", (void *) glVertexAttrib1dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1DVPROC glad_debug_glVertexAttrib1dv = glad_debug_impl_glVertexAttrib1dv; PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f; -void APIENTRY glad_debug_impl_glVertexAttrib1f(GLuint arg0, GLfloat arg1) { - _pre_call_callback_gl("glVertexAttrib1f", (void*)glVertexAttrib1f, 2, arg0, arg1); - glad_glVertexAttrib1f(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1f", (void*)glVertexAttrib1f, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1f(GLuint arg0, GLfloat arg1) { + _pre_call_callback_gl("glVertexAttrib1f", (void *) glVertexAttrib1f, 2, arg0, arg1); + glad_glVertexAttrib1f(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1f", (void *) glVertexAttrib1f, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1FPROC glad_debug_glVertexAttrib1f = glad_debug_impl_glVertexAttrib1f; PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv; -void APIENTRY glad_debug_impl_glVertexAttrib1fv(GLuint arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glVertexAttrib1fv", (void*)glVertexAttrib1fv, 2, arg0, arg1); - glad_glVertexAttrib1fv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1fv", (void*)glVertexAttrib1fv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1fv(GLuint arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glVertexAttrib1fv", (void *) glVertexAttrib1fv, 2, arg0, arg1); + glad_glVertexAttrib1fv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1fv", (void *) glVertexAttrib1fv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1FVPROC glad_debug_glVertexAttrib1fv = glad_debug_impl_glVertexAttrib1fv; PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s; -void APIENTRY glad_debug_impl_glVertexAttrib1s(GLuint arg0, GLshort arg1) { - _pre_call_callback_gl("glVertexAttrib1s", (void*)glVertexAttrib1s, 2, arg0, arg1); - glad_glVertexAttrib1s(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1s", (void*)glVertexAttrib1s, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1s(GLuint arg0, GLshort arg1) { + _pre_call_callback_gl("glVertexAttrib1s", (void *) glVertexAttrib1s, 2, arg0, arg1); + glad_glVertexAttrib1s(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1s", (void *) glVertexAttrib1s, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1SPROC glad_debug_glVertexAttrib1s = glad_debug_impl_glVertexAttrib1s; PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv; -void APIENTRY glad_debug_impl_glVertexAttrib1sv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttrib1sv", (void*)glVertexAttrib1sv, 2, arg0, arg1); - glad_glVertexAttrib1sv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib1sv", (void*)glVertexAttrib1sv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib1sv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttrib1sv", (void *) glVertexAttrib1sv, 2, arg0, arg1); + glad_glVertexAttrib1sv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib1sv", (void *) glVertexAttrib1sv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB1SVPROC glad_debug_glVertexAttrib1sv = glad_debug_impl_glVertexAttrib1sv; PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d; -void APIENTRY glad_debug_impl_glVertexAttrib2d(GLuint arg0, GLdouble arg1, GLdouble arg2) { - _pre_call_callback_gl("glVertexAttrib2d", (void*)glVertexAttrib2d, 3, arg0, arg1, arg2); - glad_glVertexAttrib2d(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttrib2d", (void*)glVertexAttrib2d, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttrib2d(GLuint arg0, GLdouble arg1, GLdouble arg2) { + _pre_call_callback_gl("glVertexAttrib2d", (void *) glVertexAttrib2d, 3, arg0, arg1, arg2); + glad_glVertexAttrib2d(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttrib2d", (void *) glVertexAttrib2d, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIB2DPROC glad_debug_glVertexAttrib2d = glad_debug_impl_glVertexAttrib2d; PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv; -void APIENTRY glad_debug_impl_glVertexAttrib2dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttrib2dv", (void*)glVertexAttrib2dv, 2, arg0, arg1); - glad_glVertexAttrib2dv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib2dv", (void*)glVertexAttrib2dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib2dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttrib2dv", (void *) glVertexAttrib2dv, 2, arg0, arg1); + glad_glVertexAttrib2dv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib2dv", (void *) glVertexAttrib2dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB2DVPROC glad_debug_glVertexAttrib2dv = glad_debug_impl_glVertexAttrib2dv; PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f; -void APIENTRY glad_debug_impl_glVertexAttrib2f(GLuint arg0, GLfloat arg1, GLfloat arg2) { - _pre_call_callback_gl("glVertexAttrib2f", (void*)glVertexAttrib2f, 3, arg0, arg1, arg2); - glad_glVertexAttrib2f(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttrib2f", (void*)glVertexAttrib2f, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttrib2f(GLuint arg0, GLfloat arg1, GLfloat arg2) { + _pre_call_callback_gl("glVertexAttrib2f", (void *) glVertexAttrib2f, 3, arg0, arg1, arg2); + glad_glVertexAttrib2f(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttrib2f", (void *) glVertexAttrib2f, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIB2FPROC glad_debug_glVertexAttrib2f = glad_debug_impl_glVertexAttrib2f; PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv; -void APIENTRY glad_debug_impl_glVertexAttrib2fv(GLuint arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glVertexAttrib2fv", (void*)glVertexAttrib2fv, 2, arg0, arg1); - glad_glVertexAttrib2fv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib2fv", (void*)glVertexAttrib2fv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib2fv(GLuint arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glVertexAttrib2fv", (void *) glVertexAttrib2fv, 2, arg0, arg1); + glad_glVertexAttrib2fv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib2fv", (void *) glVertexAttrib2fv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB2FVPROC glad_debug_glVertexAttrib2fv = glad_debug_impl_glVertexAttrib2fv; PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s; -void APIENTRY glad_debug_impl_glVertexAttrib2s(GLuint arg0, GLshort arg1, GLshort arg2) { - _pre_call_callback_gl("glVertexAttrib2s", (void*)glVertexAttrib2s, 3, arg0, arg1, arg2); - glad_glVertexAttrib2s(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttrib2s", (void*)glVertexAttrib2s, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttrib2s(GLuint arg0, GLshort arg1, GLshort arg2) { + _pre_call_callback_gl("glVertexAttrib2s", (void *) glVertexAttrib2s, 3, arg0, arg1, arg2); + glad_glVertexAttrib2s(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttrib2s", (void *) glVertexAttrib2s, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIB2SPROC glad_debug_glVertexAttrib2s = glad_debug_impl_glVertexAttrib2s; PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv; -void APIENTRY glad_debug_impl_glVertexAttrib2sv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttrib2sv", (void*)glVertexAttrib2sv, 2, arg0, arg1); - glad_glVertexAttrib2sv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib2sv", (void*)glVertexAttrib2sv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib2sv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttrib2sv", (void *) glVertexAttrib2sv, 2, arg0, arg1); + glad_glVertexAttrib2sv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib2sv", (void *) glVertexAttrib2sv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB2SVPROC glad_debug_glVertexAttrib2sv = glad_debug_impl_glVertexAttrib2sv; PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d; -void APIENTRY glad_debug_impl_glVertexAttrib3d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { - _pre_call_callback_gl("glVertexAttrib3d", (void*)glVertexAttrib3d, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttrib3d(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttrib3d", (void*)glVertexAttrib3d, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttrib3d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { + _pre_call_callback_gl("glVertexAttrib3d", (void *) glVertexAttrib3d, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttrib3d(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttrib3d", (void *) glVertexAttrib3d, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIB3DPROC glad_debug_glVertexAttrib3d = glad_debug_impl_glVertexAttrib3d; PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv; -void APIENTRY glad_debug_impl_glVertexAttrib3dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttrib3dv", (void*)glVertexAttrib3dv, 2, arg0, arg1); - glad_glVertexAttrib3dv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib3dv", (void*)glVertexAttrib3dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib3dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttrib3dv", (void *) glVertexAttrib3dv, 2, arg0, arg1); + glad_glVertexAttrib3dv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib3dv", (void *) glVertexAttrib3dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB3DVPROC glad_debug_glVertexAttrib3dv = glad_debug_impl_glVertexAttrib3dv; PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f; -void APIENTRY glad_debug_impl_glVertexAttrib3f(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { - _pre_call_callback_gl("glVertexAttrib3f", (void*)glVertexAttrib3f, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttrib3f(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttrib3f", (void*)glVertexAttrib3f, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttrib3f(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3) { + _pre_call_callback_gl("glVertexAttrib3f", (void *) glVertexAttrib3f, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttrib3f(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttrib3f", (void *) glVertexAttrib3f, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIB3FPROC glad_debug_glVertexAttrib3f = glad_debug_impl_glVertexAttrib3f; PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv; -void APIENTRY glad_debug_impl_glVertexAttrib3fv(GLuint arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glVertexAttrib3fv", (void*)glVertexAttrib3fv, 2, arg0, arg1); - glad_glVertexAttrib3fv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib3fv", (void*)glVertexAttrib3fv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib3fv(GLuint arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glVertexAttrib3fv", (void *) glVertexAttrib3fv, 2, arg0, arg1); + glad_glVertexAttrib3fv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib3fv", (void *) glVertexAttrib3fv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB3FVPROC glad_debug_glVertexAttrib3fv = glad_debug_impl_glVertexAttrib3fv; PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s; -void APIENTRY glad_debug_impl_glVertexAttrib3s(GLuint arg0, GLshort arg1, GLshort arg2, GLshort arg3) { - _pre_call_callback_gl("glVertexAttrib3s", (void*)glVertexAttrib3s, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttrib3s(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttrib3s", (void*)glVertexAttrib3s, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttrib3s(GLuint arg0, GLshort arg1, GLshort arg2, GLshort arg3) { + _pre_call_callback_gl("glVertexAttrib3s", (void *) glVertexAttrib3s, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttrib3s(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttrib3s", (void *) glVertexAttrib3s, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIB3SPROC glad_debug_glVertexAttrib3s = glad_debug_impl_glVertexAttrib3s; PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv; -void APIENTRY glad_debug_impl_glVertexAttrib3sv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttrib3sv", (void*)glVertexAttrib3sv, 2, arg0, arg1); - glad_glVertexAttrib3sv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib3sv", (void*)glVertexAttrib3sv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib3sv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttrib3sv", (void *) glVertexAttrib3sv, 2, arg0, arg1); + glad_glVertexAttrib3sv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib3sv", (void *) glVertexAttrib3sv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB3SVPROC glad_debug_glVertexAttrib3sv = glad_debug_impl_glVertexAttrib3sv; PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv; -void APIENTRY glad_debug_impl_glVertexAttrib4Nbv(GLuint arg0, const GLbyte * arg1) { - _pre_call_callback_gl("glVertexAttrib4Nbv", (void*)glVertexAttrib4Nbv, 2, arg0, arg1); - glad_glVertexAttrib4Nbv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Nbv", (void*)glVertexAttrib4Nbv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nbv(GLuint arg0, const GLbyte *arg1) { + _pre_call_callback_gl("glVertexAttrib4Nbv", (void *) glVertexAttrib4Nbv, 2, arg0, arg1); + glad_glVertexAttrib4Nbv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Nbv", (void *) glVertexAttrib4Nbv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NBVPROC glad_debug_glVertexAttrib4Nbv = glad_debug_impl_glVertexAttrib4Nbv; PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv; -void APIENTRY glad_debug_impl_glVertexAttrib4Niv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttrib4Niv", (void*)glVertexAttrib4Niv, 2, arg0, arg1); - glad_glVertexAttrib4Niv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Niv", (void*)glVertexAttrib4Niv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Niv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttrib4Niv", (void *) glVertexAttrib4Niv, 2, arg0, arg1); + glad_glVertexAttrib4Niv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Niv", (void *) glVertexAttrib4Niv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NIVPROC glad_debug_glVertexAttrib4Niv = glad_debug_impl_glVertexAttrib4Niv; PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv; -void APIENTRY glad_debug_impl_glVertexAttrib4Nsv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttrib4Nsv", (void*)glVertexAttrib4Nsv, 2, arg0, arg1); - glad_glVertexAttrib4Nsv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Nsv", (void*)glVertexAttrib4Nsv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nsv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttrib4Nsv", (void *) glVertexAttrib4Nsv, 2, arg0, arg1); + glad_glVertexAttrib4Nsv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Nsv", (void *) glVertexAttrib4Nsv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NSVPROC glad_debug_glVertexAttrib4Nsv = glad_debug_impl_glVertexAttrib4Nsv; PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub; -void APIENTRY glad_debug_impl_glVertexAttrib4Nub(GLuint arg0, GLubyte arg1, GLubyte arg2, GLubyte arg3, GLubyte arg4) { - _pre_call_callback_gl("glVertexAttrib4Nub", (void*)glVertexAttrib4Nub, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttrib4Nub(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttrib4Nub", (void*)glVertexAttrib4Nub, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nub(GLuint arg0, GLubyte arg1, GLubyte arg2, GLubyte arg3, GLubyte arg4) { + _pre_call_callback_gl("glVertexAttrib4Nub", (void *) glVertexAttrib4Nub, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttrib4Nub(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttrib4Nub", (void *) glVertexAttrib4Nub, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIB4NUBPROC glad_debug_glVertexAttrib4Nub = glad_debug_impl_glVertexAttrib4Nub; PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv; -void APIENTRY glad_debug_impl_glVertexAttrib4Nubv(GLuint arg0, const GLubyte * arg1) { - _pre_call_callback_gl("glVertexAttrib4Nubv", (void*)glVertexAttrib4Nubv, 2, arg0, arg1); - glad_glVertexAttrib4Nubv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Nubv", (void*)glVertexAttrib4Nubv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nubv(GLuint arg0, const GLubyte *arg1) { + _pre_call_callback_gl("glVertexAttrib4Nubv", (void *) glVertexAttrib4Nubv, 2, arg0, arg1); + glad_glVertexAttrib4Nubv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Nubv", (void *) glVertexAttrib4Nubv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NUBVPROC glad_debug_glVertexAttrib4Nubv = glad_debug_impl_glVertexAttrib4Nubv; PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv; -void APIENTRY glad_debug_impl_glVertexAttrib4Nuiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttrib4Nuiv", (void*)glVertexAttrib4Nuiv, 2, arg0, arg1); - glad_glVertexAttrib4Nuiv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Nuiv", (void*)glVertexAttrib4Nuiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nuiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttrib4Nuiv", (void *) glVertexAttrib4Nuiv, 2, arg0, arg1); + glad_glVertexAttrib4Nuiv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Nuiv", (void *) glVertexAttrib4Nuiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NUIVPROC glad_debug_glVertexAttrib4Nuiv = glad_debug_impl_glVertexAttrib4Nuiv; PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv; -void APIENTRY glad_debug_impl_glVertexAttrib4Nusv(GLuint arg0, const GLushort * arg1) { - _pre_call_callback_gl("glVertexAttrib4Nusv", (void*)glVertexAttrib4Nusv, 2, arg0, arg1); - glad_glVertexAttrib4Nusv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4Nusv", (void*)glVertexAttrib4Nusv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4Nusv(GLuint arg0, const GLushort *arg1) { + _pre_call_callback_gl("glVertexAttrib4Nusv", (void *) glVertexAttrib4Nusv, 2, arg0, arg1); + glad_glVertexAttrib4Nusv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4Nusv", (void *) glVertexAttrib4Nusv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4NUSVPROC glad_debug_glVertexAttrib4Nusv = glad_debug_impl_glVertexAttrib4Nusv; PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv; -void APIENTRY glad_debug_impl_glVertexAttrib4bv(GLuint arg0, const GLbyte * arg1) { - _pre_call_callback_gl("glVertexAttrib4bv", (void*)glVertexAttrib4bv, 2, arg0, arg1); - glad_glVertexAttrib4bv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4bv", (void*)glVertexAttrib4bv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4bv(GLuint arg0, const GLbyte *arg1) { + _pre_call_callback_gl("glVertexAttrib4bv", (void *) glVertexAttrib4bv, 2, arg0, arg1); + glad_glVertexAttrib4bv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4bv", (void *) glVertexAttrib4bv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4BVPROC glad_debug_glVertexAttrib4bv = glad_debug_impl_glVertexAttrib4bv; PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d; -void APIENTRY glad_debug_impl_glVertexAttrib4d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { - _pre_call_callback_gl("glVertexAttrib4d", (void*)glVertexAttrib4d, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttrib4d(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttrib4d", (void*)glVertexAttrib4d, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttrib4d(GLuint arg0, + GLdouble arg1, + GLdouble arg2, + GLdouble arg3, + GLdouble arg4) { + _pre_call_callback_gl("glVertexAttrib4d", (void *) glVertexAttrib4d, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttrib4d(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttrib4d", (void *) glVertexAttrib4d, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIB4DPROC glad_debug_glVertexAttrib4d = glad_debug_impl_glVertexAttrib4d; PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv; -void APIENTRY glad_debug_impl_glVertexAttrib4dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttrib4dv", (void*)glVertexAttrib4dv, 2, arg0, arg1); - glad_glVertexAttrib4dv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4dv", (void*)glVertexAttrib4dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttrib4dv", (void *) glVertexAttrib4dv, 2, arg0, arg1); + glad_glVertexAttrib4dv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4dv", (void *) glVertexAttrib4dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4DVPROC glad_debug_glVertexAttrib4dv = glad_debug_impl_glVertexAttrib4dv; PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f; -void APIENTRY glad_debug_impl_glVertexAttrib4f(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { - _pre_call_callback_gl("glVertexAttrib4f", (void*)glVertexAttrib4f, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttrib4f(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttrib4f", (void*)glVertexAttrib4f, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttrib4f(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { + _pre_call_callback_gl("glVertexAttrib4f", (void *) glVertexAttrib4f, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttrib4f(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttrib4f", (void *) glVertexAttrib4f, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIB4FPROC glad_debug_glVertexAttrib4f = glad_debug_impl_glVertexAttrib4f; PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv; -void APIENTRY glad_debug_impl_glVertexAttrib4fv(GLuint arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glVertexAttrib4fv", (void*)glVertexAttrib4fv, 2, arg0, arg1); - glad_glVertexAttrib4fv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4fv", (void*)glVertexAttrib4fv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4fv(GLuint arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glVertexAttrib4fv", (void *) glVertexAttrib4fv, 2, arg0, arg1); + glad_glVertexAttrib4fv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4fv", (void *) glVertexAttrib4fv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4FVPROC glad_debug_glVertexAttrib4fv = glad_debug_impl_glVertexAttrib4fv; PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv; -void APIENTRY glad_debug_impl_glVertexAttrib4iv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttrib4iv", (void*)glVertexAttrib4iv, 2, arg0, arg1); - glad_glVertexAttrib4iv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4iv", (void*)glVertexAttrib4iv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4iv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttrib4iv", (void *) glVertexAttrib4iv, 2, arg0, arg1); + glad_glVertexAttrib4iv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4iv", (void *) glVertexAttrib4iv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4IVPROC glad_debug_glVertexAttrib4iv = glad_debug_impl_glVertexAttrib4iv; PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s; -void APIENTRY glad_debug_impl_glVertexAttrib4s(GLuint arg0, GLshort arg1, GLshort arg2, GLshort arg3, GLshort arg4) { - _pre_call_callback_gl("glVertexAttrib4s", (void*)glVertexAttrib4s, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttrib4s(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttrib4s", (void*)glVertexAttrib4s, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttrib4s(GLuint arg0, GLshort arg1, GLshort arg2, GLshort arg3, GLshort arg4) { + _pre_call_callback_gl("glVertexAttrib4s", (void *) glVertexAttrib4s, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttrib4s(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttrib4s", (void *) glVertexAttrib4s, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIB4SPROC glad_debug_glVertexAttrib4s = glad_debug_impl_glVertexAttrib4s; PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv; -void APIENTRY glad_debug_impl_glVertexAttrib4sv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttrib4sv", (void*)glVertexAttrib4sv, 2, arg0, arg1); - glad_glVertexAttrib4sv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4sv", (void*)glVertexAttrib4sv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4sv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttrib4sv", (void *) glVertexAttrib4sv, 2, arg0, arg1); + glad_glVertexAttrib4sv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4sv", (void *) glVertexAttrib4sv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4SVPROC glad_debug_glVertexAttrib4sv = glad_debug_impl_glVertexAttrib4sv; PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv; -void APIENTRY glad_debug_impl_glVertexAttrib4ubv(GLuint arg0, const GLubyte * arg1) { - _pre_call_callback_gl("glVertexAttrib4ubv", (void*)glVertexAttrib4ubv, 2, arg0, arg1); - glad_glVertexAttrib4ubv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4ubv", (void*)glVertexAttrib4ubv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4ubv(GLuint arg0, const GLubyte *arg1) { + _pre_call_callback_gl("glVertexAttrib4ubv", (void *) glVertexAttrib4ubv, 2, arg0, arg1); + glad_glVertexAttrib4ubv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4ubv", (void *) glVertexAttrib4ubv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4UBVPROC glad_debug_glVertexAttrib4ubv = glad_debug_impl_glVertexAttrib4ubv; PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv; -void APIENTRY glad_debug_impl_glVertexAttrib4uiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttrib4uiv", (void*)glVertexAttrib4uiv, 2, arg0, arg1); - glad_glVertexAttrib4uiv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4uiv", (void*)glVertexAttrib4uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4uiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttrib4uiv", (void *) glVertexAttrib4uiv, 2, arg0, arg1); + glad_glVertexAttrib4uiv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4uiv", (void *) glVertexAttrib4uiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4UIVPROC glad_debug_glVertexAttrib4uiv = glad_debug_impl_glVertexAttrib4uiv; PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv; -void APIENTRY glad_debug_impl_glVertexAttrib4usv(GLuint arg0, const GLushort * arg1) { - _pre_call_callback_gl("glVertexAttrib4usv", (void*)glVertexAttrib4usv, 2, arg0, arg1); - glad_glVertexAttrib4usv(arg0, arg1); - _post_call_callback_gl("glVertexAttrib4usv", (void*)glVertexAttrib4usv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttrib4usv(GLuint arg0, const GLushort *arg1) { + _pre_call_callback_gl("glVertexAttrib4usv", (void *) glVertexAttrib4usv, 2, arg0, arg1); + glad_glVertexAttrib4usv(arg0, arg1); + _post_call_callback_gl("glVertexAttrib4usv", (void *) glVertexAttrib4usv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIB4USVPROC glad_debug_glVertexAttrib4usv = glad_debug_impl_glVertexAttrib4usv; PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding; -void APIENTRY glad_debug_impl_glVertexAttribBinding(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexAttribBinding", (void*)glVertexAttribBinding, 2, arg0, arg1); - glad_glVertexAttribBinding(arg0, arg1); - _post_call_callback_gl("glVertexAttribBinding", (void*)glVertexAttribBinding, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribBinding(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexAttribBinding", (void *) glVertexAttribBinding, 2, arg0, arg1); + glad_glVertexAttribBinding(arg0, arg1); + _post_call_callback_gl("glVertexAttribBinding", (void *) glVertexAttribBinding, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBBINDINGPROC glad_debug_glVertexAttribBinding = glad_debug_impl_glVertexAttribBinding; PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor; -void APIENTRY glad_debug_impl_glVertexAttribDivisor(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexAttribDivisor", (void*)glVertexAttribDivisor, 2, arg0, arg1); - glad_glVertexAttribDivisor(arg0, arg1); - _post_call_callback_gl("glVertexAttribDivisor", (void*)glVertexAttribDivisor, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribDivisor(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexAttribDivisor", (void *) glVertexAttribDivisor, 2, arg0, arg1); + glad_glVertexAttribDivisor(arg0, arg1); + _post_call_callback_gl("glVertexAttribDivisor", (void *) glVertexAttribDivisor, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBDIVISORPROC glad_debug_glVertexAttribDivisor = glad_debug_impl_glVertexAttribDivisor; PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat; -void APIENTRY glad_debug_impl_glVertexAttribFormat(GLuint arg0, GLint arg1, GLenum arg2, GLboolean arg3, GLuint arg4) { - _pre_call_callback_gl("glVertexAttribFormat", (void*)glVertexAttribFormat, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribFormat(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribFormat", (void*)glVertexAttribFormat, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribFormat(GLuint arg0, GLint arg1, GLenum arg2, GLboolean arg3, GLuint arg4) { + _pre_call_callback_gl("glVertexAttribFormat", (void *) glVertexAttribFormat, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribFormat(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribFormat", (void *) glVertexAttribFormat, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBFORMATPROC glad_debug_glVertexAttribFormat = glad_debug_impl_glVertexAttribFormat; PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i; -void APIENTRY glad_debug_impl_glVertexAttribI1i(GLuint arg0, GLint arg1) { - _pre_call_callback_gl("glVertexAttribI1i", (void*)glVertexAttribI1i, 2, arg0, arg1); - glad_glVertexAttribI1i(arg0, arg1); - _post_call_callback_gl("glVertexAttribI1i", (void*)glVertexAttribI1i, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI1i(GLuint arg0, GLint arg1) { + _pre_call_callback_gl("glVertexAttribI1i", (void *) glVertexAttribI1i, 2, arg0, arg1); + glad_glVertexAttribI1i(arg0, arg1); + _post_call_callback_gl("glVertexAttribI1i", (void *) glVertexAttribI1i, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI1IPROC glad_debug_glVertexAttribI1i = glad_debug_impl_glVertexAttribI1i; PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv; -void APIENTRY glad_debug_impl_glVertexAttribI1iv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttribI1iv", (void*)glVertexAttribI1iv, 2, arg0, arg1); - glad_glVertexAttribI1iv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI1iv", (void*)glVertexAttribI1iv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI1iv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttribI1iv", (void *) glVertexAttribI1iv, 2, arg0, arg1); + glad_glVertexAttribI1iv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI1iv", (void *) glVertexAttribI1iv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI1IVPROC glad_debug_glVertexAttribI1iv = glad_debug_impl_glVertexAttribI1iv; PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui; -void APIENTRY glad_debug_impl_glVertexAttribI1ui(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexAttribI1ui", (void*)glVertexAttribI1ui, 2, arg0, arg1); - glad_glVertexAttribI1ui(arg0, arg1); - _post_call_callback_gl("glVertexAttribI1ui", (void*)glVertexAttribI1ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI1ui(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexAttribI1ui", (void *) glVertexAttribI1ui, 2, arg0, arg1); + glad_glVertexAttribI1ui(arg0, arg1); + _post_call_callback_gl("glVertexAttribI1ui", (void *) glVertexAttribI1ui, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI1UIPROC glad_debug_glVertexAttribI1ui = glad_debug_impl_glVertexAttribI1ui; PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv; -void APIENTRY glad_debug_impl_glVertexAttribI1uiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttribI1uiv", (void*)glVertexAttribI1uiv, 2, arg0, arg1); - glad_glVertexAttribI1uiv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI1uiv", (void*)glVertexAttribI1uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI1uiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttribI1uiv", (void *) glVertexAttribI1uiv, 2, arg0, arg1); + glad_glVertexAttribI1uiv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI1uiv", (void *) glVertexAttribI1uiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI1UIVPROC glad_debug_glVertexAttribI1uiv = glad_debug_impl_glVertexAttribI1uiv; PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i; -void APIENTRY glad_debug_impl_glVertexAttribI2i(GLuint arg0, GLint arg1, GLint arg2) { - _pre_call_callback_gl("glVertexAttribI2i", (void*)glVertexAttribI2i, 3, arg0, arg1, arg2); - glad_glVertexAttribI2i(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttribI2i", (void*)glVertexAttribI2i, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttribI2i(GLuint arg0, GLint arg1, GLint arg2) { + _pre_call_callback_gl("glVertexAttribI2i", (void *) glVertexAttribI2i, 3, arg0, arg1, arg2); + glad_glVertexAttribI2i(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttribI2i", (void *) glVertexAttribI2i, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIBI2IPROC glad_debug_glVertexAttribI2i = glad_debug_impl_glVertexAttribI2i; PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv; -void APIENTRY glad_debug_impl_glVertexAttribI2iv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttribI2iv", (void*)glVertexAttribI2iv, 2, arg0, arg1); - glad_glVertexAttribI2iv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI2iv", (void*)glVertexAttribI2iv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI2iv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttribI2iv", (void *) glVertexAttribI2iv, 2, arg0, arg1); + glad_glVertexAttribI2iv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI2iv", (void *) glVertexAttribI2iv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI2IVPROC glad_debug_glVertexAttribI2iv = glad_debug_impl_glVertexAttribI2iv; PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui; -void APIENTRY glad_debug_impl_glVertexAttribI2ui(GLuint arg0, GLuint arg1, GLuint arg2) { - _pre_call_callback_gl("glVertexAttribI2ui", (void*)glVertexAttribI2ui, 3, arg0, arg1, arg2); - glad_glVertexAttribI2ui(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttribI2ui", (void*)glVertexAttribI2ui, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttribI2ui(GLuint arg0, GLuint arg1, GLuint arg2) { + _pre_call_callback_gl("glVertexAttribI2ui", (void *) glVertexAttribI2ui, 3, arg0, arg1, arg2); + glad_glVertexAttribI2ui(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttribI2ui", (void *) glVertexAttribI2ui, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIBI2UIPROC glad_debug_glVertexAttribI2ui = glad_debug_impl_glVertexAttribI2ui; PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv; -void APIENTRY glad_debug_impl_glVertexAttribI2uiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttribI2uiv", (void*)glVertexAttribI2uiv, 2, arg0, arg1); - glad_glVertexAttribI2uiv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI2uiv", (void*)glVertexAttribI2uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI2uiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttribI2uiv", (void *) glVertexAttribI2uiv, 2, arg0, arg1); + glad_glVertexAttribI2uiv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI2uiv", (void *) glVertexAttribI2uiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI2UIVPROC glad_debug_glVertexAttribI2uiv = glad_debug_impl_glVertexAttribI2uiv; PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i; -void APIENTRY glad_debug_impl_glVertexAttribI3i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3) { - _pre_call_callback_gl("glVertexAttribI3i", (void*)glVertexAttribI3i, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribI3i(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribI3i", (void*)glVertexAttribI3i, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribI3i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3) { + _pre_call_callback_gl("glVertexAttribI3i", (void *) glVertexAttribI3i, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribI3i(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribI3i", (void *) glVertexAttribI3i, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBI3IPROC glad_debug_glVertexAttribI3i = glad_debug_impl_glVertexAttribI3i; PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv; -void APIENTRY glad_debug_impl_glVertexAttribI3iv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttribI3iv", (void*)glVertexAttribI3iv, 2, arg0, arg1); - glad_glVertexAttribI3iv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI3iv", (void*)glVertexAttribI3iv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI3iv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttribI3iv", (void *) glVertexAttribI3iv, 2, arg0, arg1); + glad_glVertexAttribI3iv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI3iv", (void *) glVertexAttribI3iv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI3IVPROC glad_debug_glVertexAttribI3iv = glad_debug_impl_glVertexAttribI3iv; PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui; -void APIENTRY glad_debug_impl_glVertexAttribI3ui(GLuint arg0, GLuint arg1, GLuint arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribI3ui", (void*)glVertexAttribI3ui, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribI3ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribI3ui", (void*)glVertexAttribI3ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribI3ui(GLuint arg0, GLuint arg1, GLuint arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribI3ui", (void *) glVertexAttribI3ui, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribI3ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribI3ui", (void *) glVertexAttribI3ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBI3UIPROC glad_debug_glVertexAttribI3ui = glad_debug_impl_glVertexAttribI3ui; PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv; -void APIENTRY glad_debug_impl_glVertexAttribI3uiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttribI3uiv", (void*)glVertexAttribI3uiv, 2, arg0, arg1); - glad_glVertexAttribI3uiv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI3uiv", (void*)glVertexAttribI3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI3uiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttribI3uiv", (void *) glVertexAttribI3uiv, 2, arg0, arg1); + glad_glVertexAttribI3uiv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI3uiv", (void *) glVertexAttribI3uiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI3UIVPROC glad_debug_glVertexAttribI3uiv = glad_debug_impl_glVertexAttribI3uiv; PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv; -void APIENTRY glad_debug_impl_glVertexAttribI4bv(GLuint arg0, const GLbyte * arg1) { - _pre_call_callback_gl("glVertexAttribI4bv", (void*)glVertexAttribI4bv, 2, arg0, arg1); - glad_glVertexAttribI4bv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4bv", (void*)glVertexAttribI4bv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4bv(GLuint arg0, const GLbyte *arg1) { + _pre_call_callback_gl("glVertexAttribI4bv", (void *) glVertexAttribI4bv, 2, arg0, arg1); + glad_glVertexAttribI4bv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4bv", (void *) glVertexAttribI4bv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4BVPROC glad_debug_glVertexAttribI4bv = glad_debug_impl_glVertexAttribI4bv; PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i; -void APIENTRY glad_debug_impl_glVertexAttribI4i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { - _pre_call_callback_gl("glVertexAttribI4i", (void*)glVertexAttribI4i, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribI4i(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribI4i", (void*)glVertexAttribI4i, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribI4i(GLuint arg0, GLint arg1, GLint arg2, GLint arg3, GLint arg4) { + _pre_call_callback_gl("glVertexAttribI4i", (void *) glVertexAttribI4i, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribI4i(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribI4i", (void *) glVertexAttribI4i, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBI4IPROC glad_debug_glVertexAttribI4i = glad_debug_impl_glVertexAttribI4i; PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv; -void APIENTRY glad_debug_impl_glVertexAttribI4iv(GLuint arg0, const GLint * arg1) { - _pre_call_callback_gl("glVertexAttribI4iv", (void*)glVertexAttribI4iv, 2, arg0, arg1); - glad_glVertexAttribI4iv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4iv", (void*)glVertexAttribI4iv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4iv(GLuint arg0, const GLint *arg1) { + _pre_call_callback_gl("glVertexAttribI4iv", (void *) glVertexAttribI4iv, 2, arg0, arg1); + glad_glVertexAttribI4iv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4iv", (void *) glVertexAttribI4iv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4IVPROC glad_debug_glVertexAttribI4iv = glad_debug_impl_glVertexAttribI4iv; PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv; -void APIENTRY glad_debug_impl_glVertexAttribI4sv(GLuint arg0, const GLshort * arg1) { - _pre_call_callback_gl("glVertexAttribI4sv", (void*)glVertexAttribI4sv, 2, arg0, arg1); - glad_glVertexAttribI4sv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4sv", (void*)glVertexAttribI4sv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4sv(GLuint arg0, const GLshort *arg1) { + _pre_call_callback_gl("glVertexAttribI4sv", (void *) glVertexAttribI4sv, 2, arg0, arg1); + glad_glVertexAttribI4sv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4sv", (void *) glVertexAttribI4sv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4SVPROC glad_debug_glVertexAttribI4sv = glad_debug_impl_glVertexAttribI4sv; PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv; -void APIENTRY glad_debug_impl_glVertexAttribI4ubv(GLuint arg0, const GLubyte * arg1) { - _pre_call_callback_gl("glVertexAttribI4ubv", (void*)glVertexAttribI4ubv, 2, arg0, arg1); - glad_glVertexAttribI4ubv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4ubv", (void*)glVertexAttribI4ubv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4ubv(GLuint arg0, const GLubyte *arg1) { + _pre_call_callback_gl("glVertexAttribI4ubv", (void *) glVertexAttribI4ubv, 2, arg0, arg1); + glad_glVertexAttribI4ubv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4ubv", (void *) glVertexAttribI4ubv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4UBVPROC glad_debug_glVertexAttribI4ubv = glad_debug_impl_glVertexAttribI4ubv; PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui; -void APIENTRY glad_debug_impl_glVertexAttribI4ui(GLuint arg0, GLuint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { - _pre_call_callback_gl("glVertexAttribI4ui", (void*)glVertexAttribI4ui, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribI4ui(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribI4ui", (void*)glVertexAttribI4ui, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribI4ui(GLuint arg0, GLuint arg1, GLuint arg2, GLuint arg3, GLuint arg4) { + _pre_call_callback_gl("glVertexAttribI4ui", (void *) glVertexAttribI4ui, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribI4ui(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribI4ui", (void *) glVertexAttribI4ui, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBI4UIPROC glad_debug_glVertexAttribI4ui = glad_debug_impl_glVertexAttribI4ui; PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv; -void APIENTRY glad_debug_impl_glVertexAttribI4uiv(GLuint arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexAttribI4uiv", (void*)glVertexAttribI4uiv, 2, arg0, arg1); - glad_glVertexAttribI4uiv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4uiv", (void*)glVertexAttribI4uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4uiv(GLuint arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexAttribI4uiv", (void *) glVertexAttribI4uiv, 2, arg0, arg1); + glad_glVertexAttribI4uiv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4uiv", (void *) glVertexAttribI4uiv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4UIVPROC glad_debug_glVertexAttribI4uiv = glad_debug_impl_glVertexAttribI4uiv; PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv; -void APIENTRY glad_debug_impl_glVertexAttribI4usv(GLuint arg0, const GLushort * arg1) { - _pre_call_callback_gl("glVertexAttribI4usv", (void*)glVertexAttribI4usv, 2, arg0, arg1); - glad_glVertexAttribI4usv(arg0, arg1); - _post_call_callback_gl("glVertexAttribI4usv", (void*)glVertexAttribI4usv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribI4usv(GLuint arg0, const GLushort *arg1) { + _pre_call_callback_gl("glVertexAttribI4usv", (void *) glVertexAttribI4usv, 2, arg0, arg1); + glad_glVertexAttribI4usv(arg0, arg1); + _post_call_callback_gl("glVertexAttribI4usv", (void *) glVertexAttribI4usv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBI4USVPROC glad_debug_glVertexAttribI4usv = glad_debug_impl_glVertexAttribI4usv; PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat; -void APIENTRY glad_debug_impl_glVertexAttribIFormat(GLuint arg0, GLint arg1, GLenum arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribIFormat", (void*)glVertexAttribIFormat, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribIFormat(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribIFormat", (void*)glVertexAttribIFormat, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribIFormat(GLuint arg0, GLint arg1, GLenum arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribIFormat", (void *) glVertexAttribIFormat, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribIFormat(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribIFormat", (void *) glVertexAttribIFormat, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBIFORMATPROC glad_debug_glVertexAttribIFormat = glad_debug_impl_glVertexAttribIFormat; PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer; -void APIENTRY glad_debug_impl_glVertexAttribIPointer(GLuint arg0, GLint arg1, GLenum arg2, GLsizei arg3, const void * arg4) { - _pre_call_callback_gl("glVertexAttribIPointer", (void*)glVertexAttribIPointer, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribIPointer(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribIPointer", (void*)glVertexAttribIPointer, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribIPointer(GLuint arg0, + GLint arg1, + GLenum arg2, + GLsizei arg3, + const void *arg4) { + _pre_call_callback_gl("glVertexAttribIPointer", (void *) glVertexAttribIPointer, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribIPointer(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribIPointer", (void *) glVertexAttribIPointer, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBIPOINTERPROC glad_debug_glVertexAttribIPointer = glad_debug_impl_glVertexAttribIPointer; PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d; -void APIENTRY glad_debug_impl_glVertexAttribL1d(GLuint arg0, GLdouble arg1) { - _pre_call_callback_gl("glVertexAttribL1d", (void*)glVertexAttribL1d, 2, arg0, arg1); - glad_glVertexAttribL1d(arg0, arg1); - _post_call_callback_gl("glVertexAttribL1d", (void*)glVertexAttribL1d, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribL1d(GLuint arg0, GLdouble arg1) { + _pre_call_callback_gl("glVertexAttribL1d", (void *) glVertexAttribL1d, 2, arg0, arg1); + glad_glVertexAttribL1d(arg0, arg1); + _post_call_callback_gl("glVertexAttribL1d", (void *) glVertexAttribL1d, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBL1DPROC glad_debug_glVertexAttribL1d = glad_debug_impl_glVertexAttribL1d; PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv; -void APIENTRY glad_debug_impl_glVertexAttribL1dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttribL1dv", (void*)glVertexAttribL1dv, 2, arg0, arg1); - glad_glVertexAttribL1dv(arg0, arg1); - _post_call_callback_gl("glVertexAttribL1dv", (void*)glVertexAttribL1dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribL1dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttribL1dv", (void *) glVertexAttribL1dv, 2, arg0, arg1); + glad_glVertexAttribL1dv(arg0, arg1); + _post_call_callback_gl("glVertexAttribL1dv", (void *) glVertexAttribL1dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBL1DVPROC glad_debug_glVertexAttribL1dv = glad_debug_impl_glVertexAttribL1dv; PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d; -void APIENTRY glad_debug_impl_glVertexAttribL2d(GLuint arg0, GLdouble arg1, GLdouble arg2) { - _pre_call_callback_gl("glVertexAttribL2d", (void*)glVertexAttribL2d, 3, arg0, arg1, arg2); - glad_glVertexAttribL2d(arg0, arg1, arg2); - _post_call_callback_gl("glVertexAttribL2d", (void*)glVertexAttribL2d, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glVertexAttribL2d(GLuint arg0, GLdouble arg1, GLdouble arg2) { + _pre_call_callback_gl("glVertexAttribL2d", (void *) glVertexAttribL2d, 3, arg0, arg1, arg2); + glad_glVertexAttribL2d(arg0, arg1, arg2); + _post_call_callback_gl("glVertexAttribL2d", (void *) glVertexAttribL2d, 3, arg0, arg1, arg2); + } + PFNGLVERTEXATTRIBL2DPROC glad_debug_glVertexAttribL2d = glad_debug_impl_glVertexAttribL2d; PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv; -void APIENTRY glad_debug_impl_glVertexAttribL2dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttribL2dv", (void*)glVertexAttribL2dv, 2, arg0, arg1); - glad_glVertexAttribL2dv(arg0, arg1); - _post_call_callback_gl("glVertexAttribL2dv", (void*)glVertexAttribL2dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribL2dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttribL2dv", (void *) glVertexAttribL2dv, 2, arg0, arg1); + glad_glVertexAttribL2dv(arg0, arg1); + _post_call_callback_gl("glVertexAttribL2dv", (void *) glVertexAttribL2dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBL2DVPROC glad_debug_glVertexAttribL2dv = glad_debug_impl_glVertexAttribL2dv; PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d; -void APIENTRY glad_debug_impl_glVertexAttribL3d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { - _pre_call_callback_gl("glVertexAttribL3d", (void*)glVertexAttribL3d, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribL3d(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribL3d", (void*)glVertexAttribL3d, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribL3d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3) { + _pre_call_callback_gl("glVertexAttribL3d", (void *) glVertexAttribL3d, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribL3d(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribL3d", (void *) glVertexAttribL3d, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBL3DPROC glad_debug_glVertexAttribL3d = glad_debug_impl_glVertexAttribL3d; PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv; -void APIENTRY glad_debug_impl_glVertexAttribL3dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttribL3dv", (void*)glVertexAttribL3dv, 2, arg0, arg1); - glad_glVertexAttribL3dv(arg0, arg1); - _post_call_callback_gl("glVertexAttribL3dv", (void*)glVertexAttribL3dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribL3dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttribL3dv", (void *) glVertexAttribL3dv, 2, arg0, arg1); + glad_glVertexAttribL3dv(arg0, arg1); + _post_call_callback_gl("glVertexAttribL3dv", (void *) glVertexAttribL3dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBL3DVPROC glad_debug_glVertexAttribL3dv = glad_debug_impl_glVertexAttribL3dv; PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d; -void APIENTRY glad_debug_impl_glVertexAttribL4d(GLuint arg0, GLdouble arg1, GLdouble arg2, GLdouble arg3, GLdouble arg4) { - _pre_call_callback_gl("glVertexAttribL4d", (void*)glVertexAttribL4d, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribL4d(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribL4d", (void*)glVertexAttribL4d, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribL4d(GLuint arg0, + GLdouble arg1, + GLdouble arg2, + GLdouble arg3, + GLdouble arg4) { + _pre_call_callback_gl("glVertexAttribL4d", (void *) glVertexAttribL4d, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribL4d(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribL4d", (void *) glVertexAttribL4d, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBL4DPROC glad_debug_glVertexAttribL4d = glad_debug_impl_glVertexAttribL4d; PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv; -void APIENTRY glad_debug_impl_glVertexAttribL4dv(GLuint arg0, const GLdouble * arg1) { - _pre_call_callback_gl("glVertexAttribL4dv", (void*)glVertexAttribL4dv, 2, arg0, arg1); - glad_glVertexAttribL4dv(arg0, arg1); - _post_call_callback_gl("glVertexAttribL4dv", (void*)glVertexAttribL4dv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexAttribL4dv(GLuint arg0, const GLdouble *arg1) { + _pre_call_callback_gl("glVertexAttribL4dv", (void *) glVertexAttribL4dv, 2, arg0, arg1); + glad_glVertexAttribL4dv(arg0, arg1); + _post_call_callback_gl("glVertexAttribL4dv", (void *) glVertexAttribL4dv, 2, arg0, arg1); + } + PFNGLVERTEXATTRIBL4DVPROC glad_debug_glVertexAttribL4dv = glad_debug_impl_glVertexAttribL4dv; PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat; -void APIENTRY glad_debug_impl_glVertexAttribLFormat(GLuint arg0, GLint arg1, GLenum arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribLFormat", (void*)glVertexAttribLFormat, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribLFormat(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribLFormat", (void*)glVertexAttribLFormat, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribLFormat(GLuint arg0, GLint arg1, GLenum arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribLFormat", (void *) glVertexAttribLFormat, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribLFormat(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribLFormat", (void *) glVertexAttribLFormat, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBLFORMATPROC glad_debug_glVertexAttribLFormat = glad_debug_impl_glVertexAttribLFormat; PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer; -void APIENTRY glad_debug_impl_glVertexAttribLPointer(GLuint arg0, GLint arg1, GLenum arg2, GLsizei arg3, const void * arg4) { - _pre_call_callback_gl("glVertexAttribLPointer", (void*)glVertexAttribLPointer, 5, arg0, arg1, arg2, arg3, arg4); - glad_glVertexAttribLPointer(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glVertexAttribLPointer", (void*)glVertexAttribLPointer, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glVertexAttribLPointer(GLuint arg0, + GLint arg1, + GLenum arg2, + GLsizei arg3, + const void *arg4) { + _pre_call_callback_gl("glVertexAttribLPointer", (void *) glVertexAttribLPointer, 5, arg0, arg1, arg2, arg3, arg4); + glad_glVertexAttribLPointer(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glVertexAttribLPointer", (void *) glVertexAttribLPointer, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVERTEXATTRIBLPOINTERPROC glad_debug_glVertexAttribLPointer = glad_debug_impl_glVertexAttribLPointer; PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui; -void APIENTRY glad_debug_impl_glVertexAttribP1ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribP1ui", (void*)glVertexAttribP1ui, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP1ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP1ui", (void*)glVertexAttribP1ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP1ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribP1ui", (void *) glVertexAttribP1ui, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP1ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP1ui", (void *) glVertexAttribP1ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP1UIPROC glad_debug_glVertexAttribP1ui = glad_debug_impl_glVertexAttribP1ui; PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv; -void APIENTRY glad_debug_impl_glVertexAttribP1uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint * arg3) { - _pre_call_callback_gl("glVertexAttribP1uiv", (void*)glVertexAttribP1uiv, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP1uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP1uiv", (void*)glVertexAttribP1uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP1uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint *arg3) { + _pre_call_callback_gl("glVertexAttribP1uiv", (void *) glVertexAttribP1uiv, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP1uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP1uiv", (void *) glVertexAttribP1uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP1UIVPROC glad_debug_glVertexAttribP1uiv = glad_debug_impl_glVertexAttribP1uiv; PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui; -void APIENTRY glad_debug_impl_glVertexAttribP2ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribP2ui", (void*)glVertexAttribP2ui, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP2ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP2ui", (void*)glVertexAttribP2ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP2ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribP2ui", (void *) glVertexAttribP2ui, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP2ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP2ui", (void *) glVertexAttribP2ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP2UIPROC glad_debug_glVertexAttribP2ui = glad_debug_impl_glVertexAttribP2ui; PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv; -void APIENTRY glad_debug_impl_glVertexAttribP2uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint * arg3) { - _pre_call_callback_gl("glVertexAttribP2uiv", (void*)glVertexAttribP2uiv, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP2uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP2uiv", (void*)glVertexAttribP2uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP2uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint *arg3) { + _pre_call_callback_gl("glVertexAttribP2uiv", (void *) glVertexAttribP2uiv, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP2uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP2uiv", (void *) glVertexAttribP2uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP2UIVPROC glad_debug_glVertexAttribP2uiv = glad_debug_impl_glVertexAttribP2uiv; PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui; -void APIENTRY glad_debug_impl_glVertexAttribP3ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribP3ui", (void*)glVertexAttribP3ui, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP3ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP3ui", (void*)glVertexAttribP3ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP3ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribP3ui", (void *) glVertexAttribP3ui, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP3ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP3ui", (void *) glVertexAttribP3ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP3UIPROC glad_debug_glVertexAttribP3ui = glad_debug_impl_glVertexAttribP3ui; PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv; -void APIENTRY glad_debug_impl_glVertexAttribP3uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint * arg3) { - _pre_call_callback_gl("glVertexAttribP3uiv", (void*)glVertexAttribP3uiv, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP3uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP3uiv", (void*)glVertexAttribP3uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP3uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint *arg3) { + _pre_call_callback_gl("glVertexAttribP3uiv", (void *) glVertexAttribP3uiv, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP3uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP3uiv", (void *) glVertexAttribP3uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP3UIVPROC glad_debug_glVertexAttribP3uiv = glad_debug_impl_glVertexAttribP3uiv; PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui; -void APIENTRY glad_debug_impl_glVertexAttribP4ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { - _pre_call_callback_gl("glVertexAttribP4ui", (void*)glVertexAttribP4ui, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP4ui(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP4ui", (void*)glVertexAttribP4ui, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP4ui(GLuint arg0, GLenum arg1, GLboolean arg2, GLuint arg3) { + _pre_call_callback_gl("glVertexAttribP4ui", (void *) glVertexAttribP4ui, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP4ui(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP4ui", (void *) glVertexAttribP4ui, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP4UIPROC glad_debug_glVertexAttribP4ui = glad_debug_impl_glVertexAttribP4ui; PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv; -void APIENTRY glad_debug_impl_glVertexAttribP4uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint * arg3) { - _pre_call_callback_gl("glVertexAttribP4uiv", (void*)glVertexAttribP4uiv, 4, arg0, arg1, arg2, arg3); - glad_glVertexAttribP4uiv(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glVertexAttribP4uiv", (void*)glVertexAttribP4uiv, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glVertexAttribP4uiv(GLuint arg0, GLenum arg1, GLboolean arg2, const GLuint *arg3) { + _pre_call_callback_gl("glVertexAttribP4uiv", (void *) glVertexAttribP4uiv, 4, arg0, arg1, arg2, arg3); + glad_glVertexAttribP4uiv(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glVertexAttribP4uiv", (void *) glVertexAttribP4uiv, 4, arg0, arg1, arg2, arg3); + } + PFNGLVERTEXATTRIBP4UIVPROC glad_debug_glVertexAttribP4uiv = glad_debug_impl_glVertexAttribP4uiv; PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer; -void APIENTRY glad_debug_impl_glVertexAttribPointer(GLuint arg0, GLint arg1, GLenum arg2, GLboolean arg3, GLsizei arg4, const void * arg5) { - _pre_call_callback_gl("glVertexAttribPointer", (void*)glVertexAttribPointer, 6, arg0, arg1, arg2, arg3, arg4, arg5); - glad_glVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, arg5); - _post_call_callback_gl("glVertexAttribPointer", (void*)glVertexAttribPointer, 6, arg0, arg1, arg2, arg3, arg4, arg5); - + +void APIENTRY glad_debug_impl_glVertexAttribPointer(GLuint arg0, + GLint arg1, + GLenum arg2, + GLboolean arg3, + GLsizei arg4, + const void *arg5) { + _pre_call_callback_gl("glVertexAttribPointer", + (void *) glVertexAttribPointer, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + glad_glVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, arg5); + _post_call_callback_gl("glVertexAttribPointer", + (void *) glVertexAttribPointer, + 6, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } + PFNGLVERTEXATTRIBPOINTERPROC glad_debug_glVertexAttribPointer = glad_debug_impl_glVertexAttribPointer; PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor; -void APIENTRY glad_debug_impl_glVertexBindingDivisor(GLuint arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexBindingDivisor", (void*)glVertexBindingDivisor, 2, arg0, arg1); - glad_glVertexBindingDivisor(arg0, arg1); - _post_call_callback_gl("glVertexBindingDivisor", (void*)glVertexBindingDivisor, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexBindingDivisor(GLuint arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexBindingDivisor", (void *) glVertexBindingDivisor, 2, arg0, arg1); + glad_glVertexBindingDivisor(arg0, arg1); + _post_call_callback_gl("glVertexBindingDivisor", (void *) glVertexBindingDivisor, 2, arg0, arg1); + } + PFNGLVERTEXBINDINGDIVISORPROC glad_debug_glVertexBindingDivisor = glad_debug_impl_glVertexBindingDivisor; PFNGLVERTEXP2UIPROC glad_glVertexP2ui; -void APIENTRY glad_debug_impl_glVertexP2ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexP2ui", (void*)glVertexP2ui, 2, arg0, arg1); - glad_glVertexP2ui(arg0, arg1); - _post_call_callback_gl("glVertexP2ui", (void*)glVertexP2ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP2ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexP2ui", (void *) glVertexP2ui, 2, arg0, arg1); + glad_glVertexP2ui(arg0, arg1); + _post_call_callback_gl("glVertexP2ui", (void *) glVertexP2ui, 2, arg0, arg1); + } + PFNGLVERTEXP2UIPROC glad_debug_glVertexP2ui = glad_debug_impl_glVertexP2ui; PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv; -void APIENTRY glad_debug_impl_glVertexP2uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexP2uiv", (void*)glVertexP2uiv, 2, arg0, arg1); - glad_glVertexP2uiv(arg0, arg1); - _post_call_callback_gl("glVertexP2uiv", (void*)glVertexP2uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP2uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexP2uiv", (void *) glVertexP2uiv, 2, arg0, arg1); + glad_glVertexP2uiv(arg0, arg1); + _post_call_callback_gl("glVertexP2uiv", (void *) glVertexP2uiv, 2, arg0, arg1); + } + PFNGLVERTEXP2UIVPROC glad_debug_glVertexP2uiv = glad_debug_impl_glVertexP2uiv; PFNGLVERTEXP3UIPROC glad_glVertexP3ui; -void APIENTRY glad_debug_impl_glVertexP3ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexP3ui", (void*)glVertexP3ui, 2, arg0, arg1); - glad_glVertexP3ui(arg0, arg1); - _post_call_callback_gl("glVertexP3ui", (void*)glVertexP3ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP3ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexP3ui", (void *) glVertexP3ui, 2, arg0, arg1); + glad_glVertexP3ui(arg0, arg1); + _post_call_callback_gl("glVertexP3ui", (void *) glVertexP3ui, 2, arg0, arg1); + } + PFNGLVERTEXP3UIPROC glad_debug_glVertexP3ui = glad_debug_impl_glVertexP3ui; PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv; -void APIENTRY glad_debug_impl_glVertexP3uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexP3uiv", (void*)glVertexP3uiv, 2, arg0, arg1); - glad_glVertexP3uiv(arg0, arg1); - _post_call_callback_gl("glVertexP3uiv", (void*)glVertexP3uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP3uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexP3uiv", (void *) glVertexP3uiv, 2, arg0, arg1); + glad_glVertexP3uiv(arg0, arg1); + _post_call_callback_gl("glVertexP3uiv", (void *) glVertexP3uiv, 2, arg0, arg1); + } + PFNGLVERTEXP3UIVPROC glad_debug_glVertexP3uiv = glad_debug_impl_glVertexP3uiv; PFNGLVERTEXP4UIPROC glad_glVertexP4ui; -void APIENTRY glad_debug_impl_glVertexP4ui(GLenum arg0, GLuint arg1) { - _pre_call_callback_gl("glVertexP4ui", (void*)glVertexP4ui, 2, arg0, arg1); - glad_glVertexP4ui(arg0, arg1); - _post_call_callback_gl("glVertexP4ui", (void*)glVertexP4ui, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP4ui(GLenum arg0, GLuint arg1) { + _pre_call_callback_gl("glVertexP4ui", (void *) glVertexP4ui, 2, arg0, arg1); + glad_glVertexP4ui(arg0, arg1); + _post_call_callback_gl("glVertexP4ui", (void *) glVertexP4ui, 2, arg0, arg1); + } + PFNGLVERTEXP4UIPROC glad_debug_glVertexP4ui = glad_debug_impl_glVertexP4ui; PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv; -void APIENTRY glad_debug_impl_glVertexP4uiv(GLenum arg0, const GLuint * arg1) { - _pre_call_callback_gl("glVertexP4uiv", (void*)glVertexP4uiv, 2, arg0, arg1); - glad_glVertexP4uiv(arg0, arg1); - _post_call_callback_gl("glVertexP4uiv", (void*)glVertexP4uiv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glVertexP4uiv(GLenum arg0, const GLuint *arg1) { + _pre_call_callback_gl("glVertexP4uiv", (void *) glVertexP4uiv, 2, arg0, arg1); + glad_glVertexP4uiv(arg0, arg1); + _post_call_callback_gl("glVertexP4uiv", (void *) glVertexP4uiv, 2, arg0, arg1); + } + PFNGLVERTEXP4UIVPROC glad_debug_glVertexP4uiv = glad_debug_impl_glVertexP4uiv; PFNGLVIEWPORTPROC glad_glViewport; -void APIENTRY glad_debug_impl_glViewport(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { - _pre_call_callback_gl("glViewport", (void*)glViewport, 4, arg0, arg1, arg2, arg3); - glad_glViewport(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glViewport", (void*)glViewport, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glViewport(GLint arg0, GLint arg1, GLsizei arg2, GLsizei arg3) { + _pre_call_callback_gl("glViewport", (void *) glViewport, 4, arg0, arg1, arg2, arg3); + glad_glViewport(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glViewport", (void *) glViewport, 4, arg0, arg1, arg2, arg3); + } + PFNGLVIEWPORTPROC glad_debug_glViewport = glad_debug_impl_glViewport; PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv; -void APIENTRY glad_debug_impl_glViewportArrayv(GLuint arg0, GLsizei arg1, const GLfloat * arg2) { - _pre_call_callback_gl("glViewportArrayv", (void*)glViewportArrayv, 3, arg0, arg1, arg2); - glad_glViewportArrayv(arg0, arg1, arg2); - _post_call_callback_gl("glViewportArrayv", (void*)glViewportArrayv, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glViewportArrayv(GLuint arg0, GLsizei arg1, const GLfloat *arg2) { + _pre_call_callback_gl("glViewportArrayv", (void *) glViewportArrayv, 3, arg0, arg1, arg2); + glad_glViewportArrayv(arg0, arg1, arg2); + _post_call_callback_gl("glViewportArrayv", (void *) glViewportArrayv, 3, arg0, arg1, arg2); + } + PFNGLVIEWPORTARRAYVPROC glad_debug_glViewportArrayv = glad_debug_impl_glViewportArrayv; PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf; -void APIENTRY glad_debug_impl_glViewportIndexedf(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { - _pre_call_callback_gl("glViewportIndexedf", (void*)glViewportIndexedf, 5, arg0, arg1, arg2, arg3, arg4); - glad_glViewportIndexedf(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glViewportIndexedf", (void*)glViewportIndexedf, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glViewportIndexedf(GLuint arg0, GLfloat arg1, GLfloat arg2, GLfloat arg3, GLfloat arg4) { + _pre_call_callback_gl("glViewportIndexedf", (void *) glViewportIndexedf, 5, arg0, arg1, arg2, arg3, arg4); + glad_glViewportIndexedf(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glViewportIndexedf", (void *) glViewportIndexedf, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLVIEWPORTINDEXEDFPROC glad_debug_glViewportIndexedf = glad_debug_impl_glViewportIndexedf; PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv; -void APIENTRY glad_debug_impl_glViewportIndexedfv(GLuint arg0, const GLfloat * arg1) { - _pre_call_callback_gl("glViewportIndexedfv", (void*)glViewportIndexedfv, 2, arg0, arg1); - glad_glViewportIndexedfv(arg0, arg1); - _post_call_callback_gl("glViewportIndexedfv", (void*)glViewportIndexedfv, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glViewportIndexedfv(GLuint arg0, const GLfloat *arg1) { + _pre_call_callback_gl("glViewportIndexedfv", (void *) glViewportIndexedfv, 2, arg0, arg1); + glad_glViewportIndexedfv(arg0, arg1); + _post_call_callback_gl("glViewportIndexedfv", (void *) glViewportIndexedfv, 2, arg0, arg1); + } + PFNGLVIEWPORTINDEXEDFVPROC glad_debug_glViewportIndexedfv = glad_debug_impl_glViewportIndexedfv; PFNGLWAITSYNCPROC glad_glWaitSync; -void APIENTRY glad_debug_impl_glWaitSync(GLsync arg0, GLbitfield arg1, GLuint64 arg2) { - _pre_call_callback_gl("glWaitSync", (void*)glWaitSync, 3, arg0, arg1, arg2); - glad_glWaitSync(arg0, arg1, arg2); - _post_call_callback_gl("glWaitSync", (void*)glWaitSync, 3, arg0, arg1, arg2); - + +void APIENTRY glad_debug_impl_glWaitSync(GLsync arg0, GLbitfield arg1, GLuint64 arg2) { + _pre_call_callback_gl("glWaitSync", (void *) glWaitSync, 3, arg0, arg1, arg2); + glad_glWaitSync(arg0, arg1, arg2); + _post_call_callback_gl("glWaitSync", (void *) glWaitSync, 3, arg0, arg1, arg2); + } + PFNGLWAITSYNCPROC glad_debug_glWaitSync = glad_debug_impl_glWaitSync; int GLAD_GL_ARB_get_program_binary = 0; int GLAD_GL_ARB_shading_language_include = 0; PFNGLNAMEDSTRINGARBPROC glad_glNamedStringARB; -void APIENTRY glad_debug_impl_glNamedStringARB(GLenum arg0, GLint arg1, const GLchar * arg2, GLint arg3, const GLchar * arg4) { - _pre_call_callback_gl("glNamedStringARB", (void*)glNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); - glad_glNamedStringARB(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glNamedStringARB", (void*)glNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glNamedStringARB(GLenum arg0, + GLint arg1, + const GLchar *arg2, + GLint arg3, + const GLchar *arg4) { + _pre_call_callback_gl("glNamedStringARB", (void *) glNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); + glad_glNamedStringARB(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glNamedStringARB", (void *) glNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLNAMEDSTRINGARBPROC glad_debug_glNamedStringARB = glad_debug_impl_glNamedStringARB; PFNGLDELETENAMEDSTRINGARBPROC glad_glDeleteNamedStringARB; -void APIENTRY glad_debug_impl_glDeleteNamedStringARB(GLint arg0, const GLchar * arg1) { - _pre_call_callback_gl("glDeleteNamedStringARB", (void*)glDeleteNamedStringARB, 2, arg0, arg1); - glad_glDeleteNamedStringARB(arg0, arg1); - _post_call_callback_gl("glDeleteNamedStringARB", (void*)glDeleteNamedStringARB, 2, arg0, arg1); - + +void APIENTRY glad_debug_impl_glDeleteNamedStringARB(GLint arg0, const GLchar *arg1) { + _pre_call_callback_gl("glDeleteNamedStringARB", (void *) glDeleteNamedStringARB, 2, arg0, arg1); + glad_glDeleteNamedStringARB(arg0, arg1); + _post_call_callback_gl("glDeleteNamedStringARB", (void *) glDeleteNamedStringARB, 2, arg0, arg1); + } + PFNGLDELETENAMEDSTRINGARBPROC glad_debug_glDeleteNamedStringARB = glad_debug_impl_glDeleteNamedStringARB; PFNGLCOMPILESHADERINCLUDEARBPROC glad_glCompileShaderIncludeARB; -void APIENTRY glad_debug_impl_glCompileShaderIncludeARB(GLuint arg0, GLsizei arg1, const GLchar *const* arg2, const GLint * arg3) { - _pre_call_callback_gl("glCompileShaderIncludeARB", (void*)glCompileShaderIncludeARB, 4, arg0, arg1, arg2, arg3); - glad_glCompileShaderIncludeARB(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glCompileShaderIncludeARB", (void*)glCompileShaderIncludeARB, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glCompileShaderIncludeARB(GLuint arg0, + GLsizei arg1, + const GLchar *const *arg2, + const GLint *arg3) { + _pre_call_callback_gl("glCompileShaderIncludeARB", (void *) glCompileShaderIncludeARB, 4, arg0, arg1, arg2, arg3); + glad_glCompileShaderIncludeARB(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glCompileShaderIncludeARB", (void *) glCompileShaderIncludeARB, 4, arg0, arg1, arg2, arg3); + } + PFNGLCOMPILESHADERINCLUDEARBPROC glad_debug_glCompileShaderIncludeARB = glad_debug_impl_glCompileShaderIncludeARB; PFNGLISNAMEDSTRINGARBPROC glad_glIsNamedStringARB; -GLboolean APIENTRY glad_debug_impl_glIsNamedStringARB(GLint arg0, const GLchar * arg1) { - GLboolean ret; - _pre_call_callback_gl("glIsNamedStringARB", (void*)glIsNamedStringARB, 2, arg0, arg1); - ret = glad_glIsNamedStringARB(arg0, arg1); - _post_call_callback_gl("glIsNamedStringARB", (void*)glIsNamedStringARB, 2, arg0, arg1); - return ret; + +GLboolean APIENTRY glad_debug_impl_glIsNamedStringARB(GLint arg0, const GLchar *arg1) { + GLboolean ret; + _pre_call_callback_gl("glIsNamedStringARB", (void *) glIsNamedStringARB, 2, arg0, arg1); + ret = glad_glIsNamedStringARB(arg0, arg1); + _post_call_callback_gl("glIsNamedStringARB", (void *) glIsNamedStringARB, 2, arg0, arg1); + return ret; } + PFNGLISNAMEDSTRINGARBPROC glad_debug_glIsNamedStringARB = glad_debug_impl_glIsNamedStringARB; PFNGLGETNAMEDSTRINGARBPROC glad_glGetNamedStringARB; -void APIENTRY glad_debug_impl_glGetNamedStringARB(GLint arg0, const GLchar * arg1, GLsizei arg2, GLint * arg3, GLchar * arg4) { - _pre_call_callback_gl("glGetNamedStringARB", (void*)glGetNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); - glad_glGetNamedStringARB(arg0, arg1, arg2, arg3, arg4); - _post_call_callback_gl("glGetNamedStringARB", (void*)glGetNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); - + +void APIENTRY glad_debug_impl_glGetNamedStringARB(GLint arg0, + const GLchar *arg1, + GLsizei arg2, + GLint *arg3, + GLchar *arg4) { + _pre_call_callback_gl("glGetNamedStringARB", (void *) glGetNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); + glad_glGetNamedStringARB(arg0, arg1, arg2, arg3, arg4); + _post_call_callback_gl("glGetNamedStringARB", (void *) glGetNamedStringARB, 5, arg0, arg1, arg2, arg3, arg4); + } + PFNGLGETNAMEDSTRINGARBPROC glad_debug_glGetNamedStringARB = glad_debug_impl_glGetNamedStringARB; PFNGLGETNAMEDSTRINGIVARBPROC glad_glGetNamedStringivARB; -void APIENTRY glad_debug_impl_glGetNamedStringivARB(GLint arg0, const GLchar * arg1, GLenum arg2, GLint * arg3) { - _pre_call_callback_gl("glGetNamedStringivARB", (void*)glGetNamedStringivARB, 4, arg0, arg1, arg2, arg3); - glad_glGetNamedStringivARB(arg0, arg1, arg2, arg3); - _post_call_callback_gl("glGetNamedStringivARB", (void*)glGetNamedStringivARB, 4, arg0, arg1, arg2, arg3); - + +void APIENTRY glad_debug_impl_glGetNamedStringivARB(GLint arg0, const GLchar *arg1, GLenum arg2, GLint *arg3) { + _pre_call_callback_gl("glGetNamedStringivARB", (void *) glGetNamedStringivARB, 4, arg0, arg1, arg2, arg3); + glad_glGetNamedStringivARB(arg0, arg1, arg2, arg3); + _post_call_callback_gl("glGetNamedStringivARB", (void *) glGetNamedStringivARB, 4, arg0, arg1, arg2, arg3); + } + PFNGLGETNAMEDSTRINGIVARBPROC glad_debug_glGetNamedStringivARB = glad_debug_impl_glGetNamedStringivARB; + static void load_GL_VERSION_1_0(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_0) return; - glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace"); - glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace"); - glad_glHint = (PFNGLHINTPROC)load("glHint"); - glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth"); - glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize"); - glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode"); - glad_glScissor = (PFNGLSCISSORPROC)load("glScissor"); - glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf"); - glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv"); - glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri"); - glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv"); - glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D"); - glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D"); - glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer"); - glad_glClear = (PFNGLCLEARPROC)load("glClear"); - glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor"); - glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil"); - glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth"); - glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask"); - glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask"); - glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask"); - glad_glDisable = (PFNGLDISABLEPROC)load("glDisable"); - glad_glEnable = (PFNGLENABLEPROC)load("glEnable"); - glad_glFinish = (PFNGLFINISHPROC)load("glFinish"); - glad_glFlush = (PFNGLFLUSHPROC)load("glFlush"); - glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc"); - glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp"); - glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc"); - glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp"); - glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc"); - glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref"); - glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei"); - glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer"); - glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels"); - glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv"); - glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev"); - glad_glGetError = (PFNGLGETERRORPROC)load("glGetError"); - glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv"); - glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv"); - glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); - glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage"); - glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv"); - glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv"); - glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv"); - glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv"); - glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled"); - glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange"); - glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport"); + if (!GLAD_GL_VERSION_1_0) + return; + glad_glCullFace = (PFNGLCULLFACEPROC) load("glCullFace"); + glad_glFrontFace = (PFNGLFRONTFACEPROC) load("glFrontFace"); + glad_glHint = (PFNGLHINTPROC) load("glHint"); + glad_glLineWidth = (PFNGLLINEWIDTHPROC) load("glLineWidth"); + glad_glPointSize = (PFNGLPOINTSIZEPROC) load("glPointSize"); + glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load("glPolygonMode"); + glad_glScissor = (PFNGLSCISSORPROC) load("glScissor"); + glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load("glTexParameterf"); + glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load("glTexParameterfv"); + glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load("glTexParameteri"); + glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load("glTexParameteriv"); + glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load("glTexImage1D"); + glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load("glTexImage2D"); + glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load("glDrawBuffer"); + glad_glClear = (PFNGLCLEARPROC) load("glClear"); + glad_glClearColor = (PFNGLCLEARCOLORPROC) load("glClearColor"); + glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load("glClearStencil"); + glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load("glClearDepth"); + glad_glStencilMask = (PFNGLSTENCILMASKPROC) load("glStencilMask"); + glad_glColorMask = (PFNGLCOLORMASKPROC) load("glColorMask"); + glad_glDepthMask = (PFNGLDEPTHMASKPROC) load("glDepthMask"); + glad_glDisable = (PFNGLDISABLEPROC) load("glDisable"); + glad_glEnable = (PFNGLENABLEPROC) load("glEnable"); + glad_glFinish = (PFNGLFINISHPROC) load("glFinish"); + glad_glFlush = (PFNGLFLUSHPROC) load("glFlush"); + glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load("glBlendFunc"); + glad_glLogicOp = (PFNGLLOGICOPPROC) load("glLogicOp"); + glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load("glStencilFunc"); + glad_glStencilOp = (PFNGLSTENCILOPPROC) load("glStencilOp"); + glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load("glDepthFunc"); + glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load("glPixelStoref"); + glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load("glPixelStorei"); + glad_glReadBuffer = (PFNGLREADBUFFERPROC) load("glReadBuffer"); + glad_glReadPixels = (PFNGLREADPIXELSPROC) load("glReadPixels"); + glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load("glGetBooleanv"); + glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load("glGetDoublev"); + glad_glGetError = (PFNGLGETERRORPROC) load("glGetError"); + glad_glGetFloatv = (PFNGLGETFLOATVPROC) load("glGetFloatv"); + glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load("glGetIntegerv"); + glad_glGetString = (PFNGLGETSTRINGPROC) load("glGetString"); + glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load("glGetTexImage"); + glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load("glGetTexParameterfv"); + glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load("glGetTexParameteriv"); + glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load("glGetTexLevelParameterfv"); + glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load("glGetTexLevelParameteriv"); + glad_glIsEnabled = (PFNGLISENABLEDPROC) load("glIsEnabled"); + glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load("glDepthRange"); + glad_glViewport = (PFNGLVIEWPORTPROC) load("glViewport"); } + static void load_GL_VERSION_1_1(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_1) return; - glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays"); - glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements"); - glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset"); - glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D"); - glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D"); - glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D"); - glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D"); - glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D"); - glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D"); - glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture"); - glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures"); - glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures"); - glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture"); + if (!GLAD_GL_VERSION_1_1) + return; + glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load("glDrawArrays"); + glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load("glDrawElements"); + glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load("glPolygonOffset"); + glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load("glCopyTexImage1D"); + glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load("glCopyTexImage2D"); + glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load("glCopyTexSubImage1D"); + glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load("glCopyTexSubImage2D"); + glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load("glTexSubImage1D"); + glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load("glTexSubImage2D"); + glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load("glBindTexture"); + glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load("glDeleteTextures"); + glad_glGenTextures = (PFNGLGENTEXTURESPROC) load("glGenTextures"); + glad_glIsTexture = (PFNGLISTEXTUREPROC) load("glIsTexture"); } + static void load_GL_VERSION_1_2(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_2) return; - glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements"); - glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D"); - glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D"); - glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D"); + if (!GLAD_GL_VERSION_1_2) + return; + glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load("glDrawRangeElements"); + glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load("glTexImage3D"); + glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load("glTexSubImage3D"); + glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load("glCopyTexSubImage3D"); } + static void load_GL_VERSION_1_3(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_3) return; - glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture"); - glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage"); - glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D"); - glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D"); - glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D"); - glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D"); - glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D"); - glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D"); - glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage"); + if (!GLAD_GL_VERSION_1_3) + return; + glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load("glActiveTexture"); + glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage"); + glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load("glCompressedTexImage3D"); + glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load("glCompressedTexImage2D"); + glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load("glCompressedTexImage1D"); + glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load("glCompressedTexSubImage3D"); + glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load("glCompressedTexSubImage2D"); + glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load("glCompressedTexSubImage1D"); + glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load("glGetCompressedTexImage"); } + static void load_GL_VERSION_1_4(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_4) return; - glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate"); - glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays"); - glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements"); - glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf"); - glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv"); - glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri"); - glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv"); - glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor"); - glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation"); + if (!GLAD_GL_VERSION_1_4) + return; + glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load("glBlendFuncSeparate"); + glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load("glMultiDrawArrays"); + glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load("glMultiDrawElements"); + glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load("glPointParameterf"); + glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load("glPointParameterfv"); + glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load("glPointParameteri"); + glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load("glPointParameteriv"); + glad_glBlendColor = (PFNGLBLENDCOLORPROC) load("glBlendColor"); + glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load("glBlendEquation"); } + static void load_GL_VERSION_1_5(GLADloadproc load) { - if(!GLAD_GL_VERSION_1_5) return; - glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries"); - glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries"); - glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery"); - glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery"); - glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery"); - glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv"); - glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv"); - glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv"); - glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer"); - glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers"); - glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers"); - glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer"); - glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData"); - glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData"); - glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData"); - glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer"); - glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer"); - glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv"); - glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv"); + if (!GLAD_GL_VERSION_1_5) + return; + glad_glGenQueries = (PFNGLGENQUERIESPROC) load("glGenQueries"); + glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load("glDeleteQueries"); + glad_glIsQuery = (PFNGLISQUERYPROC) load("glIsQuery"); + glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load("glBeginQuery"); + glad_glEndQuery = (PFNGLENDQUERYPROC) load("glEndQuery"); + glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load("glGetQueryiv"); + glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load("glGetQueryObjectiv"); + glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load("glGetQueryObjectuiv"); + glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load("glBindBuffer"); + glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load("glDeleteBuffers"); + glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load("glGenBuffers"); + glad_glIsBuffer = (PFNGLISBUFFERPROC) load("glIsBuffer"); + glad_glBufferData = (PFNGLBUFFERDATAPROC) load("glBufferData"); + glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load("glBufferSubData"); + glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load("glGetBufferSubData"); + glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load("glMapBuffer"); + glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load("glUnmapBuffer"); + glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load("glGetBufferParameteriv"); + glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load("glGetBufferPointerv"); } + static void load_GL_VERSION_2_0(GLADloadproc load) { - if(!GLAD_GL_VERSION_2_0) return; - glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate"); - glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers"); - glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate"); - glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate"); - glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate"); - glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader"); - glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation"); - glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader"); - glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram"); - glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader"); - glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram"); - glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader"); - glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader"); - glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray"); - glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray"); - glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib"); - glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform"); - glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders"); - glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation"); - glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv"); - glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog"); - glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv"); - glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog"); - glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource"); - glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation"); - glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv"); - glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv"); - glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv"); - glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv"); - glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv"); - glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv"); - glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram"); - glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader"); - glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram"); - glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource"); - glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram"); - glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f"); - glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f"); - glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f"); - glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f"); - glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i"); - glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i"); - glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i"); - glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i"); - glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv"); - glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv"); - glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv"); - glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv"); - glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv"); - glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv"); - glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv"); - glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv"); - glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv"); - glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv"); - glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv"); - glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram"); - glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d"); - glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv"); - glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f"); - glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv"); - glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s"); - glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv"); - glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d"); - glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv"); - glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f"); - glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv"); - glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s"); - glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv"); - glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d"); - glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv"); - glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f"); - glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv"); - glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s"); - glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv"); - glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv"); - glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv"); - glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv"); - glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub"); - glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv"); - glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv"); - glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv"); - glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv"); - glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d"); - glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv"); - glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f"); - glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv"); - glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv"); - glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s"); - glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv"); - glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv"); - glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv"); - glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv"); - glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer"); + if (!GLAD_GL_VERSION_2_0) + return; + glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load("glBlendEquationSeparate"); + glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load("glDrawBuffers"); + glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load("glStencilOpSeparate"); + glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load("glStencilFuncSeparate"); + glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load("glStencilMaskSeparate"); + glad_glAttachShader = (PFNGLATTACHSHADERPROC) load("glAttachShader"); + glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load("glBindAttribLocation"); + glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load("glCompileShader"); + glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load("glCreateProgram"); + glad_glCreateShader = (PFNGLCREATESHADERPROC) load("glCreateShader"); + glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load("glDeleteProgram"); + glad_glDeleteShader = (PFNGLDELETESHADERPROC) load("glDeleteShader"); + glad_glDetachShader = (PFNGLDETACHSHADERPROC) load("glDetachShader"); + glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load("glDisableVertexAttribArray"); + glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load("glEnableVertexAttribArray"); + glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load("glGetActiveAttrib"); + glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load("glGetActiveUniform"); + glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load("glGetAttachedShaders"); + glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load("glGetAttribLocation"); + glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load("glGetProgramiv"); + glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load("glGetProgramInfoLog"); + glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load("glGetShaderiv"); + glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load("glGetShaderInfoLog"); + glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load("glGetShaderSource"); + glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load("glGetUniformLocation"); + glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load("glGetUniformfv"); + glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load("glGetUniformiv"); + glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load("glGetVertexAttribdv"); + glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load("glGetVertexAttribfv"); + glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load("glGetVertexAttribiv"); + glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load("glGetVertexAttribPointerv"); + glad_glIsProgram = (PFNGLISPROGRAMPROC) load("glIsProgram"); + glad_glIsShader = (PFNGLISSHADERPROC) load("glIsShader"); + glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load("glLinkProgram"); + glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load("glShaderSource"); + glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load("glUseProgram"); + glad_glUniform1f = (PFNGLUNIFORM1FPROC) load("glUniform1f"); + glad_glUniform2f = (PFNGLUNIFORM2FPROC) load("glUniform2f"); + glad_glUniform3f = (PFNGLUNIFORM3FPROC) load("glUniform3f"); + glad_glUniform4f = (PFNGLUNIFORM4FPROC) load("glUniform4f"); + glad_glUniform1i = (PFNGLUNIFORM1IPROC) load("glUniform1i"); + glad_glUniform2i = (PFNGLUNIFORM2IPROC) load("glUniform2i"); + glad_glUniform3i = (PFNGLUNIFORM3IPROC) load("glUniform3i"); + glad_glUniform4i = (PFNGLUNIFORM4IPROC) load("glUniform4i"); + glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load("glUniform1fv"); + glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load("glUniform2fv"); + glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load("glUniform3fv"); + glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load("glUniform4fv"); + glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load("glUniform1iv"); + glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load("glUniform2iv"); + glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load("glUniform3iv"); + glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load("glUniform4iv"); + glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load("glUniformMatrix2fv"); + glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load("glUniformMatrix3fv"); + glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load("glUniformMatrix4fv"); + glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load("glValidateProgram"); + glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load("glVertexAttrib1d"); + glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load("glVertexAttrib1dv"); + glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load("glVertexAttrib1f"); + glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load("glVertexAttrib1fv"); + glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load("glVertexAttrib1s"); + glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load("glVertexAttrib1sv"); + glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load("glVertexAttrib2d"); + glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load("glVertexAttrib2dv"); + glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load("glVertexAttrib2f"); + glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load("glVertexAttrib2fv"); + glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load("glVertexAttrib2s"); + glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load("glVertexAttrib2sv"); + glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load("glVertexAttrib3d"); + glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load("glVertexAttrib3dv"); + glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load("glVertexAttrib3f"); + glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load("glVertexAttrib3fv"); + glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load("glVertexAttrib3s"); + glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load("glVertexAttrib3sv"); + glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load("glVertexAttrib4Nbv"); + glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load("glVertexAttrib4Niv"); + glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load("glVertexAttrib4Nsv"); + glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load("glVertexAttrib4Nub"); + glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load("glVertexAttrib4Nubv"); + glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load("glVertexAttrib4Nuiv"); + glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load("glVertexAttrib4Nusv"); + glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load("glVertexAttrib4bv"); + glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load("glVertexAttrib4d"); + glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load("glVertexAttrib4dv"); + glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load("glVertexAttrib4f"); + glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load("glVertexAttrib4fv"); + glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load("glVertexAttrib4iv"); + glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load("glVertexAttrib4s"); + glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load("glVertexAttrib4sv"); + glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load("glVertexAttrib4ubv"); + glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load("glVertexAttrib4uiv"); + glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load("glVertexAttrib4usv"); + glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load("glVertexAttribPointer"); } + static void load_GL_VERSION_2_1(GLADloadproc load) { - if(!GLAD_GL_VERSION_2_1) return; - glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv"); - glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv"); - glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv"); - glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv"); - glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv"); - glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv"); + if (!GLAD_GL_VERSION_2_1) + return; + glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load("glUniformMatrix2x3fv"); + glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load("glUniformMatrix3x2fv"); + glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load("glUniformMatrix2x4fv"); + glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load("glUniformMatrix4x2fv"); + glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load("glUniformMatrix3x4fv"); + glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load("glUniformMatrix4x3fv"); } + static void load_GL_VERSION_3_0(GLADloadproc load) { - if(!GLAD_GL_VERSION_3_0) return; - glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski"); - glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v"); - glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); - glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei"); - glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei"); - glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi"); - glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback"); - glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback"); - glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); - glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); - glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings"); - glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying"); - glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor"); - glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender"); - glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender"); - glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer"); - glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv"); - glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv"); - glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i"); - glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i"); - glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i"); - glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i"); - glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui"); - glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui"); - glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui"); - glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui"); - glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv"); - glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv"); - glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv"); - glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv"); - glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv"); - glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv"); - glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv"); - glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv"); - glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv"); - glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv"); - glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv"); - glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv"); - glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv"); - glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation"); - glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation"); - glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui"); - glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui"); - glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui"); - glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui"); - glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv"); - glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv"); - glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv"); - glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv"); - glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv"); - glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv"); - glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv"); - glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv"); - glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv"); - glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv"); - glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv"); - glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi"); - glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi"); - glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer"); - glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer"); - glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers"); - glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers"); - glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage"); - glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv"); - glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer"); - glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer"); - glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers"); - glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers"); - glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus"); - glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D"); - glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D"); - glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D"); - glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer"); - glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv"); - glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap"); - glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer"); - glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample"); - glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer"); - glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange"); - glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange"); - glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray"); - glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays"); - glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays"); - glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray"); + if (!GLAD_GL_VERSION_3_0) + return; + glad_glColorMaski = (PFNGLCOLORMASKIPROC) load("glColorMaski"); + glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load("glGetBooleani_v"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v"); + glad_glEnablei = (PFNGLENABLEIPROC) load("glEnablei"); + glad_glDisablei = (PFNGLDISABLEIPROC) load("glDisablei"); + glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load("glIsEnabledi"); + glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load("glBeginTransformFeedback"); + glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load("glEndTransformFeedback"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase"); + glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load("glTransformFeedbackVaryings"); + glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load("glGetTransformFeedbackVarying"); + glad_glClampColor = (PFNGLCLAMPCOLORPROC) load("glClampColor"); + glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load("glBeginConditionalRender"); + glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load("glEndConditionalRender"); + glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load("glVertexAttribIPointer"); + glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load("glGetVertexAttribIiv"); + glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load("glGetVertexAttribIuiv"); + glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load("glVertexAttribI1i"); + glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load("glVertexAttribI2i"); + glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load("glVertexAttribI3i"); + glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load("glVertexAttribI4i"); + glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load("glVertexAttribI1ui"); + glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load("glVertexAttribI2ui"); + glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load("glVertexAttribI3ui"); + glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load("glVertexAttribI4ui"); + glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load("glVertexAttribI1iv"); + glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load("glVertexAttribI2iv"); + glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load("glVertexAttribI3iv"); + glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load("glVertexAttribI4iv"); + glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load("glVertexAttribI1uiv"); + glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load("glVertexAttribI2uiv"); + glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load("glVertexAttribI3uiv"); + glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load("glVertexAttribI4uiv"); + glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load("glVertexAttribI4bv"); + glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load("glVertexAttribI4sv"); + glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load("glVertexAttribI4ubv"); + glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load("glVertexAttribI4usv"); + glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load("glGetUniformuiv"); + glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load("glBindFragDataLocation"); + glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load("glGetFragDataLocation"); + glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load("glUniform1ui"); + glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load("glUniform2ui"); + glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load("glUniform3ui"); + glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load("glUniform4ui"); + glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load("glUniform1uiv"); + glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load("glUniform2uiv"); + glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load("glUniform3uiv"); + glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load("glUniform4uiv"); + glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load("glTexParameterIiv"); + glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load("glTexParameterIuiv"); + glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load("glGetTexParameterIiv"); + glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load("glGetTexParameterIuiv"); + glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load("glClearBufferiv"); + glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load("glClearBufferuiv"); + glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load("glClearBufferfv"); + glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load("glClearBufferfi"); + glad_glGetStringi = (PFNGLGETSTRINGIPROC) load("glGetStringi"); + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load("glIsRenderbuffer"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load("glBindRenderbuffer"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load("glDeleteRenderbuffers"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load("glGenRenderbuffers"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load("glRenderbufferStorage"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load("glGetRenderbufferParameteriv"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load("glIsFramebuffer"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load("glBindFramebuffer"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load("glDeleteFramebuffers"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load("glGenFramebuffers"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load("glCheckFramebufferStatus"); + glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load("glFramebufferTexture1D"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load("glFramebufferTexture2D"); + glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load("glFramebufferTexture3D"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load("glFramebufferRenderbuffer"); + glad_glGetFramebufferAttachmentParameteriv = + (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load("glGetFramebufferAttachmentParameteriv"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load("glGenerateMipmap"); + glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load("glBlitFramebuffer"); + glad_glRenderbufferStorageMultisample = + (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load("glRenderbufferStorageMultisample"); + glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load("glFramebufferTextureLayer"); + glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load("glMapBufferRange"); + glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load("glFlushMappedBufferRange"); + glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load("glBindVertexArray"); + glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load("glDeleteVertexArrays"); + glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load("glGenVertexArrays"); + glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load("glIsVertexArray"); } + static void load_GL_VERSION_3_1(GLADloadproc load) { - if(!GLAD_GL_VERSION_3_1) return; - glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced"); - glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced"); - glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer"); - glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex"); - glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData"); - glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices"); - glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv"); - glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName"); - glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex"); - glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv"); - glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName"); - glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding"); - glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange"); - glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase"); - glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v"); + if (!GLAD_GL_VERSION_3_1) + return; + glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load("glDrawArraysInstanced"); + glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load("glDrawElementsInstanced"); + glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load("glTexBuffer"); + glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load("glPrimitiveRestartIndex"); + glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load("glCopyBufferSubData"); + glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load("glGetUniformIndices"); + glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load("glGetActiveUniformsiv"); + glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load("glGetActiveUniformName"); + glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load("glGetUniformBlockIndex"); + glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load("glGetActiveUniformBlockiv"); + glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load("glGetActiveUniformBlockName"); + glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load("glUniformBlockBinding"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v"); } + static void load_GL_VERSION_3_2(GLADloadproc load) { - if(!GLAD_GL_VERSION_3_2) return; - glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex"); - glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex"); - glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex"); - glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex"); - glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex"); - glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync"); - glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync"); - glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync"); - glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync"); - glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync"); - glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v"); - glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv"); - glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v"); - glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v"); - glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture"); - glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample"); - glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample"); - glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv"); - glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski"); + if (!GLAD_GL_VERSION_3_2) + return; + glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load("glDrawElementsBaseVertex"); + glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load("glDrawRangeElementsBaseVertex"); + glad_glDrawElementsInstancedBaseVertex = + (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load("glDrawElementsInstancedBaseVertex"); + glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load("glMultiDrawElementsBaseVertex"); + glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load("glProvokingVertex"); + glad_glFenceSync = (PFNGLFENCESYNCPROC) load("glFenceSync"); + glad_glIsSync = (PFNGLISSYNCPROC) load("glIsSync"); + glad_glDeleteSync = (PFNGLDELETESYNCPROC) load("glDeleteSync"); + glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load("glClientWaitSync"); + glad_glWaitSync = (PFNGLWAITSYNCPROC) load("glWaitSync"); + glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load("glGetInteger64v"); + glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load("glGetSynciv"); + glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load("glGetInteger64i_v"); + glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load("glGetBufferParameteri64v"); + glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load("glFramebufferTexture"); + glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load("glTexImage2DMultisample"); + glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load("glTexImage3DMultisample"); + glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load("glGetMultisamplefv"); + glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load("glSampleMaski"); } + static void load_GL_VERSION_3_3(GLADloadproc load) { - if(!GLAD_GL_VERSION_3_3) return; - glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed"); - glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex"); - glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers"); - glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers"); - glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler"); - glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler"); - glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri"); - glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv"); - glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf"); - glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv"); - glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv"); - glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv"); - glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv"); - glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv"); - glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv"); - glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv"); - glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter"); - glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v"); - glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v"); - glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor"); - glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui"); - glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv"); - glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui"); - glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv"); - glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui"); - glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv"); - glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui"); - glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv"); - glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui"); - glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv"); - glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui"); - glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv"); - glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui"); - glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv"); - glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui"); - glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv"); - glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui"); - glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv"); - glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui"); - glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv"); - glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui"); - glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv"); - glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui"); - glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv"); - glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui"); - glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv"); - glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui"); - glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv"); - glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui"); - glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv"); - glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui"); - glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv"); - glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui"); - glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv"); - glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui"); - glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv"); - glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui"); - glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv"); + if (!GLAD_GL_VERSION_3_3) + return; + glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load("glBindFragDataLocationIndexed"); + glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load("glGetFragDataIndex"); + glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load("glGenSamplers"); + glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load("glDeleteSamplers"); + glad_glIsSampler = (PFNGLISSAMPLERPROC) load("glIsSampler"); + glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load("glBindSampler"); + glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load("glSamplerParameteri"); + glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load("glSamplerParameteriv"); + glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load("glSamplerParameterf"); + glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load("glSamplerParameterfv"); + glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load("glSamplerParameterIiv"); + glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load("glSamplerParameterIuiv"); + glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load("glGetSamplerParameteriv"); + glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load("glGetSamplerParameterIiv"); + glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load("glGetSamplerParameterfv"); + glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load("glGetSamplerParameterIuiv"); + glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load("glQueryCounter"); + glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load("glGetQueryObjecti64v"); + glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load("glGetQueryObjectui64v"); + glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load("glVertexAttribDivisor"); + glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load("glVertexAttribP1ui"); + glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load("glVertexAttribP1uiv"); + glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load("glVertexAttribP2ui"); + glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load("glVertexAttribP2uiv"); + glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load("glVertexAttribP3ui"); + glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load("glVertexAttribP3uiv"); + glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load("glVertexAttribP4ui"); + glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load("glVertexAttribP4uiv"); + glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC) load("glVertexP2ui"); + glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load("glVertexP2uiv"); + glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC) load("glVertexP3ui"); + glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load("glVertexP3uiv"); + glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC) load("glVertexP4ui"); + glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load("glVertexP4uiv"); + glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load("glTexCoordP1ui"); + glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load("glTexCoordP1uiv"); + glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load("glTexCoordP2ui"); + glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load("glTexCoordP2uiv"); + glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load("glTexCoordP3ui"); + glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load("glTexCoordP3uiv"); + glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load("glTexCoordP4ui"); + glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load("glTexCoordP4uiv"); + glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load("glMultiTexCoordP1ui"); + glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load("glMultiTexCoordP1uiv"); + glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load("glMultiTexCoordP2ui"); + glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load("glMultiTexCoordP2uiv"); + glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load("glMultiTexCoordP3ui"); + glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load("glMultiTexCoordP3uiv"); + glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load("glMultiTexCoordP4ui"); + glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load("glMultiTexCoordP4uiv"); + glad_glNormalP3ui = (PFNGLNORMALP3UIPROC) load("glNormalP3ui"); + glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load("glNormalP3uiv"); + glad_glColorP3ui = (PFNGLCOLORP3UIPROC) load("glColorP3ui"); + glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC) load("glColorP3uiv"); + glad_glColorP4ui = (PFNGLCOLORP4UIPROC) load("glColorP4ui"); + glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC) load("glColorP4uiv"); + glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load("glSecondaryColorP3ui"); + glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load("glSecondaryColorP3uiv"); } + static void load_GL_VERSION_4_0(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_0) return; - glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)load("glMinSampleShading"); - glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)load("glBlendEquationi"); - glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)load("glBlendEquationSeparatei"); - glad_glBlendFunci = (PFNGLBLENDFUNCIPROC)load("glBlendFunci"); - glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)load("glBlendFuncSeparatei"); - glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)load("glDrawArraysIndirect"); - glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)load("glDrawElementsIndirect"); - glad_glUniform1d = (PFNGLUNIFORM1DPROC)load("glUniform1d"); - glad_glUniform2d = (PFNGLUNIFORM2DPROC)load("glUniform2d"); - glad_glUniform3d = (PFNGLUNIFORM3DPROC)load("glUniform3d"); - glad_glUniform4d = (PFNGLUNIFORM4DPROC)load("glUniform4d"); - glad_glUniform1dv = (PFNGLUNIFORM1DVPROC)load("glUniform1dv"); - glad_glUniform2dv = (PFNGLUNIFORM2DVPROC)load("glUniform2dv"); - glad_glUniform3dv = (PFNGLUNIFORM3DVPROC)load("glUniform3dv"); - glad_glUniform4dv = (PFNGLUNIFORM4DVPROC)load("glUniform4dv"); - glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)load("glUniformMatrix2dv"); - glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)load("glUniformMatrix3dv"); - glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)load("glUniformMatrix4dv"); - glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)load("glUniformMatrix2x3dv"); - glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)load("glUniformMatrix2x4dv"); - glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)load("glUniformMatrix3x2dv"); - glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)load("glUniformMatrix3x4dv"); - glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)load("glUniformMatrix4x2dv"); - glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)load("glUniformMatrix4x3dv"); - glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC)load("glGetUniformdv"); - glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)load("glGetSubroutineUniformLocation"); - glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)load("glGetSubroutineIndex"); - glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)load("glGetActiveSubroutineUniformiv"); - glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)load("glGetActiveSubroutineUniformName"); - glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)load("glGetActiveSubroutineName"); - glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)load("glUniformSubroutinesuiv"); - glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)load("glGetUniformSubroutineuiv"); - glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)load("glGetProgramStageiv"); - glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)load("glPatchParameteri"); - glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)load("glPatchParameterfv"); - glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)load("glBindTransformFeedback"); - glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)load("glDeleteTransformFeedbacks"); - glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)load("glGenTransformFeedbacks"); - glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)load("glIsTransformFeedback"); - glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)load("glPauseTransformFeedback"); - glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)load("glResumeTransformFeedback"); - glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)load("glDrawTransformFeedback"); - glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)load("glDrawTransformFeedbackStream"); - glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)load("glBeginQueryIndexed"); - glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)load("glEndQueryIndexed"); - glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)load("glGetQueryIndexediv"); + if (!GLAD_GL_VERSION_4_0) + return; + glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC) load("glMinSampleShading"); + glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC) load("glBlendEquationi"); + glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC) load("glBlendEquationSeparatei"); + glad_glBlendFunci = (PFNGLBLENDFUNCIPROC) load("glBlendFunci"); + glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC) load("glBlendFuncSeparatei"); + glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC) load("glDrawArraysIndirect"); + glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) load("glDrawElementsIndirect"); + glad_glUniform1d = (PFNGLUNIFORM1DPROC) load("glUniform1d"); + glad_glUniform2d = (PFNGLUNIFORM2DPROC) load("glUniform2d"); + glad_glUniform3d = (PFNGLUNIFORM3DPROC) load("glUniform3d"); + glad_glUniform4d = (PFNGLUNIFORM4DPROC) load("glUniform4d"); + glad_glUniform1dv = (PFNGLUNIFORM1DVPROC) load("glUniform1dv"); + glad_glUniform2dv = (PFNGLUNIFORM2DVPROC) load("glUniform2dv"); + glad_glUniform3dv = (PFNGLUNIFORM3DVPROC) load("glUniform3dv"); + glad_glUniform4dv = (PFNGLUNIFORM4DVPROC) load("glUniform4dv"); + glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC) load("glUniformMatrix2dv"); + glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC) load("glUniformMatrix3dv"); + glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC) load("glUniformMatrix4dv"); + glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC) load("glUniformMatrix2x3dv"); + glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC) load("glUniformMatrix2x4dv"); + glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC) load("glUniformMatrix3x2dv"); + glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC) load("glUniformMatrix3x4dv"); + glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC) load("glUniformMatrix4x2dv"); + glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC) load("glUniformMatrix4x3dv"); + glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC) load("glGetUniformdv"); + glad_glGetSubroutineUniformLocation = + (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) load("glGetSubroutineUniformLocation"); + glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC) load("glGetSubroutineIndex"); + glad_glGetActiveSubroutineUniformiv = + (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) load("glGetActiveSubroutineUniformiv"); + glad_glGetActiveSubroutineUniformName = + (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) load("glGetActiveSubroutineUniformName"); + glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC) load("glGetActiveSubroutineName"); + glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC) load("glUniformSubroutinesuiv"); + glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC) load("glGetUniformSubroutineuiv"); + glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC) load("glGetProgramStageiv"); + glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC) load("glPatchParameteri"); + glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC) load("glPatchParameterfv"); + glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC) load("glBindTransformFeedback"); + glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC) load("glDeleteTransformFeedbacks"); + glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC) load("glGenTransformFeedbacks"); + glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC) load("glIsTransformFeedback"); + glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC) load("glPauseTransformFeedback"); + glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC) load("glResumeTransformFeedback"); + glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC) load("glDrawTransformFeedback"); + glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) load("glDrawTransformFeedbackStream"); + glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC) load("glBeginQueryIndexed"); + glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC) load("glEndQueryIndexed"); + glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC) load("glGetQueryIndexediv"); } + static void load_GL_VERSION_4_1(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_1) return; - glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load("glReleaseShaderCompiler"); - glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load("glShaderBinary"); - glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load("glGetShaderPrecisionFormat"); - glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load("glDepthRangef"); - glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf"); - glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)load("glGetProgramBinary"); - glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC)load("glProgramBinary"); - glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri"); - glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)load("glUseProgramStages"); - glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)load("glActiveShaderProgram"); - glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)load("glCreateShaderProgramv"); - glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)load("glBindProgramPipeline"); - glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)load("glDeleteProgramPipelines"); - glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)load("glGenProgramPipelines"); - glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)load("glIsProgramPipeline"); - glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)load("glGetProgramPipelineiv"); - glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri"); - glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)load("glProgramUniform1i"); - glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)load("glProgramUniform1iv"); - glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)load("glProgramUniform1f"); - glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)load("glProgramUniform1fv"); - glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)load("glProgramUniform1d"); - glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)load("glProgramUniform1dv"); - glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)load("glProgramUniform1ui"); - glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)load("glProgramUniform1uiv"); - glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)load("glProgramUniform2i"); - glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)load("glProgramUniform2iv"); - glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)load("glProgramUniform2f"); - glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)load("glProgramUniform2fv"); - glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)load("glProgramUniform2d"); - glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)load("glProgramUniform2dv"); - glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)load("glProgramUniform2ui"); - glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)load("glProgramUniform2uiv"); - glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)load("glProgramUniform3i"); - glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)load("glProgramUniform3iv"); - glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)load("glProgramUniform3f"); - glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)load("glProgramUniform3fv"); - glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)load("glProgramUniform3d"); - glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)load("glProgramUniform3dv"); - glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)load("glProgramUniform3ui"); - glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)load("glProgramUniform3uiv"); - glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)load("glProgramUniform4i"); - glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)load("glProgramUniform4iv"); - glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)load("glProgramUniform4f"); - glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)load("glProgramUniform4fv"); - glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)load("glProgramUniform4d"); - glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)load("glProgramUniform4dv"); - glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)load("glProgramUniform4ui"); - glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)load("glProgramUniform4uiv"); - glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)load("glProgramUniformMatrix2fv"); - glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)load("glProgramUniformMatrix3fv"); - glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)load("glProgramUniformMatrix4fv"); - glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)load("glProgramUniformMatrix2dv"); - glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)load("glProgramUniformMatrix3dv"); - glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)load("glProgramUniformMatrix4dv"); - glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)load("glProgramUniformMatrix2x3fv"); - glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)load("glProgramUniformMatrix3x2fv"); - glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)load("glProgramUniformMatrix2x4fv"); - glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)load("glProgramUniformMatrix4x2fv"); - glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)load("glProgramUniformMatrix3x4fv"); - glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)load("glProgramUniformMatrix4x3fv"); - glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)load("glProgramUniformMatrix2x3dv"); - glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)load("glProgramUniformMatrix3x2dv"); - glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)load("glProgramUniformMatrix2x4dv"); - glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)load("glProgramUniformMatrix4x2dv"); - glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)load("glProgramUniformMatrix3x4dv"); - glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)load("glProgramUniformMatrix4x3dv"); - glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)load("glValidateProgramPipeline"); - glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)load("glGetProgramPipelineInfoLog"); - glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)load("glVertexAttribL1d"); - glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)load("glVertexAttribL2d"); - glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)load("glVertexAttribL3d"); - glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)load("glVertexAttribL4d"); - glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)load("glVertexAttribL1dv"); - glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)load("glVertexAttribL2dv"); - glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)load("glVertexAttribL3dv"); - glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)load("glVertexAttribL4dv"); - glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)load("glVertexAttribLPointer"); - glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)load("glGetVertexAttribLdv"); - glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)load("glViewportArrayv"); - glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)load("glViewportIndexedf"); - glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)load("glViewportIndexedfv"); - glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC)load("glScissorArrayv"); - glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)load("glScissorIndexed"); - glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)load("glScissorIndexedv"); - glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)load("glDepthRangeArrayv"); - glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)load("glDepthRangeIndexed"); - glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC)load("glGetFloati_v"); - glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)load("glGetDoublei_v"); + if (!GLAD_GL_VERSION_4_1) + return; + glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load("glReleaseShaderCompiler"); + glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load("glShaderBinary"); + glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load("glGetShaderPrecisionFormat"); + glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load("glDepthRangef"); + glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load("glClearDepthf"); + glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) load("glGetProgramBinary"); + glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC) load("glProgramBinary"); + glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load("glProgramParameteri"); + glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC) load("glUseProgramStages"); + glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC) load("glActiveShaderProgram"); + glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC) load("glCreateShaderProgramv"); + glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC) load("glBindProgramPipeline"); + glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC) load("glDeleteProgramPipelines"); + glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC) load("glGenProgramPipelines"); + glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC) load("glIsProgramPipeline"); + glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC) load("glGetProgramPipelineiv"); + glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load("glProgramParameteri"); + glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC) load("glProgramUniform1i"); + glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC) load("glProgramUniform1iv"); + glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC) load("glProgramUniform1f"); + glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC) load("glProgramUniform1fv"); + glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC) load("glProgramUniform1d"); + glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC) load("glProgramUniform1dv"); + glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC) load("glProgramUniform1ui"); + glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC) load("glProgramUniform1uiv"); + glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC) load("glProgramUniform2i"); + glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC) load("glProgramUniform2iv"); + glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC) load("glProgramUniform2f"); + glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC) load("glProgramUniform2fv"); + glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC) load("glProgramUniform2d"); + glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC) load("glProgramUniform2dv"); + glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC) load("glProgramUniform2ui"); + glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC) load("glProgramUniform2uiv"); + glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC) load("glProgramUniform3i"); + glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC) load("glProgramUniform3iv"); + glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC) load("glProgramUniform3f"); + glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC) load("glProgramUniform3fv"); + glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC) load("glProgramUniform3d"); + glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC) load("glProgramUniform3dv"); + glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC) load("glProgramUniform3ui"); + glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC) load("glProgramUniform3uiv"); + glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC) load("glProgramUniform4i"); + glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC) load("glProgramUniform4iv"); + glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC) load("glProgramUniform4f"); + glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC) load("glProgramUniform4fv"); + glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC) load("glProgramUniform4d"); + glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC) load("glProgramUniform4dv"); + glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC) load("glProgramUniform4ui"); + glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC) load("glProgramUniform4uiv"); + glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC) load("glProgramUniformMatrix2fv"); + glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC) load("glProgramUniformMatrix3fv"); + glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC) load("glProgramUniformMatrix4fv"); + glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC) load("glProgramUniformMatrix2dv"); + glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC) load("glProgramUniformMatrix3dv"); + glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC) load("glProgramUniformMatrix4dv"); + glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) load("glProgramUniformMatrix2x3fv"); + glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) load("glProgramUniformMatrix3x2fv"); + glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) load("glProgramUniformMatrix2x4fv"); + glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) load("glProgramUniformMatrix4x2fv"); + glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) load("glProgramUniformMatrix3x4fv"); + glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) load("glProgramUniformMatrix4x3fv"); + glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) load("glProgramUniformMatrix2x3dv"); + glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) load("glProgramUniformMatrix3x2dv"); + glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) load("glProgramUniformMatrix2x4dv"); + glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) load("glProgramUniformMatrix4x2dv"); + glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) load("glProgramUniformMatrix3x4dv"); + glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) load("glProgramUniformMatrix4x3dv"); + glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC) load("glValidateProgramPipeline"); + glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC) load("glGetProgramPipelineInfoLog"); + glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC) load("glVertexAttribL1d"); + glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC) load("glVertexAttribL2d"); + glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC) load("glVertexAttribL3d"); + glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC) load("glVertexAttribL4d"); + glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC) load("glVertexAttribL1dv"); + glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC) load("glVertexAttribL2dv"); + glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC) load("glVertexAttribL3dv"); + glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC) load("glVertexAttribL4dv"); + glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC) load("glVertexAttribLPointer"); + glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC) load("glGetVertexAttribLdv"); + glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC) load("glViewportArrayv"); + glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC) load("glViewportIndexedf"); + glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC) load("glViewportIndexedfv"); + glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC) load("glScissorArrayv"); + glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC) load("glScissorIndexed"); + glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC) load("glScissorIndexedv"); + glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC) load("glDepthRangeArrayv"); + glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC) load("glDepthRangeIndexed"); + glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC) load("glGetFloati_v"); + glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC) load("glGetDoublei_v"); } + static void load_GL_VERSION_4_2(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_2) return; - glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)load("glDrawArraysInstancedBaseInstance"); - glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)load("glDrawElementsInstancedBaseInstance"); - glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)load("glDrawElementsInstancedBaseVertexBaseInstance"); - glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)load("glGetInternalformativ"); - glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)load("glGetActiveAtomicCounterBufferiv"); - glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)load("glBindImageTexture"); - glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)load("glMemoryBarrier"); - glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)load("glTexStorage1D"); - glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)load("glTexStorage2D"); - glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)load("glTexStorage3D"); - glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)load("glDrawTransformFeedbackInstanced"); - glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)load("glDrawTransformFeedbackStreamInstanced"); + if (!GLAD_GL_VERSION_4_2) + return; + glad_glDrawArraysInstancedBaseInstance = + (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) load("glDrawArraysInstancedBaseInstance"); + glad_glDrawElementsInstancedBaseInstance = + (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) load("glDrawElementsInstancedBaseInstance"); + glad_glDrawElementsInstancedBaseVertexBaseInstance = + (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) load("glDrawElementsInstancedBaseVertexBaseInstance"); + glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) load("glGetInternalformativ"); + glad_glGetActiveAtomicCounterBufferiv = + (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) load("glGetActiveAtomicCounterBufferiv"); + glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC) load("glBindImageTexture"); + glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC) load("glMemoryBarrier"); + glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC) load("glTexStorage1D"); + glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC) load("glTexStorage2D"); + glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC) load("glTexStorage3D"); + glad_glDrawTransformFeedbackInstanced = + (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) load("glDrawTransformFeedbackInstanced"); + glad_glDrawTransformFeedbackStreamInstanced = + (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) load("glDrawTransformFeedbackStreamInstanced"); } + static void load_GL_VERSION_4_3(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_3) return; - glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)load("glClearBufferData"); - glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)load("glClearBufferSubData"); - glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)load("glDispatchCompute"); - glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)load("glDispatchComputeIndirect"); - glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)load("glCopyImageSubData"); - glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)load("glFramebufferParameteri"); - glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)load("glGetFramebufferParameteriv"); - glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)load("glGetInternalformati64v"); - glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)load("glInvalidateTexSubImage"); - glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)load("glInvalidateTexImage"); - glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)load("glInvalidateBufferSubData"); - glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)load("glInvalidateBufferData"); - glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)load("glInvalidateFramebuffer"); - glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)load("glInvalidateSubFramebuffer"); - glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)load("glMultiDrawArraysIndirect"); - glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)load("glMultiDrawElementsIndirect"); - glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)load("glGetProgramInterfaceiv"); - glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)load("glGetProgramResourceIndex"); - glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)load("glGetProgramResourceName"); - glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)load("glGetProgramResourceiv"); - glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)load("glGetProgramResourceLocation"); - glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)load("glGetProgramResourceLocationIndex"); - glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)load("glShaderStorageBlockBinding"); - glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)load("glTexBufferRange"); - glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)load("glTexStorage2DMultisample"); - glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)load("glTexStorage3DMultisample"); - glad_glTextureView = (PFNGLTEXTUREVIEWPROC)load("glTextureView"); - glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load("glBindVertexBuffer"); - glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load("glVertexAttribFormat"); - glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load("glVertexAttribIFormat"); - glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load("glVertexAttribLFormat"); - glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load("glVertexAttribBinding"); - glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load("glVertexBindingDivisor"); - glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)load("glDebugMessageControl"); - glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)load("glDebugMessageInsert"); - glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)load("glDebugMessageCallback"); - glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)load("glGetDebugMessageLog"); - glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)load("glPushDebugGroup"); - glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)load("glPopDebugGroup"); - glad_glObjectLabel = (PFNGLOBJECTLABELPROC)load("glObjectLabel"); - glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)load("glGetObjectLabel"); - glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)load("glObjectPtrLabel"); - glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)load("glGetObjectPtrLabel"); - glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load("glGetPointerv"); + if (!GLAD_GL_VERSION_4_3) + return; + glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) load("glClearBufferData"); + glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC) load("glClearBufferSubData"); + glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) load("glDispatchCompute"); + glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC) load("glDispatchComputeIndirect"); + glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC) load("glCopyImageSubData"); + glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC) load("glFramebufferParameteri"); + glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC) load("glGetFramebufferParameteriv"); + glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC) load("glGetInternalformati64v"); + glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC) load("glInvalidateTexSubImage"); + glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC) load("glInvalidateTexImage"); + glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC) load("glInvalidateBufferSubData"); + glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC) load("glInvalidateBufferData"); + glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC) load("glInvalidateFramebuffer"); + glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC) load("glInvalidateSubFramebuffer"); + glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC) load("glMultiDrawArraysIndirect"); + glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC) load("glMultiDrawElementsIndirect"); + glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC) load("glGetProgramInterfaceiv"); + glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC) load("glGetProgramResourceIndex"); + glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC) load("glGetProgramResourceName"); + glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC) load("glGetProgramResourceiv"); + glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC) load("glGetProgramResourceLocation"); + glad_glGetProgramResourceLocationIndex = + (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) load("glGetProgramResourceLocationIndex"); + glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC) load("glShaderStorageBlockBinding"); + glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC) load("glTexBufferRange"); + glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC) load("glTexStorage2DMultisample"); + glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC) load("glTexStorage3DMultisample"); + glad_glTextureView = (PFNGLTEXTUREVIEWPROC) load("glTextureView"); + glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC) load("glBindVertexBuffer"); + glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC) load("glVertexAttribFormat"); + glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC) load("glVertexAttribIFormat"); + glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC) load("glVertexAttribLFormat"); + glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC) load("glVertexAttribBinding"); + glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC) load("glVertexBindingDivisor"); + glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load("glDebugMessageControl"); + glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load("glDebugMessageInsert"); + glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load("glDebugMessageCallback"); + glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load("glGetDebugMessageLog"); + glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load("glPushDebugGroup"); + glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load("glPopDebugGroup"); + glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load("glObjectLabel"); + glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load("glGetObjectLabel"); + glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load("glObjectPtrLabel"); + glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load("glGetObjectPtrLabel"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv"); } + static void load_GL_VERSION_4_4(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_4) return; - glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC)load("glBufferStorage"); - glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC)load("glClearTexImage"); - glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC)load("glClearTexSubImage"); - glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)load("glBindBuffersBase"); - glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC)load("glBindBuffersRange"); - glad_glBindTextures = (PFNGLBINDTEXTURESPROC)load("glBindTextures"); - glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC)load("glBindSamplers"); - glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC)load("glBindImageTextures"); - glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC)load("glBindVertexBuffers"); + if (!GLAD_GL_VERSION_4_4) + return; + glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC) load("glBufferStorage"); + glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC) load("glClearTexImage"); + glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC) load("glClearTexSubImage"); + glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC) load("glBindBuffersBase"); + glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC) load("glBindBuffersRange"); + glad_glBindTextures = (PFNGLBINDTEXTURESPROC) load("glBindTextures"); + glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC) load("glBindSamplers"); + glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC) load("glBindImageTextures"); + glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC) load("glBindVertexBuffers"); } + static void load_GL_VERSION_4_5(GLADloadproc load) { - if(!GLAD_GL_VERSION_4_5) return; - glad_glClipControl = (PFNGLCLIPCONTROLPROC)load("glClipControl"); - glad_glCreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC)load("glCreateTransformFeedbacks"); - glad_glTransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)load("glTransformFeedbackBufferBase"); - glad_glTransformFeedbackBufferRange = (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)load("glTransformFeedbackBufferRange"); - glad_glGetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC)load("glGetTransformFeedbackiv"); - glad_glGetTransformFeedbacki_v = (PFNGLGETTRANSFORMFEEDBACKI_VPROC)load("glGetTransformFeedbacki_v"); - glad_glGetTransformFeedbacki64_v = (PFNGLGETTRANSFORMFEEDBACKI64_VPROC)load("glGetTransformFeedbacki64_v"); - glad_glCreateBuffers = (PFNGLCREATEBUFFERSPROC)load("glCreateBuffers"); - glad_glNamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC)load("glNamedBufferStorage"); - glad_glNamedBufferData = (PFNGLNAMEDBUFFERDATAPROC)load("glNamedBufferData"); - glad_glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC)load("glNamedBufferSubData"); - glad_glCopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC)load("glCopyNamedBufferSubData"); - glad_glClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC)load("glClearNamedBufferData"); - glad_glClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC)load("glClearNamedBufferSubData"); - glad_glMapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC)load("glMapNamedBuffer"); - glad_glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC)load("glMapNamedBufferRange"); - glad_glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC)load("glUnmapNamedBuffer"); - glad_glFlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)load("glFlushMappedNamedBufferRange"); - glad_glGetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC)load("glGetNamedBufferParameteriv"); - glad_glGetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)load("glGetNamedBufferParameteri64v"); - glad_glGetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC)load("glGetNamedBufferPointerv"); - glad_glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC)load("glGetNamedBufferSubData"); - glad_glCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC)load("glCreateFramebuffers"); - glad_glNamedFramebufferRenderbuffer = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)load("glNamedFramebufferRenderbuffer"); - glad_glNamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)load("glNamedFramebufferParameteri"); - glad_glNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)load("glNamedFramebufferTexture"); - glad_glNamedFramebufferTextureLayer = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)load("glNamedFramebufferTextureLayer"); - glad_glNamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)load("glNamedFramebufferDrawBuffer"); - glad_glNamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)load("glNamedFramebufferDrawBuffers"); - glad_glNamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)load("glNamedFramebufferReadBuffer"); - glad_glInvalidateNamedFramebufferData = (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)load("glInvalidateNamedFramebufferData"); - glad_glInvalidateNamedFramebufferSubData = (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)load("glInvalidateNamedFramebufferSubData"); - glad_glClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)load("glClearNamedFramebufferiv"); - glad_glClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)load("glClearNamedFramebufferuiv"); - glad_glClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)load("glClearNamedFramebufferfv"); - glad_glClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)load("glClearNamedFramebufferfi"); - glad_glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC)load("glBlitNamedFramebuffer"); - glad_glCheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)load("glCheckNamedFramebufferStatus"); - glad_glGetNamedFramebufferParameteriv = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)load("glGetNamedFramebufferParameteriv"); - glad_glGetNamedFramebufferAttachmentParameteriv = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetNamedFramebufferAttachmentParameteriv"); - glad_glCreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC)load("glCreateRenderbuffers"); - glad_glNamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC)load("glNamedRenderbufferStorage"); - glad_glNamedRenderbufferStorageMultisample = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glNamedRenderbufferStorageMultisample"); - glad_glGetNamedRenderbufferParameteriv = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)load("glGetNamedRenderbufferParameteriv"); - glad_glCreateTextures = (PFNGLCREATETEXTURESPROC)load("glCreateTextures"); - glad_glTextureBuffer = (PFNGLTEXTUREBUFFERPROC)load("glTextureBuffer"); - glad_glTextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC)load("glTextureBufferRange"); - glad_glTextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC)load("glTextureStorage1D"); - glad_glTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC)load("glTextureStorage2D"); - glad_glTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC)load("glTextureStorage3D"); - glad_glTextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)load("glTextureStorage2DMultisample"); - glad_glTextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)load("glTextureStorage3DMultisample"); - glad_glTextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC)load("glTextureSubImage1D"); - glad_glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)load("glTextureSubImage2D"); - glad_glTextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC)load("glTextureSubImage3D"); - glad_glCompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)load("glCompressedTextureSubImage1D"); - glad_glCompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)load("glCompressedTextureSubImage2D"); - glad_glCompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)load("glCompressedTextureSubImage3D"); - glad_glCopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC)load("glCopyTextureSubImage1D"); - glad_glCopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC)load("glCopyTextureSubImage2D"); - glad_glCopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC)load("glCopyTextureSubImage3D"); - glad_glTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC)load("glTextureParameterf"); - glad_glTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC)load("glTextureParameterfv"); - glad_glTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC)load("glTextureParameteri"); - glad_glTextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC)load("glTextureParameterIiv"); - glad_glTextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC)load("glTextureParameterIuiv"); - glad_glTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC)load("glTextureParameteriv"); - glad_glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)load("glGenerateTextureMipmap"); - glad_glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC)load("glBindTextureUnit"); - glad_glGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)load("glGetTextureImage"); - glad_glGetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)load("glGetCompressedTextureImage"); - glad_glGetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC)load("glGetTextureLevelParameterfv"); - glad_glGetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC)load("glGetTextureLevelParameteriv"); - glad_glGetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC)load("glGetTextureParameterfv"); - glad_glGetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC)load("glGetTextureParameterIiv"); - glad_glGetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC)load("glGetTextureParameterIuiv"); - glad_glGetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC)load("glGetTextureParameteriv"); - glad_glCreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC)load("glCreateVertexArrays"); - glad_glDisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC)load("glDisableVertexArrayAttrib"); - glad_glEnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC)load("glEnableVertexArrayAttrib"); - glad_glVertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC)load("glVertexArrayElementBuffer"); - glad_glVertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC)load("glVertexArrayVertexBuffer"); - glad_glVertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC)load("glVertexArrayVertexBuffers"); - glad_glVertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC)load("glVertexArrayAttribBinding"); - glad_glVertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC)load("glVertexArrayAttribFormat"); - glad_glVertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC)load("glVertexArrayAttribIFormat"); - glad_glVertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC)load("glVertexArrayAttribLFormat"); - glad_glVertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC)load("glVertexArrayBindingDivisor"); - glad_glGetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC)load("glGetVertexArrayiv"); - glad_glGetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC)load("glGetVertexArrayIndexediv"); - glad_glGetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC)load("glGetVertexArrayIndexed64iv"); - glad_glCreateSamplers = (PFNGLCREATESAMPLERSPROC)load("glCreateSamplers"); - glad_glCreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC)load("glCreateProgramPipelines"); - glad_glCreateQueries = (PFNGLCREATEQUERIESPROC)load("glCreateQueries"); - glad_glGetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC)load("glGetQueryBufferObjecti64v"); - glad_glGetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC)load("glGetQueryBufferObjectiv"); - glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC)load("glGetQueryBufferObjectui64v"); - glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC)load("glGetQueryBufferObjectuiv"); - glad_glMemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC)load("glMemoryBarrierByRegion"); - glad_glGetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC)load("glGetTextureSubImage"); - glad_glGetCompressedTextureSubImage = (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)load("glGetCompressedTextureSubImage"); - glad_glGetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC)load("glGetGraphicsResetStatus"); - glad_glGetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC)load("glGetnCompressedTexImage"); - glad_glGetnTexImage = (PFNGLGETNTEXIMAGEPROC)load("glGetnTexImage"); - glad_glGetnUniformdv = (PFNGLGETNUNIFORMDVPROC)load("glGetnUniformdv"); - glad_glGetnUniformfv = (PFNGLGETNUNIFORMFVPROC)load("glGetnUniformfv"); - glad_glGetnUniformiv = (PFNGLGETNUNIFORMIVPROC)load("glGetnUniformiv"); - glad_glGetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC)load("glGetnUniformuiv"); - glad_glReadnPixels = (PFNGLREADNPIXELSPROC)load("glReadnPixels"); - glad_glGetnMapdv = (PFNGLGETNMAPDVPROC)load("glGetnMapdv"); - glad_glGetnMapfv = (PFNGLGETNMAPFVPROC)load("glGetnMapfv"); - glad_glGetnMapiv = (PFNGLGETNMAPIVPROC)load("glGetnMapiv"); - glad_glGetnPixelMapfv = (PFNGLGETNPIXELMAPFVPROC)load("glGetnPixelMapfv"); - glad_glGetnPixelMapuiv = (PFNGLGETNPIXELMAPUIVPROC)load("glGetnPixelMapuiv"); - glad_glGetnPixelMapusv = (PFNGLGETNPIXELMAPUSVPROC)load("glGetnPixelMapusv"); - glad_glGetnPolygonStipple = (PFNGLGETNPOLYGONSTIPPLEPROC)load("glGetnPolygonStipple"); - glad_glGetnColorTable = (PFNGLGETNCOLORTABLEPROC)load("glGetnColorTable"); - glad_glGetnConvolutionFilter = (PFNGLGETNCONVOLUTIONFILTERPROC)load("glGetnConvolutionFilter"); - glad_glGetnSeparableFilter = (PFNGLGETNSEPARABLEFILTERPROC)load("glGetnSeparableFilter"); - glad_glGetnHistogram = (PFNGLGETNHISTOGRAMPROC)load("glGetnHistogram"); - glad_glGetnMinmax = (PFNGLGETNMINMAXPROC)load("glGetnMinmax"); - glad_glTextureBarrier = (PFNGLTEXTUREBARRIERPROC)load("glTextureBarrier"); + if (!GLAD_GL_VERSION_4_5) + return; + glad_glClipControl = (PFNGLCLIPCONTROLPROC) load("glClipControl"); + glad_glCreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC) load("glCreateTransformFeedbacks"); + glad_glTransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) load("glTransformFeedbackBufferBase"); + glad_glTransformFeedbackBufferRange = + (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) load("glTransformFeedbackBufferRange"); + glad_glGetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC) load("glGetTransformFeedbackiv"); + glad_glGetTransformFeedbacki_v = (PFNGLGETTRANSFORMFEEDBACKI_VPROC) load("glGetTransformFeedbacki_v"); + glad_glGetTransformFeedbacki64_v = (PFNGLGETTRANSFORMFEEDBACKI64_VPROC) load("glGetTransformFeedbacki64_v"); + glad_glCreateBuffers = (PFNGLCREATEBUFFERSPROC) load("glCreateBuffers"); + glad_glNamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC) load("glNamedBufferStorage"); + glad_glNamedBufferData = (PFNGLNAMEDBUFFERDATAPROC) load("glNamedBufferData"); + glad_glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC) load("glNamedBufferSubData"); + glad_glCopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC) load("glCopyNamedBufferSubData"); + glad_glClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC) load("glClearNamedBufferData"); + glad_glClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC) load("glClearNamedBufferSubData"); + glad_glMapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC) load("glMapNamedBuffer"); + glad_glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC) load("glMapNamedBufferRange"); + glad_glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC) load("glUnmapNamedBuffer"); + glad_glFlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) load("glFlushMappedNamedBufferRange"); + glad_glGetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC) load("glGetNamedBufferParameteriv"); + glad_glGetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) load("glGetNamedBufferParameteri64v"); + glad_glGetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC) load("glGetNamedBufferPointerv"); + glad_glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC) load("glGetNamedBufferSubData"); + glad_glCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC) load("glCreateFramebuffers"); + glad_glNamedFramebufferRenderbuffer = + (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) load("glNamedFramebufferRenderbuffer"); + glad_glNamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) load("glNamedFramebufferParameteri"); + glad_glNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) load("glNamedFramebufferTexture"); + glad_glNamedFramebufferTextureLayer = + (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) load("glNamedFramebufferTextureLayer"); + glad_glNamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) load("glNamedFramebufferDrawBuffer"); + glad_glNamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) load("glNamedFramebufferDrawBuffers"); + glad_glNamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) load("glNamedFramebufferReadBuffer"); + glad_glInvalidateNamedFramebufferData = + (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) load("glInvalidateNamedFramebufferData"); + glad_glInvalidateNamedFramebufferSubData = + (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) load("glInvalidateNamedFramebufferSubData"); + glad_glClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) load("glClearNamedFramebufferiv"); + glad_glClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) load("glClearNamedFramebufferuiv"); + glad_glClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) load("glClearNamedFramebufferfv"); + glad_glClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) load("glClearNamedFramebufferfi"); + glad_glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC) load("glBlitNamedFramebuffer"); + glad_glCheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) load("glCheckNamedFramebufferStatus"); + glad_glGetNamedFramebufferParameteriv = + (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) load("glGetNamedFramebufferParameteriv"); + glad_glGetNamedFramebufferAttachmentParameteriv = + (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load("glGetNamedFramebufferAttachmentParameteriv"); + glad_glCreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC) load("glCreateRenderbuffers"); + glad_glNamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC) load("glNamedRenderbufferStorage"); + glad_glNamedRenderbufferStorageMultisample = + (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) load("glNamedRenderbufferStorageMultisample"); + glad_glGetNamedRenderbufferParameteriv = + (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) load("glGetNamedRenderbufferParameteriv"); + glad_glCreateTextures = (PFNGLCREATETEXTURESPROC) load("glCreateTextures"); + glad_glTextureBuffer = (PFNGLTEXTUREBUFFERPROC) load("glTextureBuffer"); + glad_glTextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC) load("glTextureBufferRange"); + glad_glTextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC) load("glTextureStorage1D"); + glad_glTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC) load("glTextureStorage2D"); + glad_glTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC) load("glTextureStorage3D"); + glad_glTextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) load("glTextureStorage2DMultisample"); + glad_glTextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) load("glTextureStorage3DMultisample"); + glad_glTextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC) load("glTextureSubImage1D"); + glad_glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC) load("glTextureSubImage2D"); + glad_glTextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC) load("glTextureSubImage3D"); + glad_glCompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) load("glCompressedTextureSubImage1D"); + glad_glCompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) load("glCompressedTextureSubImage2D"); + glad_glCompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) load("glCompressedTextureSubImage3D"); + glad_glCopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC) load("glCopyTextureSubImage1D"); + glad_glCopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC) load("glCopyTextureSubImage2D"); + glad_glCopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC) load("glCopyTextureSubImage3D"); + glad_glTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC) load("glTextureParameterf"); + glad_glTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC) load("glTextureParameterfv"); + glad_glTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC) load("glTextureParameteri"); + glad_glTextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC) load("glTextureParameterIiv"); + glad_glTextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC) load("glTextureParameterIuiv"); + glad_glTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC) load("glTextureParameteriv"); + glad_glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) load("glGenerateTextureMipmap"); + glad_glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC) load("glBindTextureUnit"); + glad_glGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC) load("glGetTextureImage"); + glad_glGetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) load("glGetCompressedTextureImage"); + glad_glGetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC) load("glGetTextureLevelParameterfv"); + glad_glGetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC) load("glGetTextureLevelParameteriv"); + glad_glGetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC) load("glGetTextureParameterfv"); + glad_glGetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC) load("glGetTextureParameterIiv"); + glad_glGetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC) load("glGetTextureParameterIuiv"); + glad_glGetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC) load("glGetTextureParameteriv"); + glad_glCreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC) load("glCreateVertexArrays"); + glad_glDisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC) load("glDisableVertexArrayAttrib"); + glad_glEnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC) load("glEnableVertexArrayAttrib"); + glad_glVertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC) load("glVertexArrayElementBuffer"); + glad_glVertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC) load("glVertexArrayVertexBuffer"); + glad_glVertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC) load("glVertexArrayVertexBuffers"); + glad_glVertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC) load("glVertexArrayAttribBinding"); + glad_glVertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC) load("glVertexArrayAttribFormat"); + glad_glVertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC) load("glVertexArrayAttribIFormat"); + glad_glVertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC) load("glVertexArrayAttribLFormat"); + glad_glVertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC) load("glVertexArrayBindingDivisor"); + glad_glGetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC) load("glGetVertexArrayiv"); + glad_glGetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC) load("glGetVertexArrayIndexediv"); + glad_glGetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC) load("glGetVertexArrayIndexed64iv"); + glad_glCreateSamplers = (PFNGLCREATESAMPLERSPROC) load("glCreateSamplers"); + glad_glCreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC) load("glCreateProgramPipelines"); + glad_glCreateQueries = (PFNGLCREATEQUERIESPROC) load("glCreateQueries"); + glad_glGetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC) load("glGetQueryBufferObjecti64v"); + glad_glGetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC) load("glGetQueryBufferObjectiv"); + glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC) load("glGetQueryBufferObjectui64v"); + glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC) load("glGetQueryBufferObjectuiv"); + glad_glMemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC) load("glMemoryBarrierByRegion"); + glad_glGetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC) load("glGetTextureSubImage"); + glad_glGetCompressedTextureSubImage = + (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) load("glGetCompressedTextureSubImage"); + glad_glGetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC) load("glGetGraphicsResetStatus"); + glad_glGetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC) load("glGetnCompressedTexImage"); + glad_glGetnTexImage = (PFNGLGETNTEXIMAGEPROC) load("glGetnTexImage"); + glad_glGetnUniformdv = (PFNGLGETNUNIFORMDVPROC) load("glGetnUniformdv"); + glad_glGetnUniformfv = (PFNGLGETNUNIFORMFVPROC) load("glGetnUniformfv"); + glad_glGetnUniformiv = (PFNGLGETNUNIFORMIVPROC) load("glGetnUniformiv"); + glad_glGetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC) load("glGetnUniformuiv"); + glad_glReadnPixels = (PFNGLREADNPIXELSPROC) load("glReadnPixels"); + glad_glGetnMapdv = (PFNGLGETNMAPDVPROC) load("glGetnMapdv"); + glad_glGetnMapfv = (PFNGLGETNMAPFVPROC) load("glGetnMapfv"); + glad_glGetnMapiv = (PFNGLGETNMAPIVPROC) load("glGetnMapiv"); + glad_glGetnPixelMapfv = (PFNGLGETNPIXELMAPFVPROC) load("glGetnPixelMapfv"); + glad_glGetnPixelMapuiv = (PFNGLGETNPIXELMAPUIVPROC) load("glGetnPixelMapuiv"); + glad_glGetnPixelMapusv = (PFNGLGETNPIXELMAPUSVPROC) load("glGetnPixelMapusv"); + glad_glGetnPolygonStipple = (PFNGLGETNPOLYGONSTIPPLEPROC) load("glGetnPolygonStipple"); + glad_glGetnColorTable = (PFNGLGETNCOLORTABLEPROC) load("glGetnColorTable"); + glad_glGetnConvolutionFilter = (PFNGLGETNCONVOLUTIONFILTERPROC) load("glGetnConvolutionFilter"); + glad_glGetnSeparableFilter = (PFNGLGETNSEPARABLEFILTERPROC) load("glGetnSeparableFilter"); + glad_glGetnHistogram = (PFNGLGETNHISTOGRAMPROC) load("glGetnHistogram"); + glad_glGetnMinmax = (PFNGLGETNMINMAXPROC) load("glGetnMinmax"); + glad_glTextureBarrier = (PFNGLTEXTUREBARRIERPROC) load("glTextureBarrier"); } + static void load_GL_ARB_get_program_binary(GLADloadproc load) { - if(!GLAD_GL_ARB_get_program_binary) return; - glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)load("glGetProgramBinary"); - glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC)load("glProgramBinary"); - glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri"); + if (!GLAD_GL_ARB_get_program_binary) + return; + glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC) load("glGetProgramBinary"); + glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC) load("glProgramBinary"); + glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) load("glProgramParameteri"); } + static void load_GL_ARB_shading_language_include(GLADloadproc load) { - if(!GLAD_GL_ARB_shading_language_include) return; - glad_glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC)load("glNamedStringARB"); - glad_glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC)load("glDeleteNamedStringARB"); - glad_glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC)load("glCompileShaderIncludeARB"); - glad_glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC)load("glIsNamedStringARB"); - glad_glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC)load("glGetNamedStringARB"); - glad_glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC)load("glGetNamedStringivARB"); + if (!GLAD_GL_ARB_shading_language_include) + return; + glad_glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC) load("glNamedStringARB"); + glad_glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC) load("glDeleteNamedStringARB"); + glad_glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC) load("glCompileShaderIncludeARB"); + glad_glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC) load("glIsNamedStringARB"); + glad_glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC) load("glGetNamedStringARB"); + glad_glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC) load("glGetNamedStringivARB"); } + static int find_extensionsGL(void) { - if (!get_exts()) return 0; + if (!get_exts()) + return 0; GLAD_GL_ARB_get_program_binary = has_ext("GL_ARB_get_program_binary"); GLAD_GL_ARB_shading_language_include = has_ext("GL_ARB_shading_language_include"); free_exts(); @@ -6740,40 +10938,43 @@ static int find_extensionsGL(void) { static void find_coreGL(void) { - /* Thank you @elmindreda + /* Thank you @elmindreda * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176 * https://github.com/glfw/glfw/blob/master/src/context.c#L36 */ - int i, major, minor; - - const char* version; - const char* prefixes[] = { - "OpenGL ES-CM ", - "OpenGL ES-CL ", - "OpenGL ES ", - NULL - }; + int i, major, minor; - version = (const char*) glGetString(GL_VERSION); - if (!version) return; + const char *version; + const char *prefixes[] = { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + NULL + }; - for (i = 0; prefixes[i]; i++) { - const size_t length = strlen(prefixes[i]); - if (strncmp(version, prefixes[i], length) == 0) { - version += length; - break; - } - } + version = (const char *) glGetString(GL_VERSION); + if (!version) + return; + + for (i = 0; prefixes[i]; i++) { + const size_t length = strlen(prefixes[i]); + if (strncmp(version, prefixes[i], length) == 0) { + version += length; + break; + } + } /* PR #18 */ #ifdef _MSC_VER - sscanf_s(version, "%d.%d", &major, &minor); + sscanf_s(version, "%d.%d", &major, &minor); #else - sscanf(version, "%d.%d", &major, &minor); + sscanf(version, "%d.%d", &major, &minor); #endif - GLVersion.major = major; GLVersion.minor = minor; - max_loaded_major = major; max_loaded_minor = minor; + GLVersion.major = major; + GLVersion.minor = minor; + max_loaded_major = major; + max_loaded_minor = minor; GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; @@ -6799,10 +11000,13 @@ static void find_coreGL(void) { } int gladLoadGLLoader(GLADloadproc load) { - GLVersion.major = 0; GLVersion.minor = 0; - glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); - if(glGetString == NULL) return 0; - if(glGetString(GL_VERSION) == NULL) return 0; + GLVersion.major = 0; + GLVersion.minor = 0; + glGetString = (PFNGLGETSTRINGPROC) load("glGetString"); + if (glGetString == NULL) + return 0; + if (glGetString(GL_VERSION) == NULL) + return 0; find_coreGL(); load_GL_VERSION_1_0(load); load_GL_VERSION_1_1(load); @@ -6823,7 +11027,8 @@ int gladLoadGLLoader(GLADloadproc load) { load_GL_VERSION_4_4(load); load_GL_VERSION_4_5(load); - if (!find_extensionsGL()) return 0; + if (!find_extensionsGL()) + return 0; load_GL_ARB_get_program_binary(load); load_GL_ARB_shading_language_include(load); return GLVersion.major != 0 || GLVersion.minor != 0; diff --git a/fggl/gfx/ogl/renderer.cpp b/fggl/gfx/ogl/renderer.cpp index 241dfc5afead8adc3e0f869c0d2682406981ec3c..b92d80e7425818320a367c96f31c957038e256f2 100644 --- a/fggl/gfx/ogl/renderer.cpp +++ b/fggl/gfx/ogl/renderer.cpp @@ -90,25 +90,30 @@ constexpr auto static fggl_ogl_type(GLenum type) -> const char * { PRAGMA_DIAGNOSTIC_PUSH #pragma ide diagnostic ignored "bugprone-easily-swappable-parameters" -constexpr const char* OGL_LOG_FMT {"[GL] {}, {}: [{}]: {}"}; +constexpr const char *OGL_LOG_FMT{"[GL] {}, {}: [{}]: {}"}; -void static GLAPIENTRY fggl_ogl_to_spdlog(GLenum source, GLenum type, unsigned int msgId, GLenum severity, GLsizei /*length*/, - const char *message, const void * /*userParam*/) { +void static GLAPIENTRY fggl_ogl_to_spdlog(GLenum source, + GLenum type, + unsigned int msgId, + GLenum severity, + GLsizei /*length*/, + const char *message, + const void * /*userParam*/) { const auto *const sourceStr = fggl_ogl_source(source); const auto *const typeStr = fggl_ogl_type(type); // table 20.3, GL spec 4.5 switch (severity) { - case GL_DEBUG_SEVERITY_HIGH: fggl::debug::error(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); - break; - default: - case GL_DEBUG_SEVERITY_MEDIUM: fggl::debug::warning(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); - break; - case GL_DEBUG_SEVERITY_LOW: fggl::debug::info(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); - break; - case GL_DEBUG_SEVERITY_NOTIFICATION: fggl::debug::debug(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); - break; + case GL_DEBUG_SEVERITY_HIGH: fggl::debug::error(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); + break; + default: + case GL_DEBUG_SEVERITY_MEDIUM: fggl::debug::warning(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); + break; + case GL_DEBUG_SEVERITY_LOW: fggl::debug::info(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); + break; + case GL_DEBUG_SEVERITY_NOTIFICATION: fggl::debug::debug(OGL_LOG_FMT, sourceStr, typeStr, msgId, message); + break; } } @@ -134,10 +139,11 @@ namespace fggl::gfx { using data::Mesh2D; using data::Vertex2D; - OpenGL4Backend::OpenGL4Backend(data::Storage* storage, gui::FontLibrary* fonts) : fggl::gfx::Graphics(), m_canvasPipeline(INVALID_SHADER_ID), m_storage(storage) { + OpenGL4Backend::OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts) + : fggl::gfx::Graphics(), m_canvasPipeline(INVALID_SHADER_ID), m_storage(storage) { // initialise GLEW, or fail // FIXME this binds the graphics stack to GLFW :'( - int version = gladLoadGLLoader( (GLADloadproc)glfwGetProcAddress ); + int version = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); if (version == 0) { printf("Failed to initialize OpenGL context\n"); } @@ -145,7 +151,7 @@ namespace fggl::gfx { // OpenGL debug Support GLint flags = 0; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); - if ( (flags & GL_CONTEXT_FLAG_DEBUG_BIT) == GL_CONTEXT_FLAG_DEBUG_BIT) { // NOLINT(hicpp-signed-bitwise) + if ((flags & GL_CONTEXT_FLAG_DEBUG_BIT) == GL_CONTEXT_FLAG_DEBUG_BIT) { // NOLINT(hicpp-signed-bitwise) debug::info("enabling OpenGL debug output"); glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); @@ -163,7 +169,7 @@ namespace fggl::gfx { // setup 2D rendering system ShaderConfig shader2DConfig = ShaderConfig::named("canvas"); m_canvasPipeline = m_cache->load(shader2DConfig); - if ( m_canvasPipeline == INVALID_SHADER_ID) { + if (m_canvasPipeline == INVALID_SHADER_ID) { debug::error("failed to load shader2D - using fallback"); m_canvasPipeline = m_cache->get(ogl4::FALLBACK_CANVAS_PIPELINE); } @@ -178,7 +184,7 @@ namespace fggl::gfx { m_modelRenderer = std::make_unique<ogl4::StaticModelRenderer>(m_cache.get()); m_debugRenderer = std::make_unique<ogl4::DebugRenderer>(m_cache->getOrLoad(ShaderConfig::named("debug"))); - if ( m_debugRenderer ) { + if (m_debugRenderer) { dd::initialize(m_debugRenderer.get()); } }; @@ -189,7 +195,7 @@ namespace fggl::gfx { } void OpenGL4Backend::draw2D(const gfx::Paint &paint) { - if ( !m_canvasRenderer ) { + if (!m_canvasRenderer) { return; } @@ -197,23 +203,24 @@ namespace fggl::gfx { } void OpenGL4Backend::drawScene(entity::EntityManager &world) { - if ( m_modelRenderer ) { + if (m_modelRenderer) { m_modelRenderer->render(world); } - if ( m_debugRenderer ) { + if (m_debugRenderer) { auto cameras = world.find<gfx::Camera>(); - if ( cameras.empty() ) { + if (cameras.empty()) { return; } auto cameraEnt = cameras.front(); - const auto& camTransform = world.get<math::Transform>(cameraEnt); - const auto& camComp = world.get<gfx::Camera>(cameraEnt); + const auto &camTransform = world.get<math::Transform>(cameraEnt); + const auto &camComp = world.get<gfx::Camera>(cameraEnt); - const math::mat4 projectionMatrix = glm::perspective(camComp.fov, camComp.aspectRatio, camComp.nearPlane, camComp.farPlane); - const math::mat4 viewMatrix = glm::lookAt( camTransform.origin(), camComp.target, camTransform.up() ); + const math::mat4 projectionMatrix = + glm::perspective(camComp.fov, camComp.aspectRatio, camComp.nearPlane, camComp.farPlane); + const math::mat4 viewMatrix = glm::lookAt(camTransform.origin(), camComp.target, camTransform.up()); m_debugRenderer->mvpMatrix = projectionMatrix * viewMatrix; dd::flush(); diff --git a/fggl/gfx/ogl/shader.cpp b/fggl/gfx/ogl/shader.cpp index 21403f4087cc06320322cb6060872f0caff63ee4..953751d50bfa5328ca3082df7d554bc3f69017f7 100644 --- a/fggl/gfx/ogl/shader.cpp +++ b/fggl/gfx/ogl/shader.cpp @@ -22,23 +22,23 @@ using namespace fggl::gfx; -bool ShaderCache::compileShaderFromSource(const std::string& source, GLuint sid) { +bool ShaderCache::compileShaderFromSource(const std::string &source, GLuint sid) { // upload and compile shader - const char* src = source.c_str(); + const char *src = source.c_str(); glShaderSource(sid, 1, &src, nullptr); glCompileShader(sid); // check it worked GLint compiled = GL_FALSE; glGetShaderiv(sid, GL_COMPILE_STATUS, &compiled); - if ( compiled == GL_FALSE ) { + if (compiled == GL_FALSE) { GLint maxLength = 0; glGetShaderiv(sid, GL_INFO_LOG_LENGTH, &maxLength); - char* infoLog = new char[maxLength]; + char *infoLog = new char[maxLength]; glGetShaderInfoLog(sid, maxLength, &maxLength, infoLog); - spdlog::warn("could not compile shader source: {}", infoLog); + spdlog::warn("could not compile shader source: {}", infoLog); delete[] infoLog; return false; } @@ -49,7 +49,7 @@ bool ShaderCache::compileShaderFromSource(const std::string& source, GLuint sid) bool ShaderCache::readAndCompileShader(const std::string &filename, GLuint shader) { std::string source; bool result = m_storage->load(fggl::data::Data, filename, &source); - if ( !result ) { + if (!result) { spdlog::warn("could not load shader source from disk: {}", filename.c_str()); return false; } @@ -57,9 +57,9 @@ bool ShaderCache::readAndCompileShader(const std::string &filename, GLuint shade return compileShaderFromSource(source, shader); } -ShaderCache::ShaderCache(fggl::data::Storage* storage) : m_storage(storage), m_shaders(), m_binary(true) { +ShaderCache::ShaderCache(fggl::data::Storage *storage) : m_storage(storage), m_shaders(), m_binary(true) { - if ( !GLAD_GL_ARB_get_program_binary ) { + if (!GLAD_GL_ARB_get_program_binary) { spdlog::warn("the graphics card doesn support shader caching, disabling"); m_binary = false; } else { @@ -67,35 +67,35 @@ ShaderCache::ShaderCache(fggl::data::Storage* storage) : m_storage(storage), m_s m_binary = false; } - if ( GLAD_GL_ARB_shading_language_include ) { + if (GLAD_GL_ARB_shading_language_include) { setupIncludes(); } initFallbackPipelines(); } void ShaderCache::setupIncludes() { - auto root = m_storage->resolvePath( data::StorageType::Data, "include" ); - auto paths = m_storage->findResources( root, ".glsl"); + auto root = m_storage->resolvePath(data::StorageType::Data, "include"); + auto paths = m_storage->findResources(root, ".glsl"); - for ( auto& path : paths ){ + for (auto &path : paths) { std::string source; - m_storage->load( fggl::data::Data, path.string(), &source ); + m_storage->load(fggl::data::Data, path.string(), &source); auto relPath = std::filesystem::relative(path, root); const auto relPathStr = "/" + relPath.string(); - glNamedStringARB(GL_SHADER_INCLUDE_ARB, -1, relPathStr.c_str(), -1, source.c_str() ); + glNamedStringARB(GL_SHADER_INCLUDE_ARB, -1, relPathStr.c_str(), -1, source.c_str()); } } -bool ShaderCache::loadFromDisk(GLuint pid, const std::string& pipelineName) { +bool ShaderCache::loadFromDisk(GLuint pid, const std::string &pipelineName) { BinaryCache cache; auto fname = "shader_" + pipelineName + ".bin"; - bool status = m_storage->load( fggl::data::Cache, fname, &cache ); + bool status = m_storage->load(fggl::data::Cache, fname, &cache); - if ( !status ) { - spdlog::info("cached shader '{}' could not be loaded from disk", pipelineName); + if (!status) { + spdlog::info("cached shader '{}' could not be loaded from disk", pipelineName); return false; } @@ -104,41 +104,41 @@ bool ShaderCache::loadFromDisk(GLuint pid, const std::string& pipelineName) { return result; } -void ShaderCache::saveToDisk(GLuint pid, const std::string& pipelineName) { +void ShaderCache::saveToDisk(GLuint pid, const std::string &pipelineName) { BinaryCache cache; cacheSave(pid, &cache); auto fname = "shader_" + pipelineName + ".bin"; - m_storage->save( fggl::data::Cache, fname, &cache); + m_storage->save(fggl::data::Cache, fname, &cache); } -GLuint ShaderCache::getOrLoad(const ShaderConfig& config) { +GLuint ShaderCache::getOrLoad(const ShaderConfig &config) { try { return m_shaders.at(config.name); - } catch ( std::out_of_range& e) { + } catch (std::out_of_range &e) { return load(config); } } -GLuint ShaderCache::get(const std::string& name) { +GLuint ShaderCache::get(const std::string &name) { return m_shaders.at(name); } -GLuint ShaderCache::load(const ShaderConfig& config) { +GLuint ShaderCache::load(const ShaderConfig &config) { - spdlog::debug("starting shader program generation for {}", config.name); + spdlog::debug("starting shader program generation for {}", config.name); GLuint pid = glCreateProgram(); - if ( m_binary ) { + if (m_binary) { // if we have support for shader cache, give that a go bool worked = loadFromDisk(pid, config.name); - if ( worked ) { + if (worked) { m_shaders[config.name] = pid; return pid; } - spdlog::debug("could not use cached shader for '{}', doing full compile.", config.name); + spdlog::debug("could not use cached shader for '{}', doing full compile.", config.name); } // TODO actual shader loading @@ -151,9 +151,9 @@ GLuint ShaderCache::load(const ShaderConfig& config) { glAttachShader(pid, fragShader); GLuint geomShader = 0; - if ( config.hasGeom ) { + if (config.hasGeom) { geomShader = glCreateShader(GL_GEOMETRY_SHADER); - readAndCompileShader( config.geometry, geomShader ); + readAndCompileShader(config.geometry, geomShader); glAttachShader(pid, geomShader); } @@ -161,49 +161,49 @@ GLuint ShaderCache::load(const ShaderConfig& config) { glDetachShader(pid, vertShader); glDetachShader(pid, fragShader); - if ( config.hasGeom ) { + if (config.hasGeom) { glDetachShader(pid, geomShader); } GLint linked = GL_FALSE; glGetProgramiv(pid, GL_LINK_STATUS, &linked); - if ( linked == GL_FALSE ) { + if (linked == GL_FALSE) { // get the error std::array<char, 512> infoLog; glGetProgramInfoLog(pid, infoLog.size(), nullptr, infoLog.data()); - spdlog::warn("linking shader program '{}' failed: {}", config.name, infoLog.data()); + spdlog::warn("linking shader program '{}' failed: {}", config.name, infoLog.data()); // cleanup - glDeleteProgram( pid ); - glDeleteShader( vertShader ); - glDeleteShader( fragShader ); - if ( config.hasGeom ) { - glDeleteShader( geomShader ); + glDeleteProgram(pid); + glDeleteShader(vertShader); + glDeleteShader(fragShader); + if (config.hasGeom) { + glDeleteShader(geomShader); } return INVALID_SHADER_ID; } - - if ( m_binary ) { + + if (m_binary) { saveToDisk(pid, config.name); } // update the cache and return - m_shaders[ config.name ] = pid; + m_shaders[config.name] = pid; return pid; } -GLuint ShaderCache::load(const ShaderSources& sources, bool allowBinaryCache) { +GLuint ShaderCache::load(const ShaderSources &sources, bool allowBinaryCache) { spdlog::debug("starting shader program generation for {}", sources.name); GLuint pid = glCreateProgram(); - if ( m_binary && allowBinaryCache ) { + if (m_binary && allowBinaryCache) { // if we have support for shader cache, give that a go bool worked = loadFromDisk(pid, sources.name); - if ( worked ) { + if (worked) { m_shaders[sources.name] = pid; return pid; } @@ -221,7 +221,7 @@ GLuint ShaderCache::load(const ShaderSources& sources, bool allowBinaryCache) { glAttachShader(pid, fragShader); GLuint geomShader = INVALID_SHADER_ID; - if ( !sources.geometrySource.empty() ) { + if (!sources.geometrySource.empty()) { geomShader = glCreateShader(GL_GEOMETRY_SHADER); compileShaderFromSource(sources.geometrySource, geomShader); glAttachShader(pid, geomShader); @@ -231,13 +231,13 @@ GLuint ShaderCache::load(const ShaderSources& sources, bool allowBinaryCache) { glDetachShader(pid, vertShader); glDetachShader(pid, fragShader); - if ( geomShader != INVALID_SHADER_ID ) { + if (geomShader != INVALID_SHADER_ID) { glDetachShader(pid, geomShader); } GLint linked = GL_FALSE; glGetProgramiv(pid, GL_LINK_STATUS, &linked); - if ( linked == GL_FALSE ) { + if (linked == GL_FALSE) { // get the error std::array<char, 512> infoLog; @@ -245,26 +245,26 @@ GLuint ShaderCache::load(const ShaderSources& sources, bool allowBinaryCache) { spdlog::warn("linking shader program '{}' failed: {}", sources.name, infoLog.data()); // cleanup - glDeleteProgram( pid ); - glDeleteShader( vertShader ); - glDeleteShader( fragShader ); - if ( geomShader != INVALID_SHADER_ID ) { - glDeleteShader( geomShader ); + glDeleteProgram(pid); + glDeleteShader(vertShader); + glDeleteShader(fragShader); + if (geomShader != INVALID_SHADER_ID) { + glDeleteShader(geomShader); } return INVALID_SHADER_ID; } - if ( m_binary && allowBinaryCache ) { + if (m_binary && allowBinaryCache) { saveToDisk(pid, sources.name); } // update the cache and return - m_shaders[ sources.name ] = pid; + m_shaders[sources.name] = pid; return pid; } -void ShaderCache::cacheSave(GLuint pid, BinaryCache* cache) { +void ShaderCache::cacheSave(GLuint pid, BinaryCache *cache) { GLsizei length; glGetProgramiv(pid, GL_PROGRAM_BINARY_LENGTH, &length); @@ -274,8 +274,8 @@ void ShaderCache::cacheSave(GLuint pid, BinaryCache* cache) { glGetProgramBinary(pid, length, &cache->size, &cache->format, cache->data); } -bool ShaderCache::cacheLoad(GLuint pid, const BinaryCache* cache) { - if ( !m_binary ) { +bool ShaderCache::cacheLoad(GLuint pid, const BinaryCache *cache) { + if (!m_binary) { return false; } glProgramBinary(pid, cache->format, cache->data, cache->size); @@ -289,49 +289,49 @@ bool ShaderCache::cacheLoad(GLuint pid, const BinaryCache* cache) { void ShaderCache::initFallbackPipelines() { // canvas fallback pipeline load({ - .name = ogl4::FALLBACK_CANVAS_PIPELINE, - .vertexSource = ogl4::FALLBACK_CANVAS_VERTEX_SHADER, - .fragmentSource = ogl4::FALLBACK_CANVAS_FRAGMENT_SHADER, - .geometrySource = "" - }, false); + .name = ogl4::FALLBACK_CANVAS_PIPELINE, + .vertexSource = ogl4::FALLBACK_CANVAS_VERTEX_SHADER, + .fragmentSource = ogl4::FALLBACK_CANVAS_FRAGMENT_SHADER, + .geometrySource = "" + }, false); } template<> bool fggl::data::fggl_deserialize(std::filesystem::path &data, fggl::gfx::BinaryCache *out) { - auto f = - #ifdef _MSC_VER + auto f = + #ifdef _MSC_VER _wfopen(data.c_str(), L"r"); - #else - std::fopen( data.c_str(), "r"); + #else + std::fopen(data.c_str(), "r"); #endif - if ( f == nullptr ) { - spdlog::warn("could not load cached shader, fp was null"); + if (f == nullptr) { + spdlog::warn("could not load cached shader, fp was null"); return false; } - auto rsize = std::fread( &out->format, sizeof(GLenum), 1, f); - if ( rsize != 1 ) { - spdlog::warn("could not load cached shader: type read failed"); + auto rsize = std::fread(&out->format, sizeof(GLenum), 1, f); + if (rsize != 1) { + spdlog::warn("could not load cached shader: type read failed"); std::fclose(f); return false; } out->size = 0; - rsize = std::fread( &out->size, sizeof(GLsizei), 1, f); - if ( rsize != 1 ) { - spdlog::warn("could not load cached shader: size read failed"); + rsize = std::fread(&out->size, sizeof(GLsizei), 1, f); + if (rsize != 1) { + spdlog::warn("could not load cached shader: size read failed"); std::fclose(f); return false; } out->data = std::malloc(out->size); - auto readSize = std::fread( out->data, out->size, 1, f ); + auto readSize = std::fread(out->data, out->size, 1, f); auto result = true; - if ( readSize != 1 ) { - spdlog::warn("could not load cached shader: reading failed!"); - std::free( out->data ); + if (readSize != 1) { + spdlog::warn("could not load cached shader: reading failed!"); + std::free(out->data); result = false; } @@ -343,36 +343,34 @@ bool fggl::data::fggl_deserialize(std::filesystem::path &data, fggl::gfx::Binary #include <fstream> template<> -bool fggl::data::fggl_deserialize(std::filesystem::path& data, std::string *out) { +bool fggl::data::fggl_deserialize(std::filesystem::path &data, std::string *out) { std::ifstream ifs(data); - out->assign( (std::istreambuf_iterator<char>(ifs)), - (std::istreambuf_iterator<char>()) ); + out->assign((std::istreambuf_iterator<char>(ifs)), + (std::istreambuf_iterator<char>())); return true; } - - template<> bool fggl::data::fggl_serialize(std::filesystem::path &data, const fggl::gfx::BinaryCache *out) { // try and write auto f = #ifdef _MSC_VER - _wfopen( data.c_str(), L"w"); + _wfopen( data.c_str(), L"w"); #else - std::fopen( data.c_str(), "w"); - #endif + std::fopen(data.c_str(), "w"); + #endif - if ( f == nullptr ){ + if (f == nullptr) { return false; } - std::fwrite( &out->format, sizeof(GLenum), 1, f); - std::fwrite( &out->size, sizeof(GLsizei), 1, f); - std::fwrite( out->data, out->size, 1, f); + std::fwrite(&out->format, sizeof(GLenum), 1, f); + std::fwrite(&out->size, sizeof(GLsizei), 1, f); + std::fwrite(out->data, out->size, 1, f); std::fclose(f); - std::free( out->data ); + std::free(out->data); return true; } diff --git a/fggl/gfx/ogl/types.cpp b/fggl/gfx/ogl/types.cpp index 9ff8c2a1108b3df4f5c4d8a0d7008416d68af7f2..16bf58dbfc91e0fd4c73877a29e6e0ab165005d6 100644 --- a/fggl/gfx/ogl/types.cpp +++ b/fggl/gfx/ogl/types.cpp @@ -40,12 +40,12 @@ namespace fggl::gfx::ogl { release(); } - VertexArray::VertexArray(VertexArray &&other) noexcept : m_obj(other.m_obj) { + VertexArray::VertexArray(VertexArray &&other) noexcept: m_obj(other.m_obj) { other.m_obj = 0; } VertexArray &VertexArray::operator=(VertexArray &&other) { - if ( this != &other ){ + if (this != &other) { release(); std::swap(m_obj, other.m_obj); } @@ -57,56 +57,61 @@ namespace fggl::gfx::ogl { m_obj = 0; } - void VertexArray::setAttribute(const ArrayBuffer& buff, GLuint idx, AttributeF& attr) { - assert( 0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); - assert( 1 <= attr.elmCount && attr.elmCount <= 4); - assert( buff.isValid() ); + void VertexArray::setAttribute(const ArrayBuffer &buff, GLuint idx, AttributeF &attr) { + assert(0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); + assert(1 <= attr.elmCount && attr.elmCount <= 4); + assert(buff.isValid()); #ifndef FGGL_GL_I_BOUND - bind(); - GLuint boundVertexArray = 0; - bind_buffer(&boundVertexArray, buff); + bind(); + GLuint boundVertexArray = 0; + bind_buffer(&boundVertexArray, buff); #endif glEnableVertexAttribArray(idx); - glVertexAttribPointer( idx, attr.elmCount, (GLenum)attr.attrType, GL_FALSE, attr.stride, (void*)attr.offset); + glVertexAttribPointer(idx, attr.elmCount, (GLenum) attr.attrType, GL_FALSE, attr.stride, (void *) attr.offset); #ifndef FGGL_GL_I_BOUND - unbind_buffer(&boundVertexArray, buff); + unbind_buffer(&boundVertexArray, buff); #endif } - void VertexArray::setAttribute(const ArrayBuffer& buff, GLuint idx, AttributeI& attr, bool normalized) { - assert( 0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); - assert( 1 <= attr.elmCount && attr.elmCount <= 4); - assert( buff.isValid() ); + void VertexArray::setAttribute(const ArrayBuffer &buff, GLuint idx, AttributeI &attr, bool normalized) { + assert(0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); + assert(1 <= attr.elmCount && attr.elmCount <= 4); + assert(buff.isValid()); #ifndef FGGL_GL_I_BOUND - GLuint boundVertexArray = 0; - bind_buffer(&boundVertexArray, buff); + GLuint boundVertexArray = 0; + bind_buffer(&boundVertexArray, buff); #endif - glVertexAttribPointer(idx, attr.elmCount, (GLenum)attr.attrType, (GLboolean)normalized, attr.stride, (void*)attr.offset); + glVertexAttribPointer(idx, + attr.elmCount, + (GLenum) attr.attrType, + (GLboolean) normalized, + attr.stride, + (void *) attr.offset); #ifndef FGGL_GL_I_BOUND - unbind_buffer(&boundVertexArray, buff); + unbind_buffer(&boundVertexArray, buff); #endif } - void VertexArray::setAttributeI(const ArrayBuffer& buff, GLuint idx, AttributeI& attr) { - assert( 0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); - assert( 1 <= attr.elmCount && attr.elmCount <= 4); - assert( buff.isValid() ); + void VertexArray::setAttributeI(const ArrayBuffer &buff, GLuint idx, AttributeI &attr) { + assert(0 <= idx && idx < GL_MAX_VERTEX_ATTRIBS); + assert(1 <= attr.elmCount && attr.elmCount <= 4); + assert(buff.isValid()); #ifndef FGGL_GL_I_BOUND - GLuint boundVertexArray = 0; - bind_buffer(&boundVertexArray, buff); + GLuint boundVertexArray = 0; + bind_buffer(&boundVertexArray, buff); #endif - glVertexAttribIPointer( idx, attr.elmCount, (GLenum)attr.attrType, attr.stride, (void*)attr.offset); + glVertexAttribIPointer(idx, attr.elmCount, (GLenum) attr.attrType, attr.stride, (void *) attr.offset); #ifndef FGGL_GL_I_BOUND - unbind_buffer(&boundVertexArray, buff); + unbind_buffer(&boundVertexArray, buff); #endif } @@ -114,19 +119,19 @@ namespace fggl::gfx::ogl { bind(); #ifndef FGGL_I_BOUND - GLuint boundElementArray = 0; - bind_buffer(&boundElementArray, buff); + GLuint boundElementArray = 0; + bind_buffer(&boundElementArray, buff); #endif - glDrawElements( (GLenum)drawType, (GLsizei)size, GL_UNSIGNED_INT, nullptr ); + glDrawElements((GLenum) drawType, (GLsizei) size, GL_UNSIGNED_INT, nullptr); #ifndef FGGL_I_BOUND - unbind_buffer(&boundElementArray, buff); + unbind_buffer(&boundElementArray, buff); #endif } void VertexArray::draw(Primative drawType, int first, std::size_t count) { - glDrawArrays( (GLenum)drawType, first, count); + glDrawArrays((GLenum) drawType, first, count); } } // namespace fggl::gfx::ogl \ No newline at end of file diff --git a/fggl/gfx/ogl4/CMakeLists.txt b/fggl/gfx/ogl4/CMakeLists.txt index 93a61b15202c27edb630dcb029c154b9ba35a6fb..e00047055ea3833dcbeb550666289faa81626ef6 100644 --- a/fggl/gfx/ogl4/CMakeLists.txt +++ b/fggl/gfx/ogl4/CMakeLists.txt @@ -1,10 +1,10 @@ # Sources target_sources(fggl - PRIVATE - setup.cpp - canvas.cpp - models.cpp - debug.cpp - module.cpp -) + PRIVATE + setup.cpp + canvas.cpp + models.cpp + debug.cpp + module.cpp + ) diff --git a/fggl/gfx/ogl4/canvas.cpp b/fggl/gfx/ogl4/canvas.cpp index fae046626887c5886eb5cfa868f28cdca367dff4..e78057e59a7144e9a2ee9cd9338563b4727c5b17 100644 --- a/fggl/gfx/ogl4/canvas.cpp +++ b/fggl/gfx/ogl4/canvas.cpp @@ -27,23 +27,23 @@ namespace fggl::gfx::ogl4 { - static void make_box( gfx::Path2D& path, glm::vec2 topLeft, glm::vec2 bottomRight ) { - path.moveTo( { topLeft.x, topLeft.y } ); - path.pathTo( { bottomRight.x, topLeft.y } ); - path.pathTo( { bottomRight.x, bottomRight.y } ); - path.pathTo( { topLeft.x, bottomRight.y } ); - path.pathTo( { topLeft.x, topLeft.y } ); + static void make_box(gfx::Path2D &path, glm::vec2 topLeft, glm::vec2 bottomRight) { + path.moveTo({topLeft.x, topLeft.y}); + path.pathTo({bottomRight.x, topLeft.y}); + path.pathTo({bottomRight.x, bottomRight.y}); + path.pathTo({topLeft.x, bottomRight.y}); + path.pathTo({topLeft.x, topLeft.y}); } - inline static void add_mesh_triangle(data::Mesh2D& mesh, const std::vector<data::Vertex2D>& verts) { - assert( verts.size() == 3); - for( const auto& vert : verts ) { + inline static void add_mesh_triangle(data::Mesh2D &mesh, const std::vector<data::Vertex2D> &verts) { + assert(verts.size() == 3); + for (const auto &vert : verts) { auto idx = mesh.add_vertex(vert); mesh.add_index(idx); } } - static void convert_to_mesh(const gfx::Paint& paint, data::Mesh2D& mesh) { + static void convert_to_mesh(const gfx::Paint &paint, data::Mesh2D &mesh) { for (const auto &cmd : paint.cmds()) { auto path = cmd.path; @@ -83,17 +83,17 @@ namespace fggl::gfx::ogl4 { } } - CanvasRenderer::CanvasRenderer(fggl::gui::FontLibrary* fonts) : + CanvasRenderer::CanvasRenderer(fggl::gui::FontLibrary *fonts) : m_bounds({0.0F, 1920.F, 1080.0F, 0.0F}), m_fonts(fonts), m_fontTex(ogl::TextureType::Tex2D) { m_vao.bind(); #ifdef FGGL_GL_I_BOUND - // user will handle binding themselves usually, so attribute won't bind itself. - // which means it's our problem right now... - GLuint originalVertexList; - ogl::bind_buffer( &originalVertexList, m_vertexList ); + // user will handle binding themselves usually, so attribute won't bind itself. + // which means it's our problem right now... + GLuint originalVertexList; + ogl::bind_buffer( &originalVertexList, m_vertexList ); #endif // define our attributes @@ -107,19 +107,19 @@ namespace fggl::gfx::ogl4 { m_vao.setAttribute(m_vertexList, 2, texAttr); #ifdef FGGL_GL_I_BOUND - // cool, rebind whatever happened before, or not - ogl::unbind_buffer( &originalVertexList, m_vertexList ); + // cool, rebind whatever happened before, or not + ogl::unbind_buffer( &originalVertexList, m_vertexList ); #endif glBindVertexArray(0); } - void CanvasRenderer::renderShapes (const gfx::Paint& paint, GLuint shader) { + void CanvasRenderer::renderShapes(const gfx::Paint &paint, GLuint shader) { data::Mesh2D mesh; convert_to_mesh(paint, mesh); // nothing to render? give up - if ( mesh.indexList.empty() ){ + if (mesh.indexList.empty()) { return; } @@ -129,55 +129,55 @@ namespace fggl::gfx::ogl4 { m_indexList.replace(mesh.indexList.size(), mesh.indexList.data()); // draw - glDisable( GL_DEPTH_TEST ); - glDisable( GL_CULL_FACE ); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); // FIXME: this should be abstracted into the shader class - glUseProgram( shader ); + glUseProgram(shader); auto projMat = glm::ortho(m_bounds.left, m_bounds.right, m_bounds.bottom, m_bounds.top); - glUniformMatrix4fv(glGetUniformLocation( shader, "projection"), 1, GL_FALSE, + glUniformMatrix4fv(glGetUniformLocation(shader, "projection"), 1, GL_FALSE, glm::value_ptr(projMat)); m_vao.drawElements(m_indexList, ogl::Primative::TRIANGLE, mesh.indexList.size()); - glUseProgram( 0 ); + glUseProgram(0); } // slow version - void CanvasRenderer::renderText(const Paint& paint, GLuint shader) { - if ( paint.textCmds().empty() ){ + void CanvasRenderer::renderText(const Paint &paint, GLuint shader) { + if (paint.textCmds().empty()) { return; } // get the expected font std::shared_ptr<gui::FontFace> face = m_fonts->getFont("LiberationSans-Regular.ttf"); - if ( face == nullptr ){ + if (face == nullptr) { // we don't know about that font... return; } // setup the shader - glUseProgram( shader ); + glUseProgram(shader); auto projMat = glm::ortho(0.0f, 1920.0f, 1080.0f, 0.f); - glUniformMatrix4fv(glGetUniformLocation( shader, "projection"), 1, GL_FALSE, + glUniformMatrix4fv(glGetUniformLocation(shader, "projection"), 1, GL_FALSE, glm::value_ptr(projMat)); // bind the vbo we'll use for writing m_vao.bind(); // setup the openGL state we expect for rendering - glDisable( GL_DEPTH_TEST ); - glDisable( GL_CULL_FACE ); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // for each text string, attempt to render it - for ( const auto& textCmd : paint.textCmds() ) { + for (const auto &textCmd : paint.textCmds()) { const auto label = textCmd.text; math::vec2 penPos(textCmd.pos); - for ( auto letter : label ) { + for (auto letter : label) { ogl::Image img{}; img.format = ogl::ImageFormat::R; img.type = ogl::PixelFormat::UNSIGNED_BYTE; @@ -192,16 +192,16 @@ namespace fggl::gfx::ogl4 { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); m_fontTex.bind(1); - glUniform1i( glGetUniformLocation(shader, "tex"), 1); + glUniform1i(glGetUniformLocation(shader, "tex"), 1); // this is why this is called the slow version, we render each quad as a single call - auto& metrics = face->metrics(letter); + auto &metrics = face->metrics(letter); float xPos = penPos.x + metrics.bearing.x; float yPos = (penPos.y - metrics.bearing.y); float w = metrics.size.x; float h = metrics.size.y; - const math::vec3 texCol{ 1.0f, 1.0f, 1.0f}; + const math::vec3 texCol{1.0f, 1.0f, 1.0f}; std::array<data::Vertex2D, 6> verts{{ {{xPos, yPos + h}, texCol, {0.0F, 1.0F}}, @@ -216,7 +216,7 @@ namespace fggl::gfx::ogl4 { m_vao.bind(); m_vao.draw(ogl::Primative::TRIANGLE, 0, verts.size()); - penPos.x += (metrics.advance >> 6 ); + penPos.x += (metrics.advance >> 6); } } diff --git a/fggl/gfx/ogl4/debug.cpp b/fggl/gfx/ogl4/debug.cpp index fb4e13e4461e19abd22e8077d385f6ab2061f508..e84a000c96caac6c1927b11a9682d2385667d913 100644 --- a/fggl/gfx/ogl4/debug.cpp +++ b/fggl/gfx/ogl4/debug.cpp @@ -24,22 +24,20 @@ namespace fggl::gfx::ogl4 { - DebugRenderer::DebugRenderer(GLuint shader) : mvpMatrix(1.0f), m_lineShader(shader), - m_lineShaderMVP( m_lineShader.uniform("u_MvpMatrix")) { + m_lineShaderMVP(m_lineShader.uniform("u_MvpMatrix")) { // define our attributes - auto posAttr = ogl::attribute<dd::DrawVertex, math::vec3>( 0 ); - auto colAttr = ogl::attribute<dd::DrawVertex, math::vec3>( sizeof(float) * 3 ); + auto posAttr = ogl::attribute<dd::DrawVertex, math::vec3>(0); + auto colAttr = ogl::attribute<dd::DrawVertex, math::vec3>(sizeof(float) * 3); // bind the attributes to the vao m_lineVao.setAttribute(m_lineVbo, 0, posAttr); m_lineVao.setAttribute(m_lineVbo, 1, colAttr); } - void DebugRenderer::drawLineList(const dd::DrawVertex * lines, int count, bool depthEnabled) - { + void DebugRenderer::drawLineList(const dd::DrawVertex *lines, int count, bool depthEnabled) { assert(lines != nullptr); assert(count > 0 && count <= DEBUG_DRAW_VERTEX_BUFFER_SIZE); @@ -47,12 +45,9 @@ namespace fggl::gfx::ogl4 { m_lineShader.use(); m_lineShader.setUniformMtx(m_lineShaderMVP, mvpMatrix); - if (depthEnabled) - { + if (depthEnabled) { glEnable(GL_DEPTH_TEST); - } - else - { + } else { glDisable(GL_DEPTH_TEST); } diff --git a/fggl/gfx/ogl4/models.cpp b/fggl/gfx/ogl4/models.cpp index c00e08f9a62ec9ed0028974180bca4833180bd67..ed6e430698d371b9dbe5373962365b19d5b0cb9a 100644 --- a/fggl/gfx/ogl4/models.cpp +++ b/fggl/gfx/ogl4/models.cpp @@ -26,8 +26,8 @@ namespace fggl::gfx::ogl4 { - static std::shared_ptr<ogl::ArrayBuffer> setupArrayBuffer(std::shared_ptr<ogl::VertexArray>& vao, - std::vector<data::Vertex>& data) { + static std::shared_ptr<ogl::ArrayBuffer> setupArrayBuffer(std::shared_ptr<ogl::VertexArray> &vao, + std::vector<data::Vertex> &data) { auto buff = std::make_shared<ogl::ArrayBuffer>(); buff->write(data.size() * sizeof(data::Vertex), data.data(), ogl::BufUsage::STATIC_DRAW); @@ -36,22 +36,22 @@ namespace fggl::gfx::ogl4 { auto normalAttr = ogl::attribute<data::Vertex, math::vec3>(offsetof(data::Vertex, normal)); auto colAttr = ogl::attribute<data::Vertex, math::vec3>(offsetof(data::Vertex, colour)); - vao->setAttribute( *buff, 0, posAttr ); - vao->setAttribute( *buff, 1, normalAttr ); - vao->setAttribute( *buff, 2, colAttr ); + vao->setAttribute(*buff, 0, posAttr); + vao->setAttribute(*buff, 1, normalAttr); + vao->setAttribute(*buff, 2, colAttr); return buff; } - static std::shared_ptr<ogl::ElementBuffer> setupIndexBuffer(std::shared_ptr<ogl::VertexArray>& vao, - std::vector<uint32_t>& data) { + static std::shared_ptr<ogl::ElementBuffer> setupIndexBuffer(std::shared_ptr<ogl::VertexArray> &vao, + std::vector<uint32_t> &data) { auto elementBuffer = std::make_shared<ogl::ElementBuffer>(); elementBuffer->write(data.size() * sizeof(uint32_t), data.data(), ogl::BufUsage::STATIC_DRAW); return elementBuffer; } - static void setupComponent(StaticModel& modelComp, std::shared_ptr<ogl::Shader>& shader, data::Mesh& mesh) { - auto vao = std::make_shared< ogl::VertexArray >(); + static void setupComponent(StaticModel &modelComp, std::shared_ptr<ogl::Shader> &shader, data::Mesh &mesh) { + auto vao = std::make_shared<ogl::VertexArray>(); auto meshBuffer = setupArrayBuffer(vao, mesh.vertexList()); auto elementBuffer = setupIndexBuffer(vao, mesh.indexList()); @@ -67,39 +67,39 @@ namespace fggl::gfx::ogl4 { void StaticModelRenderer::resolveModels(entity::EntityManager &world) { // FIXME: this needs something reactive or performance will suck. auto renderables = world.find<data::StaticMesh>(); - for (const auto& renderable : renderables){ - auto* currModel = world.tryGet<StaticModel>( renderable ); - if ( currModel != nullptr ){ + for (const auto &renderable : renderables) { + auto *currModel = world.tryGet<StaticModel>(renderable); + if (currModel != nullptr) { continue; } - auto& meshComp = world.get<data::StaticMesh>(renderable); - auto& modelComp = world.add<StaticModel>(renderable); + auto &meshComp = world.get<data::StaticMesh>(renderable); + auto &modelComp = world.add<StaticModel>(renderable); auto shader = m_phong; try { - shader = std::make_shared<ogl::Shader>( m_shaders->get( meshComp.pipeline ) ); - } catch ( std::out_of_range& e) { + shader = std::make_shared<ogl::Shader>(m_shaders->get(meshComp.pipeline)); + } catch (std::out_of_range &e) { debug::log(debug::Level::warning, "Could not find shader: {}", meshComp.pipeline); } setupComponent(modelComp, shader, meshComp.mesh); - debug::log(debug::Level::info, "Added static mesh to {}", (uint64_t)renderable); + debug::log(debug::Level::info, "Added static mesh to {}", (uint64_t) renderable); } // terrain auto terrain = world.find<data::HeightMap>(); - for (auto& renderable : terrain){ - auto currModel = world.tryGet<StaticModel>( renderable ); - if ( currModel != nullptr ){ + for (auto &renderable : terrain) { + auto currModel = world.tryGet<StaticModel>(renderable); + if (currModel != nullptr) { continue; } - auto& heightmap = world.get<data::HeightMap>(renderable); + auto &heightmap = world.get<data::HeightMap>(renderable); data::Mesh heightMapMesh{}; data::generateHeightMesh(heightmap, heightMapMesh); - auto& modelComp = world.add<StaticModel>(renderable); + auto &modelComp = world.add<StaticModel>(renderable); setupComponent(modelComp, m_phong, heightMapMesh); // we know this is a triangle strip with a restart vertex... @@ -118,64 +118,65 @@ namespace fggl::gfx::ogl4 { auto cameras = world.find<gfx::Camera>(); // if there are no cameras, we can't do anything... - if ( cameras.empty() ) { + if (cameras.empty()) { spdlog::warn("asked to render static models, but there were no cameras"); return; } // perform a rendering pass for each camera (will usually only be one...) - for ( const auto& cameraEnt : cameras ){ + for (const auto &cameraEnt : cameras) { //TODO should be clipping this to only visible objects // enable required OpenGL state - glEnable( GL_CULL_FACE ); - glCullFace( GL_BACK ); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); // enable depth testing - glEnable( GL_DEPTH_TEST ); + glEnable(GL_DEPTH_TEST); // set-up camera matrices - const auto& camTransform = world.get<math::Transform>(cameraEnt); - const auto& camComp = world.get<gfx::Camera>(cameraEnt); + const auto &camTransform = world.get<math::Transform>(cameraEnt); + const auto &camComp = world.get<gfx::Camera>(cameraEnt); - const math::mat4 projectionMatrix = glm::perspective(camComp.fov, camComp.aspectRatio, camComp.nearPlane, camComp.farPlane); - const math::mat4 viewMatrix = glm::lookAt( camTransform.origin(), camComp.target, camTransform.up() ); + const math::mat4 projectionMatrix = + glm::perspective(camComp.fov, camComp.aspectRatio, camComp.nearPlane, camComp.farPlane); + const math::mat4 viewMatrix = glm::lookAt(camTransform.origin(), camComp.target, camTransform.up()); // TODO lighting needs to not be this... math::vec3 lightPos{0.0f, 10.0f, 0.0f}; std::shared_ptr<ogl::Shader> shader = nullptr; auto renderables = world.find<StaticModel>(); - for ( const auto& entity : renderables ){ + for (const auto &entity : renderables) { // ensure that the model pipeline actually exists... - const auto& model = world.get<StaticModel>(entity); - if ( model.pipeline == nullptr ) { + const auto &model = world.get<StaticModel>(entity); + if (model.pipeline == nullptr) { spdlog::warn("shader was null, aborting render"); continue; } // check if we switched shaders - if ( shader != model.pipeline ) { + if (shader != model.pipeline) { // new shader - need to re-send the view and projection matrices shader = model.pipeline; shader->use(); - if ( shader->hasUniform("projection") ) { + if (shader->hasUniform("projection")) { shader->setUniformMtx(shader->uniform("view"), viewMatrix); shader->setUniformMtx(shader->uniform("projection"), projectionMatrix); } } // set model transform - const auto& transform = world.get<math::Transform>(entity); - shader->setUniformMtx(shader->uniform("MVPMatrix"), projectionMatrix * viewMatrix * transform.model() ); + const auto &transform = world.get<math::Transform>(entity); + shader->setUniformMtx(shader->uniform("MVPMatrix"), projectionMatrix * viewMatrix * transform.model()); shader->setUniformMtx(shader->uniform("MVMatrix"), viewMatrix * transform.model()); auto normalMatrix = glm::mat3(glm::transpose(inverse(transform.model()))); shader->setUniformMtx(shader->uniform("NormalMatrix"), normalMatrix); // setup lighting mode - if ( shader->hasUniform("lights[0].isEnabled") ) { + if (shader->hasUniform("lights[0].isEnabled")) { bool local = true; shader->setUniformI(shader->uniform("lights[0].isEnabled"), 1); @@ -192,7 +193,7 @@ namespace fggl::gfx::ogl4 { lightPos = glm::normalize(lightPos); auto viewDir = glm::normalize(camTransform.origin() - transform.origin()); auto halfVector = glm::normalize(lightPos + viewDir); - shader->setUniformF(shader->uniform("lights[0].halfVector"), halfVector ); + shader->setUniformF(shader->uniform("lights[0].halfVector"), halfVector); shader->setUniformF(shader->uniform("EyeDirection"), viewDir); shader->setUniformF(shader->uniform("lights[0].position"), lightPos); } else { @@ -201,7 +202,8 @@ namespace fggl::gfx::ogl4 { math::vec3 viewDir = glm::normalize(camModelView - modelModelView); shader->setUniformF(shader->uniform("EyeDirection"), viewDir); - shader->setUniformF(shader->uniform("lights[0].position"), math::vec3(viewMatrix * math::vec4(lightPos, 1.0f))); + shader->setUniformF(shader->uniform("lights[0].position"), + math::vec3(viewMatrix * math::vec4(lightPos, 1.0f))); } shader->setUniformF(shader->uniform("lights[0].ambient"), {0.0f, 0.5f, 0.0f}); @@ -209,9 +211,9 @@ namespace fggl::gfx::ogl4 { } // material detection with fallback - const auto& material = world.get<PhongMaterial>(entity); + const auto &material = world.get<PhongMaterial>(entity); - if ( shader->hasUniform("materials[0].ambient") ) { + if (shader->hasUniform("materials[0].ambient")) { shader->setUniformF(shader->uniform("materials[0].emission"), material.emission); shader->setUniformF(shader->uniform("materials[0].ambient"), material.ambient); shader->setUniformF(shader->uniform("materials[0].diffuse"), material.diffuse); @@ -219,22 +221,22 @@ namespace fggl::gfx::ogl4 { shader->setUniformF(shader->uniform("materials[0].shininess"), material.shininess); } - if ( shader->hasUniform("lightPos")) { - shader->setUniformF( shader->uniform("lightPos"), lightPos); + if (shader->hasUniform("lightPos")) { + shader->setUniformF(shader->uniform("lightPos"), lightPos); } auto vao = model.vao; vao->bind(); model.vertexData->bind(); - if ( model.restartIndex != NO_RESTART_IDX) { + if (model.restartIndex != NO_RESTART_IDX) { glEnable(GL_PRIMITIVE_RESTART); glPrimitiveRestartIndex(model.restartIndex); } - auto* elements = model.elements.get(); - vao->drawElements( *elements, model.drawType, model.elementCount); - if ( model.restartIndex != NO_RESTART_IDX) { + auto *elements = model.elements.get(); + vao->drawElements(*elements, model.drawType, model.elementCount); + if (model.restartIndex != NO_RESTART_IDX) { glDisable(GL_PRIMITIVE_RESTART); } } diff --git a/fggl/gfx/ogl4/module.cpp b/fggl/gfx/ogl4/module.cpp index 9bfe38cc869beb8d26197edd1dc66d4b1a71f558..dc6767b2c4d6845e9e74f949958f65438a32048e 100644 --- a/fggl/gfx/ogl4/module.cpp +++ b/fggl/gfx/ogl4/module.cpp @@ -26,10 +26,10 @@ namespace fggl::gfx { constexpr uint32_t DEFAULT_STACKS = 16; constexpr uint32_t DEFAULT_SLICES = 16; - constexpr const char* SHAPE_SPHERE{"sphere"}; - constexpr const char* SHAPE_BOX{"box"}; + constexpr const char *SHAPE_SPHERE{"sphere"}; + constexpr const char *SHAPE_BOX{"box"}; - static void process_shape(const YAML::Node& node, data::Mesh& mesh) { + static void process_shape(const YAML::Node &node, data::Mesh &mesh) { auto transform = data::OFFSET_NONE; auto offset = node["offset"].as<math::vec3>(math::VEC3_ZERO); @@ -41,9 +41,9 @@ namespace fggl::gfx { // now the shape itself auto type = node["type"].as<std::string>(); - if ( type == SHAPE_BOX ) { + if (type == SHAPE_BOX) { data::make_cube(mesh, transform); - } else if ( type == SHAPE_SPHERE ) { + } else if (type == SHAPE_SPHERE) { auto stacks = node["stacks"].as<uint32_t>(DEFAULT_STACKS); auto slices = node["slices"].as<uint32_t>(DEFAULT_SLICES); data::make_sphere(mesh, transform, stacks, slices); @@ -52,15 +52,15 @@ namespace fggl::gfx { } } - void attach_mesh(const entity::ComponentSpec& spec, entity::EntityManager& manager, const entity::EntityID& id) { - auto& meshComp = manager.add<data::StaticMesh>(id); + void attach_mesh(const entity::ComponentSpec &spec, entity::EntityManager &manager, const entity::EntityID &id) { + auto &meshComp = manager.add<data::StaticMesh>(id); meshComp.pipeline = spec.get<std::string>("pipeline", ""); - if ( spec.has("shape") ) { + if (spec.has("shape")) { // procedural mesh data::Mesh mesh; - if ( spec.config["shape"].IsSequence() ) { - for( const auto& node : spec.config["shape"] ) { + if (spec.config["shape"].IsSequence()) { + for (const auto &node : spec.config["shape"]) { process_shape(node, mesh); } } else { @@ -71,27 +71,29 @@ namespace fggl::gfx { } } - void attach_material(const entity::ComponentSpec& spec, entity::EntityManager& manager, const entity::EntityID& id) { - auto& mat = manager.add<gfx::PhongMaterial>(id); + void attach_material(const entity::ComponentSpec &spec, + entity::EntityManager &manager, + const entity::EntityID &id) { + auto &mat = manager.add<gfx::PhongMaterial>(id); mat.ambient = spec.get<math::vec3>("ambient", gfx::DEFAULT_AMBIENT); mat.diffuse = spec.get<math::vec3>("diffuse", gfx::DEFAULT_DIFFUSE); mat.specular = spec.get<math::vec3>("ambient", gfx::DEFAULT_SPECULAR); mat.shininess = spec.get<float>("ambient", gfx::DEFAULT_SHININESS); } - void attach_light(const entity::ComponentSpec& spec, entity::EntityManager& manager, const entity::EntityID& id) { - auto& light = manager.add<gfx::Light>(id); + void attach_light(const entity::ComponentSpec &spec, entity::EntityManager &manager, const entity::EntityID &id) { + auto &light = manager.add<gfx::Light>(id); } - bool OpenGL4::factory(modules::ModuleService service, modules::Services& services) { + bool OpenGL4::factory(modules::ModuleService service, modules::Services &services) { if (service == WindowGraphics::service) { // setup the thing responsible for graphics - auto* storage = services.get<data::Storage>(); - auto* fontLibrary = services.get<gui::FontLibrary>(); + auto *storage = services.get<data::Storage>(); + auto *fontLibrary = services.get<gui::FontLibrary>(); services.bind<WindowGraphics, ogl4::WindowGraphics>(storage, fontLibrary); // register as responsible for creating rendering components - auto* entityFactory = services.get<entity::EntityFactory>(); + auto *entityFactory = services.get<entity::EntityFactory>(); entityFactory->bind(data::StaticMesh::guid, attach_mesh); entityFactory->bind(gfx::PhongMaterial::guid, attach_material); entityFactory->bind(gfx::Light::guid, attach_light); diff --git a/fggl/gfx/window.cpp b/fggl/gfx/window.cpp index 0420c77889e1e79127e7780e3f264c57b391ed07..b0e86d1068e272936db6767cfa5346f7944a7ebb 100644 --- a/fggl/gfx/window.cpp +++ b/fggl/gfx/window.cpp @@ -155,7 +155,7 @@ namespace fggl::display::glfw { fggl_joystick_poll(); } - Window::Window(std::shared_ptr<GlfwContext> context, gfx::WindowGraphics* graphics) + Window::Window(std::shared_ptr<GlfwContext> context, gfx::WindowGraphics *graphics) : m_context(std::move(context)), m_window(nullptr), m_framesize() { spdlog::debug("[glfw] creating window"); diff --git a/fggl/gui/containers.cpp b/fggl/gui/containers.cpp index c46dbffe0447b955970563c3c185c3b58bbbce0b..c0232ddbc698dc33452f5ca5993ca696b0e63600 100644 --- a/fggl/gui/containers.cpp +++ b/fggl/gui/containers.cpp @@ -18,8 +18,8 @@ namespace fggl::gui { Widget *Container::getChildAt(const math::vec2 &point) { - for ( auto& child : m_children ){ - if ( child->contains(point) ){ + for (auto &child : m_children) { + if (child->contains(point)) { return child->getChildAt(point); } } @@ -32,13 +32,13 @@ namespace fggl::gui { } void Container::render(gfx::Paint &paint) { - for( auto& child : m_children ){ - child->render( paint ); + for (auto &child : m_children) { + child->render(paint); } } void Container::add(std::unique_ptr<Widget> widget) { - m_children.push_back( std::move(widget) ); + m_children.push_back(std::move(widget)); m_dirty = true; } @@ -70,7 +70,7 @@ namespace fggl::gui { void Panel::render(gfx::Paint &paint) { // background painting time gfx::Path2D background(topLeft()); - background.colour(math::vec3(32.0f/255.0f, 74.0F/255.0F, 135.0F/255.0F)); + background.colour(math::vec3(32.0f / 255.0f, 74.0F / 255.0F, 135.0F / 255.0F)); draw_box(background, topLeft(), bottomRight()); paint.fill(background); diff --git a/fggl/gui/fonts.cpp b/fggl/gui/fonts.cpp index 0efb616f02741834e00645d0d9bdf83ada81d202..a8d91a960bb2040d6c451b84c2458728ddf40b73 100644 --- a/fggl/gui/fonts.cpp +++ b/fggl/gui/fonts.cpp @@ -23,13 +23,13 @@ namespace fggl::gui { FT_Done_Face(m_face); } - FontLibrary::FontLibrary(data::Storage* storage) : m_context(nullptr), m_storage(storage) { + FontLibrary::FontLibrary(data::Storage *storage) : m_context(nullptr), m_storage(storage) { FT_Init_FreeType(&m_context); } FontLibrary::~FontLibrary() { // free all fonts - for (auto& face : m_cache ){ + for (auto &face : m_cache) { face.second = nullptr; } @@ -38,14 +38,14 @@ namespace fggl::gui { } GlyphMetrics &FontFace::populateMetrics(char letter) { - if (FT_Load_Char(m_face, letter, FT_LOAD_RENDER) ) { + if (FT_Load_Char(m_face, letter, FT_LOAD_RENDER)) { // something bad happened return m_metrics['?']; } - GlyphMetrics metrics { - { m_face->glyph->bitmap.width, m_face->glyph->bitmap.rows}, - { m_face->glyph->bitmap_left, m_face->glyph->bitmap_top }, + GlyphMetrics metrics{ + {m_face->glyph->bitmap.width, m_face->glyph->bitmap.rows}, + {m_face->glyph->bitmap_left, m_face->glyph->bitmap_top}, m_face->glyph->advance.x }; @@ -55,7 +55,7 @@ namespace fggl::gui { } void FontFace::texture(char letter, int &width, int &height, void **buff) { - if (FT_Load_Char(m_face, letter, FT_LOAD_RENDER) ) { + if (FT_Load_Char(m_face, letter, FT_LOAD_RENDER)) { // something bad happened return; } diff --git a/fggl/gui/widget.cpp b/fggl/gui/widget.cpp index c8d4e49f88a5e6b09fdd4430c6c6bcefa99b3491..1b186e272d50b99cf3f3a1efc5d7c72cbf3cf7d1 100644 --- a/fggl/gui/widget.cpp +++ b/fggl/gui/widget.cpp @@ -20,44 +20,44 @@ namespace fggl::gui { - void buttonBorder( gfx::Path2D& path, glm::vec2 pos, glm::vec2 size ) { + void buttonBorder(gfx::Path2D &path, glm::vec2 pos, glm::vec2 size) { // outer box - path.colour( {1.0f, 0.0f, 0.0f} ); - path.pathTo( { pos.x + size.x, pos.y } ); - path.pathTo( { pos.x + size.x, pos.y + size.y } ); - path.pathTo( { pos.x, pos.y + size.y } ); + path.colour({1.0f, 0.0f, 0.0f}); + path.pathTo({pos.x + size.x, pos.y}); + path.pathTo({pos.x + size.x, pos.y + size.y}); + path.pathTo({pos.x, pos.y + size.y}); path.close(); // inner box - math::vec2 innerTop { pos.x + 5, pos.y + 5 }; - math::vec2 innerBottom { pos.x + size.x - 5, pos.y + size.y - 5 }; - - path.colour( {1.0f, 1.0f, 0.0f} ); - path.moveTo( { innerTop.x, innerTop.y } ); - path.pathTo( { innerBottom.x, innerTop.y } ); - path.pathTo( { innerBottom.x, innerBottom.y } ); - path.pathTo( { innerTop.x, innerBottom.y } ); - path.pathTo( { innerTop.x, innerTop.y } ); + math::vec2 innerTop{pos.x + 5, pos.y + 5}; + math::vec2 innerBottom{pos.x + size.x - 5, pos.y + size.y - 5}; + + path.colour({1.0f, 1.0f, 0.0f}); + path.moveTo({innerTop.x, innerTop.y}); + path.pathTo({innerBottom.x, innerTop.y}); + path.pathTo({innerBottom.x, innerBottom.y}); + path.pathTo({innerTop.x, innerBottom.y}); + path.pathTo({innerTop.x, innerTop.y}); } - void draw_box( gfx::Path2D& path, glm::vec2 topLeft, glm::vec2 bottomRight ) { - path.moveTo( { topLeft.x, topLeft.y } ); - path.pathTo( { bottomRight.x, topLeft.y } ); - path.pathTo( { bottomRight.x, bottomRight.y } ); - path.pathTo( { topLeft.x, bottomRight.y } ); - path.pathTo( { topLeft.x, topLeft.y } ); + void draw_box(gfx::Path2D &path, glm::vec2 topLeft, glm::vec2 bottomRight) { + path.moveTo({topLeft.x, topLeft.y}); + path.pathTo({bottomRight.x, topLeft.y}); + path.pathTo({bottomRight.x, bottomRight.y}); + path.pathTo({topLeft.x, bottomRight.y}); + path.pathTo({topLeft.x, topLeft.y}); } - void draw_progress( gfx::Path2D& path, glm::vec2 topLeft, glm::vec2 size, float value ) { - const auto bottomRight { topLeft + size }; + void draw_progress(gfx::Path2D &path, glm::vec2 topLeft, glm::vec2 size, float value) { + const auto bottomRight{topLeft + size}; // background - path.colour( {0.5f, 0.5f, 0.5f} ); - draw_box( path, topLeft, bottomRight ); + path.colour({0.5f, 0.5f, 0.5f}); + draw_box(path, topLeft, bottomRight); // fill - math::vec2 innerTop { topLeft.x + 5, topLeft.y + 5 }; - math::vec2 innerBottom { bottomRight.x - 5, bottomRight.y - 5 }; + math::vec2 innerTop{topLeft.x + 5, topLeft.y + 5}; + math::vec2 innerBottom{bottomRight.x - 5, bottomRight.y - 5}; // figure out how wide the bar should be float barWidth = (innerBottom.x - innerTop.x) * value; @@ -65,55 +65,55 @@ namespace fggl::gui { innerBottom.x = innerTop.x + barWidth; // draw the bar - path.colour( {0.8f, 0.0f, 0.0f} ); - draw_box( path, innerTop, innerBottom ); + path.colour({0.8f, 0.0f, 0.0f}); + draw_box(path, innerTop, innerBottom); // part of the bar that's not filled in - math::vec2 emptyTop { innerBottom.x, innerTop.y }; - math::vec2 emptyBottom { trueBottom, innerBottom.y }; - path.colour( {0.4f, 0.0f, 0.0f} ); - draw_box( path, emptyTop, emptyBottom ); + math::vec2 emptyTop{innerBottom.x, innerTop.y}; + math::vec2 emptyBottom{trueBottom, innerBottom.y}; + path.colour({0.4f, 0.0f, 0.0f}); + draw_box(path, emptyTop, emptyBottom); } - void draw_slider( gfx::Path2D& path, glm::vec2 topLeft, glm::vec2 size, float value ) { - draw_progress( path, topLeft, size, value ); + void draw_slider(gfx::Path2D &path, glm::vec2 topLeft, glm::vec2 size, float value) { + draw_progress(path, topLeft, size, value); // dimensions - const auto bottomRight { topLeft + size }; - const math::vec2 innerTop { topLeft.x + 5, topLeft.y + 5 }; - const math::vec2 innerBottom { bottomRight.x - 5, bottomRight.y - 5 }; + const auto bottomRight{topLeft + size}; + const math::vec2 innerTop{topLeft.x + 5, topLeft.y + 5}; + const math::vec2 innerBottom{bottomRight.x - 5, bottomRight.y - 5}; // selector bar float trackWidth = innerBottom.x - innerTop.x; float selectorValue = trackWidth * value; float selectorWidth = 6; - math::vec2 selectorTop { innerTop.x + selectorValue - ( selectorWidth/2), topLeft.y }; - math::vec2 selectorBottom { selectorTop.x + selectorWidth, bottomRight.y }; - path.colour( {1.0f, 1.0f, 1.0f} ); - draw_box( path, selectorTop, selectorBottom ); + math::vec2 selectorTop{innerTop.x + selectorValue - (selectorWidth / 2), topLeft.y}; + math::vec2 selectorBottom{selectorTop.x + selectorWidth, bottomRight.y}; + path.colour({1.0f, 1.0f, 1.0f}); + draw_box(path, selectorTop, selectorBottom); } - void draw_button( gfx::Path2D& path, glm::vec2 pos, glm::vec2 size, bool active, bool pressed) { + void draw_button(gfx::Path2D &path, glm::vec2 pos, glm::vec2 size, bool active, bool pressed) { // locations - math::vec2 outerTop { pos }; - math::vec2 outerBottom { pos + size }; - math::vec2 innerTop { pos.x + 5, pos.y + 5 }; - math::vec2 innerBottom { pos.x + size.x - 5, pos.y + size.y - 5 }; + math::vec2 outerTop{pos}; + math::vec2 outerBottom{pos + size}; + math::vec2 innerTop{pos.x + 5, pos.y + 5}; + math::vec2 innerBottom{pos.x + size.x - 5, pos.y + size.y - 5}; - math::vec3 baseColour{ 0.5f, 0.5f, 0.5f }; + math::vec3 baseColour{0.5f, 0.5f, 0.5f}; - if ( active ) { + if (active) { baseColour *= 1.2f; } - if ( pressed ) { + if (pressed) { baseColour *= 0.8f; } - math::vec3 lightColour{ baseColour * 1.2f }; - math::vec3 darkColour{ baseColour * 0.8f }; - if ( pressed ) { + math::vec3 lightColour{baseColour * 1.2f}; + math::vec3 darkColour{baseColour * 0.8f}; + if (pressed) { // flip light and dark for selected buttons auto tmp = darkColour; darkColour = lightColour; @@ -121,39 +121,39 @@ namespace fggl::gui { } // bottom side - path.colour( lightColour ); - path.moveTo( outerTop ); - path.pathTo( innerTop ); - path.pathTo( { innerBottom.x, innerTop.y } ); - path.pathTo( { outerBottom.x, outerTop.y } ); - path.pathTo( outerTop ); + path.colour(lightColour); + path.moveTo(outerTop); + path.pathTo(innerTop); + path.pathTo({innerBottom.x, innerTop.y}); + path.pathTo({outerBottom.x, outerTop.y}); + path.pathTo(outerTop); // left side - path.colour( lightColour ); - path.moveTo( outerTop ); - path.pathTo( innerTop ); - path.pathTo( { innerTop.x, innerBottom.y } ); - path.pathTo( { outerTop.x, outerBottom.y } ); - path.pathTo( outerTop ); + path.colour(lightColour); + path.moveTo(outerTop); + path.pathTo(innerTop); + path.pathTo({innerTop.x, innerBottom.y}); + path.pathTo({outerTop.x, outerBottom.y}); + path.pathTo(outerTop); // top side - path.colour( darkColour ); - path.moveTo( { outerTop.x, outerBottom.y} ); - path.pathTo( { innerTop.x, innerBottom.y} ); - path.pathTo( innerBottom ); - path.pathTo( outerBottom ); - path.pathTo( { outerTop.x, outerBottom.y} ); + path.colour(darkColour); + path.moveTo({outerTop.x, outerBottom.y}); + path.pathTo({innerTop.x, innerBottom.y}); + path.pathTo(innerBottom); + path.pathTo(outerBottom); + path.pathTo({outerTop.x, outerBottom.y}); // right side - path.colour( darkColour ); - path.moveTo( outerBottom ); - path.pathTo( innerBottom ); - path.pathTo( { innerBottom.x, innerTop.y } ); - path.pathTo( { outerBottom.x, outerTop.y } ); - path.pathTo( outerBottom ); + path.colour(darkColour); + path.moveTo(outerBottom); + path.pathTo(innerBottom); + path.pathTo({innerBottom.x, innerTop.y}); + path.pathTo({outerBottom.x, outerTop.y}); + path.pathTo(outerBottom); // inner box - path.colour( baseColour ); - draw_box( path, innerTop, innerBottom ); + path.colour(baseColour); + draw_box(path, innerTop, innerBottom); } } \ No newline at end of file diff --git a/fggl/gui/widgets.cpp b/fggl/gui/widgets.cpp index f797c96694df5a251dfeb84dfbdb4ea184355576..12583aaa0b5247c4a8127ec1c03c4fce45661556 100644 --- a/fggl/gui/widgets.cpp +++ b/fggl/gui/widgets.cpp @@ -23,10 +23,11 @@ namespace fggl::gui { - Button::Button( math::vec2 pos, math::vec2 size) : Widget(pos, size), m_label(pos, size), m_hover(false), m_active(false) {} + Button::Button(math::vec2 pos, math::vec2 size) : Widget(pos, size), m_label(pos, size), m_hover(false), + m_active(false) {} void Button::render(gfx::Paint &paint) { - gfx::Path2D path{ topLeft() }; + gfx::Path2D path{topLeft()}; draw_button(path, topLeft(), size(), m_hover, m_active); paint.fill(path); @@ -35,8 +36,8 @@ namespace fggl::gui { void Button::activate() { m_active = !m_active; - if ( m_active ) { - for( auto& callback : m_callbacks ) { + if (m_active) { + for (auto &callback : m_callbacks) { callback(); m_active = false; } @@ -52,7 +53,7 @@ namespace fggl::gui { } void Button::addCallback(Callback cb) { - m_callbacks.push_back( cb ); + m_callbacks.push_back(cb); } void Button::label(const std::string &value) { @@ -64,12 +65,12 @@ namespace fggl::gui { } void Label::layout() { - if ( m_font == nullptr ) { + if (m_font == nullptr) { return; } math::vec2 size; - for (const auto& letter : m_value) { + for (const auto &letter : m_value) { auto metrics = m_font->metrics(letter); size.x += (metrics.advance << 6); size.y = std::max(size.y, metrics.size.y); diff --git a/fggl/input/camera_input.cpp b/fggl/input/camera_input.cpp index 6c6dbeefba5ac9ed8b4780487b995bc1c02953c5..3dd5e6d59b59cb251484364c41626980f8d354ea 100644 --- a/fggl/input/camera_input.cpp +++ b/fggl/input/camera_input.cpp @@ -23,156 +23,160 @@ namespace fggl::input { - void process_arcball(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { - // see https://asliceofrendering.com/camera/2019/11/30/ArcballCamera/ - auto& camTransform = ecs.get<fggl::math::Transform>(cam); - auto& camComp = ecs.get<fggl::gfx::Camera>(cam); - auto &mouse = input.mouse; - - glm::vec4 position(camTransform.origin(), 1.0f); - glm::vec4 pivot(camComp.target, 1.0f); - glm::mat4 view = glm::lookAt(camTransform.origin(), camComp.target, camTransform.up()); - glm::vec3 viewDir = -glm::transpose(view)[2]; - glm::vec3 rightDir = glm::transpose(view)[0]; - - float deltaAngleX = (2 * M_PI); - float deltaAngleY = (M_PI); - float xAngle = (-mouse.axisDelta(fggl::input::MouseAxis::X)) * deltaAngleX; - float yAngle = (-mouse.axisDelta(fggl::input::MouseAxis::Y)) * deltaAngleY; - - // rotate the camera around the pivot on the first axis - glm::mat4x4 rotationMatrixX(1.0f); - rotationMatrixX = glm::rotate(rotationMatrixX, xAngle, fggl::math::UP); - position = (rotationMatrixX * (position - pivot)) + pivot; - - // rotate the camera aroud the pivot on the second axis - glm::mat4x4 rotationMatrixY(1.0f); - rotationMatrixY = glm::rotate(rotationMatrixY, yAngle, rightDir); - glm::vec3 finalPos = (rotationMatrixY * (position - pivot)) + pivot; - - camTransform.origin(finalPos); - } - - void process_scroll(entity::EntityManager &ecs, const Input &input, entity::EntityID cam, float minZoom, float maxZoom){ - auto& camTransform = ecs.get<fggl::math::Transform>(cam); - auto& camComp = ecs.get<fggl::gfx::Camera>(cam); - - const glm::vec3 dir = ( camTransform.origin() - camComp.target ); - const glm::vec3 forward = glm::normalize( dir ); + void process_arcball(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { + // see https://asliceofrendering.com/camera/2019/11/30/ArcballCamera/ + auto &camTransform = ecs.get<fggl::math::Transform>(cam); + auto &camComp = ecs.get<fggl::gfx::Camera>(cam); + auto &mouse = input.mouse; + + glm::vec4 position(camTransform.origin(), 1.0f); + glm::vec4 pivot(camComp.target, 1.0f); + glm::mat4 view = glm::lookAt(camTransform.origin(), camComp.target, camTransform.up()); + glm::vec3 viewDir = -glm::transpose(view)[2]; + glm::vec3 rightDir = glm::transpose(view)[0]; + + float deltaAngleX = (2 * M_PI); + float deltaAngleY = (M_PI); + float xAngle = (-mouse.axisDelta(fggl::input::MouseAxis::X)) * deltaAngleX; + float yAngle = (-mouse.axisDelta(fggl::input::MouseAxis::Y)) * deltaAngleY; + + // rotate the camera around the pivot on the first axis + glm::mat4x4 rotationMatrixX(1.0f); + rotationMatrixX = glm::rotate(rotationMatrixX, xAngle, fggl::math::UP); + position = (rotationMatrixX * (position - pivot)) + pivot; + + // rotate the camera aroud the pivot on the second axis + glm::mat4x4 rotationMatrixY(1.0f); + rotationMatrixY = glm::rotate(rotationMatrixY, yAngle, rightDir); + glm::vec3 finalPos = (rotationMatrixY * (position - pivot)) + pivot; + + camTransform.origin(finalPos); + } + + void process_scroll(entity::EntityManager &ecs, + const Input &input, + entity::EntityID cam, + float minZoom, + float maxZoom) { + auto &camTransform = ecs.get<fggl::math::Transform>(cam); + auto &camComp = ecs.get<fggl::gfx::Camera>(cam); + + const glm::vec3 dir = (camTransform.origin() - camComp.target); + const glm::vec3 forward = glm::normalize(dir); glm::vec3 motion(0.0F); - float delta = input.mouse.axis( fggl::input::MouseAxis::SCROLL_Y ); - if ( (glm::length( dir ) < maxZoom && delta < 0.0f) || (glm::length( dir ) > minZoom && delta > 0.0f) ) { + float delta = input.mouse.axis(fggl::input::MouseAxis::SCROLL_Y); + if ((glm::length(dir) < maxZoom && delta < 0.0f) || (glm::length(dir) > minZoom && delta > 0.0f)) { motion -= (forward * delta); camTransform.origin(camTransform.origin() + motion); } } - void process_freecam(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { - float rotationValue = 0.0f; - glm::vec3 translation(0.0f); + void process_freecam(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { + float rotationValue = 0.0f; + glm::vec3 translation(0.0f); + + auto &keyboard = input.keyboard; + auto &settings = ecs.get<FreeCamKeys>(cam); + + // calculate rotation (user input) + if (keyboard.down(settings.rotate_cw)) { + rotationValue = ROT_SPEED; + } else if (keyboard.down(settings.rotate_ccw)) { + rotationValue = -ROT_SPEED; + } - auto &keyboard = input.keyboard; - auto& settings = ecs.get<FreeCamKeys>(cam); - - // calculate rotation (user input) - if (keyboard.down(settings.rotate_cw)) { - rotationValue = ROT_SPEED; - } else if (keyboard.down(settings.rotate_ccw)) { - rotationValue = -ROT_SPEED; - } - - // calculate movement (user input) - if (keyboard.down(settings.forward)) { - translation -= fggl::math::RIGHT; - } - - if (keyboard.down(settings.backward)) { - translation += fggl::math::RIGHT; - } - - if (keyboard.down(settings.right)) { - translation += fggl::math::FORWARD; - } - - if (keyboard.down(settings.left)) { - translation -= fggl::math::FORWARD; - } - - // apply rotation/movement - auto camTransform = ecs.get<fggl::math::Transform>(cam); - auto camComp = ecs.get<fggl::gfx::Camera>(cam); - - glm::vec4 position(camTransform.origin(), 1.0f); - glm::vec4 pivot(camComp.target, 1.0f); - - // apply movement - if (translation != glm::vec3(0.0f)) { - const auto rotation = (position - pivot); - const float angle = atan2f(rotation.x, rotation.z); - const auto rotationMat = glm::rotate(MAT_IDENTITY, angle, fggl::math::UP); - - auto deltaMove = (rotationMat * glm::vec4(translation, 1.0f)) * PAN_SPEED; - deltaMove.w = 0.0f; - - position += deltaMove; - pivot += deltaMove; - } - - // apply rotation - if (rotationValue != 0.0f) { - glm::mat4 rotation = glm::rotate(MAT_IDENTITY, rotationValue, fggl::math::UP); - position = (rotation * (position - pivot)) + pivot; - } - - camTransform.origin(position); - camComp.target = pivot; - } - - void process_edgescroll(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { - glm::vec3 translation(0.0f); - - auto &mouse = input.mouse; - - // calculate movement (user input) - if (mouse.axis(MouseAxis::Y) < 0.9f) { - translation -= fggl::math::RIGHT; - } - - if (mouse.axis(MouseAxis::Y) > -0.9f) { - translation += fggl::math::RIGHT; - } - - if (mouse.axis(MouseAxis::X) > -0.9f) { - translation += fggl::math::FORWARD; - } - - if (mouse.axis(MouseAxis::X) < 0.9f) { - translation -= fggl::math::FORWARD; - } - - // apply rotation/movement - auto& camTransform = ecs.get<fggl::math::Transform>(cam); - auto& camComp = ecs.get<fggl::gfx::Camera>(cam); - - glm::vec4 position(camTransform.origin(), 1.0f); - glm::vec4 pivot(camComp.target, 1.0f); - - // apply movement - if (translation != glm::vec3(0.0f)) { - const auto rotation = (position - pivot); - const float angle = atan2f(rotation.x, rotation.z); - const auto rotationMat = glm::rotate(MAT_IDENTITY, angle, fggl::math::UP); - - auto deltaMove = (rotationMat * glm::vec4(translation, 1.0f)) * PAN_SPEED; - deltaMove.w = 0.0f; - - position += deltaMove; - pivot += deltaMove; - } - - // move camera - camTransform.origin(position); - camComp.target = pivot; - } + // calculate movement (user input) + if (keyboard.down(settings.forward)) { + translation -= fggl::math::RIGHT; + } + + if (keyboard.down(settings.backward)) { + translation += fggl::math::RIGHT; + } + + if (keyboard.down(settings.right)) { + translation += fggl::math::FORWARD; + } + + if (keyboard.down(settings.left)) { + translation -= fggl::math::FORWARD; + } + + // apply rotation/movement + auto camTransform = ecs.get<fggl::math::Transform>(cam); + auto camComp = ecs.get<fggl::gfx::Camera>(cam); + + glm::vec4 position(camTransform.origin(), 1.0f); + glm::vec4 pivot(camComp.target, 1.0f); + + // apply movement + if (translation != glm::vec3(0.0f)) { + const auto rotation = (position - pivot); + const float angle = atan2f(rotation.x, rotation.z); + const auto rotationMat = glm::rotate(MAT_IDENTITY, angle, fggl::math::UP); + + auto deltaMove = (rotationMat * glm::vec4(translation, 1.0f)) * PAN_SPEED; + deltaMove.w = 0.0f; + + position += deltaMove; + pivot += deltaMove; + } + + // apply rotation + if (rotationValue != 0.0f) { + glm::mat4 rotation = glm::rotate(MAT_IDENTITY, rotationValue, fggl::math::UP); + position = (rotation * (position - pivot)) + pivot; + } + + camTransform.origin(position); + camComp.target = pivot; + } + + void process_edgescroll(entity::EntityManager &ecs, const Input &input, entity::EntityID cam) { + glm::vec3 translation(0.0f); + + auto &mouse = input.mouse; + + // calculate movement (user input) + if (mouse.axis(MouseAxis::Y) < 0.9f) { + translation -= fggl::math::RIGHT; + } + + if (mouse.axis(MouseAxis::Y) > -0.9f) { + translation += fggl::math::RIGHT; + } + + if (mouse.axis(MouseAxis::X) > -0.9f) { + translation += fggl::math::FORWARD; + } + + if (mouse.axis(MouseAxis::X) < 0.9f) { + translation -= fggl::math::FORWARD; + } + + // apply rotation/movement + auto &camTransform = ecs.get<fggl::math::Transform>(cam); + auto &camComp = ecs.get<fggl::gfx::Camera>(cam); + + glm::vec4 position(camTransform.origin(), 1.0f); + glm::vec4 pivot(camComp.target, 1.0f); + + // apply movement + if (translation != glm::vec3(0.0f)) { + const auto rotation = (position - pivot); + const float angle = atan2f(rotation.x, rotation.z); + const auto rotationMat = glm::rotate(MAT_IDENTITY, angle, fggl::math::UP); + + auto deltaMove = (rotationMat * glm::vec4(translation, 1.0f)) * PAN_SPEED; + deltaMove.w = 0.0f; + + position += deltaMove; + pivot += deltaMove; + } + + // move camera + camTransform.origin(position); + camComp.target = pivot; + } } diff --git a/fggl/input/mouse.cpp b/fggl/input/mouse.cpp index ad357f47ba039817d33bd0cf07e97500df3f4eec..e936000116663af495606a983608401889de3068 100644 --- a/fggl/input/mouse.cpp +++ b/fggl/input/mouse.cpp @@ -16,12 +16,11 @@ namespace fggl::input { - void MouseState::operator=(const MouseState& rhs) { - for ( int i=0; i<4; i++ ) { - axis[i] = rhs.axis[i]; - } - buttons = rhs.buttons; - } - + void MouseState::operator=(const MouseState &rhs) { + for (int i = 0; i < 4; i++) { + axis[i] = rhs.axis[i]; + } + buttons = rhs.buttons; + } } // namespace fggl::input diff --git a/fggl/math/CMakeLists.txt b/fggl/math/CMakeLists.txt index a3d1d3929d1cc4f5967fb631746e60838f9f4c58..965f8cde632713908ed36c05ad2c53ccf707798e 100644 --- a/fggl/math/CMakeLists.txt +++ b/fggl/math/CMakeLists.txt @@ -1,9 +1,9 @@ # math -find_package( glm CONFIG REQUIRED ) -target_link_libraries( fggl PUBLIC glm::glm ) +find_package(glm CONFIG REQUIRED) +target_link_libraries(fggl PUBLIC glm::glm) target_sources(fggl PRIVATE - shapes.cpp - triangulation.cpp -) + shapes.cpp + triangulation.cpp + ) diff --git a/fggl/math/shapes.cpp b/fggl/math/shapes.cpp index f1c9311e530e5507999d442e03578411516d43aa..5188927d5cd50342638038c183bd9b4970b084e9 100644 --- a/fggl/math/shapes.cpp +++ b/fggl/math/shapes.cpp @@ -19,21 +19,27 @@ namespace fggl::math::phs3d { void AABB::emtpy() { min = {FLT_MAX, FLT_MAX, FLT_MAX}; - max = { - FLT_MAX, - FLT_MAX, -FLT_MAX}; + max = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; } void AABB::add(const math::vec3 &p) { - if ( p.x < min.x ) min.x = p.x; - if ( p.x > max.x ) max.x = p.x; - if ( p.y < min.y ) min.y = p.y; - if ( p.y > min.y ) max.y = p.y; - if ( p.z < min.z ) min.z = p.z; - if ( p.z > max.z ) max.z = p.z; + if (p.x < min.x) + min.x = p.x; + if (p.x > max.x) + max.x = p.x; + if (p.y < min.y) + min.y = p.y; + if (p.y > min.y) + max.y = p.y; + if (p.z < min.z) + min.z = p.z; + if (p.z > max.z) + max.z = p.z; } AABB AABB::fromPoints(const std::vector<math::vec3> &points) { AABB box; - for (const auto& point : points) { + for (const auto &point : points) { box.add(point); } return box; @@ -44,9 +50,9 @@ namespace fggl::math::phs3d { min = max = m[3]; // should be the translation component of the matrix // this feels like something that should be vectorizable... - for ( int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - if ( m[i][j] > 0.0f ) { + if (m[i][j] > 0.0f) { min[j] += m[i][j] * other.min[j]; max[j] += m[i][j] * other.max[j]; } else { @@ -65,13 +71,13 @@ namespace fggl::math::phs3d { return {normal, d}; } - static math::vec3 bestFitNormal(const std::vector<math::vec3>& points) { + static math::vec3 bestFitNormal(const std::vector<math::vec3> &points) { assert(!points.empty()); math::vec3 result; math::vec3 p = points.back(); - for ( std::size_t i = 0; i < points.size(); ++i ){ + for (std::size_t i = 0; i < points.size(); ++i) { math::vec3 c = points[i]; result.x += (p.z + c.z) * (p.y - c.y); @@ -84,13 +90,13 @@ namespace fggl::math::phs3d { return glm::normalize(result); }; - static float bestFitD(const std::vector<math::vec3>& points, glm::vec3 normal) { + static float bestFitD(const std::vector<math::vec3> &points, glm::vec3 normal) { math::vec3 sum; - for (auto& point : points) { + for (auto &point : points) { sum += point; } - sum *= 1.0F/points.size(); - return glm::dot( sum, normal ); + sum *= 1.0F / points.size(); + return glm::dot(sum, normal); } const char X = 0; @@ -102,11 +108,11 @@ namespace fggl::math::phs3d { const char b; }; - static bary_axis baryCalcAxis(const math::vec3& normal) { - if ( (fabs(normal.x) >= fabs(normal.y)) && (fabs(normal.x) >= fabs(normal.z))) { + static bary_axis baryCalcAxis(const math::vec3 &normal) { + if ((fabs(normal.x) >= fabs(normal.y)) && (fabs(normal.x) >= fabs(normal.z))) { // discard x return {Y, Z}; - } else if ( fabs(normal.y) >= fabs(normal.z) ) { + } else if (fabs(normal.y) >= fabs(normal.z)) { // discard y return {Z, X}; } else { @@ -115,7 +121,7 @@ namespace fggl::math::phs3d { } } - bool Triangle::CartToBarycentric(const math::vec3& cart, Barycentric& outVal) { + bool Triangle::CartToBarycentric(const math::vec3 &cart, Barycentric &outVal) { // everything is const because I'm paying the compiler is smarter than me... const auto d1 = v[1] - v[0]; @@ -137,20 +143,20 @@ namespace fggl::math::phs3d { const float v3 = cart[ax.b] - v[0][ax.b]; const float v4 = cart[ax.b] - v[2][ax.b]; - const float denom = v1*u2 - v2*u1; - if ( denom == 0.0f) { + const float denom = v1 * u2 - v2 * u1; + if (denom == 0.0f) { return false; } // finally, we can work it out const float oneOverDenom = 1.0f / denom; - outVal.b[0] = (v4*u2 - v2*u4) * oneOverDenom; - outVal.b[1] = (v1*u3 - v3*u1) * oneOverDenom; + outVal.b[0] = (v4 * u2 - v2 * u4) * oneOverDenom; + outVal.b[1] = (v1 * u3 - v3 * u1) * oneOverDenom; outVal.b[2] = 1.0f - outVal.b[0] - outVal.b[1]; return true; } - bool Triangle::CartToBarycentric2(const math::vec3& cart, Barycentric& outVal) { + bool Triangle::CartToBarycentric2(const math::vec3 &cart, Barycentric &outVal) { const auto e1 = v[2] - v[1]; const auto e2 = v[0] - v[2]; const auto e3 = v[1] - v[0]; @@ -161,7 +167,7 @@ namespace fggl::math::phs3d { const auto normal = glm::normalize(glm::cross(e1, e2)); const auto denom = glm::dot(glm::cross(e1, e2), normal); - assert( denom != 0.0f); + assert(denom != 0.0f); outVal.b[0] = glm::dot(glm::cross(e1, d3), normal) / denom; outVal.b[1] = glm::dot(glm::cross(e2, d1), normal) / denom; diff --git a/fggl/math/triangulation.cpp b/fggl/math/triangulation.cpp index efabc2dea37cbbc976243d687c5b92db477a080b..8f620a561c4be1abaa08099608df8249bff839ef 100644 --- a/fggl/math/triangulation.cpp +++ b/fggl/math/triangulation.cpp @@ -20,7 +20,7 @@ namespace fggl::math { /** * Fast Triangulation for convex polygons. */ - void fan_triangulation(const PolygonVertex& polygon, data::Mesh2D &mesh) { + void fan_triangulation(const PolygonVertex &polygon, data::Mesh2D &mesh) { assert(polygon.size() >= 3); // add the first two points to the mesh diff --git a/fggl/phys/CMakeLists.txt b/fggl/phys/CMakeLists.txt index 8589e54d16e0ba15739da7c87a92a02f9f521cca..535c60d41243de6b093a94f7faca5f86ca702db4 100644 --- a/fggl/phys/CMakeLists.txt +++ b/fggl/phys/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources(fggl PRIVATE - null.cpp -) \ No newline at end of file + null.cpp + ) \ No newline at end of file diff --git a/fggl/platform/CMakeLists.txt b/fggl/platform/CMakeLists.txt index 87c143a7c3dfb30e03826a497a4276c2f83a4c6f..49b67c8124dd033349221c681921558525410702 100644 --- a/fggl/platform/CMakeLists.txt +++ b/fggl/platform/CMakeLists.txt @@ -1,5 +1,5 @@ -if ( CMAKE_SYSTEM_NAME MATCHES "Linux" ) +if (CMAKE_SYSTEM_NAME MATCHES "Linux") add_subdirectory(linux) -else() +else () add_subdirectory(fallback) -endif() \ No newline at end of file +endif () \ No newline at end of file diff --git a/fggl/platform/fallback/paths.cpp b/fggl/platform/fallback/paths.cpp index 8dca3fc6ffcc2d0539b6f2e786f2bc2b943d3a28..1bc8de9316bd2a801e3bba2160fe9be68a88b3f7 100644 --- a/fggl/platform/fallback/paths.cpp +++ b/fggl/platform/fallback/paths.cpp @@ -22,16 +22,16 @@ namespace fggl::platform { - inline static std::filesystem::path get_user_path(const char* env, const char* fallback) { - const char* path = std::getenv(env); + inline static std::filesystem::path get_user_path(const char *env, const char *fallback) { + const char *path = std::getenv(env); if (path != nullptr) { return {path}; } return std::filesystem::current_path() / fallback; } - EnginePaths calc_engine_paths(const char* base) { - return EnginePaths { + EnginePaths calc_engine_paths(const char *base) { + return EnginePaths{ get_user_path(ENV_USER_CONFIG, DEFAULT_USER_CONFIG) / base, get_user_path(ENV_USER_DATA, DEFAULT_USER_DATA) / base, std::filesystem::temp_directory_path() / base @@ -40,13 +40,13 @@ namespace fggl::platform { std::filesystem::path locate_data(const EnginePaths &paths, const std::filesystem::path &relPath) { auto userPath = paths.userData / relPath; - if ( std::filesystem::exists(userPath) ) { + if (std::filesystem::exists(userPath)) { return userPath; } // if debug mode, try CWD as well. auto debugPath = std::filesystem::current_path() / "data" / relPath; - if ( std::filesystem::exists(debugPath) ) { + if (std::filesystem::exists(debugPath)) { return debugPath; } diff --git a/fggl/platform/linux/CMakeLists.txt b/fggl/platform/linux/CMakeLists.txt index cc1d2b0028bcfad87c3400caa484a1d99d791f29..a177d99b15013ab1b85c4da967f297438a7ba867 100644 --- a/fggl/platform/linux/CMakeLists.txt +++ b/fggl/platform/linux/CMakeLists.txt @@ -1,8 +1,8 @@ #find_package(Fontconfig) #target_link_libraries(fggl PRIVATE Fontconfig::Fontconfig) -target_sources( fggl - PRIVATE - # fonts.cpp +target_sources(fggl + PRIVATE + # fonts.cpp paths.cpp -) \ No newline at end of file + ) \ No newline at end of file diff --git a/fggl/platform/linux/fonts.cpp b/fggl/platform/linux/fonts.cpp index 49db2f848ffb4c3abaffd86a995cbffe395e6a19..1362cf58e6353c2bee5d8084358d0e49701846cb 100644 --- a/fggl/platform/linux/fonts.cpp +++ b/fggl/platform/linux/fonts.cpp @@ -21,14 +21,14 @@ namespace fggl::platform::Linux { void get_font() { - /* FcConfig *config = FcInitLoadConfigAndFonts(); - FcPattern* pat = FcPatternCreate(); - FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT, FC_PIXEL_SIZE, FC_SIZE, nullptr); - FcFontSet* fs = FcFontList(config, pat, os); + /* FcConfig *config = FcInitLoadConfigAndFonts(); + FcPattern* pat = FcPatternCreate(); + FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT, FC_PIXEL_SIZE, FC_SIZE, nullptr); + FcFontSet* fs = FcFontList(config, pat, os); - if ( fs ) { - FcFontSetDestroy(fs); - }*/ + if ( fs ) { + FcFontSetDestroy(fs); + }*/ } } // namespace fggl::platform::linux \ No newline at end of file diff --git a/fggl/platform/linux/paths.cpp b/fggl/platform/linux/paths.cpp index b1aba8cde2cd0ac6f744e026d5ffbf571a5cf2a9..a414ff1b6d7ad718e2b23784b648c547915913de 100644 --- a/fggl/platform/linux/paths.cpp +++ b/fggl/platform/linux/paths.cpp @@ -23,16 +23,16 @@ namespace fggl::platform { - inline static std::filesystem::path get_user_path(const char* env, const char* fallback) { - const char* path = std::getenv(env); + inline static std::filesystem::path get_user_path(const char *env, const char *fallback) { + const char *path = std::getenv(env); if (path != nullptr) { return {path}; } return {fallback}; } - static std::vector<std::filesystem::path> get_path_list(const char* env, const char* folderName) { - const char* pathList = std::getenv(env); + static std::vector<std::filesystem::path> get_path_list(const char *env, const char *folderName) { + const char *pathList = std::getenv(env); std::vector<std::filesystem::path> paths; if (pathList) { std::string pathListStr(pathList); @@ -50,22 +50,22 @@ namespace fggl::platform { return paths; } - EnginePaths calc_engine_paths(const char* base) { + EnginePaths calc_engine_paths(const char *base) { auto dataDirs = get_path_list(ENV_DATA_DIRS, base); - if ( dataDirs.empty() ) { - for ( const auto& defaultDir : DEFAULT_DATA_DIRS ) { - dataDirs.push_back(std::filesystem::path(defaultDir) / base ); + if (dataDirs.empty()) { + for (const auto &defaultDir : DEFAULT_DATA_DIRS) { + dataDirs.push_back(std::filesystem::path(defaultDir) / base); } } auto configDirs = get_path_list(ENV_CONFIG_DIRS, base); - if ( configDirs.empty() ) { - for ( const auto& defaultDir : DEFAULT_CONFIG_DIRS ) { - configDirs.push_back(std::filesystem::path(defaultDir) / base ); + if (configDirs.empty()) { + for (const auto &defaultDir : DEFAULT_CONFIG_DIRS) { + configDirs.push_back(std::filesystem::path(defaultDir) / base); } } - return EnginePaths { + return EnginePaths{ get_user_path(ENV_USER_CONFIG, DEFAULT_USER_CONFIG) / base, get_user_path(ENV_USER_DATA, DEFAULT_USER_DATA) / base, get_user_path(ENV_USER_CACHE, DEFAULT_USER_CACHE) / base, @@ -76,22 +76,22 @@ namespace fggl::platform { std::filesystem::path locate_data(const EnginePaths &paths, const std::filesystem::path &relPath) { auto userPath = paths.userData / relPath; - if ( std::filesystem::exists(userPath) ) { + if (std::filesystem::exists(userPath)) { return userPath; } // check system paths - for ( const auto& path : paths.dataDirs ) { + for (const auto &path : paths.dataDirs) { auto fullPath = path / relPath; debug::trace("Checking data path: {}, exists: {}", fullPath.c_str(), std::filesystem::exists(fullPath)); - if ( std::filesystem::exists(fullPath) ) { + if (std::filesystem::exists(fullPath)) { return fullPath; } } // if debug mode, try CWD as well. auto debugPath = std::filesystem::current_path() / "data" / relPath; - if ( std::filesystem::exists(debugPath) ) { + if (std::filesystem::exists(debugPath)) { debug::trace("Checking debug path: {}, exists: {}", debugPath.c_str(), std::filesystem::exists(debugPath)); return debugPath; } @@ -102,14 +102,14 @@ namespace fggl::platform { std::filesystem::path locate_config(const EnginePaths &paths, const std::filesystem::path &relPath) { auto userPath = paths.userConfig / relPath; - if ( std::filesystem::exists(userPath) ) { + if (std::filesystem::exists(userPath)) { return userPath; } // check system paths - for ( const auto& path : paths.configDirs ) { + for (const auto &path : paths.configDirs) { auto fullPath = path / relPath; - if ( std::filesystem::exists(fullPath) ) { + if (std::filesystem::exists(fullPath)) { return fullPath; } } @@ -120,14 +120,14 @@ namespace fggl::platform { std::filesystem::path locate_cache(const EnginePaths &paths, const std::filesystem::path &relPath) { auto userPath = paths.userCache / relPath; - if ( std::filesystem::exists(userPath) ) { + if (std::filesystem::exists(userPath)) { return userPath; } // check system paths - for ( const auto& path : paths.configDirs ) { + for (const auto &path : paths.configDirs) { auto fullPath = path / relPath; - if ( std::filesystem::exists(fullPath) ) { + if (std::filesystem::exists(fullPath)) { return fullPath; } } diff --git a/fggl/scenes/game.cpp b/fggl/scenes/game.cpp index 5774f23a19d4bfd2e8d18f5ad89e8953cda28c11..c5542433fe9cf8b670c52adf376ce83a1d833bf8 100644 --- a/fggl/scenes/game.cpp +++ b/fggl/scenes/game.cpp @@ -35,8 +35,8 @@ namespace fggl::scenes { m_world = std::make_unique<entity::EntityManager>(); #ifdef FGGL_MODULE_BULLET - // FIXME this ties bullet to the game state - which shouldn't be the case - m_phys = std::make_unique<fggl::phys::bullet::BulletPhysicsEngine>(m_world.get()); + // FIXME this ties bullet to the game state - which shouldn't be the case + m_phys = std::make_unique<fggl::phys::bullet::BulletPhysicsEngine>(m_world.get()); #endif } @@ -46,16 +46,16 @@ namespace fggl::scenes { } void Game::update() { - assert( m_world && "called game update, but there was no world - was activate called?" ); + assert(m_world && "called game update, but there was no world - was activate called?"); - if ( m_input != nullptr ) { + if (m_input != nullptr) { bool escapePressed = m_input->keyboard.pressed(glfwGetKeyScancode(GLFW_KEY_ESCAPE)); if (escapePressed) { m_owner.change_state(m_previous); } } - if ( m_phys != nullptr ) { + if (m_phys != nullptr) { m_phys->step(); } @@ -63,8 +63,8 @@ namespace fggl::scenes { } void Game::render(fggl::gfx::Graphics &gfx) { - if ( m_world != nullptr ) { - gfx.drawScene( *m_world ); + if (m_world != nullptr) { + gfx.drawScene(*m_world); } } diff --git a/fggl/scenes/menu.cpp b/fggl/scenes/menu.cpp index 9b6dec85d05bd7a90072b3bd9699f479152e68c5..de6dfc0d6cc8ea1178d194853d9135c4ee457ee6 100644 --- a/fggl/scenes/menu.cpp +++ b/fggl/scenes/menu.cpp @@ -19,19 +19,17 @@ namespace fggl::scenes { - using fggl::input::MouseButton; - using fggl::input::MouseAxis; + using fggl::input::MouseButton; + using fggl::input::MouseAxis; + BasicMenu::BasicMenu(fggl::App &app) : AppState(app), m_inputs(nullptr), m_active(), m_hover(nullptr) { + m_inputs = app.service<input::Input>(); + } - - BasicMenu::BasicMenu(fggl::App& app) : AppState(app), m_inputs(nullptr), m_active(), m_hover(nullptr) { - m_inputs = app.service<input::Input>(); - } - - void BasicMenu::update() { - if ( m_inputs != nullptr ) { - m_cursorPos.x = m_inputs->mouse.axis( MouseAxis::X ); - m_cursorPos.y = m_inputs->mouse.axis( MouseAxis::Y ); + void BasicMenu::update() { + if (m_inputs != nullptr) { + m_cursorPos.x = m_inputs->mouse.axis(MouseAxis::X); + m_cursorPos.y = m_inputs->mouse.axis(MouseAxis::Y); // in canvas space math::vec2 projected; @@ -39,18 +37,18 @@ namespace fggl::scenes { //projected.y = math::rescale_ndc(m_cursorPos.y, 1080.0f, 0); projected.y = math::rescale_ndc(m_cursorPos.y, 0, 1080.0f); - auto* hoverWidget = m_canvas.getChildAt(projected); - if ( hoverWidget != m_hover ){ - if ( m_hover != nullptr ) { + auto *hoverWidget = m_canvas.getChildAt(projected); + if (hoverWidget != m_hover) { + if (m_hover != nullptr) { m_hover->onExit(); } m_hover = hoverWidget; - if ( m_hover != nullptr ){ + if (m_hover != nullptr) { m_hover->onEnter(); } } - if ( m_inputs->mouse.pressed( MouseButton::LEFT ) ) { + if (m_inputs->mouse.pressed(MouseButton::LEFT)) { spdlog::info("clicky clicky: ({}, {})", projected.x, projected.y); auto widget = m_canvas.getChildAt(projected); @@ -58,36 +56,36 @@ namespace fggl::scenes { widget->activate(); spdlog::info("ooo! there is a thing there!"); } - } - } - } + } + } + } - void BasicMenu::render(gfx::Graphics& gfx) { + void BasicMenu::render(gfx::Graphics &gfx) { // render the 2D scene (we don't have a 3D scene to worry about in menus) gfx::Paint paint; - m_canvas.render( paint ); + m_canvas.render(paint); gfx.draw2D(paint); - } + } - void BasicMenu::activate() { + void BasicMenu::activate() { - } + } - void BasicMenu::deactivate() { + void BasicMenu::deactivate() { - } + } - void BasicMenu::add(const std::string& name, callback cb) { - m_items[name] = cb; + void BasicMenu::add(const std::string &name, callback cb) { + m_items[name] = cb; - const math::vec2 btnSize{ 150.0f, 30.0f }; + const math::vec2 btnSize{150.0f, 30.0f}; const float spacing = 5; const float padX = 50.0f; const float padY = 50.0f; // figure out the position based off the old logic // FIXME should be the container's job - math::vec2 pos { 1920.0f - ( padX + btnSize.x ), padY }; + math::vec2 pos{1920.0f - (padX + btnSize.x), padY}; auto btnIdx = m_items.size() - 1; pos.y += (btnIdx * (btnSize.y + spacing)); @@ -97,6 +95,6 @@ namespace fggl::scenes { btn->addCallback(cb); m_canvas.add(std::move(btn)); - } + } }; diff --git a/fggl/stb/stb_connected_components.h b/fggl/stb/stb_connected_components.h index f762f655d32e92755455ee1b958bfb21d121961d..da541decf35f539210478d80f3329de41954db97 100644 --- a/fggl/stb/stb_connected_components.h +++ b/fggl/stb/stb_connected_components.h @@ -146,7 +146,7 @@ extern unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y); #include <string.h> // memset #if !defined(STBCC_GRID_COUNT_X_LOG2) || !defined(STBCC_GRID_COUNT_Y_LOG2) - #error "You must define STBCC_GRID_COUNT_X_LOG2 and STBCC_GRID_COUNT_Y_LOG2 to define the max grid supported." + #error "You must define STBCC_GRID_COUNT_X_LOG2 and STBCC_GRID_COUNT_Y_LOG2 to define the max grid supported." #endif #define STBCC__GRID_COUNT_X (1 << STBCC_GRID_COUNT_X_LOG2) @@ -155,19 +155,19 @@ extern unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y); #define STBCC__MAP_STRIDE (1 << (STBCC_GRID_COUNT_X_LOG2-3)) #ifndef STBCC_CLUSTER_SIZE_X_LOG2 - #define STBCC_CLUSTER_SIZE_X_LOG2 (STBCC_GRID_COUNT_X_LOG2/2) // log2(sqrt(2^N)) = 1/2 * log2(2^N)) = 1/2 * N - #if STBCC_CLUSTER_SIZE_X_LOG2 > 6 - #undef STBCC_CLUSTER_SIZE_X_LOG2 - #define STBCC_CLUSTER_SIZE_X_LOG2 6 - #endif + #define STBCC_CLUSTER_SIZE_X_LOG2 (STBCC_GRID_COUNT_X_LOG2/2) // log2(sqrt(2^N)) = 1/2 * log2(2^N)) = 1/2 * N + #if STBCC_CLUSTER_SIZE_X_LOG2 > 6 + #undef STBCC_CLUSTER_SIZE_X_LOG2 + #define STBCC_CLUSTER_SIZE_X_LOG2 6 + #endif #endif #ifndef STBCC_CLUSTER_SIZE_Y_LOG2 - #define STBCC_CLUSTER_SIZE_Y_LOG2 (STBCC_GRID_COUNT_Y_LOG2/2) - #if STBCC_CLUSTER_SIZE_Y_LOG2 > 6 - #undef STBCC_CLUSTER_SIZE_Y_LOG2 - #define STBCC_CLUSTER_SIZE_Y_LOG2 6 - #endif + #define STBCC_CLUSTER_SIZE_Y_LOG2 (STBCC_GRID_COUNT_Y_LOG2/2) + #if STBCC_CLUSTER_SIZE_Y_LOG2 > 6 + #undef STBCC_CLUSTER_SIZE_Y_LOG2 + #define STBCC_CLUSTER_SIZE_Y_LOG2 6 + #endif #endif #define STBCC__CLUSTER_SIZE_X (1 << STBCC_CLUSTER_SIZE_X_LOG2) @@ -180,7 +180,7 @@ extern unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y); #define STBCC__CLUSTER_COUNT_Y (1 << STBCC__CLUSTER_COUNT_Y_LOG2) #if STBCC__CLUSTER_SIZE_X >= STBCC__GRID_COUNT_X || STBCC__CLUSTER_SIZE_Y >= STBCC__GRID_COUNT_Y - #error "STBCC_CLUSTER_SIZE_X/Y_LOG2 must be smaller than STBCC_GRID_COUNT_X/Y_LOG2" + #error "STBCC_CLUSTER_SIZE_X/Y_LOG2 must be smaller than STBCC_GRID_COUNT_X/Y_LOG2" #endif // worst case # of clumps per cluster @@ -222,16 +222,16 @@ typedef unsigned char stbcc__verify_max_exits[STBCC__MAX_EXITS_PER_CLUMP <= 256] typedef struct { unsigned short clump_index:12; - signed short cluster_dx:2; - signed short cluster_dy:2; + signed short cluster_dx:2; + signed short cluster_dy:2; } stbcc__relative_clumpid; typedef union { struct { - unsigned int clump_index:12; - unsigned int cluster_x:10; - unsigned int cluster_y:10; + unsigned int clump_index:12; + unsigned int cluster_x:10; + unsigned int cluster_y:10; } f; unsigned int c; } stbcc__global_clumpid; @@ -280,11 +280,11 @@ int stbcc_query_grid_node_connection(stbcc_grid *g, int x1, int y1, int x2, int int cy2 = STBCC__CLUSTER_Y_FOR_COORD_Y(y2); assert(!g->in_batched_update); if (c1 == STBCC__NULL_CLUMPID || c2 == STBCC__NULL_CLUMPID) - return 0; + return 0; label1 = g->cluster[cy1][cx1].clump[c1].global_label; label2 = g->cluster[cy2][cx2].clump[c2].global_label; if (label1.c == label2.c) - return 1; + return 1; return 0; } @@ -324,7 +324,7 @@ static stbcc__global_clumpid stbcc__clump_find(stbcc_grid *g, stbcc__global_clum stbcc__clump *c = &g->cluster[n.f.cluster_y][n.f.cluster_x].clump[n.f.clump_index]; if (c->global_label.c == n.c) - return n; + return n; q = stbcc__clump_find(g, c->global_label); c->global_label = q; @@ -346,7 +346,7 @@ static void stbcc__clump_union(stbcc_grid *g, stbcc__unpacked_clumpid m, int x, stbcc__global_clumpid np = stbcc__clump_find(g, nc->global_label); if (mp.c == np.c) - return; + return; g->cluster[mp.f.cluster_y][mp.f.cluster_x].clump[mp.f.clump_index].global_label = np; } @@ -356,51 +356,51 @@ static void stbcc__build_connected_components_for_clumps(stbcc_grid *g) int i,j,k,h; for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { - for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { - stbcc__cluster *cluster = &g->cluster[j][i]; - for (k=0; k < (int) cluster->num_edge_clumps; ++k) { - stbcc__global_clumpid m; - m.f.clump_index = k; - m.f.cluster_x = i; - m.f.cluster_y = j; - assert((int) m.f.clump_index == k && (int) m.f.cluster_x == i && (int) m.f.cluster_y == j); - cluster->clump[k].global_label = m; - } - } + for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { + stbcc__cluster *cluster = &g->cluster[j][i]; + for (k=0; k < (int) cluster->num_edge_clumps; ++k) { + stbcc__global_clumpid m; + m.f.clump_index = k; + m.f.cluster_x = i; + m.f.cluster_y = j; + assert((int) m.f.clump_index == k && (int) m.f.cluster_x == i && (int) m.f.cluster_y == j); + cluster->clump[k].global_label = m; + } + } } for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { - for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { - stbcc__cluster *cluster = &g->cluster[j][i]; - for (k=0; k < (int) cluster->num_edge_clumps; ++k) { - stbcc__clump *clump = &cluster->clump[k]; - stbcc__unpacked_clumpid m; - stbcc__relative_clumpid *adj; - m.clump_index = k; - m.cluster_x = i; - m.cluster_y = j; - adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; - for (h=0; h < clump->num_adjacent; ++h) { - unsigned int clump_index = adj[h].clump_index; - unsigned int x = adj[h].cluster_dx + i; - unsigned int y = adj[h].cluster_dy + j; - stbcc__clump_union(g, m, x, y, clump_index); - } - } - } + for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { + stbcc__cluster *cluster = &g->cluster[j][i]; + for (k=0; k < (int) cluster->num_edge_clumps; ++k) { + stbcc__clump *clump = &cluster->clump[k]; + stbcc__unpacked_clumpid m; + stbcc__relative_clumpid *adj; + m.clump_index = k; + m.cluster_x = i; + m.cluster_y = j; + adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; + for (h=0; h < clump->num_adjacent; ++h) { + unsigned int clump_index = adj[h].clump_index; + unsigned int x = adj[h].cluster_dx + i; + unsigned int y = adj[h].cluster_dy + j; + stbcc__clump_union(g, m, x, y, clump_index); + } + } + } } for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { - for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { - stbcc__cluster *cluster = &g->cluster[j][i]; - for (k=0; k < (int) cluster->num_edge_clumps; ++k) { - stbcc__global_clumpid m; - m.f.clump_index = k; - m.f.cluster_x = i; - m.f.cluster_y = j; - stbcc__clump_find(g, m); - } - } + for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { + stbcc__cluster *cluster = &g->cluster[j][i]; + for (k=0; k < (int) cluster->num_edge_clumps; ++k) { + stbcc__global_clumpid m; + m.f.clump_index = k; + m.f.cluster_x = i; + m.f.cluster_y = j; + stbcc__clump_find(g, m); + } + } } } @@ -422,57 +422,57 @@ static void stbcc__build_all_connections_for_cluster(stbcc_grid *g, int cx, int total = 0; for (m=0; m < 4; ++m) { - switch (m) { - case 0: - dx = 1, dy = 0; - step_x = 0, step_y = 1; - i = STBCC__CLUSTER_SIZE_X-1; - j = 0; - n = STBCC__CLUSTER_SIZE_Y; - break; - case 1: - dx = -1, dy = 0; - i = 0; - j = 0; - step_x = 0; - step_y = 1; - n = STBCC__CLUSTER_SIZE_Y; - break; - case 2: - dy = -1, dx = 0; - i = 0; - j = 0; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; - break; - case 3: - dy = 1, dx = 0; - i = 0; - j = STBCC__CLUSTER_SIZE_Y-1; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; - break; - } - - if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) - continue; - - memset(connected, 0, sizeof(connected)); - for (k=0; k < n; ++k) { - if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { - stbcc__clumpid src = g->clump_for_node[y+j][x+i]; - stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; - if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { - connected[src][dest>>3] |= 1 << (dest & 7); - ++num_adj[src]; - ++total; - } - } - i += step_x; - j += step_y; - } + switch (m) { + case 0: + dx = 1, dy = 0; + step_x = 0, step_y = 1; + i = STBCC__CLUSTER_SIZE_X-1; + j = 0; + n = STBCC__CLUSTER_SIZE_Y; + break; + case 1: + dx = -1, dy = 0; + i = 0; + j = 0; + step_x = 0; + step_y = 1; + n = STBCC__CLUSTER_SIZE_Y; + break; + case 2: + dy = -1, dx = 0; + i = 0; + j = 0; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; + break; + case 3: + dy = 1, dx = 0; + i = 0; + j = STBCC__CLUSTER_SIZE_Y-1; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; + break; + } + + if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) + continue; + + memset(connected, 0, sizeof(connected)); + for (k=0; k < n; ++k) { + if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { + stbcc__clumpid src = g->clump_for_node[y+j][x+i]; + stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; + if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { + connected[src][dest>>3] |= 1 << (dest & 7); + ++num_adj[src]; + ++total; + } + } + i += step_x; + j += step_y; + } } assert(total <= STBCC__CLUSTER_ADJACENCY_COUNT); @@ -487,24 +487,24 @@ static void stbcc__build_all_connections_for_cluster(stbcc_grid *g, int cx, int // ignoring edge-vs-non-edge with 'num_adj[i]*2' was faster than // 'num_adj[i]+extra' with the divide if (total + (cluster->num_edge_clumps<<2) <= STBCC__CLUSTER_ADJACENCY_COUNT) - extra = 4; + extra = 4; else if (total + (cluster->num_edge_clumps<<1) <= STBCC__CLUSTER_ADJACENCY_COUNT) - extra = 2; + extra = 2; else if (total + (cluster->num_edge_clumps<<0) <= STBCC__CLUSTER_ADJACENCY_COUNT) - extra = 1; + extra = 1; else - extra = 0; + extra = 0; total = 0; for (i=0; i < (int) cluster->num_edge_clumps; ++i) { - int alloc = num_adj[i]+extra; - if (alloc > STBCC__MAX_EXITS_PER_CLUSTER) - alloc = STBCC__MAX_EXITS_PER_CLUSTER; - assert(total < 256); // must fit in byte - cluster->clump[i].adjacent_clump_list_index = (unsigned char) total; - cluster->clump[i].max_adjacent = alloc; - cluster->clump[i].num_adjacent = 0; - total += alloc; + int alloc = num_adj[i]+extra; + if (alloc > STBCC__MAX_EXITS_PER_CLUSTER) + alloc = STBCC__MAX_EXITS_PER_CLUSTER; + assert(total < 256); // must fit in byte + cluster->clump[i].adjacent_clump_list_index = (unsigned char) total; + cluster->clump[i].max_adjacent = alloc; + cluster->clump[i].num_adjacent = 0; + total += alloc; } assert(total <= STBCC__CLUSTER_ADJACENCY_COUNT); @@ -519,9 +519,9 @@ static void stbcc__build_all_connections_for_cluster(stbcc_grid *g, int cx, int static void stbcc__add_connections_to_adjacent_cluster_with_rebuild(stbcc_grid *g, int cx, int cy, int dx, int dy) { if (cx >= 0 && cx < g->cw && cy >= 0 && cy < g->ch) { - stbcc__add_connections_to_adjacent_cluster(g, cx, cy, dx, dy); - if (g->cluster[cy][cx].rebuild_adjacency) - stbcc__build_all_connections_for_cluster(g, cx, cy); + stbcc__add_connections_to_adjacent_cluster(g, cx, cy, dx, dy); + if (g->cluster[cy][cx].rebuild_adjacency) + stbcc__build_all_connections_for_cluster(g, cx, cy); } } @@ -530,11 +530,11 @@ void stbcc_update_grid(stbcc_grid *g, int x, int y, int solid) int cx,cy; if (!solid) { - if (STBCC__MAP_OPEN(g,x,y)) - return; + if (STBCC__MAP_OPEN(g,x,y)) + return; } else { - if (!STBCC__MAP_OPEN(g,x,y)) - return; + if (!STBCC__MAP_OPEN(g,x,y)) + return; } cx = STBCC__CLUSTER_X_FOR_COORD_X(x); @@ -546,9 +546,9 @@ void stbcc_update_grid(stbcc_grid *g, int x, int y, int solid) stbcc__remove_connections_to_adjacent_cluster(g, cx, cy+1, 0,-1); if (!solid) - STBCC__MAP_BYTE(g,x,y) |= STBCC__MAP_BYTE_MASK(x,y); + STBCC__MAP_BYTE(g,x,y) |= STBCC__MAP_BYTE_MASK(x,y); else - STBCC__MAP_BYTE(g,x,y) &= ~STBCC__MAP_BYTE_MASK(x,y); + STBCC__MAP_BYTE(g,x,y) &= ~STBCC__MAP_BYTE_MASK(x,y); stbcc__build_clumps_for_cluster(g, cx, cy); stbcc__build_all_connections_for_cluster(g, cx, cy); @@ -559,11 +559,11 @@ void stbcc_update_grid(stbcc_grid *g, int x, int y, int solid) stbcc__add_connections_to_adjacent_cluster_with_rebuild(g, cx, cy+1, 0,-1); if (!g->in_batched_update) - stbcc__build_connected_components_for_clumps(g); - #if 0 + stbcc__build_connected_components_for_clumps(g); +#if 0 else - g->cluster_dirty[cy][cx] = 1; - #endif + g->cluster_dirty[cy][cx] = 1; +#endif } void stbcc_update_batch_begin(stbcc_grid *g) @@ -597,35 +597,35 @@ void stbcc_init_grid(stbcc_grid *g, unsigned char *map, int w, int h) g->ch = h >> STBCC_CLUSTER_SIZE_Y_LOG2; g->in_batched_update = 0; - #if 0 +#if 0 for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) - for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) - g->cluster_dirty[j][i] = 0; - #endif + for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) + g->cluster_dirty[j][i] = 0; +#endif for (j=0; j < h; ++j) { - for (i=0; i < w; i += 8) { - unsigned char c = 0; - for (k=0; k < 8; ++k) - if (map[j*w + (i+k)] == 0) - c |= (1 << k); - g->map[j][i>>3] = c; - } + for (i=0; i < w; i += 8) { + unsigned char c = 0; + for (k=0; k < 8; ++k) + if (map[j*w + (i+k)] == 0) + c |= (1 << k); + g->map[j][i>>3] = c; + } } for (j=0; j < g->ch; ++j) - for (i=0; i < g->cw; ++i) - stbcc__build_clumps_for_cluster(g, i, j); + for (i=0; i < g->cw; ++i) + stbcc__build_clumps_for_cluster(g, i, j); for (j=0; j < g->ch; ++j) - for (i=0; i < g->cw; ++i) - stbcc__build_all_connections_for_cluster(g, i, j); + for (i=0; i < g->cw; ++i) + stbcc__build_all_connections_for_cluster(g, i, j); stbcc__build_connected_components_for_clumps(g); for (j=0; j < g->h; ++j) - for (i=0; i < g->w; ++i) - assert(g->clump_for_node[j][i] <= STBCC__NULL_CLUMPID); + for (i=0; i < g->w; ++i) + assert(g->clump_for_node[j][i] <= STBCC__NULL_CLUMPID); } @@ -657,12 +657,12 @@ static void stbcc__add_clump_connection(stbcc_grid *g, int x1, int y1, int x2, i clump = &cluster->clump[c1]; assert(clump->num_adjacent <= clump->max_adjacent); if (clump->num_adjacent == clump->max_adjacent) - g->cluster[cy1][cx1].rebuild_adjacency = 1; + g->cluster[cy1][cx1].rebuild_adjacency = 1; else { - stbcc__relative_clumpid *adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; - assert(clump->num_adjacent < STBCC__MAX_EXITS_PER_CLUMP); - assert(clump->adjacent_clump_list_index + clump->num_adjacent <= STBCC__CLUSTER_ADJACENCY_COUNT); - adj[clump->num_adjacent++] = rc; + stbcc__relative_clumpid *adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; + assert(clump->num_adjacent < STBCC__MAX_EXITS_PER_CLUMP); + assert(clump->adjacent_clump_list_index + clump->num_adjacent <= STBCC__CLUSTER_ADJACENCY_COUNT); + adj[clump->num_adjacent++] = rc; } } @@ -697,15 +697,15 @@ static void stbcc__remove_clump_connection(stbcc_grid *g, int x1, int y1, int x2 adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; for (i=0; i < clump->num_adjacent; ++i) - if (rc.clump_index == adj[i].clump_index && - rc.cluster_dx == adj[i].cluster_dx && - rc.cluster_dy == adj[i].cluster_dy) - break; + if (rc.clump_index == adj[i].clump_index && + rc.cluster_dx == adj[i].cluster_dx && + rc.cluster_dy == adj[i].cluster_dy) + break; if (i < clump->num_adjacent) - adj[i] = adj[--clump->num_adjacent]; + adj[i] = adj[--clump->num_adjacent]; else - assert(0); + assert(0); } static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy) @@ -716,59 +716,59 @@ static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, in int step_x, step_y=0, i, j, k, n; if (cx < 0 || cx >= g->cw || cy < 0 || cy >= g->ch) - return; + return; if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) - return; + return; if (g->cluster[cy][cx].rebuild_adjacency) - return; + return; assert(abs(dx) + abs(dy) == 1); if (dx == 1) { - i = STBCC__CLUSTER_SIZE_X-1; - j = 0; - step_x = 0; - step_y = 1; - n = STBCC__CLUSTER_SIZE_Y; + i = STBCC__CLUSTER_SIZE_X-1; + j = 0; + step_x = 0; + step_y = 1; + n = STBCC__CLUSTER_SIZE_Y; } else if (dx == -1) { - i = 0; - j = 0; - step_x = 0; - step_y = 1; - n = STBCC__CLUSTER_SIZE_Y; + i = 0; + j = 0; + step_x = 0; + step_y = 1; + n = STBCC__CLUSTER_SIZE_Y; } else if (dy == -1) { - i = 0; - j = 0; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; + i = 0; + j = 0; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; } else if (dy == 1) { - i = 0; - j = STBCC__CLUSTER_SIZE_Y-1; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; + i = 0; + j = STBCC__CLUSTER_SIZE_Y-1; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; } else { - assert(0); - return; + assert(0); + return; } for (k=0; k < n; ++k) { - if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { - stbcc__clumpid src = g->clump_for_node[y+j][x+i]; - stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; - if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { - assert((dest>>3) < sizeof(connected)); - connected[src][dest>>3] |= 1 << (dest & 7); - stbcc__add_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); - if (g->cluster[cy][cx].rebuild_adjacency) - break; - } - } - i += step_x; - j += step_y; + if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { + stbcc__clumpid src = g->clump_for_node[y+j][x+i]; + stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; + if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { + assert((dest>>3) < sizeof(connected)); + connected[src][dest>>3] |= 1 << (dest & 7); + stbcc__add_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); + if (g->cluster[cy][cx].rebuild_adjacency) + break; + } + } + i += step_x; + j += step_y; } } @@ -780,53 +780,53 @@ static void stbcc__remove_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int step_x, step_y=0, i, j, k, n; if (cx < 0 || cx >= g->cw || cy < 0 || cy >= g->ch) - return; + return; if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) - return; + return; assert(abs(dx) + abs(dy) == 1); if (dx == 1) { - i = STBCC__CLUSTER_SIZE_X-1; - j = 0; - step_x = 0; - step_y = 1; - n = STBCC__CLUSTER_SIZE_Y; + i = STBCC__CLUSTER_SIZE_X-1; + j = 0; + step_x = 0; + step_y = 1; + n = STBCC__CLUSTER_SIZE_Y; } else if (dx == -1) { - i = 0; - j = 0; - step_x = 0; - step_y = 1; - n = STBCC__CLUSTER_SIZE_Y; + i = 0; + j = 0; + step_x = 0; + step_y = 1; + n = STBCC__CLUSTER_SIZE_Y; } else if (dy == -1) { - i = 0; - j = 0; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; + i = 0; + j = 0; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; } else if (dy == 1) { - i = 0; - j = STBCC__CLUSTER_SIZE_Y-1; - step_x = 1; - step_y = 0; - n = STBCC__CLUSTER_SIZE_X; + i = 0; + j = STBCC__CLUSTER_SIZE_Y-1; + step_x = 1; + step_y = 0; + n = STBCC__CLUSTER_SIZE_X; } else { - assert(0); - return; + assert(0); + return; } for (k=0; k < n; ++k) { - if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { - stbcc__clumpid src = g->clump_for_node[y+j][x+i]; - stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; - if (0 == (disconnected[src][dest>>3] & (1 << (dest & 7)))) { - disconnected[src][dest>>3] |= 1 << (dest & 7); - stbcc__remove_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); - } - } - i += step_x; - j += step_y; + if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { + stbcc__clumpid src = g->clump_for_node[y+j][x+i]; + stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; + if (0 == (disconnected[src][dest>>3] & (1 << (dest & 7)))) { + disconnected[src][dest>>3] |= 1 << (dest & 7); + stbcc__remove_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); + } + } + i += step_x; + j += step_y; } } @@ -835,7 +835,7 @@ static stbcc__tinypoint stbcc__incluster_find(stbcc__cluster_build_info *cbi, in stbcc__tinypoint p,q; p = cbi->parent[y][x]; if (p.x == x && p.y == y) - return p; + return p; q = stbcc__incluster_find(cbi, p.x, p.y); cbi->parent[y][x] = q; return q; @@ -847,7 +847,7 @@ static void stbcc__incluster_union(stbcc__cluster_build_info *cbi, int x1, int y stbcc__tinypoint q = stbcc__incluster_find(cbi, x2,y2); if (p.x == q.x && p.y == q.y) - return; + return; cbi->parent[p.y][p.x] = q; } @@ -871,23 +871,23 @@ static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy) // set initial disjoint set forest state for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { - for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { - cbi.parent[j][i].x = i; - cbi.parent[j][i].y = j; - } + for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { + cbi.parent[j][i].x = i; + cbi.parent[j][i].y = j; + } } // join all sets that are connected for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { - // check down only if not on bottom row - if (j < STBCC__CLUSTER_SIZE_Y-1) - for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) - if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i ,y+j+1)) - stbcc__incluster_union(&cbi, i,j, i,j+1); - // check right for everything but rightmost column - for (i=0; i < STBCC__CLUSTER_SIZE_X-1; ++i) - if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i+1,y+j )) - stbcc__incluster_union(&cbi, i,j, i+1,j); + // check down only if not on bottom row + if (j < STBCC__CLUSTER_SIZE_Y-1) + for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) + if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i ,y+j+1)) + stbcc__incluster_union(&cbi, i,j, i,j+1); + // check right for everything but rightmost column + for (i=0; i < STBCC__CLUSTER_SIZE_X-1; ++i) + if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i+1,y+j )) + stbcc__incluster_union(&cbi, i,j, i+1,j); } // label all non-empty clumps along edges so that all edge clumps are first @@ -897,57 +897,57 @@ static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy) // first put solid labels on all the edges; these will get overwritten if they're open for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) - cbi.label[j][0] = cbi.label[j][STBCC__CLUSTER_SIZE_X-1] = STBCC__NULL_CLUMPID; + cbi.label[j][0] = cbi.label[j][STBCC__CLUSTER_SIZE_X-1] = STBCC__NULL_CLUMPID; for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) - cbi.label[0][i] = cbi.label[STBCC__CLUSTER_SIZE_Y-1][i] = STBCC__NULL_CLUMPID; + cbi.label[0][i] = cbi.label[STBCC__CLUSTER_SIZE_Y-1][i] = STBCC__NULL_CLUMPID; for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { - i = 0; - if (STBCC__MAP_OPEN(g, x+i, y+j)) { - stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); - if (p.x == i && p.y == j) - // if this is the leader, give it a label - cbi.label[j][i] = label++; - else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { - // if leader is in interior, promote this edge node to leader and label - stbcc__switch_root(&cbi, i, j, p); - cbi.label[j][i] = label++; - } - // else if leader is on edge, do nothing (it'll get labelled when we reach it) - } - i = STBCC__CLUSTER_SIZE_X-1; - if (STBCC__MAP_OPEN(g, x+i, y+j)) { - stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); - if (p.x == i && p.y == j) - cbi.label[j][i] = label++; - else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { - stbcc__switch_root(&cbi, i, j, p); - cbi.label[j][i] = label++; - } - } + i = 0; + if (STBCC__MAP_OPEN(g, x+i, y+j)) { + stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); + if (p.x == i && p.y == j) + // if this is the leader, give it a label + cbi.label[j][i] = label++; + else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { + // if leader is in interior, promote this edge node to leader and label + stbcc__switch_root(&cbi, i, j, p); + cbi.label[j][i] = label++; + } + // else if leader is on edge, do nothing (it'll get labelled when we reach it) + } + i = STBCC__CLUSTER_SIZE_X-1; + if (STBCC__MAP_OPEN(g, x+i, y+j)) { + stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); + if (p.x == i && p.y == j) + cbi.label[j][i] = label++; + else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { + stbcc__switch_root(&cbi, i, j, p); + cbi.label[j][i] = label++; + } + } } for (i=1; i < STBCC__CLUSTER_SIZE_Y-1; ++i) { - j = 0; - if (STBCC__MAP_OPEN(g, x+i, y+j)) { - stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); - if (p.x == i && p.y == j) - cbi.label[j][i] = label++; - else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { - stbcc__switch_root(&cbi, i, j, p); - cbi.label[j][i] = label++; - } - } - j = STBCC__CLUSTER_SIZE_Y-1; - if (STBCC__MAP_OPEN(g, x+i, y+j)) { - stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); - if (p.x == i && p.y == j) - cbi.label[j][i] = label++; - else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { - stbcc__switch_root(&cbi, i, j, p); - cbi.label[j][i] = label++; - } - } + j = 0; + if (STBCC__MAP_OPEN(g, x+i, y+j)) { + stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); + if (p.x == i && p.y == j) + cbi.label[j][i] = label++; + else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { + stbcc__switch_root(&cbi, i, j, p); + cbi.label[j][i] = label++; + } + } + j = STBCC__CLUSTER_SIZE_Y-1; + if (STBCC__MAP_OPEN(g, x+i, y+j)) { + stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); + if (p.x == i && p.y == j) + cbi.label[j][i] = label++; + else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { + stbcc__switch_root(&cbi, i, j, p); + cbi.label[j][i] = label++; + } + } } c = &g->cluster[cy][cx]; @@ -955,51 +955,51 @@ static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy) // label any internal clusters for (j=1; j < STBCC__CLUSTER_SIZE_Y-1; ++j) { - for (i=1; i < STBCC__CLUSTER_SIZE_X-1; ++i) { - stbcc__tinypoint p = cbi.parent[j][i]; - if (p.x == i && p.y == j) { - if (STBCC__MAP_OPEN(g,x+i,y+j)) - cbi.label[j][i] = label++; - else - cbi.label[j][i] = STBCC__NULL_CLUMPID; - } - } + for (i=1; i < STBCC__CLUSTER_SIZE_X-1; ++i) { + stbcc__tinypoint p = cbi.parent[j][i]; + if (p.x == i && p.y == j) { + if (STBCC__MAP_OPEN(g,x+i,y+j)) + cbi.label[j][i] = label++; + else + cbi.label[j][i] = STBCC__NULL_CLUMPID; + } + } } // label all other nodes for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { - for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { - stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); - if (p.x != i || p.y != j) { - if (STBCC__MAP_OPEN(g,x+i,y+j)) - cbi.label[j][i] = cbi.label[p.y][p.x]; - } - if (STBCC__MAP_OPEN(g,x+i,y+j)) - assert(cbi.label[j][i] != STBCC__NULL_CLUMPID); - } + for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { + stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); + if (p.x != i || p.y != j) { + if (STBCC__MAP_OPEN(g,x+i,y+j)) + cbi.label[j][i] = cbi.label[p.y][p.x]; + } + if (STBCC__MAP_OPEN(g,x+i,y+j)) + assert(cbi.label[j][i] != STBCC__NULL_CLUMPID); + } } c->num_clumps = label; for (i=0; i < label; ++i) { - c->clump[i].num_adjacent = 0; - c->clump[i].max_adjacent = 0; + c->clump[i].num_adjacent = 0; + c->clump[i].max_adjacent = 0; } for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) - for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { - g->clump_for_node[y+j][x+i] = cbi.label[j][i]; // @OPTIMIZE: remove cbi.label entirely - assert(g->clump_for_node[y+j][x+i] <= STBCC__NULL_CLUMPID); - } + for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { + g->clump_for_node[y+j][x+i] = cbi.label[j][i]; // @OPTIMIZE: remove cbi.label entirely + assert(g->clump_for_node[y+j][x+i] <= STBCC__NULL_CLUMPID); + } // set the global label for all interior clumps since they can't have connections, // so we don't have to do this on the global pass (brings from O(N) to O(N^0.75)) for (i=(int) c->num_edge_clumps; i < (int) c->num_clumps; ++i) { - stbcc__global_clumpid gc; - gc.f.cluster_x = cx; - gc.f.cluster_y = cy; - gc.f.clump_index = i; - c->clump[i].global_label = gc; + stbcc__global_clumpid gc; + gc.f.cluster_x = cx; + gc.f.cluster_y = cy; + gc.f.clump_index = i; + c->clump[i].global_label = gc; } c->rebuild_adjacency = 1; // flag that it has no valid adjacency data diff --git a/fggl/stb/stb_divide.h b/fggl/stb/stb_divide.h index 6a51e3f2e3b328df25bf9c9a866268782889d08c..277c8b8e26c48cdf71885c4eddd4c07cc935f262 100644 --- a/fggl/stb/stb_divide.h +++ b/fggl/stb/stb_divide.h @@ -93,10 +93,10 @@ extern "C" { extern int stb_div_trunc(int value_to_be_divided, int value_to_divide_by); extern int stb_div_floor(int value_to_be_divided, int value_to_divide_by); -extern int stb_div_eucl (int value_to_be_divided, int value_to_divide_by); +extern int stb_div_eucl(int value_to_be_divided, int value_to_divide_by); extern int stb_mod_trunc(int value_to_be_divided, int value_to_divide_by); extern int stb_mod_floor(int value_to_be_divided, int value_to_divide_by); -extern int stb_mod_eucl (int value_to_be_divided, int value_to_divide_by); +extern int stb_mod_eucl(int value_to_be_divided, int value_to_divide_by); #ifdef __cplusplus } @@ -105,9 +105,9 @@ extern int stb_mod_eucl (int value_to_be_divided, int value_to_divide_by); #ifdef STB_DIVIDE_IMPLEMENTATION #if defined(__STDC_VERSION) && __STDC_VERSION__ >= 19901 - #ifndef C_INTEGER_DIVISION_TRUNCATES - #define C_INTEGER_DIVISION_TRUNCATES - #endif + #ifndef C_INTEGER_DIVISION_TRUNCATES + #define C_INTEGER_DIVISION_TRUNCATES + #endif #endif #ifndef INT_MIN @@ -117,150 +117,150 @@ extern int stb_mod_eucl (int value_to_be_divided, int value_to_divide_by); // the following macros are designed to allow testing // other platforms by simulating them #ifndef STB_DIVIDE_TEST_FLOOR - #define stb__div(a,b) ((a)/(b)) - #define stb__mod(a,b) ((a)%(b)) + #define stb__div(a,b) ((a)/(b)) + #define stb__mod(a,b) ((a)%(b)) #else // implement floor-style divide on trunc platform - #ifndef C_INTEGER_DIVISION_TRUNCATES - #error "floor test requires truncating division" - #endif - #undef C_INTEGER_DIVISION_TRUNCATES + #ifndef C_INTEGER_DIVISION_TRUNCATES + #error "floor test requires truncating division" + #endif + #undef C_INTEGER_DIVISION_TRUNCATES int stb__div(int v1, int v2) { - int q = v1/v2, r = v1%v2; - if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) - return q-1; - else - return q; + int q = v1/v2, r = v1%v2; + if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) + return q-1; + else + return q; } int stb__mod(int v1, int v2) { - int r = v1%v2; - if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) - return r+v2; - else - return r; + int r = v1%v2; + if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) + return r+v2; + else + return r; } #endif int stb_div_trunc(int v1, int v2) { - #ifdef C_INTEGER_DIVISION_TRUNCATES +#ifdef C_INTEGER_DIVISION_TRUNCATES return v1/v2; - #else +#else if (v1 >= 0 && v2 <= 0) - return -stb__div(-v1,v2); // both negative to avoid overflow + return -stb__div(-v1,v2); // both negative to avoid overflow if (v1 <= 0 && v2 >= 0) - if (v1 != INT_MIN) - return -stb__div(v1,-v2); // both negative to avoid overflow - else - return -stb__div(v1+v2,-v2)-1; // push v1 away from wrap point + if (v1 != INT_MIN) + return -stb__div(v1,-v2); // both negative to avoid overflow + else + return -stb__div(v1+v2,-v2)-1; // push v1 away from wrap point else - return v1/v2; // same sign, so expect truncation - #endif + return v1/v2; // same sign, so expect truncation +#endif } int stb_div_floor(int v1, int v2) { - #ifdef C_INTEGER_DIVISION_FLOORS +#ifdef C_INTEGER_DIVISION_FLOORS return v1/v2; - #else +#else if (v1 >= 0 && v2 < 0) { - if (v2 + 1 >= INT_MIN + v1) // check if increasing v1's magnitude overflows - return -stb__div((v2+1)-v1,v2); // nope, so just compute it - else - return -stb__div(-v1,v2) + ((-v1)%v2 ? -1 : 0); + if (v2 + 1 >= INT_MIN + v1) // check if increasing v1's magnitude overflows + return -stb__div((v2+1)-v1,v2); // nope, so just compute it + else + return -stb__div(-v1,v2) + ((-v1)%v2 ? -1 : 0); } if (v1 < 0 && v2 >= 0) { - if (v1 != INT_MIN) { - if (v1 + 1 >= INT_MIN + v2) // check if increasing v1's magnitude overflows - return -stb__div((v1+1)-v2,-v2); // nope, so just compute it - else - return -stb__div(-v1,v2) + (stb__mod(v1,-v2) ? -1 : 0); - } else // it must be possible to compute -(v1+v2) without overflowing - return -stb__div(-(v1+v2),v2) + (stb__mod(-(v1+v2),v2) ? -2 : -1); + if (v1 != INT_MIN) { + if (v1 + 1 >= INT_MIN + v2) // check if increasing v1's magnitude overflows + return -stb__div((v1+1)-v2,-v2); // nope, so just compute it + else + return -stb__div(-v1,v2) + (stb__mod(v1,-v2) ? -1 : 0); + } else // it must be possible to compute -(v1+v2) without overflowing + return -stb__div(-(v1+v2),v2) + (stb__mod(-(v1+v2),v2) ? -2 : -1); } else - return v1/v2; // same sign, so expect truncation - #endif + return v1/v2; // same sign, so expect truncation +#endif } int stb_div_eucl(int v1, int v2) { int q,r; - #ifdef C_INTEGER_DIVISION_TRUNCATES +#ifdef C_INTEGER_DIVISION_TRUNCATES q = v1/v2; r = v1%v2; - #else +#else // handle every quadrant separately, since we can't rely on q and r flor if (v1 >= 0) - if (v2 >= 0) - return stb__div(v1,v2); - else if (v2 != INT_MIN) - q = -stb__div(v1,-v2), r = stb__mod(v1,-v2); - else - q = 0, r = v1; + if (v2 >= 0) + return stb__div(v1,v2); + else if (v2 != INT_MIN) + q = -stb__div(v1,-v2), r = stb__mod(v1,-v2); + else + q = 0, r = v1; else if (v1 != INT_MIN) - if (v2 >= 0) - q = -stb__div(-v1,v2), r = -stb__mod(-v1,v2); - else if (v2 != INT_MIN) - q = stb__div(-v1,-v2), r = -stb__mod(-v1,-v2); - else // if v2 is INT_MIN, then we can't use -v2, but we can't divide by v2 - q = 1, r = v1-q*v2; + if (v2 >= 0) + q = -stb__div(-v1,v2), r = -stb__mod(-v1,v2); + else if (v2 != INT_MIN) + q = stb__div(-v1,-v2), r = -stb__mod(-v1,-v2); + else // if v2 is INT_MIN, then we can't use -v2, but we can't divide by v2 + q = 1, r = v1-q*v2; else // if v1 is INT_MIN, we have to move away from overflow place - if (v2 >= 0) - q = -stb__div(-(v1+v2),v2)-1, r = -stb__mod(-(v1+v2),v2); - else if (v2 != INT_MIN) - q = stb__div(-(v1-v2),-v2)+1, r = -stb__mod(-(v1-v2),-v2); - else // for INT_MIN / INT_MIN, we need to be extra-careful to avoid overflow - q = 1, r = 0; - #endif + if (v2 >= 0) + q = -stb__div(-(v1+v2),v2)-1, r = -stb__mod(-(v1+v2),v2); + else if (v2 != INT_MIN) + q = stb__div(-(v1-v2),-v2)+1, r = -stb__mod(-(v1-v2),-v2); + else // for INT_MIN / INT_MIN, we need to be extra-careful to avoid overflow + q = 1, r = 0; +#endif if (r >= 0) - return q; + return q; else - return q + (v2 > 0 ? -1 : 1); + return q + (v2 > 0 ? -1 : 1); } int stb_mod_trunc(int v1, int v2) { - #ifdef C_INTEGER_DIVISION_TRUNCATES +#ifdef C_INTEGER_DIVISION_TRUNCATES return v1%v2; - #else +#else if (v1 >= 0) { // modulus result should always be positive - int r = stb__mod(v1,v2); - if (r >= 0) - return r; - else - return r - (v2 < 0 ? v2 : -v2); + int r = stb__mod(v1,v2); + if (r >= 0) + return r; + else + return r - (v2 < 0 ? v2 : -v2); } else { // modulus result should always be negative - int r = stb__mod(v1,v2); - if (r <= 0) - return r; - else - return r + (v2 < 0 ? v2 : -v2); + int r = stb__mod(v1,v2); + if (r <= 0) + return r; + else + return r + (v2 < 0 ? v2 : -v2); } - #endif +#endif } int stb_mod_floor(int v1, int v2) { - #ifdef C_INTEGER_DIVISION_FLOORS +#ifdef C_INTEGER_DIVISION_FLOORS return v1%v2; - #else +#else if (v2 >= 0) { // result should always be positive - int r = stb__mod(v1,v2); - if (r >= 0) - return r; - else - return r + v2; + int r = stb__mod(v1,v2); + if (r >= 0) + return r; + else + return r + v2; } else { // result should always be negative - int r = stb__mod(v1,v2); - if (r <= 0) - return r; - else - return r + v2; + int r = stb__mod(v1,v2); + if (r <= 0) + return r; + else + return r + v2; } - #endif +#endif } int stb_mod_eucl(int v1, int v2) @@ -268,9 +268,9 @@ int stb_mod_eucl(int v1, int v2) int r = stb__mod(v1,v2); if (r >= 0) - return r; + return r; else - return r - (v2 < 0 ? v2 : -v2); // negative abs() [to avoid overflow] + return r - (v2 < 0 ? v2 : -v2); // negative abs() [to avoid overflow] } #ifdef STB_DIVIDE_TEST @@ -284,28 +284,28 @@ int err=0; void stbdiv_check(int q, int r, int a, int b, char *type, int dir) { if ((dir > 0 && r < 0) || (dir < 0 && r > 0)) { - fprintf(stderr, "FAILED: %s(%d,%d) remainder %d in wrong direction\n", type,a,b,r); - err++; + fprintf(stderr, "FAILED: %s(%d,%d) remainder %d in wrong direction\n", type,a,b,r); + err++; } else - if (b != INT_MIN) // can't compute abs(), but if b==INT_MIN all remainders are valid - if (r <= -abs(b) || r >= abs(b)) { - fprintf(stderr, "FAILED: %s(%d,%d) remainder %d out of range\n", type,a,b,r); - err++; - } - #ifdef STB_DIVIDE_TEST_64 + if (b != INT_MIN) // can't compute abs(), but if b==INT_MIN all remainders are valid + if (r <= -abs(b) || r >= abs(b)) { + fprintf(stderr, "FAILED: %s(%d,%d) remainder %d out of range\n", type,a,b,r); + err++; + } +#ifdef STB_DIVIDE_TEST_64 { - STB_DIVIDE_TEST_64 q64 = q, r64=r, a64=a, b64=b; - if (q64*b64+r64 != a64) { - fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); - err++; - } + STB_DIVIDE_TEST_64 q64 = q, r64=r, a64=a, b64=b; + if (q64*b64+r64 != a64) { + fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); + err++; + } } - #else +#else if (q*b+r != a) { - fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); - err++; + fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); + err++; } - #endif +#endif } void test(int a, int b) diff --git a/fggl/stb/stb_hexwave.h b/fggl/stb/stb_hexwave.h index 480ab1b2aaee52adab00fe8024542ad62961e060..755fe5d654feb0a037e365ef4939761c5f052e17 100644 --- a/fggl/stb/stb_hexwave.h +++ b/fggl/stb/stb_hexwave.h @@ -256,21 +256,19 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He // oscillator_freq: frequency of the oscillator divided by the sample rate // private: -typedef struct -{ - int reflect; - float peak_time; - float zero_wait; - float half_height; +typedef struct { + int reflect; + float peak_time; + float zero_wait; + float half_height; } HexWaveParameters; -struct HexWave -{ - float t, prev_dt; - HexWaveParameters current, pending; - int have_pending; - float buffer[STB_HEXWAVE_MAX_BLEP_LENGTH]; -}; +struct HexWave { + float t, prev_dt; + HexWaveParameters current, pending; + int have_pending; + float buffer[STB_HEXWAVE_MAX_BLEP_LENGTH]; +}; #endif #ifdef STB_HEXWAVE_IMPLEMENTATION @@ -320,14 +318,14 @@ static void hex_add_oversampled_bleplike(float *output, float time_since_transit int slot = (int) (time_since_transition * hexblep.oversample); if (slot >= hexblep.oversample) - slot = hexblep.oversample-1; // clamp in case the floats overshoot + slot = hexblep.oversample-1; // clamp in case the floats overshoot d1 = &data[ slot *bw]; d2 = &data[(slot+1)*bw]; lerpweight = time_since_transition * hexblep.oversample - slot; for (i=0; i < bw; ++i) - output[i] += scale * (d1[i] + (d2[i]-d1[i])*lerpweight); + output[i] += scale * (d1[i] + (d2[i]-d1[i])*lerpweight); } static void hex_blep (float *output, float time_since_transition, float scale) @@ -362,52 +360,52 @@ static void hexwave_generate_linesegs(hexvert vert[9], HexWave *hex, float dt) vert[3].v = hex->current.half_height; if (hex->current.reflect) { - for (j=4; j <= 7; ++j) { - vert[j].t = 1 - vert[7-j].t; - vert[j].v = - vert[7-j].v; - } + for (j=4; j <= 7; ++j) { + vert[j].t = 1 - vert[7-j].t; + vert[j].v = - vert[7-j].v; + } } else { - for (j=4; j <= 7; ++j) { - vert[j].t = 0.5f + vert[j-4].t; - vert[j].v = - vert[j-4].v; - } + for (j=4; j <= 7; ++j) { + vert[j].t = 0.5f + vert[j-4].t; + vert[j].v = - vert[j-4].v; + } } vert[8].t = 1; vert[8].v = 0; for (j=0; j < 8; ++j) { - if (vert[j+1].t <= vert[j].t + min_len) { - // if change takes place over less than a fraction of a sample treat as discontinuity - // - // otherwise the slope computation can blow up to arbitrarily large and we - // try to generate a huge BLAMP and the result is wrong. - // - // why does this happen if the math is right? i believe if done perfectly, - // the two BLAMPs on either side of the slope would cancel out, but our - // BLAMPs have only limited sub-sample precision and limited integration - // accuracy. or maybe it's just the math blowing up w/ floating point precision - // limits as we try to make x * (1/x) cancel out - // - // min_len verified artifact-free even near nyquist with only oversample=4 - vert[j+1].t = vert[j].t; - } + if (vert[j+1].t <= vert[j].t + min_len) { + // if change takes place over less than a fraction of a sample treat as discontinuity + // + // otherwise the slope computation can blow up to arbitrarily large and we + // try to generate a huge BLAMP and the result is wrong. + // + // why does this happen if the math is right? i believe if done perfectly, + // the two BLAMPs on either side of the slope would cancel out, but our + // BLAMPs have only limited sub-sample precision and limited integration + // accuracy. or maybe it's just the math blowing up w/ floating point precision + // limits as we try to make x * (1/x) cancel out + // + // min_len verified artifact-free even near nyquist with only oversample=4 + vert[j+1].t = vert[j].t; + } } if (vert[8].t != 1.0f) { - // if the above fixup moved the endpoint away from 1.0, move it back, - // along with any other vertices that got moved to the same time - float t = vert[8].t; - for (j=5; j <= 8; ++j) - if (vert[j].t == t) - vert[j].t = 1.0f; + // if the above fixup moved the endpoint away from 1.0, move it back, + // along with any other vertices that got moved to the same time + float t = vert[8].t; + for (j=5; j <= 8; ++j) + if (vert[j].t == t) + vert[j].t = 1.0f; } // compute the exact slopes from the final fixed-up positions for (j=0; j < 8; ++j) - if (vert[j+1].t == vert[j].t) - vert[j].s = 0; - else - vert[j].s = (vert[j+1].v - vert[j].v) / (vert[j+1].t - vert[j].t); + if (vert[j+1].t == vert[j].t) + vert[j].s = 0; + else + vert[j].s = (vert[j+1].v - vert[j].v) / (vert[j+1].t - vert[j].t); // wraparound at end vert[8].t = 1; @@ -429,21 +427,21 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He // all sample times are biased by halfw to leave room for BLEP/BLAMP to go back in time if (num_samples <= 0) - return; + return; // convert parameters to times and slopes hexwave_generate_linesegs(vert, hex, dt); if (hex->prev_dt != dt) { - // if frequency changes, add a fixup at the derivative discontinuity starting at now - float slope; - for (j=1; j < 6; ++j) - if (t < vert[j].t) - break; - slope = vert[j].s; - if (slope != 0) - hex_blamp(output, 0, (dt - hex->prev_dt)*slope); - hex->prev_dt = dt; + // if frequency changes, add a fixup at the derivative discontinuity starting at now + float slope; + for (j=1; j < 6; ++j) + if (t < vert[j].t) + break; + slope = vert[j].s; + if (slope != 0) + hex_blamp(output, 0, (dt - hex->prev_dt)*slope); + hex->prev_dt = dt; } // copy the buffered data from last call and clear the rest of the output array @@ -451,93 +449,93 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He memset(temp_output, 0, 2*hexblep.width*sizeof(float)); if (num_samples >= hexblep.width) { - memcpy(output, hex->buffer, buffered_length); + memcpy(output, hex->buffer, buffered_length); } else { - // if the output is shorter than hexblep.width, we do all synthesis to temp_output - memcpy(temp_output, hex->buffer, buffered_length); + // if the output is shorter than hexblep.width, we do all synthesis to temp_output + memcpy(temp_output, hex->buffer, buffered_length); } for (pass=0; pass < 2; ++pass) { - int i0,i1; - float *out; - - // we want to simulate having one buffer that is num_output + hexblep.width - // samples long, without putting that requirement on the user, and without - // allocating a temp buffer that's as long as the whole thing. so we use two - // overlapping buffers, one the user's buffer and one a fixed-length temp - // buffer. - - if (pass == 0) { - if (num_samples < hexblep.width) - continue; - // run as far as we can without overwriting the end of the user's buffer - out = output; - i0 = 0; - i1 = num_samples - hexblep.width; - } else { - // generate the rest into a temp buffer - out = temp_output; - i0 = 0; - if (num_samples >= hexblep.width) - i1 = hexblep.width; - else - i1 = num_samples; - } - - // determine current segment - for (j=0; j < 8; ++j) - if (t < vert[j+1].t) - break; - - i = i0; - for(;;) { - while (t < vert[j+1].t) { - if (i == i1) - goto done; - out[i+halfw] += vert[j].v + vert[j].s*(t - vert[j].t); - t += dt; - ++i; - } - // transition from lineseg starting at j to lineseg starting at j+1 - - if (vert[j].t == vert[j+1].t) - hex_blep(out+i, recip_dt*(t-vert[j+1].t), (vert[j+1].v - vert[j].v)); - hex_blamp(out+i, recip_dt*(t-vert[j+1].t), dt*(vert[j+1].s - vert[j].s)); - ++j; - - if (j == 8) { - // change to different waveform if there's a change pending - j = 0; - t -= 1.0; // t was >= 1.f if j==8 - if (hex->have_pending) { - float prev_s0 = vert[j].s; - float prev_v0 = vert[j].v; - hex->current = hex->pending; - hex->have_pending = 0; - hexwave_generate_linesegs(vert, hex, dt); - // the following never occurs with this oscillator, but it makes - // the code work in more general cases - if (vert[j].v != prev_v0) - hex_blep (out+i, recip_dt*t, (vert[j].v - prev_v0)); - if (vert[j].s != prev_s0) - hex_blamp(out+i, recip_dt*t, dt*(vert[j].s - prev_s0)); - } - } - } - done: - ; + int i0,i1; + float *out; + + // we want to simulate having one buffer that is num_output + hexblep.width + // samples long, without putting that requirement on the user, and without + // allocating a temp buffer that's as long as the whole thing. so we use two + // overlapping buffers, one the user's buffer and one a fixed-length temp + // buffer. + + if (pass == 0) { + if (num_samples < hexblep.width) + continue; + // run as far as we can without overwriting the end of the user's buffer + out = output; + i0 = 0; + i1 = num_samples - hexblep.width; + } else { + // generate the rest into a temp buffer + out = temp_output; + i0 = 0; + if (num_samples >= hexblep.width) + i1 = hexblep.width; + else + i1 = num_samples; + } + + // determine current segment + for (j=0; j < 8; ++j) + if (t < vert[j+1].t) + break; + + i = i0; + for(;;) { + while (t < vert[j+1].t) { + if (i == i1) + goto done; + out[i+halfw] += vert[j].v + vert[j].s*(t - vert[j].t); + t += dt; + ++i; + } + // transition from lineseg starting at j to lineseg starting at j+1 + + if (vert[j].t == vert[j+1].t) + hex_blep(out+i, recip_dt*(t-vert[j+1].t), (vert[j+1].v - vert[j].v)); + hex_blamp(out+i, recip_dt*(t-vert[j+1].t), dt*(vert[j+1].s - vert[j].s)); + ++j; + + if (j == 8) { + // change to different waveform if there's a change pending + j = 0; + t -= 1.0; // t was >= 1.f if j==8 + if (hex->have_pending) { + float prev_s0 = vert[j].s; + float prev_v0 = vert[j].v; + hex->current = hex->pending; + hex->have_pending = 0; + hexwave_generate_linesegs(vert, hex, dt); + // the following never occurs with this oscillator, but it makes + // the code work in more general cases + if (vert[j].v != prev_v0) + hex_blep (out+i, recip_dt*t, (vert[j].v - prev_v0)); + if (vert[j].s != prev_s0) + hex_blamp(out+i, recip_dt*t, dt*(vert[j].s - prev_s0)); + } + } + } + done: + ; } // at this point, we've written output[] and temp_output[] if (num_samples >= hexblep.width) { - // the first half of temp[] overlaps the end of output, the second half will be the new start overlap - for (i=0; i < hexblep.width; ++i) - output[num_samples-hexblep.width + i] += temp_output[i]; - memcpy(hex->buffer, temp_output+hexblep.width, buffered_length); + // the first half of temp[] overlaps the end of output, the second half will be the new start overlap + for (i=0; i < hexblep.width; ++i) + output[num_samples-hexblep.width + i] += temp_output[i]; + memcpy(hex->buffer, temp_output+hexblep.width, buffered_length); } else { - for (i=0; i < num_samples; ++i) - output[i] = temp_output[i]; - memcpy(hex->buffer, temp_output+num_samples, buffered_length); + for (i=0; i < num_samples; ++i) + output[i] = temp_output[i]; + memcpy(hex->buffer, temp_output+num_samples, buffered_length); } hex->t = t; @@ -545,15 +543,15 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He STB_HEXWAVE_DEF void hexwave_shutdown(float *user_buffer) { - #ifndef STB_HEXWAVE_NO_ALLOCATION +#ifndef STB_HEXWAVE_NO_ALLOCATION if (user_buffer != 0) { - free(hexblep.blep); - free(hexblep.blamp); + free(hexblep.blep); + free(hexblep.blamp); } - #endif +#endif } -// buffer should be NULL or must be 4*(width*(oversample+1)*2 + +// buffer should be NULL or must be 4*(width*(oversample+1)*2 + STB_HEXWAVE_DEF void hexwave_init(int width, int oversample, float *user_buffer) { int halfwidth = width/2; @@ -572,57 +570,57 @@ STB_HEXWAVE_DEF void hexwave_init(int width, int oversample, float *user_buffer) int i,j; if (width > STB_HEXWAVE_MAX_BLEP_LENGTH) - width = STB_HEXWAVE_MAX_BLEP_LENGTH; + width = STB_HEXWAVE_MAX_BLEP_LENGTH; if (user_buffer == 0) { - #ifndef STB_HEXWAVE_NO_ALLOCATION - blep_buffer = (float *) malloc(sizeof(float)*blep_buffer_count); - blamp_buffer = (float *) malloc(sizeof(float)*blep_buffer_count); - #endif +#ifndef STB_HEXWAVE_NO_ALLOCATION + blep_buffer = (float *) malloc(sizeof(float)*blep_buffer_count); + blamp_buffer = (float *) malloc(sizeof(float)*blep_buffer_count); +#endif } else { - blep_buffer = ramp+n; - blamp_buffer = blep_buffer + blep_buffer_count; + blep_buffer = ramp+n; + blamp_buffer = blep_buffer + blep_buffer_count; } // compute BLEP and BLAMP by integerating windowed sinc for (i=0; i < n; ++i) { - for (j=0; j < 16; ++j) { - float sinc_t = 3.141592f* (i-half) / oversample; - float sinc = (i==half) ? 1.0f : (float) sin(sinc_t) / (sinc_t); - float wt = 2.0f*3.1415926f * i / (n-1); - float window = (float) (0.355768 - 0.487396*cos(wt) + 0.144232*cos(2*wt) - 0.012604*cos(3*wt)); // Nuttall - double value = window * sinc; - integrate_impulse += value/16; - integrate_step += integrate_impulse/16; - } - step[i] = (float) integrate_impulse; - ramp[i] = (float) integrate_step; + for (j=0; j < 16; ++j) { + float sinc_t = 3.141592f* (i-half) / oversample; + float sinc = (i==half) ? 1.0f : (float) sin(sinc_t) / (sinc_t); + float wt = 2.0f*3.1415926f * i / (n-1); + float window = (float) (0.355768 - 0.487396*cos(wt) + 0.144232*cos(2*wt) - 0.012604*cos(3*wt)); // Nuttall + double value = window * sinc; + integrate_impulse += value/16; + integrate_step += integrate_impulse/16; + } + step[i] = (float) integrate_impulse; + ramp[i] = (float) integrate_step; } // renormalize for (i=0; i < n; ++i) { - step[i] = step[i] * (float) (1.0 / step[n-1]); // step needs to reach to 1.0 - ramp[i] = ramp[i] * (float) (halfwidth / ramp[n-1]); // ramp needs to become a slope of 1.0 after oversampling + step[i] = step[i] * (float) (1.0 / step[n-1]); // step needs to reach to 1.0 + ramp[i] = ramp[i] * (float) (halfwidth / ramp[n-1]); // ramp needs to become a slope of 1.0 after oversampling } // deinterleave to allow efficient interpolation e.g. w/SIMD for (j=0; j <= oversample; ++j) { - for (i=0; i < width; ++i) { - blep_buffer [j*width+i] = step[j+i*oversample]; - blamp_buffer[j*width+i] = ramp[j+i*oversample]; - } + for (i=0; i < width; ++i) { + blep_buffer [j*width+i] = step[j+i*oversample]; + blamp_buffer[j*width+i] = ramp[j+i*oversample]; + } } // subtract out the naive waveform; note we can't do this to the raw data // above, because we want the discontinuity to be in a different locations // for j=0 and j=oversample (which exists to provide something to interpolate against) for (j=0; j <= oversample; ++j) { - // subtract step - for (i=halfwidth; i < width; ++i) - blep_buffer [j*width+i] -= 1.0f; - // subtract ramp - for (i=halfwidth; i < width; ++i) - blamp_buffer[j*width+i] -= (j+i*oversample-half)*(1.0f/oversample); + // subtract step + for (i=halfwidth; i < width; ++i) + blep_buffer [j*width+i] -= 1.0f; + // subtract ramp + for (i=halfwidth; i < width; ++i) + blamp_buffer[j*width+i] -= (j+i*oversample-half)*(1.0f/oversample); } hexblep.blep = blep_buffer; @@ -630,10 +628,10 @@ STB_HEXWAVE_DEF void hexwave_init(int width, int oversample, float *user_buffer) hexblep.width = width; hexblep.oversample = oversample; - #ifndef STB_HEXWAVE_NO_ALLOCATION +#ifndef STB_HEXWAVE_NO_ALLOCATION if (user_buffer == 0) - free(buffers); - #endif + free(buffers); +#endif } #endif // STB_HEXWAVE_IMPLEMENTATION diff --git a/fggl/stb/stb_image_write.h b/fggl/stb/stb_image_write.h index e4b32ed1bc32ef9c962acbf47a9d10af01939e08..1f1b2806904f7f4c176075c37754162e7f62400b 100644 --- a/fggl/stb/stb_image_write.h +++ b/fggl/stb/stb_image_write.h @@ -173,11 +173,11 @@ STBIWDEF int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); -STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); -STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #ifdef STBIW_WINDOWS_UTF8 STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); @@ -186,11 +186,23 @@ STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const w typedef void stbi_write_func(void *context, void *data, int size); -STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); -STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, + void *context, + int w, + int h, + int comp, + const void *data, + int stride_in_bytes); +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); -STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, + void *context, + int x, + int y, + int comp, + const void *data, + int quality); STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); @@ -199,12 +211,12 @@ STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 - #ifndef _CRT_SECURE_NO_WARNINGS - #define _CRT_SECURE_NO_WARNINGS - #endif - #ifndef _CRT_NONSTDC_NO_DEPRECATE - #define _CRT_NONSTDC_NO_DEPRECATE - #endif + #ifndef _CRT_SECURE_NO_WARNINGS + #define _CRT_SECURE_NO_WARNINGS + #endif + #ifndef _CRT_NONSTDC_NO_DEPRECATE + #define _CRT_NONSTDC_NO_DEPRECATE + #endif #endif #ifndef STBI_WRITE_NO_STDIO @@ -308,21 +320,21 @@ static FILE *stbiw__fopen(char const *filename, char const *mode) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename))) - return 0; + return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode))) - return 0; + return 0; #if defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) - f = 0; + f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) - f=0; + f=0; #else f = fopen(filename, mode); #endif @@ -349,29 +361,29 @@ typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { - switch (*fmt++) { - case ' ': break; - case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); - s->func(s->context,&x,1); - break; } - case '2': { int x = va_arg(v,int); - unsigned char b[2]; - b[0] = STBIW_UCHAR(x); - b[1] = STBIW_UCHAR(x>>8); - s->func(s->context,b,2); - break; } - case '4': { stbiw_uint32 x = va_arg(v,int); - unsigned char b[4]; - b[0]=STBIW_UCHAR(x); - b[1]=STBIW_UCHAR(x>>8); - b[2]=STBIW_UCHAR(x>>16); - b[3]=STBIW_UCHAR(x>>24); - s->func(s->context,b,4); - break; } - default: - STBIW_ASSERT(0); - return; - } + switch (*fmt++) { + case ' ': break; + case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); + s->func(s->context,&x,1); + break; } + case '2': { int x = va_arg(v,int); + unsigned char b[2]; + b[0] = STBIW_UCHAR(x); + b[1] = STBIW_UCHAR(x>>8); + s->func(s->context,b,2); + break; } + case '4': { stbiw_uint32 x = va_arg(v,int); + unsigned char b[4]; + b[0]=STBIW_UCHAR(x); + b[1]=STBIW_UCHAR(x>>8); + b[2]=STBIW_UCHAR(x>>16); + b[3]=STBIW_UCHAR(x>>24); + s->func(s->context,b,4); + break; } + default: + STBIW_ASSERT(0); + return; + } } } @@ -386,8 +398,8 @@ static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) static void stbiw__write_flush(stbi__write_context *s) { if (s->buf_used) { - s->func(s->context, &s->buffer, s->buf_used); - s->buf_used = 0; + s->func(s->context, &s->buffer, s->buf_used); + s->buf_used = 0; } } @@ -399,7 +411,7 @@ static void stbiw__putc(stbi__write_context *s, unsigned char c) static void stbiw__write1(stbi__write_context *s, unsigned char a) { if ((size_t)s->buf_used + 1 > sizeof(s->buffer)) - stbiw__write_flush(s); + stbiw__write_flush(s); s->buffer[s->buf_used++] = a; } @@ -407,7 +419,7 @@ static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char { int n; if ((size_t)s->buf_used + 3 > sizeof(s->buffer)) - stbiw__write_flush(s); + stbiw__write_flush(s); n = s->buf_used; s->buf_used = n+3; s->buffer[n+0] = a; @@ -421,31 +433,31 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in int k; if (write_alpha < 0) - stbiw__write1(s, d[comp - 1]); + stbiw__write1(s, d[comp - 1]); switch (comp) { - case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case - case 1: - if (expand_mono) - stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp - else - stbiw__write1(s, d[0]); // monochrome TGA - break; - case 4: - if (!write_alpha) { - // composite against pink background - for (k = 0; k < 3; ++k) - px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; - stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); - break; - } - /* FALLTHROUGH */ - case 3: - stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); - break; + case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case + case 1: + if (expand_mono) + stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp + else + stbiw__write1(s, d[0]); // monochrome TGA + break; + case 4: + if (!write_alpha) { + // composite against pink background + for (k = 0; k < 3; ++k) + px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; + stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); + break; + } + /* FALLTHROUGH */ + case 3: + stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); + break; } if (write_alpha > 0) - stbiw__write1(s, d[comp - 1]); + stbiw__write1(s, d[comp - 1]); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) @@ -454,58 +466,58 @@ static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, i int i,j, j_end; if (y <= 0) - return; + return; if (stbi__flip_vertically_on_write) - vdir *= -1; + vdir *= -1; if (vdir < 0) { - j_end = -1; j = y-1; + j_end = -1; j = y-1; } else { - j_end = y; j = 0; + j_end = y; j = 0; } for (; j != j_end; j += vdir) { - for (i=0; i < x; ++i) { - unsigned char *d = (unsigned char *) data + (j*x+i)*comp; - stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); - } - stbiw__write_flush(s); - s->func(s->context, &zero, scanline_pad); + for (i=0; i < x; ++i) { + unsigned char *d = (unsigned char *) data + (j*x+i)*comp; + stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); + } + stbiw__write_flush(s); + s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { - return 0; + return 0; } else { - va_list v; - va_start(v, fmt); - stbiw__writefv(s, fmt, v); - va_end(v); - stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); - return 1; + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); + stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); + return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { if (comp != 4) { - // write RGB bitmap - int pad = (-x*3) & 3; - return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, - "11 4 22 4" "4 44 22 444444", - 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header - 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header + // write RGB bitmap + int pad = (-x*3) & 3; + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, + "11 4 22 4" "4 44 22 444444", + 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header + 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } else { - // RGBA bitmaps need a v4 header - // use BI_BITFIELDS mode with 32bpp and alpha mask - // (straight BI_RGB with alpha mask doesn't work in most readers) - return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0, - "11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444", - 'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header - 108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header + // RGBA bitmaps need a v4 header + // use BI_BITFIELDS mode with 32bpp and alpha mask + // (straight BI_RGB with alpha mask doesn't work in most readers) + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0, + "11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444", + 'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header + 108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header } } @@ -521,11 +533,11 @@ STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_bmp_core(&s, x, y, comp, data); - stbi__end_write_file(&s); - return r; + int r = stbi_write_bmp_core(&s, x, y, comp, data); + stbi__end_write_file(&s); + return r; } else - return 0; + return 0; } #endif //!STBI_WRITE_NO_STDIO @@ -536,74 +548,74 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) - return 0; + return 0; if (!stbi_write_tga_with_rle) { - return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, - "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); + return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, + "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { - int i,j,k; - int jend, jdir; - - stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); - - if (stbi__flip_vertically_on_write) { - j = 0; - jend = y; - jdir = 1; - } else { - j = y-1; - jend = -1; - jdir = -1; - } - for (; j != jend; j += jdir) { - unsigned char *row = (unsigned char *) data + j * x * comp; - int len; - - for (i = 0; i < x; i += len) { - unsigned char *begin = row + i * comp; - int diff = 1; - len = 1; - - if (i < x - 1) { - ++len; - diff = memcmp(begin, row + (i + 1) * comp, comp); - if (diff) { - const unsigned char *prev = begin; - for (k = i + 2; k < x && len < 128; ++k) { - if (memcmp(prev, row + k * comp, comp)) { - prev += comp; - ++len; - } else { - --len; - break; - } - } - } else { - for (k = i + 2; k < x && len < 128; ++k) { - if (!memcmp(begin, row + k * comp, comp)) { - ++len; - } else { - break; - } - } - } - } - - if (diff) { - unsigned char header = STBIW_UCHAR(len - 1); - stbiw__write1(s, header); - for (k = 0; k < len; ++k) { - stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); - } - } else { - unsigned char header = STBIW_UCHAR(len - 129); - stbiw__write1(s, header); - stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); - } - } - } - stbiw__write_flush(s); + int i,j,k; + int jend, jdir; + + stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); + + if (stbi__flip_vertically_on_write) { + j = 0; + jend = y; + jdir = 1; + } else { + j = y-1; + jend = -1; + jdir = -1; + } + for (; j != jend; j += jdir) { + unsigned char *row = (unsigned char *) data + j * x * comp; + int len; + + for (i = 0; i < x; i += len) { + unsigned char *begin = row + i * comp; + int diff = 1; + len = 1; + + if (i < x - 1) { + ++len; + diff = memcmp(begin, row + (i + 1) * comp, comp); + if (diff) { + const unsigned char *prev = begin; + for (k = i + 2; k < x && len < 128; ++k) { + if (memcmp(prev, row + k * comp, comp)) { + prev += comp; + ++len; + } else { + --len; + break; + } + } + } else { + for (k = i + 2; k < x && len < 128; ++k) { + if (!memcmp(begin, row + k * comp, comp)) { + ++len; + } else { + break; + } + } + } + } + + if (diff) { + unsigned char header = STBIW_UCHAR(len - 1); + stbiw__write1(s, header); + for (k = 0; k < len; ++k) { + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); + } + } else { + unsigned char header = STBIW_UCHAR(len - 129); + stbiw__write1(s, header); + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); + } + } + } + stbiw__write_flush(s); } return 1; } @@ -620,11 +632,11 @@ STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); - stbi__end_write_file(&s); - return r; + int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); + stbi__end_write_file(&s); + return r; } else - return 0; + return 0; } #endif @@ -642,14 +654,14 @@ static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { - rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; + rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { - float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; + float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; - rgbe[0] = (unsigned char)(linear[0] * normalize); - rgbe[1] = (unsigned char)(linear[1] * normalize); - rgbe[2] = (unsigned char)(linear[2] * normalize); - rgbe[3] = (unsigned char)(exponent + 128); + rgbe[0] = (unsigned char)(linear[0] * normalize); + rgbe[1] = (unsigned char)(linear[1] * normalize); + rgbe[2] = (unsigned char)(linear[2] * normalize); + rgbe[3] = (unsigned char)(exponent + 128); } } @@ -681,106 +693,106 @@ static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int nco /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { - for (x=0; x < width; x++) { - switch (ncomp) { - case 4: /* fallthrough */ - case 3: linear[2] = scanline[x*ncomp + 2]; - linear[1] = scanline[x*ncomp + 1]; - linear[0] = scanline[x*ncomp + 0]; - break; - default: - linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; - break; - } - stbiw__linear_to_rgbe(rgbe, linear); - s->func(s->context, rgbe, 4); - } + for (x=0; x < width; x++) { + switch (ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + s->func(s->context, rgbe, 4); + } } else { - int c,r; - /* encode into scratch buffer */ - for (x=0; x < width; x++) { - switch(ncomp) { - case 4: /* fallthrough */ - case 3: linear[2] = scanline[x*ncomp + 2]; - linear[1] = scanline[x*ncomp + 1]; - linear[0] = scanline[x*ncomp + 0]; - break; - default: - linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; - break; - } - stbiw__linear_to_rgbe(rgbe, linear); - scratch[x + width*0] = rgbe[0]; - scratch[x + width*1] = rgbe[1]; - scratch[x + width*2] = rgbe[2]; - scratch[x + width*3] = rgbe[3]; - } - - s->func(s->context, scanlineheader, 4); - - /* RLE each component separately */ - for (c=0; c < 4; c++) { - unsigned char *comp = &scratch[width*c]; - - x = 0; - while (x < width) { - // find first run - r = x; - while (r+2 < width) { - if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) - break; - ++r; - } - if (r+2 >= width) - r = width; - // dump up to first run - while (x < r) { - int len = r-x; - if (len > 128) len = 128; - stbiw__write_dump_data(s, len, &comp[x]); - x += len; - } - // if there's a run, output it - if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd - // find next byte after run - while (r < width && comp[r] == comp[x]) - ++r; - // output run up to r - while (x < r) { - int len = r-x; - if (len > 127) len = 127; - stbiw__write_run_data(s, len, comp[x]); - x += len; - } - } - } - } + int c,r; + /* encode into scratch buffer */ + for (x=0; x < width; x++) { + switch(ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + scratch[x + width*0] = rgbe[0]; + scratch[x + width*1] = rgbe[1]; + scratch[x + width*2] = rgbe[2]; + scratch[x + width*3] = rgbe[3]; + } + + s->func(s->context, scanlineheader, 4); + + /* RLE each component separately */ + for (c=0; c < 4; c++) { + unsigned char *comp = &scratch[width*c]; + + x = 0; + while (x < width) { + // find first run + r = x; + while (r+2 < width) { + if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) + break; + ++r; + } + if (r+2 >= width) + r = width; + // dump up to first run + while (x < r) { + int len = r-x; + if (len > 128) len = 128; + stbiw__write_dump_data(s, len, &comp[x]); + x += len; + } + // if there's a run, output it + if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd + // find next byte after run + while (r < width && comp[r] == comp[x]) + ++r; + // output run up to r + while (x < r) { + int len = r-x; + if (len > 127) len = 127; + stbiw__write_run_data(s, len, comp[x]); + x += len; + } + } + } + } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) - return 0; + return 0; else { - // Each component is stored separately. Allocate scratch space for full output scanline. - unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); - int i, len; - char buffer[128]; - char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; - s->func(s->context, header, sizeof(header)-1); + // Each component is stored separately. Allocate scratch space for full output scanline. + unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); + int i, len; + char buffer[128]; + char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; + s->func(s->context, header, sizeof(header)-1); #ifdef __STDC_LIB_EXT1__ - len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); + len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else - len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); + len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif - s->func(s->context, buffer, len); + s->func(s->context, buffer, len); - for(i=0; i < y; i++) - stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); - STBIW_FREE(scratch); - return 1; + for(i=0; i < y; i++) + stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); + STBIW_FREE(scratch); + return 1; } } @@ -795,11 +807,11 @@ STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); - stbi__end_write_file(&s); - return r; + int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); + stbi__end_write_file(&s); + return r; } else - return 0; + return 0; } #endif // STBI_WRITE_NO_STDIO @@ -829,9 +841,9 @@ static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { - if (!*arr) ((int *) p)[1] = 0; - *arr = (void *) ((int *) p + 2); - stbiw__sbm(*arr) = m; + if (!*arr) ((int *) p)[1] = 0; + *arr = (void *) ((int *) p + 2); + stbiw__sbm(*arr) = m; } return *arr; } @@ -839,9 +851,9 @@ static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { - stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); - *bitbuffer >>= 8; - *bitcount -= 8; + stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); + *bitbuffer >>= 8; + *bitcount -= 8; } return data; } @@ -850,8 +862,8 @@ static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { - res = (res << 1) | (code & 1); - code >>= 1; + res = (res << 1) | (code & 1); + code >>= 1; } return res; } @@ -860,7 +872,7 @@ static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int l { int i; for (i=0; i < limit && i < 258; ++i) - if (a[i] != b[i]) break; + if (a[i] != b[i]) break; return i; } @@ -878,7 +890,7 @@ static unsigned int stbiw__zhash(unsigned char *data) #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ - (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) + (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) @@ -907,7 +919,7 @@ STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, i unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**)); if (hash_table == NULL) - return NULL; + return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window @@ -916,103 +928,103 @@ STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, i stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) - hash_table[i] = NULL; + hash_table[i] = NULL; i=0; while (i < data_len-3) { - // hash next 3 bytes of data to be compressed - int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; - unsigned char *bestloc = 0; - unsigned char **hlist = hash_table[h]; - int n = stbiw__sbcount(hlist); - for (j=0; j < n; ++j) { - if (hlist[j]-data > i-32768) { // if entry lies within window - int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); - if (d >= best) { best=d; bestloc=hlist[j]; } - } - } - // when hash table entry is too long, delete half the entries - if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { - STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); - stbiw__sbn(hash_table[h]) = quality; - } - stbiw__sbpush(hash_table[h],data+i); - - if (bestloc) { - // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal - h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); - hlist = hash_table[h]; - n = stbiw__sbcount(hlist); - for (j=0; j < n; ++j) { - if (hlist[j]-data > i-32767) { - int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); - if (e > best) { // if next match is better, bail on current match - bestloc = NULL; - break; - } - } - } - } - - if (bestloc) { - int d = (int) (data+i - bestloc); // distance back - STBIW_ASSERT(d <= 32767 && best <= 258); - for (j=0; best > lengthc[j+1]-1; ++j); - stbiw__zlib_huff(j+257); - if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); - for (j=0; d > distc[j+1]-1; ++j); - stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); - if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); - i += best; - } else { - stbiw__zlib_huffb(data[i]); - ++i; - } + // hash next 3 bytes of data to be compressed + int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; + unsigned char *bestloc = 0; + unsigned char **hlist = hash_table[h]; + int n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32768) { // if entry lies within window + int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); + if (d >= best) { best=d; bestloc=hlist[j]; } + } + } + // when hash table entry is too long, delete half the entries + if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { + STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); + stbiw__sbn(hash_table[h]) = quality; + } + stbiw__sbpush(hash_table[h],data+i); + + if (bestloc) { + // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal + h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); + hlist = hash_table[h]; + n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32767) { + int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); + if (e > best) { // if next match is better, bail on current match + bestloc = NULL; + break; + } + } + } + } + + if (bestloc) { + int d = (int) (data+i - bestloc); // distance back + STBIW_ASSERT(d <= 32767 && best <= 258); + for (j=0; best > lengthc[j+1]-1; ++j); + stbiw__zlib_huff(j+257); + if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); + for (j=0; d > distc[j+1]-1; ++j); + stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); + if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); + i += best; + } else { + stbiw__zlib_huffb(data[i]); + ++i; + } } // write out final bytes for (;i < data_len; ++i) - stbiw__zlib_huffb(data[i]); + stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) - stbiw__zlib_add(0,1); + stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) - (void) stbiw__sbfree(hash_table[i]); + (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); // store uncompressed instead if compression was worse if (stbiw__sbn(out) > data_len + 2 + ((data_len+32766)/32767)*5) { - stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1 - for (j = 0; j < data_len;) { - int blocklen = data_len - j; - if (blocklen > 32767) blocklen = 32767; - stbiw__sbpush(out, data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression - stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN - stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8)); - stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN - stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8)); - memcpy(out+stbiw__sbn(out), data+j, blocklen); - stbiw__sbn(out) += blocklen; - j += blocklen; - } + stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1 + for (j = 0; j < data_len;) { + int blocklen = data_len - j; + if (blocklen > 32767) blocklen = 32767; + stbiw__sbpush(out, data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression + stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN + stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN + stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8)); + memcpy(out+stbiw__sbn(out), data+j, blocklen); + stbiw__sbn(out) += blocklen; + j += blocklen; + } } { - // compute adler32 on input - unsigned int s1=1, s2=0; - int blocklen = (int) (data_len % 5552); - j=0; - while (j < data_len) { - for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } - s1 %= 65521; s2 %= 65521; - j += blocklen; - blocklen = 5552; - } - stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); - stbiw__sbpush(out, STBIW_UCHAR(s2)); - stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); - stbiw__sbpush(out, STBIW_UCHAR(s1)); + // compute adler32 on input + unsigned int s1=1, s2=0; + int blocklen = (int) (data_len % 5552); + j=0; + while (j < data_len) { + for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } + s1 %= 65521; s2 %= 65521; + j += blocklen; + blocklen = 5552; + } + stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s2)); + stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable @@ -1024,48 +1036,48 @@ STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, i static unsigned int stbiw__crc32(unsigned char *buffer, int len) { #ifdef STBIW_CRC32 - return STBIW_CRC32(buffer, len); + return STBIW_CRC32(buffer, len); #else static unsigned int crc_table[256] = { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) - crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; + crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; #endif } @@ -1100,28 +1112,28 @@ static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; if (type==0) { - memcpy(line_buffer, z, width*n); - return; + memcpy(line_buffer, z, width*n); + return; } // first loop isn't optimized since it's just one pixel for (i = 0; i < n; ++i) { - switch (type) { - case 1: line_buffer[i] = z[i]; break; - case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; - case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; - case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; - case 5: line_buffer[i] = z[i]; break; - case 6: line_buffer[i] = z[i]; break; - } + switch (type) { + case 1: line_buffer[i] = z[i]; break; + case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; + case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; + case 5: line_buffer[i] = z[i]; break; + case 6: line_buffer[i] = z[i]; break; + } } switch (type) { - case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; - case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; - case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; - case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; - case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; - case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; + case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; + case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; + case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; + case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; + case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } @@ -1135,42 +1147,42 @@ STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int s int j,zlen; if (stride_bytes == 0) - stride_bytes = x * n; + stride_bytes = x * n; if (force_filter >= 5) { - force_filter = -1; + force_filter = -1; } filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { - int filter_type; - if (force_filter > -1) { - filter_type = force_filter; - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); - } else { // Estimate the best filter by running through all of them: - int best_filter = 0, best_filter_val = 0x7fffffff, est, i; - for (filter_type = 0; filter_type < 5; filter_type++) { - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); - - // Estimate the entropy of the line using this filter; the less, the better. - est = 0; - for (i = 0; i < x*n; ++i) { - est += abs((signed char) line_buffer[i]); - } - if (est < best_filter_val) { - best_filter_val = est; - best_filter = filter_type; - } - } - if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); - filter_type = best_filter; - } - } - // when we get here, filter_type contains the filter type, and line_buffer contains the data - filt[j*(x*n+1)] = (unsigned char) filter_type; - STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); + int filter_type; + if (force_filter > -1) { + filter_type = force_filter; + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); + } else { // Estimate the best filter by running through all of them: + int best_filter = 0, best_filter_val = 0x7fffffff, est, i; + for (filter_type = 0; filter_type < 5; filter_type++) { + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); + + // Estimate the entropy of the line using this filter; the less, the better. + est = 0; + for (i = 0; i < x*n; ++i) { + est += abs((signed char) line_buffer[i]); + } + if (est < best_filter_val) { + best_filter_val = est; + best_filter = filter_type; + } + } + if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); + filter_type = best_filter; + } + } + // when we get here, filter_type contains the filter type, and line_buffer contains the data + filt[j*(x*n+1)] = (unsigned char) filter_type; + STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); @@ -1248,20 +1260,20 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, - 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; + 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { - unsigned char c = (bitBuf >> 16) & 255; - stbiw__putc(s, c); - if(c == 255) { - stbiw__putc(s, 0); - } - bitBuf <<= 8; - bitCnt -= 8; + unsigned char c = (bitBuf >> 16) & 255; + stbiw__putc(s, c); + if(c == 255) { + stbiw__putc(s, 0); + } + bitBuf <<= 8; + bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; @@ -1320,7 +1332,7 @@ static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { - ++bits[1]; + ++bits[1]; } bits[0] = val & ((1<<bits[1])-1); } @@ -1333,34 +1345,34 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt // DCT rows for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) { - stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]); + stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]); } // DCT columns for(dataOff=0; dataOff<8; ++dataOff) { - stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4], - &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]); + stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4], + &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]); } // Quantize/descale/zigzag the coefficients for(y = 0, j=0; y < 8; ++y) { - for(x = 0; x < 8; ++x,++j) { - float v; - i = y*du_stride+x; - v = CDU[i]*fdtbl[j]; - // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f)); - // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway? - DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f); - } + for(x = 0; x < 8; ++x,++j) { + float v; + i = y*du_stride+x; + v = CDU[i]*fdtbl[j]; + // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f)); + // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway? + DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f); + } } // Encode DC diff = DU[0] - DC; if (diff == 0) { - stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]); } else { - unsigned short bits[2]; - stbiw__jpg_calcBits(diff, bits); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + unsigned short bits[2]; + stbiw__jpg_calcBits(diff, bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } // Encode ACs end0pos = 63; @@ -1368,29 +1380,29 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt } // end0pos = first element in reverse order !=0 if(end0pos == 0) { - stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); - return DU[0]; + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + return DU[0]; } for(i = 1; i <= end0pos; ++i) { - int startpos = i; - int nrzeroes; - unsigned short bits[2]; - for (; DU[i]==0 && i<=end0pos; ++i) { - } - nrzeroes = i-startpos; - if ( nrzeroes >= 16 ) { - int lng = nrzeroes>>4; - int nrmarker; - for (nrmarker=1; nrmarker <= lng; ++nrmarker) - stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); - nrzeroes &= 15; - } - stbiw__jpg_calcBits(DU[i], bits); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + int startpos = i; + int nrzeroes; + unsigned short bits[2]; + for (; DU[i]==0 && i<=end0pos; ++i) { + } + nrzeroes = i-startpos; + if ( nrzeroes >= 16 ) { + int lng = nrzeroes>>4; + int nrmarker; + for (nrmarker=1; nrmarker <= lng; ++nrmarker) + stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); + nrzeroes &= 15; + } + stbiw__jpg_calcBits(DU[i], bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { - stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } @@ -1401,78 +1413,78 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { - 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, - 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, - 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, - 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, - 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, - 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, - 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, + 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, + 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, + 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, + 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { - 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, - 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, - 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, - 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, - 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, - 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, - 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, + 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, + 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, + 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, + 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { - {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { - {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, - 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; + 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, - 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; + 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, - 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; + 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k, subsample; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { - return 0; + return 0; } quality = quality ? quality : 90; @@ -1481,120 +1493,120 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { - int uvti, yti = (YQT[i]*quality+50)/100; - YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); - uvti = (UVQT[i]*quality+50)/100; - UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); + int uvti, yti = (YQT[i]*quality+50)/100; + YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); + uvti = (UVQT[i]*quality+50)/100; + UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { - for(col = 0; col < 8; ++col, ++k) { - fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); - fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); - } + for(col = 0; col < 8; ++col, ++k) { + fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + } } // Write Headers { - static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; - static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; - const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), - 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; - s->func(s->context, (void*)head0, sizeof(head0)); - s->func(s->context, (void*)YTable, sizeof(YTable)); - stbiw__putc(s, 1); - s->func(s->context, UVTable, sizeof(UVTable)); - s->func(s->context, (void*)head1, sizeof(head1)); - s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); - s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); - stbiw__putc(s, 0x10); // HTYACinfo - s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); - s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); - stbiw__putc(s, 1); // HTUDCinfo - s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); - s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); - stbiw__putc(s, 0x11); // HTUACinfo - s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); - s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); - s->func(s->context, (void*)head2, sizeof(head2)); + static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; + static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; + const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), + 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; + s->func(s->context, (void*)head0, sizeof(head0)); + s->func(s->context, (void*)YTable, sizeof(YTable)); + stbiw__putc(s, 1); + s->func(s->context, UVTable, sizeof(UVTable)); + s->func(s->context, (void*)head1, sizeof(head1)); + s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); + s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); + stbiw__putc(s, 0x10); // HTYACinfo + s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); + s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); + stbiw__putc(s, 1); // HTUDCinfo + s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); + stbiw__putc(s, 0x11); // HTUACinfo + s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); + s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { - static const unsigned short fillBits[] = {0x7F, 7}; - int DCY=0, DCU=0, DCV=0; - int bitBuf=0, bitCnt=0; - // comp == 2 is grey+alpha (alpha is ignored) - int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; - const unsigned char *dataR = (const unsigned char *)data; - const unsigned char *dataG = dataR + ofsG; - const unsigned char *dataB = dataR + ofsB; - int x, y, pos; - if(subsample) { - for(y = 0; y < height; y += 16) { - for(x = 0; x < width; x += 16) { - float Y[256], U[256], V[256]; - for(row = y, pos = 0; row < y+16; ++row) { - // row >= height => use last input row - int clamped_row = (row < height) ? row : height - 1; - int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; - for(col = x; col < x+16; ++col, ++pos) { - // if col >= width => use pixel from last input column - int p = base_p + ((col < width) ? col : (width-1))*comp; - float r = dataR[p], g = dataG[p], b = dataB[p]; - Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; - U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; - V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; - } - } - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - - // subsample U,V - { - float subU[64], subV[64]; - int yy, xx; - for(yy = 0, pos = 0; yy < 8; ++yy) { - for(xx = 0; xx < 8; ++xx, ++pos) { - int j = yy*32+xx*2; - subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; - subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; - } - } - DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); - DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); - } - } - } - } else { - for(y = 0; y < height; y += 8) { - for(x = 0; x < width; x += 8) { - float Y[64], U[64], V[64]; - for(row = y, pos = 0; row < y+8; ++row) { - // row >= height => use last input row - int clamped_row = (row < height) ? row : height - 1; - int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; - for(col = x; col < x+8; ++col, ++pos) { - // if col >= width => use pixel from last input column - int p = base_p + ((col < width) ? col : (width-1))*comp; - float r = dataR[p], g = dataG[p], b = dataB[p]; - Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; - U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; - V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; - } - } - - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); - DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); - } - } - } - - // Do the bit alignment of the EOI marker - stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); + static const unsigned short fillBits[] = {0x7F, 7}; + int DCY=0, DCU=0, DCV=0; + int bitBuf=0, bitCnt=0; + // comp == 2 is grey+alpha (alpha is ignored) + int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; + const unsigned char *dataR = (const unsigned char *)data; + const unsigned char *dataG = dataR + ofsG; + const unsigned char *dataB = dataR + ofsB; + int x, y, pos; + if(subsample) { + for(y = 0; y < height; y += 16) { + for(x = 0; x < width; x += 16) { + float Y[256], U[256], V[256]; + for(row = y, pos = 0; row < y+16; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+16; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + + // subsample U,V + { + float subU[64], subV[64]; + int yy, xx; + for(yy = 0, pos = 0; yy < 8; ++yy) { + for(xx = 0; xx < 8; ++xx, ++pos) { + int j = yy*32+xx*2; + subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; + subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; + } + } + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + } else { + for(y = 0; y < height; y += 8) { + for(x = 0; x < width; x += 8) { + float Y[64], U[64], V[64]; + for(row = y, pos = 0; row < y+8; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+8; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + + // Do the bit alignment of the EOI marker + stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI @@ -1617,11 +1629,11 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); - stbi__end_write_file(&s); - return r; + int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); + stbi__end_write_file(&s); + return r; } else - return 0; + return 0; } #endif diff --git a/fggl/stb/stb_rect_pack.h b/fggl/stb/stb_rect_pack.h index 6a633ce666a8600d7d974996fea072faabe939b3..79416d516e442067b1ef9dab6f64963bf581bc31 100644 --- a/fggl/stb/stb_rect_pack.h +++ b/fggl/stb/stb_rect_pack.h @@ -79,15 +79,15 @@ extern "C" { #endif typedef struct stbrp_context stbrp_context; -typedef struct stbrp_node stbrp_node; -typedef struct stbrp_rect stbrp_rect; +typedef struct stbrp_node stbrp_node; +typedef struct stbrp_rect stbrp_rect; -typedef int stbrp_coord; +typedef int stbrp_coord; #define STBRP__MAXVAL 0x7fffffff // Mostly for internal use, but this is the maximum supported coordinate value. -STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); +STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects); // Assign packed locations to rectangles. The rectangles are of type // 'stbrp_rect' defined below, stored in the array 'rects', and there // are 'num_rects' many of them. @@ -112,22 +112,21 @@ STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int n // The function returns 1 if all of the rectangles were successfully // packed and 0 otherwise. -struct stbrp_rect -{ - // reserved for your use: - int id; +struct stbrp_rect { + // reserved for your use: + int id; - // input: - stbrp_coord w, h; + // input: + stbrp_coord w, h; - // output: - stbrp_coord x, y; - int was_packed; // non-zero if valid packing + // output: + stbrp_coord x, y; + int was_packed; // non-zero if valid packing }; // 16 bytes, nominally -STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); +STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); // Initialize a rectangle packer to: // pack a rectangle that is 'width' by 'height' in dimensions // using temporary storage provided by the array 'nodes', which is 'num_nodes' long @@ -148,22 +147,21 @@ STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, // If you do #2, then the non-quantized algorithm will be used, but the algorithm // may run out of temporary storage and be unable to pack some rectangles. -STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); +STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem); // Optionally call this function after init but before doing any packing to // change the handling of the out-of-temp-memory scenario, described above. // If you call init again, this will be reset to the default (false). -STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); +STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic); // Optionally select which packing heuristic the library should use. Different // heuristics will produce better/worse results for different data sets. // If you call init again, this will be reset to the default. -enum -{ - STBRP_HEURISTIC_Skyline_default=0, - STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, - STBRP_HEURISTIC_Skyline_BF_sortHeight +enum { + STBRP_HEURISTIC_Skyline_default = 0, + STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, + STBRP_HEURISTIC_Skyline_BF_sortHeight }; @@ -172,23 +170,21 @@ enum // the details of the following structures don't matter to you, but they must // be visible so you can handle the memory allocations for them -struct stbrp_node -{ - stbrp_coord x,y; - stbrp_node *next; +struct stbrp_node { + stbrp_coord x, y; + stbrp_node *next; }; -struct stbrp_context -{ - int width; - int height; - int align; - int init_mode; - int heuristic; - int num_nodes; - stbrp_node *active_head; - stbrp_node *free_head; - stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' +struct stbrp_context { + int width; + int height; + int align; + int init_mode; + int heuristic; + int num_nodes; + stbrp_node *active_head; + stbrp_node *free_head; + stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' }; #ifdef __cplusplus @@ -205,11 +201,13 @@ struct stbrp_context #ifdef STB_RECT_PACK_IMPLEMENTATION #ifndef STBRP_SORT #include <stdlib.h> + #define STBRP_SORT qsort #endif #ifndef STBRP_ASSERT #include <assert.h> + #define STBRP_ASSERT assert #endif @@ -221,363 +219,352 @@ struct stbrp_context #define STBRP__CDECL #endif -enum -{ - STBRP__INIT_skyline = 1 +enum { + STBRP__INIT_skyline = 1 }; -STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) -{ - switch (context->init_mode) { - case STBRP__INIT_skyline: - STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); - context->heuristic = heuristic; - break; - default: - STBRP_ASSERT(0); - } +STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) { + switch (context->init_mode) { + case STBRP__INIT_skyline:STBRP_ASSERT( + heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); + context->heuristic = heuristic; + break; + default:STBRP_ASSERT(0); + } } -STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) -{ - if (allow_out_of_mem) - // if it's ok to run out of memory, then don't bother aligning them; - // this gives better packing, but may fail due to OOM (even though - // the rectangles easily fit). @TODO a smarter approach would be to only - // quantize once we've hit OOM, then we could get rid of this parameter. - context->align = 1; - else { - // if it's not ok to run out of memory, then quantize the widths - // so that num_nodes is always enough nodes. - // - // I.e. num_nodes * align >= width - // align >= width / num_nodes - // align = ceil(width/num_nodes) - - context->align = (context->width + context->num_nodes-1) / context->num_nodes; - } +STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) { + if (allow_out_of_mem) + // if it's ok to run out of memory, then don't bother aligning them; + // this gives better packing, but may fail due to OOM (even though + // the rectangles easily fit). @TODO a smarter approach would be to only + // quantize once we've hit OOM, then we could get rid of this parameter. + context->align = 1; + else { + // if it's not ok to run out of memory, then quantize the widths + // so that num_nodes is always enough nodes. + // + // I.e. num_nodes * align >= width + // align >= width / num_nodes + // align = ceil(width/num_nodes) + + context->align = (context->width + context->num_nodes - 1) / context->num_nodes; + } } -STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) -{ - int i; - - for (i=0; i < num_nodes-1; ++i) - nodes[i].next = &nodes[i+1]; - nodes[i].next = NULL; - context->init_mode = STBRP__INIT_skyline; - context->heuristic = STBRP_HEURISTIC_Skyline_default; - context->free_head = &nodes[0]; - context->active_head = &context->extra[0]; - context->width = width; - context->height = height; - context->num_nodes = num_nodes; - stbrp_setup_allow_out_of_mem(context, 0); - - // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) - context->extra[0].x = 0; - context->extra[0].y = 0; - context->extra[0].next = &context->extra[1]; - context->extra[1].x = (stbrp_coord) width; - context->extra[1].y = (1<<30); - context->extra[1].next = NULL; +STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) { + int i; + + for (i = 0; i < num_nodes - 1; ++i) + nodes[i].next = &nodes[i + 1]; + nodes[i].next = NULL; + context->init_mode = STBRP__INIT_skyline; + context->heuristic = STBRP_HEURISTIC_Skyline_default; + context->free_head = &nodes[0]; + context->active_head = &context->extra[0]; + context->width = width; + context->height = height; + context->num_nodes = num_nodes; + stbrp_setup_allow_out_of_mem(context, 0); + + // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) + context->extra[0].x = 0; + context->extra[0].y = 0; + context->extra[0].next = &context->extra[1]; + context->extra[1].x = (stbrp_coord) width; + context->extra[1].y = (1 << 30); + context->extra[1].next = NULL; } // find minimum y position if it starts at x1 -static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) -{ - stbrp_node *node = first; - int x1 = x0 + width; - int min_y, visited_width, waste_area; - - STBRP__NOTUSED(c); - - STBRP_ASSERT(first->x <= x0); - - #if 0 - // skip in case we're past the node - while (node->next->x <= x0) - ++node; - #else - STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency - #endif - - STBRP_ASSERT(node->x <= x0); - - min_y = 0; - waste_area = 0; - visited_width = 0; - while (node->x < x1) { - if (node->y > min_y) { - // raise min_y higher. - // we've accounted for all waste up to min_y, - // but we'll now add more waste for everything we've visted - waste_area += visited_width * (node->y - min_y); - min_y = node->y; - // the first time through, visited_width might be reduced - if (node->x < x0) - visited_width += node->next->x - x0; - else - visited_width += node->next->x - node->x; - } else { - // add waste area - int under_width = node->next->x - node->x; - if (under_width + visited_width > width) - under_width = width - visited_width; - waste_area += under_width * (min_y - node->y); - visited_width += under_width; - } - node = node->next; - } - - *pwaste = waste_area; - return min_y; +static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) { + stbrp_node *node = first; + int x1 = x0 + width; + int min_y, visited_width, waste_area; + + STBRP__NOTUSED(c); + + STBRP_ASSERT(first->x <= x0); + + #if 0 + // skip in case we're past the node + while (node->next->x <= x0) + ++node; + #else + STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency + #endif + + STBRP_ASSERT(node->x <= x0); + + min_y = 0; + waste_area = 0; + visited_width = 0; + while (node->x < x1) { + if (node->y > min_y) { + // raise min_y higher. + // we've accounted for all waste up to min_y, + // but we'll now add more waste for everything we've visted + waste_area += visited_width * (node->y - min_y); + min_y = node->y; + // the first time through, visited_width might be reduced + if (node->x < x0) + visited_width += node->next->x - x0; + else + visited_width += node->next->x - node->x; + } else { + // add waste area + int under_width = node->next->x - node->x; + if (under_width + visited_width > width) + under_width = width - visited_width; + waste_area += under_width * (min_y - node->y); + visited_width += under_width; + } + node = node->next; + } + + *pwaste = waste_area; + return min_y; } -typedef struct -{ - int x,y; - stbrp_node **prev_link; +typedef struct { + int x, y; + stbrp_node **prev_link; } stbrp__findresult; -static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) -{ - int best_waste = (1<<30), best_x, best_y = (1 << 30); - stbrp__findresult fr; - stbrp_node **prev, *node, *tail, **best = NULL; - - // align to multiple of c->align - width = (width + c->align - 1); - width -= width % c->align; - STBRP_ASSERT(width % c->align == 0); - - // if it can't possibly fit, bail immediately - if (width > c->width || height > c->height) { - fr.prev_link = NULL; - fr.x = fr.y = 0; - return fr; - } - - node = c->active_head; - prev = &c->active_head; - while (node->x + width <= c->width) { - int y,waste; - y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); - if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL - // bottom left - if (y < best_y) { - best_y = y; - best = prev; - } - } else { - // best-fit - if (y + height <= c->height) { - // can only use it if it first vertically - if (y < best_y || (y == best_y && waste < best_waste)) { - best_y = y; - best_waste = waste; - best = prev; - } - } - } - prev = &node->next; - node = node->next; - } - - best_x = (best == NULL) ? 0 : (*best)->x; - - // if doing best-fit (BF), we also have to try aligning right edge to each node position - // - // e.g, if fitting - // - // ____________________ - // |____________________| - // - // into - // - // | | - // | ____________| - // |____________| - // - // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned - // - // This makes BF take about 2x the time - - if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { - tail = c->active_head; - node = c->active_head; - prev = &c->active_head; - // find first node that's admissible - while (tail->x < width) - tail = tail->next; - while (tail) { - int xpos = tail->x - width; - int y,waste; - STBRP_ASSERT(xpos >= 0); - // find the left position that matches this - while (node->next->x <= xpos) { - prev = &node->next; - node = node->next; - } - STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); - y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); - if (y + height <= c->height) { - if (y <= best_y) { - if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { - best_x = xpos; - STBRP_ASSERT(y <= best_y); - best_y = y; - best_waste = waste; - best = prev; - } - } - } - tail = tail->next; - } - } - - fr.prev_link = best; - fr.x = best_x; - fr.y = best_y; - return fr; +static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) { + int best_waste = (1 << 30), best_x, best_y = (1 << 30); + stbrp__findresult fr; + stbrp_node **prev, *node, *tail, **best = NULL; + + // align to multiple of c->align + width = (width + c->align - 1); + width -= width % c->align; + STBRP_ASSERT(width % c->align == 0); + + // if it can't possibly fit, bail immediately + if (width > c->width || height > c->height) { + fr.prev_link = NULL; + fr.x = fr.y = 0; + return fr; + } + + node = c->active_head; + prev = &c->active_head; + while (node->x + width <= c->width) { + int y, waste; + y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); + if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL + // bottom left + if (y < best_y) { + best_y = y; + best = prev; + } + } else { + // best-fit + if (y + height <= c->height) { + // can only use it if it first vertically + if (y < best_y || (y == best_y && waste < best_waste)) { + best_y = y; + best_waste = waste; + best = prev; + } + } + } + prev = &node->next; + node = node->next; + } + + best_x = (best == NULL) ? 0 : (*best)->x; + + // if doing best-fit (BF), we also have to try aligning right edge to each node position + // + // e.g, if fitting + // + // ____________________ + // |____________________| + // + // into + // + // | | + // | ____________| + // |____________| + // + // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned + // + // This makes BF take about 2x the time + + if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { + tail = c->active_head; + node = c->active_head; + prev = &c->active_head; + // find first node that's admissible + while (tail->x < width) + tail = tail->next; + while (tail) { + int xpos = tail->x - width; + int y, waste; + STBRP_ASSERT(xpos >= 0); + // find the left position that matches this + while (node->next->x <= xpos) { + prev = &node->next; + node = node->next; + } + STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); + y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); + if (y + height <= c->height) { + if (y <= best_y) { + if (y < best_y || waste < best_waste || (waste == best_waste && xpos < best_x)) { + best_x = xpos; + STBRP_ASSERT(y <= best_y); + best_y = y; + best_waste = waste; + best = prev; + } + } + } + tail = tail->next; + } + } + + fr.prev_link = best; + fr.x = best_x; + fr.y = best_y; + return fr; } -static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) -{ - // find best position according to heuristic - stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); - stbrp_node *node, *cur; - - // bail if: - // 1. it failed - // 2. the best node doesn't fit (we don't always check this) - // 3. we're out of memory - if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { - res.prev_link = NULL; - return res; - } - - // on success, create new node - node = context->free_head; - node->x = (stbrp_coord) res.x; - node->y = (stbrp_coord) (res.y + height); - - context->free_head = node->next; - - // insert the new node into the right starting point, and - // let 'cur' point to the remaining nodes needing to be - // stiched back in - - cur = *res.prev_link; - if (cur->x < res.x) { - // preserve the existing one, so start testing with the next one - stbrp_node *next = cur->next; - cur->next = node; - cur = next; - } else { - *res.prev_link = node; - } - - // from here, traverse cur and free the nodes, until we get to one - // that shouldn't be freed - while (cur->next && cur->next->x <= res.x + width) { - stbrp_node *next = cur->next; - // move the current node to the free list - cur->next = context->free_head; - context->free_head = cur; - cur = next; - } - - // stitch the list back in - node->next = cur; - - if (cur->x < res.x + width) - cur->x = (stbrp_coord) (res.x + width); +static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) { + // find best position according to heuristic + stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); + stbrp_node *node, *cur; + + // bail if: + // 1. it failed + // 2. the best node doesn't fit (we don't always check this) + // 3. we're out of memory + if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { + res.prev_link = NULL; + return res; + } + + // on success, create new node + node = context->free_head; + node->x = (stbrp_coord) res.x; + node->y = (stbrp_coord) (res.y + height); + + context->free_head = node->next; + + // insert the new node into the right starting point, and + // let 'cur' point to the remaining nodes needing to be + // stiched back in + + cur = *res.prev_link; + if (cur->x < res.x) { + // preserve the existing one, so start testing with the next one + stbrp_node *next = cur->next; + cur->next = node; + cur = next; + } else { + *res.prev_link = node; + } + + // from here, traverse cur and free the nodes, until we get to one + // that shouldn't be freed + while (cur->next && cur->next->x <= res.x + width) { + stbrp_node *next = cur->next; + // move the current node to the free list + cur->next = context->free_head; + context->free_head = cur; + cur = next; + } + + // stitch the list back in + node->next = cur; + + if (cur->x < res.x + width) + cur->x = (stbrp_coord) (res.x + width); #ifdef _DEBUG - cur = context->active_head; - while (cur->x < context->width) { - STBRP_ASSERT(cur->x < cur->next->x); - cur = cur->next; - } - STBRP_ASSERT(cur->next == NULL); - - { - int count=0; - cur = context->active_head; - while (cur) { - cur = cur->next; - ++count; - } - cur = context->free_head; - while (cur) { - cur = cur->next; - ++count; - } - STBRP_ASSERT(count == context->num_nodes+2); - } + cur = context->active_head; + while (cur->x < context->width) { + STBRP_ASSERT(cur->x < cur->next->x); + cur = cur->next; + } + STBRP_ASSERT(cur->next == NULL); + + { + int count=0; + cur = context->active_head; + while (cur) { + cur = cur->next; + ++count; + } + cur = context->free_head; + while (cur) { + cur = cur->next; + ++count; + } + STBRP_ASSERT(count == context->num_nodes+2); + } #endif - return res; + return res; } -static int STBRP__CDECL rect_height_compare(const void *a, const void *b) -{ - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; - if (p->h > q->h) - return -1; - if (p->h < q->h) - return 1; - return (p->w > q->w) ? -1 : (p->w < q->w); +static int STBRP__CDECL rect_height_compare(const void *a, const void *b) { + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + if (p->h > q->h) + return -1; + if (p->h < q->h) + return 1; + return (p->w > q->w) ? -1 : (p->w < q->w); } -static int STBRP__CDECL rect_original_order(const void *a, const void *b) -{ - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; - return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); +static int STBRP__CDECL rect_original_order(const void *a, const void *b) { + const stbrp_rect *p = (const stbrp_rect *) a; + const stbrp_rect *q = (const stbrp_rect *) b; + return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } -STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) -{ - int i, all_rects_packed = 1; - - // we use the 'was_packed' field internally to allow sorting/unsorting - for (i=0; i < num_rects; ++i) { - rects[i].was_packed = i; - } - - // sort according to heuristic - STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); - - for (i=0; i < num_rects; ++i) { - if (rects[i].w == 0 || rects[i].h == 0) { - rects[i].x = rects[i].y = 0; // empty rect needs no space - } else { - stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); - if (fr.prev_link) { - rects[i].x = (stbrp_coord) fr.x; - rects[i].y = (stbrp_coord) fr.y; - } else { - rects[i].x = rects[i].y = STBRP__MAXVAL; - } - } - } - - // unsort - STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); - - // set was_packed flags and all_rects_packed status - for (i=0; i < num_rects; ++i) { - rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); - if (!rects[i].was_packed) - all_rects_packed = 0; - } - - // return the all_rects_packed status - return all_rects_packed; +STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) { + int i, all_rects_packed = 1; + + // we use the 'was_packed' field internally to allow sorting/unsorting + for (i = 0; i < num_rects; ++i) { + rects[i].was_packed = i; + } + + // sort according to heuristic + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); + + for (i = 0; i < num_rects; ++i) { + if (rects[i].w == 0 || rects[i].h == 0) { + rects[i].x = rects[i].y = 0; // empty rect needs no space + } else { + stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); + if (fr.prev_link) { + rects[i].x = (stbrp_coord) fr.x; + rects[i].y = (stbrp_coord) fr.y; + } else { + rects[i].x = rects[i].y = STBRP__MAXVAL; + } + } + } + + // unsort + STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); + + // set was_packed flags and all_rects_packed status + for (i = 0; i < num_rects; ++i) { + rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); + if (!rects[i].was_packed) + all_rects_packed = 0; + } + + // return the all_rects_packed status + return all_rects_packed; } + #endif /* diff --git a/fggl/stb/stb_textedit.h b/fggl/stb/stb_textedit.h index 14424935f0a3f7dee0aa7679d04332a72c3a9b4e..b12a8e926c413ac33fcd6353056cd951969c206a 100644 --- a/fggl/stb/stb_textedit.h +++ b/fggl/stb/stb_textedit.h @@ -292,60 +292,57 @@ #define STB_TEXTEDIT_POSITIONTYPE int #endif -typedef struct -{ - // private data - STB_TEXTEDIT_POSITIONTYPE where; - STB_TEXTEDIT_POSITIONTYPE insert_length; - STB_TEXTEDIT_POSITIONTYPE delete_length; - int char_storage; +typedef struct { + // private data + STB_TEXTEDIT_POSITIONTYPE where; + STB_TEXTEDIT_POSITIONTYPE insert_length; + STB_TEXTEDIT_POSITIONTYPE delete_length; + int char_storage; } StbUndoRecord; -typedef struct -{ - // private data - StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; - STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; - short undo_point, redo_point; - int undo_char_point, redo_char_point; +typedef struct { + // private data + StbUndoRecord undo_rec[STB_TEXTEDIT_UNDOSTATECOUNT]; + STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; + short undo_point, redo_point; + int undo_char_point, redo_char_point; } StbUndoState; -typedef struct -{ - ///////////////////// - // - // public data - // - - int cursor; - // position of the text cursor within the string - - int select_start; // selection start point - int select_end; - // selection start and end point in characters; if equal, no selection. - // note that start may be less than or greater than end (e.g. when - // dragging the mouse, start is where the initial click was, and you - // can drag in either direction) - - unsigned char insert_mode; - // each textfield keeps its own insert mode state. to keep an app-wide - // insert mode, copy this value in/out of the app state - - int row_count_per_page; - // page size in number of row. - // this value MUST be set to >0 for pageup or pagedown in multilines documents. - - ///////////////////// - // - // private data - // - unsigned char cursor_at_end_of_line; // not implemented yet - unsigned char initialized; - unsigned char has_preferred_x; - unsigned char single_line; - unsigned char padding1, padding2, padding3; - float preferred_x; // this determines where the cursor up/down tries to seek to along x - StbUndoState undostate; +typedef struct { + ///////////////////// + // + // public data + // + + int cursor; + // position of the text cursor within the string + + int select_start; // selection start point + int select_end; + // selection start and end point in characters; if equal, no selection. + // note that start may be less than or greater than end (e.g. when + // dragging the mouse, start is where the initial click was, and you + // can drag in either direction) + + unsigned char insert_mode; + // each textfield keeps its own insert mode state. to keep an app-wide + // insert mode, copy this value in/out of the app state + + int row_count_per_page; + // page size in number of row. + // this value MUST be set to >0 for pageup or pagedown in multilines documents. + + ///////////////////// + // + // private data + // + unsigned char cursor_at_end_of_line; // not implemented yet + unsigned char initialized; + unsigned char has_preferred_x; + unsigned char single_line; + unsigned char padding1, padding2, padding3; + float preferred_x; // this determines where the cursor up/down tries to seek to along x + StbUndoState undostate; } STB_TexteditState; @@ -357,12 +354,11 @@ typedef struct // the text in each row is. // result of layout query -typedef struct -{ - float x0,x1; // starting x location, end x location (allows for align=right, etc) - float baseline_y_delta; // position of baseline relative to previous row's baseline - float ymin,ymax; // height of row above and below baseline - int num_chars; +typedef struct { + float x0, x1; // starting x location, end x location (allows for align=right, etc) + float baseline_y_delta; // position of baseline relative to previous row's baseline + float ymin, ymax; // height of row above and below baseline + int num_chars; } StbTexteditRow; #endif //INCLUDE_STB_TEXTEDIT_H @@ -404,50 +400,50 @@ static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) // search rows to find one that straddles 'y' while (i < n) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - if (r.num_chars <= 0) - return n; + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (r.num_chars <= 0) + return n; - if (i==0 && y < base_y + r.ymin) - return 0; + if (i==0 && y < base_y + r.ymin) + return 0; - if (y < base_y + r.ymax) - break; + if (y < base_y + r.ymax) + break; - i += r.num_chars; - base_y += r.baseline_y_delta; + i += r.num_chars; + base_y += r.baseline_y_delta; } // below all text, return 'after' last character if (i >= n) - return n; + return n; // check if it's before the beginning of the line if (x < r.x0) - return i; + return i; // check if it's before the end of the line if (x < r.x1) { - // search characters in row for one that straddles 'x' - prev_x = r.x0; - for (k=0; k < r.num_chars; ++k) { - float w = STB_TEXTEDIT_GETWIDTH(str, i, k); - if (x < prev_x+w) { - if (x < prev_x+w/2) - return k+i; - else - return k+i+1; - } - prev_x += w; - } - // shouldn't happen, but if it does, fall through to end-of-line case + // search characters in row for one that straddles 'x' + prev_x = r.x0; + for (k=0; k < r.num_chars; ++k) { + float w = STB_TEXTEDIT_GETWIDTH(str, i, k); + if (x < prev_x+w) { + if (x < prev_x+w/2) + return k+i; + else + return k+i+1; + } + prev_x += w; + } + // shouldn't happen, but if it does, fall through to end-of-line case } // if the last character is a newline, return that. otherwise return 'after' the last character if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) - return i+r.num_chars-1; + return i+r.num_chars-1; else - return i+r.num_chars; + return i+r.num_chars; } // API click: on mouse down, move the cursor to the clicked location, and reset the selection @@ -457,9 +453,9 @@ static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat // goes off the top or bottom of the text if( state->single_line ) { - StbTexteditRow r; - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - y = r.ymin; + StbTexteditRow r; + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + y = r.ymin; } state->cursor = stb_text_locate_coord(str, x, y); @@ -477,13 +473,13 @@ static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state // goes off the top or bottom of the text if( state->single_line ) { - StbTexteditRow r; - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - y = r.ymin; + StbTexteditRow r; + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + y = r.ymin; } if (state->select_start == state->select_end) - state->select_start = state->cursor; + state->select_start = state->cursor; p = stb_text_locate_coord(str, x, y); state->cursor = state->select_end = p; @@ -519,41 +515,41 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s int i=0, first; if (n == z) { - // if it's at the end, then find the last line -- simpler than trying to - // explicitly handle this case in the regular code - if (single_line) { - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - find->y = 0; - find->first_char = 0; - find->length = z; - find->height = r.ymax - r.ymin; - find->x = r.x1; - } else { - find->y = 0; - find->x = 0; - find->height = 1; - while (i < z) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - prev_start = i; - i += r.num_chars; - } - find->first_char = i; - find->length = 0; - find->prev_first = prev_start; - } - return; + // if it's at the end, then find the last line -- simpler than trying to + // explicitly handle this case in the regular code + if (single_line) { + STB_TEXTEDIT_LAYOUTROW(&r, str, 0); + find->y = 0; + find->first_char = 0; + find->length = z; + find->height = r.ymax - r.ymin; + find->x = r.x1; + } else { + find->y = 0; + find->x = 0; + find->height = 1; + while (i < z) { + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + prev_start = i; + i += r.num_chars; + } + find->first_char = i; + find->length = 0; + find->prev_first = prev_start; + } + return; } // search rows to find the one that straddles character n find->y = 0; for(;;) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - if (n < i + r.num_chars) - break; - prev_start = i; - i += r.num_chars; - find->y += r.baseline_y_delta; + STB_TEXTEDIT_LAYOUTROW(&r, str, i); + if (n < i + r.num_chars) + break; + prev_start = i; + i += r.num_chars; + find->y += r.baseline_y_delta; } find->first_char = first = i; @@ -564,7 +560,7 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s // now scan to find xpos find->x = r.x0; for (i=0; first+i < n; ++i) - find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); + find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); } #define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) @@ -574,11 +570,11 @@ static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat { int n = STB_TEXTEDIT_STRINGLEN(str); if (STB_TEXT_HAS_SELECTION(state)) { - if (state->select_start > n) state->select_start = n; - if (state->select_end > n) state->select_end = n; - // if clamping forced them to be equal, move the cursor to match - if (state->select_start == state->select_end) - state->cursor = state->select_start; + if (state->select_start > n) state->select_start = n; + if (state->select_end > n) state->select_end = n; + // if clamping forced them to be equal, move the cursor to match + if (state->select_start == state->select_end) + state->cursor = state->select_start; } if (state->cursor > n) state->cursor = n; } @@ -596,14 +592,14 @@ static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_Textedit { stb_textedit_clamp(str, state); if (STB_TEXT_HAS_SELECTION(state)) { - if (state->select_start < state->select_end) { - stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); - state->select_end = state->cursor = state->select_start; - } else { - stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); - state->select_start = state->cursor = state->select_end; - } - state->has_preferred_x = 0; + if (state->select_start < state->select_end) { + stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); + state->select_end = state->cursor = state->select_start; + } else { + stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); + state->select_start = state->cursor = state->select_end; + } + state->has_preferred_x = 0; } } @@ -611,9 +607,9 @@ static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_Textedit static void stb_textedit_sortselection(STB_TexteditState *state) { if (state->select_end < state->select_start) { - int temp = state->select_end; - state->select_end = state->select_start; - state->select_start = temp; + int temp = state->select_end; + state->select_end = state->select_start; + state->select_start = temp; } } @@ -621,10 +617,10 @@ static void stb_textedit_sortselection(STB_TexteditState *state) static void stb_textedit_move_to_first(STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_sortselection(state); - state->cursor = state->select_start; - state->select_end = state->select_start; - state->has_preferred_x = 0; + stb_textedit_sortselection(state); + state->cursor = state->select_start; + state->select_end = state->select_start; + state->has_preferred_x = 0; } } @@ -632,11 +628,11 @@ static void stb_textedit_move_to_first(STB_TexteditState *state) static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_sortselection(state); - stb_textedit_clamp(str, state); - state->cursor = state->select_end; - state->select_start = state->select_end; - state->has_preferred_x = 0; + stb_textedit_sortselection(state); + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->select_start = state->select_end; + state->has_preferred_x = 0; } } @@ -651,10 +647,10 @@ static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) { --c; // always move at least one character while( c >= 0 && !is_word_boundary( str, c ) ) - --c; + --c; if( c < 0 ) - c = 0; + c = 0; return c; } @@ -667,10 +663,10 @@ static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) const int len = STB_TEXTEDIT_STRINGLEN(str); ++c; // always move at least one character while( c < len && !is_word_boundary( str, c ) ) - ++c; + ++c; if( c > len ) - c = len; + c = len; return c; } @@ -683,18 +679,18 @@ static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) { if (!STB_TEXT_HAS_SELECTION(state)) - state->select_start = state->select_end = state->cursor; + state->select_start = state->select_end = state->cursor; else - state->cursor = state->select_end; + state->cursor = state->select_end; } // API cut: delete selection static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_delete_selection(str,state); // implicitly clamps - state->has_preferred_x = 0; - return 1; + stb_textedit_delete_selection(str,state); // implicitly clamps + state->has_preferred_x = 0; + return 1; } return 0; } @@ -707,10 +703,10 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta stb_textedit_delete_selection(str,state); // try to insert the characters if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { - stb_text_makeundo_insert(state, state->cursor, len); - state->cursor += len; - state->has_preferred_x = 0; - return 1; + stb_text_makeundo_insert(state, state->cursor, len); + state->cursor += len; + state->has_preferred_x = 0; + return 1; } // note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details) return 0; @@ -725,378 +721,378 @@ static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, { retry: switch (key) { - default: { - int c = STB_TEXTEDIT_KEYTOTEXT(key); - if (c > 0) { - STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; - - // can't add newline in single-line mode - if (c == '\n' && state->single_line) - break; - - if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { - stb_text_makeundo_replace(str, state, state->cursor, 1, 1); - STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); - if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { - ++state->cursor; - state->has_preferred_x = 0; - } - } else { - stb_textedit_delete_selection(str,state); // implicitly clamps - if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { - stb_text_makeundo_insert(state, state->cursor, 1); - ++state->cursor; - state->has_preferred_x = 0; - } - } - } - break; - } + default: { + int c = STB_TEXTEDIT_KEYTOTEXT(key); + if (c > 0) { + STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; + + // can't add newline in single-line mode + if (c == '\n' && state->single_line) + break; + + if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { + stb_text_makeundo_replace(str, state, state->cursor, 1, 1); + STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + ++state->cursor; + state->has_preferred_x = 0; + } + } else { + stb_textedit_delete_selection(str,state); // implicitly clamps + if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { + stb_text_makeundo_insert(state, state->cursor, 1); + ++state->cursor; + state->has_preferred_x = 0; + } + } + } + break; + } #ifdef STB_TEXTEDIT_K_INSERT - case STB_TEXTEDIT_K_INSERT: - state->insert_mode = !state->insert_mode; - break; + case STB_TEXTEDIT_K_INSERT: + state->insert_mode = !state->insert_mode; + break; #endif - case STB_TEXTEDIT_K_UNDO: - stb_text_undo(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_REDO: - stb_text_redo(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_LEFT: - // if currently there's a selection, move cursor to start of selection - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - else - if (state->cursor > 0) - --state->cursor; - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_RIGHT: - // if currently there's a selection, move cursor to end of selection - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - else - ++state->cursor; - stb_textedit_clamp(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - // move selection left - if (state->select_end > 0) - --state->select_end; - state->cursor = state->select_end; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_UNDO: + stb_text_undo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_REDO: + stb_text_redo(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT: + // if currently there's a selection, move cursor to start of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else + if (state->cursor > 0) + --state->cursor; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_RIGHT: + // if currently there's a selection, move cursor to end of selection + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else + ++state->cursor; + stb_textedit_clamp(str, state); + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + // move selection left + if (state->select_end > 0) + --state->select_end; + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_MOVEWORDLEFT - case STB_TEXTEDIT_K_WORDLEFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - else { - state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); - stb_textedit_clamp( str, state ); - } - break; - - case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: - if( !STB_TEXT_HAS_SELECTION( state ) ) - stb_textedit_prep_selection_at_cursor(state); - - state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); - state->select_end = state->cursor; - - stb_textedit_clamp( str, state ); - break; + case STB_TEXTEDIT_K_WORDLEFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; #endif #ifdef STB_TEXTEDIT_MOVEWORDRIGHT - case STB_TEXTEDIT_K_WORDRIGHT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - else { - state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); - stb_textedit_clamp( str, state ); - } - break; - - case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: - if( !STB_TEXT_HAS_SELECTION( state ) ) - stb_textedit_prep_selection_at_cursor(state); - - state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); - state->select_end = state->cursor; - - stb_textedit_clamp( str, state ); - break; + case STB_TEXTEDIT_K_WORDRIGHT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + else { + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + stb_textedit_clamp( str, state ); + } + break; + + case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: + if( !STB_TEXT_HAS_SELECTION( state ) ) + stb_textedit_prep_selection_at_cursor(state); + + state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); + state->select_end = state->cursor; + + stb_textedit_clamp( str, state ); + break; #endif - case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - // move selection right - ++state->select_end; - stb_textedit_clamp(str, state); - state->cursor = state->select_end; - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_DOWN: - case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: - case STB_TEXTEDIT_K_PGDOWN: - case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: { - StbFindState find; - StbTexteditRow row; - int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; - int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN; - int row_count = is_page ? state->row_count_per_page : 1; - - if (!is_page && state->single_line) { - // on windows, up&down in single-line behave like left&right - key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); - goto retry; - } - - if (sel) - stb_textedit_prep_selection_at_cursor(state); - else if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - - // compute current position of cursor point - stb_textedit_clamp(str, state); - stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); - - for (j = 0; j < row_count; ++j) { - float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; - int start = find.first_char + find.length; - - if (find.length == 0) - break; - - // now find character position down a row - state->cursor = start; - STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); - x = row.x0; - for (i=0; i < row.num_chars; ++i) { - float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); - #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE - if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) - break; - #endif - x += dx; - if (x > goal_x) - break; - ++state->cursor; - } - stb_textedit_clamp(str, state); - - state->has_preferred_x = 1; - state->preferred_x = goal_x; - - if (sel) - state->select_end = state->cursor; - - // go to next line - find.first_char = find.first_char + find.length; - find.length = row.num_chars; - } - break; - } - - case STB_TEXTEDIT_K_UP: - case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: - case STB_TEXTEDIT_K_PGUP: - case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: { - StbFindState find; - StbTexteditRow row; - int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; - int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP; - int row_count = is_page ? state->row_count_per_page : 1; - - if (!is_page && state->single_line) { - // on windows, up&down become left&right - key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); - goto retry; - } - - if (sel) - stb_textedit_prep_selection_at_cursor(state); - else if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - - // compute current position of cursor point - stb_textedit_clamp(str, state); - stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); - - for (j = 0; j < row_count; ++j) { - float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; - - // can only go up if there's a previous row - if (find.prev_first == find.first_char) - break; - - // now find character position up a row - state->cursor = find.prev_first; - STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); - x = row.x0; - for (i=0; i < row.num_chars; ++i) { - float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); - #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE - if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) - break; - #endif - x += dx; - if (x > goal_x) - break; - ++state->cursor; - } - stb_textedit_clamp(str, state); - - state->has_preferred_x = 1; - state->preferred_x = goal_x; - - if (sel) - state->select_end = state->cursor; - - // go to previous line - // (we need to scan previous line the hard way. maybe we could expose this as a new API function?) - prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0; - while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE) - --prev_scan; - find.first_char = find.prev_first; - find.prev_first = prev_scan; - } - break; - } - - case STB_TEXTEDIT_K_DELETE: - case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_delete_selection(str, state); - else { - int n = STB_TEXTEDIT_STRINGLEN(str); - if (state->cursor < n) - stb_textedit_delete(str, state, state->cursor, 1); - } - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_BACKSPACE: - case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_delete_selection(str, state); - else { - stb_textedit_clamp(str, state); - if (state->cursor > 0) { - stb_textedit_delete(str, state, state->cursor-1, 1); - --state->cursor; - } - } - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + // move selection right + ++state->select_end; + stb_textedit_clamp(str, state); + state->cursor = state->select_end; + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_DOWN: + case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_PGDOWN: + case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN; + int row_count = is_page ? state->row_count_per_page : 1; + + if (!is_page && state->single_line) { + // on windows, up&down in single-line behave like left&right + key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_last(str, state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + for (j = 0; j < row_count; ++j) { + float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; + int start = find.first_char + find.length; + + if (find.length == 0) + break; + + // now find character position down a row + state->cursor = start; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); +#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; +#endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + + // go to next line + find.first_char = find.first_char + find.length; + find.length = row.num_chars; + } + break; + } + + case STB_TEXTEDIT_K_UP: + case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_PGUP: + case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: { + StbFindState find; + StbTexteditRow row; + int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; + int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP; + int row_count = is_page ? state->row_count_per_page : 1; + + if (!is_page && state->single_line) { + // on windows, up&down become left&right + key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); + goto retry; + } + + if (sel) + stb_textedit_prep_selection_at_cursor(state); + else if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_move_to_first(state); + + // compute current position of cursor point + stb_textedit_clamp(str, state); + stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); + + for (j = 0; j < row_count; ++j) { + float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; + + // can only go up if there's a previous row + if (find.prev_first == find.first_char) + break; + + // now find character position up a row + state->cursor = find.prev_first; + STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); + x = row.x0; + for (i=0; i < row.num_chars; ++i) { + float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); +#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE + if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) + break; +#endif + x += dx; + if (x > goal_x) + break; + ++state->cursor; + } + stb_textedit_clamp(str, state); + + state->has_preferred_x = 1; + state->preferred_x = goal_x; + + if (sel) + state->select_end = state->cursor; + + // go to previous line + // (we need to scan previous line the hard way. maybe we could expose this as a new API function?) + prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0; + while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE) + --prev_scan; + find.first_char = find.prev_first; + find.prev_first = prev_scan; + } + break; + } + + case STB_TEXTEDIT_K_DELETE: + case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + int n = STB_TEXTEDIT_STRINGLEN(str); + if (state->cursor < n) + stb_textedit_delete(str, state, state->cursor, 1); + } + state->has_preferred_x = 0; + break; + + case STB_TEXTEDIT_K_BACKSPACE: + case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: + if (STB_TEXT_HAS_SELECTION(state)) + stb_textedit_delete_selection(str, state); + else { + stb_textedit_clamp(str, state); + if (state->cursor > 0) { + stb_textedit_delete(str, state, state->cursor-1, 1); + --state->cursor; + } + } + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 - case STB_TEXTEDIT_K_TEXTSTART2: + case STB_TEXTEDIT_K_TEXTSTART2: #endif - case STB_TEXTEDIT_K_TEXTSTART: - state->cursor = state->select_start = state->select_end = 0; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_TEXTSTART: + state->cursor = state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_TEXTEND2 - case STB_TEXTEDIT_K_TEXTEND2: + case STB_TEXTEDIT_K_TEXTEND2: #endif - case STB_TEXTEDIT_K_TEXTEND: - state->cursor = STB_TEXTEDIT_STRINGLEN(str); - state->select_start = state->select_end = 0; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_TEXTEND: + state->cursor = STB_TEXTEDIT_STRINGLEN(str); + state->select_start = state->select_end = 0; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 - case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: #endif - case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - state->cursor = state->select_end = 0; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = 0; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_TEXTEND2 - case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: #endif - case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: + stb_textedit_prep_selection_at_cursor(state); + state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_LINESTART2 - case STB_TEXTEDIT_K_LINESTART2: + case STB_TEXTEDIT_K_LINESTART2: #endif - case STB_TEXTEDIT_K_LINESTART: - stb_textedit_clamp(str, state); - stb_textedit_move_to_first(state); - if (state->single_line) - state->cursor = 0; - else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) - --state->cursor; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_LINESTART: + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_LINEEND2 - case STB_TEXTEDIT_K_LINEEND2: + case STB_TEXTEDIT_K_LINEEND2: #endif - case STB_TEXTEDIT_K_LINEEND: { - int n = STB_TEXTEDIT_STRINGLEN(str); - stb_textedit_clamp(str, state); - stb_textedit_move_to_first(state); - if (state->single_line) - state->cursor = n; - else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) - ++state->cursor; - state->has_preferred_x = 0; - break; - } + case STB_TEXTEDIT_K_LINEEND: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_move_to_first(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->has_preferred_x = 0; + break; + } #ifdef STB_TEXTEDIT_K_LINESTART2 - case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: #endif - case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - if (state->single_line) - state->cursor = 0; - else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) - --state->cursor; - state->select_end = state->cursor; - state->has_preferred_x = 0; - break; + case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = 0; + else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) + --state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; #ifdef STB_TEXTEDIT_K_LINEEND2 - case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: + case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: #endif - case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { - int n = STB_TEXTEDIT_STRINGLEN(str); - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - if (state->single_line) - state->cursor = n; - else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) - ++state->cursor; - state->select_end = state->cursor; - state->has_preferred_x = 0; - break; - } + case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { + int n = STB_TEXTEDIT_STRINGLEN(str); + stb_textedit_clamp(str, state); + stb_textedit_prep_selection_at_cursor(state); + if (state->single_line) + state->cursor = n; + else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) + ++state->cursor; + state->select_end = state->cursor; + state->has_preferred_x = 0; + break; + } } } @@ -1116,18 +1112,18 @@ static void stb_textedit_flush_redo(StbUndoState *state) static void stb_textedit_discard_undo(StbUndoState *state) { if (state->undo_point > 0) { - // if the 0th undo state has characters, clean those up - if (state->undo_rec[0].char_storage >= 0) { - int n = state->undo_rec[0].insert_length, i; - // delete n characters from all other records - state->undo_char_point -= n; - STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); - for (i=0; i < state->undo_point; ++i) - if (state->undo_rec[i].char_storage >= 0) - state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it - } - --state->undo_point; - STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); + // if the 0th undo state has characters, clean those up + if (state->undo_rec[0].char_storage >= 0) { + int n = state->undo_rec[0].insert_length, i; + // delete n characters from all other records + state->undo_char_point -= n; + STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); + for (i=0; i < state->undo_point; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it + } + --state->undo_point; + STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); } } @@ -1140,21 +1136,21 @@ static void stb_textedit_discard_redo(StbUndoState *state) int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; if (state->redo_point <= k) { - // if the k'th undo state has characters, clean those up - if (state->undo_rec[k].char_storage >= 0) { - int n = state->undo_rec[k].insert_length, i; - // move the remaining redo character data to the end of the buffer - state->redo_char_point += n; - STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); - // adjust the position of all the other records to account for above memmove - for (i=state->redo_point; i < k; ++i) - if (state->undo_rec[i].char_storage >= 0) - state->undo_rec[i].char_storage += n; - } - // now move all the redo records towards the end of the buffer; the first one is at 'redo_point' - STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); - // now move redo_point to point to the new one - ++state->redo_point; + // if the k'th undo state has characters, clean those up + if (state->undo_rec[k].char_storage >= 0) { + int n = state->undo_rec[k].insert_length, i; + // move the remaining redo character data to the end of the buffer + state->redo_char_point += n; + STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); + // adjust the position of all the other records to account for above memmove + for (i=state->redo_point; i < k; ++i) + if (state->undo_rec[i].char_storage >= 0) + state->undo_rec[i].char_storage += n; + } + // now move all the redo records towards the end of the buffer; the first one is at 'redo_point' + STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); + // now move redo_point to point to the new one + ++state->redo_point; } } @@ -1166,18 +1162,18 @@ static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numch // if we have no free records, we have to make room, by sliding the // existing records down if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - stb_textedit_discard_undo(state); + stb_textedit_discard_undo(state); // if the characters to store won't possibly fit in the buffer, we can't undo if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { - state->undo_point = 0; - state->undo_char_point = 0; - return NULL; + state->undo_point = 0; + state->undo_char_point = 0; + return NULL; } // if we don't have enough free characters in the buffer, we have to make room while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) - stb_textedit_discard_undo(state); + stb_textedit_discard_undo(state); return &state->undo_rec[state->undo_point++]; } @@ -1186,19 +1182,19 @@ static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, { StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); if (r == NULL) - return NULL; + return NULL; r->where = pos; r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len; r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len; if (insert_len == 0) { - r->char_storage = -1; - return NULL; + r->char_storage = -1; + return NULL; } else { - r->char_storage = state->undo_char_point; - state->undo_char_point += insert_len; - return &state->undo_char[r->char_storage]; + r->char_storage = state->undo_char_point; + state->undo_char_point += insert_len; + return &state->undo_char[r->char_storage]; } } @@ -1207,7 +1203,7 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) StbUndoState *s = &state->undostate; StbUndoRecord u, *r; if (s->undo_point == 0) - return; + return; // we need to do two things: apply the undo record, and create a redo record u = s->undo_rec[s->undo_point-1]; @@ -1219,49 +1215,49 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) r->where = u.where; if (u.delete_length) { - // if the undo record says to delete characters, then the redo record will - // need to re-insert the characters that get deleted, so we need to store - // them. - - // there are three cases: - // there's enough room to store the characters - // characters stored for *redoing* don't leave room for redo - // characters stored for *undoing* don't leave room for redo - // if the last is true, we have to bail - - if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { - // the undo records take up too much character space; there's no space to store the redo characters - r->insert_length = 0; - } else { - int i; - - // there's definitely room to store the characters eventually - while (s->undo_char_point + u.delete_length > s->redo_char_point) { - // should never happen: - if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - return; - // there's currently not enough room, so discard a redo record - stb_textedit_discard_redo(s); - } - r = &s->undo_rec[s->redo_point-1]; - - r->char_storage = s->redo_char_point - u.delete_length; - s->redo_char_point = s->redo_char_point - u.delete_length; - - // now save the characters - for (i=0; i < u.delete_length; ++i) - s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); - } - - // now we can carry out the deletion - STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); + // if the undo record says to delete characters, then the redo record will + // need to re-insert the characters that get deleted, so we need to store + // them. + + // there are three cases: + // there's enough room to store the characters + // characters stored for *redoing* don't leave room for redo + // characters stored for *undoing* don't leave room for redo + // if the last is true, we have to bail + + if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { + // the undo records take up too much character space; there's no space to store the redo characters + r->insert_length = 0; + } else { + int i; + + // there's definitely room to store the characters eventually + while (s->undo_char_point + u.delete_length > s->redo_char_point) { + // should never happen: + if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) + return; + // there's currently not enough room, so discard a redo record + stb_textedit_discard_redo(s); + } + r = &s->undo_rec[s->redo_point-1]; + + r->char_storage = s->redo_char_point - u.delete_length; + s->redo_char_point = s->redo_char_point - u.delete_length; + + // now save the characters + for (i=0; i < u.delete_length; ++i) + s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); + } + + // now we can carry out the deletion + STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); } // check type of recorded action: if (u.insert_length) { - // easy case: was a deletion, so we need to insert n characters - STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); - s->undo_char_point -= u.insert_length; + // easy case: was a deletion, so we need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); + s->undo_char_point -= u.insert_length; } state->cursor = u.where + u.insert_length; @@ -1275,7 +1271,7 @@ static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) StbUndoState *s = &state->undostate; StbUndoRecord *u, r; if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - return; + return; // we need to do two things: apply the redo record, and create an undo record u = &s->undo_rec[s->undo_point]; @@ -1290,29 +1286,29 @@ static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) u->char_storage = -1; if (r.delete_length) { - // the redo record requires us to delete characters, so the undo record - // needs to store the characters - - if (s->undo_char_point + u->insert_length > s->redo_char_point) { - u->insert_length = 0; - u->delete_length = 0; - } else { - int i; - u->char_storage = s->undo_char_point; - s->undo_char_point = s->undo_char_point + u->insert_length; - - // now save the characters - for (i=0; i < u->insert_length; ++i) - s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); - } - - STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); + // the redo record requires us to delete characters, so the undo record + // needs to store the characters + + if (s->undo_char_point + u->insert_length > s->redo_char_point) { + u->insert_length = 0; + u->delete_length = 0; + } else { + int i; + u->char_storage = s->undo_char_point; + s->undo_char_point = s->undo_char_point + u->insert_length; + + // now save the characters + for (i=0; i < u->insert_length; ++i) + s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); + } + + STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); } if (r.insert_length) { - // easy case: need to insert n characters - STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); - s->redo_char_point += r.insert_length; + // easy case: need to insert n characters + STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); + s->redo_char_point += r.insert_length; } state->cursor = r.where + r.insert_length; @@ -1331,8 +1327,8 @@ static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); if (p) { - for (i=0; i < length; ++i) - p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + for (i=0; i < length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } @@ -1341,8 +1337,8 @@ static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditStat int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); if (p) { - for (i=0; i < old_length; ++i) - p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); + for (i=0; i < old_length; ++i) + p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } diff --git a/fggl/stb/stb_truetype.h b/fggl/stb/stb_truetype.h index bbf2284b164c2bc23f31d90439c416397fa02d71..f195cb12f02f44bd88e3dd65a8e1f6eadc5d2e19 100644 --- a/fggl/stb/stb_truetype.h +++ b/fggl/stb/stb_truetype.h @@ -305,15 +305,15 @@ void my_stbtt_print(float x, float y, char *text) glBindTexture(GL_TEXTURE_2D, ftex); glBegin(GL_QUADS); while (*text) { - if (*text >= 32 && *text < 128) { - stbtt_aligned_quad q; - stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 - glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y0); - glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y0); - glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y1); - glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y1); - } - ++text; + if (*text >= 32 && *text < 128) { + stbtt_aligned_quad q; + stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 + glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y0); + glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y0); + glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y1); + glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y1); + } + ++text; } glEnd(); } @@ -343,9 +343,9 @@ int main(int argc, char **argv) bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) - putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); - putchar('\n'); + for (i=0; i < w; ++i) + putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); + putchar('\n'); } return 0; } @@ -387,25 +387,25 @@ int main(int arg, char **argv) baseline = (int) (ascent*scale); while (text[ch]) { - int advance,lsb,x0,y0,x1,y1; - float x_shift = xpos - (float) floor(xpos); - stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); - stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); - stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); - // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong - // because this API is really for baking character bitmaps into textures. if you want to render - // a sequence of characters, you really need to render each bitmap to a temp buffer, then - // "alpha blend" that into the working buffer - xpos += (advance * scale); - if (text[ch+1]) - xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); - ++ch; + int advance,lsb,x0,y0,x1,y1; + float x_shift = xpos - (float) floor(xpos); + stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); + stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); + // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong + // because this API is really for baking character bitmaps into textures. if you want to render + // a sequence of characters, you really need to render each bitmap to a temp buffer, then + // "alpha blend" that into the working buffer + xpos += (advance * scale); + if (text[ch+1]) + xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); + ++ch; } for (j=0; j < 20; ++j) { - for (i=0; i < 78; ++i) - putchar(" .:ioVM@"[screen[j][i]>>5]); - putchar('\n'); + for (i=0; i < 78; ++i) + putchar(" .:ioVM@"[screen[j][i]>>5]); + putchar('\n'); } return 0; @@ -423,70 +423,70 @@ int main(int arg, char **argv) //// link with the C runtime library. #ifdef STB_TRUETYPE_IMPLEMENTATION - // #define your own (u)stbtt_int8/16/32 before including to override this - #ifndef stbtt_uint8 - typedef unsigned char stbtt_uint8; - typedef signed char stbtt_int8; - typedef unsigned short stbtt_uint16; - typedef signed short stbtt_int16; - typedef unsigned int stbtt_uint32; - typedef signed int stbtt_int32; - #endif - - typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; - typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; - - // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h - #ifndef STBTT_ifloor - #include <math.h> - #define STBTT_ifloor(x) ((int) floor(x)) - #define STBTT_iceil(x) ((int) ceil(x)) - #endif - - #ifndef STBTT_sqrt - #include <math.h> - #define STBTT_sqrt(x) sqrt(x) - #define STBTT_pow(x,y) pow(x,y) - #endif - - #ifndef STBTT_fmod - #include <math.h> - #define STBTT_fmod(x,y) fmod(x,y) - #endif - - #ifndef STBTT_cos - #include <math.h> - #define STBTT_cos(x) cos(x) - #define STBTT_acos(x) acos(x) - #endif - - #ifndef STBTT_fabs - #include <math.h> - #define STBTT_fabs(x) fabs(x) - #endif - - // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h - #ifndef STBTT_malloc - #include <stdlib.h> - #define STBTT_malloc(x,u) ((void)(u),malloc(x)) - #define STBTT_free(x,u) ((void)(u),free(x)) - #endif - - #ifndef STBTT_assert - #include <assert.h> - #define STBTT_assert(x) assert(x) - #endif - - #ifndef STBTT_strlen - #include <string.h> - #define STBTT_strlen(x) strlen(x) - #endif - - #ifndef STBTT_memcpy - #include <string.h> - #define STBTT_memcpy memcpy - #define STBTT_memset memset - #endif +// #define your own (u)stbtt_int8/16/32 before including to override this + #ifndef stbtt_uint8 +typedef unsigned char stbtt_uint8; +typedef signed char stbtt_int8; +typedef unsigned short stbtt_uint16; +typedef signed short stbtt_int16; +typedef unsigned int stbtt_uint32; +typedef signed int stbtt_int32; + #endif + +typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; +typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; + +// e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h +#ifndef STBTT_ifloor + #include <math.h> + #define STBTT_ifloor(x) ((int) floor(x)) + #define STBTT_iceil(x) ((int) ceil(x)) +#endif + + #ifndef STBTT_sqrt + #include <math.h> + #define STBTT_sqrt(x) sqrt(x) + #define STBTT_pow(x,y) pow(x,y) + #endif + + #ifndef STBTT_fmod + #include <math.h> + #define STBTT_fmod(x,y) fmod(x,y) + #endif + + #ifndef STBTT_cos + #include <math.h> + #define STBTT_cos(x) cos(x) + #define STBTT_acos(x) acos(x) + #endif + + #ifndef STBTT_fabs + #include <math.h> + #define STBTT_fabs(x) fabs(x) + #endif + +// #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h +#ifndef STBTT_malloc + #include <stdlib.h> + #define STBTT_malloc(x,u) ((void)(u),malloc(x)) + #define STBTT_free(x,u) ((void)(u),free(x)) +#endif + + #ifndef STBTT_assert + #include <assert.h> + #define STBTT_assert(x) assert(x) + #endif + + #ifndef STBTT_strlen + #include <string.h> + #define STBTT_strlen(x) strlen(x) + #endif + + #ifndef STBTT_memcpy + #include <string.h> + #define STBTT_memcpy memcpy + #define STBTT_memset memset + #endif #endif /////////////////////////////////////////////////////////////////////////////// @@ -510,11 +510,10 @@ extern "C" { #endif // private structure -typedef struct -{ - unsigned char *data; - int cursor; - int size; +typedef struct { + unsigned char *data; + int cursor; + int size; } stbtt__buf; ////////////////////////////////////////////////////////////////////////////// @@ -524,33 +523,35 @@ typedef struct // If you use this API, you only have to call two functions ever. // -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; +typedef struct { + unsigned short x0, y0, x1, y1; // coordinates of bbox in bitmap + float xoff, yoff, xadvance; } stbtt_bakedchar; -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) - float pixel_height, // height of font in pixels - unsigned char *pixels, int pw, int ph, // bitmap to be filled in - int first_char, int num_chars, // characters to bake - stbtt_bakedchar *chardata); // you allocate this, it's num_chars long +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, + int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, + int pw, + int ph, // bitmap to be filled in + int first_char, + int num_chars, // characters to bake + stbtt_bakedchar *chardata); // you allocate this, it's num_chars long // if return is positive, the first unused row of the bitmap // if return is negative, returns the negative of the number of characters that fit // if return is 0, no characters fit and no rows were used // This uses a very crappy packing. -typedef struct -{ - float x0,y0,s0,t0; // top-left - float x1,y1,s1,t1; // bottom-right +typedef struct { + float x0, y0, s0, t0; // top-left + float x1, y1, s1, t1; // bottom-right } stbtt_aligned_quad; STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above - int char_index, // character to display - float *xpos, float *ypos, // pointers to current position in screen pixel space - stbtt_aligned_quad *q, // output: quad to draw - int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier // Call GetBakedQuad with char_index = 'character - first_char', and it // creates the quad you need to draw and advances the current position. // @@ -561,7 +562,12 @@ STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int p // // It's inefficient; you might want to c&p it and optimize it. -STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, + int index, + float size, + float *ascent, + float *descent, + float *lineGap); // Query the font vertical metrics without having to create a font first. @@ -572,11 +578,10 @@ STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int in // This provides options for packing multiple fonts into one atlas, not // perfectly but better than nothing. -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; - float xoff2,yoff2; +typedef struct { + unsigned short x0, y0, x1, y1; // coordinates of bbox in bitmap + float xoff, yoff, xadvance; + float xoff2, yoff2; } stbtt_packedchar; typedef struct stbtt_pack_context stbtt_pack_context; @@ -585,7 +590,13 @@ typedef struct stbtt_fontinfo stbtt_fontinfo; typedef struct stbrp_rect stbrp_rect; #endif -STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, + unsigned char *pixels, + int width, + int height, + int stride_in_bytes, + int padding, + void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed // in here: a 1-channel bitmap that is width * height. stride_in_bytes is @@ -596,13 +607,18 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, i // // Returns 0 on failure, 1 on success. -STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); +STBTT_DEF void stbtt_PackEnd(stbtt_pack_context *spc); // Cleans up the packing context and frees all memory. #define STBTT_POINT_SIZE(x) (-(x)) -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, - int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, + const unsigned char *fontdata, + int font_index, + float font_size, + int first_unicode_char_in_range, + int num_chars_in_range, + stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range // bitmaps for characters with unicode values starting at first_unicode_char_in_range @@ -616,17 +632,21 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char // ..., 20 , ... // font max minus min y is 20 pixels tall // ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall -typedef struct -{ - float font_size; - int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint - int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints - int num_chars; - stbtt_packedchar *chardata_for_range; // output - unsigned char h_oversample, v_oversample; // don't set these, they're used internally +typedef struct { + float font_size; + int + first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint + int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints + int num_chars; + stbtt_packedchar *chardata_for_range; // output + unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, + const unsigned char *fontdata, + int font_index, + stbtt_pack_range *ranges, + int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple @@ -655,14 +675,22 @@ STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int s // typically an empty box by convention. STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above - int char_index, // character to display - float *xpos, float *ypos, // pointers to current position in screen pixel space - stbtt_aligned_quad *q, // output: quad to draw - int align_to_integer); - -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int align_to_integer); + +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, + const stbtt_fontinfo *info, + stbtt_pack_range *ranges, + int num_ranges, + stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, + const stbtt_fontinfo *info, + stbtt_pack_range *ranges, + int num_ranges, + stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look @@ -676,16 +704,16 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, cons // this is an opaque structure that you shouldn't mess with which holds // all the context needed from PackBegin to PackEnd. struct stbtt_pack_context { - void *user_allocator_context; - void *pack_info; - int width; - int height; - int stride_in_bytes; - int padding; - int skip_missing; - unsigned int h_oversample, v_oversample; - unsigned char *pixels; - void *nodes; + void *user_allocator_context; + void *pack_info; + int width; + int height; + int stride_in_bytes; + int padding; + int skip_missing; + unsigned int h_oversample, v_oversample; + unsigned char *pixels; + void *nodes; }; ////////////////////////////////////////////////////////////////////////////// @@ -710,24 +738,23 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // The following structure is defined publicly so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. -struct stbtt_fontinfo -{ - void * userdata; - unsigned char * data; // pointer to .ttf file - int fontstart; // offset of start of font - - int numGlyphs; // number of glyphs, needed for range checking - - int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf - int index_map; // a cmap mapping for our chosen character encoding - int indexToLocFormat; // format needed to map from glyph index to glyph - - stbtt__buf cff; // cff font data - stbtt__buf charstrings; // the charstring index - stbtt__buf gsubrs; // global charstring subroutines index - stbtt__buf subrs; // private charstring subroutines index - stbtt__buf fontdicts; // array of font dicts - stbtt__buf fdselect; // map from glyph to fontdict +struct stbtt_fontinfo { + void *userdata; + unsigned char *data; // pointer to .ttf file + int fontstart; // offset of start of font + + int numGlyphs; // number of glyphs, needed for range checking + + int loca, head, glyf, hhea, hmtx, kern, gpos, svg; // table locations as offset from start of .ttf + int index_map; // a cmap mapping for our chosen character encoding + int indexToLocFormat; // format needed to map from glyph index to glyph + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict }; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); @@ -776,7 +803,7 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size -STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 // table (specific to MS/Windows TTF files). // @@ -785,31 +812,36 @@ STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAsc STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, + int codepoint, + int *advanceWidth, + int *leftSideBearing); // leftSideBearing is the offset from the current horizontal position to the left edge of the character // advanceWidth is the offset from the current horizontal position to the next horizontal position // these are expressed in unscaled coordinates -STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); // an additional amount to add to the 'advance' value between ch1 and ch2 STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); // Gets the bounding box of the visible part of the glyph, in unscaled coordinates -STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); -STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, + int glyph_index, + int *advanceWidth, + int *leftSideBearing); +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); // as above, but takes one or more glyph indices for greater efficiency -typedef struct stbtt_kerningentry -{ - int glyph1; // use stbtt_FindGlyphIndex - int glyph2; - int advance; +typedef struct stbtt_kerningentry { + int glyph1; // use stbtt_FindGlyphIndex + int glyph2; + int advance; } stbtt_kerningentry; -STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info); -STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length); +STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info); +STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry *table, int table_length); // Retrieves a complete list of all of the kerning pairs provided by the font // stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write. // The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1) @@ -821,22 +853,21 @@ STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningen // #ifndef STBTT_vmove // you can predefine these to use different values (but why?) - enum { - STBTT_vmove=1, - STBTT_vline, - STBTT_vcurve, - STBTT_vcubic - }; +enum { + STBTT_vmove = 1, + STBTT_vline, + STBTT_vcurve, + STBTT_vcubic +}; #endif #ifndef stbtt_vertex // you can predefine this to use different values - // (we share this with other code at RAD) - #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file - typedef struct - { - stbtt_vertex_type x,y,cx,cy,cx1,cy1; - unsigned char type,padding; - } stbtt_vertex; +// (we share this with other code at RAD) + #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file +typedef struct { + stbtt_vertex_type x, y, cx, cy, cx1, cy1; + unsigned char type, padding; +} stbtt_vertex; #endif STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); @@ -871,7 +902,14 @@ STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char * STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); // frees the bitmap allocated below -STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, + float scale_x, + float scale_y, + int codepoint, + int *width, + int *height, + int *xoff, + int *yoff); // allocates a large-enough single-channel 8bpp bitmap and renders the // specified character/glyph at the specified scale into it, with // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). @@ -880,63 +918,176 @@ STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, fl // // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap -STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int codepoint, + int *width, + int *height, + int *xoff, + int *yoff); // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel // shift for the character -STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + int codepoint); // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the // width and height and positioning info for it first. -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int codepoint); // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int oversample_x, + int oversample_y, + float *sub_x, + float *sub_y, + int codepoint); // same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering // is performed (see stbtt_PackSetOversampling) -STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, + int codepoint, + float scale_x, + float scale_y, + int *ix0, + int *iy0, + int *ix1, + int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place // the bitmap top left is (leftSideBearing*scale,iy0). // (Note that the bitmap uses y-increases-down, but the shape uses // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, + int codepoint, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int *ix0, + int *iy0, + int *ix1, + int *iy1); // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel // shift for the character // the following functions are equivalent to the above functions, but operate // on glyph indices instead of Unicode codepoints (for efficiency) -STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); -STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); -STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); - +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, + float scale_x, + float scale_y, + int glyph, + int *width, + int *height, + int *xoff, + int *yoff); +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int glyph, + int *width, + int *height, + int *xoff, + int *yoff); +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, + unsigned char *output, + int out_w, + int out_h, + int out_stride, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int oversample_x, + int oversample_y, + float *sub_x, + float *sub_y, + int glyph); +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, + int glyph, + float scale_x, + float scale_y, + int *ix0, + int *iy0, + int *ix1, + int *iy1); +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, + int glyph, + float scale_x, + float scale_y, + float shift_x, + float shift_y, + int *ix0, + int *iy0, + int *ix1, + int *iy1); // @TODO: don't expose this structure -typedef struct -{ - int w,h,stride; - unsigned char *pixels; +typedef struct { + int w, h, stride; + unsigned char *pixels; } stbtt__bitmap; // rasterize a shape with quadratic beziers into a bitmap STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into - float flatness_in_pixels, // allowable error of curve in pixels - stbtt_vertex *vertices, // array of vertices defining shape - int num_verts, // number of vertices in above array - float scale_x, float scale_y, // scale applied to input vertices - float shift_x, float shift_y, // translation applied to input vertices - int x_off, int y_off, // another translation applied to input - int invert, // if non-zero, vertically flip shape - void *userdata); // context for to STBTT_MALLOC + float flatness_in_pixels, // allowable error of curve in pixels + stbtt_vertex *vertices, // array of vertices defining shape + int num_verts, // number of vertices in above array + float scale_x, float scale_y, // scale applied to input vertices + float shift_x, float shift_y, // translation applied to input vertices + int x_off, int y_off, // another translation applied to input + int invert, // if non-zero, vertically flip shape + void *userdata); // context for to STBTT_MALLOC ////////////////////////////////////////////////////////////////////////////// // @@ -945,8 +1096,26 @@ STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); // frees the SDF bitmap allocated below -STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char *stbtt_GetGlyphSDF(const stbtt_fontinfo *info, + float scale, + int glyph, + int padding, + unsigned char onedge_value, + float pixel_dist_scale, + int *width, + int *height, + int *xoff, + int *yoff); +STBTT_DEF unsigned char *stbtt_GetCodepointSDF(const stbtt_fontinfo *info, + float scale, + int codepoint, + int padding, + unsigned char onedge_value, + float pixel_dist_scale, + int *width, + int *height, + int *xoff, + int *yoff); // These functions compute a discretized SDF field for a single character, suitable for storing // in a single-channel texture, sampling with bilinear filtering, and testing against // larger than some threshold to produce scalable fonts. @@ -1033,7 +1202,12 @@ STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const // returns 1/0 whether the first string interpreted as utf8 is identical to // the second string interpreted as big-endian utf16... useful for strings from next func -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, + int *length, + int platformID, + int encodingID, + int languageID, + int nameID); // returns the string (which may be big-endian double byte, e.g. for unicode) // and puts the length in bytes in *length. // @@ -1042,52 +1216,52 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l // http://www.microsoft.com/typography/otspec/name.htm enum { // platformID - STBTT_PLATFORM_ID_UNICODE =0, - STBTT_PLATFORM_ID_MAC =1, - STBTT_PLATFORM_ID_ISO =2, - STBTT_PLATFORM_ID_MICROSOFT =3 + STBTT_PLATFORM_ID_UNICODE = 0, + STBTT_PLATFORM_ID_MAC = 1, + STBTT_PLATFORM_ID_ISO = 2, + STBTT_PLATFORM_ID_MICROSOFT = 3 }; enum { // encodingID for STBTT_PLATFORM_ID_UNICODE - STBTT_UNICODE_EID_UNICODE_1_0 =0, - STBTT_UNICODE_EID_UNICODE_1_1 =1, - STBTT_UNICODE_EID_ISO_10646 =2, - STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, - STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 + STBTT_UNICODE_EID_UNICODE_1_0 = 0, + STBTT_UNICODE_EID_UNICODE_1_1 = 1, + STBTT_UNICODE_EID_ISO_10646 = 2, + STBTT_UNICODE_EID_UNICODE_2_0_BMP = 3, + STBTT_UNICODE_EID_UNICODE_2_0_FULL = 4 }; enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT - STBTT_MS_EID_SYMBOL =0, - STBTT_MS_EID_UNICODE_BMP =1, - STBTT_MS_EID_SHIFTJIS =2, - STBTT_MS_EID_UNICODE_FULL =10 + STBTT_MS_EID_SYMBOL = 0, + STBTT_MS_EID_UNICODE_BMP = 1, + STBTT_MS_EID_SHIFTJIS = 2, + STBTT_MS_EID_UNICODE_FULL = 10 }; enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes - STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, - STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, - STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, - STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 + STBTT_MAC_EID_ROMAN = 0, STBTT_MAC_EID_ARABIC = 4, + STBTT_MAC_EID_JAPANESE = 1, STBTT_MAC_EID_HEBREW = 5, + STBTT_MAC_EID_CHINESE_TRAD = 2, STBTT_MAC_EID_GREEK = 6, + STBTT_MAC_EID_KOREAN = 3, STBTT_MAC_EID_RUSSIAN = 7 }; enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... - // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs - STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, - STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, - STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, - STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, - STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, - STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + STBTT_MS_LANG_ENGLISH = 0x0409, STBTT_MS_LANG_ITALIAN = 0x0410, + STBTT_MS_LANG_CHINESE = 0x0804, STBTT_MS_LANG_JAPANESE = 0x0411, + STBTT_MS_LANG_DUTCH = 0x0413, STBTT_MS_LANG_KOREAN = 0x0412, + STBTT_MS_LANG_FRENCH = 0x040c, STBTT_MS_LANG_RUSSIAN = 0x0419, + STBTT_MS_LANG_GERMAN = 0x0407, STBTT_MS_LANG_SPANISH = 0x0409, + STBTT_MS_LANG_HEBREW = 0x040d, STBTT_MS_LANG_SWEDISH = 0x041D }; enum { // languageID for STBTT_PLATFORM_ID_MAC - STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, - STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, - STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, - STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , - STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , - STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, - STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 + STBTT_MAC_LANG_ENGLISH = 0, STBTT_MAC_LANG_JAPANESE = 11, + STBTT_MAC_LANG_ARABIC = 12, STBTT_MAC_LANG_KOREAN = 23, + STBTT_MAC_LANG_DUTCH = 4, STBTT_MAC_LANG_RUSSIAN = 32, + STBTT_MAC_LANG_FRENCH = 1, STBTT_MAC_LANG_SPANISH = 6, + STBTT_MAC_LANG_GERMAN = 2, STBTT_MAC_LANG_SWEDISH = 5, + STBTT_MAC_LANG_HEBREW = 10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED = 33, + STBTT_MAC_LANG_ITALIAN = 3, STBTT_MAC_LANG_CHINESE_TRAD = 19 }; #ifdef __cplusplus @@ -1133,14 +1307,14 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) { if (b->cursor >= b->size) - return 0; + return 0; return b->data[b->cursor++]; } static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) { if (b->cursor >= b->size) - return 0; + return 0; return b->data[b->cursor]; } @@ -1161,7 +1335,7 @@ static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) int i; STBTT_assert(n >= 1 && n <= 4); for (i = 0; i < n; i++) - v = (v << 8) | stbtt__buf_get8(b); + v = (v << 8) | stbtt__buf_get8(b); return v; } @@ -1193,10 +1367,10 @@ static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) start = b->cursor; count = stbtt__buf_get16(b); if (count) { - offsize = stbtt__buf_get8(b); - STBTT_assert(offsize >= 1 && offsize <= 4); - stbtt__buf_skip(b, offsize * count); - stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); } return stbtt__buf_range(b, start, b->cursor - start); } @@ -1217,14 +1391,14 @@ static void stbtt__cff_skip_operand(stbtt__buf *b) { int v, b0 = stbtt__buf_peek8(b); STBTT_assert(b0 >= 28); if (b0 == 30) { - stbtt__buf_skip(b, 1); - while (b->cursor < b->size) { - v = stbtt__buf_get8(b); - if ((v & 0xF) == 0xF || (v >> 4) == 0xF) - break; - } + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } } else { - stbtt__cff_int(b); + stbtt__cff_int(b); } } @@ -1232,13 +1406,13 @@ static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) { stbtt__buf_seek(b, 0); while (b->cursor < b->size) { - int start = b->cursor, end, op; - while (stbtt__buf_peek8(b) >= 28) - stbtt__cff_skip_operand(b); - end = b->cursor; - op = stbtt__buf_get8(b); - if (op == 12) op = stbtt__buf_get8(b) | 0x100; - if (op == key) return stbtt__buf_range(b, start, end-start); + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); } return stbtt__buf_range(b, 0, 0); } @@ -1248,7 +1422,7 @@ static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uin int i; stbtt__buf operands = stbtt__dict_get(b, key); for (i = 0; i < outcount && operands.cursor < operands.size; i++) - out[i] = stbtt__cff_int(&operands); + out[i] = stbtt__cff_int(&operands); } static int stbtt__cff_index_count(stbtt__buf *b) @@ -1309,9 +1483,9 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, stbtt_uint32 tabledir = fontstart + 12; stbtt_int32 i; for (i=0; i < num_tables; ++i) { - stbtt_uint32 loc = tabledir + 16*i; - if (stbtt_tag(data+loc+0, tag)) - return ttULONG(data+loc+8); + stbtt_uint32 loc = tabledir + 16*i; + if (stbtt_tag(data+loc+0, tag)) + return ttULONG(data+loc+8); } return 0; } @@ -1320,17 +1494,17 @@ static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) - return index == 0 ? 0 : -1; + return index == 0 ? 0 : -1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { - // version 1? - if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { - stbtt_int32 n = ttLONG(font_collection+8); - if (index >= n) - return -1; - return ttULONG(font_collection+12+index*4); - } + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + stbtt_int32 n = ttLONG(font_collection+8); + if (index >= n) + return -1; + return ttULONG(font_collection+12+index*4); + } } return -1; } @@ -1339,14 +1513,14 @@ static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) { // if it's just a font, there's only one valid font if (stbtt__isfont(font_collection)) - return 1; + return 1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { - // version 1? - if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { - return ttLONG(font_collection+8); - } + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } } return 0; } @@ -1369,13 +1543,13 @@ static int stbtt__get_svg(stbtt_fontinfo *info) { stbtt_uint32 t; if (info->svg < 0) { - t = stbtt__find_table(info->data, info->fontstart, "SVG "); - if (t) { - stbtt_uint32 offset = ttULONG(info->data + t + 2); - info->svg = t + offset; - } else { - info->svg = 0; - } + t = stbtt__find_table(info->data, info->fontstart, "SVG "); + if (t) { + stbtt_uint32 offset = ttULONG(info->data + t + 2); + info->svg = t + offset; + } else { + info->svg = 0; + } } return info->svg; } @@ -1399,65 +1573,65 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required if (!cmap || !info->head || !info->hhea || !info->hmtx) - return 0; + return 0; if (info->glyf) { - // required for truetype - if (!info->loca) return 0; + // required for truetype + if (!info->loca) return 0; } else { - // initialization for CFF / Type2 fonts (OTF) - stbtt__buf b, topdict, topdictidx; - stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; - stbtt_uint32 cff; - - cff = stbtt__find_table(data, fontstart, "CFF "); - if (!cff) return 0; - - info->fontdicts = stbtt__new_buf(NULL, 0); - info->fdselect = stbtt__new_buf(NULL, 0); - - // @TODO this should use size from table (not 512MB) - info->cff = stbtt__new_buf(data+cff, 512*1024*1024); - b = info->cff; - - // read the header - stbtt__buf_skip(&b, 2); - stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize - - // @TODO the name INDEX could list multiple fonts, - // but we just use the first one. - stbtt__cff_get_index(&b); // name INDEX - topdictidx = stbtt__cff_get_index(&b); - topdict = stbtt__cff_index_get(topdictidx, 0); - stbtt__cff_get_index(&b); // string INDEX - info->gsubrs = stbtt__cff_get_index(&b); - - stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); - stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); - stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); - stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); - info->subrs = stbtt__get_subrs(b, topdict); - - // we only support Type 2 charstrings - if (cstype != 2) return 0; - if (charstrings == 0) return 0; - - if (fdarrayoff) { - // looks like a CID font - if (!fdselectoff) return 0; - stbtt__buf_seek(&b, fdarrayoff); - info->fontdicts = stbtt__cff_get_index(&b); - info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); - } - - stbtt__buf_seek(&b, charstrings); - info->charstrings = stbtt__cff_get_index(&b); + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); } t = stbtt__find_table(data, fontstart, "maxp"); if (t) - info->numGlyphs = ttUSHORT(data+t+4); + info->numGlyphs = ttUSHORT(data+t+4); else - info->numGlyphs = 0xffff; + info->numGlyphs = 0xffff; info->svg = -1; @@ -1467,27 +1641,27 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in numTables = ttUSHORT(data + cmap + 2); info->index_map = 0; for (i=0; i < numTables; ++i) { - stbtt_uint32 encoding_record = cmap + 4 + 8 * i; - // find an encoding we understand: - switch(ttUSHORT(data+encoding_record)) { - case STBTT_PLATFORM_ID_MICROSOFT: - switch (ttUSHORT(data+encoding_record+2)) { - case STBTT_MS_EID_UNICODE_BMP: - case STBTT_MS_EID_UNICODE_FULL: - // MS/Unicode - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } - break; - case STBTT_PLATFORM_ID_UNICODE: - // Mac/iOS has these - // all the encodingIDs are unicode, so we don't bother to check it - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } + stbtt_uint32 encoding_record = cmap + 4 + 8 * i; + // find an encoding we understand: + switch(ttUSHORT(data+encoding_record)) { + case STBTT_PLATFORM_ID_MICROSOFT: + switch (ttUSHORT(data+encoding_record+2)) { + case STBTT_MS_EID_UNICODE_BMP: + case STBTT_MS_EID_UNICODE_FULL: + // MS/Unicode + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + break; + case STBTT_PLATFORM_ID_UNICODE: + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } } if (info->index_map == 0) - return 0; + return 0; info->indexToLocFormat = ttUSHORT(data+info->head + 50); return 1; @@ -1500,86 +1674,86 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep stbtt_uint16 format = ttUSHORT(data + index_map + 0); if (format == 0) { // apple byte encoding - stbtt_int32 bytes = ttUSHORT(data + index_map + 2); - if (unicode_codepoint < bytes-6) - return ttBYTE(data + index_map + 6 + unicode_codepoint); - return 0; + stbtt_int32 bytes = ttUSHORT(data + index_map + 2); + if (unicode_codepoint < bytes-6) + return ttBYTE(data + index_map + 6 + unicode_codepoint); + return 0; } else if (format == 6) { - stbtt_uint32 first = ttUSHORT(data + index_map + 6); - stbtt_uint32 count = ttUSHORT(data + index_map + 8); - if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) - return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); - return 0; + stbtt_uint32 first = ttUSHORT(data + index_map + 6); + stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); + return 0; } else if (format == 2) { - STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean - return 0; + STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean + return 0; } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges - stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; - stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; - stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); - stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; - - // do a binary search of the segments - stbtt_uint32 endCount = index_map + 14; - stbtt_uint32 search = endCount; - - if (unicode_codepoint > 0xffff) - return 0; - - // they lie from endCount .. endCount + segCount - // but searchRange is the nearest power of two, so... - if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) - search += rangeShift*2; - - // now decrement to bias correctly to find smallest - search -= 2; - while (entrySelector) { - stbtt_uint16 end; - searchRange >>= 1; - end = ttUSHORT(data + search + searchRange*2); - if (unicode_codepoint > end) - search += searchRange*2; - --entrySelector; - } - search += 2; - - { - stbtt_uint16 offset, start, last; - stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); - - start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); - last = ttUSHORT(data + endCount + 2*item); - if (unicode_codepoint < start || unicode_codepoint > last) - return 0; - - offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); - if (offset == 0) - return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); - - return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); - } + stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); + stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + + // do a binary search of the segments + stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; + + if (unicode_codepoint > 0xffff) + return 0; + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) + search += rangeShift*2; + + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange*2); + if (unicode_codepoint > end) + search += searchRange*2; + --entrySelector; + } + search += 2; + + { + stbtt_uint16 offset, start, last; + stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + + start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); + last = ttUSHORT(data + endCount + 2*item); + if (unicode_codepoint < start || unicode_codepoint > last) + return 0; + + offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); + if (offset == 0) + return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + + return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); + } } else if (format == 12 || format == 13) { - stbtt_uint32 ngroups = ttULONG(data+index_map+12); - stbtt_int32 low,high; - low = 0; high = (stbtt_int32)ngroups; - // Binary search the right group. - while (low < high) { - stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high - stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); - stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); - if ((stbtt_uint32) unicode_codepoint < start_char) - high = mid; - else if ((stbtt_uint32) unicode_codepoint > end_char) - low = mid+1; - else { - stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); - if (format == 12) - return start_glyph + unicode_codepoint-start_char; - else // format == 13 - return start_glyph; - } - } - return 0; // not found + stbtt_uint32 ngroups = ttULONG(data+index_map+12); + stbtt_int32 low,high; + low = 0; high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) { + stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high + stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); + stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); + if ((stbtt_uint32) unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32) unicode_codepoint > end_char) + low = mid+1; + else { + stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); + if (format == 12) + return start_glyph + unicode_codepoint-start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found } // @TODO STBTT_assert(0); @@ -1610,11 +1784,11 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format if (info->indexToLocFormat == 0) { - g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; - g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; + g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; + g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; } else { - g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); - g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); + g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); + g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); } return g1==g2 ? -1 : g1; // if length is 0, return -1 @@ -1625,15 +1799,15 @@ static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, in STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { if (info->cff.size) { - stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); } else { - int g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 0; + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; - if (x0) *x0 = ttSHORT(info->data + g + 2); - if (y0) *y0 = ttSHORT(info->data + g + 4); - if (x1) *x1 = ttSHORT(info->data + g + 6); - if (y1) *y1 = ttSHORT(info->data + g + 8); + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); } return 1; } @@ -1648,7 +1822,7 @@ STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) stbtt_int16 numberOfContours; int g; if (info->cff.size) - return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); @@ -1656,17 +1830,17 @@ STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) } static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, - stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) + stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) { if (start_off) { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); } return num_vertices; } @@ -1687,207 +1861,207 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s numberOfContours = ttSHORT(data + g); if (numberOfContours > 0) { - stbtt_uint8 flags=0,flagcount; - stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; - stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; - stbtt_uint8 *points; - endPtsOfContours = (data + g + 10); - ins = ttUSHORT(data + g + 10 + numberOfContours * 2); - points = data + g + 10 + numberOfContours * 2 + 2 + ins; - - n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); - - m = n + 2*numberOfContours; // a loose bound on how many vertices we might need - vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); - if (vertices == 0) - return 0; - - next_move = 0; - flagcount=0; - - // in first pass, we load uninterpreted data into the allocated array - // above, shifted to the end of the array so we won't overwrite it when - // we create our final data starting from the front - - off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated - - // first load flags - - for (i=0; i < n; ++i) { - if (flagcount == 0) { - flags = *points++; - if (flags & 8) - flagcount = *points++; - } else - --flagcount; - vertices[off+i].type = flags; - } - - // now load x coordinates - x=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 2) { - stbtt_int16 dx = *points++; - x += (flags & 16) ? dx : -dx; // ??? - } else { - if (!(flags & 16)) { - x = x + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].x = (stbtt_int16) x; - } - - // now load y coordinates - y=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 4) { - stbtt_int16 dy = *points++; - y += (flags & 32) ? dy : -dy; // ??? - } else { - if (!(flags & 32)) { - y = y + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].y = (stbtt_int16) y; - } - - // now convert them to our format - num_vertices=0; - sx = sy = cx = cy = scx = scy = 0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - x = (stbtt_int16) vertices[off+i].x; - y = (stbtt_int16) vertices[off+i].y; - - if (next_move == i) { - if (i != 0) - num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - - // now start the new one - start_off = !(flags & 1); - if (start_off) { - // if we start off with an off-curve point, then when we need to find a point on the curve - // where we can start, and we need to save some state for when we wraparound. - scx = x; - scy = y; - if (!(vertices[off+i+1].type & 1)) { - // next point is also a curve point, so interpolate an on-point curve - sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; - sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; - } else { - // otherwise just use the next point as our start point - sx = (stbtt_int32) vertices[off+i+1].x; - sy = (stbtt_int32) vertices[off+i+1].y; - ++i; // we're using point i+1 as the starting point, so skip it - } - } else { - sx = x; - sy = y; - } - stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); - was_off = 0; - next_move = 1 + ttUSHORT(endPtsOfContours+j*2); - ++j; - } else { - if (!(flags & 1)) { // if it's a curve - if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); - cx = x; - cy = y; - was_off = 1; - } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); - was_off = 0; - } - } - } - num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + stbtt_uint8 flags=0,flagcount; + stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; + stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; + stbtt_uint8 *points; + endPtsOfContours = (data + g + 10); + ins = ttUSHORT(data + g + 10 + numberOfContours * 2); + points = data + g + 10 + numberOfContours * 2 + 2 + ins; + + n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); + + m = n + 2*numberOfContours; // a loose bound on how many vertices we might need + vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); + if (vertices == 0) + return 0; + + next_move = 0; + flagcount=0; + + // in first pass, we load uninterpreted data into the allocated array + // above, shifted to the end of the array so we won't overwrite it when + // we create our final data starting from the front + + off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated + + // first load flags + + for (i=0; i < n; ++i) { + if (flagcount == 0) { + flags = *points++; + if (flags & 8) + flagcount = *points++; + } else + --flagcount; + vertices[off+i].type = flags; + } + + // now load x coordinates + x=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 2) { + stbtt_int16 dx = *points++; + x += (flags & 16) ? dx : -dx; // ??? + } else { + if (!(flags & 16)) { + x = x + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].x = (stbtt_int16) x; + } + + // now load y coordinates + y=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 4) { + stbtt_int16 dy = *points++; + y += (flags & 32) ? dy : -dy; // ??? + } else { + if (!(flags & 32)) { + y = y + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].y = (stbtt_int16) y; + } + + // now convert them to our format + num_vertices=0; + sx = sy = cx = cy = scx = scy = 0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + x = (stbtt_int16) vertices[off+i].x; + y = (stbtt_int16) vertices[off+i].y; + + if (next_move == i) { + if (i != 0) + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + + // now start the new one + start_off = !(flags & 1); + if (start_off) { + // if we start off with an off-curve point, then when we need to find a point on the curve + // where we can start, and we need to save some state for when we wraparound. + scx = x; + scy = y; + if (!(vertices[off+i+1].type & 1)) { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; + sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = (stbtt_int32) vertices[off+i+1].x; + sy = (stbtt_int32) vertices[off+i+1].y; + ++i; // we're using point i+1 as the starting point, so skip it + } + } else { + sx = x; + sy = y; + } + stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); + was_off = 0; + next_move = 1 + ttUSHORT(endPtsOfContours+j*2); + ++j; + } else { + if (!(flags & 1)) { // if it's a curve + if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); + cx = x; + cy = y; + was_off = 1; + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); + was_off = 0; + } + } + } + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); } else if (numberOfContours < 0) { - // Compound shapes. - int more = 1; - stbtt_uint8 *comp = data + g + 10; - num_vertices = 0; - vertices = 0; - while (more) { - stbtt_uint16 flags, gidx; - int comp_num_verts = 0, i; - stbtt_vertex *comp_verts = 0, *tmp = 0; - float mtx[6] = {1,0,0,1,0,0}, m, n; - - flags = ttSHORT(comp); comp+=2; - gidx = ttSHORT(comp); comp+=2; - - if (flags & 2) { // XY values - if (flags & 1) { // shorts - mtx[4] = ttSHORT(comp); comp+=2; - mtx[5] = ttSHORT(comp); comp+=2; - } else { - mtx[4] = ttCHAR(comp); comp+=1; - mtx[5] = ttCHAR(comp); comp+=1; - } - } - else { - // @TODO handle matching point - STBTT_assert(0); - } - if (flags & (1<<3)) { // WE_HAVE_A_SCALE - mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - } - - // Find transformation scales. - m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); - n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); - - // Get indexed glyph. - comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); - if (comp_num_verts > 0) { - // Transform vertices. - for (i = 0; i < comp_num_verts; ++i) { - stbtt_vertex* v = &comp_verts[i]; - stbtt_vertex_type x,y; - x=v->x; y=v->y; - v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - x=v->cx; y=v->cy; - v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - } - // Append vertices. - tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); - if (!tmp) { - if (vertices) STBTT_free(vertices, info->userdata); - if (comp_verts) STBTT_free(comp_verts, info->userdata); - return 0; - } - if (num_vertices > 0 && vertices) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); - STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); - if (vertices) STBTT_free(vertices, info->userdata); - vertices = tmp; - STBTT_free(comp_verts, info->userdata); - num_vertices += comp_num_verts; - } - // More components ? - more = flags & (1<<5); - } + // Compound shapes. + int more = 1; + stbtt_uint8 *comp = data + g + 10; + num_vertices = 0; + vertices = 0; + while (more) { + stbtt_uint16 flags, gidx; + int comp_num_verts = 0, i; + stbtt_vertex *comp_verts = 0, *tmp = 0; + float mtx[6] = {1,0,0,1,0,0}, m, n; + + flags = ttSHORT(comp); comp+=2; + gidx = ttSHORT(comp); comp+=2; + + if (flags & 2) { // XY values + if (flags & 1) { // shorts + mtx[4] = ttSHORT(comp); comp+=2; + mtx[5] = ttSHORT(comp); comp+=2; + } else { + mtx[4] = ttCHAR(comp); comp+=1; + mtx[5] = ttCHAR(comp); comp+=1; + } + } + else { + // @TODO handle matching point + STBTT_assert(0); + } + if (flags & (1<<3)) { // WE_HAVE_A_SCALE + mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } + + // Find transformation scales. + m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); + n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); + + // Get indexed glyph. + comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); + if (comp_num_verts > 0) { + // Transform vertices. + for (i = 0; i < comp_num_verts; ++i) { + stbtt_vertex* v = &comp_verts[i]; + stbtt_vertex_type x,y; + x=v->x; y=v->y; + v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + x=v->cx; y=v->cy; + v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + } + // Append vertices. + tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); + if (!tmp) { + if (vertices) STBTT_free(vertices, info->userdata); + if (comp_verts) STBTT_free(comp_verts, info->userdata); + return 0; + } + if (num_vertices > 0 && vertices) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); + STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); + if (vertices) STBTT_free(vertices, info->userdata); + vertices = tmp; + STBTT_free(comp_verts, info->userdata); + num_vertices += comp_num_verts; + } + // More components ? + more = flags & (1<<5); + } } else { - // numberOfCounters == 0, do nothing + // numberOfCounters == 0, do nothing } *pvertices = vertices; @@ -1920,15 +2094,15 @@ static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) { if (c->bounds) { - stbtt__track_vertex(c, x, y); - if (type == STBTT_vcubic) { - stbtt__track_vertex(c, cx, cy); - stbtt__track_vertex(c, cx1, cy1); - } + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } } else { - stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); - c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; - c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; } c->num_vertices++; } @@ -1936,7 +2110,7 @@ static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stb static void stbtt__csctx_close_shape(stbtt__csctx *ctx) { if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) - stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); } static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) @@ -1970,12 +2144,12 @@ static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) int count = stbtt__cff_index_count(&idx); int bias = 107; if (count >= 33900) - bias = 32768; + bias = 32768; else if (count >= 1240) - bias = 1131; + bias = 1131; n += bias; if (n < 0 || n >= count) - return stbtt__new_buf(NULL, 0); + return stbtt__new_buf(NULL, 0); return stbtt__cff_index_get(idx, n); } @@ -1987,21 +2161,21 @@ static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int gly stbtt__buf_seek(&fdselect, 0); fmt = stbtt__buf_get8(&fdselect); if (fmt == 0) { - // untested - stbtt__buf_skip(&fdselect, glyph_index); - fdselector = stbtt__buf_get8(&fdselect); + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); } else if (fmt == 3) { - nranges = stbtt__buf_get16(&fdselect); - start = stbtt__buf_get16(&fdselect); - for (i = 0; i < nranges; i++) { - v = stbtt__buf_get8(&fdselect); - end = stbtt__buf_get16(&fdselect); - if (glyph_index >= start && glyph_index < end) { - fdselector = v; - break; - } - start = end; - } + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } } if (fdselector == -1) stbtt__new_buf(NULL, 0); return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); @@ -2020,246 +2194,246 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st // this currently ignores the initial width value, which isn't needed if we have hmtx b = stbtt__cff_index_get(info->charstrings, glyph_index); while (b.cursor < b.size) { - i = 0; - clear_stack = 1; - b0 = stbtt__buf_get8(&b); - switch (b0) { - // @TODO implement hinting - case 0x13: // hintmask - case 0x14: // cntrmask - if (in_header) - maskbits += (sp / 2); // implicit "vstem" - in_header = 0; - stbtt__buf_skip(&b, (maskbits + 7) / 8); - break; - - case 0x01: // hstem - case 0x03: // vstem - case 0x12: // hstemhm - case 0x17: // vstemhm - maskbits += (sp / 2); - break; - - case 0x15: // rmoveto - in_header = 0; - if (sp < 2) return STBTT__CSERR("rmoveto stack"); - stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); - break; - case 0x04: // vmoveto - in_header = 0; - if (sp < 1) return STBTT__CSERR("vmoveto stack"); - stbtt__csctx_rmove_to(c, 0, s[sp-1]); - break; - case 0x16: // hmoveto - in_header = 0; - if (sp < 1) return STBTT__CSERR("hmoveto stack"); - stbtt__csctx_rmove_to(c, s[sp-1], 0); - break; - - case 0x05: // rlineto - if (sp < 2) return STBTT__CSERR("rlineto stack"); - for (; i + 1 < sp; i += 2) - stbtt__csctx_rline_to(c, s[i], s[i+1]); - break; - - // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical - // starting from a different place. - - case 0x07: // vlineto - if (sp < 1) return STBTT__CSERR("vlineto stack"); - goto vlineto; - case 0x06: // hlineto - if (sp < 1) return STBTT__CSERR("hlineto stack"); - for (;;) { - if (i >= sp) break; - stbtt__csctx_rline_to(c, s[i], 0); - i++; - vlineto: - if (i >= sp) break; - stbtt__csctx_rline_to(c, 0, s[i]); - i++; - } - break; - - case 0x1F: // hvcurveto - if (sp < 4) return STBTT__CSERR("hvcurveto stack"); - goto hvcurveto; - case 0x1E: // vhcurveto - if (sp < 4) return STBTT__CSERR("vhcurveto stack"); - for (;;) { - if (i + 3 >= sp) break; - stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); - i += 4; - hvcurveto: - if (i + 3 >= sp) break; - stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); - i += 4; - } - break; - - case 0x08: // rrcurveto - if (sp < 6) return STBTT__CSERR("rcurveline stack"); - for (; i + 5 < sp; i += 6) - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - break; - - case 0x18: // rcurveline - if (sp < 8) return STBTT__CSERR("rcurveline stack"); - for (; i + 5 < sp - 2; i += 6) - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); - stbtt__csctx_rline_to(c, s[i], s[i+1]); - break; - - case 0x19: // rlinecurve - if (sp < 8) return STBTT__CSERR("rlinecurve stack"); - for (; i + 1 < sp - 6; i += 2) - stbtt__csctx_rline_to(c, s[i], s[i+1]); - if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - break; - - case 0x1A: // vvcurveto - case 0x1B: // hhcurveto - if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); - f = 0.0; - if (sp & 1) { f = s[i]; i++; } - for (; i + 3 < sp; i += 4) { - if (b0 == 0x1B) - stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); - else - stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); - f = 0.0; - } - break; - - case 0x0A: // callsubr - if (!has_subrs) { - if (info->fdselect.size) - subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); - has_subrs = 1; - } - // FALLTHROUGH - case 0x1D: // callgsubr - if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); - v = (int) s[--sp]; - if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); - subr_stack[subr_stack_height++] = b; - b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); - if (b.size == 0) return STBTT__CSERR("subr not found"); - b.cursor = 0; - clear_stack = 0; - break; - - case 0x0B: // return - if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); - b = subr_stack[--subr_stack_height]; - clear_stack = 0; - break; - - case 0x0E: // endchar - stbtt__csctx_close_shape(c); - return 1; - - case 0x0C: { // two-byte escape - float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; - float dx, dy; - int b1 = stbtt__buf_get8(&b); - switch (b1) { - // @TODO These "flex" implementations ignore the flex-depth and resolution, - // and always draw beziers. - case 0x22: // hflex - if (sp < 7) return STBTT__CSERR("hflex stack"); - dx1 = s[0]; - dx2 = s[1]; - dy2 = s[2]; - dx3 = s[3]; - dx4 = s[4]; - dx5 = s[5]; - dx6 = s[6]; - stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); - stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); - break; - - case 0x23: // flex - if (sp < 13) return STBTT__CSERR("flex stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dy3 = s[5]; - dx4 = s[6]; - dy4 = s[7]; - dx5 = s[8]; - dy5 = s[9]; - dx6 = s[10]; - dy6 = s[11]; - //fd is s[12] - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); - stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); - break; - - case 0x24: // hflex1 - if (sp < 9) return STBTT__CSERR("hflex1 stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dx4 = s[5]; - dx5 = s[6]; - dy5 = s[7]; - dx6 = s[8]; - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); - stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); - break; - - case 0x25: // flex1 - if (sp < 11) return STBTT__CSERR("flex1 stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dy3 = s[5]; - dx4 = s[6]; - dy4 = s[7]; - dx5 = s[8]; - dy5 = s[9]; - dx6 = dy6 = s[10]; - dx = dx1+dx2+dx3+dx4+dx5; - dy = dy1+dy2+dy3+dy4+dy5; - if (STBTT_fabs(dx) > STBTT_fabs(dy)) - dy6 = -dy; - else - dx6 = -dx; - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); - stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); - break; - - default: - return STBTT__CSERR("unimplemented"); - } - } break; - - default: - if (b0 != 255 && b0 != 28 && b0 < 32) - return STBTT__CSERR("reserved operator"); - - // push immediate - if (b0 == 255) { - f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; - } else { - stbtt__buf_skip(&b, -1); - f = (float)(stbtt_int16)stbtt__cff_int(&b); - } - if (sp >= 48) return STBTT__CSERR("push stack overflow"); - s[sp++] = f; - clear_stack = 0; - break; - } - if (clear_stack) sp = 0; + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // FALLTHROUGH + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-byte escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && b0 < 32) + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; } return STBTT__CSERR("no endchar"); @@ -2272,12 +2446,12 @@ static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, s stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { - *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); - output_ctx.pvertices = *pvertices; - if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { - STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); - return output_ctx.num_vertices; - } + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } } *pvertices = NULL; return 0; @@ -2297,20 +2471,20 @@ static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, in STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { if (!info->cff.size) - return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); else - return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); } STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); if (glyph_index < numOfLongHorMetrics) { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); } else { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); } } @@ -2320,11 +2494,11 @@ STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info) // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) - return 0; + return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 - return 0; + return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format - return 0; + return 0; return ttUSHORT(data+10); } @@ -2336,21 +2510,21 @@ STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningent // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) - return 0; + return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 - return 0; + return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format - return 0; + return 0; length = ttUSHORT(data+10); if (table_length < length) - length = table_length; + length = table_length; for (k = 0; k < length; k++) { - table[k].glyph1 = ttUSHORT(data+18+(k*6)); - table[k].glyph2 = ttUSHORT(data+20+(k*6)); - table[k].advance = ttSHORT(data+22+(k*6)); + table[k].glyph1 = ttUSHORT(data+18+(k*6)); + table[k].glyph2 = ttUSHORT(data+20+(k*6)); + table[k].advance = ttSHORT(data+22+(k*6)); } return length; @@ -2364,24 +2538,24 @@ static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1 // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) - return 0; + return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 - return 0; + return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format - return 0; + return 0; l = 0; r = ttUSHORT(data+10) - 1; needle = glyph1 << 16 | glyph2; while (l <= r) { - m = (l + r) >> 1; - straw = ttULONG(data+18+(m*6)); // note: unaligned read - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else - return ttSHORT(data+22+(m*6)); + m = (l + r) >> 1; + straw = ttULONG(data+18+(m*6)); // note: unaligned read + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else + return ttSHORT(data+22+(m*6)); } return 0; } @@ -2390,55 +2564,55 @@ static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph { stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); switch (coverageFormat) { - case 1: { - stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); - - // Binary search. - stbtt_int32 l=0, r=glyphCount-1, m; - int straw, needle=glyph; - while (l <= r) { - stbtt_uint8 *glyphArray = coverageTable + 4; - stbtt_uint16 glyphID; - m = (l + r) >> 1; - glyphID = ttUSHORT(glyphArray + 2 * m); - straw = glyphID; - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else { - return m; - } - } - break; - } - - case 2: { - stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); - stbtt_uint8 *rangeArray = coverageTable + 4; - - // Binary search. - stbtt_int32 l=0, r=rangeCount-1, m; - int strawStart, strawEnd, needle=glyph; - while (l <= r) { - stbtt_uint8 *rangeRecord; - m = (l + r) >> 1; - rangeRecord = rangeArray + 6 * m; - strawStart = ttUSHORT(rangeRecord); - strawEnd = ttUSHORT(rangeRecord + 2); - if (needle < strawStart) - r = m - 1; - else if (needle > strawEnd) - l = m + 1; - else { - stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); - return startCoverageIndex + glyph - strawStart; - } - } - break; - } - - default: return -1; // unsupported + case 1: { + stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); + + // Binary search. + stbtt_int32 l=0, r=glyphCount-1, m; + int straw, needle=glyph; + while (l <= r) { + stbtt_uint8 *glyphArray = coverageTable + 4; + stbtt_uint16 glyphID; + m = (l + r) >> 1; + glyphID = ttUSHORT(glyphArray + 2 * m); + straw = glyphID; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + return m; + } + } + break; + } + + case 2: { + stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); + stbtt_uint8 *rangeArray = coverageTable + 4; + + // Binary search. + stbtt_int32 l=0, r=rangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *rangeRecord; + m = (l + r) >> 1; + rangeRecord = rangeArray + 6 * m; + strawStart = ttUSHORT(rangeRecord); + strawEnd = ttUSHORT(rangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else { + stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); + return startCoverageIndex + glyph - strawStart; + } + } + break; + } + + default: return -1; // unsupported } return -1; @@ -2449,41 +2623,41 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); switch (classDefFormat) { - case 1: { - stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); - stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); - stbtt_uint8 *classDef1ValueArray = classDefTable + 6; - - if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) - return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); - break; - } - - case 2: { - stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); - stbtt_uint8 *classRangeRecords = classDefTable + 4; - - // Binary search. - stbtt_int32 l=0, r=classRangeCount-1, m; - int strawStart, strawEnd, needle=glyph; - while (l <= r) { - stbtt_uint8 *classRangeRecord; - m = (l + r) >> 1; - classRangeRecord = classRangeRecords + 6 * m; - strawStart = ttUSHORT(classRangeRecord); - strawEnd = ttUSHORT(classRangeRecord + 2); - if (needle < strawStart) - r = m - 1; - else if (needle > strawEnd) - l = m + 1; - else - return (stbtt_int32)ttUSHORT(classRangeRecord + 4); - } - break; - } - - default: - return -1; // Unsupported definition type, return an error. + case 1: { + stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); + stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); + stbtt_uint8 *classDef1ValueArray = classDefTable + 6; + + if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) + return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); + break; + } + + case 2: { + stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); + stbtt_uint8 *classRangeRecords = classDefTable + 4; + + // Binary search. + stbtt_int32 l=0, r=classRangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *classRangeRecord; + m = (l + r) >> 1; + classRangeRecord = classRangeRecords + 6 * m; + strawStart = ttUSHORT(classRangeRecord); + strawEnd = ttUSHORT(classRangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else + return (stbtt_int32)ttUSHORT(classRangeRecord + 4); + } + break; + } + + default: + return -1; // Unsupported definition type, return an error. } // "All glyphs not assigned to a class fall into class 0". (OpenType spec) @@ -2513,95 +2687,95 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, in lookupCount = ttUSHORT(lookupList); for (i=0; i<lookupCount; ++i) { - stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i); - stbtt_uint8 *lookupTable = lookupList + lookupOffset; - - stbtt_uint16 lookupType = ttUSHORT(lookupTable); - stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4); - stbtt_uint8 *subTableOffsets = lookupTable + 6; - if (lookupType != 2) // Pair Adjustment Positioning Subtable - continue; - - for (sti=0; sti<subTableCount; sti++) { - stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti); - stbtt_uint8 *table = lookupTable + subtableOffset; - stbtt_uint16 posFormat = ttUSHORT(table); - stbtt_uint16 coverageOffset = ttUSHORT(table + 2); - stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1); - if (coverageIndex == -1) continue; - - switch (posFormat) { - case 1: { - stbtt_int32 l, r, m; - int straw, needle; - stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); - stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); - if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats? - stbtt_int32 valueRecordPairSizeInBytes = 2; - stbtt_uint16 pairSetCount = ttUSHORT(table + 8); - stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex); - stbtt_uint8 *pairValueTable = table + pairPosOffset; - stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable); - stbtt_uint8 *pairValueArray = pairValueTable + 2; - - if (coverageIndex >= pairSetCount) return 0; - - needle=glyph2; - r=pairValueCount-1; - l=0; - - // Binary search. - while (l <= r) { - stbtt_uint16 secondGlyph; - stbtt_uint8 *pairValue; - m = (l + r) >> 1; - pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; - secondGlyph = ttUSHORT(pairValue); - straw = secondGlyph; - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else { - stbtt_int16 xAdvance = ttSHORT(pairValue + 2); - return xAdvance; - } - } - } else - return 0; - break; - } - - case 2: { - stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); - stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); - if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats? - stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); - stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); - int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); - int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); - - stbtt_uint16 class1Count = ttUSHORT(table + 12); - stbtt_uint16 class2Count = ttUSHORT(table + 14); - stbtt_uint8 *class1Records, *class2Records; - stbtt_int16 xAdvance; - - if (glyph1class < 0 || glyph1class >= class1Count) return 0; // malformed - if (glyph2class < 0 || glyph2class >= class2Count) return 0; // malformed - - class1Records = table + 16; - class2Records = class1Records + 2 * (glyph1class * class2Count); - xAdvance = ttSHORT(class2Records + 2 * glyph2class); - return xAdvance; - } else - return 0; - break; - } - - default: - return 0; // Unsupported position format - } - } + stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i); + stbtt_uint8 *lookupTable = lookupList + lookupOffset; + + stbtt_uint16 lookupType = ttUSHORT(lookupTable); + stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4); + stbtt_uint8 *subTableOffsets = lookupTable + 6; + if (lookupType != 2) // Pair Adjustment Positioning Subtable + continue; + + for (sti=0; sti<subTableCount; sti++) { + stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti); + stbtt_uint8 *table = lookupTable + subtableOffset; + stbtt_uint16 posFormat = ttUSHORT(table); + stbtt_uint16 coverageOffset = ttUSHORT(table + 2); + stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1); + if (coverageIndex == -1) continue; + + switch (posFormat) { + case 1: { + stbtt_int32 l, r, m; + int straw, needle; + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats? + stbtt_int32 valueRecordPairSizeInBytes = 2; + stbtt_uint16 pairSetCount = ttUSHORT(table + 8); + stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex); + stbtt_uint8 *pairValueTable = table + pairPosOffset; + stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable); + stbtt_uint8 *pairValueArray = pairValueTable + 2; + + if (coverageIndex >= pairSetCount) return 0; + + needle=glyph2; + r=pairValueCount-1; + l=0; + + // Binary search. + while (l <= r) { + stbtt_uint16 secondGlyph; + stbtt_uint8 *pairValue; + m = (l + r) >> 1; + pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; + secondGlyph = ttUSHORT(pairValue); + straw = secondGlyph; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + stbtt_int16 xAdvance = ttSHORT(pairValue + 2); + return xAdvance; + } + } + } else + return 0; + break; + } + + case 2: { + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + if (valueFormat1 == 4 && valueFormat2 == 0) { // Support more formats? + stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); + stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); + int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); + int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); + + stbtt_uint16 class1Count = ttUSHORT(table + 12); + stbtt_uint16 class2Count = ttUSHORT(table + 14); + stbtt_uint8 *class1Records, *class2Records; + stbtt_int16 xAdvance; + + if (glyph1class < 0 || glyph1class >= class1Count) return 0; // malformed + if (glyph2class < 0 || glyph2class >= class2Count) return 0; // malformed + + class1Records = table + 16; + class2Records = class1Records + 2 * (glyph1class * class2Count); + xAdvance = ttSHORT(class2Records + 2 * glyph2class); + return xAdvance; + } else + return 0; + break; + } + + default: + return 0; // Unsupported position format + } + } } return 0; @@ -2612,9 +2786,9 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int int xAdvance = 0; if (info->gpos) - xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); + xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); else if (info->kern) - xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); + xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); return xAdvance; } @@ -2622,7 +2796,7 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs - return 0; + return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } @@ -2642,7 +2816,7 @@ STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAsc { int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); if (!tab) - return 0; + return 0; if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); @@ -2684,9 +2858,9 @@ STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl) stbtt_uint8 *svg_docs = svg_doc_list + 2; for(i=0; i<numEntries; i++) { - stbtt_uint8 *svg_doc = svg_docs + (12 * i); - if ((gl >= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2))) - return svg_doc; + stbtt_uint8 *svg_doc = svg_docs + (12 * i); + if ((gl >= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2))) + return svg_doc; } return 0; } @@ -2697,14 +2871,14 @@ STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char * stbtt_uint8 *svg_doc; if (info->svg == 0) - return 0; + return 0; svg_doc = stbtt_FindSVGDoc(info, gl); if (svg_doc != NULL) { - *svg = (char *) data + info->svg + ttULONG(svg_doc + 4); - return ttULONG(svg_doc + 8); + *svg = (char *) data + info->svg + ttULONG(svg_doc + 4); + return ttULONG(svg_doc + 8); } else { - return 0; + return 0; } } @@ -2722,17 +2896,17 @@ STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int g { int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { - // e.g. space character - if (ix0) *ix0 = 0; - if (iy0) *iy0 = 0; - if (ix1) *ix1 = 0; - if (iy1) *iy1 = 0; + // e.g. space character + if (ix0) *ix0 = 0; + if (iy0) *iy0 = 0; + if (ix1) *ix1 = 0; + if (iy1) *iy1 = 0; } else { - // move to integral bboxes (treating pixels as little squares, what pixels get touched)? - if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); - if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); - if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); - if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); + // move to integral bboxes (treating pixels as little squares, what pixels get touched)? + if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); + if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); + if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); + if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); } } @@ -2770,21 +2944,21 @@ typedef struct stbtt__hheap static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) { if (hh->first_free) { - void *p = hh->first_free; - hh->first_free = * (void **) p; - return p; + void *p = hh->first_free; + hh->first_free = * (void **) p; + return p; } else { - if (hh->num_remaining_in_head_chunk == 0) { - int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); - stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); - if (c == NULL) - return NULL; - c->next = hh->head; - hh->head = c; - hh->num_remaining_in_head_chunk = count; - } - --hh->num_remaining_in_head_chunk; - return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; + if (hh->num_remaining_in_head_chunk == 0) { + int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); + stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); + if (c == NULL) + return NULL; + c->next = hh->head; + hh->head = c; + hh->num_remaining_in_head_chunk = count; + } + --hh->num_remaining_in_head_chunk; + return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; } } @@ -2798,9 +2972,9 @@ static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) { stbtt__hheap_chunk *c = hh->head; while (c) { - stbtt__hheap_chunk *n = c->next; - STBTT_free(c, userdata); - c = n; + stbtt__hheap_chunk *n = c->next; + STBTT_free(c, userdata); + c = n; } } @@ -2813,18 +2987,18 @@ typedef struct stbtt__edge { typedef struct stbtt__active_edge { struct stbtt__active_edge *next; - #if STBTT_RASTERIZER_VERSION==1 +#if STBTT_RASTERIZER_VERSION==1 int x,dx; float ey; int direction; - #elif STBTT_RASTERIZER_VERSION==2 +#elif STBTT_RASTERIZER_VERSION==2 float fx,fdx,fdy; float direction; float sy; float ey; - #else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" - #endif +#else + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif } stbtt__active_edge; #if STBTT_RASTERIZER_VERSION == 1 @@ -2841,9 +3015,9 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i // round dx down to avoid overshooting if (dxdy < 0) - z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); + z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); else - z->dx = STBTT_ifloor(STBTT_FIX * dxdy); + z->dx = STBTT_ifloor(STBTT_FIX * dxdy); z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount z->x -= off_x * STBTT_FIX; @@ -2885,39 +3059,39 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac int x0=0, w=0; while (e) { - if (w == 0) { - // if we're currently at zero, we need to record the edge start point - x0 = e->x; w += e->direction; - } else { - int x1 = e->x; w += e->direction; - // if we went to zero, we need to draw - if (w == 0) { - int i = x0 >> STBTT_FIXSHIFT; - int j = x1 >> STBTT_FIXSHIFT; - - if (i < len && j >= 0) { - if (i == j) { - // x0,x1 are the same pixel, so compute combined coverage - scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); - } else { - if (i >= 0) // add antialiasing for x0 - scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); - else - i = -1; // clip - - if (j < len) // add antialiasing for x1 - scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); - else - j = len; // clip - - for (++i; i < j; ++i) // fill pixels between x0 and x1 - scanline[i] = scanline[i] + (stbtt_uint8) max_weight; - } - } - } - } - - e = e->next; + if (w == 0) { + // if we're currently at zero, we need to record the edge start point + x0 = e->x; w += e->direction; + } else { + int x1 = e->x; w += e->direction; + // if we went to zero, we need to draw + if (w == 0) { + int i = x0 >> STBTT_FIXSHIFT; + int j = x1 >> STBTT_FIXSHIFT; + + if (i < len && j >= 0) { + if (i == j) { + // x0,x1 are the same pixel, so compute combined coverage + scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); + } else { + if (i >= 0) // add antialiasing for x0 + scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); + else + i = -1; // clip + + if (j < len) // add antialiasing for x1 + scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); + else + j = len; // clip + + for (++i; i < j; ++i) // fill pixels between x0 and x1 + scanline[i] = scanline[i] + (stbtt_uint8) max_weight; + } + } + } + } + + e = e->next; } } @@ -2931,94 +3105,94 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, unsigned char scanline_data[512], *scanline; if (result->w > 512) - scanline = (unsigned char *) STBTT_malloc(result->w, userdata); + scanline = (unsigned char *) STBTT_malloc(result->w, userdata); else - scanline = scanline_data; + scanline = scanline_data; y = off_y * vsubsample; e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; while (j < result->h) { - STBTT_memset(scanline, 0, result->w); - for (s=0; s < vsubsample; ++s) { - // find center of pixel for this scanline - float scan_y = y + 0.5f; - stbtt__active_edge **step = &active; - - // update all active edges; - // remove all active edges that terminate before the center of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - z->x += z->dx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - } - - // resort the list if needed - for(;;) { - int changed=0; - step = &active; - while (*step && (*step)->next) { - if ((*step)->x > (*step)->next->x) { - stbtt__active_edge *t = *step; - stbtt__active_edge *q = t->next; - - t->next = q->next; - q->next = t; - *step = q; - changed = 1; - } - step = &(*step)->next; - } - if (!changed) break; - } - - // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline - while (e->y0 <= scan_y) { - if (e->y1 > scan_y) { - stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); - if (z != NULL) { - // find insertion point - if (active == NULL) - active = z; - else if (z->x < active->x) { - // insert at front - z->next = active; - active = z; - } else { - // find thing to insert AFTER - stbtt__active_edge *p = active; - while (p->next && p->next->x < z->x) - p = p->next; - // at this point, p->next->x is NOT < z->x - z->next = p->next; - p->next = z; - } - } - } - ++e; - } - - // now process all active edges in XOR fashion - if (active) - stbtt__fill_active_edges(scanline, result->w, active, max_weight); - - ++y; - } - STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); - ++j; + STBTT_memset(scanline, 0, result->w); + for (s=0; s < vsubsample; ++s) { + // find center of pixel for this scanline + float scan_y = y + 0.5f; + stbtt__active_edge **step = &active; + + // update all active edges; + // remove all active edges that terminate before the center of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + z->x += z->dx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + } + + // resort the list if needed + for(;;) { + int changed=0; + step = &active; + while (*step && (*step)->next) { + if ((*step)->x > (*step)->next->x) { + stbtt__active_edge *t = *step; + stbtt__active_edge *q = t->next; + + t->next = q->next; + q->next = t; + *step = q; + changed = 1; + } + step = &(*step)->next; + } + if (!changed) break; + } + + // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + while (e->y0 <= scan_y) { + if (e->y1 > scan_y) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); + if (z != NULL) { + // find insertion point + if (active == NULL) + active = z; + else if (z->x < active->x) { + // insert at front + z->next = active; + active = z; + } else { + // find thing to insert AFTER + stbtt__active_edge *p = active; + while (p->next && p->next->x < z->x) + p = p->next; + // at this point, p->next->x is NOT < z->x + z->next = p->next; + p->next = z; + } + } + } + ++e; + } + + // now process all active edges in XOR fashion + if (active) + stbtt__fill_active_edges(scanline, result->w, active, max_weight); + + ++y; + } + STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); + ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) - STBTT_free(scanline, userdata); + STBTT_free(scanline, userdata); } #elif STBTT_RASTERIZER_VERSION == 2 @@ -3033,32 +3207,32 @@ static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edg if (y0 > e->ey) return; if (y1 < e->sy) return; if (y0 < e->sy) { - x0 += (x1-x0) * (e->sy - y0) / (y1-y0); - y0 = e->sy; + x0 += (x1-x0) * (e->sy - y0) / (y1-y0); + y0 = e->sy; } if (y1 > e->ey) { - x1 += (x1-x0) * (e->ey - y1) / (y1-y0); - y1 = e->ey; + x1 += (x1-x0) * (e->ey - y1) / (y1-y0); + y1 = e->ey; } if (x0 == x) - STBTT_assert(x1 <= x+1); + STBTT_assert(x1 <= x+1); else if (x0 == x+1) - STBTT_assert(x1 >= x); + STBTT_assert(x1 >= x); else if (x0 <= x) - STBTT_assert(x1 <= x); + STBTT_assert(x1 <= x); else if (x0 >= x+1) - STBTT_assert(x1 >= x+1); + STBTT_assert(x1 >= x+1); else - STBTT_assert(x1 >= x && x1 <= x+1); + STBTT_assert(x1 >= x && x1 <= x+1); if (x0 <= x && x1 <= x) - scanline[x] += e->direction * (y1-y0); + scanline[x] += e->direction * (y1-y0); else if (x0 >= x+1 && x1 >= x+1) - ; + ; else { - STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); - scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position + STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); + scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position } } @@ -3084,212 +3258,212 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, float y_bottom = y_top+1; while (e) { - // brute force every pixel - - // compute intersection points with top & bottom - STBTT_assert(e->ey >= y_top); - - if (e->fdx == 0) { - float x0 = e->fx; - if (x0 < len) { - if (x0 >= 0) { - stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); - stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); - } else { - stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); - } - } - } else { - float x0 = e->fx; - float dx = e->fdx; - float xb = x0 + dx; - float x_top, x_bottom; - float sy0,sy1; - float dy = e->fdy; - STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); - - // compute endpoints of line segment clipped to this scanline (if the - // line segment starts on this scanline. x0 is the intersection of the - // line with y_top, but that may be off the line segment. - if (e->sy > y_top) { - x_top = x0 + dx * (e->sy - y_top); - sy0 = e->sy; - } else { - x_top = x0; - sy0 = y_top; - } - if (e->ey < y_bottom) { - x_bottom = x0 + dx * (e->ey - y_top); - sy1 = e->ey; - } else { - x_bottom = xb; - sy1 = y_bottom; - } - - if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { - // from here on, we don't have to range check x values - - if ((int) x_top == (int) x_bottom) { - float height; - // simple case, only spans one pixel - int x = (int) x_top; - height = (sy1 - sy0) * e->direction; - STBTT_assert(x >= 0 && x < len); - scanline[x] += stbtt__position_trapezoid_area(height, x_top, x+1.0f, x_bottom, x+1.0f); - scanline_fill[x] += height; // everything right of this pixel is filled - } else { - int x,x1,x2; - float y_crossing, y_final, step, sign, area; - // covers 2+ pixels - if (x_top > x_bottom) { - // flip scanline vertically; signed area is the same - float t; - sy0 = y_bottom - (sy0 - y_top); - sy1 = y_bottom - (sy1 - y_top); - t = sy0, sy0 = sy1, sy1 = t; - t = x_bottom, x_bottom = x_top, x_top = t; - dx = -dx; - dy = -dy; - t = x0, x0 = xb, xb = t; - } - STBTT_assert(dy >= 0); - STBTT_assert(dx >= 0); - - x1 = (int) x_top; - x2 = (int) x_bottom; - // compute intersection with y axis at x1+1 - y_crossing = y_top + dy * (x1+1 - x0); - - // compute intersection with y axis at x2 - y_final = y_top + dy * (x2 - x0); - - // x1 x_top x2 x_bottom - // y_top +------|-----+------------+------------+--------|---+------------+ - // | | | | | | - // | | | | | | - // sy0 | Txxxxx|............|............|............|............| - // y_crossing | *xxxxx.......|............|............|............| - // | | xxxxx..|............|............|............| - // | | /- xx*xxxx........|............|............| - // | | dy < | xxxxxx..|............|............| - // y_final | | \- | xx*xxx.........|............| - // sy1 | | | | xxxxxB...|............| - // | | | | | | - // | | | | | | - // y_bottom +------------+------------+------------+------------+------------+ - // - // goal is to measure the area covered by '.' in each pixel - - // if x2 is right at the right edge of x1, y_crossing can blow up, github #1057 - // @TODO: maybe test against sy1 rather than y_bottom? - if (y_crossing > y_bottom) - y_crossing = y_bottom; - - sign = e->direction; - - // area of the rectangle covered from sy0..y_crossing - area = sign * (y_crossing-sy0); - - // area of the triangle (x_top,sy0), (x1+1,sy0), (x1+1,y_crossing) - scanline[x1] += stbtt__sized_triangle_area(area, x1+1 - x_top); - - // check if final y_crossing is blown up; no test case for this - if (y_final > y_bottom) { - y_final = y_bottom; - dy = (y_final - y_crossing ) / (x2 - (x1+1)); // if denom=0, y_final = y_crossing, so y_final <= y_bottom - } - - // in second pixel, area covered by line segment found in first pixel - // is always a rectangle 1 wide * the height of that line segment; this - // is exactly what the variable 'area' stores. it also gets a contribution - // from the line segment within it. the THIRD pixel will get the first - // pixel's rectangle contribution, the second pixel's rectangle contribution, - // and its own contribution. the 'own contribution' is the same in every pixel except - // the leftmost and rightmost, a trapezoid that slides down in each pixel. - // the second pixel's contribution to the third pixel will be the - // rectangle 1 wide times the height change in the second pixel, which is dy. - - step = sign * dy * 1; // dy is dy/dx, change in y for every 1 change in x, - // which multiplied by 1-pixel-width is how much pixel area changes for each step in x - // so the area advances by 'step' every time - - for (x = x1+1; x < x2; ++x) { - scanline[x] += area + step/2; // area of trapezoid is 1*step/2 - area += step; - } - STBTT_assert(STBTT_fabs(area) <= 1.01f); // accumulated error from area += step unless we round step down - STBTT_assert(sy1 > y_final-0.01f); - - // area covered in the last pixel is the rectangle from all the pixels to the left, - // plus the trapezoid filled by the line segment in this pixel all the way to the right edge - scanline[x2] += area + sign * stbtt__position_trapezoid_area(sy1-y_final, (float) x2, x2+1.0f, x_bottom, x2+1.0f); - - // the rest of the line is filled based on the total height of the line segment in this pixel - scanline_fill[x2] += sign * (sy1-sy0); - } - } else { - // if edge goes outside of box we're drawing, we require - // clipping logic. since this does not match the intended use - // of this library, we use a different, very slow brute - // force implementation - // note though that this does happen some of the time because - // x_top and x_bottom can be extrapolated at the top & bottom of - // the shape and actually lie outside the bounding box - int x; - for (x=0; x < len; ++x) { - // cases: - // - // there can be up to two intersections with the pixel. any intersection - // with left or right edges can be handled by splitting into two (or three) - // regions. intersections with top & bottom do not necessitate case-wise logic. - // - // the old way of doing this found the intersections with the left & right edges, - // then used some simple logic to produce up to three segments in sorted order - // from top-to-bottom. however, this had a problem: if an x edge was epsilon - // across the x border, then the corresponding y position might not be distinct - // from the other y segment, and it might ignored as an empty segment. to avoid - // that, we need to explicitly produce segments based on x positions. - - // rename variables to clearly-defined pairs - float y0 = y_top; - float x1 = (float) (x); - float x2 = (float) (x+1); - float x3 = xb; - float y3 = y_bottom; - - // x = e->x + e->dx * (y-y_top) - // (y-y_top) = (x - e->x) / e->dx - // y = (x - e->x) / e->dx + y_top - float y1 = (x - x0) / dx + y_top; - float y2 = (x+1 - x0) / dx + y_top; - - if (x0 < x1 && x3 > x2) { // three segments descending down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x1 && x0 > x2) { // three segments descending down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else { // one segment - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); - } - } - } - } - e = e->next; + // brute force every pixel + + // compute intersection points with top & bottom + STBTT_assert(e->ey >= y_top); + + if (e->fdx == 0) { + float x0 = e->fx; + if (x0 < len) { + if (x0 >= 0) { + stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); + stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); + } else { + stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); + } + } + } else { + float x0 = e->fx; + float dx = e->fdx; + float xb = x0 + dx; + float x_top, x_bottom; + float sy0,sy1; + float dy = e->fdy; + STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); + + // compute endpoints of line segment clipped to this scanline (if the + // line segment starts on this scanline. x0 is the intersection of the + // line with y_top, but that may be off the line segment. + if (e->sy > y_top) { + x_top = x0 + dx * (e->sy - y_top); + sy0 = e->sy; + } else { + x_top = x0; + sy0 = y_top; + } + if (e->ey < y_bottom) { + x_bottom = x0 + dx * (e->ey - y_top); + sy1 = e->ey; + } else { + x_bottom = xb; + sy1 = y_bottom; + } + + if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { + // from here on, we don't have to range check x values + + if ((int) x_top == (int) x_bottom) { + float height; + // simple case, only spans one pixel + int x = (int) x_top; + height = (sy1 - sy0) * e->direction; + STBTT_assert(x >= 0 && x < len); + scanline[x] += stbtt__position_trapezoid_area(height, x_top, x+1.0f, x_bottom, x+1.0f); + scanline_fill[x] += height; // everything right of this pixel is filled + } else { + int x,x1,x2; + float y_crossing, y_final, step, sign, area; + // covers 2+ pixels + if (x_top > x_bottom) { + // flip scanline vertically; signed area is the same + float t; + sy0 = y_bottom - (sy0 - y_top); + sy1 = y_bottom - (sy1 - y_top); + t = sy0, sy0 = sy1, sy1 = t; + t = x_bottom, x_bottom = x_top, x_top = t; + dx = -dx; + dy = -dy; + t = x0, x0 = xb, xb = t; + } + STBTT_assert(dy >= 0); + STBTT_assert(dx >= 0); + + x1 = (int) x_top; + x2 = (int) x_bottom; + // compute intersection with y axis at x1+1 + y_crossing = y_top + dy * (x1+1 - x0); + + // compute intersection with y axis at x2 + y_final = y_top + dy * (x2 - x0); + + // x1 x_top x2 x_bottom + // y_top +------|-----+------------+------------+--------|---+------------+ + // | | | | | | + // | | | | | | + // sy0 | Txxxxx|............|............|............|............| + // y_crossing | *xxxxx.......|............|............|............| + // | | xxxxx..|............|............|............| + // | | /- xx*xxxx........|............|............| + // | | dy < | xxxxxx..|............|............| + // y_final | | \- | xx*xxx.........|............| + // sy1 | | | | xxxxxB...|............| + // | | | | | | + // | | | | | | + // y_bottom +------------+------------+------------+------------+------------+ + // + // goal is to measure the area covered by '.' in each pixel + + // if x2 is right at the right edge of x1, y_crossing can blow up, github #1057 + // @TODO: maybe test against sy1 rather than y_bottom? + if (y_crossing > y_bottom) + y_crossing = y_bottom; + + sign = e->direction; + + // area of the rectangle covered from sy0..y_crossing + area = sign * (y_crossing-sy0); + + // area of the triangle (x_top,sy0), (x1+1,sy0), (x1+1,y_crossing) + scanline[x1] += stbtt__sized_triangle_area(area, x1+1 - x_top); + + // check if final y_crossing is blown up; no test case for this + if (y_final > y_bottom) { + y_final = y_bottom; + dy = (y_final - y_crossing ) / (x2 - (x1+1)); // if denom=0, y_final = y_crossing, so y_final <= y_bottom + } + + // in second pixel, area covered by line segment found in first pixel + // is always a rectangle 1 wide * the height of that line segment; this + // is exactly what the variable 'area' stores. it also gets a contribution + // from the line segment within it. the THIRD pixel will get the first + // pixel's rectangle contribution, the second pixel's rectangle contribution, + // and its own contribution. the 'own contribution' is the same in every pixel except + // the leftmost and rightmost, a trapezoid that slides down in each pixel. + // the second pixel's contribution to the third pixel will be the + // rectangle 1 wide times the height change in the second pixel, which is dy. + + step = sign * dy * 1; // dy is dy/dx, change in y for every 1 change in x, + // which multiplied by 1-pixel-width is how much pixel area changes for each step in x + // so the area advances by 'step' every time + + for (x = x1+1; x < x2; ++x) { + scanline[x] += area + step/2; // area of trapezoid is 1*step/2 + area += step; + } + STBTT_assert(STBTT_fabs(area) <= 1.01f); // accumulated error from area += step unless we round step down + STBTT_assert(sy1 > y_final-0.01f); + + // area covered in the last pixel is the rectangle from all the pixels to the left, + // plus the trapezoid filled by the line segment in this pixel all the way to the right edge + scanline[x2] += area + sign * stbtt__position_trapezoid_area(sy1-y_final, (float) x2, x2+1.0f, x_bottom, x2+1.0f); + + // the rest of the line is filled based on the total height of the line segment in this pixel + scanline_fill[x2] += sign * (sy1-sy0); + } + } else { + // if edge goes outside of box we're drawing, we require + // clipping logic. since this does not match the intended use + // of this library, we use a different, very slow brute + // force implementation + // note though that this does happen some of the time because + // x_top and x_bottom can be extrapolated at the top & bottom of + // the shape and actually lie outside the bounding box + int x; + for (x=0; x < len; ++x) { + // cases: + // + // there can be up to two intersections with the pixel. any intersection + // with left or right edges can be handled by splitting into two (or three) + // regions. intersections with top & bottom do not necessitate case-wise logic. + // + // the old way of doing this found the intersections with the left & right edges, + // then used some simple logic to produce up to three segments in sorted order + // from top-to-bottom. however, this had a problem: if an x edge was epsilon + // across the x border, then the corresponding y position might not be distinct + // from the other y segment, and it might ignored as an empty segment. to avoid + // that, we need to explicitly produce segments based on x positions. + + // rename variables to clearly-defined pairs + float y0 = y_top; + float x1 = (float) (x); + float x2 = (float) (x+1); + float x3 = xb; + float y3 = y_bottom; + + // x = e->x + e->dx * (y-y_top) + // (y-y_top) = (x - e->x) / e->dx + // y = (x - e->x) / e->dx + y_top + float y1 = (x - x0) / dx + y_top; + float y2 = (x+1 - x0) / dx + y_top; + + if (x0 < x1 && x3 > x2) { // three segments descending down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x1 && x0 > x2) { // three segments descending down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else { // one segment + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); + } + } + } + } + e = e->next; } } @@ -3304,9 +3478,9 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, STBTT__NOTUSED(vsubsample); if (result->w > 64) - scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); + scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); else - scanline = scanline_data; + scanline = scanline_data; scanline2 = scanline + result->w; @@ -3314,81 +3488,81 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, e[n].y0 = (float) (off_y + result->h) + 1; while (j < result->h) { - // find center of pixel for this scanline - float scan_y_top = y + 0.0f; - float scan_y_bottom = y + 1.0f; - stbtt__active_edge **step = &active; - - STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); - STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); - - // update all active edges; - // remove all active edges that terminate before the top of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y_top) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - step = &((*step)->next); // advance through list - } - } - - // insert all edges that start before the bottom of this scanline - while (e->y0 <= scan_y_bottom) { - if (e->y0 != e->y1) { - stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); - if (z != NULL) { - if (j == 0 && off_y != 0) { - if (z->ey < scan_y_top) { - // this can happen due to subpixel positioning and some kind of fp rounding error i think - z->ey = scan_y_top; - } - } - STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds - // insert at front - z->next = active; - active = z; - } - } - ++e; - } - - // now process all active edges - if (active) - stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); - - { - float sum = 0; - for (i=0; i < result->w; ++i) { - float k; - int m; - sum += scanline2[i]; - k = scanline[i] + sum; - k = (float) STBTT_fabs(k)*255 + 0.5f; - m = (int) k; - if (m > 255) m = 255; - result->pixels[j*result->stride + i] = (unsigned char) m; - } - } - // advance all the edges - step = &active; - while (*step) { - stbtt__active_edge *z = *step; - z->fx += z->fdx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - - ++y; - ++j; + // find center of pixel for this scanline + float scan_y_top = y + 0.0f; + float scan_y_bottom = y + 1.0f; + stbtt__active_edge **step = &active; + + STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); + STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); + + // update all active edges; + // remove all active edges that terminate before the top of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y_top) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + step = &((*step)->next); // advance through list + } + } + + // insert all edges that start before the bottom of this scanline + while (e->y0 <= scan_y_bottom) { + if (e->y0 != e->y1) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); + if (z != NULL) { + if (j == 0 && off_y != 0) { + if (z->ey < scan_y_top) { + // this can happen due to subpixel positioning and some kind of fp rounding error i think + z->ey = scan_y_top; + } + } + STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds + // insert at front + z->next = active; + active = z; + } + } + ++e; + } + + // now process all active edges + if (active) + stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); + + { + float sum = 0; + for (i=0; i < result->w; ++i) { + float k; + int m; + sum += scanline2[i]; + k = scanline[i] + sum; + k = (float) STBTT_fabs(k)*255 + 0.5f; + m = (int) k; + if (m > 255) m = 255; + result->pixels[j*result->stride + i] = (unsigned char) m; + } + } + // advance all the edges + step = &active; + while (*step) { + stbtt__active_edge *z = *step; + z->fx += z->fdx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + + ++y; + ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) - STBTT_free(scanline, userdata); + STBTT_free(scanline, userdata); } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" @@ -3400,17 +3574,17 @@ static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) { int i,j; for (i=1; i < n; ++i) { - stbtt__edge t = p[i], *a = &t; - j = i; - while (j > 0) { - stbtt__edge *b = &p[j-1]; - int c = STBTT__COMPARE(a,b); - if (!c) break; - p[j] = p[j-1]; - --j; - } - if (i != j) - p[j] = t; + stbtt__edge t = p[i], *a = &t; + j = i; + while (j > 0) { + stbtt__edge *b = &p[j-1]; + int c = STBTT__COMPARE(a,b); + if (!c) break; + p[j] = p[j-1]; + --j; + } + if (i != j) + p[j] = t; } } @@ -3418,61 +3592,61 @@ static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { /* threshold for transitioning to insertion sort */ while (n > 12) { - stbtt__edge t; - int c01,c12,c,m,i,j; - - /* compute median of three */ - m = n >> 1; - c01 = STBTT__COMPARE(&p[0],&p[m]); - c12 = STBTT__COMPARE(&p[m],&p[n-1]); - /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ - if (c01 != c12) { - /* otherwise, we'll need to swap something else to middle */ - int z; - c = STBTT__COMPARE(&p[0],&p[n-1]); - /* 0>mid && mid<n: 0>n => n; 0<n => 0 */ - /* 0<mid && mid>n: 0>n => 0; 0<n => n */ - z = (c == c12) ? 0 : n-1; - t = p[z]; - p[z] = p[m]; - p[m] = t; - } - /* now p[m] is the median-of-three */ - /* swap it to the beginning so it won't move around */ - t = p[0]; - p[0] = p[m]; - p[m] = t; - - /* partition loop */ - i=1; - j=n-1; - for(;;) { - /* handling of equality is crucial here */ - /* for sentinels & efficiency with duplicates */ - for (;;++i) { - if (!STBTT__COMPARE(&p[i], &p[0])) break; - } - for (;;--j) { - if (!STBTT__COMPARE(&p[0], &p[j])) break; - } - /* make sure we haven't crossed */ - if (i >= j) break; - t = p[i]; - p[i] = p[j]; - p[j] = t; - - ++i; - --j; - } - /* recurse on smaller side, iterate on larger */ - if (j < (n-i)) { - stbtt__sort_edges_quicksort(p,j); - p = p+i; - n = n-i; - } else { - stbtt__sort_edges_quicksort(p+i, n-i); - n = j; - } + stbtt__edge t; + int c01,c12,c,m,i,j; + + /* compute median of three */ + m = n >> 1; + c01 = STBTT__COMPARE(&p[0],&p[m]); + c12 = STBTT__COMPARE(&p[m],&p[n-1]); + /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ + if (c01 != c12) { + /* otherwise, we'll need to swap something else to middle */ + int z; + c = STBTT__COMPARE(&p[0],&p[n-1]); + /* 0>mid && mid<n: 0>n => n; 0<n => 0 */ + /* 0<mid && mid>n: 0>n => 0; 0<n => n */ + z = (c == c12) ? 0 : n-1; + t = p[z]; + p[z] = p[m]; + p[m] = t; + } + /* now p[m] is the median-of-three */ + /* swap it to the beginning so it won't move around */ + t = p[0]; + p[0] = p[m]; + p[m] = t; + + /* partition loop */ + i=1; + j=n-1; + for(;;) { + /* handling of equality is crucial here */ + /* for sentinels & efficiency with duplicates */ + for (;;++i) { + if (!STBTT__COMPARE(&p[i], &p[0])) break; + } + for (;;--j) { + if (!STBTT__COMPARE(&p[0], &p[j])) break; + } + /* make sure we haven't crossed */ + if (i >= j) break; + t = p[i]; + p[i] = p[j]; + p[j] = t; + + ++i; + --j; + } + /* recurse on smaller side, iterate on larger */ + if (j < (n-i)) { + stbtt__sort_edges_quicksort(p,j); + p = p+i; + n = n-i; + } else { + stbtt__sort_edges_quicksort(p+i, n-i); + n = j; + } } } @@ -3497,14 +3671,14 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou #elif STBTT_RASTERIZER_VERSION == 2 int vsubsample = 1; #else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" + #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif // vsubsample should divide 255 evenly; otherwise we won't reach full opacity // now we have to blow out the windings into explicit edge lists n = 0; for (i=0; i < windings; ++i) - n += wcount[i]; + n += wcount[i]; e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel if (e == 0) return; @@ -3512,26 +3686,26 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou m=0; for (i=0; i < windings; ++i) { - stbtt__point *p = pts + m; - m += wcount[i]; - j = wcount[i]-1; - for (k=0; k < wcount[i]; j=k++) { - int a=k,b=j; - // skip the edge if horizontal - if (p[j].y == p[k].y) - continue; - // add edge from j to k to the list - e[n].invert = 0; - if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { - e[n].invert = 1; - a=j,b=k; - } - e[n].x0 = p[a].x * scale_x + shift_x; - e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; - e[n].x1 = p[b].x * scale_x + shift_x; - e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; - ++n; - } + stbtt__point *p = pts + m; + m += wcount[i]; + j = wcount[i]-1; + for (k=0; k < wcount[i]; j=k++) { + int a=k,b=j; + // skip the edge if horizontal + if (p[j].y == p[k].y) + continue; + // add edge from j to k to the list + e[n].invert = 0; + if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { + e[n].invert = 1; + a=j,b=k; + } + e[n].x0 = p[a].x * scale_x + shift_x; + e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; + e[n].x1 = p[b].x * scale_x + shift_x; + e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; + ++n; + } } // now sort the edges by their highest point (should snap to integer, and then by x) @@ -3561,13 +3735,13 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x float dx = (x0+x2)/2 - mx; float dy = (y0+y2)/2 - my; if (n > 16) // 65536 segments on one curve better be enough! - return 1; + return 1; if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA - stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); - stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); } else { - stbtt__add_point(points, *num_points,x2,y2); - *num_points = *num_points+1; + stbtt__add_point(points, *num_points,x2,y2); + *num_points = *num_points+1; } return 1; } @@ -3588,29 +3762,29 @@ static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float float flatness_squared = longlen*longlen-shortlen*shortlen; if (n > 16) // 65536 segments on one curve better be enough! - return; + return; if (flatness_squared > objspace_flatness_squared) { - float x01 = (x0+x1)/2; - float y01 = (y0+y1)/2; - float x12 = (x1+x2)/2; - float y12 = (y1+y2)/2; - float x23 = (x2+x3)/2; - float y23 = (y2+y3)/2; - - float xa = (x01+x12)/2; - float ya = (y01+y12)/2; - float xb = (x12+x23)/2; - float yb = (y12+y23)/2; - - float mx = (xa+xb)/2; - float my = (ya+yb)/2; - - stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); - stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); } else { - stbtt__add_point(points, *num_points,x3,y3); - *num_points = *num_points+1; + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; } } @@ -3625,8 +3799,8 @@ static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, // count how many "moves" there are to get the contour count for (i=0; i < num_verts; ++i) - if (vertices[i].type == STBTT_vmove) - ++n; + if (vertices[i].type == STBTT_vmove) + ++n; *num_contours = n; if (n == 0) return 0; @@ -3634,53 +3808,53 @@ static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); if (*contour_lengths == 0) { - *num_contours = 0; - return 0; + *num_contours = 0; + return 0; } // make two passes through the points so we don't need to realloc for (pass=0; pass < 2; ++pass) { - float x=0,y=0; - if (pass == 1) { - points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); - if (points == NULL) goto error; - } - num_points = 0; - n= -1; - for (i=0; i < num_verts; ++i) { - switch (vertices[i].type) { - case STBTT_vmove: - // start the next contour - if (n >= 0) - (*contour_lengths)[n] = num_points - start; - ++n; - start = num_points; - - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x,y); - break; - case STBTT_vline: - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x, y); - break; - case STBTT_vcurve: - stbtt__tesselate_curve(points, &num_points, x,y, - vertices[i].cx, vertices[i].cy, - vertices[i].x, vertices[i].y, - objspace_flatness_squared, 0); - x = vertices[i].x, y = vertices[i].y; - break; - case STBTT_vcubic: - stbtt__tesselate_cubic(points, &num_points, x,y, - vertices[i].cx, vertices[i].cy, - vertices[i].cx1, vertices[i].cy1, - vertices[i].x, vertices[i].y, - objspace_flatness_squared, 0); - x = vertices[i].x, y = vertices[i].y; - break; - } - } - (*contour_lengths)[n] = num_points - start; + float x=0,y=0; + if (pass == 1) { + points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); + if (points == NULL) goto error; + } + num_points = 0; + n= -1; + for (i=0; i < num_verts; ++i) { + switch (vertices[i].type) { + case STBTT_vmove: + // start the next contour + if (n >= 0) + (*contour_lengths)[n] = num_points - start; + ++n; + start = num_points; + + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x,y); + break; + case STBTT_vline: + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x, y); + break; + case STBTT_vcurve: + stbtt__tesselate_curve(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + } + } + (*contour_lengths)[n] = num_points - start; } return points; @@ -3699,9 +3873,9 @@ STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, int *winding_lengths = NULL; stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); if (windings) { - stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); - STBTT_free(winding_lengths, userdata); - STBTT_free(windings, userdata); + stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); + STBTT_free(winding_lengths, userdata); + STBTT_free(windings, userdata); } } @@ -3719,11 +3893,11 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { - if (scale_x == 0) { - STBTT_free(vertices, info->userdata); - return NULL; - } - scale_y = scale_x; + if (scale_x == 0) { + STBTT_free(vertices, info->userdata); + return NULL; + } + scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); @@ -3739,12 +3913,12 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (yoff ) *yoff = iy0; if (gbm.w && gbm.h) { - gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); - if (gbm.pixels) { - gbm.stride = gbm.w; + gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); + if (gbm.pixels) { + gbm.stride = gbm.w; - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); - } + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); + } } STBTT_free(vertices, info->userdata); return gbm.pixels; @@ -3769,7 +3943,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne gbm.stride = out_stride; if (gbm.w && gbm.h) - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); STBTT_free(vertices, info->userdata); } @@ -3811,17 +3985,17 @@ STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned ch // This is SUPER-CRAPPY packing to keep source code small static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) - float pixel_height, // height of font in pixels - unsigned char *pixels, int pw, int ph, // bitmap to be filled in - int first_char, int num_chars, // characters to bake - stbtt_bakedchar *chardata) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata) { float scale; int x,y,bottom_y, i; stbtt_fontinfo f; f.userdata = NULL; if (!stbtt_InitFont(&f, data, offset)) - return -1; + return -1; STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels x=y=1; bottom_y = 1; @@ -3829,29 +4003,29 @@ static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // fo scale = stbtt_ScaleForPixelHeight(&f, pixel_height); for (i=0; i < num_chars; ++i) { - int advance, lsb, x0,y0,x1,y1,gw,gh; - int g = stbtt_FindGlyphIndex(&f, first_char + i); - stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); - stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); - gw = x1-x0; - gh = y1-y0; - if (x + gw + 1 >= pw) - y = bottom_y, x = 1; // advance to next row - if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row - return -i; - STBTT_assert(x+gw < pw); - STBTT_assert(y+gh < ph); - stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); - chardata[i].x0 = (stbtt_int16) x; - chardata[i].y0 = (stbtt_int16) y; - chardata[i].x1 = (stbtt_int16) (x + gw); - chardata[i].y1 = (stbtt_int16) (y + gh); - chardata[i].xadvance = scale * advance; - chardata[i].xoff = (float) x0; - chardata[i].yoff = (float) y0; - x = x + gw + 1; - if (y+gh+1 > bottom_y) - bottom_y = y+gh+1; + int advance, lsb, x0,y0,x1,y1,gw,gh; + int g = stbtt_FindGlyphIndex(&f, first_char + i); + stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); + gw = x1-x0; + gh = y1-y0; + if (x + gw + 1 >= pw) + y = bottom_y, x = 1; // advance to next row + if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row + return -i; + STBTT_assert(x+gw < pw); + STBTT_assert(y+gh < ph); + stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); + chardata[i].x0 = (stbtt_int16) x; + chardata[i].y0 = (stbtt_int16) y; + chardata[i].x1 = (stbtt_int16) (x + gw); + chardata[i].y1 = (stbtt_int16) (y + gh); + chardata[i].xadvance = scale * advance; + chardata[i].xoff = (float) x0; + chardata[i].yoff = (float) y0; + x = x + gw + 1; + if (y+gh+1 > bottom_y) + bottom_y = y+gh+1; } return bottom_y; } @@ -3929,21 +4103,21 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect { int i; for (i=0; i < num_rects; ++i) { - if (con->x + rects[i].w > con->width) { - con->x = 0; - con->y = con->bottom_y; - } - if (con->y + rects[i].h > con->height) - break; - rects[i].x = con->x; - rects[i].y = con->y; - rects[i].was_packed = 1; - con->x += rects[i].w; - if (con->y + rects[i].h > con->bottom_y) - con->bottom_y = con->y + rects[i].h; + if (con->x + rects[i].w > con->width) { + con->x = 0; + con->y = con->bottom_y; + } + if (con->y + rects[i].h > con->height) + break; + rects[i].x = con->x; + rects[i].y = con->y; + rects[i].was_packed = 1; + con->x += rects[i].w; + if (con->y + rects[i].h > con->bottom_y) + con->bottom_y = con->y + rects[i].h; } for ( ; i < num_rects; ++i) - rects[i].was_packed = 0; + rects[i].was_packed = 0; } #endif @@ -3961,9 +4135,9 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); if (context == NULL || nodes == NULL) { - if (context != NULL) STBTT_free(context, alloc_context); - if (nodes != NULL) STBTT_free(nodes , alloc_context); - return 0; + if (context != NULL) STBTT_free(context, alloc_context); + if (nodes != NULL) STBTT_free(nodes , alloc_context); + return 0; } spc->user_allocator_context = alloc_context; @@ -3981,7 +4155,7 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); if (pixels) - STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels return 1; } @@ -3997,9 +4171,9 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); if (h_oversample <= STBTT_MAX_OVERSAMPLE) - spc->h_oversample = h_oversample; + spc->h_oversample = h_oversample; if (v_oversample <= STBTT_MAX_OVERSAMPLE) - spc->v_oversample = v_oversample; + spc->v_oversample = v_oversample; } STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) @@ -4016,58 +4190,58 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < h; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < w; ++i) { - STBTT_assert(pixels[i] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i] = (unsigned char) (total / kernel_width); - } - - pixels += stride_in_bytes; + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < w; ++i) { + STBTT_assert(pixels[i] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i] = (unsigned char) (total / kernel_width); + } + + pixels += stride_in_bytes; } } @@ -4078,65 +4252,65 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < w; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < h; ++i) { - STBTT_assert(pixels[i*stride_in_bytes] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - - pixels += 1; + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < h; ++i) { + STBTT_assert(pixels[i*stride_in_bytes] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + + pixels += 1; } } static float stbtt__oversample_shift(int oversample) { if (!oversample) - return 0.0f; + return 0.0f; // The prefilter is a box filter of width "oversample", // which shifts phase by (oversample - 1)/2 pixels in @@ -4153,29 +4327,29 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb k=0; for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - ranges[i].h_oversample = (unsigned char) spc->h_oversample; - ranges[i].v_oversample = (unsigned char) spc->v_oversample; - for (j=0; j < ranges[i].num_chars; ++j) { - int x0,y0,x1,y1; - int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; - int glyph = stbtt_FindGlyphIndex(info, codepoint); - if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) { - rects[k].w = rects[k].h = 0; - } else { - stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - &x0,&y0,&x1,&y1); - rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); - rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); - if (glyph == 0) - missing_glyph_added = 1; - } - ++k; - } + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + ranges[i].h_oversample = (unsigned char) spc->h_oversample; + ranges[i].v_oversample = (unsigned char) spc->v_oversample; + for (j=0; j < ranges[i].num_chars; ++j) { + int x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) { + rects[k].w = rects[k].h = 0; + } else { + stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + if (glyph == 0) + missing_glyph_added = 1; + } + ++k; + } } return k; @@ -4184,21 +4358,21 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, - output, - out_w - (prefilter_x - 1), - out_h - (prefilter_y - 1), - out_stride, - scale_x, - scale_y, - shift_x, - shift_y, - glyph); + output, + out_w - (prefilter_x - 1), + out_h - (prefilter_y - 1), + out_stride, + scale_x, + scale_y, + shift_x, + shift_y, + glyph); if (prefilter_x > 1) - stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); + stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); if (prefilter_y > 1) - stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); + stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); *sub_x = stbtt__oversample_shift(prefilter_x); *sub_y = stbtt__oversample_shift(prefilter_y); @@ -4215,76 +4389,76 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const k = 0; for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - float recip_h,recip_v,sub_x,sub_y; - spc->h_oversample = ranges[i].h_oversample; - spc->v_oversample = ranges[i].v_oversample; - recip_h = 1.0f / spc->h_oversample; - recip_v = 1.0f / spc->v_oversample; - sub_x = stbtt__oversample_shift(spc->h_oversample); - sub_y = stbtt__oversample_shift(spc->v_oversample); - for (j=0; j < ranges[i].num_chars; ++j) { - stbrp_rect *r = &rects[k]; - if (r->was_packed && r->w != 0 && r->h != 0) { - stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; - int advance, lsb, x0,y0,x1,y1; - int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; - int glyph = stbtt_FindGlyphIndex(info, codepoint); - stbrp_coord pad = (stbrp_coord) spc->padding; - - // pad on left and top - r->x += pad; - r->y += pad; - r->w -= pad; - r->h -= pad; - stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); - stbtt_GetGlyphBitmapBox(info, glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - &x0,&y0,&x1,&y1); - stbtt_MakeGlyphBitmapSubpixel(info, - spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w - spc->h_oversample+1, - r->h - spc->v_oversample+1, - spc->stride_in_bytes, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - glyph); - - if (spc->h_oversample > 1) - stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->h_oversample); - - if (spc->v_oversample > 1) - stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->v_oversample); - - bc->x0 = (stbtt_int16) r->x; - bc->y0 = (stbtt_int16) r->y; - bc->x1 = (stbtt_int16) (r->x + r->w); - bc->y1 = (stbtt_int16) (r->y + r->h); - bc->xadvance = scale * advance; - bc->xoff = (float) x0 * recip_h + sub_x; - bc->yoff = (float) y0 * recip_v + sub_y; - bc->xoff2 = (x0 + r->w) * recip_h + sub_x; - bc->yoff2 = (y0 + r->h) * recip_v + sub_y; - - if (glyph == 0) - missing_glyph = j; - } else if (spc->skip_missing) { - return_value = 0; - } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) { - ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph]; - } else { - return_value = 0; // if any fail, report failure - } - - ++k; - } + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + float recip_h,recip_v,sub_x,sub_y; + spc->h_oversample = ranges[i].h_oversample; + spc->v_oversample = ranges[i].v_oversample; + recip_h = 1.0f / spc->h_oversample; + recip_v = 1.0f / spc->v_oversample; + sub_x = stbtt__oversample_shift(spc->h_oversample); + sub_y = stbtt__oversample_shift(spc->v_oversample); + for (j=0; j < ranges[i].num_chars; ++j) { + stbrp_rect *r = &rects[k]; + if (r->was_packed && r->w != 0 && r->h != 0) { + stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; + int advance, lsb, x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbrp_coord pad = (stbrp_coord) spc->padding; + + // pad on left and top + r->x += pad; + r->y += pad; + r->w -= pad; + r->h -= pad; + stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); + stbtt_GetGlyphBitmapBox(info, glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + &x0,&y0,&x1,&y1); + stbtt_MakeGlyphBitmapSubpixel(info, + spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w - spc->h_oversample+1, + r->h - spc->v_oversample+1, + spc->stride_in_bytes, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + glyph); + + if (spc->h_oversample > 1) + stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->h_oversample); + + if (spc->v_oversample > 1) + stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->v_oversample); + + bc->x0 = (stbtt_int16) r->x; + bc->y0 = (stbtt_int16) r->y; + bc->x1 = (stbtt_int16) (r->x + r->w); + bc->y1 = (stbtt_int16) (r->y + r->h); + bc->xadvance = scale * advance; + bc->xoff = (float) x0 * recip_h + sub_x; + bc->yoff = (float) y0 * recip_v + sub_y; + bc->xoff2 = (x0 + r->w) * recip_h + sub_x; + bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + + if (glyph == 0) + missing_glyph = j; + } else if (spc->skip_missing) { + return_value = 0; + } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) { + ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph]; + } else { + return_value = 0; // if any fail, report failure + } + + ++k; + } } // restore original values @@ -4308,19 +4482,19 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char // flag all characters as NOT packed for (i=0; i < num_ranges; ++i) - for (j=0; j < ranges[i].num_chars; ++j) - ranges[i].chardata_for_range[j].x0 = - ranges[i].chardata_for_range[j].y0 = - ranges[i].chardata_for_range[j].x1 = - ranges[i].chardata_for_range[j].y1 = 0; + for (j=0; j < ranges[i].num_chars; ++j) + ranges[i].chardata_for_range[j].x0 = + ranges[i].chardata_for_range[j].y0 = + ranges[i].chardata_for_range[j].x1 = + ranges[i].chardata_for_range[j].y1 = 0; n = 0; for (i=0; i < num_ranges; ++i) - n += ranges[i].num_chars; + n += ranges[i].num_chars; rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) - return 0; + return 0; info.userdata = spc->user_allocator_context; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); @@ -4336,7 +4510,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char } STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, - int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) + int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; @@ -4366,17 +4540,17 @@ STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { - float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); - float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); - q->x0 = x; - q->y0 = y; - q->x1 = x + b->xoff2 - b->xoff; - q->y1 = y + b->yoff2 - b->yoff; + float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); + float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); + q->x0 = x; + q->y0 = y; + q->x1 = x + b->xoff2 - b->xoff; + q->y1 = y + b->yoff2 - b->yoff; } else { - q->x0 = *xpos + b->xoff; - q->y0 = *ypos + b->yoff; - q->x1 = *xpos + b->xoff2; - q->y1 = *ypos + b->yoff2; + q->x0 = *xpos + b->xoff; + q->y0 = *ypos + b->yoff; + q->x1 = *xpos + b->xoff2; + q->y1 = *ypos + b->yoff2; } q->s0 = b->x0 * ipw; @@ -4410,52 +4584,52 @@ static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], int num_s = 0; if (a != 0.0) { - float discr = b*b - a*c; - if (discr > 0.0) { - float rcpna = -1 / a; - float d = (float) STBTT_sqrt(discr); - s0 = (b+d) * rcpna; - s1 = (b-d) * rcpna; - if (s0 >= 0.0 && s0 <= 1.0) - num_s = 1; - if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { - if (num_s == 0) s0 = s1; - ++num_s; - } - } + float discr = b*b - a*c; + if (discr > 0.0) { + float rcpna = -1 / a; + float d = (float) STBTT_sqrt(discr); + s0 = (b+d) * rcpna; + s1 = (b-d) * rcpna; + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { + if (num_s == 0) s0 = s1; + ++num_s; + } + } } else { - // 2*b*s + c = 0 - // s = -c / (2*b) - s0 = c / (-2 * b); - if (s0 >= 0.0 && s0 <= 1.0) - num_s = 1; + // 2*b*s + c = 0 + // s = -c / (2*b) + s0 = c / (-2 * b); + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; } if (num_s == 0) - return 0; + return 0; else { - float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); - float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; - - float q0d = q0[0]*rayn_x + q0[1]*rayn_y; - float q1d = q1[0]*rayn_x + q1[1]*rayn_y; - float q2d = q2[0]*rayn_x + q2[1]*rayn_y; - float rod = orig[0]*rayn_x + orig[1]*rayn_y; - - float q10d = q1d - q0d; - float q20d = q2d - q0d; - float q0rd = q0d - rod; - - hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; - hits[0][1] = a*s0+b; - - if (num_s > 1) { - hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; - hits[1][1] = a*s1+b; - return 2; - } else { - return 1; - } + float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); + float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; + + float q0d = q0[0]*rayn_x + q0[1]*rayn_y; + float q1d = q1[0]*rayn_x + q1[1]*rayn_y; + float q2d = q2[0]*rayn_x + q2[1]*rayn_y; + float rod = orig[0]*rayn_x + orig[1]*rayn_y; + + float q10d = q1d - q0d; + float q20d = q2d - q0d; + float q0rd = q0d - rod; + + hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; + hits[0][1] = a*s0+b; + + if (num_s > 1) { + hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; + hits[1][1] = a*s1+b; + return 2; + } else { + return 1; + } } } @@ -4474,60 +4648,60 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex // make sure y never passes through a vertex of the shape y_frac = (float) STBTT_fmod(y, 1.0f); if (y_frac < 0.01f) - y += 0.01f; + y += 0.01f; else if (y_frac > 0.99f) - y -= 0.01f; + y -= 0.01f; orig[0] = x; orig[1] = y; // test a ray from (-infinity,y) to (x,y) for (i=0; i < nverts; ++i) { - if (verts[i].type == STBTT_vline) { - int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; - int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; - if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { - float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; - if (x_inter < x) - winding += (y0 < y1) ? 1 : -1; - } - } - if (verts[i].type == STBTT_vcurve) { - int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; - int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; - int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; - int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); - int by = STBTT_max(y0,STBTT_max(y1,y2)); - if (y > ay && y < by && x > ax) { - float q0[2],q1[2],q2[2]; - float hits[2][2]; - q0[0] = (float)x0; - q0[1] = (float)y0; - q1[0] = (float)x1; - q1[1] = (float)y1; - q2[0] = (float)x2; - q2[1] = (float)y2; - if (equal(q0,q1) || equal(q1,q2)) { - x0 = (int)verts[i-1].x; - y0 = (int)verts[i-1].y; - x1 = (int)verts[i ].x; - y1 = (int)verts[i ].y; - if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { - float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; - if (x_inter < x) - winding += (y0 < y1) ? 1 : -1; - } - } else { - int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); - if (num_hits >= 1) - if (hits[0][0] < 0) - winding += (hits[0][1] < 0 ? -1 : 1); - if (num_hits >= 2) - if (hits[1][0] < 0) - winding += (hits[1][1] < 0 ? -1 : 1); - } - } - } + if (verts[i].type == STBTT_vline) { + int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; + int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } + if (verts[i].type == STBTT_vcurve) { + int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; + int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; + int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; + int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); + int by = STBTT_max(y0,STBTT_max(y1,y2)); + if (y > ay && y < by && x > ax) { + float q0[2],q1[2],q2[2]; + float hits[2][2]; + q0[0] = (float)x0; + q0[1] = (float)y0; + q1[0] = (float)x1; + q1[1] = (float)y1; + q2[0] = (float)x2; + q2[1] = (float)y2; + if (equal(q0,q1) || equal(q1,q2)) { + x0 = (int)verts[i-1].x; + y0 = (int)verts[i-1].y; + x1 = (int)verts[i ].x; + y1 = (int)verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } else { + int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); + if (num_hits >= 1) + if (hits[0][0] < 0) + winding += (hits[0][1] < 0 ? -1 : 1); + if (num_hits >= 2) + if (hits[1][0] < 0) + winding += (hits[1][1] < 0 ? -1 : 1); + } + } + } } return winding; } @@ -4535,9 +4709,9 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex static float stbtt__cuberoot( float x ) { if (x<0) - return -(float) STBTT_pow(-x,1.0f/3.0f); + return -(float) STBTT_pow(-x,1.0f/3.0f); else - return (float) STBTT_pow( x,1.0f/3.0f); + return (float) STBTT_pow( x,1.0f/3.0f); } // x^3 + a*x^2 + b*x + c = 0 @@ -4549,26 +4723,26 @@ static int stbtt__solve_cubic(float a, float b, float c, float* r) float p3 = p*p*p; float d = q*q + 4*p3 / 27; if (d >= 0) { - float z = (float) STBTT_sqrt(d); - float u = (-q + z) / 2; - float v = (-q - z) / 2; - u = stbtt__cuberoot(u); - v = stbtt__cuberoot(v); - r[0] = s + u + v; - return 1; + float z = (float) STBTT_sqrt(d); + float u = (-q + z) / 2; + float v = (-q - z) / 2; + u = stbtt__cuberoot(u); + v = stbtt__cuberoot(v); + r[0] = s + u + v; + return 1; } else { - float u = (float) STBTT_sqrt(-p/3); - float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative - float m = (float) STBTT_cos(v); - float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; - r[0] = s + u * 2 * m; - r[1] = s - u * (m + n); - r[2] = s - u * (m - n); - - //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? - //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); - //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); - return 3; + float u = (float) STBTT_sqrt(-p/3); + float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative + float m = (float) STBTT_cos(v); + float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; + r[0] = s + u * 2 * m; + r[1] = s - u * (m + n); + r[2] = s - u * (m - n); + + //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? + //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); + //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); + return 3; } } @@ -4585,7 +4759,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc // if empty, return NULL if (ix0 == ix1 || iy0 == iy1) - return NULL; + return NULL; ix0 -= padding; iy0 -= padding; @@ -4604,155 +4778,155 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc scale_y = -scale_y; { - int x,y,i,j; - float *precompute; - stbtt_vertex *verts; - int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); - data = (unsigned char *) STBTT_malloc(w * h, info->userdata); - precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); - - for (i=0,j=num_verts-1; i < num_verts; j=i++) { - if (verts[i].type == STBTT_vline) { - float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; - float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; - float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); - precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; - } else if (verts[i].type == STBTT_vcurve) { - float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; - float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; - float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; - float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; - float len2 = bx*bx + by*by; - if (len2 != 0.0f) - precompute[i] = 1.0f / (bx*bx + by*by); - else - precompute[i] = 0.0f; - } else - precompute[i] = 0.0f; - } - - for (y=iy0; y < iy1; ++y) { - for (x=ix0; x < ix1; ++x) { - float val; - float min_dist = 999999.0f; - float sx = (float) x + 0.5f; - float sy = (float) y + 0.5f; - float x_gspace = (sx / scale_x); - float y_gspace = (sy / scale_y); - - int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path - - for (i=0; i < num_verts; ++i) { - float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; - - if (verts[i].type == STBTT_vline && precompute[i] != 0.0f) { - float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; - - float dist,dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); - if (dist2 < min_dist*min_dist) - min_dist = (float) STBTT_sqrt(dist2); - - // coarse culling against bbox - //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && - // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) - dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; - STBTT_assert(i != 0); - if (dist < min_dist) { - // check position along line - // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) - // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) - float dx = x1-x0, dy = y1-y0; - float px = x0-sx, py = y0-sy; - // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy - // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve - float t = -(px*dx + py*dy) / (dx*dx + dy*dy); - if (t >= 0.0f && t <= 1.0f) - min_dist = dist; - } - } else if (verts[i].type == STBTT_vcurve) { - float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; - float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; - float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); - float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); - float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); - float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); - // coarse culling against bbox to avoid computing cubic unnecessarily - if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { - int num=0; - float ax = x1-x0, ay = y1-y0; - float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; - float mx = x0 - sx, my = y0 - sy; - float res[3] = {0.f,0.f,0.f}; - float px,py,t,it,dist2; - float a_inv = precompute[i]; - if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula - float a = 3*(ax*bx + ay*by); - float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); - float c = mx*ax+my*ay; - if (a == 0.0) { // if a is 0, it's linear - if (b != 0.0) { - res[num++] = -c/b; - } - } else { - float discriminant = b*b - 4*a*c; - if (discriminant < 0) - num = 0; - else { - float root = (float) STBTT_sqrt(discriminant); - res[0] = (-b - root)/(2*a); - res[1] = (-b + root)/(2*a); - num = 2; // don't bother distinguishing 1-solution case, as code below will still work - } - } - } else { - float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point - float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; - float d = (mx*ax+my*ay) * a_inv; - num = stbtt__solve_cubic(b, c, d, res); - } - dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); - if (dist2 < min_dist*min_dist) - min_dist = (float) STBTT_sqrt(dist2); - - if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { - t = res[0], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { - t = res[1], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { - t = res[2], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - } - } - } - if (winding == 0) - min_dist = -min_dist; // if outside the shape, value is negative - val = onedge_value + pixel_dist_scale * min_dist; - if (val < 0) - val = 0; - else if (val > 255) - val = 255; - data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; - } - } - STBTT_free(precompute, info->userdata); - STBTT_free(verts, info->userdata); + int x,y,i,j; + float *precompute; + stbtt_vertex *verts; + int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); + data = (unsigned char *) STBTT_malloc(w * h, info->userdata); + precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); + + for (i=0,j=num_verts-1; i < num_verts; j=i++) { + if (verts[i].type == STBTT_vline) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; + float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); + precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; + float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; + float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float len2 = bx*bx + by*by; + if (len2 != 0.0f) + precompute[i] = 1.0f / (bx*bx + by*by); + else + precompute[i] = 0.0f; + } else + precompute[i] = 0.0f; + } + + for (y=iy0; y < iy1; ++y) { + for (x=ix0; x < ix1; ++x) { + float val; + float min_dist = 999999.0f; + float sx = (float) x + 0.5f; + float sy = (float) y + 0.5f; + float x_gspace = (sx / scale_x); + float y_gspace = (sy / scale_y); + + int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path + + for (i=0; i < num_verts; ++i) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + + if (verts[i].type == STBTT_vline && precompute[i] != 0.0f) { + float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; + + float dist,dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + // coarse culling against bbox + //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && + // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) + dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; + STBTT_assert(i != 0); + if (dist < min_dist) { + // check position along line + // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) + // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) + float dx = x1-x0, dy = y1-y0; + float px = x0-sx, py = y0-sy; + // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy + // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve + float t = -(px*dx + py*dy) / (dx*dx + dy*dy); + if (t >= 0.0f && t <= 1.0f) + min_dist = dist; + } + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; + float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; + float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); + float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); + float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); + float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); + // coarse culling against bbox to avoid computing cubic unnecessarily + if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { + int num=0; + float ax = x1-x0, ay = y1-y0; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float mx = x0 - sx, my = y0 - sy; + float res[3] = {0.f,0.f,0.f}; + float px,py,t,it,dist2; + float a_inv = precompute[i]; + if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula + float a = 3*(ax*bx + ay*by); + float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); + float c = mx*ax+my*ay; + if (a == 0.0) { // if a is 0, it's linear + if (b != 0.0) { + res[num++] = -c/b; + } + } else { + float discriminant = b*b - 4*a*c; + if (discriminant < 0) + num = 0; + else { + float root = (float) STBTT_sqrt(discriminant); + res[0] = (-b - root)/(2*a); + res[1] = (-b + root)/(2*a); + num = 2; // don't bother distinguishing 1-solution case, as code below will still work + } + } + } else { + float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point + float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; + float d = (mx*ax+my*ay) * a_inv; + num = stbtt__solve_cubic(b, c, d, res); + } + dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { + t = res[0], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { + t = res[1], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { + t = res[2], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + } + } + } + if (winding == 0) + min_dist = -min_dist; // if outside the shape, value is negative + val = onedge_value + pixel_dist_scale * min_dist; + if (val < 0) + val = 0; + else if (val > 255) + val = 255; + data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; + } + } + STBTT_free(precompute, info->userdata); + STBTT_free(verts, info->userdata); } return data; } @@ -4779,35 +4953,35 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, s // convert utf16 to utf8 and compare the results while converting while (len2) { - stbtt_uint16 ch = s2[0]*256 + s2[1]; - if (ch < 0x80) { - if (i >= len1) return -1; - if (s1[i++] != ch) return -1; - } else if (ch < 0x800) { - if (i+1 >= len1) return -1; - if (s1[i++] != 0xc0 + (ch >> 6)) return -1; - if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; - } else if (ch >= 0xd800 && ch < 0xdc00) { - stbtt_uint32 c; - stbtt_uint16 ch2 = s2[2]*256 + s2[3]; - if (i+3 >= len1) return -1; - c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; - if (s1[i++] != 0xf0 + (c >> 18)) return -1; - if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; - s2 += 2; // plus another 2 below - len2 -= 2; - } else if (ch >= 0xdc00 && ch < 0xe000) { - return -1; - } else { - if (i+2 >= len1) return -1; - if (s1[i++] != 0xe0 + (ch >> 12)) return -1; - if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; - } - s2 += 2; - len2 -= 2; + stbtt_uint16 ch = s2[0]*256 + s2[1]; + if (ch < 0x80) { + if (i >= len1) return -1; + if (s1[i++] != ch) return -1; + } else if (ch < 0x800) { + if (i+1 >= len1) return -1; + if (s1[i++] != 0xc0 + (ch >> 6)) return -1; + if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; + } else if (ch >= 0xd800 && ch < 0xdc00) { + stbtt_uint32 c; + stbtt_uint16 ch2 = s2[2]*256 + s2[3]; + if (i+3 >= len1) return -1; + c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; + if (s1[i++] != 0xf0 + (c >> 18)) return -1; + if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; + s2 += 2; // plus another 2 below + len2 -= 2; + } else if (ch >= 0xdc00 && ch < 0xe000) { + return -1; + } else { + if (i+2 >= len1) return -1; + if (s1[i++] != 0xe0 + (ch >> 12)) return -1; + if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; + } + s2 += 2; + len2 -= 2; } return i; } @@ -4830,12 +5004,12 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l count = ttUSHORT(fc+nm+2); stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) - && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { - *length = ttUSHORT(fc+loc+8); - return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); - } + stbtt_uint32 loc = nm + 6 + 12 * i; + if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) + && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { + *length = ttUSHORT(fc+loc+8); + return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); + } } return NULL; } @@ -4847,42 +5021,42 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - stbtt_int32 id = ttUSHORT(fc+loc+6); - if (id == target_id) { - // find the encoding - stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); - - // is this a Unicode encoding? - if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { - stbtt_int32 slen = ttUSHORT(fc+loc+8); - stbtt_int32 off = ttUSHORT(fc+loc+10); - - // check if there's a prefix match - stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); - if (matchlen >= 0) { - // check for target_id+1 immediately following, with same encoding & language - if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { - slen = ttUSHORT(fc+loc+12+8); - off = ttUSHORT(fc+loc+12+10); - if (slen == 0) { - if (matchlen == nlen) - return 1; - } else if (matchlen < nlen && name[matchlen] == ' ') { - ++matchlen; - if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) - return 1; - } - } else { - // if nothing immediately following - if (matchlen == nlen) - return 1; - } - } - } - - // @TODO handle other encodings - } + stbtt_uint32 loc = nm + 6 + 12 * i; + stbtt_int32 id = ttUSHORT(fc+loc+6); + if (id == target_id) { + // find the encoding + stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); + + // is this a Unicode encoding? + if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { + stbtt_int32 slen = ttUSHORT(fc+loc+8); + stbtt_int32 off = ttUSHORT(fc+loc+10); + + // check if there's a prefix match + stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); + if (matchlen >= 0) { + // check for target_id+1 immediately following, with same encoding & language + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); + if (slen == 0) { + if (matchlen == nlen) + return 1; + } else if (matchlen < nlen && name[matchlen] == ' ') { + ++matchlen; + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + return 1; + } + } else { + // if nothing immediately following + if (matchlen == nlen) + return 1; + } + } + } + + // @TODO handle other encodings + } } return 0; } @@ -4895,22 +5069,22 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam // check italics/bold/underline flags in macStyle... if (flags) { - hd = stbtt__find_table(fc, offset, "head"); - if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; + hd = stbtt__find_table(fc, offset, "head"); + if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; } nm = stbtt__find_table(fc, offset, "name"); if (!nm) return 0; if (flags) { - // if we checked the macStyle flags, then just check the family and ignore the subfamily - if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + // if we checked the macStyle flags, then just check the family and ignore the subfamily + if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } else { - if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } return 0; @@ -4920,10 +5094,10 @@ static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char { stbtt_int32 i; for (i=0;;++i) { - stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); - if (off < 0) return off; - if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) - return off; + stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); + if (off < 0) return off; + if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) + return off; } } @@ -4933,8 +5107,8 @@ static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char #endif STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, - float pixel_height, unsigned char *pixels, int pw, int ph, - int first_char, int num_chars, stbtt_bakedchar *chardata) + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) { return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); } diff --git a/fggl/stb/stb_vorbis.h b/fggl/stb/stb_vorbis.h index 3e5c2504c08f76b9d04e4adfbce80818631e835e..c7ef36b83806eb1432b377c59e3c00c4dc1ad727 100644 --- a/fggl/stb/stb_vorbis.h +++ b/fggl/stb/stb_vorbis.h @@ -80,6 +80,7 @@ #ifndef STB_VORBIS_NO_STDIO #include <stdio.h> + #endif #ifdef __cplusplus @@ -115,10 +116,9 @@ extern "C" { // will occur from it as described above. Otherwise just pass NULL // to use malloc()/alloca() -typedef struct -{ - char *alloc_buffer; - int alloc_buffer_length_in_bytes; +typedef struct { + char *alloc_buffer; + int alloc_buffer_length_in_bytes; } stb_vorbis_alloc; @@ -126,24 +126,22 @@ typedef struct typedef struct stb_vorbis stb_vorbis; -typedef struct -{ - unsigned int sample_rate; - int channels; +typedef struct { + unsigned int sample_rate; + int channels; - unsigned int setup_memory_required; - unsigned int setup_temp_memory_required; - unsigned int temp_memory_required; + unsigned int setup_memory_required; + unsigned int setup_temp_memory_required; + unsigned int temp_memory_required; - int max_frame_size; + int max_frame_size; } stb_vorbis_info; -typedef struct -{ - char *vendor; +typedef struct { + char *vendor; - int comment_list_length; - char **comment_list; + int comment_list_length; + char **comment_list; } stb_vorbis_comment; // get general information about the file @@ -181,10 +179,10 @@ extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); // specification does not bound the size of an individual frame. extern stb_vorbis *stb_vorbis_open_pushdata( - const unsigned char * datablock, int datablock_length_in_bytes, - int *datablock_memory_consumed_in_bytes, - int *error, - const stb_vorbis_alloc *alloc_buffer); + const unsigned char *datablock, int datablock_length_in_bytes, + int *datablock_memory_consumed_in_bytes, + int *error, + const stb_vorbis_alloc *alloc_buffer); // create a vorbis decoder by passing in the initial data block containing // the ogg&vorbis headers (you don't need to do parse them, just provide // the first N bytes of the file--you're told if it's not enough, see below) @@ -195,12 +193,12 @@ extern stb_vorbis *stb_vorbis_open_pushdata( // incomplete and you need to pass in a larger block from the start of the file extern int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, - const unsigned char *datablock, int datablock_length_in_bytes, - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ); + stb_vorbis *f, + const unsigned char *datablock, int datablock_length_in_bytes, + int *channels, // place to write number of float * buffers + float ***output, // place to write float ** array of float * buffers + int *samples // place to write number of output samples +); // decode a frame of audio sample data if possible from the passed-in data block // // return value: number of bytes we used from datablock @@ -265,19 +263,19 @@ extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *chan // decoded, or -1 if the file could not be opened or was not an ogg vorbis file. // When you're done with it, just free() the pointer returned in *output. -extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, - int *error, const stb_vorbis_alloc *alloc_buffer); +extern stb_vorbis *stb_vorbis_open_memory(const unsigned char *data, int len, + int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an ogg vorbis stream in memory (note // this must be the entire stream!). on failure, returns NULL and sets *error #ifndef STB_VORBIS_NO_STDIO -extern stb_vorbis * stb_vorbis_open_filename(const char *filename, - int *error, const stb_vorbis_alloc *alloc_buffer); +extern stb_vorbis *stb_vorbis_open_filename(const char *filename, + int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from a filename via fopen(). on failure, // returns NULL and sets *error (possibly to VORBIS_file_open_failure). -extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, - int *error, const stb_vorbis_alloc *alloc_buffer); +extern stb_vorbis *stb_vorbis_open_file(FILE *f, int close_handle_on_close, + int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell). on failure, returns NULL and sets *error. // note that stb_vorbis must "own" this stream; if you seek it in between @@ -286,8 +284,8 @@ extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, // owns the _entire_ rest of the file after the start point. Use the next // function, stb_vorbis_open_file_section(), to limit it. -extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, - int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); +extern stb_vorbis *stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, + int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell); the stream will be of length 'len' bytes. // on failure, returns NULL and sets *error. note that stb_vorbis must "own" @@ -308,7 +306,7 @@ extern int stb_vorbis_seek_start(stb_vorbis *f); // this function is equivalent to stb_vorbis_seek(f,0) extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); -extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); +extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); // these functions return the total length of the vorbis stream extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); @@ -323,7 +321,7 @@ extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***out #ifndef STB_VORBIS_NO_INTEGER_CONVERSION extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); -extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); +extern int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples); #endif // decode the next frame and return the number of *samples* per channel. // Note that for interleaved data, you pass in the number of shorts (the @@ -371,42 +369,40 @@ extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buf //////// ERROR CODES -enum STBVorbisError -{ - VORBIS__no_error, - - VORBIS_need_more_data=1, // not a real error - - VORBIS_invalid_api_mixing, // can't mix API modes - VORBIS_outofmem, // not enough memory - VORBIS_feature_not_supported, // uses floor 0 - VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small - VORBIS_file_open_failure, // fopen() failed - VORBIS_seek_without_length, // can't seek in unknown-length file - - VORBIS_unexpected_eof=10, // file is truncated? - VORBIS_seek_invalid, // seek past EOF - - // decoding errors (corrupt/invalid stream) -- you probably - // don't care about the exact details of these - - // vorbis errors: - VORBIS_invalid_setup=20, - VORBIS_invalid_stream, - - // ogg errors: - VORBIS_missing_capture_pattern=30, - VORBIS_invalid_stream_structure_version, - VORBIS_continued_packet_flag_invalid, - VORBIS_incorrect_stream_serial_number, - VORBIS_invalid_first_page, - VORBIS_bad_packet_type, - VORBIS_cant_find_last_page, - VORBIS_seek_failed, - VORBIS_ogg_skeleton_not_supported +enum STBVorbisError { + VORBIS__no_error, + + VORBIS_need_more_data = 1, // not a real error + + VORBIS_invalid_api_mixing, // can't mix API modes + VORBIS_outofmem, // not enough memory + VORBIS_feature_not_supported, // uses floor 0 + VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small + VORBIS_file_open_failure, // fopen() failed + VORBIS_seek_without_length, // can't seek in unknown-length file + + VORBIS_unexpected_eof = 10, // file is truncated? + VORBIS_seek_invalid, // seek past EOF + + // decoding errors (corrupt/invalid stream) -- you probably + // don't care about the exact details of these + + // vorbis errors: + VORBIS_invalid_setup = 20, + VORBIS_invalid_stream, + + // ogg errors: + VORBIS_missing_capture_pattern = 30, + VORBIS_invalid_stream_structure_version, + VORBIS_continued_packet_flag_invalid, + VORBIS_incorrect_stream_serial_number, + VORBIS_invalid_first_page, + VORBIS_bad_packet_type, + VORBIS_cant_find_last_page, + VORBIS_seek_failed, + VORBIS_ogg_skeleton_not_supported }; - #ifdef __cplusplus } #endif @@ -550,49 +546,50 @@ enum STBVorbisError ////////////////////////////////////////////////////////////////////////////// #ifdef STB_VORBIS_NO_PULLDATA_API - #define STB_VORBIS_NO_INTEGER_CONVERSION + #define STB_VORBIS_NO_INTEGER_CONVERSION #define STB_VORBIS_NO_STDIO #endif #if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) - #define STB_VORBIS_NO_STDIO 1 + #define STB_VORBIS_NO_STDIO 1 #endif #ifndef STB_VORBIS_NO_INTEGER_CONVERSION #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - // only need endianness for fast-float-to-int, which we don't - // use for pushdata +// only need endianness for fast-float-to-int, which we don't +// use for pushdata - #ifndef STB_VORBIS_BIG_ENDIAN - #define STB_VORBIS_ENDIAN 0 - #else - #define STB_VORBIS_ENDIAN 1 - #endif + #ifndef STB_VORBIS_BIG_ENDIAN + #define STB_VORBIS_ENDIAN 0 + #else + #define STB_VORBIS_ENDIAN 1 + #endif #endif #endif - #ifndef STB_VORBIS_NO_STDIO #include <stdio.h> + #endif #ifndef STB_VORBIS_NO_CRT - #include <stdlib.h> - #include <string.h> - #include <assert.h> - #include <math.h> - - // find definition of alloca if it's not in stdlib.h: - #if defined(_MSC_VER) || defined(__MINGW32__) - #include <malloc.h> - #endif - #if defined(__linux__) || defined(__linux) || defined(__sun__) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__) - #include <alloca.h> - #endif + #include <stdlib.h> + #include <string.h> + #include <assert.h> + #include <math.h> + +// find definition of alloca if it's not in stdlib.h: + #if defined(_MSC_VER) || defined(__MINGW32__) + #include <malloc.h> + #endif + #if defined(__linux__) || defined(__linux) || defined(__sun__) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__) + #include <alloca.h> + + #endif #else // STB_VORBIS_NO_CRT - #define NULL 0 + #define NULL 0 #define malloc(s) 0 #define free(s) ((void) 0) #define realloc(s) 0 @@ -601,7 +598,7 @@ enum STBVorbisError #include <limits.h> #ifdef __MINGW32__ - // eff you mingw: + // eff you mingw: // "fixed": // http://sourceforge.net/p/mingw-w64/mailman/message/32882927/ // "no that broke the build, reverted, who cares about C": @@ -614,11 +611,11 @@ enum STBVorbisError #define alloca __builtin_alloca #endif #elif !defined(_MSC_VER) - #if __GNUC__ - #define __forceinline inline - #else - #define __forceinline - #endif + #if __GNUC__ + #define __forceinline inline + #else + #define __forceinline + #endif #endif #if STB_VORBIS_MAX_CHANNELS > 256 @@ -629,9 +626,8 @@ enum STBVorbisError #error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" #endif - #if 0 -#include <crtdbg.h> + #include <crtdbg.h> #define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1]) #else #define CHECK(f) ((void) 0) @@ -640,13 +636,12 @@ enum STBVorbisError #define MAX_BLOCKSIZE_LOG 13 // from specification #define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) - -typedef unsigned char uint8; -typedef signed char int8; +typedef unsigned char uint8; +typedef signed char int8; typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned int uint32; -typedef signed int int32; +typedef signed short int16; +typedef unsigned int uint32; +typedef signed int int32; #ifndef TRUE #define TRUE 1 @@ -677,246 +672,234 @@ typedef float codetype; #define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) #define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) -typedef struct -{ - int dimensions, entries; - uint8 *codeword_lengths; - float minimum_value; - float delta_value; - uint8 value_bits; - uint8 lookup_type; - uint8 sequence_p; - uint8 sparse; - uint32 lookup_values; - codetype *multiplicands; - uint32 *codewords; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #else - int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #endif - uint32 *sorted_codewords; - int *sorted_values; - int sorted_entries; +typedef struct { + int dimensions, entries; + uint8 *codeword_lengths; + float minimum_value; + float delta_value; + uint8 value_bits; + uint8 lookup_type; + uint8 sequence_p; + uint8 sparse; + uint32 lookup_values; + codetype *multiplicands; + uint32 *codewords; + #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT + int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; + #else + int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; + #endif + uint32 *sorted_codewords; + int *sorted_values; + int sorted_entries; } Codebook; -typedef struct -{ - uint8 order; - uint16 rate; - uint16 bark_map_size; - uint8 amplitude_bits; - uint8 amplitude_offset; - uint8 number_of_books; - uint8 book_list[16]; // varies +typedef struct { + uint8 order; + uint16 rate; + uint16 bark_map_size; + uint8 amplitude_bits; + uint8 amplitude_offset; + uint8 number_of_books; + uint8 book_list[16]; // varies } Floor0; -typedef struct -{ - uint8 partitions; - uint8 partition_class_list[32]; // varies - uint8 class_dimensions[16]; // varies - uint8 class_subclasses[16]; // varies - uint8 class_masterbooks[16]; // varies - int16 subclass_books[16][8]; // varies - uint16 Xlist[31*8+2]; // varies - uint8 sorted_order[31*8+2]; - uint8 neighbors[31*8+2][2]; - uint8 floor1_multiplier; - uint8 rangebits; - int values; +typedef struct { + uint8 partitions; + uint8 partition_class_list[32]; // varies + uint8 class_dimensions[16]; // varies + uint8 class_subclasses[16]; // varies + uint8 class_masterbooks[16]; // varies + int16 subclass_books[16][8]; // varies + uint16 Xlist[31 * 8 + 2]; // varies + uint8 sorted_order[31 * 8 + 2]; + uint8 neighbors[31 * 8 + 2][2]; + uint8 floor1_multiplier; + uint8 rangebits; + int values; } Floor1; -typedef union -{ - Floor0 floor0; - Floor1 floor1; +typedef union { + Floor0 floor0; + Floor1 floor1; } Floor; -typedef struct -{ - uint32 begin, end; - uint32 part_size; - uint8 classifications; - uint8 classbook; - uint8 **classdata; - int16 (*residue_books)[8]; +typedef struct { + uint32 begin, end; + uint32 part_size; + uint8 classifications; + uint8 classbook; + uint8 **classdata; + int16 (*residue_books)[8]; } Residue; -typedef struct -{ - uint8 magnitude; - uint8 angle; - uint8 mux; +typedef struct { + uint8 magnitude; + uint8 angle; + uint8 mux; } MappingChannel; -typedef struct -{ - uint16 coupling_steps; - MappingChannel *chan; - uint8 submaps; - uint8 submap_floor[15]; // varies - uint8 submap_residue[15]; // varies +typedef struct { + uint16 coupling_steps; + MappingChannel *chan; + uint8 submaps; + uint8 submap_floor[15]; // varies + uint8 submap_residue[15]; // varies } Mapping; -typedef struct -{ - uint8 blockflag; - uint8 mapping; - uint16 windowtype; - uint16 transformtype; +typedef struct { + uint8 blockflag; + uint8 mapping; + uint16 windowtype; + uint16 transformtype; } Mode; -typedef struct -{ - uint32 goal_crc; // expected crc if match - int bytes_left; // bytes left in packet - uint32 crc_so_far; // running crc - int bytes_done; // bytes processed in _current_ chunk - uint32 sample_loc; // granule pos encoded in page +typedef struct { + uint32 goal_crc; // expected crc if match + int bytes_left; // bytes left in packet + uint32 crc_so_far; // running crc + int bytes_done; // bytes processed in _current_ chunk + uint32 sample_loc; // granule pos encoded in page } CRCscan; -typedef struct -{ - uint32 page_start, page_end; - uint32 last_decoded_sample; +typedef struct { + uint32 page_start, page_end; + uint32 last_decoded_sample; } ProbedPage; -struct stb_vorbis -{ - // user-accessible info - unsigned int sample_rate; - int channels; +struct stb_vorbis { + // user-accessible info + unsigned int sample_rate; + int channels; - unsigned int setup_memory_required; - unsigned int temp_memory_required; - unsigned int setup_temp_memory_required; + unsigned int setup_memory_required; + unsigned int temp_memory_required; + unsigned int setup_temp_memory_required; - char *vendor; - int comment_list_length; - char **comment_list; + char *vendor; + int comment_list_length; + char **comment_list; - // input config + // input config #ifndef STB_VORBIS_NO_STDIO - FILE *f; - uint32 f_start; - int close_on_free; + FILE *f; + uint32 f_start; + int close_on_free; #endif - uint8 *stream; - uint8 *stream_start; - uint8 *stream_end; - - uint32 stream_len; - - uint8 push_mode; - - // the page to seek to when seeking to start, may be zero - uint32 first_audio_page_offset; - - // p_first is the page on which the first audio packet ends - // (but not necessarily the page on which it starts) - ProbedPage p_first, p_last; - - // memory management - stb_vorbis_alloc alloc; - int setup_offset; - int temp_offset; - - // run-time results - int eof; - enum STBVorbisError error; - - // user-useful data - - // header info - int blocksize[2]; - int blocksize_0, blocksize_1; - int codebook_count; - Codebook *codebooks; - int floor_count; - uint16 floor_types[64]; // varies - Floor *floor_config; - int residue_count; - uint16 residue_types[64]; // varies - Residue *residue_config; - int mapping_count; - Mapping *mapping; - int mode_count; - Mode mode_config[64]; // varies - - uint32 total_samples; - - // decode buffer - float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; - float *outputs [STB_VORBIS_MAX_CHANNELS]; - - float *previous_window[STB_VORBIS_MAX_CHANNELS]; - int previous_length; - - #ifndef STB_VORBIS_NO_DEFER_FLOOR - int16 *finalY[STB_VORBIS_MAX_CHANNELS]; - #else - float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; - #endif - - uint32 current_loc; // sample location of next frame to decode - int current_loc_valid; - - // per-blocksize precomputed data - - // twiddle factors - float *A[2],*B[2],*C[2]; - float *window[2]; - uint16 *bit_reverse[2]; - - // current page/packet/segment streaming info - uint32 serial; // stream serial number for verification - int last_page; - int segment_count; - uint8 segments[255]; - uint8 page_flag; - uint8 bytes_in_seg; - uint8 first_decode; - int next_seg; - int last_seg; // flag that we're on the last segment - int last_seg_which; // what was the segment number of the last seg? - uint32 acc; - int valid_bits; - int packet_bytes; - int end_seg_with_known_loc; - uint32 known_loc_for_packet; - int discard_samples_deferred; - uint32 samples_output; - - // push mode scanning - int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching + uint8 *stream; + uint8 *stream_start; + uint8 *stream_end; + + uint32 stream_len; + + uint8 push_mode; + + // the page to seek to when seeking to start, may be zero + uint32 first_audio_page_offset; + + // p_first is the page on which the first audio packet ends + // (but not necessarily the page on which it starts) + ProbedPage p_first, p_last; + + // memory management + stb_vorbis_alloc alloc; + int setup_offset; + int temp_offset; + + // run-time results + int eof; + enum STBVorbisError error; + + // user-useful data + + // header info + int blocksize[2]; + int blocksize_0, blocksize_1; + int codebook_count; + Codebook *codebooks; + int floor_count; + uint16 floor_types[64]; // varies + Floor *floor_config; + int residue_count; + uint16 residue_types[64]; // varies + Residue *residue_config; + int mapping_count; + Mapping *mapping; + int mode_count; + Mode mode_config[64]; // varies + + uint32 total_samples; + + // decode buffer + float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; + float *outputs[STB_VORBIS_MAX_CHANNELS]; + + float *previous_window[STB_VORBIS_MAX_CHANNELS]; + int previous_length; + + #ifndef STB_VORBIS_NO_DEFER_FLOOR + int16 *finalY[STB_VORBIS_MAX_CHANNELS]; + #else + float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; + #endif + + uint32 current_loc; // sample location of next frame to decode + int current_loc_valid; + + // per-blocksize precomputed data + + // twiddle factors + float *A[2], *B[2], *C[2]; + float *window[2]; + uint16 *bit_reverse[2]; + + // current page/packet/segment streaming info + uint32 serial; // stream serial number for verification + int last_page; + int segment_count; + uint8 segments[255]; + uint8 page_flag; + uint8 bytes_in_seg; + uint8 first_decode; + int next_seg; + int last_seg; // flag that we're on the last segment + int last_seg_which; // what was the segment number of the last seg? + uint32 acc; + int valid_bits; + int packet_bytes; + int end_seg_with_known_loc; + uint32 known_loc_for_packet; + int discard_samples_deferred; + uint32 samples_output; + + // push mode scanning + int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching #ifndef STB_VORBIS_NO_PUSHDATA_API - CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; + CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; #endif - // sample-access - int channel_buffer_start; - int channel_buffer_end; + // sample-access + int channel_buffer_start; + int channel_buffer_end; }; #if defined(STB_VORBIS_NO_PUSHDATA_API) - #define IS_PUSH_MODE(f) FALSE + #define IS_PUSH_MODE(f) FALSE #elif defined(STB_VORBIS_NO_PULLDATA_API) - #define IS_PUSH_MODE(f) TRUE + #define IS_PUSH_MODE(f) TRUE #else - #define IS_PUSH_MODE(f) ((f)->push_mode) + #define IS_PUSH_MODE(f) ((f)->push_mode) #endif typedef struct stb_vorbis vorb; -static int error(vorb *f, enum STBVorbisError e) -{ - f->error = e; - if (!f->eof && e != VORBIS_need_more_data) { - f->error=e; // breakpoint for debugging - } - return 0; +static int error(vorb *f, enum STBVorbisError e) { + f->error = e; + if (!f->eof && e != VORBIS_need_more_data) { + f->error = e; // breakpoint for debugging + } + return 0; } @@ -925,125 +908,126 @@ static int error(vorb *f, enum STBVorbisError e) // alloca(); otherwise, provide a temp buffer and it will // allocate out of those. -#define array_size_required(count,size) (count*(sizeof(void *)+(size))) +#define array_size_required(count, size) (count*(sizeof(void *)+(size))) -#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) -#define temp_free(f,p) (void)0 +#define temp_alloc(f, size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) +#define temp_free(f, p) (void)0 #define temp_alloc_save(f) ((f)->temp_offset) -#define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) +#define temp_alloc_restore(f, p) ((f)->temp_offset = (p)) -#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) +#define temp_block_array(f, count, size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) // given a sufficiently large block of memory, make an array of pointers to subblocks of it -static void *make_block_array(void *mem, int count, int size) -{ - int i; - void ** p = (void **) mem; - char *q = (char *) (p + count); - for (i=0; i < count; ++i) { - p[i] = q; - q += size; - } - return p; +static void *make_block_array(void *mem, int count, int size) { + int i; + void **p = (void **) mem; + char *q = (char *) (p + count); + for (i = 0; i < count; ++i) { + p[i] = q; + q += size; + } + return p; } -static void *setup_malloc(vorb *f, int sz) -{ - sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs. - f->setup_memory_required += sz; - if (f->alloc.alloc_buffer) { - void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; - if (f->setup_offset + sz > f->temp_offset) return NULL; - f->setup_offset += sz; - return p; - } - return sz ? malloc(sz) : NULL; +static void *setup_malloc(vorb *f, int sz) { + sz = (sz + 7) & ~7; // round up to nearest 8 for alignment of future allocs. + f->setup_memory_required += sz; + if (f->alloc.alloc_buffer) { + void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; + if (f->setup_offset + sz > f->temp_offset) + return NULL; + f->setup_offset += sz; + return p; + } + return sz ? malloc(sz) : NULL; } -static void setup_free(vorb *f, void *p) -{ - if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack - free(p); +static void setup_free(vorb *f, void *p) { + if (f->alloc.alloc_buffer) + return; // do nothing; setup mem is a stack + free(p); } -static void *setup_temp_malloc(vorb *f, int sz) -{ - sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs. - if (f->alloc.alloc_buffer) { - if (f->temp_offset - sz < f->setup_offset) return NULL; - f->temp_offset -= sz; - return (char *) f->alloc.alloc_buffer + f->temp_offset; - } - return malloc(sz); +static void *setup_temp_malloc(vorb *f, int sz) { + sz = (sz + 7) & ~7; // round up to nearest 8 for alignment of future allocs. + if (f->alloc.alloc_buffer) { + if (f->temp_offset - sz < f->setup_offset) + return NULL; + f->temp_offset -= sz; + return (char *) f->alloc.alloc_buffer + f->temp_offset; + } + return malloc(sz); } -static void setup_temp_free(vorb *f, void *p, int sz) -{ - if (f->alloc.alloc_buffer) { - f->temp_offset += (sz+7)&~7; - return; - } - free(p); +static void setup_temp_free(vorb *f, void *p, int sz) { + if (f->alloc.alloc_buffer) { + f->temp_offset += (sz + 7) & ~7; + return; + } + free(p); } #define CRC32_POLY 0x04c11db7 // from spec static uint32 crc_table[256]; -static void crc32_init(void) -{ - int i,j; - uint32 s; - for(i=0; i < 256; i++) { - for (s=(uint32) i << 24, j=0; j < 8; ++j) - s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); - crc_table[i] = s; - } -} -static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) -{ - return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; +static void crc32_init(void) { + int i, j; + uint32 s; + for (i = 0; i < 256; i++) { + for (s = (uint32) i << 24, j = 0; j < 8; ++j) + s = (s << 1) ^ (s >= (1U << 31) ? CRC32_POLY : 0); + crc_table[i] = s; + } } +static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) { + return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; +} // used in setup, and for huffman that doesn't go fast path -static unsigned int bit_reverse(unsigned int n) -{ - n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); - n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); - n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); - n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); - return (n >> 16) | (n << 16); +static unsigned int bit_reverse(unsigned int n) { + n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); + n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); + n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); + n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); + return (n >> 16) | (n << 16); } -static float square(float x) -{ - return x*x; +static float square(float x) { + return x * x; } // this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 // as required by the specification. fast(?) implementation from stb.h // @OPTIMIZE: called multiple times per-packet with "constants"; move to setup -static int ilog(int32 n) -{ - static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; - - if (n < 0) return 0; // signed n returns 0 - - // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) - if (n < (1 << 14)) - if (n < (1 << 4)) return 0 + log2_4[n ]; - else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; - else return 10 + log2_4[n >> 10]; - else if (n < (1 << 24)) - if (n < (1 << 19)) return 15 + log2_4[n >> 15]; - else return 20 + log2_4[n >> 20]; - else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; - else return 30 + log2_4[n >> 30]; +static int ilog(int32 n) { + static signed char log2_4[16] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4}; + + if (n < 0) + return 0; // signed n returns 0 + + // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) + if (n < (1 << 14)) + if (n < (1 << 4)) + return 0 + log2_4[n]; + else if (n < (1 << 9)) + return 5 + log2_4[n >> 5]; + else + return 10 + log2_4[n >> 10]; + else if (n < (1 << 24)) + if (n < (1 << 19)) + return 15 + log2_4[n >> 15]; + else + return 20 + log2_4[n >> 20]; + else if (n < (1 << 29)) + return 25 + log2_4[n >> 25]; + else + return 30 + log2_4[n >> 30]; } #ifndef M_PI - #define M_PI 3.14159265358979323846264f // from CRC + #define M_PI 3.14159265358979323846264f // from CRC #endif // code length assigned to a value with no huffman encoding @@ -1054,17 +1038,15 @@ static int ilog(int32 n) // these functions are only called at setup, and only a few times // per file -static float float32_unpack(uint32 x) -{ - // from the specification - uint32 mantissa = x & 0x1fffff; - uint32 sign = x & 0x80000000; - uint32 exp = (x & 0x7fe00000) >> 21; - double res = sign ? -(double)mantissa : (double)mantissa; - return (float) ldexp((float)res, (int)exp-788); +static float float32_unpack(uint32 x) { + // from the specification + uint32 mantissa = x & 0x1fffff; + uint32 sign = x & 0x80000000; + uint32 exp = (x & 0x7fe00000) >> 21; + double res = sign ? -(double) mantissa : (double) mantissa; + return (float) ldexp((float) res, (int) exp - 788); } - // zlib & jpeg huffman tables assume that the output symbols // can either be arbitrarily arranged, or have monotonically // increasing frequencies--they rely on the lengths being sorted; @@ -1072,85 +1054,92 @@ static float float32_unpack(uint32 x) // vorbis allows a huffman table with non-sorted lengths. This // requires a more sophisticated construction, since symbols in // order do not map to huffman codes "in order". -static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) -{ - if (!c->sparse) { - c->codewords [symbol] = huff_code; - } else { - c->codewords [count] = huff_code; - c->codeword_lengths[count] = len; - values [count] = symbol; - } +static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) { + if (!c->sparse) { + c->codewords[symbol] = huff_code; + } else { + c->codewords[count] = huff_code; + c->codeword_lengths[count] = len; + values[count] = symbol; + } } -static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) -{ - int i,k,m=0; - uint32 available[32]; - - memset(available, 0, sizeof(available)); - // find the first entry - for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; - if (k == n) { assert(c->sorted_entries == 0); return TRUE; } - assert(len[k] < 32); // no error return required, code reading lens checks this - // add to the list - add_entry(c, 0, k, m++, len[k], values); - // add all available leaves - for (i=1; i <= len[k]; ++i) - available[i] = 1U << (32-i); - // note that the above code treats the first case specially, - // but it's really the same as the following code, so they - // could probably be combined (except the initial code is 0, - // and I use 0 in available[] to mean 'empty') - for (i=k+1; i < n; ++i) { - uint32 res; - int z = len[i], y; - if (z == NO_CODE) continue; - assert(z < 32); // no error return required, code reading lens checks this - // find lowest available leaf (should always be earliest, - // which is what the specification calls for) - // note that this property, and the fact we can never have - // more than one free leaf at a given level, isn't totally - // trivial to prove, but it seems true and the assert never - // fires, so! - while (z > 0 && !available[z]) --z; - if (z == 0) { return FALSE; } - res = available[z]; - available[z] = 0; - add_entry(c, bit_reverse(res), i, m++, len[i], values); - // propagate availability up the tree - if (z != len[i]) { - for (y=len[i]; y > z; --y) { - assert(available[y] == 0); - available[y] = res + (1 << (32-y)); - } - } - } - return TRUE; +static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) { + int i, k, m = 0; + uint32 available[32]; + + memset(available, 0, sizeof(available)); + // find the first entry + for (k = 0; k < n; ++k) + if (len[k] < NO_CODE) + break; + if (k == n) { + assert(c->sorted_entries == 0); + return TRUE; + } + assert(len[k] < 32); // no error return required, code reading lens checks this + // add to the list + add_entry(c, 0, k, m++, len[k], values); + // add all available leaves + for (i = 1; i <= len[k]; ++i) + available[i] = 1U << (32 - i); + // note that the above code treats the first case specially, + // but it's really the same as the following code, so they + // could probably be combined (except the initial code is 0, + // and I use 0 in available[] to mean 'empty') + for (i = k + 1; i < n; ++i) { + uint32 res; + int z = len[i], y; + if (z == NO_CODE) + continue; + assert(z < 32); // no error return required, code reading lens checks this + // find lowest available leaf (should always be earliest, + // which is what the specification calls for) + // note that this property, and the fact we can never have + // more than one free leaf at a given level, isn't totally + // trivial to prove, but it seems true and the assert never + // fires, so! + while (z > 0 && !available[z]) + --z; + if (z == 0) { + return FALSE; + } + res = available[z]; + available[z] = 0; + add_entry(c, bit_reverse(res), i, m++, len[i], values); + // propagate availability up the tree + if (z != len[i]) { + for (y = len[i]; y > z; --y) { + assert(available[y] == 0); + available[y] = res + (1 << (32 - y)); + } + } + } + return TRUE; } // accelerated huffman table allows fast O(1) match of all symbols // of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH -static void compute_accelerated_huffman(Codebook *c) -{ - int i, len; - for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) - c->fast_huffman[i] = -1; - - len = c->sparse ? c->sorted_entries : c->entries; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - if (len > 32767) len = 32767; // largest possible value we can encode! - #endif - for (i=0; i < len; ++i) { - if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { - uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; - // set table entries for all bit combinations in the higher bits - while (z < FAST_HUFFMAN_TABLE_SIZE) { - c->fast_huffman[z] = i; - z += 1 << c->codeword_lengths[i]; - } - } - } +static void compute_accelerated_huffman(Codebook *c) { + int i, len; + for (i = 0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) + c->fast_huffman[i] = -1; + + len = c->sparse ? c->sorted_entries : c->entries; + #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT + if (len > 32767) + len = 32767; // largest possible value we can encode! + #endif + for (i = 0; i < len; ++i) { + if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { + uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; + // set table entries for all bit combinations in the higher bits + while (z < FAST_HUFFMAN_TABLE_SIZE) { + c->fast_huffman[z] = i; + z += 1 << c->codeword_lengths[i]; + } + } + } } #ifdef _MSC_VER @@ -1159,169 +1148,171 @@ static void compute_accelerated_huffman(Codebook *c) #define STBV_CDECL #endif -static int STBV_CDECL uint32_compare(const void *p, const void *q) -{ - uint32 x = * (uint32 *) p; - uint32 y = * (uint32 *) q; - return x < y ? -1 : x > y; +static int STBV_CDECL uint32_compare(const void *p, const void *q) { + uint32 x = *(uint32 *) p; + uint32 y = *(uint32 *) q; + return x < y ? -1 : x > y; } -static int include_in_sort(Codebook *c, uint8 len) -{ - if (c->sparse) { assert(len != NO_CODE); return TRUE; } - if (len == NO_CODE) return FALSE; - if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; - return FALSE; +static int include_in_sort(Codebook *c, uint8 len) { + if (c->sparse) { + assert(len != NO_CODE); + return TRUE; + } + if (len == NO_CODE) + return FALSE; + if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) + return TRUE; + return FALSE; } // if the fast table above doesn't work, we want to binary // search them... need to reverse the bits -static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) -{ - int i, len; - // build a list of all the entries - // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. - // this is kind of a frivolous optimization--I don't see any performance improvement, - // but it's like 4 extra lines of code, so. - if (!c->sparse) { - int k = 0; - for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) - c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); - assert(k == c->sorted_entries); - } else { - for (i=0; i < c->sorted_entries; ++i) - c->sorted_codewords[i] = bit_reverse(c->codewords[i]); - } - - qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); - c->sorted_codewords[c->sorted_entries] = 0xffffffff; - - len = c->sparse ? c->sorted_entries : c->entries; - // now we need to indicate how they correspond; we could either - // #1: sort a different data structure that says who they correspond to - // #2: for each sorted entry, search the original list to find who corresponds - // #3: for each original entry, find the sorted entry - // #1 requires extra storage, #2 is slow, #3 can use binary search! - for (i=0; i < len; ++i) { - int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; - if (include_in_sort(c,huff_len)) { - uint32 code = bit_reverse(c->codewords[i]); - int x=0, n=c->sorted_entries; - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - assert(c->sorted_codewords[x] == code); - if (c->sparse) { - c->sorted_values[x] = values[i]; - c->codeword_lengths[x] = huff_len; - } else { - c->sorted_values[x] = i; - } - } - } +static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) { + int i, len; + // build a list of all the entries + // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. + // this is kind of a frivolous optimization--I don't see any performance improvement, + // but it's like 4 extra lines of code, so. + if (!c->sparse) { + int k = 0; + for (i = 0; i < c->entries; ++i) + if (include_in_sort(c, lengths[i])) + c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); + assert(k == c->sorted_entries); + } else { + for (i = 0; i < c->sorted_entries; ++i) + c->sorted_codewords[i] = bit_reverse(c->codewords[i]); + } + + qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); + c->sorted_codewords[c->sorted_entries] = 0xffffffff; + + len = c->sparse ? c->sorted_entries : c->entries; + // now we need to indicate how they correspond; we could either + // #1: sort a different data structure that says who they correspond to + // #2: for each sorted entry, search the original list to find who corresponds + // #3: for each original entry, find the sorted entry + // #1 requires extra storage, #2 is slow, #3 can use binary search! + for (i = 0; i < len; ++i) { + int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; + if (include_in_sort(c, huff_len)) { + uint32 code = bit_reverse(c->codewords[i]); + int x = 0, n = c->sorted_entries; + while (n > 1) { + // invariant: sc[x] <= code < sc[x+n] + int m = x + (n >> 1); + if (c->sorted_codewords[m] <= code) { + x = m; + n -= (n >> 1); + } else { + n >>= 1; + } + } + assert(c->sorted_codewords[x] == code); + if (c->sparse) { + c->sorted_values[x] = values[i]; + c->codeword_lengths[x] = huff_len; + } else { + c->sorted_values[x] = i; + } + } + } } // only run while parsing the header (3 times) -static int vorbis_validate(uint8 *data) -{ - static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; - return memcmp(data, vorbis, 6) == 0; +static int vorbis_validate(uint8 *data) { + static uint8 vorbis[6] = {'v', 'o', 'r', 'b', 'i', 's'}; + return memcmp(data, vorbis, 6) == 0; } // called from setup only, once per code book // (formula implied by specification) -static int lookup1_values(int entries, int dim) -{ - int r = (int) floor(exp((float) log((float) entries) / dim)); - if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; - ++r; // floor() to avoid _ftol() when non-CRT - if (pow((float) r+1, dim) <= entries) - return -1; - if ((int) floor(pow((float) r, dim)) > entries) - return -1; - return r; +static int lookup1_values(int entries, int dim) { + int r = (int) floor(exp((float) log((float) entries) / dim)); + if ((int) floor(pow((float) r + 1, dim)) <= entries) // (int) cast for MinGW warning; + ++r; // floor() to avoid _ftol() when non-CRT + if (pow((float) r + 1, dim) <= entries) + return -1; + if ((int) floor(pow((float) r, dim)) > entries) + return -1; + return r; } // called twice per file -static void compute_twiddle_factors(int n, float *A, float *B, float *C) -{ - int n4 = n >> 2, n8 = n >> 3; - int k,k2; - - for (k=k2=0; k < n4; ++k,k2+=2) { - A[k2 ] = (float) cos(4*k*M_PI/n); - A[k2+1] = (float) -sin(4*k*M_PI/n); - B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; - B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; - } - for (k=k2=0; k < n8; ++k,k2+=2) { - C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); - C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); - } +static void compute_twiddle_factors(int n, float *A, float *B, float *C) { + int n4 = n >> 2, n8 = n >> 3; + int k, k2; + + for (k = k2 = 0; k < n4; ++k, k2 += 2) { + A[k2] = (float) cos(4 * k * M_PI / n); + A[k2 + 1] = (float) -sin(4 * k * M_PI / n); + B[k2] = (float) cos((k2 + 1) * M_PI / n / 2) * 0.5f; + B[k2 + 1] = (float) sin((k2 + 1) * M_PI / n / 2) * 0.5f; + } + for (k = k2 = 0; k < n8; ++k, k2 += 2) { + C[k2] = (float) cos(2 * (k2 + 1) * M_PI / n); + C[k2 + 1] = (float) -sin(2 * (k2 + 1) * M_PI / n); + } } -static void compute_window(int n, float *window) -{ - int n2 = n >> 1, i; - for (i=0; i < n2; ++i) - window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); +static void compute_window(int n, float *window) { + int n2 = n >> 1, i; + for (i = 0; i < n2; ++i) + window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); } -static void compute_bitreverse(int n, uint16 *rev) -{ - int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - int i, n8 = n >> 3; - for (i=0; i < n8; ++i) - rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; +static void compute_bitreverse(int n, uint16 *rev) { + int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + int i, n8 = n >> 3; + for (i = 0; i < n8; ++i) + rev[i] = (bit_reverse(i) >> (32 - ld + 3)) << 2; } -static int init_blocksize(vorb *f, int b, int n) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; - f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); - if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); - compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); - f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); - if (!f->window[b]) return error(f, VORBIS_outofmem); - compute_window(n, f->window[b]); - f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); - if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); - compute_bitreverse(n, f->bit_reverse[b]); - return TRUE; +static int init_blocksize(vorb *f, int b, int n) { + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; + f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); + f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); + f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); + if (!f->A[b] || !f->B[b] || !f->C[b]) + return error(f, VORBIS_outofmem); + compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); + f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); + if (!f->window[b]) + return error(f, VORBIS_outofmem); + compute_window(n, f->window[b]); + f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); + if (!f->bit_reverse[b]) + return error(f, VORBIS_outofmem); + compute_bitreverse(n, f->bit_reverse[b]); + return TRUE; } -static void neighbors(uint16 *x, int n, int *plow, int *phigh) -{ - int low = -1; - int high = 65536; - int i; - for (i=0; i < n; ++i) { - if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } - if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } - } +static void neighbors(uint16 *x, int n, int *plow, int *phigh) { + int low = -1; + int high = 65536; + int i; + for (i = 0; i < n; ++i) { + if (x[i] > low && x[i] < x[n]) { + *plow = i; + low = x[i]; + } + if (x[i] < high && x[i] > x[n]) { + *phigh = i; + high = x[i]; + } + } } // this has been repurposed so y is now the original index instead of y -typedef struct -{ - uint16 x,id; +typedef struct { + uint16 x, id; } stbv__floor_ordering; -static int STBV_CDECL point_compare(const void *p, const void *q) -{ - stbv__floor_ordering *a = (stbv__floor_ordering *) p; - stbv__floor_ordering *b = (stbv__floor_ordering *) q; - return a->x < b->x ? -1 : a->x > b->x; +static int STBV_CDECL point_compare(const void *p, const void *q) { + stbv__floor_ordering *a = (stbv__floor_ordering *) p; + stbv__floor_ordering *b = (stbv__floor_ordering *) q; + return a->x < b->x ? -1 : a->x > b->x; } // @@ -1329,392 +1320,410 @@ static int STBV_CDECL point_compare(const void *p, const void *q) #if defined(STB_VORBIS_NO_STDIO) - #define USE_MEMORY(z) TRUE + #define USE_MEMORY(z) TRUE #else - #define USE_MEMORY(z) ((z)->stream) + #define USE_MEMORY(z) ((z)->stream) #endif -static uint8 get8(vorb *z) -{ - if (USE_MEMORY(z)) { - if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } - return *z->stream++; - } - - #ifndef STB_VORBIS_NO_STDIO - { - int c = fgetc(z->f); - if (c == EOF) { z->eof = TRUE; return 0; } - return c; - } - #endif +static uint8 get8(vorb *z) { + if (USE_MEMORY(z)) { + if (z->stream >= z->stream_end) { + z->eof = TRUE; + return 0; + } + return *z->stream++; + } + + #ifndef STB_VORBIS_NO_STDIO + { + int c = fgetc(z->f); + if (c == EOF) { + z->eof = TRUE; + return 0; + } + return c; + } + #endif } -static uint32 get32(vorb *f) -{ - uint32 x; - x = get8(f); - x += get8(f) << 8; - x += get8(f) << 16; - x += (uint32) get8(f) << 24; - return x; +static uint32 get32(vorb *f) { + uint32 x; + x = get8(f); + x += get8(f) << 8; + x += get8(f) << 16; + x += (uint32) get8(f) << 24; + return x; } -static int getn(vorb *z, uint8 *data, int n) -{ - if (USE_MEMORY(z)) { - if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } - memcpy(data, z->stream, n); - z->stream += n; - return 1; - } - - #ifndef STB_VORBIS_NO_STDIO - if (fread(data, n, 1, z->f) == 1) - return 1; - else { - z->eof = 1; - return 0; - } - #endif +static int getn(vorb *z, uint8 *data, int n) { + if (USE_MEMORY(z)) { + if (z->stream + n > z->stream_end) { + z->eof = 1; + return 0; + } + memcpy(data, z->stream, n); + z->stream += n; + return 1; + } + + #ifndef STB_VORBIS_NO_STDIO + if (fread(data, n, 1, z->f) == 1) + return 1; + else { + z->eof = 1; + return 0; + } + #endif } -static void skip(vorb *z, int n) -{ - if (USE_MEMORY(z)) { - z->stream += n; - if (z->stream >= z->stream_end) z->eof = 1; - return; - } - #ifndef STB_VORBIS_NO_STDIO - { - long x = ftell(z->f); - fseek(z->f, x+n, SEEK_SET); - } - #endif +static void skip(vorb *z, int n) { + if (USE_MEMORY(z)) { + z->stream += n; + if (z->stream >= z->stream_end) + z->eof = 1; + return; + } + #ifndef STB_VORBIS_NO_STDIO + { + long x = ftell(z->f); + fseek(z->f, x + n, SEEK_SET); + } + #endif } -static int set_file_offset(stb_vorbis *f, unsigned int loc) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - f->eof = 0; - if (USE_MEMORY(f)) { - if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { - f->stream = f->stream_end; - f->eof = 1; - return 0; - } else { - f->stream = f->stream_start + loc; - return 1; - } - } - #ifndef STB_VORBIS_NO_STDIO - if (loc + f->f_start < loc || loc >= 0x80000000) { - loc = 0x7fffffff; - f->eof = 1; - } else { - loc += f->f_start; - } - if (!fseek(f->f, loc, SEEK_SET)) - return 1; - f->eof = 1; - fseek(f->f, f->f_start, SEEK_END); - return 0; - #endif +static int set_file_offset(stb_vorbis *f, unsigned int loc) { + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (f->push_mode) + return 0; + #endif + f->eof = 0; + if (USE_MEMORY(f)) { + if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { + f->stream = f->stream_end; + f->eof = 1; + return 0; + } else { + f->stream = f->stream_start + loc; + return 1; + } + } + #ifndef STB_VORBIS_NO_STDIO + if (loc + f->f_start < loc || loc >= 0x80000000) { + loc = 0x7fffffff; + f->eof = 1; + } else { + loc += f->f_start; + } + if (!fseek(f->f, loc, SEEK_SET)) + return 1; + f->eof = 1; + fseek(f->f, f->f_start, SEEK_END); + return 0; + #endif } - -static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; - -static int capture_pattern(vorb *f) -{ - if (0x4f != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x53 != get8(f)) return FALSE; - return TRUE; +static uint8 ogg_page_header[4] = {0x4f, 0x67, 0x67, 0x53}; + +static int capture_pattern(vorb *f) { + if (0x4f != get8(f)) + return FALSE; + if (0x67 != get8(f)) + return FALSE; + if (0x67 != get8(f)) + return FALSE; + if (0x53 != get8(f)) + return FALSE; + return TRUE; } #define PAGEFLAG_continued_packet 1 #define PAGEFLAG_first_page 2 #define PAGEFLAG_last_page 4 -static int start_page_no_capturepattern(vorb *f) -{ - uint32 loc0,loc1,n; - if (f->first_decode && !IS_PUSH_MODE(f)) { - f->p_first.page_start = stb_vorbis_get_file_offset(f) - 4; - } - // stream structure version - if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); - // header flag - f->page_flag = get8(f); - // absolute granule position - loc0 = get32(f); - loc1 = get32(f); - // @TODO: validate loc0,loc1 as valid positions? - // stream serial number -- vorbis doesn't interleave, so discard - get32(f); - //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); - // page sequence number - n = get32(f); - f->last_page = n; - // CRC32 - get32(f); - // page_segments - f->segment_count = get8(f); - if (!getn(f, f->segments, f->segment_count)) - return error(f, VORBIS_unexpected_eof); - // assume we _don't_ know any the sample position of any segments - f->end_seg_with_known_loc = -2; - if (loc0 != ~0U || loc1 != ~0U) { - int i; - // determine which packet is the last one that will complete - for (i=f->segment_count-1; i >= 0; --i) - if (f->segments[i] < 255) - break; - // 'i' is now the index of the _last_ segment of a packet that ends - if (i >= 0) { - f->end_seg_with_known_loc = i; - f->known_loc_for_packet = loc0; - } - } - if (f->first_decode) { - int i,len; - len = 0; - for (i=0; i < f->segment_count; ++i) - len += f->segments[i]; - len += 27 + f->segment_count; - f->p_first.page_end = f->p_first.page_start + len; - f->p_first.last_decoded_sample = loc0; - } - f->next_seg = 0; - return TRUE; +static int start_page_no_capturepattern(vorb *f) { + uint32 loc0, loc1, n; + if (f->first_decode && !IS_PUSH_MODE(f)) { + f->p_first.page_start = stb_vorbis_get_file_offset(f) - 4; + } + // stream structure version + if (0 != get8(f)) + return error(f, VORBIS_invalid_stream_structure_version); + // header flag + f->page_flag = get8(f); + // absolute granule position + loc0 = get32(f); + loc1 = get32(f); + // @TODO: validate loc0,loc1 as valid positions? + // stream serial number -- vorbis doesn't interleave, so discard + get32(f); + //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); + // page sequence number + n = get32(f); + f->last_page = n; + // CRC32 + get32(f); + // page_segments + f->segment_count = get8(f); + if (!getn(f, f->segments, f->segment_count)) + return error(f, VORBIS_unexpected_eof); + // assume we _don't_ know any the sample position of any segments + f->end_seg_with_known_loc = -2; + if (loc0 != ~0U || loc1 != ~0U) { + int i; + // determine which packet is the last one that will complete + for (i = f->segment_count - 1; i >= 0; --i) + if (f->segments[i] < 255) + break; + // 'i' is now the index of the _last_ segment of a packet that ends + if (i >= 0) { + f->end_seg_with_known_loc = i; + f->known_loc_for_packet = loc0; + } + } + if (f->first_decode) { + int i, len; + len = 0; + for (i = 0; i < f->segment_count; ++i) + len += f->segments[i]; + len += 27 + f->segment_count; + f->p_first.page_end = f->p_first.page_start + len; + f->p_first.last_decoded_sample = loc0; + } + f->next_seg = 0; + return TRUE; } -static int start_page(vorb *f) -{ - if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); - return start_page_no_capturepattern(f); +static int start_page(vorb *f) { + if (!capture_pattern(f)) + return error(f, VORBIS_missing_capture_pattern); + return start_page_no_capturepattern(f); } -static int start_packet(vorb *f) -{ - while (f->next_seg == -1) { - if (!start_page(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) - return error(f, VORBIS_continued_packet_flag_invalid); - } - f->last_seg = FALSE; - f->valid_bits = 0; - f->packet_bytes = 0; - f->bytes_in_seg = 0; - // f->next_seg is now valid - return TRUE; +static int start_packet(vorb *f) { + while (f->next_seg == -1) { + if (!start_page(f)) + return FALSE; + if (f->page_flag & PAGEFLAG_continued_packet) + return error(f, VORBIS_continued_packet_flag_invalid); + } + f->last_seg = FALSE; + f->valid_bits = 0; + f->packet_bytes = 0; + f->bytes_in_seg = 0; + // f->next_seg is now valid + return TRUE; } -static int maybe_start_packet(vorb *f) -{ - if (f->next_seg == -1) { - int x = get8(f); - if (f->eof) return FALSE; // EOF at page boundary is not an error! - if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (!start_page_no_capturepattern(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) { - // set up enough state that we can read this packet if we want, - // e.g. during recovery - f->last_seg = FALSE; - f->bytes_in_seg = 0; - return error(f, VORBIS_continued_packet_flag_invalid); - } - } - return start_packet(f); +static int maybe_start_packet(vorb *f) { + if (f->next_seg == -1) { + int x = get8(f); + if (f->eof) + return FALSE; // EOF at page boundary is not an error! + if (0x4f != x) + return error(f, VORBIS_missing_capture_pattern); + if (0x67 != get8(f)) + return error(f, VORBIS_missing_capture_pattern); + if (0x67 != get8(f)) + return error(f, VORBIS_missing_capture_pattern); + if (0x53 != get8(f)) + return error(f, VORBIS_missing_capture_pattern); + if (!start_page_no_capturepattern(f)) + return FALSE; + if (f->page_flag & PAGEFLAG_continued_packet) { + // set up enough state that we can read this packet if we want, + // e.g. during recovery + f->last_seg = FALSE; + f->bytes_in_seg = 0; + return error(f, VORBIS_continued_packet_flag_invalid); + } + } + return start_packet(f); } -static int next_segment(vorb *f) -{ - int len; - if (f->last_seg) return 0; - if (f->next_seg == -1) { - f->last_seg_which = f->segment_count-1; // in case start_page fails - if (!start_page(f)) { f->last_seg = 1; return 0; } - if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); - } - len = f->segments[f->next_seg++]; - if (len < 255) { - f->last_seg = TRUE; - f->last_seg_which = f->next_seg-1; - } - if (f->next_seg >= f->segment_count) - f->next_seg = -1; - assert(f->bytes_in_seg == 0); - f->bytes_in_seg = len; - return len; +static int next_segment(vorb *f) { + int len; + if (f->last_seg) + return 0; + if (f->next_seg == -1) { + f->last_seg_which = f->segment_count - 1; // in case start_page fails + if (!start_page(f)) { + f->last_seg = 1; + return 0; + } + if (!(f->page_flag & PAGEFLAG_continued_packet)) + return error(f, VORBIS_continued_packet_flag_invalid); + } + len = f->segments[f->next_seg++]; + if (len < 255) { + f->last_seg = TRUE; + f->last_seg_which = f->next_seg - 1; + } + if (f->next_seg >= f->segment_count) + f->next_seg = -1; + assert(f->bytes_in_seg == 0); + f->bytes_in_seg = len; + return len; } #define EOP (-1) #define INVALID_BITS (-1) -static int get8_packet_raw(vorb *f) -{ - if (!f->bytes_in_seg) { // CLANG! - if (f->last_seg) return EOP; - else if (!next_segment(f)) return EOP; - } - assert(f->bytes_in_seg > 0); - --f->bytes_in_seg; - ++f->packet_bytes; - return get8(f); +static int get8_packet_raw(vorb *f) { + if (!f->bytes_in_seg) { // CLANG! + if (f->last_seg) + return EOP; + else if (!next_segment(f)) + return EOP; + } + assert(f->bytes_in_seg > 0); + --f->bytes_in_seg; + ++f->packet_bytes; + return get8(f); } -static int get8_packet(vorb *f) -{ - int x = get8_packet_raw(f); - f->valid_bits = 0; - return x; +static int get8_packet(vorb *f) { + int x = get8_packet_raw(f); + f->valid_bits = 0; + return x; } -static int get32_packet(vorb *f) -{ - uint32 x; - x = get8_packet(f); - x += get8_packet(f) << 8; - x += get8_packet(f) << 16; - x += (uint32) get8_packet(f) << 24; - return x; +static int get32_packet(vorb *f) { + uint32 x; + x = get8_packet(f); + x += get8_packet(f) << 8; + x += get8_packet(f) << 16; + x += (uint32) get8_packet(f) << 24; + return x; } -static void flush_packet(vorb *f) -{ - while (get8_packet_raw(f) != EOP); +static void flush_packet(vorb *f) { + while (get8_packet_raw(f) != EOP); } // @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important // as the huffman decoder? -static uint32 get_bits(vorb *f, int n) -{ - uint32 z; - - if (f->valid_bits < 0) return 0; - if (f->valid_bits < n) { - if (n > 24) { - // the accumulator technique below would not work correctly in this case - z = get_bits(f, 24); - z += get_bits(f, n-24) << 24; - return z; - } - if (f->valid_bits == 0) f->acc = 0; - while (f->valid_bits < n) { - int z = get8_packet_raw(f); - if (z == EOP) { - f->valid_bits = INVALID_BITS; - return 0; - } - f->acc += z << f->valid_bits; - f->valid_bits += 8; - } - } - - assert(f->valid_bits >= n); - z = f->acc & ((1 << n)-1); - f->acc >>= n; - f->valid_bits -= n; - return z; +static uint32 get_bits(vorb *f, int n) { + uint32 z; + + if (f->valid_bits < 0) + return 0; + if (f->valid_bits < n) { + if (n > 24) { + // the accumulator technique below would not work correctly in this case + z = get_bits(f, 24); + z += get_bits(f, n - 24) << 24; + return z; + } + if (f->valid_bits == 0) + f->acc = 0; + while (f->valid_bits < n) { + int z = get8_packet_raw(f); + if (z == EOP) { + f->valid_bits = INVALID_BITS; + return 0; + } + f->acc += z << f->valid_bits; + f->valid_bits += 8; + } + } + + assert(f->valid_bits >= n); + z = f->acc & ((1 << n) - 1); + f->acc >>= n; + f->valid_bits -= n; + return z; } // @OPTIMIZE: primary accumulator for huffman // expand the buffer to as many bits as possible without reading off end of packet // it might be nice to allow f->valid_bits and f->acc to be stored in registers, // e.g. cache them locally and decode locally -static __forceinline void prep_huffman(vorb *f) -{ - if (f->valid_bits <= 24) { - if (f->valid_bits == 0) f->acc = 0; - do { - int z; - if (f->last_seg && !f->bytes_in_seg) return; - z = get8_packet_raw(f); - if (z == EOP) return; - f->acc += (unsigned) z << f->valid_bits; - f->valid_bits += 8; - } while (f->valid_bits <= 24); - } +static __forceinline void prep_huffman(vorb *f) { + if (f->valid_bits <= 24) { + if (f->valid_bits == 0) + f->acc = 0; + do { + int z; + if (f->last_seg && !f->bytes_in_seg) + return; + z = get8_packet_raw(f); + if (z == EOP) + return; + f->acc += (unsigned) z << f->valid_bits; + f->valid_bits += 8; + } while (f->valid_bits <= 24); + } } -enum -{ - VORBIS_packet_id = 1, - VORBIS_packet_comment = 3, - VORBIS_packet_setup = 5 +enum { + VORBIS_packet_id = 1, + VORBIS_packet_comment = 3, + VORBIS_packet_setup = 5 }; -static int codebook_decode_scalar_raw(vorb *f, Codebook *c) -{ - int i; - prep_huffman(f); - - if (c->codewords == NULL && c->sorted_codewords == NULL) - return -1; - - // cases to use binary search: sorted_codewords && !c->codewords - // sorted_codewords && c->entries > 8 - if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { - // binary search - uint32 code = bit_reverse(f->acc); - int x=0, n=c->sorted_entries, len; - - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - // x is now the sorted index - if (!c->sparse) x = c->sorted_values[x]; - // x is now sorted index if sparse, or symbol otherwise - len = c->codeword_lengths[x]; - if (f->valid_bits >= len) { - f->acc >>= len; - f->valid_bits -= len; - return x; - } - - f->valid_bits = 0; - return -1; - } - - // if small, linear search - assert(!c->sparse); - for (i=0; i < c->entries; ++i) { - if (c->codeword_lengths[i] == NO_CODE) continue; - if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { - if (f->valid_bits >= c->codeword_lengths[i]) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - return i; - } - f->valid_bits = 0; - return -1; - } - } - - error(f, VORBIS_invalid_stream); - f->valid_bits = 0; - return -1; +static int codebook_decode_scalar_raw(vorb *f, Codebook *c) { + int i; + prep_huffman(f); + + if (c->codewords == NULL && c->sorted_codewords == NULL) + return -1; + + // cases to use binary search: sorted_codewords && !c->codewords + // sorted_codewords && c->entries > 8 + if (c->entries > 8 ? c->sorted_codewords != NULL : !c->codewords) { + // binary search + uint32 code = bit_reverse(f->acc); + int x = 0, n = c->sorted_entries, len; + + while (n > 1) { + // invariant: sc[x] <= code < sc[x+n] + int m = x + (n >> 1); + if (c->sorted_codewords[m] <= code) { + x = m; + n -= (n >> 1); + } else { + n >>= 1; + } + } + // x is now the sorted index + if (!c->sparse) + x = c->sorted_values[x]; + // x is now sorted index if sparse, or symbol otherwise + len = c->codeword_lengths[x]; + if (f->valid_bits >= len) { + f->acc >>= len; + f->valid_bits -= len; + return x; + } + + f->valid_bits = 0; + return -1; + } + + // if small, linear search + assert(!c->sparse); + for (i = 0; i < c->entries; ++i) { + if (c->codeword_lengths[i] == NO_CODE) + continue; + if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i]) - 1))) { + if (f->valid_bits >= c->codeword_lengths[i]) { + f->acc >>= c->codeword_lengths[i]; + f->valid_bits -= c->codeword_lengths[i]; + return i; + } + f->valid_bits = 0; + return -1; + } + } + + error(f, VORBIS_invalid_stream); + f->valid_bits = 0; + return -1; } #ifndef STB_VORBIS_NO_INLINE_DECODE -#define DECODE_RAW(var, f,c) \ +#define DECODE_RAW(var, f, c) \ if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ prep_huffman(f); \ var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ @@ -1730,7 +1739,7 @@ static int codebook_decode_scalar_raw(vorb *f, Codebook *c) #else -static int codebook_decode_scalar(vorb *f, Codebook *c) + static int codebook_decode_scalar(vorb *f, Codebook *c) { int i; if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) @@ -1751,14 +1760,14 @@ static int codebook_decode_scalar(vorb *f, Codebook *c) #endif -#define DECODE(var,f,c) \ +#define DECODE(var, f, c) \ DECODE_RAW(var,f,c) \ if (c->sparse) var = c->sorted_values[var]; #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) + #define DECODE_VQ(var, f, c) DECODE_RAW(var,f,c) #else - #define DECODE_VQ(var,f,c) DECODE(var,f,c) + #define DECODE_VQ(var,f,c) DECODE(var,f,c) #endif @@ -1768,38 +1777,39 @@ static int codebook_decode_scalar(vorb *f, Codebook *c) // CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case // where we avoid one addition -#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) -#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) +#define CODEBOOK_ELEMENT(c, off) (c->multiplicands[off]) +#define CODEBOOK_ELEMENT_FAST(c, off) (c->multiplicands[off]) #define CODEBOOK_ELEMENT_BASE(c) (0) -static int codebook_decode_start(vorb *f, Codebook *c) -{ - int z = -1; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) - error(f, VORBIS_invalid_stream); - else { - DECODE_VQ(z,f,c); - if (c->sparse) assert(z < c->sorted_entries); - if (z < 0) { // check for EOP - if (!f->bytes_in_seg) - if (f->last_seg) - return z; - error(f, VORBIS_invalid_stream); - } - } - return z; +static int codebook_decode_start(vorb *f, Codebook *c) { + int z = -1; + + // type 0 is only legal in a scalar context + if (c->lookup_type == 0) + error(f, VORBIS_invalid_stream); + else { + DECODE_VQ(z, f, c); + if (c->sparse) + assert(z < c->sorted_entries); + if (z < 0) { // check for EOP + if (!f->bytes_in_seg) + if (f->last_seg) + return z; + error(f, VORBIS_invalid_stream); + } + } + return z; } -static int codebook_decode(vorb *f, Codebook *c, float *output, int len) -{ - int i,z = codebook_decode_start(f,c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; +static int codebook_decode(vorb *f, Codebook *c, float *output, int len) { + int i, z = codebook_decode_start(f, c); + if (z < 0) + return FALSE; + if (len > c->dimensions) + len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { + if (c->lookup_type == 1) { float last = CODEBOOK_ELEMENT_BASE(c); int div = 1; for (i=0; i < len; ++i) { @@ -1813,33 +1823,34 @@ static int codebook_decode(vorb *f, Codebook *c, float *output, int len) } #endif - z *= c->dimensions; - if (c->sequence_p) { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i] += val; - last = val + c->minimum_value; - } - } else { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; - } - } - - return TRUE; + z *= c->dimensions; + if (c->sequence_p) { + float last = CODEBOOK_ELEMENT_BASE(c); + for (i = 0; i < len; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c, z + i) + last; + output[i] += val; + last = val + c->minimum_value; + } + } else { + float last = CODEBOOK_ELEMENT_BASE(c); + for (i = 0; i < len; ++i) { + output[i] += CODEBOOK_ELEMENT_FAST(c, z + i) + last; + } + } + + return TRUE; } -static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) -{ - int i,z = codebook_decode_start(f,c); - float last = CODEBOOK_ELEMENT_BASE(c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; +static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) { + int i, z = codebook_decode_start(f, c); + float last = CODEBOOK_ELEMENT_BASE(c); + if (z < 0) + return FALSE; + if (len > c->dimensions) + len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { + if (c->lookup_type == 1) { int div = 1; for (i=0; i < len; ++i) { int off = (z / div) % c->lookup_values; @@ -1852,47 +1863,56 @@ static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, in } #endif - z *= c->dimensions; - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i*step] += val; - if (c->sequence_p) last = val; - } + z *= c->dimensions; + for (i = 0; i < len; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c, z + i) + last; + output[i * step] += val; + if (c->sequence_p) + last = val; + } - return TRUE; + return TRUE; } -static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) -{ - int c_inter = *c_inter_p; - int p_inter = *p_inter_p; - int i,z, effective = c->dimensions; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); - - while (total_decode > 0) { - float last = CODEBOOK_ELEMENT_BASE(c); - DECODE_VQ(z,f,c); - #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - assert(!c->sparse || z < c->sorted_entries); - #endif - if (z < 0) { - if (!f->bytes_in_seg) - if (f->last_seg) return FALSE; - return error(f, VORBIS_invalid_stream); - } - - // if this will take us off the end of the buffers, stop short! - // we check by computing the length of the virtual interleaved - // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), - // and the length we'll be using (effective) - if (c_inter + p_inter*ch + effective > len * ch) { - effective = len*ch - (p_inter*ch - c_inter); - } - - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { +static int codebook_decode_deinterleave_repeat(vorb *f, + Codebook *c, + float **outputs, + int ch, + int *c_inter_p, + int *p_inter_p, + int len, + int total_decode) { + int c_inter = *c_inter_p; + int p_inter = *p_inter_p; + int i, z, effective = c->dimensions; + + // type 0 is only legal in a scalar context + if (c->lookup_type == 0) + return error(f, VORBIS_invalid_stream); + + while (total_decode > 0) { + float last = CODEBOOK_ELEMENT_BASE(c); + DECODE_VQ(z, f, c); + #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK + assert(!c->sparse || z < c->sorted_entries); + #endif + if (z < 0) { + if (!f->bytes_in_seg) + if (f->last_seg) + return FALSE; + return error(f, VORBIS_invalid_stream); + } + + // if this will take us off the end of the buffers, stop short! + // we check by computing the length of the virtual interleaved + // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), + // and the length we'll be using (effective) + if (c_inter + p_inter * ch + effective > len * ch) { + effective = len * ch - (p_inter * ch - c_inter); + } + + #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (c->lookup_type == 1) { int div = 1; for (i=0; i < effective; ++i) { int off = (z / div) % c->lookup_values; @@ -1904,112 +1924,117 @@ static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **out div *= c->lookup_values; } } else - #endif - { - z *= c->dimensions; - if (c->sequence_p) { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - last = val; - } - } else { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - } - } - } - - total_decode -= effective; - } - *c_inter_p = c_inter; - *p_inter_p = p_inter; - return TRUE; + #endif + { + z *= c->dimensions; + if (c->sequence_p) { + for (i = 0; i < effective; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c, z + i) + last; + if (outputs[c_inter]) + outputs[c_inter][p_inter] += val; + if (++c_inter == ch) { + c_inter = 0; + ++p_inter; + } + last = val; + } + } else { + for (i = 0; i < effective; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c, z + i) + last; + if (outputs[c_inter]) + outputs[c_inter][p_inter] += val; + if (++c_inter == ch) { + c_inter = 0; + ++p_inter; + } + } + } + } + + total_decode -= effective; + } + *c_inter_p = c_inter; + *p_inter_p = p_inter; + return TRUE; } -static int predict_point(int x, int x0, int x1, int y0, int y1) -{ - int dy = y1 - y0; - int adx = x1 - x0; - // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? - int err = abs(dy) * (x - x0); - int off = err / adx; - return dy < 0 ? y0 - off : y0 + off; +static int predict_point(int x, int x0, int x1, int y0, int y1) { + int dy = y1 - y0; + int adx = x1 - x0; + // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? + int err = abs(dy) * (x - x0); + int off = err / adx; + return dy < 0 ? y0 - off : y0 + off; } // the following table is block-copied from the specification static float inverse_db_table[256] = -{ - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, - 0.82788260f, 0.88168307f, 0.9389798f, 1.0f -}; + { + 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, + 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, + 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, + 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, + 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, + 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, + 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, + 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, + 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, + 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, + 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, + 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, + 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, + 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, + 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, + 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, + 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, + 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, + 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, + 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, + 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, + 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, + 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, + 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, + 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, + 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, + 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, + 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, + 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, + 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, + 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, + 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, + 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, + 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, + 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, + 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, + 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, + 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, + 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, + 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, + 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, + 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, + 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, + 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, + 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, + 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, + 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, + 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, + 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, + 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, + 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, + 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, + 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, + 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, + 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, + 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, + 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, + 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, + 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, + 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, + 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, + 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, + 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, + 0.82788260f, 0.88168307f, 0.9389798f, 1.0f + }; // @OPTIMIZE: if you want to replace this bresenham line-drawing routine, @@ -2020,29 +2045,28 @@ static float inverse_db_table[256] = // ... also, isn't the whole point of Bresenham's algorithm to NOT // have to divide in the setup? sigh. #ifndef STB_VORBIS_NO_DEFER_FLOOR -#define LINE_OP(a,b) a *= b +#define LINE_OP(a, b) a *= b #else #define LINE_OP(a,b) a = b #endif #ifdef STB_VORBIS_DIVIDE_TABLE -#define DIVTAB_NUMER 32 + #define DIVTAB_NUMER 32 #define DIVTAB_DENOM 64 int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB #endif -static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) -{ - int dy = y1 - y0; - int adx = x1 - x0; - int ady = abs(dy); - int base; - int x=x0,y=y0; - int err = 0; - int sy; +static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) { + int dy = y1 - y0; + int adx = x1 - x0; + int ady = abs(dy); + int base; + int x = x0, y = y0; + int err = 0; + int sy; #ifdef STB_VORBIS_DIVIDE_TABLE - if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { + if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { if (dy < 0) { base = -integer_divide_table[ady][adx]; sy = base-1; @@ -2058,234 +2082,249 @@ static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y sy = base+1; } #else - base = dy / adx; - if (dy < 0) - sy = base - 1; - else - sy = base+1; + base = dy / adx; + if (dy < 0) + sy = base - 1; + else + sy = base + 1; #endif - ady -= abs(base) * adx; - if (x1 > n) x1 = n; - if (x < x1) { - LINE_OP(output[x], inverse_db_table[y&255]); - for (++x; x < x1; ++x) { - err += ady; - if (err >= adx) { - err -= adx; - y += sy; - } else - y += base; - LINE_OP(output[x], inverse_db_table[y&255]); - } - } + ady -= abs(base) * adx; + if (x1 > n) + x1 = n; + if (x < x1) { + LINE_OP(output[x], inverse_db_table[y & 255]); + for (++x; x < x1; ++x) { + err += ady; + if (err >= adx) { + err -= adx; + y += sy; + } else + y += base; + LINE_OP(output[x], inverse_db_table[y & 255]); + } + } } -static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) -{ - int k; - if (rtype == 0) { - int step = n / book->dimensions; - for (k=0; k < step; ++k) - if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) - return FALSE; - } else { - for (k=0; k < n; ) { - if (!codebook_decode(f, book, target+offset, n-k)) - return FALSE; - k += book->dimensions; - offset += book->dimensions; - } - } - return TRUE; +static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) { + int k; + if (rtype == 0) { + int step = n / book->dimensions; + for (k = 0; k < step; ++k) + if (!codebook_decode_step(f, book, target + offset + k, n - offset - k, step)) + return FALSE; + } else { + for (k = 0; k < n;) { + if (!codebook_decode(f, book, target + offset, n - k)) + return FALSE; + k += book->dimensions; + offset += book->dimensions; + } + } + return TRUE; } // n is 1/2 of the blocksize -- // specification: "Correct per-vector decode length is [n]/2" -static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) -{ - int i,j,pass; - Residue *r = f->residue_config + rn; - int rtype = f->residue_types[rn]; - int c = r->classbook; - int classwords = f->codebooks[c].dimensions; - unsigned int actual_size = rtype == 2 ? n*2 : n; - unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size); - unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size); - int n_read = limit_r_end - limit_r_begin; - int part_read = n_read / r->part_size; - int temp_alloc_point = temp_alloc_save(f); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); - #else - int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); - #endif - - CHECK(f); - - for (i=0; i < ch; ++i) - if (!do_not_decode[i]) - memset(residue_buffers[i], 0, sizeof(float) * n); - - if (rtype == 2 && ch != 1) { - for (j=0; j < ch; ++j) - if (!do_not_decode[j]) - break; - if (j == ch) - goto done; - - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set = 0; - if (ch == 2) { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = (z & 1), p_inter = z>>1; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { +static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) { + int i, j, pass; + Residue *r = f->residue_config + rn; + int rtype = f->residue_types[rn]; + int c = r->classbook; + int classwords = f->codebooks[c].dimensions; + unsigned int actual_size = rtype == 2 ? n * 2 : n; + unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size); + unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size); + int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + int temp_alloc_point = temp_alloc_save(f); + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + uint8 ***part_classdata = (uint8 ***) temp_block_array(f, f->channels, part_read * sizeof(**part_classdata)); + #else + int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); + #endif + + CHECK(f); + + for (i = 0; i < ch; ++i) + if (!do_not_decode[i]) + memset(residue_buffers[i], 0, sizeof(float) * n); + + if (rtype == 2 && ch != 1) { + for (j = 0; j < ch; ++j) + if (!do_not_decode[j]) + break; + if (j == ch) + goto done; + + for (pass = 0; pass < 8; ++pass) { + int pcount = 0, class_set = 0; + if (ch == 2) { + while (pcount < part_read) { + int z = r->begin + pcount * r->part_size; + int c_inter = (z & 1), p_inter = z >> 1; + if (pass == 0) { + Codebook *c = f->codebooks + r->classbook; + int q; + DECODE(q, f, c); + if (q == EOP) + goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[0][class_set] = r->classdata[q]; + #else + for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - #else - // saves 1% - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) + #endif + } + for (i = 0; i < classwords && pcount < part_read; ++i, ++pcount) { + int z = r->begin + pcount * r->part_size; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[0][class_set][i]; + #else + int c = classifications[0][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + Codebook *book = f->codebooks + b; + #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; - #endif - } else { - z += r->part_size; - c_inter = z & 1; - p_inter = z >> 1; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else if (ch > 2) { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = z % ch, p_inter = z/ch; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { + #else + // saves 1% + if (!codebook_decode_deinterleave_repeat(f, + book, + residue_buffers, + ch, + &c_inter, + &p_inter, + n, + r->part_size)) + goto done; + #endif + } else { + z += r->part_size; + c_inter = z & 1; + p_inter = z >> 1; + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } else if (ch > 2) { + while (pcount < part_read) { + int z = r->begin + pcount * r->part_size; + int c_inter = z % ch, p_inter = z / ch; + if (pass == 0) { + Codebook *c = f->codebooks + r->classbook; + int q; + DECODE(q, f, c); + if (q == EOP) + goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[0][class_set] = r->classdata[q]; + #else + for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - } else { - z += r->part_size; - c_inter = z % ch; - p_inter = z / ch; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - } - goto done; - } - CHECK(f); - - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set=0; - while (pcount < part_read) { - if (pass == 0) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - Codebook *c = f->codebooks+r->classbook; - int temp; - DECODE(temp,f,c); - if (temp == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[j][class_set] = r->classdata[temp]; - #else - for (i=classwords-1; i >= 0; --i) { + #endif + } + for (i = 0; i < classwords && pcount < part_read; ++i, ++pcount) { + int z = r->begin + pcount * r->part_size; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[0][class_set][i]; + #else + int c = classifications[0][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + Codebook *book = f->codebooks + b; + if (!codebook_decode_deinterleave_repeat(f, + book, + residue_buffers, + ch, + &c_inter, + &p_inter, + n, + r->part_size)) + goto done; + } else { + z += r->part_size; + c_inter = z % ch; + p_inter = z / ch; + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } + } + goto done; + } + CHECK(f); + + for (pass = 0; pass < 8; ++pass) { + int pcount = 0, class_set = 0; + while (pcount < part_read) { + if (pass == 0) { + for (j = 0; j < ch; ++j) { + if (!do_not_decode[j]) { + Codebook *c = f->codebooks + r->classbook; + int temp; + DECODE(temp, f, c); + if (temp == EOP) + goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[j][class_set] = r->classdata[temp]; + #else + for (i=classwords-1; i >= 0; --i) { classifications[j][i+pcount] = temp % r->classifications; temp /= r->classifications; } - #endif - } - } - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[j][class_set][i]; - #else - int c = classifications[j][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - float *target = residue_buffers[j]; - int offset = r->begin + pcount * r->part_size; - int n = r->part_size; - Codebook *book = f->codebooks + b; - if (!residue_decode(f, book, target, offset, n, rtype)) - goto done; - } - } - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - done: - CHECK(f); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - temp_free(f,part_classdata); - #else - temp_free(f,classifications); - #endif - temp_alloc_restore(f,temp_alloc_point); + #endif + } + } + } + for (i = 0; i < classwords && pcount < part_read; ++i, ++pcount) { + for (j = 0; j < ch; ++j) { + if (!do_not_decode[j]) { + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[j][class_set][i]; + #else + int c = classifications[j][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + float *target = residue_buffers[j]; + int offset = r->begin + pcount * r->part_size; + int n = r->part_size; + Codebook *book = f->codebooks + b; + if (!residue_decode(f, book, target, offset, n, rtype)) + goto done; + } + } + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } + done: + CHECK(f); + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + temp_free(f, part_classdata); + #else + temp_free(f,classifications); + #endif + temp_alloc_restore(f, temp_alloc_point); } - #if 0 -// slow way for debugging + // slow way for debugging void inverse_mdct_slow(float *buffer, int n) { int i,j; @@ -2308,7 +2347,7 @@ void inverse_mdct_slow(float *buffer, int n) free(x); } #elif 0 -// same as above, but just barely able to run in real time on modern machines + // same as above, but just barely able to run in real time on modern machines void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) { float mcos[16384]; @@ -2328,7 +2367,7 @@ void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) free(x); } #elif 0 -// transform to use a slow dct-iv; this is STILL basically trivial, + // transform to use a slow dct-iv; this is STILL basically trivial, // but only requires half as many ops void dct_iv_slow(float *buffer, int n) { @@ -2366,7 +2405,7 @@ void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) #endif #if LIBVORBIS_MDCT -// directly call the vorbis MDCT using an interface documented + // directly call the vorbis MDCT using an interface documented // by Jeff Roberts... useful for performance comparison typedef struct { @@ -2401,535 +2440,528 @@ void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) } #endif - // the following were split out into separate functions while optimizing; // they could be pushed back up but eh. __forceinline showed no change; // they're probably already being inlined. -static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) -{ - float *ee0 = e + i_off; - float *ee2 = ee0 + k_off; - int i; - - assert((n & 3) == 0); - for (i=(n>>2); i > 0; --i) { - float k00_20, k01_21; - k00_20 = ee0[ 0] - ee2[ 0]; - k01_21 = ee0[-1] - ee2[-1]; - ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-2] - ee2[-2]; - k01_21 = ee0[-3] - ee2[-3]; - ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-4] - ee2[-4]; - k01_21 = ee0[-5] - ee2[-5]; - ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-6] - ee2[-6]; - k01_21 = ee0[-7] - ee2[-7]; - ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - ee0 -= 8; - ee2 -= 8; - } +static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) { + float *ee0 = e + i_off; + float *ee2 = ee0 + k_off; + int i; + + assert((n & 3) == 0); + for (i = (n >> 2); i > 0; --i) { + float k00_20, k01_21; + k00_20 = ee0[0] - ee2[0]; + k01_21 = ee0[-1] - ee2[-1]; + ee0[0] += ee2[0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; + ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; + ee2[0] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-2] - ee2[-2]; + k01_21 = ee0[-3] - ee2[-3]; + ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; + ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; + ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-4] - ee2[-4]; + k01_21 = ee0[-5] - ee2[-5]; + ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; + ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; + ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-6] - ee2[-6]; + k01_21 = ee0[-7] - ee2[-7]; + ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; + ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; + ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + ee0 -= 8; + ee2 -= 8; + } } -static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) -{ - int i; - float k00_20, k01_21; - - float *e0 = e + d0; - float *e2 = e0 + k_off; - - for (i=lim >> 2; i > 0; --i) { - k00_20 = e0[-0] - e2[-0]; - k01_21 = e0[-1] - e2[-1]; - e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; - e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; - e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-2] - e2[-2]; - k01_21 = e0[-3] - e2[-3]; - e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; - e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; - e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-4] - e2[-4]; - k01_21 = e0[-5] - e2[-5]; - e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; - e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; - e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-6] - e2[-6]; - k01_21 = e0[-7] - e2[-7]; - e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; - e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; - e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; - - e0 -= 8; - e2 -= 8; - - A += k1; - } +static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) { + int i; + float k00_20, k01_21; + + float *e0 = e + d0; + float *e2 = e0 + k_off; + + for (i = lim >> 2; i > 0; --i) { + k00_20 = e0[-0] - e2[-0]; + k01_21 = e0[-1] - e2[-1]; + e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; + e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; + e2[-0] = (k00_20) * A[0] - (k01_21) * A[1]; + e2[-1] = (k01_21) * A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-2] - e2[-2]; + k01_21 = e0[-3] - e2[-3]; + e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; + e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; + e2[-2] = (k00_20) * A[0] - (k01_21) * A[1]; + e2[-3] = (k01_21) * A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-4] - e2[-4]; + k01_21 = e0[-5] - e2[-5]; + e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; + e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; + e2[-4] = (k00_20) * A[0] - (k01_21) * A[1]; + e2[-5] = (k01_21) * A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-6] - e2[-6]; + k01_21 = e0[-7] - e2[-7]; + e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; + e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; + e2[-6] = (k00_20) * A[0] - (k01_21) * A[1]; + e2[-7] = (k01_21) * A[0] + (k00_20) * A[1]; + + e0 -= 8; + e2 -= 8; + + A += k1; + } } -static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) -{ - int i; - float A0 = A[0]; - float A1 = A[0+1]; - float A2 = A[0+a_off]; - float A3 = A[0+a_off+1]; - float A4 = A[0+a_off*2+0]; - float A5 = A[0+a_off*2+1]; - float A6 = A[0+a_off*3+0]; - float A7 = A[0+a_off*3+1]; - - float k00,k11; - - float *ee0 = e +i_off; - float *ee2 = ee0+k_off; - - for (i=n; i > 0; --i) { - k00 = ee0[ 0] - ee2[ 0]; - k11 = ee0[-1] - ee2[-1]; - ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = (k00) * A0 - (k11) * A1; - ee2[-1] = (k11) * A0 + (k00) * A1; - - k00 = ee0[-2] - ee2[-2]; - k11 = ee0[-3] - ee2[-3]; - ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = (k00) * A2 - (k11) * A3; - ee2[-3] = (k11) * A2 + (k00) * A3; - - k00 = ee0[-4] - ee2[-4]; - k11 = ee0[-5] - ee2[-5]; - ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = (k00) * A4 - (k11) * A5; - ee2[-5] = (k11) * A4 + (k00) * A5; - - k00 = ee0[-6] - ee2[-6]; - k11 = ee0[-7] - ee2[-7]; - ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = (k00) * A6 - (k11) * A7; - ee2[-7] = (k11) * A6 + (k00) * A7; - - ee0 -= k0; - ee2 -= k0; - } +static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) { + int i; + float A0 = A[0]; + float A1 = A[0 + 1]; + float A2 = A[0 + a_off]; + float A3 = A[0 + a_off + 1]; + float A4 = A[0 + a_off * 2 + 0]; + float A5 = A[0 + a_off * 2 + 1]; + float A6 = A[0 + a_off * 3 + 0]; + float A7 = A[0 + a_off * 3 + 1]; + + float k00, k11; + + float *ee0 = e + i_off; + float *ee2 = ee0 + k_off; + + for (i = n; i > 0; --i) { + k00 = ee0[0] - ee2[0]; + k11 = ee0[-1] - ee2[-1]; + ee0[0] = ee0[0] + ee2[0]; + ee0[-1] = ee0[-1] + ee2[-1]; + ee2[0] = (k00) * A0 - (k11) * A1; + ee2[-1] = (k11) * A0 + (k00) * A1; + + k00 = ee0[-2] - ee2[-2]; + k11 = ee0[-3] - ee2[-3]; + ee0[-2] = ee0[-2] + ee2[-2]; + ee0[-3] = ee0[-3] + ee2[-3]; + ee2[-2] = (k00) * A2 - (k11) * A3; + ee2[-3] = (k11) * A2 + (k00) * A3; + + k00 = ee0[-4] - ee2[-4]; + k11 = ee0[-5] - ee2[-5]; + ee0[-4] = ee0[-4] + ee2[-4]; + ee0[-5] = ee0[-5] + ee2[-5]; + ee2[-4] = (k00) * A4 - (k11) * A5; + ee2[-5] = (k11) * A4 + (k00) * A5; + + k00 = ee0[-6] - ee2[-6]; + k11 = ee0[-7] - ee2[-7]; + ee0[-6] = ee0[-6] + ee2[-6]; + ee0[-7] = ee0[-7] + ee2[-7]; + ee2[-6] = (k00) * A6 - (k11) * A7; + ee2[-7] = (k11) * A6 + (k00) * A7; + + ee0 -= k0; + ee2 -= k0; + } } -static __forceinline void iter_54(float *z) -{ - float k00,k11,k22,k33; - float y0,y1,y2,y3; +static __forceinline void iter_54(float *z) { + float k00, k11, k22, k33; + float y0, y1, y2, y3; - k00 = z[ 0] - z[-4]; - y0 = z[ 0] + z[-4]; - y2 = z[-2] + z[-6]; - k22 = z[-2] - z[-6]; + k00 = z[0] - z[-4]; + y0 = z[0] + z[-4]; + y2 = z[-2] + z[-6]; + k22 = z[-2] - z[-6]; - z[-0] = y0 + y2; // z0 + z4 + z2 + z6 - z[-2] = y0 - y2; // z0 + z4 - z2 - z6 + z[-0] = y0 + y2; // z0 + z4 + z2 + z6 + z[-2] = y0 - y2; // z0 + z4 - z2 - z6 - // done with y0,y2 + // done with y0,y2 - k33 = z[-3] - z[-7]; + k33 = z[-3] - z[-7]; - z[-4] = k00 + k33; // z0 - z4 + z3 - z7 - z[-6] = k00 - k33; // z0 - z4 - z3 + z7 + z[-4] = k00 + k33; // z0 - z4 + z3 - z7 + z[-6] = k00 - k33; // z0 - z4 - z3 + z7 - // done with k33 + // done with k33 - k11 = z[-1] - z[-5]; - y1 = z[-1] + z[-5]; - y3 = z[-3] + z[-7]; + k11 = z[-1] - z[-5]; + y1 = z[-1] + z[-5]; + y3 = z[-3] + z[-7]; - z[-1] = y1 + y3; // z1 + z5 + z3 + z7 - z[-3] = y1 - y3; // z1 + z5 - z3 - z7 - z[-5] = k11 - k22; // z1 - z5 + z2 - z6 - z[-7] = k11 + k22; // z1 - z5 - z2 + z6 + z[-1] = y1 + y3; // z1 + z5 + z3 + z7 + z[-3] = y1 - y3; // z1 + z5 - z3 - z7 + z[-5] = k11 - k22; // z1 - z5 + z2 - z6 + z[-7] = k11 + k22; // z1 - z5 - z2 + z6 } -static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) -{ - int a_off = base_n >> 3; - float A2 = A[0+a_off]; - float *z = e + i_off; - float *base = z - 16 * n; - - while (z > base) { - float k00,k11; - float l00,l11; - - k00 = z[-0] - z[ -8]; - k11 = z[-1] - z[ -9]; - l00 = z[-2] - z[-10]; - l11 = z[-3] - z[-11]; - z[ -0] = z[-0] + z[ -8]; - z[ -1] = z[-1] + z[ -9]; - z[ -2] = z[-2] + z[-10]; - z[ -3] = z[-3] + z[-11]; - z[ -8] = k00; - z[ -9] = k11; - z[-10] = (l00+l11) * A2; - z[-11] = (l11-l00) * A2; - - k00 = z[ -4] - z[-12]; - k11 = z[ -5] - z[-13]; - l00 = z[ -6] - z[-14]; - l11 = z[ -7] - z[-15]; - z[ -4] = z[ -4] + z[-12]; - z[ -5] = z[ -5] + z[-13]; - z[ -6] = z[ -6] + z[-14]; - z[ -7] = z[ -7] + z[-15]; - z[-12] = k11; - z[-13] = -k00; - z[-14] = (l11-l00) * A2; - z[-15] = (l00+l11) * -A2; - - iter_54(z); - iter_54(z-8); - z -= 16; - } +static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) { + int a_off = base_n >> 3; + float A2 = A[0 + a_off]; + float *z = e + i_off; + float *base = z - 16 * n; + + while (z > base) { + float k00, k11; + float l00, l11; + + k00 = z[-0] - z[-8]; + k11 = z[-1] - z[-9]; + l00 = z[-2] - z[-10]; + l11 = z[-3] - z[-11]; + z[-0] = z[-0] + z[-8]; + z[-1] = z[-1] + z[-9]; + z[-2] = z[-2] + z[-10]; + z[-3] = z[-3] + z[-11]; + z[-8] = k00; + z[-9] = k11; + z[-10] = (l00 + l11) * A2; + z[-11] = (l11 - l00) * A2; + + k00 = z[-4] - z[-12]; + k11 = z[-5] - z[-13]; + l00 = z[-6] - z[-14]; + l11 = z[-7] - z[-15]; + z[-4] = z[-4] + z[-12]; + z[-5] = z[-5] + z[-13]; + z[-6] = z[-6] + z[-14]; + z[-7] = z[-7] + z[-15]; + z[-12] = k11; + z[-13] = -k00; + z[-14] = (l11 - l00) * A2; + z[-15] = (l00 + l11) * -A2; + + iter_54(z); + iter_54(z - 8); + z -= 16; + } } -static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; - int ld; - // @OPTIMIZE: reduce register pressure by using fewer variables? - int save_point = temp_alloc_save(f); - float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); - float *u=NULL,*v=NULL; - // twiddle factors - float *A = f->A[blocktype]; +static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) { + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; + int ld; + // @OPTIMIZE: reduce register pressure by using fewer variables? + int save_point = temp_alloc_save(f); + float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); + float *u = NULL, *v = NULL; + // twiddle factors + float *A = f->A[blocktype]; + + // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" + // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. + + // kernel from paper + + + // merged: + // copy and reflect spectral data + // step 0 + + // note that it turns out that the items added together during + // this step are, in fact, being added to themselves (as reflected + // by step 0). inexplicable inefficiency! this became obvious + // once I combined the passes. + + // so there's a missing 'times 2' here (for adding X to itself). + // this propagates through linearly to the end, where the numbers + // are 1/2 too small, and need to be compensated for. + + { + float *d, *e, *AA, *e_stop; + d = &buf2[n2 - 2]; + AA = A; + e = &buffer[0]; + e_stop = &buffer[n2]; + while (e != e_stop) { + d[1] = (e[0] * AA[0] - e[2] * AA[1]); + d[0] = (e[0] * AA[1] + e[2] * AA[0]); + d -= 2; + AA += 2; + e += 4; + } + + e = &buffer[n2 - 3]; + while (d >= buf2) { + d[1] = (-e[2] * AA[0] - -e[0] * AA[1]); + d[0] = (-e[2] * AA[1] + -e[0] * AA[0]); + d -= 2; + AA += 2; + e -= 4; + } + } + + // now we use symbolic names for these, so that we can + // possibly swap their meaning as we change which operations + // are in place + + u = buffer; + v = buf2; + + // step 2 (paper output is w, now u) + // this could be in place, but the data ends up in the wrong + // place... _somebody_'s got to swap it, so this is nominated + { + float *AA = &A[n2 - 8]; + float *d0, *d1, *e0, *e1; + + e0 = &v[n4]; + e1 = &v[0]; + + d0 = &u[n4]; + d1 = &u[0]; + + while (AA >= A) { + float v40_20, v41_21; + + v41_21 = e0[1] - e1[1]; + v40_20 = e0[0] - e1[0]; + d0[1] = e0[1] + e1[1]; + d0[0] = e0[0] + e1[0]; + d1[1] = v41_21 * AA[4] - v40_20 * AA[5]; + d1[0] = v40_20 * AA[4] + v41_21 * AA[5]; + + v41_21 = e0[3] - e1[3]; + v40_20 = e0[2] - e1[2]; + d0[3] = e0[3] + e1[3]; + d0[2] = e0[2] + e1[2]; + d1[3] = v41_21 * AA[0] - v40_20 * AA[1]; + d1[2] = v40_20 * AA[0] + v41_21 * AA[1]; + + AA -= 8; + + d0 += 4; + d1 += 4; + e0 += 4; + e1 += 4; + } + } + + // step 3 + ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + + // optimized step 3: + + // the original step3 loop can be nested r inside s or s inside r; + // it's written originally as s inside r, but this is dumb when r + // iterates many times, and s few. So I have two copies of it and + // switch between them halfway. + + // this is iteration 0 of step 3 + imdct_step3_iter0_loop(n >> 4, u, n2 - 1 - n4 * 0, -(n >> 3), A); + imdct_step3_iter0_loop(n >> 4, u, n2 - 1 - n4 * 1, -(n >> 3), A); + + // this is iteration 1 of step 3 + imdct_step3_inner_r_loop(n >> 5, u, n2 - 1 - n8 * 0, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2 - 1 - n8 * 1, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2 - 1 - n8 * 2, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2 - 1 - n8 * 3, -(n >> 4), A, 16); + + l = 2; + for (; l < (ld - 3) >> 1; ++l) { + int k0 = n >> (l + 2), k0_2 = k0 >> 1; + int lim = 1 << (l + 1); + int i; + for (i = 0; i < lim; ++i) + imdct_step3_inner_r_loop(n >> (l + 4), u, n2 - 1 - k0 * i, -k0_2, A, 1 << (l + 3)); + } + + for (; l < ld - 6; ++l) { + int k0 = n >> (l + 2), k1 = 1 << (l + 3), k0_2 = k0 >> 1; + int rlim = n >> (l + 6), r; + int lim = 1 << (l + 1); + int i_off; + float *A0 = A; + i_off = n2 - 1; + for (r = rlim; r > 0; --r) { + imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); + A0 += k1 * 4; + i_off -= 8; + } + } + + // iterations with count: + // ld-6,-5,-4 all interleaved together + // the big win comes from getting rid of needless flops + // due to the constants on pass 5 & 4 being all 1 and 0; + // combining them to be simultaneous to improve cache made little difference + imdct_step3_inner_s_loop_ld654(n >> 5, u, n2 - 1, A, n); + + // output is u + + // step 4, 5, and 6 + // cannot be in-place because of step 5 + { + uint16 *bitrev = f->bit_reverse[blocktype]; + // weirdly, I'd have thought reading sequentially and writing + // erratically would have been better than vice-versa, but in + // fact that's not what my testing showed. (That is, with + // j = bitreverse(i), do you read i and write j, or read j and write i.) + + float *d0 = &v[n4 - 4]; + float *d1 = &v[n2 - 4]; + while (d0 >= v) { + int k4; + + k4 = bitrev[0]; + d1[3] = u[k4 + 0]; + d1[2] = u[k4 + 1]; + d0[3] = u[k4 + 2]; + d0[2] = u[k4 + 3]; + + k4 = bitrev[1]; + d1[1] = u[k4 + 0]; + d1[0] = u[k4 + 1]; + d0[1] = u[k4 + 2]; + d0[0] = u[k4 + 3]; + + d0 -= 4; + d1 -= 4; + bitrev += 2; + } + } + // (paper output is u, now v) + + + // data must be in buf2 + assert(v == buf2); + + // step 7 (paper output is v, now v) + // this is now in place + { + float *C = f->C[blocktype]; + float *d, *e; + + d = v; + e = v + n2 - 4; + + while (d < e) { + float a02, a11, b0, b1, b2, b3; + + a02 = d[0] - e[2]; + a11 = d[1] + e[3]; + + b0 = C[1] * a02 + C[0] * a11; + b1 = C[1] * a11 - C[0] * a02; + + b2 = d[0] + e[2]; + b3 = d[1] - e[3]; + + d[0] = b2 + b0; + d[1] = b3 + b1; + e[2] = b2 - b0; + e[3] = b1 - b3; + + a02 = d[2] - e[0]; + a11 = d[3] + e[1]; + + b0 = C[3] * a02 + C[2] * a11; + b1 = C[3] * a11 - C[2] * a02; + + b2 = d[2] + e[0]; + b3 = d[3] - e[1]; + + d[2] = b2 + b0; + d[3] = b3 + b1; + e[0] = b2 - b0; + e[1] = b1 - b3; + + C += 4; + d += 4; + e -= 4; + } + } + + // data must be in buf2 + + + // step 8+decode (paper output is X, now buffer) + // this generates pairs of data a la 8 and pushes them directly through + // the decode kernel (pushing rather than pulling) to avoid having + // to make another pass later + + // this cannot POSSIBLY be in place, so we refer to the buffers directly + + { + float *d0, *d1, *d2, *d3; + + float *B = f->B[blocktype] + n2 - 8; + float *e = buf2 + n2 - 8; + d0 = &buffer[0]; + d1 = &buffer[n2 - 4]; + d2 = &buffer[n2]; + d3 = &buffer[n - 4]; + while (e >= v) { + float p0, p1, p2, p3; + + p3 = e[6] * B[7] - e[7] * B[6]; + p2 = -e[6] * B[6] - e[7] * B[7]; + + d0[0] = p3; + d1[3] = -p3; + d2[0] = p2; + d3[3] = p2; + + p1 = e[4] * B[5] - e[5] * B[4]; + p0 = -e[4] * B[4] - e[5] * B[5]; + + d0[1] = p1; + d1[2] = -p1; + d2[1] = p0; + d3[2] = p0; + + p3 = e[2] * B[3] - e[3] * B[2]; + p2 = -e[2] * B[2] - e[3] * B[3]; - // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" - // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. + d0[2] = p3; + d1[1] = -p3; + d2[2] = p2; + d3[1] = p2; - // kernel from paper + p1 = e[0] * B[1] - e[1] * B[0]; + p0 = -e[0] * B[0] - e[1] * B[1]; + d0[3] = p1; + d1[0] = -p1; + d2[3] = p0; + d3[0] = p0; - // merged: - // copy and reflect spectral data - // step 0 - - // note that it turns out that the items added together during - // this step are, in fact, being added to themselves (as reflected - // by step 0). inexplicable inefficiency! this became obvious - // once I combined the passes. - - // so there's a missing 'times 2' here (for adding X to itself). - // this propagates through linearly to the end, where the numbers - // are 1/2 too small, and need to be compensated for. - - { - float *d,*e, *AA, *e_stop; - d = &buf2[n2-2]; - AA = A; - e = &buffer[0]; - e_stop = &buffer[n2]; - while (e != e_stop) { - d[1] = (e[0] * AA[0] - e[2]*AA[1]); - d[0] = (e[0] * AA[1] + e[2]*AA[0]); - d -= 2; - AA += 2; - e += 4; - } + B -= 8; + e -= 8; + d0 += 4; + d2 += 4; + d1 -= 4; + d3 -= 4; + } + } - e = &buffer[n2-3]; - while (d >= buf2) { - d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); - d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); - d -= 2; - AA += 2; - e -= 4; - } - } - - // now we use symbolic names for these, so that we can - // possibly swap their meaning as we change which operations - // are in place - - u = buffer; - v = buf2; - - // step 2 (paper output is w, now u) - // this could be in place, but the data ends up in the wrong - // place... _somebody_'s got to swap it, so this is nominated - { - float *AA = &A[n2-8]; - float *d0,*d1, *e0, *e1; - - e0 = &v[n4]; - e1 = &v[0]; - - d0 = &u[n4]; - d1 = &u[0]; - - while (AA >= A) { - float v40_20, v41_21; - - v41_21 = e0[1] - e1[1]; - v40_20 = e0[0] - e1[0]; - d0[1] = e0[1] + e1[1]; - d0[0] = e0[0] + e1[0]; - d1[1] = v41_21*AA[4] - v40_20*AA[5]; - d1[0] = v40_20*AA[4] + v41_21*AA[5]; - - v41_21 = e0[3] - e1[3]; - v40_20 = e0[2] - e1[2]; - d0[3] = e0[3] + e1[3]; - d0[2] = e0[2] + e1[2]; - d1[3] = v41_21*AA[0] - v40_20*AA[1]; - d1[2] = v40_20*AA[0] + v41_21*AA[1]; - - AA -= 8; - - d0 += 4; - d1 += 4; - e0 += 4; - e1 += 4; - } - } - - // step 3 - ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - - // optimized step 3: - - // the original step3 loop can be nested r inside s or s inside r; - // it's written originally as s inside r, but this is dumb when r - // iterates many times, and s few. So I have two copies of it and - // switch between them halfway. - - // this is iteration 0 of step 3 - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); - - // this is iteration 1 of step 3 - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); - - l=2; - for (; l < (ld-3)>>1; ++l) { - int k0 = n >> (l+2), k0_2 = k0>>1; - int lim = 1 << (l+1); - int i; - for (i=0; i < lim; ++i) - imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); - } - - for (; l < ld-6; ++l) { - int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; - int rlim = n >> (l+6), r; - int lim = 1 << (l+1); - int i_off; - float *A0 = A; - i_off = n2-1; - for (r=rlim; r > 0; --r) { - imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); - A0 += k1*4; - i_off -= 8; - } - } - - // iterations with count: - // ld-6,-5,-4 all interleaved together - // the big win comes from getting rid of needless flops - // due to the constants on pass 5 & 4 being all 1 and 0; - // combining them to be simultaneous to improve cache made little difference - imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); - - // output is u - - // step 4, 5, and 6 - // cannot be in-place because of step 5 - { - uint16 *bitrev = f->bit_reverse[blocktype]; - // weirdly, I'd have thought reading sequentially and writing - // erratically would have been better than vice-versa, but in - // fact that's not what my testing showed. (That is, with - // j = bitreverse(i), do you read i and write j, or read j and write i.) - - float *d0 = &v[n4-4]; - float *d1 = &v[n2-4]; - while (d0 >= v) { - int k4; - - k4 = bitrev[0]; - d1[3] = u[k4+0]; - d1[2] = u[k4+1]; - d0[3] = u[k4+2]; - d0[2] = u[k4+3]; - - k4 = bitrev[1]; - d1[1] = u[k4+0]; - d1[0] = u[k4+1]; - d0[1] = u[k4+2]; - d0[0] = u[k4+3]; - - d0 -= 4; - d1 -= 4; - bitrev += 2; - } - } - // (paper output is u, now v) - - - // data must be in buf2 - assert(v == buf2); - - // step 7 (paper output is v, now v) - // this is now in place - { - float *C = f->C[blocktype]; - float *d, *e; - - d = v; - e = v + n2 - 4; - - while (d < e) { - float a02,a11,b0,b1,b2,b3; - - a02 = d[0] - e[2]; - a11 = d[1] + e[3]; - - b0 = C[1]*a02 + C[0]*a11; - b1 = C[1]*a11 - C[0]*a02; - - b2 = d[0] + e[ 2]; - b3 = d[1] - e[ 3]; - - d[0] = b2 + b0; - d[1] = b3 + b1; - e[2] = b2 - b0; - e[3] = b1 - b3; - - a02 = d[2] - e[0]; - a11 = d[3] + e[1]; - - b0 = C[3]*a02 + C[2]*a11; - b1 = C[3]*a11 - C[2]*a02; - - b2 = d[2] + e[ 0]; - b3 = d[3] - e[ 1]; - - d[2] = b2 + b0; - d[3] = b3 + b1; - e[0] = b2 - b0; - e[1] = b1 - b3; - - C += 4; - d += 4; - e -= 4; - } - } - - // data must be in buf2 - - - // step 8+decode (paper output is X, now buffer) - // this generates pairs of data a la 8 and pushes them directly through - // the decode kernel (pushing rather than pulling) to avoid having - // to make another pass later - - // this cannot POSSIBLY be in place, so we refer to the buffers directly - - { - float *d0,*d1,*d2,*d3; - - float *B = f->B[blocktype] + n2 - 8; - float *e = buf2 + n2 - 8; - d0 = &buffer[0]; - d1 = &buffer[n2-4]; - d2 = &buffer[n2]; - d3 = &buffer[n-4]; - while (e >= v) { - float p0,p1,p2,p3; - - p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; - - d0[0] = p3; - d1[3] = - p3; - d2[0] = p2; - d3[3] = p2; - - p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; - - d0[1] = p1; - d1[2] = - p1; - d2[1] = p0; - d3[2] = p0; - - p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; - - d0[2] = p3; - d1[1] = - p3; - d2[2] = p2; - d3[1] = p2; - - p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; - - d0[3] = p1; - d1[0] = - p1; - d2[3] = p0; - d3[0] = p0; - - B -= 8; - e -= 8; - d0 += 4; - d2 += 4; - d1 -= 4; - d3 -= 4; - } - } - - temp_free(f,buf2); - temp_alloc_restore(f,save_point); -} + temp_free(f, buf2); + temp_alloc_restore(f, save_point); +} #if 0 -// this is the original version of the above code, if you want to optimize it from scratch + // this is the original version of the above code, if you want to optimize it from scratch void inverse_mdct_naive(float *buffer, int n) { float s; @@ -3056,12 +3088,13 @@ void inverse_mdct_naive(float *buffer, int n) } #endif -static float *get_window(vorb *f, int len) -{ - len <<= 1; - if (len == f->blocksize_0) return f->window[0]; - if (len == f->blocksize_1) return f->window[1]; - return NULL; +static float *get_window(vorb *f, int len) { + len <<= 1; + if (len == f->blocksize_0) + return f->window[0]; + if (len == f->blocksize_1) + return f->window[1]; + return NULL; } #ifndef STB_VORBIS_NO_DEFER_FLOOR @@ -3069,42 +3102,42 @@ typedef int16 YTYPE; #else typedef int YTYPE; #endif -static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) -{ - int n2 = n >> 1; - int s = map->chan[i].mux, floor; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - int j,q; - int lx = 0, ly = finalY[0] * g->floor1_multiplier; - for (q=1; q < g->values; ++q) { - j = g->sorted_order[q]; - #ifndef STB_VORBIS_NO_DEFER_FLOOR - STBV_NOTUSED(step2_flag); - if (finalY[j] >= 0) - #else - if (step2_flag[j]) - #endif - { - int hy = finalY[j] * g->floor1_multiplier; - int hx = g->Xlist[j]; - if (lx != hx) - draw_line(target, lx,ly, hx,hy, n2); - CHECK(f); - lx = hx, ly = hy; - } - } - if (lx < n2) { - // optimization of: draw_line(target, lx,ly, n,ly, n2); - for (j=lx; j < n2; ++j) - LINE_OP(target[j], inverse_db_table[ly]); - CHECK(f); - } - } - return TRUE; + +static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) { + int n2 = n >> 1; + int s = map->chan[i].mux, floor; + floor = map->submap_floor[s]; + if (f->floor_types[floor] == 0) { + return error(f, VORBIS_invalid_stream); + } else { + Floor1 *g = &f->floor_config[floor].floor1; + int j, q; + int lx = 0, ly = finalY[0] * g->floor1_multiplier; + for (q = 1; q < g->values; ++q) { + j = g->sorted_order[q]; + #ifndef STB_VORBIS_NO_DEFER_FLOOR + STBV_NOTUSED(step2_flag); + if (finalY[j] >= 0) + #else + if (step2_flag[j]) + #endif + { + int hy = finalY[j] * g->floor1_multiplier; + int hx = g->Xlist[j]; + if (lx != hx) + draw_line(target, lx, ly, hx, hy, n2); + CHECK(f); + lx = hx, ly = hy; + } + } + if (lx < n2) { + // optimization of: draw_line(target, lx,ly, n,ly, n2); + for (j = lx; j < n2; ++j) + LINE_OP(target[j], inverse_db_table[ly]); + CHECK(f); + } + } + return TRUE; } // The meaning of "left" and "right" @@ -3121,245 +3154,257 @@ static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *f // has to be the same as frame N+1's left_end-left_start (which they are by // construction) -static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) -{ - Mode *m; - int i, n, prev, next, window_center; - f->channel_buffer_start = f->channel_buffer_end = 0; - - retry: - if (f->eof) return FALSE; - if (!maybe_start_packet(f)) - return FALSE; - // check packet type - if (get_bits(f,1) != 0) { - if (IS_PUSH_MODE(f)) - return error(f,VORBIS_bad_packet_type); - while (EOP != get8_packet(f)); - goto retry; - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - i = get_bits(f, ilog(f->mode_count-1)); - if (i == EOP) return FALSE; - if (i >= f->mode_count) return FALSE; - *mode = i; - m = f->mode_config + i; - if (m->blockflag) { - n = f->blocksize_1; - prev = get_bits(f,1); - next = get_bits(f,1); - } else { - prev = next = 0; - n = f->blocksize_0; - } +static int vorbis_decode_initial(vorb *f, + int *p_left_start, + int *p_left_end, + int *p_right_start, + int *p_right_end, + int *mode) { + Mode *m; + int i, n, prev, next, window_center; + f->channel_buffer_start = f->channel_buffer_end = 0; + + retry: + if (f->eof) + return FALSE; + if (!maybe_start_packet(f)) + return FALSE; + // check packet type + if (get_bits(f, 1) != 0) { + if (IS_PUSH_MODE(f)) + return error(f, VORBIS_bad_packet_type); + while (EOP != get8_packet(f)); + goto retry; + } + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + + i = get_bits(f, ilog(f->mode_count - 1)); + if (i == EOP) + return FALSE; + if (i >= f->mode_count) + return FALSE; + *mode = i; + m = f->mode_config + i; + if (m->blockflag) { + n = f->blocksize_1; + prev = get_bits(f, 1); + next = get_bits(f, 1); + } else { + prev = next = 0; + n = f->blocksize_0; + } // WINDOWING - window_center = n >> 1; - if (m->blockflag && !prev) { - *p_left_start = (n - f->blocksize_0) >> 2; - *p_left_end = (n + f->blocksize_0) >> 2; - } else { - *p_left_start = 0; - *p_left_end = window_center; - } - if (m->blockflag && !next) { - *p_right_start = (n*3 - f->blocksize_0) >> 2; - *p_right_end = (n*3 + f->blocksize_0) >> 2; - } else { - *p_right_start = window_center; - *p_right_end = n; - } - - return TRUE; + window_center = n >> 1; + if (m->blockflag && !prev) { + *p_left_start = (n - f->blocksize_0) >> 2; + *p_left_end = (n + f->blocksize_0) >> 2; + } else { + *p_left_start = 0; + *p_left_end = window_center; + } + if (m->blockflag && !next) { + *p_right_start = (n * 3 - f->blocksize_0) >> 2; + *p_right_end = (n * 3 + f->blocksize_0) >> 2; + } else { + *p_right_start = window_center; + *p_right_end = n; + } + + return TRUE; } -static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) -{ - Mapping *map; - int i,j,k,n,n2; - int zero_channel[256]; - int really_zero_channel[256]; +static int vorbis_decode_packet_rest(vorb *f, + int *len, + Mode *m, + int left_start, + int left_end, + int right_start, + int right_end, + int *p_left) { + Mapping *map; + int i, j, k, n, n2; + int zero_channel[256]; + int really_zero_channel[256]; // WINDOWING - STBV_NOTUSED(left_end); - n = f->blocksize[m->blockflag]; - map = &f->mapping[m->mapping]; + STBV_NOTUSED(left_end); + n = f->blocksize[m->blockflag]; + map = &f->mapping[m->mapping]; // FLOORS - n2 = n >> 1; - - CHECK(f); - - for (i=0; i < f->channels; ++i) { - int s = map->chan[i].mux, floor; - zero_channel[i] = FALSE; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - if (get_bits(f, 1)) { - short *finalY; - uint8 step2_flag[256]; - static int range_list[4] = { 256, 128, 86, 64 }; - int range = range_list[g->floor1_multiplier-1]; - int offset = 2; - finalY = f->finalY[i]; - finalY[0] = get_bits(f, ilog(range)-1); - finalY[1] = get_bits(f, ilog(range)-1); - for (j=0; j < g->partitions; ++j) { - int pclass = g->partition_class_list[j]; - int cdim = g->class_dimensions[pclass]; - int cbits = g->class_subclasses[pclass]; - int csub = (1 << cbits)-1; - int cval = 0; - if (cbits) { - Codebook *c = f->codebooks + g->class_masterbooks[pclass]; - DECODE(cval,f,c); - } - for (k=0; k < cdim; ++k) { - int book = g->subclass_books[pclass][cval & csub]; - cval = cval >> cbits; - if (book >= 0) { - int temp; - Codebook *c = f->codebooks + book; - DECODE(temp,f,c); - finalY[offset++] = temp; - } else - finalY[offset++] = 0; - } - } - if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec - step2_flag[0] = step2_flag[1] = 1; - for (j=2; j < g->values; ++j) { - int low, high, pred, highroom, lowroom, room, val; - low = g->neighbors[j][0]; - high = g->neighbors[j][1]; - //neighbors(g->Xlist, j, &low, &high); - pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); - val = finalY[j]; - highroom = range - pred; - lowroom = pred; - if (highroom < lowroom) - room = highroom * 2; - else - room = lowroom * 2; - if (val) { - step2_flag[low] = step2_flag[high] = 1; - step2_flag[j] = 1; - if (val >= room) - if (highroom > lowroom) - finalY[j] = val - lowroom + pred; - else - finalY[j] = pred - val + highroom - 1; - else - if (val & 1) - finalY[j] = pred - ((val+1)>>1); - else - finalY[j] = pred + (val>>1); - } else { - step2_flag[j] = 0; - finalY[j] = pred; - } - } + n2 = n >> 1; + + CHECK(f); + + for (i = 0; i < f->channels; ++i) { + int s = map->chan[i].mux, floor; + zero_channel[i] = FALSE; + floor = map->submap_floor[s]; + if (f->floor_types[floor] == 0) { + return error(f, VORBIS_invalid_stream); + } else { + Floor1 *g = &f->floor_config[floor].floor1; + if (get_bits(f, 1)) { + short *finalY; + uint8 step2_flag[256]; + static int range_list[4] = {256, 128, 86, 64}; + int range = range_list[g->floor1_multiplier - 1]; + int offset = 2; + finalY = f->finalY[i]; + finalY[0] = get_bits(f, ilog(range) - 1); + finalY[1] = get_bits(f, ilog(range) - 1); + for (j = 0; j < g->partitions; ++j) { + int pclass = g->partition_class_list[j]; + int cdim = g->class_dimensions[pclass]; + int cbits = g->class_subclasses[pclass]; + int csub = (1 << cbits) - 1; + int cval = 0; + if (cbits) { + Codebook *c = f->codebooks + g->class_masterbooks[pclass]; + DECODE(cval, f, c); + } + for (k = 0; k < cdim; ++k) { + int book = g->subclass_books[pclass][cval & csub]; + cval = cval >> cbits; + if (book >= 0) { + int temp; + Codebook *c = f->codebooks + book; + DECODE(temp, f, c); + finalY[offset++] = temp; + } else + finalY[offset++] = 0; + } + } + if (f->valid_bits == INVALID_BITS) + goto error; // behavior according to spec + step2_flag[0] = step2_flag[1] = 1; + for (j = 2; j < g->values; ++j) { + int low, high, pred, highroom, lowroom, room, val; + low = g->neighbors[j][0]; + high = g->neighbors[j][1]; + //neighbors(g->Xlist, j, &low, &high); + pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); + val = finalY[j]; + highroom = range - pred; + lowroom = pred; + if (highroom < lowroom) + room = highroom * 2; + else + room = lowroom * 2; + if (val) { + step2_flag[low] = step2_flag[high] = 1; + step2_flag[j] = 1; + if (val >= room) + if (highroom > lowroom) + finalY[j] = val - lowroom + pred; + else + finalY[j] = pred - val + highroom - 1; + else if (val & 1) + finalY[j] = pred - ((val + 1) >> 1); + else + finalY[j] = pred + (val >> 1); + } else { + step2_flag[j] = 0; + finalY[j] = pred; + } + } #ifdef STB_VORBIS_NO_DEFER_FLOOR - do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); + do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); #else - // defer final floor computation until _after_ residue - for (j=0; j < g->values; ++j) { - if (!step2_flag[j]) - finalY[j] = -1; - } + // defer final floor computation until _after_ residue + for (j = 0; j < g->values; ++j) { + if (!step2_flag[j]) + finalY[j] = -1; + } #endif - } else { - error: - zero_channel[i] = TRUE; - } - // So we just defer everything else to later - - // at this point we've decoded the floor into buffer - } - } - CHECK(f); - // at this point we've decoded all floors - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - // re-enable coupled channels if necessary - memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); - for (i=0; i < map->coupling_steps; ++i) - if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { - zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; - } - - CHECK(f); + } else { + error: + zero_channel[i] = TRUE; + } + // So we just defer everything else to later + + // at this point we've decoded the floor into buffer + } + } + CHECK(f); + // at this point we've decoded all floors + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + + // re-enable coupled channels if necessary + memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); + for (i = 0; i < map->coupling_steps; ++i) + if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { + zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; + } + + CHECK(f); // RESIDUE DECODE - for (i=0; i < map->submaps; ++i) { - float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; - int r; - uint8 do_not_decode[256]; - int ch = 0; - for (j=0; j < f->channels; ++j) { - if (map->chan[j].mux == i) { - if (zero_channel[j]) { - do_not_decode[ch] = TRUE; - residue_buffers[ch] = NULL; - } else { - do_not_decode[ch] = FALSE; - residue_buffers[ch] = f->channel_buffers[j]; - } - ++ch; - } - } - r = map->submap_residue[i]; - decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - CHECK(f); + for (i = 0; i < map->submaps; ++i) { + float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; + int r; + uint8 do_not_decode[256]; + int ch = 0; + for (j = 0; j < f->channels; ++j) { + if (map->chan[j].mux == i) { + if (zero_channel[j]) { + do_not_decode[ch] = TRUE; + residue_buffers[ch] = NULL; + } else { + do_not_decode[ch] = FALSE; + residue_buffers[ch] = f->channel_buffers[j]; + } + ++ch; + } + } + r = map->submap_residue[i]; + decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); + } + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + CHECK(f); // INVERSE COUPLING - for (i = map->coupling_steps-1; i >= 0; --i) { - int n2 = n >> 1; - float *m = f->channel_buffers[map->chan[i].magnitude]; - float *a = f->channel_buffers[map->chan[i].angle ]; - for (j=0; j < n2; ++j) { - float a2,m2; - if (m[j] > 0) - if (a[j] > 0) - m2 = m[j], a2 = m[j] - a[j]; - else - a2 = m[j], m2 = m[j] + a[j]; - else - if (a[j] > 0) - m2 = m[j], a2 = m[j] + a[j]; - else - a2 = m[j], m2 = m[j] - a[j]; - m[j] = m2; - a[j] = a2; - } - } - CHECK(f); - - // finish decoding the floors + for (i = map->coupling_steps - 1; i >= 0; --i) { + int n2 = n >> 1; + float *m = f->channel_buffers[map->chan[i].magnitude]; + float *a = f->channel_buffers[map->chan[i].angle]; + for (j = 0; j < n2; ++j) { + float a2, m2; + if (m[j] > 0) + if (a[j] > 0) + m2 = m[j], a2 = m[j] - a[j]; + else + a2 = m[j], m2 = m[j] + a[j]; + else if (a[j] > 0) + m2 = m[j], a2 = m[j] + a[j]; + else + a2 = m[j], m2 = m[j] - a[j]; + m[j] = m2; + a[j] = a2; + } + } + CHECK(f); + + // finish decoding the floors #ifndef STB_VORBIS_NO_DEFER_FLOOR - for (i=0; i < f->channels; ++i) { - if (really_zero_channel[i]) { - memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); - } else { - do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); - } - } + for (i = 0; i < f->channels; ++i) { + if (really_zero_channel[i]) { + memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); + } else { + do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); + } + } #else - for (i=0; i < f->channels; ++i) { + for (i=0; i < f->channels; ++i) { if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { @@ -3370,1187 +3415,1294 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, #endif // INVERSE MDCT - CHECK(f); - for (i=0; i < f->channels; ++i) - inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); - CHECK(f); - - // this shouldn't be necessary, unless we exited on an error - // and want to flush to get to the next packet - flush_packet(f); - - if (f->first_decode) { - // assume we start so first non-discarded sample is sample 0 - // this isn't to spec, but spec would require us to read ahead - // and decode the size of all current frames--could be done, - // but presumably it's not a commonly used feature - f->current_loc = 0u - n2; // start of first frame is positioned for discard (NB this is an intentional unsigned overflow/wrap-around) - // we might have to discard samples "from" the next frame too, - // if we're lapping a large block then a small at the start? - f->discard_samples_deferred = n - right_end; - f->current_loc_valid = TRUE; - f->first_decode = FALSE; - } else if (f->discard_samples_deferred) { - if (f->discard_samples_deferred >= right_start - left_start) { - f->discard_samples_deferred -= (right_start - left_start); - left_start = right_start; - *p_left = left_start; - } else { - left_start += f->discard_samples_deferred; - *p_left = left_start; - f->discard_samples_deferred = 0; - } - } else if (f->previous_length == 0 && f->current_loc_valid) { - // we're recovering from a seek... that means we're going to discard - // the samples from this packet even though we know our position from - // the last page header, so we need to update the position based on - // the discarded samples here - // but wait, the code below is going to add this in itself even - // on a discard, so we don't need to do it here... - } - - // check if we have ogg information about the sample # for this packet - if (f->last_seg_which == f->end_seg_with_known_loc) { - // if we have a valid current loc, and this is final: - if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { - uint32 current_end = f->known_loc_for_packet; - // then let's infer the size of the (probably) short final frame - if (current_end < f->current_loc + (right_end-left_start)) { - if (current_end < f->current_loc) { - // negative truncation, that's impossible! - *len = 0; - } else { - *len = current_end - f->current_loc; - } - *len += left_start; // this doesn't seem right, but has no ill effect on my test files - if (*len > right_end) *len = right_end; // this should never happen - f->current_loc += *len; - return TRUE; - } - } - // otherwise, just set our sample loc - // guess that the ogg granule pos refers to the _middle_ of the - // last frame? - // set f->current_loc to the position of left_start - f->current_loc = f->known_loc_for_packet - (n2-left_start); - f->current_loc_valid = TRUE; - } - if (f->current_loc_valid) - f->current_loc += (right_start - left_start); - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - *len = right_end; // ignore samples after the window goes to 0 - CHECK(f); - - return TRUE; + CHECK(f); + for (i = 0; i < f->channels; ++i) + inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); + CHECK(f); + + // this shouldn't be necessary, unless we exited on an error + // and want to flush to get to the next packet + flush_packet(f); + + if (f->first_decode) { + // assume we start so first non-discarded sample is sample 0 + // this isn't to spec, but spec would require us to read ahead + // and decode the size of all current frames--could be done, + // but presumably it's not a commonly used feature + f->current_loc = 0u + - n2; // start of first frame is positioned for discard (NB this is an intentional unsigned overflow/wrap-around) + // we might have to discard samples "from" the next frame too, + // if we're lapping a large block then a small at the start? + f->discard_samples_deferred = n - right_end; + f->current_loc_valid = TRUE; + f->first_decode = FALSE; + } else if (f->discard_samples_deferred) { + if (f->discard_samples_deferred >= right_start - left_start) { + f->discard_samples_deferred -= (right_start - left_start); + left_start = right_start; + *p_left = left_start; + } else { + left_start += f->discard_samples_deferred; + *p_left = left_start; + f->discard_samples_deferred = 0; + } + } else if (f->previous_length == 0 && f->current_loc_valid) { + // we're recovering from a seek... that means we're going to discard + // the samples from this packet even though we know our position from + // the last page header, so we need to update the position based on + // the discarded samples here + // but wait, the code below is going to add this in itself even + // on a discard, so we don't need to do it here... + } + + // check if we have ogg information about the sample # for this packet + if (f->last_seg_which == f->end_seg_with_known_loc) { + // if we have a valid current loc, and this is final: + if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { + uint32 current_end = f->known_loc_for_packet; + // then let's infer the size of the (probably) short final frame + if (current_end < f->current_loc + (right_end - left_start)) { + if (current_end < f->current_loc) { + // negative truncation, that's impossible! + *len = 0; + } else { + *len = current_end - f->current_loc; + } + *len += left_start; // this doesn't seem right, but has no ill effect on my test files + if (*len > right_end) + *len = right_end; // this should never happen + f->current_loc += *len; + return TRUE; + } + } + // otherwise, just set our sample loc + // guess that the ogg granule pos refers to the _middle_ of the + // last frame? + // set f->current_loc to the position of left_start + f->current_loc = f->known_loc_for_packet - (n2 - left_start); + f->current_loc_valid = TRUE; + } + if (f->current_loc_valid) + f->current_loc += (right_start - left_start); + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + *len = right_end; // ignore samples after the window goes to 0 + CHECK(f); + + return TRUE; } -static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) -{ - int mode, left_end, right_end; - if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; - return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); +static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) { + int mode, left_end, right_end; + if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) + return 0; + return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); } -static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) -{ - int prev,i,j; - // we use right&left (the start of the right- and left-window sin()-regions) - // to determine how much to return, rather than inferring from the rules - // (same result, clearer code); 'left' indicates where our sin() window - // starts, therefore where the previous window's right edge starts, and - // therefore where to start mixing from the previous buffer. 'right' - // indicates where our sin() ending-window starts, therefore that's where - // we start saving, and where our returned-data ends. - - // mixin from previous window - if (f->previous_length) { - int i,j, n = f->previous_length; - float *w = get_window(f, n); - if (w == NULL) return 0; - for (i=0; i < f->channels; ++i) { - for (j=0; j < n; ++j) - f->channel_buffers[i][left+j] = - f->channel_buffers[i][left+j]*w[ j] + - f->previous_window[i][ j]*w[n-1-j]; - } - } - - prev = f->previous_length; - - // last half of this data becomes previous window - f->previous_length = len - right; - - // @OPTIMIZE: could avoid this copy by double-buffering the - // output (flipping previous_window with channel_buffers), but - // then previous_window would have to be 2x as large, and - // channel_buffers couldn't be temp mem (although they're NOT - // currently temp mem, they could be (unless we want to level - // performance by spreading out the computation)) - for (i=0; i < f->channels; ++i) - for (j=0; right+j < len; ++j) - f->previous_window[i][j] = f->channel_buffers[i][right+j]; - - if (!prev) - // there was no previous packet, so this data isn't valid... - // this isn't entirely true, only the would-have-overlapped data - // isn't valid, but this seems to be what the spec requires - return 0; - - // truncate a short frame - if (len < right) right = len; - - f->samples_output += right-left; - - return right - left; +static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) { + int prev, i, j; + // we use right&left (the start of the right- and left-window sin()-regions) + // to determine how much to return, rather than inferring from the rules + // (same result, clearer code); 'left' indicates where our sin() window + // starts, therefore where the previous window's right edge starts, and + // therefore where to start mixing from the previous buffer. 'right' + // indicates where our sin() ending-window starts, therefore that's where + // we start saving, and where our returned-data ends. + + // mixin from previous window + if (f->previous_length) { + int i, j, n = f->previous_length; + float *w = get_window(f, n); + if (w == NULL) + return 0; + for (i = 0; i < f->channels; ++i) { + for (j = 0; j < n; ++j) + f->channel_buffers[i][left + j] = + f->channel_buffers[i][left + j] * w[j] + + f->previous_window[i][j] * w[n - 1 - j]; + } + } + + prev = f->previous_length; + + // last half of this data becomes previous window + f->previous_length = len - right; + + // @OPTIMIZE: could avoid this copy by double-buffering the + // output (flipping previous_window with channel_buffers), but + // then previous_window would have to be 2x as large, and + // channel_buffers couldn't be temp mem (although they're NOT + // currently temp mem, they could be (unless we want to level + // performance by spreading out the computation)) + for (i = 0; i < f->channels; ++i) + for (j = 0; right + j < len; ++j) + f->previous_window[i][j] = f->channel_buffers[i][right + j]; + + if (!prev) + // there was no previous packet, so this data isn't valid... + // this isn't entirely true, only the would-have-overlapped data + // isn't valid, but this seems to be what the spec requires + return 0; + + // truncate a short frame + if (len < right) + right = len; + + f->samples_output += right - left; + + return right - left; } -static int vorbis_pump_first_frame(stb_vorbis *f) -{ - int len, right, left, res; - res = vorbis_decode_packet(f, &len, &left, &right); - if (res) - vorbis_finish_frame(f, len, left, right); - return res; +static int vorbis_pump_first_frame(stb_vorbis *f) { + int len, right, left, res; + res = vorbis_decode_packet(f, &len, &left, &right); + if (res) + vorbis_finish_frame(f, len, left, right); + return res; } #ifndef STB_VORBIS_NO_PUSHDATA_API -static int is_whole_packet_present(stb_vorbis *f) -{ - // make sure that we have the packet available before continuing... - // this requires a full ogg parse, but we know we can fetch from f->stream - - // instead of coding this out explicitly, we could save the current read state, - // read the next packet with get8() until end-of-packet, check f->eof, then - // reset the state? but that would be slower, esp. since we'd have over 256 bytes - // of state to restore (primarily the page segment table) - - int s = f->next_seg, first = TRUE; - uint8 *p = f->stream; - - if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag - for (; s < f->segment_count; ++s) { - p += f->segments[s]; - if (f->segments[s] < 255) // stop at first short segment - break; - } - // either this continues, or it ends it... - if (s == f->segment_count) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - for (; s == -1;) { - uint8 *q; - int n; - - // check that we have the page header ready - if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); - // validate the page - if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); - if (p[4] != 0) return error(f, VORBIS_invalid_stream); - if (first) { // the first segment must NOT have 'continued_packet', later ones MUST - if (f->previous_length) - if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - // if no previous length, we're resynching, so we can come in on a continued-packet, - // which we'll just drop - } else { - if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - } - n = p[26]; // segment counts - q = p+27; // q points to segment table - p = q + n; // advance past header - // make sure we've read the segment table - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - for (s=0; s < n; ++s) { - p += q[s]; - if (q[s] < 255) - break; - } - if (s == n) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - return TRUE; -} -#endif // !STB_VORBIS_NO_PUSHDATA_API - -static int start_decoder(vorb *f) -{ - uint8 header[6], x,y; - int len,i,j,k, max_submaps = 0; - int longest_floorlist=0; - - // first page, first packet - f->first_decode = TRUE; - - if (!start_page(f)) return FALSE; - // validate page flag - if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); - // check for expected packet length - if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); - if (f->segments[0] != 30) { - // check for the Ogg skeleton fishead identifying header to refine our error - if (f->segments[0] == 64 && - getn(f, header, 6) && - header[0] == 'f' && - header[1] == 'i' && - header[2] == 's' && - header[3] == 'h' && - header[4] == 'e' && - header[5] == 'a' && - get8(f) == 'd' && - get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported); - else - return error(f, VORBIS_invalid_first_page); - } - - // read packet - // check packet header - if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); - if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); - // vorbis_version - if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); - f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); - if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); - f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); - get32(f); // bitrate_maximum - get32(f); // bitrate_nominal - get32(f); // bitrate_minimum - x = get8(f); - { - int log0,log1; - log0 = x & 15; - log1 = x >> 4; - f->blocksize_0 = 1 << log0; - f->blocksize_1 = 1 << log1; - if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); - if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); - if (log0 > log1) return error(f, VORBIS_invalid_setup); - } - - // framing_flag - x = get8(f); - if (!(x & 1)) return error(f, VORBIS_invalid_first_page); - - // second packet! - if (!start_page(f)) return FALSE; - - if (!start_packet(f)) return FALSE; - - if (!next_segment(f)) return FALSE; - - if (get8_packet(f) != VORBIS_packet_comment) return error(f, VORBIS_invalid_setup); - for (i=0; i < 6; ++i) header[i] = get8_packet(f); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); - //file vendor - len = get32_packet(f); - f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1)); - if (f->vendor == NULL) return error(f, VORBIS_outofmem); - for(i=0; i < len; ++i) { - f->vendor[i] = get8_packet(f); - } - f->vendor[len] = (char)'\0'; - //user comments - f->comment_list_length = get32_packet(f); - f->comment_list = NULL; - if (f->comment_list_length > 0) - { - f->comment_list = (char**) setup_malloc(f, sizeof(char*) * (f->comment_list_length)); - if (f->comment_list == NULL) return error(f, VORBIS_outofmem); - } - - for(i=0; i < f->comment_list_length; ++i) { - len = get32_packet(f); - f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1)); - if (f->comment_list[i] == NULL) return error(f, VORBIS_outofmem); - - for(j=0; j < len; ++j) { - f->comment_list[i][j] = get8_packet(f); - } - f->comment_list[i][len] = (char)'\0'; - } - - // framing_flag - x = get8_packet(f); - if (!(x & 1)) return error(f, VORBIS_invalid_setup); - - - skip(f, f->bytes_in_seg); - f->bytes_in_seg = 0; - - do { - len = next_segment(f); - skip(f, len); - f->bytes_in_seg = 0; - } while (len); - - // third packet! - if (!start_packet(f)) return FALSE; - - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (IS_PUSH_MODE(f)) { - if (!is_whole_packet_present(f)) { - // convert error in ogg header to write type - if (f->error == VORBIS_invalid_stream) - f->error = VORBIS_invalid_setup; - return FALSE; - } - } - #endif - - crc32_init(); // always init it, to avoid multithread race conditions - - if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); - for (i=0; i < 6; ++i) header[i] = get8_packet(f); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); - - // codebooks - - f->codebook_count = get_bits(f,8) + 1; - f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); - if (f->codebooks == NULL) return error(f, VORBIS_outofmem); - memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); - for (i=0; i < f->codebook_count; ++i) { - uint32 *values; - int ordered, sorted_count; - int total=0; - uint8 *lengths; - Codebook *c = f->codebooks+i; - CHECK(f); - x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); - c->dimensions = (get_bits(f, 8)<<8) + x; - x = get_bits(f, 8); - y = get_bits(f, 8); - c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; - ordered = get_bits(f,1); - c->sparse = ordered ? 0 : get_bits(f,1); - - if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup); - - if (c->sparse) - lengths = (uint8 *) setup_temp_malloc(f, c->entries); - else - lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - - if (!lengths) return error(f, VORBIS_outofmem); - - if (ordered) { - int current_entry = 0; - int current_length = get_bits(f,5) + 1; - while (current_entry < c->entries) { - int limit = c->entries - current_entry; - int n = get_bits(f, ilog(limit)); - if (current_length >= 32) return error(f, VORBIS_invalid_setup); - if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } - memset(lengths + current_entry, current_length, n); - current_entry += n; - ++current_length; - } - } else { - for (j=0; j < c->entries; ++j) { - int present = c->sparse ? get_bits(f,1) : 1; - if (present) { - lengths[j] = get_bits(f, 5) + 1; - ++total; - if (lengths[j] == 32) - return error(f, VORBIS_invalid_setup); - } else { - lengths[j] = NO_CODE; - } - } - } - if (c->sparse && total >= c->entries >> 2) { - // convert sparse items to non-sparse! - if (c->entries > (int) f->setup_temp_memory_required) - f->setup_temp_memory_required = c->entries; - - c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); - memcpy(c->codeword_lengths, lengths, c->entries); - setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! - lengths = c->codeword_lengths; - c->sparse = 0; - } - - // compute the size of the sorted tables - if (c->sparse) { - sorted_count = total; - } else { - sorted_count = 0; - #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH - for (j=0; j < c->entries; ++j) - if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) - ++sorted_count; - #endif - } - - c->sorted_entries = sorted_count; - values = NULL; - - CHECK(f); - if (!c->sparse) { - c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - } else { - unsigned int size; - if (c->sorted_entries) { - c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); - if (!c->codeword_lengths) return error(f, VORBIS_outofmem); - c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); - if (!values) return error(f, VORBIS_outofmem); - } - size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; - if (size > f->setup_temp_memory_required) - f->setup_temp_memory_required = size; - } - - if (!compute_codewords(c, lengths, c->entries, values)) { - if (c->sparse) setup_temp_free(f, values, 0); - return error(f, VORBIS_invalid_setup); - } - - if (c->sorted_entries) { - // allocate an extra slot for sentinels - c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); - if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); - // allocate an extra slot at the front so that c->sorted_values[-1] is defined - // so that we can catch that case without an extra if - c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); - if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); - ++c->sorted_values; - c->sorted_values[-1] = -1; - compute_sorted_huffman(c, lengths, values); - } +static int is_whole_packet_present(stb_vorbis *f) { + // make sure that we have the packet available before continuing... + // this requires a full ogg parse, but we know we can fetch from f->stream + + // instead of coding this out explicitly, we could save the current read state, + // read the next packet with get8() until end-of-packet, check f->eof, then + // reset the state? but that would be slower, esp. since we'd have over 256 bytes + // of state to restore (primarily the page segment table) + + int s = f->next_seg, first = TRUE; + uint8 *p = f->stream; + + if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag + for (; s < f->segment_count; ++s) { + p += f->segments[s]; + if (f->segments[s] < 255) // stop at first short segment + break; + } + // either this continues, or it ends it... + if (s == f->segment_count) + s = -1; // set 'crosses page' flag + if (p > f->stream_end) + return error(f, VORBIS_need_more_data); + first = FALSE; + } + for (; s == -1;) { + uint8 *q; + int n; + + // check that we have the page header ready + if (p + 26 >= f->stream_end) + return error(f, VORBIS_need_more_data); + // validate the page + if (memcmp(p, ogg_page_header, 4)) + return error(f, VORBIS_invalid_stream); + if (p[4] != 0) + return error(f, VORBIS_invalid_stream); + if (first) { // the first segment must NOT have 'continued_packet', later ones MUST + if (f->previous_length) + if ((p[5] & PAGEFLAG_continued_packet)) + return error(f, VORBIS_invalid_stream); + // if no previous length, we're resynching, so we can come in on a continued-packet, + // which we'll just drop + } else { + if (!(p[5] & PAGEFLAG_continued_packet)) + return error(f, VORBIS_invalid_stream); + } + n = p[26]; // segment counts + q = p + 27; // q points to segment table + p = q + n; // advance past header + // make sure we've read the segment table + if (p > f->stream_end) + return error(f, VORBIS_need_more_data); + for (s = 0; s < n; ++s) { + p += q[s]; + if (q[s] < 255) + break; + } + if (s == n) + s = -1; // set 'crosses page' flag + if (p > f->stream_end) + return error(f, VORBIS_need_more_data); + first = FALSE; + } + return TRUE; +} - if (c->sparse) { - setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); - setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); - setup_temp_free(f, lengths, c->entries); - c->codewords = NULL; - } +#endif // !STB_VORBIS_NO_PUSHDATA_API - compute_accelerated_huffman(c); - - CHECK(f); - c->lookup_type = get_bits(f, 4); - if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); - if (c->lookup_type > 0) { - uint16 *mults; - c->minimum_value = float32_unpack(get_bits(f, 32)); - c->delta_value = float32_unpack(get_bits(f, 32)); - c->value_bits = get_bits(f, 4)+1; - c->sequence_p = get_bits(f,1); - if (c->lookup_type == 1) { - int values = lookup1_values(c->entries, c->dimensions); - if (values < 0) return error(f, VORBIS_invalid_setup); - c->lookup_values = (uint32) values; - } else { - c->lookup_values = c->entries * c->dimensions; - } - if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); - mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); - if (mults == NULL) return error(f, VORBIS_outofmem); - for (j=0; j < (int) c->lookup_values; ++j) { - int q = get_bits(f, c->value_bits); - if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } - mults[j] = q; - } +static int start_decoder(vorb *f) { + uint8 header[6], x, y; + int len, i, j, k, max_submaps = 0; + int longest_floorlist = 0; + + // first page, first packet + f->first_decode = TRUE; + + if (!start_page(f)) + return FALSE; + // validate page flag + if (!(f->page_flag & PAGEFLAG_first_page)) + return error(f, VORBIS_invalid_first_page); + if (f->page_flag & PAGEFLAG_last_page) + return error(f, VORBIS_invalid_first_page); + if (f->page_flag & PAGEFLAG_continued_packet) + return error(f, VORBIS_invalid_first_page); + // check for expected packet length + if (f->segment_count != 1) + return error(f, VORBIS_invalid_first_page); + if (f->segments[0] != 30) { + // check for the Ogg skeleton fishead identifying header to refine our error + if (f->segments[0] == 64 && + getn(f, header, 6) && + header[0] == 'f' && + header[1] == 'i' && + header[2] == 's' && + header[3] == 'h' && + header[4] == 'e' && + header[5] == 'a' && + get8(f) == 'd' && + get8(f) == '\0') + return error(f, VORBIS_ogg_skeleton_not_supported); + else + return error(f, VORBIS_invalid_first_page); + } + + // read packet + // check packet header + if (get8(f) != VORBIS_packet_id) + return error(f, VORBIS_invalid_first_page); + if (!getn(f, header, 6)) + return error(f, VORBIS_unexpected_eof); + if (!vorbis_validate(header)) + return error(f, VORBIS_invalid_first_page); + // vorbis_version + if (get32(f) != 0) + return error(f, VORBIS_invalid_first_page); + f->channels = get8(f); + if (!f->channels) + return error(f, VORBIS_invalid_first_page); + if (f->channels > STB_VORBIS_MAX_CHANNELS) + return error(f, VORBIS_too_many_channels); + f->sample_rate = get32(f); + if (!f->sample_rate) + return error(f, VORBIS_invalid_first_page); + get32(f); // bitrate_maximum + get32(f); // bitrate_nominal + get32(f); // bitrate_minimum + x = get8(f); + { + int log0, log1; + log0 = x & 15; + log1 = x >> 4; + f->blocksize_0 = 1 << log0; + f->blocksize_1 = 1 << log1; + if (log0 < 6 || log0 > 13) + return error(f, VORBIS_invalid_setup); + if (log1 < 6 || log1 > 13) + return error(f, VORBIS_invalid_setup); + if (log0 > log1) + return error(f, VORBIS_invalid_setup); + } + + // framing_flag + x = get8(f); + if (!(x & 1)) + return error(f, VORBIS_invalid_first_page); + + // second packet! + if (!start_page(f)) + return FALSE; + + if (!start_packet(f)) + return FALSE; + + if (!next_segment(f)) + return FALSE; + + if (get8_packet(f) != VORBIS_packet_comment) + return error(f, VORBIS_invalid_setup); + for (i = 0; i < 6; ++i) + header[i] = get8_packet(f); + if (!vorbis_validate(header)) + return error(f, VORBIS_invalid_setup); + //file vendor + len = get32_packet(f); + f->vendor = (char *) setup_malloc(f, sizeof(char) * (len + 1)); + if (f->vendor == NULL) + return error(f, VORBIS_outofmem); + for (i = 0; i < len; ++i) { + f->vendor[i] = get8_packet(f); + } + f->vendor[len] = (char) '\0'; + //user comments + f->comment_list_length = get32_packet(f); + f->comment_list = NULL; + if (f->comment_list_length > 0) { + f->comment_list = (char **) setup_malloc(f, sizeof(char *) * (f->comment_list_length)); + if (f->comment_list == NULL) + return error(f, VORBIS_outofmem); + } + + for (i = 0; i < f->comment_list_length; ++i) { + len = get32_packet(f); + f->comment_list[i] = (char *) setup_malloc(f, sizeof(char) * (len + 1)); + if (f->comment_list[i] == NULL) + return error(f, VORBIS_outofmem); + + for (j = 0; j < len; ++j) { + f->comment_list[i][j] = get8_packet(f); + } + f->comment_list[i][len] = (char) '\0'; + } + + // framing_flag + x = get8_packet(f); + if (!(x & 1)) + return error(f, VORBIS_invalid_setup); + + skip(f, f->bytes_in_seg); + f->bytes_in_seg = 0; + + do { + len = next_segment(f); + skip(f, len); + f->bytes_in_seg = 0; + } while (len); + + // third packet! + if (!start_packet(f)) + return FALSE; + + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (IS_PUSH_MODE(f)) { + if (!is_whole_packet_present(f)) { + // convert error in ogg header to write type + if (f->error == VORBIS_invalid_stream) + f->error = VORBIS_invalid_setup; + return FALSE; + } + } + #endif + + crc32_init(); // always init it, to avoid multithread race conditions + + if (get8_packet(f) != VORBIS_packet_setup) + return error(f, VORBIS_invalid_setup); + for (i = 0; i < 6; ++i) + header[i] = get8_packet(f); + if (!vorbis_validate(header)) + return error(f, VORBIS_invalid_setup); + + // codebooks + + f->codebook_count = get_bits(f, 8) + 1; + f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); + if (f->codebooks == NULL) + return error(f, VORBIS_outofmem); + memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); + for (i = 0; i < f->codebook_count; ++i) { + uint32 *values; + int ordered, sorted_count; + int total = 0; + uint8 *lengths; + Codebook *c = f->codebooks + i; + CHECK(f); + x = get_bits(f, 8); + if (x != 0x42) + return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); + if (x != 0x43) + return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); + if (x != 0x56) + return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); + c->dimensions = (get_bits(f, 8) << 8) + x; + x = get_bits(f, 8); + y = get_bits(f, 8); + c->entries = (get_bits(f, 8) << 16) + (y << 8) + x; + ordered = get_bits(f, 1); + c->sparse = ordered ? 0 : get_bits(f, 1); + + if (c->dimensions == 0 && c->entries != 0) + return error(f, VORBIS_invalid_setup); + + if (c->sparse) + lengths = (uint8 *) setup_temp_malloc(f, c->entries); + else + lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); + + if (!lengths) + return error(f, VORBIS_outofmem); + + if (ordered) { + int current_entry = 0; + int current_length = get_bits(f, 5) + 1; + while (current_entry < c->entries) { + int limit = c->entries - current_entry; + int n = get_bits(f, ilog(limit)); + if (current_length >= 32) + return error(f, VORBIS_invalid_setup); + if (current_entry + n > (int) c->entries) { + return error(f, VORBIS_invalid_setup); + } + memset(lengths + current_entry, current_length, n); + current_entry += n; + ++current_length; + } + } else { + for (j = 0; j < c->entries; ++j) { + int present = c->sparse ? get_bits(f, 1) : 1; + if (present) { + lengths[j] = get_bits(f, 5) + 1; + ++total; + if (lengths[j] == 32) + return error(f, VORBIS_invalid_setup); + } else { + lengths[j] = NO_CODE; + } + } + } + + if (c->sparse && total >= c->entries >> 2) { + // convert sparse items to non-sparse! + if (c->entries > (int) f->setup_temp_memory_required) + f->setup_temp_memory_required = c->entries; + + c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); + if (c->codeword_lengths == NULL) + return error(f, VORBIS_outofmem); + memcpy(c->codeword_lengths, lengths, c->entries); + setup_temp_free(f, + lengths, + c->entries); // note this is only safe if there have been no intervening temp mallocs! + lengths = c->codeword_lengths; + c->sparse = 0; + } + + // compute the size of the sorted tables + if (c->sparse) { + sorted_count = total; + } else { + sorted_count = 0; + #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH + for (j = 0; j < c->entries; ++j) + if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) + ++sorted_count; + #endif + } + + c->sorted_entries = sorted_count; + values = NULL; + + CHECK(f); + if (!c->sparse) { + c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); + if (!c->codewords) + return error(f, VORBIS_outofmem); + } else { + unsigned int size; + if (c->sorted_entries) { + c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); + if (!c->codeword_lengths) + return error(f, VORBIS_outofmem); + c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); + if (!c->codewords) + return error(f, VORBIS_outofmem); + values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); + if (!values) + return error(f, VORBIS_outofmem); + } + size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; + if (size > f->setup_temp_memory_required) + f->setup_temp_memory_required = size; + } + + if (!compute_codewords(c, lengths, c->entries, values)) { + if (c->sparse) + setup_temp_free(f, values, 0); + return error(f, VORBIS_invalid_setup); + } + + if (c->sorted_entries) { + // allocate an extra slot for sentinels + c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries + 1)); + if (c->sorted_codewords == NULL) + return error(f, VORBIS_outofmem); + // allocate an extra slot at the front so that c->sorted_values[-1] is defined + // so that we can catch that case without an extra if + c->sorted_values = (int *) setup_malloc(f, sizeof(*c->sorted_values) * (c->sorted_entries + 1)); + if (c->sorted_values == NULL) + return error(f, VORBIS_outofmem); + ++c->sorted_values; + c->sorted_values[-1] = -1; + compute_sorted_huffman(c, lengths, values); + } + + if (c->sparse) { + setup_temp_free(f, values, sizeof(*values) * c->sorted_entries); + setup_temp_free(f, c->codewords, sizeof(*c->codewords) * c->sorted_entries); + setup_temp_free(f, lengths, c->entries); + c->codewords = NULL; + } + + compute_accelerated_huffman(c); + + CHECK(f); + c->lookup_type = get_bits(f, 4); + if (c->lookup_type > 2) + return error(f, VORBIS_invalid_setup); + if (c->lookup_type > 0) { + uint16 *mults; + c->minimum_value = float32_unpack(get_bits(f, 32)); + c->delta_value = float32_unpack(get_bits(f, 32)); + c->value_bits = get_bits(f, 4) + 1; + c->sequence_p = get_bits(f, 1); + if (c->lookup_type == 1) { + int values = lookup1_values(c->entries, c->dimensions); + if (values < 0) + return error(f, VORBIS_invalid_setup); + c->lookup_values = (uint32) values; + } else { + c->lookup_values = c->entries * c->dimensions; + } + if (c->lookup_values == 0) + return error(f, VORBIS_invalid_setup); + mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); + if (mults == NULL) + return error(f, VORBIS_outofmem); + for (j = 0; j < (int) c->lookup_values; ++j) { + int q = get_bits(f, c->value_bits); + if (q == EOP) { + setup_temp_free(f, mults, sizeof(mults[0]) * c->lookup_values); + return error(f, VORBIS_invalid_setup); + } + mults[j] = q; + } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int len, sparse = c->sparse; - float last=0; - // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop - if (sparse) { - if (c->sorted_entries == 0) goto skip; - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); - } else - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); - if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } - len = sparse ? c->sorted_entries : c->entries; - for (j=0; j < len; ++j) { - unsigned int z = sparse ? c->sorted_values[j] : j; - unsigned int div=1; - for (k=0; k < c->dimensions; ++k) { - int off = (z / div) % c->lookup_values; - float val = mults[off]*c->delta_value + c->minimum_value + last; - c->multiplicands[j*c->dimensions + k] = val; - if (c->sequence_p) - last = val; - if (k+1 < c->dimensions) { - if (div > UINT_MAX / (unsigned int) c->lookup_values) { - setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); - return error(f, VORBIS_invalid_setup); - } - div *= c->lookup_values; - } - } - } - c->lookup_type = 2; - } - else + if (c->lookup_type == 1) { + int len, sparse = c->sparse; + float last = 0; + // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop + if (sparse) { + if (c->sorted_entries == 0) + goto skip; + c->multiplicands = + (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); + } else + c->multiplicands = + (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); + if (c->multiplicands == NULL) { + setup_temp_free(f, mults, sizeof(mults[0]) * c->lookup_values); + return error(f, VORBIS_outofmem); + } + len = sparse ? c->sorted_entries : c->entries; + for (j = 0; j < len; ++j) { + unsigned int z = sparse ? c->sorted_values[j] : j; + unsigned int div = 1; + for (k = 0; k < c->dimensions; ++k) { + int off = (z / div) % c->lookup_values; + float val = mults[off] * c->delta_value + c->minimum_value + last; + c->multiplicands[j * c->dimensions + k] = val; + if (c->sequence_p) + last = val; + if (k + 1 < c->dimensions) { + if (div > UINT_MAX / (unsigned int) c->lookup_values) { + setup_temp_free(f, mults, sizeof(mults[0]) * c->lookup_values); + return error(f, VORBIS_invalid_setup); + } + div *= c->lookup_values; + } + } + } + c->lookup_type = 2; + } else #endif - { - float last=0; - CHECK(f); - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); - if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } - for (j=0; j < (int) c->lookup_values; ++j) { - float val = mults[j] * c->delta_value + c->minimum_value + last; - c->multiplicands[j] = val; - if (c->sequence_p) - last = val; - } - } + { + float last = 0; + CHECK(f); + c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); + if (c->multiplicands == NULL) { + setup_temp_free(f, mults, sizeof(mults[0]) * c->lookup_values); + return error(f, VORBIS_outofmem); + } + for (j = 0; j < (int) c->lookup_values; ++j) { + float val = mults[j] * c->delta_value + c->minimum_value + last; + c->multiplicands[j] = val; + if (c->sequence_p) + last = val; + } + } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - skip:; + skip:; #endif - setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values); - - CHECK(f); - } - CHECK(f); - } - - // time domain transfers (notused) - - x = get_bits(f, 6) + 1; - for (i=0; i < x; ++i) { - uint32 z = get_bits(f, 16); - if (z != 0) return error(f, VORBIS_invalid_setup); - } - - // Floors - f->floor_count = get_bits(f, 6)+1; - f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); - if (f->floor_config == NULL) return error(f, VORBIS_outofmem); - for (i=0; i < f->floor_count; ++i) { - f->floor_types[i] = get_bits(f, 16); - if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); - if (f->floor_types[i] == 0) { - Floor0 *g = &f->floor_config[i].floor0; - g->order = get_bits(f,8); - g->rate = get_bits(f,16); - g->bark_map_size = get_bits(f,16); - g->amplitude_bits = get_bits(f,6); - g->amplitude_offset = get_bits(f,8); - g->number_of_books = get_bits(f,4) + 1; - for (j=0; j < g->number_of_books; ++j) - g->book_list[j] = get_bits(f,8); - return error(f, VORBIS_feature_not_supported); - } else { - stbv__floor_ordering p[31*8+2]; - Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; - g->partitions = get_bits(f, 5); - for (j=0; j < g->partitions; ++j) { - g->partition_class_list[j] = get_bits(f, 4); - if (g->partition_class_list[j] > max_class) - max_class = g->partition_class_list[j]; - } - for (j=0; j <= max_class; ++j) { - g->class_dimensions[j] = get_bits(f, 3)+1; - g->class_subclasses[j] = get_bits(f, 2); - if (g->class_subclasses[j]) { - g->class_masterbooks[j] = get_bits(f, 8); - if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - for (k=0; k < 1 << g->class_subclasses[j]; ++k) { - g->subclass_books[j][k] = (int16)get_bits(f,8)-1; - if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - } - g->floor1_multiplier = get_bits(f,2)+1; - g->rangebits = get_bits(f,4); - g->Xlist[0] = 0; - g->Xlist[1] = 1 << g->rangebits; - g->values = 2; - for (j=0; j < g->partitions; ++j) { - int c = g->partition_class_list[j]; - for (k=0; k < g->class_dimensions[c]; ++k) { - g->Xlist[g->values] = get_bits(f, g->rangebits); - ++g->values; - } - } - // precompute the sorting - for (j=0; j < g->values; ++j) { - p[j].x = g->Xlist[j]; - p[j].id = j; - } - qsort(p, g->values, sizeof(p[0]), point_compare); - for (j=0; j < g->values-1; ++j) - if (p[j].x == p[j+1].x) - return error(f, VORBIS_invalid_setup); - for (j=0; j < g->values; ++j) - g->sorted_order[j] = (uint8) p[j].id; - // precompute the neighbors - for (j=2; j < g->values; ++j) { - int low = 0,hi = 0; - neighbors(g->Xlist, j, &low,&hi); - g->neighbors[j][0] = low; - g->neighbors[j][1] = hi; - } - - if (g->values > longest_floorlist) - longest_floorlist = g->values; - } - } - - // Residue - f->residue_count = get_bits(f, 6)+1; - f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); - if (f->residue_config == NULL) return error(f, VORBIS_outofmem); - memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); - for (i=0; i < f->residue_count; ++i) { - uint8 residue_cascade[64]; - Residue *r = f->residue_config+i; - f->residue_types[i] = get_bits(f, 16); - if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); - r->begin = get_bits(f, 24); - r->end = get_bits(f, 24); - if (r->end < r->begin) return error(f, VORBIS_invalid_setup); - r->part_size = get_bits(f,24)+1; - r->classifications = get_bits(f,6)+1; - r->classbook = get_bits(f,8); - if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup); - for (j=0; j < r->classifications; ++j) { - uint8 high_bits=0; - uint8 low_bits=get_bits(f,3); - if (get_bits(f,1)) - high_bits = get_bits(f,5); - residue_cascade[j] = high_bits*8 + low_bits; - } - r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); - if (r->residue_books == NULL) return error(f, VORBIS_outofmem); - for (j=0; j < r->classifications; ++j) { - for (k=0; k < 8; ++k) { - if (residue_cascade[j] & (1 << k)) { - r->residue_books[j][k] = get_bits(f, 8); - if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } else { - r->residue_books[j][k] = -1; - } - } - } - // precompute the classifications[] array to avoid inner-loop mod/divide - // call it 'classdata' since we already have r->classifications - r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - if (!r->classdata) return error(f, VORBIS_outofmem); - memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - for (j=0; j < f->codebooks[r->classbook].entries; ++j) { - int classwords = f->codebooks[r->classbook].dimensions; - int temp = j; - r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); - if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); - for (k=classwords-1; k >= 0; --k) { - r->classdata[j][k] = temp % r->classifications; - temp /= r->classifications; - } - } - } - - f->mapping_count = get_bits(f,6)+1; - f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); - if (f->mapping == NULL) return error(f, VORBIS_outofmem); - memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); - for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; - int mapping_type = get_bits(f,16); - if (mapping_type != 0) return error(f, VORBIS_invalid_setup); - m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); - if (m->chan == NULL) return error(f, VORBIS_outofmem); - if (get_bits(f,1)) - m->submaps = get_bits(f,4)+1; - else - m->submaps = 1; - if (m->submaps > max_submaps) - max_submaps = m->submaps; - if (get_bits(f,1)) { - m->coupling_steps = get_bits(f,8)+1; - if (m->coupling_steps > f->channels) return error(f, VORBIS_invalid_setup); - for (k=0; k < m->coupling_steps; ++k) { - m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); - m->chan[k].angle = get_bits(f, ilog(f->channels-1)); - if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); - } - } else - m->coupling_steps = 0; - - // reserved field - if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); - if (m->submaps > 1) { - for (j=0; j < f->channels; ++j) { - m->chan[j].mux = get_bits(f, 4); - if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); - } - } else - // @SPECIFICATION: this case is missing from the spec - for (j=0; j < f->channels; ++j) - m->chan[j].mux = 0; - - for (j=0; j < m->submaps; ++j) { - get_bits(f,8); // discard - m->submap_floor[j] = get_bits(f,8); - m->submap_residue[j] = get_bits(f,8); - if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); - if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); - } - } - - // Modes - f->mode_count = get_bits(f, 6)+1; - for (i=0; i < f->mode_count; ++i) { - Mode *m = f->mode_config+i; - m->blockflag = get_bits(f,1); - m->windowtype = get_bits(f,16); - m->transformtype = get_bits(f,16); - m->mapping = get_bits(f,8); - if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); - if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); - if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); - } - - flush_packet(f); - - f->previous_length = 0; - - for (i=0; i < f->channels; ++i) { - f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); - f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); - if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); - memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); + setup_temp_free(f, mults, sizeof(mults[0]) * c->lookup_values); + + CHECK(f); + } + CHECK(f); + } + + // time domain transfers (notused) + + x = get_bits(f, 6) + 1; + for (i = 0; i < x; ++i) { + uint32 z = get_bits(f, 16); + if (z != 0) + return error(f, VORBIS_invalid_setup); + } + + // Floors + f->floor_count = get_bits(f, 6) + 1; + f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); + if (f->floor_config == NULL) + return error(f, VORBIS_outofmem); + for (i = 0; i < f->floor_count; ++i) { + f->floor_types[i] = get_bits(f, 16); + if (f->floor_types[i] > 1) + return error(f, VORBIS_invalid_setup); + if (f->floor_types[i] == 0) { + Floor0 *g = &f->floor_config[i].floor0; + g->order = get_bits(f, 8); + g->rate = get_bits(f, 16); + g->bark_map_size = get_bits(f, 16); + g->amplitude_bits = get_bits(f, 6); + g->amplitude_offset = get_bits(f, 8); + g->number_of_books = get_bits(f, 4) + 1; + for (j = 0; j < g->number_of_books; ++j) + g->book_list[j] = get_bits(f, 8); + return error(f, VORBIS_feature_not_supported); + } else { + stbv__floor_ordering p[31 * 8 + 2]; + Floor1 *g = &f->floor_config[i].floor1; + int max_class = -1; + g->partitions = get_bits(f, 5); + for (j = 0; j < g->partitions; ++j) { + g->partition_class_list[j] = get_bits(f, 4); + if (g->partition_class_list[j] > max_class) + max_class = g->partition_class_list[j]; + } + for (j = 0; j <= max_class; ++j) { + g->class_dimensions[j] = get_bits(f, 3) + 1; + g->class_subclasses[j] = get_bits(f, 2); + if (g->class_subclasses[j]) { + g->class_masterbooks[j] = get_bits(f, 8); + if (g->class_masterbooks[j] >= f->codebook_count) + return error(f, VORBIS_invalid_setup); + } + for (k = 0; k < 1 << g->class_subclasses[j]; ++k) { + g->subclass_books[j][k] = (int16) get_bits(f, 8) - 1; + if (g->subclass_books[j][k] >= f->codebook_count) + return error(f, VORBIS_invalid_setup); + } + } + g->floor1_multiplier = get_bits(f, 2) + 1; + g->rangebits = get_bits(f, 4); + g->Xlist[0] = 0; + g->Xlist[1] = 1 << g->rangebits; + g->values = 2; + for (j = 0; j < g->partitions; ++j) { + int c = g->partition_class_list[j]; + for (k = 0; k < g->class_dimensions[c]; ++k) { + g->Xlist[g->values] = get_bits(f, g->rangebits); + ++g->values; + } + } + // precompute the sorting + for (j = 0; j < g->values; ++j) { + p[j].x = g->Xlist[j]; + p[j].id = j; + } + qsort(p, g->values, sizeof(p[0]), point_compare); + for (j = 0; j < g->values - 1; ++j) + if (p[j].x == p[j + 1].x) + return error(f, VORBIS_invalid_setup); + for (j = 0; j < g->values; ++j) + g->sorted_order[j] = (uint8) p[j].id; + // precompute the neighbors + for (j = 2; j < g->values; ++j) { + int low = 0, hi = 0; + neighbors(g->Xlist, j, &low, &hi); + g->neighbors[j][0] = low; + g->neighbors[j][1] = hi; + } + + if (g->values > longest_floorlist) + longest_floorlist = g->values; + } + } + + // Residue + f->residue_count = get_bits(f, 6) + 1; + f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); + if (f->residue_config == NULL) + return error(f, VORBIS_outofmem); + memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); + for (i = 0; i < f->residue_count; ++i) { + uint8 residue_cascade[64]; + Residue *r = f->residue_config + i; + f->residue_types[i] = get_bits(f, 16); + if (f->residue_types[i] > 2) + return error(f, VORBIS_invalid_setup); + r->begin = get_bits(f, 24); + r->end = get_bits(f, 24); + if (r->end < r->begin) + return error(f, VORBIS_invalid_setup); + r->part_size = get_bits(f, 24) + 1; + r->classifications = get_bits(f, 6) + 1; + r->classbook = get_bits(f, 8); + if (r->classbook >= f->codebook_count) + return error(f, VORBIS_invalid_setup); + for (j = 0; j < r->classifications; ++j) { + uint8 high_bits = 0; + uint8 low_bits = get_bits(f, 3); + if (get_bits(f, 1)) + high_bits = get_bits(f, 5); + residue_cascade[j] = high_bits * 8 + low_bits; + } + r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); + if (r->residue_books == NULL) + return error(f, VORBIS_outofmem); + for (j = 0; j < r->classifications; ++j) { + for (k = 0; k < 8; ++k) { + if (residue_cascade[j] & (1 << k)) { + r->residue_books[j][k] = get_bits(f, 8); + if (r->residue_books[j][k] >= f->codebook_count) + return error(f, VORBIS_invalid_setup); + } else { + r->residue_books[j][k] = -1; + } + } + } + // precompute the classifications[] array to avoid inner-loop mod/divide + // call it 'classdata' since we already have r->classifications + r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); + if (!r->classdata) + return error(f, VORBIS_outofmem); + memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); + for (j = 0; j < f->codebooks[r->classbook].entries; ++j) { + int classwords = f->codebooks[r->classbook].dimensions; + int temp = j; + r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); + if (r->classdata[j] == NULL) + return error(f, VORBIS_outofmem); + for (k = classwords - 1; k >= 0; --k) { + r->classdata[j][k] = temp % r->classifications; + temp /= r->classifications; + } + } + } + + f->mapping_count = get_bits(f, 6) + 1; + f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); + if (f->mapping == NULL) + return error(f, VORBIS_outofmem); + memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); + for (i = 0; i < f->mapping_count; ++i) { + Mapping *m = f->mapping + i; + int mapping_type = get_bits(f, 16); + if (mapping_type != 0) + return error(f, VORBIS_invalid_setup); + m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); + if (m->chan == NULL) + return error(f, VORBIS_outofmem); + if (get_bits(f, 1)) + m->submaps = get_bits(f, 4) + 1; + else + m->submaps = 1; + if (m->submaps > max_submaps) + max_submaps = m->submaps; + if (get_bits(f, 1)) { + m->coupling_steps = get_bits(f, 8) + 1; + if (m->coupling_steps > f->channels) + return error(f, VORBIS_invalid_setup); + for (k = 0; k < m->coupling_steps; ++k) { + m->chan[k].magnitude = get_bits(f, ilog(f->channels - 1)); + m->chan[k].angle = get_bits(f, ilog(f->channels - 1)); + if (m->chan[k].magnitude >= f->channels) + return error(f, VORBIS_invalid_setup); + if (m->chan[k].angle >= f->channels) + return error(f, VORBIS_invalid_setup); + if (m->chan[k].magnitude == m->chan[k].angle) + return error(f, VORBIS_invalid_setup); + } + } else + m->coupling_steps = 0; + + // reserved field + if (get_bits(f, 2)) + return error(f, VORBIS_invalid_setup); + if (m->submaps > 1) { + for (j = 0; j < f->channels; ++j) { + m->chan[j].mux = get_bits(f, 4); + if (m->chan[j].mux >= m->submaps) + return error(f, VORBIS_invalid_setup); + } + } else + // @SPECIFICATION: this case is missing from the spec + for (j = 0; j < f->channels; ++j) + m->chan[j].mux = 0; + + for (j = 0; j < m->submaps; ++j) { + get_bits(f, 8); // discard + m->submap_floor[j] = get_bits(f, 8); + m->submap_residue[j] = get_bits(f, 8); + if (m->submap_floor[j] >= f->floor_count) + return error(f, VORBIS_invalid_setup); + if (m->submap_residue[j] >= f->residue_count) + return error(f, VORBIS_invalid_setup); + } + } + + // Modes + f->mode_count = get_bits(f, 6) + 1; + for (i = 0; i < f->mode_count; ++i) { + Mode *m = f->mode_config + i; + m->blockflag = get_bits(f, 1); + m->windowtype = get_bits(f, 16); + m->transformtype = get_bits(f, 16); + m->mapping = get_bits(f, 8); + if (m->windowtype != 0) + return error(f, VORBIS_invalid_setup); + if (m->transformtype != 0) + return error(f, VORBIS_invalid_setup); + if (m->mapping >= f->mapping_count) + return error(f, VORBIS_invalid_setup); + } + + flush_packet(f); + + f->previous_length = 0; + + for (i = 0; i < f->channels; ++i) { + f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); + f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1 / 2); + f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); + if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) + return error(f, VORBIS_outofmem); + memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1); + #ifdef STB_VORBIS_NO_DEFER_FLOOR + f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); - #endif - } + #endif + } - if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; - if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; - f->blocksize[0] = f->blocksize_0; - f->blocksize[1] = f->blocksize_1; + if (!init_blocksize(f, 0, f->blocksize_0)) + return FALSE; + if (!init_blocksize(f, 1, f->blocksize_1)) + return FALSE; + f->blocksize[0] = f->blocksize_0; + f->blocksize[1] = f->blocksize_1; #ifdef STB_VORBIS_DIVIDE_TABLE - if (integer_divide_table[1][1]==0) + if (integer_divide_table[1][1]==0) for (i=0; i < DIVTAB_NUMER; ++i) for (j=1; j < DIVTAB_DENOM; ++j) integer_divide_table[i][j] = i / j; #endif - // compute how much temporary memory is needed - - // 1. - { - uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); - uint32 classify_mem; - int i,max_part_read=0; - for (i=0; i < f->residue_count; ++i) { - Residue *r = f->residue_config + i; - unsigned int actual_size = f->blocksize_1 / 2; - unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size; - unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size; - int n_read = limit_r_end - limit_r_begin; - int part_read = n_read / r->part_size; - if (part_read > max_part_read) - max_part_read = part_read; - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); - #else - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); - #endif - - // maximum reasonable partition size is f->blocksize_1 - - f->temp_memory_required = classify_mem; - if (imdct_mem > f->temp_memory_required) - f->temp_memory_required = imdct_mem; - } - - - if (f->alloc.alloc_buffer) { - assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); - // check if there's enough temp memory so we don't error later - if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) - return error(f, VORBIS_outofmem); - } - - // @TODO: stb_vorbis_seek_start expects first_audio_page_offset to point to a page - // without PAGEFLAG_continued_packet, so this either points to the first page, or - // the page after the end of the headers. It might be cleaner to point to a page - // in the middle of the headers, when that's the page where the first audio packet - // starts, but we'd have to also correctly skip the end of any continued packet in - // stb_vorbis_seek_start. - if (f->next_seg == -1) { - f->first_audio_page_offset = stb_vorbis_get_file_offset(f); - } else { - f->first_audio_page_offset = 0; - } - - return TRUE; + // compute how much temporary memory is needed + + // 1. + { + uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); + uint32 classify_mem; + int i, max_part_read = 0; + for (i = 0; i < f->residue_count; ++i) { + Residue *r = f->residue_config + i; + unsigned int actual_size = f->blocksize_1 / 2; + unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size; + unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size; + int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + if (part_read > max_part_read) + max_part_read = part_read; + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + classify_mem = f->channels * (sizeof(void *) + max_part_read * sizeof(uint8 *)); + #else + classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); + #endif + + // maximum reasonable partition size is f->blocksize_1 + + f->temp_memory_required = classify_mem; + if (imdct_mem > f->temp_memory_required) + f->temp_memory_required = imdct_mem; + } + + if (f->alloc.alloc_buffer) { + assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); + // check if there's enough temp memory so we don't error later + if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) + return error(f, VORBIS_outofmem); + } + + // @TODO: stb_vorbis_seek_start expects first_audio_page_offset to point to a page + // without PAGEFLAG_continued_packet, so this either points to the first page, or + // the page after the end of the headers. It might be cleaner to point to a page + // in the middle of the headers, when that's the page where the first audio packet + // starts, but we'd have to also correctly skip the end of any continued packet in + // stb_vorbis_seek_start. + if (f->next_seg == -1) { + f->first_audio_page_offset = stb_vorbis_get_file_offset(f); + } else { + f->first_audio_page_offset = 0; + } + + return TRUE; } -static void vorbis_deinit(stb_vorbis *p) -{ - int i,j; - - setup_free(p, p->vendor); - for (i=0; i < p->comment_list_length; ++i) { - setup_free(p, p->comment_list[i]); - } - setup_free(p, p->comment_list); - - if (p->residue_config) { - for (i=0; i < p->residue_count; ++i) { - Residue *r = p->residue_config+i; - if (r->classdata) { - for (j=0; j < p->codebooks[r->classbook].entries; ++j) - setup_free(p, r->classdata[j]); - setup_free(p, r->classdata); - } - setup_free(p, r->residue_books); - } - } - - if (p->codebooks) { - CHECK(p); - for (i=0; i < p->codebook_count; ++i) { - Codebook *c = p->codebooks + i; - setup_free(p, c->codeword_lengths); - setup_free(p, c->multiplicands); - setup_free(p, c->codewords); - setup_free(p, c->sorted_codewords); - // c->sorted_values[-1] is the first entry in the array - setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); - } - setup_free(p, p->codebooks); - } - setup_free(p, p->floor_config); - setup_free(p, p->residue_config); - if (p->mapping) { - for (i=0; i < p->mapping_count; ++i) - setup_free(p, p->mapping[i].chan); - setup_free(p, p->mapping); - } - CHECK(p); - for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) { - setup_free(p, p->channel_buffers[i]); - setup_free(p, p->previous_window[i]); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - setup_free(p, p->floor_buffers[i]); - #endif - setup_free(p, p->finalY[i]); - } - for (i=0; i < 2; ++i) { - setup_free(p, p->A[i]); - setup_free(p, p->B[i]); - setup_free(p, p->C[i]); - setup_free(p, p->window[i]); - setup_free(p, p->bit_reverse[i]); - } - #ifndef STB_VORBIS_NO_STDIO - if (p->close_on_free) fclose(p->f); - #endif +static void vorbis_deinit(stb_vorbis *p) { + int i, j; + + setup_free(p, p->vendor); + for (i = 0; i < p->comment_list_length; ++i) { + setup_free(p, p->comment_list[i]); + } + setup_free(p, p->comment_list); + + if (p->residue_config) { + for (i = 0; i < p->residue_count; ++i) { + Residue *r = p->residue_config + i; + if (r->classdata) { + for (j = 0; j < p->codebooks[r->classbook].entries; ++j) + setup_free(p, r->classdata[j]); + setup_free(p, r->classdata); + } + setup_free(p, r->residue_books); + } + } + + if (p->codebooks) { + CHECK(p); + for (i = 0; i < p->codebook_count; ++i) { + Codebook *c = p->codebooks + i; + setup_free(p, c->codeword_lengths); + setup_free(p, c->multiplicands); + setup_free(p, c->codewords); + setup_free(p, c->sorted_codewords); + // c->sorted_values[-1] is the first entry in the array + setup_free(p, c->sorted_values ? c->sorted_values - 1 : NULL); + } + setup_free(p, p->codebooks); + } + setup_free(p, p->floor_config); + setup_free(p, p->residue_config); + if (p->mapping) { + for (i = 0; i < p->mapping_count; ++i) + setup_free(p, p->mapping[i].chan); + setup_free(p, p->mapping); + } + CHECK(p); + for (i = 0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) { + setup_free(p, p->channel_buffers[i]); + setup_free(p, p->previous_window[i]); + #ifdef STB_VORBIS_NO_DEFER_FLOOR + setup_free(p, p->floor_buffers[i]); + #endif + setup_free(p, p->finalY[i]); + } + for (i = 0; i < 2; ++i) { + setup_free(p, p->A[i]); + setup_free(p, p->B[i]); + setup_free(p, p->C[i]); + setup_free(p, p->window[i]); + setup_free(p, p->bit_reverse[i]); + } + #ifndef STB_VORBIS_NO_STDIO + if (p->close_on_free) + fclose(p->f); + #endif } -void stb_vorbis_close(stb_vorbis *p) -{ - if (p == NULL) return; - vorbis_deinit(p); - setup_free(p,p); +void stb_vorbis_close(stb_vorbis *p) { + if (p == NULL) + return; + vorbis_deinit(p); + setup_free(p, p); } -static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) -{ - memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start - if (z) { - p->alloc = *z; - p->alloc.alloc_buffer_length_in_bytes &= ~7; - p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; - } - p->eof = 0; - p->error = VORBIS__no_error; - p->stream = NULL; - p->codebooks = NULL; - p->page_crc_tests = -1; - #ifndef STB_VORBIS_NO_STDIO - p->close_on_free = FALSE; - p->f = NULL; - #endif +static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) { + memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start + if (z) { + p->alloc = *z; + p->alloc.alloc_buffer_length_in_bytes &= ~7; + p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; + } + p->eof = 0; + p->error = VORBIS__no_error; + p->stream = NULL; + p->codebooks = NULL; + p->page_crc_tests = -1; + #ifndef STB_VORBIS_NO_STDIO + p->close_on_free = FALSE; + p->f = NULL; + #endif } -int stb_vorbis_get_sample_offset(stb_vorbis *f) -{ - if (f->current_loc_valid) - return f->current_loc; - else - return -1; +int stb_vorbis_get_sample_offset(stb_vorbis *f) { + if (f->current_loc_valid) + return f->current_loc; + else + return -1; } -stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) -{ - stb_vorbis_info d; - d.channels = f->channels; - d.sample_rate = f->sample_rate; - d.setup_memory_required = f->setup_memory_required; - d.setup_temp_memory_required = f->setup_temp_memory_required; - d.temp_memory_required = f->temp_memory_required; - d.max_frame_size = f->blocksize_1 >> 1; - return d; +stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) { + stb_vorbis_info d; + d.channels = f->channels; + d.sample_rate = f->sample_rate; + d.setup_memory_required = f->setup_memory_required; + d.setup_temp_memory_required = f->setup_temp_memory_required; + d.temp_memory_required = f->temp_memory_required; + d.max_frame_size = f->blocksize_1 >> 1; + return d; } -stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f) -{ - stb_vorbis_comment d; - d.vendor = f->vendor; - d.comment_list_length = f->comment_list_length; - d.comment_list = f->comment_list; - return d; +stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f) { + stb_vorbis_comment d; + d.vendor = f->vendor; + d.comment_list_length = f->comment_list_length; + d.comment_list = f->comment_list; + return d; } -int stb_vorbis_get_error(stb_vorbis *f) -{ - int e = f->error; - f->error = VORBIS__no_error; - return e; +int stb_vorbis_get_error(stb_vorbis *f) { + int e = f->error; + f->error = VORBIS__no_error; + return e; } -static stb_vorbis * vorbis_alloc(stb_vorbis *f) -{ - stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); - return p; +static stb_vorbis *vorbis_alloc(stb_vorbis *f) { + stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); + return p; } #ifndef STB_VORBIS_NO_PUSHDATA_API -void stb_vorbis_flush_pushdata(stb_vorbis *f) -{ - f->previous_length = 0; - f->page_crc_tests = 0; - f->discard_samples_deferred = 0; - f->current_loc_valid = FALSE; - f->first_decode = FALSE; - f->samples_output = 0; - f->channel_buffer_start = 0; - f->channel_buffer_end = 0; +void stb_vorbis_flush_pushdata(stb_vorbis *f) { + f->previous_length = 0; + f->page_crc_tests = 0; + f->discard_samples_deferred = 0; + f->current_loc_valid = FALSE; + f->first_decode = FALSE; + f->samples_output = 0; + f->channel_buffer_start = 0; + f->channel_buffer_end = 0; } -static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) -{ - int i,n; - for (i=0; i < f->page_crc_tests; ++i) - f->scan[i].bytes_done = 0; - - // if we have room for more scans, search for them first, because - // they may cause us to stop early if their header is incomplete - if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { - if (data_len < 4) return 0; - data_len -= 3; // need to look for 4-byte sequence, so don't miss - // one that straddles a boundary - for (i=0; i < data_len; ++i) { - if (data[i] == 0x4f) { - if (0==memcmp(data+i, ogg_page_header, 4)) { - int j,len; - uint32 crc; - // make sure we have the whole page header - if (i+26 >= data_len || i+27+data[i+26] >= data_len) { - // only read up to this page start, so hopefully we'll - // have the whole page header start next time - data_len = i; - break; - } - // ok, we have it all; compute the length of the page - len = 27 + data[i+26]; - for (j=0; j < data[i+26]; ++j) - len += data[i+27+j]; - // scan everything up to the embedded crc (which we must 0) - crc = 0; - for (j=0; j < 22; ++j) - crc = crc32_update(crc, data[i+j]); - // now process 4 0-bytes - for ( ; j < 26; ++j) - crc = crc32_update(crc, 0); - // len is the total number of bytes we need to scan - n = f->page_crc_tests++; - f->scan[n].bytes_left = len-j; - f->scan[n].crc_so_far = crc; - f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); - // if the last frame on a page is continued to the next, then - // we can't recover the sample_loc immediately - if (data[i+27+data[i+26]-1] == 255) - f->scan[n].sample_loc = ~0; - else - f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); - f->scan[n].bytes_done = i+j; - if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) - break; - // keep going if we still have room for more - } - } - } - } - - for (i=0; i < f->page_crc_tests;) { - uint32 crc; - int j; - int n = f->scan[i].bytes_done; - int m = f->scan[i].bytes_left; - if (m > data_len - n) m = data_len - n; - // m is the bytes to scan in the current chunk - crc = f->scan[i].crc_so_far; - for (j=0; j < m; ++j) - crc = crc32_update(crc, data[n+j]); - f->scan[i].bytes_left -= m; - f->scan[i].crc_so_far = crc; - if (f->scan[i].bytes_left == 0) { - // does it match? - if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { - // Houston, we have page - data_len = n+m; // consumption amount is wherever that scan ended - f->page_crc_tests = -1; // drop out of page scan mode - f->previous_length = 0; // decode-but-don't-output one frame - f->next_seg = -1; // start a new page - f->current_loc = f->scan[i].sample_loc; // set the current sample location - // to the amount we'd have decoded had we decoded this page - f->current_loc_valid = f->current_loc != ~0U; - return data_len; - } - // delete entry - f->scan[i] = f->scan[--f->page_crc_tests]; - } else { - ++i; - } - } - - return data_len; +static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) { + int i, n; + for (i = 0; i < f->page_crc_tests; ++i) + f->scan[i].bytes_done = 0; + + // if we have room for more scans, search for them first, because + // they may cause us to stop early if their header is incomplete + if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { + if (data_len < 4) + return 0; + data_len -= 3; // need to look for 4-byte sequence, so don't miss + // one that straddles a boundary + for (i = 0; i < data_len; ++i) { + if (data[i] == 0x4f) { + if (0 == memcmp(data + i, ogg_page_header, 4)) { + int j, len; + uint32 crc; + // make sure we have the whole page header + if (i + 26 >= data_len || i + 27 + data[i + 26] >= data_len) { + // only read up to this page start, so hopefully we'll + // have the whole page header start next time + data_len = i; + break; + } + // ok, we have it all; compute the length of the page + len = 27 + data[i + 26]; + for (j = 0; j < data[i + 26]; ++j) + len += data[i + 27 + j]; + // scan everything up to the embedded crc (which we must 0) + crc = 0; + for (j = 0; j < 22; ++j) + crc = crc32_update(crc, data[i + j]); + // now process 4 0-bytes + for (; j < 26; ++j) + crc = crc32_update(crc, 0); + // len is the total number of bytes we need to scan + n = f->page_crc_tests++; + f->scan[n].bytes_left = len - j; + f->scan[n].crc_so_far = crc; + f->scan[n].goal_crc = + data[i + 22] + (data[i + 23] << 8) + (data[i + 24] << 16) + (data[i + 25] << 24); + // if the last frame on a page is continued to the next, then + // we can't recover the sample_loc immediately + if (data[i + 27 + data[i + 26] - 1] == 255) + f->scan[n].sample_loc = ~0; + else + f->scan[n].sample_loc = + data[i + 6] + (data[i + 7] << 8) + (data[i + 8] << 16) + (data[i + 9] << 24); + f->scan[n].bytes_done = i + j; + if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) + break; + // keep going if we still have room for more + } + } + } + } + + for (i = 0; i < f->page_crc_tests;) { + uint32 crc; + int j; + int n = f->scan[i].bytes_done; + int m = f->scan[i].bytes_left; + if (m > data_len - n) + m = data_len - n; + // m is the bytes to scan in the current chunk + crc = f->scan[i].crc_so_far; + for (j = 0; j < m; ++j) + crc = crc32_update(crc, data[n + j]); + f->scan[i].bytes_left -= m; + f->scan[i].crc_so_far = crc; + if (f->scan[i].bytes_left == 0) { + // does it match? + if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { + // Houston, we have page + data_len = n + m; // consumption amount is wherever that scan ended + f->page_crc_tests = -1; // drop out of page scan mode + f->previous_length = 0; // decode-but-don't-output one frame + f->next_seg = -1; // start a new page + f->current_loc = f->scan[i].sample_loc; // set the current sample location + // to the amount we'd have decoded had we decoded this page + f->current_loc_valid = f->current_loc != ~0U; + return data_len; + } + // delete entry + f->scan[i] = f->scan[--f->page_crc_tests]; + } else { + ++i; + } + } + + return data_len; } // return value: number of bytes we used int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, // the file we're decoding - const uint8 *data, int data_len, // the memory available for decoding - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ) -{ - int i; - int len,right,left; - - if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (f->page_crc_tests >= 0) { - *samples = 0; - return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len); - } - - f->stream = (uint8 *) data; - f->stream_end = (uint8 *) data + data_len; - f->error = VORBIS__no_error; - - // check that we have the entire packet in memory - if (!is_whole_packet_present(f)) { - *samples = 0; - return 0; - } - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - // save the actual error we encountered - enum STBVorbisError error = f->error; - if (error == VORBIS_bad_packet_type) { - // flush and resynch - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return (int) (f->stream - data); - } - if (error == VORBIS_continued_packet_flag_invalid) { - if (f->previous_length == 0) { - // we may be resynching, in which case it's ok to hit one - // of these; just discard the packet - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return (int) (f->stream - data); - } - } - // if we get an error while parsing, what to do? - // well, it DEFINITELY won't work to continue from where we are! - stb_vorbis_flush_pushdata(f); - // restore the error that actually made us bail - f->error = error; - *samples = 0; - return 1; - } - - // success! - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; - - if (channels) *channels = f->channels; - *samples = len; - *output = f->outputs; - return (int) (f->stream - data); + stb_vorbis *f, // the file we're decoding + const uint8 *data, int data_len, // the memory available for decoding + int *channels, // place to write number of float * buffers + float ***output, // place to write float ** array of float * buffers + int *samples // place to write number of output samples +) { + int i; + int len, right, left; + + if (!IS_PUSH_MODE(f)) + return error(f, VORBIS_invalid_api_mixing); + + if (f->page_crc_tests >= 0) { + *samples = 0; + return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len); + } + + f->stream = (uint8 *) data; + f->stream_end = (uint8 *) data + data_len; + f->error = VORBIS__no_error; + + // check that we have the entire packet in memory + if (!is_whole_packet_present(f)) { + *samples = 0; + return 0; + } + + if (!vorbis_decode_packet(f, &len, &left, &right)) { + // save the actual error we encountered + enum STBVorbisError error = f->error; + if (error == VORBIS_bad_packet_type) { + // flush and resynch + f->error = VORBIS__no_error; + while (get8_packet(f) != EOP) + if (f->eof) + break; + *samples = 0; + return (int) (f->stream - data); + } + if (error == VORBIS_continued_packet_flag_invalid) { + if (f->previous_length == 0) { + // we may be resynching, in which case it's ok to hit one + // of these; just discard the packet + f->error = VORBIS__no_error; + while (get8_packet(f) != EOP) + if (f->eof) + break; + *samples = 0; + return (int) (f->stream - data); + } + } + // if we get an error while parsing, what to do? + // well, it DEFINITELY won't work to continue from where we are! + stb_vorbis_flush_pushdata(f); + // restore the error that actually made us bail + f->error = error; + *samples = 0; + return 1; + } + + // success! + len = vorbis_finish_frame(f, len, left, right); + for (i = 0; i < f->channels; ++i) + f->outputs[i] = f->channel_buffers[i] + left; + + if (channels) + *channels = f->channels; + *samples = len; + *output = f->outputs; + return (int) (f->stream - data); } stb_vorbis *stb_vorbis_open_pushdata( - const unsigned char *data, int data_len, // the memory available for decoding - int *data_used, // only defined if result is not NULL - int *error, const stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.stream = (uint8 *) data; - p.stream_end = (uint8 *) data + data_len; - p.push_mode = TRUE; - if (!start_decoder(&p)) { - if (p.eof) - *error = VORBIS_need_more_data; - else - *error = p.error; - vorbis_deinit(&p); - return NULL; - } - f = vorbis_alloc(&p); - if (f) { - *f = p; - *data_used = (int) (f->stream - data); - *error = 0; - return f; - } else { - vorbis_deinit(&p); - return NULL; - } + const unsigned char *data, int data_len, // the memory available for decoding + int *data_used, // only defined if result is not NULL + int *error, const stb_vorbis_alloc *alloc) { + stb_vorbis *f, p; + vorbis_init(&p, alloc); + p.stream = (uint8 *) data; + p.stream_end = (uint8 *) data + data_len; + p.push_mode = TRUE; + if (!start_decoder(&p)) { + if (p.eof) + *error = VORBIS_need_more_data; + else + *error = p.error; + vorbis_deinit(&p); + return NULL; + } + f = vorbis_alloc(&p); + if (f) { + *f = p; + *data_used = (int) (f->stream - data); + *error = 0; + return f; + } else { + vorbis_deinit(&p); + return NULL; + } } + #endif // STB_VORBIS_NO_PUSHDATA_API -unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start); - #ifndef STB_VORBIS_NO_STDIO - return (unsigned int) (ftell(f->f) - f->f_start); - #endif +unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) { + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (f->push_mode) + return 0; + #endif + if (USE_MEMORY(f)) + return (unsigned int) (f->stream - f->stream_start); + #ifndef STB_VORBIS_NO_STDIO + return (unsigned int) (ftell(f->f) - f->f_start); + #endif } #ifndef STB_VORBIS_NO_PULLDATA_API @@ -4558,77 +4710,80 @@ unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) // DATA-PULLING API // -static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) -{ - for(;;) { - int n; - if (f->eof) return 0; - n = get8(f); - if (n == 0x4f) { // page header candidate - unsigned int retry_loc = stb_vorbis_get_file_offset(f); - int i; - // check if we're off the end of a file_section stream - if (retry_loc - 25 > f->stream_len) - return 0; - // check the rest of the header - for (i=1; i < 4; ++i) - if (get8(f) != ogg_page_header[i]) - break; - if (f->eof) return 0; - if (i == 4) { - uint8 header[27]; - uint32 i, crc, goal, len; - for (i=0; i < 4; ++i) - header[i] = ogg_page_header[i]; - for (; i < 27; ++i) - header[i] = get8(f); - if (f->eof) return 0; - if (header[4] != 0) goto invalid; - goal = header[22] + (header[23] << 8) + (header[24]<<16) + ((uint32)header[25]<<24); - for (i=22; i < 26; ++i) - header[i] = 0; - crc = 0; - for (i=0; i < 27; ++i) - crc = crc32_update(crc, header[i]); - len = 0; - for (i=0; i < header[26]; ++i) { - int s = get8(f); - crc = crc32_update(crc, s); - len += s; - } - if (len && f->eof) return 0; - for (i=0; i < len; ++i) - crc = crc32_update(crc, get8(f)); - // finished parsing probable page - if (crc == goal) { - // we could now check that it's either got the last - // page flag set, OR it's followed by the capture - // pattern, but I guess TECHNICALLY you could have - // a file with garbage between each ogg page and recover - // from it automatically? So even though that paranoia - // might decrease the chance of an invalid decode by - // another 2^32, not worth it since it would hose those - // invalid-but-useful files? - if (end) - *end = stb_vorbis_get_file_offset(f); - if (last) { - if (header[5] & 0x04) - *last = 1; - else - *last = 0; - } - set_file_offset(f, retry_loc-1); - return 1; - } - } - invalid: - // not a valid page, so rewind and look for next one - set_file_offset(f, retry_loc); - } - } +static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) { + for (;;) { + int n; + if (f->eof) + return 0; + n = get8(f); + if (n == 0x4f) { // page header candidate + unsigned int retry_loc = stb_vorbis_get_file_offset(f); + int i; + // check if we're off the end of a file_section stream + if (retry_loc - 25 > f->stream_len) + return 0; + // check the rest of the header + for (i = 1; i < 4; ++i) + if (get8(f) != ogg_page_header[i]) + break; + if (f->eof) + return 0; + if (i == 4) { + uint8 header[27]; + uint32 i, crc, goal, len; + for (i = 0; i < 4; ++i) + header[i] = ogg_page_header[i]; + for (; i < 27; ++i) + header[i] = get8(f); + if (f->eof) + return 0; + if (header[4] != 0) + goto invalid; + goal = header[22] + (header[23] << 8) + (header[24] << 16) + ((uint32) header[25] << 24); + for (i = 22; i < 26; ++i) + header[i] = 0; + crc = 0; + for (i = 0; i < 27; ++i) + crc = crc32_update(crc, header[i]); + len = 0; + for (i = 0; i < header[26]; ++i) { + int s = get8(f); + crc = crc32_update(crc, s); + len += s; + } + if (len && f->eof) + return 0; + for (i = 0; i < len; ++i) + crc = crc32_update(crc, get8(f)); + // finished parsing probable page + if (crc == goal) { + // we could now check that it's either got the last + // page flag set, OR it's followed by the capture + // pattern, but I guess TECHNICALLY you could have + // a file with garbage between each ogg page and recover + // from it automatically? So even though that paranoia + // might decrease the chance of an invalid decode by + // another 2^32, not worth it since it would hose those + // invalid-but-useful files? + if (end) + *end = stb_vorbis_get_file_offset(f); + if (last) { + if (header[5] & 0x04) + *last = 1; + else + *last = 0; + } + set_file_offset(f, retry_loc - 1); + return 1; + } + } + invalid: + // not a valid page, so rewind and look for next one + set_file_offset(f, retry_loc); + } + } } - #define SAMPLE_unknown 0xffffffff // seeking is implemented with a binary search, which narrows down the range to @@ -4640,487 +4795,504 @@ static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) // to try to bound either side of the binary search sensibly, while still // working in O(log n) time if they fail. -static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) -{ - uint8 header[27], lacing[255]; - int i,len; +static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) { + uint8 header[27], lacing[255]; + int i, len; - // record where the page starts - z->page_start = stb_vorbis_get_file_offset(f); + // record where the page starts + z->page_start = stb_vorbis_get_file_offset(f); - // parse the header - getn(f, header, 27); - if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S') - return 0; - getn(f, lacing, header[26]); + // parse the header + getn(f, header, 27); + if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S') + return 0; + getn(f, lacing, header[26]); - // determine the length of the payload - len = 0; - for (i=0; i < header[26]; ++i) - len += lacing[i]; + // determine the length of the payload + len = 0; + for (i = 0; i < header[26]; ++i) + len += lacing[i]; - // this implies where the page ends - z->page_end = z->page_start + 27 + header[26] + len; + // this implies where the page ends + z->page_end = z->page_start + 27 + header[26] + len; - // read the last-decoded sample out of the data - z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24); + // read the last-decoded sample out of the data + z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24); - // restore file state to where we were - set_file_offset(f, z->page_start); - return 1; + // restore file state to where we were + set_file_offset(f, z->page_start); + return 1; } // rarely used function to seek back to the preceding page while finding the // start of a packet -static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) -{ - unsigned int previous_safe, end; +static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) { + unsigned int previous_safe, end; - // now we want to seek back 64K from the limit - if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset) - previous_safe = limit_offset - 65536; - else - previous_safe = f->first_audio_page_offset; + // now we want to seek back 64K from the limit + if (limit_offset >= 65536 && limit_offset - 65536 >= f->first_audio_page_offset) + previous_safe = limit_offset - 65536; + else + previous_safe = f->first_audio_page_offset; - set_file_offset(f, previous_safe); + set_file_offset(f, previous_safe); - while (vorbis_find_page(f, &end, NULL)) { - if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) - return 1; - set_file_offset(f, end); - } + while (vorbis_find_page(f, &end, NULL)) { + if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) + return 1; + set_file_offset(f, end); + } - return 0; + return 0; } // implements the search logic for finding a page and starting decoding. if // the function succeeds, current_loc_valid will be true and current_loc will // be less than or equal to the provided sample number (the closer the // better). -static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) -{ - ProbedPage left, right, mid; - int i, start_seg_with_known_loc, end_pos, page_start; - uint32 delta, stream_length, padding, last_sample_limit; - double offset = 0.0, bytes_per_sample = 0.0; - int probe = 0; - - // find the last page and validate the target sample - stream_length = stb_vorbis_stream_length_in_samples(f); - if (stream_length == 0) return error(f, VORBIS_seek_without_length); - if (sample_number > stream_length) return error(f, VORBIS_seek_invalid); - - // this is the maximum difference between the window-center (which is the - // actual granule position value), and the right-start (which the spec - // indicates should be the granule position (give or take one)). - padding = ((f->blocksize_1 - f->blocksize_0) >> 2); - if (sample_number < padding) - last_sample_limit = 0; - else - last_sample_limit = sample_number - padding; - - left = f->p_first; - while (left.last_decoded_sample == ~0U) { - // (untested) the first page does not have a 'last_decoded_sample' - set_file_offset(f, left.page_end); - if (!get_seek_page_info(f, &left)) goto error; - } - - right = f->p_last; - assert(right.last_decoded_sample != ~0U); - - // starting from the start is handled differently - if (last_sample_limit <= left.last_decoded_sample) { - if (stb_vorbis_seek_start(f)) { - if (f->current_loc > sample_number) - return error(f, VORBIS_seek_failed); - return 1; - } - return 0; - } - - while (left.page_end != right.page_start) { - assert(left.page_end < right.page_start); - // search range in bytes - delta = right.page_start - left.page_end; - if (delta <= 65536) { - // there's only 64K left to search - handle it linearly - set_file_offset(f, left.page_end); - } else { - if (probe < 2) { - if (probe == 0) { - // first probe (interpolate) - double data_bytes = right.page_end - left.page_start; - bytes_per_sample = data_bytes / right.last_decoded_sample; - offset = left.page_start + bytes_per_sample * (last_sample_limit - left.last_decoded_sample); - } else { - // second probe (try to bound the other side) - double error = ((double) last_sample_limit - mid.last_decoded_sample) * bytes_per_sample; - if (error >= 0 && error < 8000) error = 8000; - if (error < 0 && error > -8000) error = -8000; - offset += error * 2; - } - - // ensure the offset is valid - if (offset < left.page_end) - offset = left.page_end; - if (offset > right.page_start - 65536) - offset = right.page_start - 65536; - - set_file_offset(f, (unsigned int) offset); - } else { - // binary search for large ranges (offset by 32K to ensure - // we don't hit the right page) - set_file_offset(f, left.page_end + (delta / 2) - 32768); - } - - if (!vorbis_find_page(f, NULL, NULL)) goto error; - } - - for (;;) { - if (!get_seek_page_info(f, &mid)) goto error; - if (mid.last_decoded_sample != ~0U) break; - // (untested) no frames end on this page - set_file_offset(f, mid.page_end); - assert(mid.page_start < right.page_start); - } - - // if we've just found the last page again then we're in a tricky file, - // and we're close enough (if it wasn't an interpolation probe). - if (mid.page_start == right.page_start) { - if (probe >= 2 || delta <= 65536) - break; - } else { - if (last_sample_limit < mid.last_decoded_sample) - right = mid; - else - left = mid; - } - - ++probe; - } - - // seek back to start of the last packet - page_start = left.page_start; - set_file_offset(f, page_start); - if (!start_page(f)) return error(f, VORBIS_seek_failed); - end_pos = f->end_seg_with_known_loc; - assert(end_pos >= 0); - - for (;;) { - for (i = end_pos; i > 0; --i) - if (f->segments[i-1] != 255) - break; - - start_seg_with_known_loc = i; - - if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet)) - break; - - // (untested) the final packet begins on an earlier page - if (!go_to_page_before(f, page_start)) - goto error; - - page_start = stb_vorbis_get_file_offset(f); - if (!start_page(f)) goto error; - end_pos = f->segment_count - 1; - } - - // prepare to start decoding - f->current_loc_valid = FALSE; - f->last_seg = FALSE; - f->valid_bits = 0; - f->packet_bytes = 0; - f->bytes_in_seg = 0; - f->previous_length = 0; - f->next_seg = start_seg_with_known_loc; - - for (i = 0; i < start_seg_with_known_loc; i++) - skip(f, f->segments[i]); - - // start decoding (optimizable - this frame is generally discarded) - if (!vorbis_pump_first_frame(f)) - return 0; - if (f->current_loc > sample_number) - return error(f, VORBIS_seek_failed); - return 1; - -error: - // try to restore the file to a valid state - stb_vorbis_seek_start(f); - return error(f, VORBIS_seek_failed); +static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) { + ProbedPage left, right, mid; + int i, start_seg_with_known_loc, end_pos, page_start; + uint32 delta, stream_length, padding, last_sample_limit; + double offset = 0.0, bytes_per_sample = 0.0; + int probe = 0; + + // find the last page and validate the target sample + stream_length = stb_vorbis_stream_length_in_samples(f); + if (stream_length == 0) + return error(f, VORBIS_seek_without_length); + if (sample_number > stream_length) + return error(f, VORBIS_seek_invalid); + + // this is the maximum difference between the window-center (which is the + // actual granule position value), and the right-start (which the spec + // indicates should be the granule position (give or take one)). + padding = ((f->blocksize_1 - f->blocksize_0) >> 2); + if (sample_number < padding) + last_sample_limit = 0; + else + last_sample_limit = sample_number - padding; + + left = f->p_first; + while (left.last_decoded_sample == ~0U) { + // (untested) the first page does not have a 'last_decoded_sample' + set_file_offset(f, left.page_end); + if (!get_seek_page_info(f, &left)) + goto error; + } + + right = f->p_last; + assert(right.last_decoded_sample != ~0U); + + // starting from the start is handled differently + if (last_sample_limit <= left.last_decoded_sample) { + if (stb_vorbis_seek_start(f)) { + if (f->current_loc > sample_number) + return error(f, VORBIS_seek_failed); + return 1; + } + return 0; + } + + while (left.page_end != right.page_start) { + assert(left.page_end < right.page_start); + // search range in bytes + delta = right.page_start - left.page_end; + if (delta <= 65536) { + // there's only 64K left to search - handle it linearly + set_file_offset(f, left.page_end); + } else { + if (probe < 2) { + if (probe == 0) { + // first probe (interpolate) + double data_bytes = right.page_end - left.page_start; + bytes_per_sample = data_bytes / right.last_decoded_sample; + offset = left.page_start + bytes_per_sample * (last_sample_limit - left.last_decoded_sample); + } else { + // second probe (try to bound the other side) + double error = ((double) last_sample_limit - mid.last_decoded_sample) * bytes_per_sample; + if (error >= 0 && error < 8000) + error = 8000; + if (error < 0 && error > -8000) + error = -8000; + offset += error * 2; + } + + // ensure the offset is valid + if (offset < left.page_end) + offset = left.page_end; + if (offset > right.page_start - 65536) + offset = right.page_start - 65536; + + set_file_offset(f, (unsigned int) offset); + } else { + // binary search for large ranges (offset by 32K to ensure + // we don't hit the right page) + set_file_offset(f, left.page_end + (delta / 2) - 32768); + } + + if (!vorbis_find_page(f, NULL, NULL)) + goto error; + } + + for (;;) { + if (!get_seek_page_info(f, &mid)) + goto error; + if (mid.last_decoded_sample != ~0U) + break; + // (untested) no frames end on this page + set_file_offset(f, mid.page_end); + assert(mid.page_start < right.page_start); + } + + // if we've just found the last page again then we're in a tricky file, + // and we're close enough (if it wasn't an interpolation probe). + if (mid.page_start == right.page_start) { + if (probe >= 2 || delta <= 65536) + break; + } else { + if (last_sample_limit < mid.last_decoded_sample) + right = mid; + else + left = mid; + } + + ++probe; + } + + // seek back to start of the last packet + page_start = left.page_start; + set_file_offset(f, page_start); + if (!start_page(f)) + return error(f, VORBIS_seek_failed); + end_pos = f->end_seg_with_known_loc; + assert(end_pos >= 0); + + for (;;) { + for (i = end_pos; i > 0; --i) + if (f->segments[i - 1] != 255) + break; + + start_seg_with_known_loc = i; + + if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet)) + break; + + // (untested) the final packet begins on an earlier page + if (!go_to_page_before(f, page_start)) + goto error; + + page_start = stb_vorbis_get_file_offset(f); + if (!start_page(f)) + goto error; + end_pos = f->segment_count - 1; + } + + // prepare to start decoding + f->current_loc_valid = FALSE; + f->last_seg = FALSE; + f->valid_bits = 0; + f->packet_bytes = 0; + f->bytes_in_seg = 0; + f->previous_length = 0; + f->next_seg = start_seg_with_known_loc; + + for (i = 0; i < start_seg_with_known_loc; i++) + skip(f, f->segments[i]); + + // start decoding (optimizable - this frame is generally discarded) + if (!vorbis_pump_first_frame(f)) + return 0; + if (f->current_loc > sample_number) + return error(f, VORBIS_seek_failed); + return 1; + + error: + // try to restore the file to a valid state + stb_vorbis_seek_start(f); + return error(f, VORBIS_seek_failed); } // the same as vorbis_decode_initial, but without advancing -static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) -{ - int bits_read, bytes_read; - - if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode)) - return 0; - - // either 1 or 2 bytes were read, figure out which so we can rewind - bits_read = 1 + ilog(f->mode_count-1); - if (f->mode_config[*mode].blockflag) - bits_read += 2; - bytes_read = (bits_read + 7) / 8; - - f->bytes_in_seg += bytes_read; - f->packet_bytes -= bytes_read; - skip(f, -bytes_read); - if (f->next_seg == -1) - f->next_seg = f->segment_count - 1; - else - f->next_seg--; - f->valid_bits = 0; - - return 1; +static int peek_decode_initial(vorb *f, + int *p_left_start, + int *p_left_end, + int *p_right_start, + int *p_right_end, + int *mode) { + int bits_read, bytes_read; + + if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode)) + return 0; + + // either 1 or 2 bytes were read, figure out which so we can rewind + bits_read = 1 + ilog(f->mode_count - 1); + if (f->mode_config[*mode].blockflag) + bits_read += 2; + bytes_read = (bits_read + 7) / 8; + + f->bytes_in_seg += bytes_read; + f->packet_bytes -= bytes_read; + skip(f, -bytes_read); + if (f->next_seg == -1) + f->next_seg = f->segment_count - 1; + else + f->next_seg--; + f->valid_bits = 0; + + return 1; } -int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) -{ - uint32 max_frame_samples; - - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - // fast page-level search - if (!seek_to_sample_coarse(f, sample_number)) - return 0; - - assert(f->current_loc_valid); - assert(f->current_loc <= sample_number); - - // linear search for the relevant packet - max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2; - while (f->current_loc < sample_number) { - int left_start, left_end, right_start, right_end, mode, frame_samples; - if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) - return error(f, VORBIS_seek_failed); - // calculate the number of samples returned by the next frame - frame_samples = right_start - left_start; - if (f->current_loc + frame_samples > sample_number) { - return 1; // the next frame will contain the sample - } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) { - // there's a chance the frame after this could contain the sample - vorbis_pump_first_frame(f); - } else { - // this frame is too early to be relevant - f->current_loc += frame_samples; - f->previous_length = 0; - maybe_start_packet(f); - flush_packet(f); - } - } - // the next frame should start with the sample - if (f->current_loc != sample_number) return error(f, VORBIS_seek_failed); - return 1; +int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) { + uint32 max_frame_samples; + + if (IS_PUSH_MODE(f)) + return error(f, VORBIS_invalid_api_mixing); + + // fast page-level search + if (!seek_to_sample_coarse(f, sample_number)) + return 0; + + assert(f->current_loc_valid); + assert(f->current_loc <= sample_number); + + // linear search for the relevant packet + max_frame_samples = (f->blocksize_1 * 3 - f->blocksize_0) >> 2; + while (f->current_loc < sample_number) { + int left_start, left_end, right_start, right_end, mode, frame_samples; + if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) + return error(f, VORBIS_seek_failed); + // calculate the number of samples returned by the next frame + frame_samples = right_start - left_start; + if (f->current_loc + frame_samples > sample_number) { + return 1; // the next frame will contain the sample + } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) { + // there's a chance the frame after this could contain the sample + vorbis_pump_first_frame(f); + } else { + // this frame is too early to be relevant + f->current_loc += frame_samples; + f->previous_length = 0; + maybe_start_packet(f); + flush_packet(f); + } + } + // the next frame should start with the sample + if (f->current_loc != sample_number) + return error(f, VORBIS_seek_failed); + return 1; } -int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) -{ - if (!stb_vorbis_seek_frame(f, sample_number)) - return 0; - - if (sample_number != f->current_loc) { - int n; - uint32 frame_start = f->current_loc; - stb_vorbis_get_frame_float(f, &n, NULL); - assert(sample_number > frame_start); - assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end); - f->channel_buffer_start += (sample_number - frame_start); - } +int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) { + if (!stb_vorbis_seek_frame(f, sample_number)) + return 0; - return 1; -} + if (sample_number != f->current_loc) { + int n; + uint32 frame_start = f->current_loc; + stb_vorbis_get_frame_float(f, &n, NULL); + assert(sample_number > frame_start); + assert(f->channel_buffer_start + (int) (sample_number - frame_start) <= f->channel_buffer_end); + f->channel_buffer_start += (sample_number - frame_start); + } -int stb_vorbis_seek_start(stb_vorbis *f) -{ - if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); } - set_file_offset(f, f->first_audio_page_offset); - f->previous_length = 0; - f->first_decode = TRUE; - f->next_seg = -1; - return vorbis_pump_first_frame(f); + return 1; } -unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) -{ - unsigned int restore_offset, previous_safe; - unsigned int end, last_page_loc; - - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - if (!f->total_samples) { - unsigned int last; - uint32 lo,hi; - char header[6]; - - // first, store the current decode position so we can restore it - restore_offset = stb_vorbis_get_file_offset(f); - - // now we want to seek back 64K from the end (the last page must - // be at most a little less than 64K, but let's allow a little slop) - if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) - previous_safe = f->stream_len - 65536; - else - previous_safe = f->first_audio_page_offset; - - set_file_offset(f, previous_safe); - // previous_safe is now our candidate 'earliest known place that seeking - // to will lead to the final page' - - if (!vorbis_find_page(f, &end, &last)) { - // if we can't find a page, we're hosed! - f->error = VORBIS_cant_find_last_page; - f->total_samples = 0xffffffff; - goto done; - } - - // check if there are more pages - last_page_loc = stb_vorbis_get_file_offset(f); - - // stop when the last_page flag is set, not when we reach eof; - // this allows us to stop short of a 'file_section' end without - // explicitly checking the length of the section - while (!last) { - set_file_offset(f, end); - if (!vorbis_find_page(f, &end, &last)) { - // the last page we found didn't have the 'last page' flag - // set. whoops! - break; - } - //previous_safe = last_page_loc+1; // NOTE: not used after this point, but note for debugging - last_page_loc = stb_vorbis_get_file_offset(f); - } - - set_file_offset(f, last_page_loc); - - // parse the header - getn(f, (unsigned char *)header, 6); - // extract the absolute granule position - lo = get32(f); - hi = get32(f); - if (lo == 0xffffffff && hi == 0xffffffff) { - f->error = VORBIS_cant_find_last_page; - f->total_samples = SAMPLE_unknown; - goto done; - } - if (hi) - lo = 0xfffffffe; // saturate - f->total_samples = lo; - - f->p_last.page_start = last_page_loc; - f->p_last.page_end = end; - f->p_last.last_decoded_sample = lo; - - done: - set_file_offset(f, restore_offset); - } - return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; +int stb_vorbis_seek_start(stb_vorbis *f) { + if (IS_PUSH_MODE(f)) { + return error(f, VORBIS_invalid_api_mixing); + } + set_file_offset(f, f->first_audio_page_offset); + f->previous_length = 0; + f->first_decode = TRUE; + f->next_seg = -1; + return vorbis_pump_first_frame(f); } -float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) -{ - return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; +unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) { + unsigned int restore_offset, previous_safe; + unsigned int end, last_page_loc; + + if (IS_PUSH_MODE(f)) + return error(f, VORBIS_invalid_api_mixing); + if (!f->total_samples) { + unsigned int last; + uint32 lo, hi; + char header[6]; + + // first, store the current decode position so we can restore it + restore_offset = stb_vorbis_get_file_offset(f); + + // now we want to seek back 64K from the end (the last page must + // be at most a little less than 64K, but let's allow a little slop) + if (f->stream_len >= 65536 && f->stream_len - 65536 >= f->first_audio_page_offset) + previous_safe = f->stream_len - 65536; + else + previous_safe = f->first_audio_page_offset; + + set_file_offset(f, previous_safe); + // previous_safe is now our candidate 'earliest known place that seeking + // to will lead to the final page' + + if (!vorbis_find_page(f, &end, &last)) { + // if we can't find a page, we're hosed! + f->error = VORBIS_cant_find_last_page; + f->total_samples = 0xffffffff; + goto done; + } + + // check if there are more pages + last_page_loc = stb_vorbis_get_file_offset(f); + + // stop when the last_page flag is set, not when we reach eof; + // this allows us to stop short of a 'file_section' end without + // explicitly checking the length of the section + while (!last) { + set_file_offset(f, end); + if (!vorbis_find_page(f, &end, &last)) { + // the last page we found didn't have the 'last page' flag + // set. whoops! + break; + } + //previous_safe = last_page_loc+1; // NOTE: not used after this point, but note for debugging + last_page_loc = stb_vorbis_get_file_offset(f); + } + + set_file_offset(f, last_page_loc); + + // parse the header + getn(f, (unsigned char *) header, 6); + // extract the absolute granule position + lo = get32(f); + hi = get32(f); + if (lo == 0xffffffff && hi == 0xffffffff) { + f->error = VORBIS_cant_find_last_page; + f->total_samples = SAMPLE_unknown; + goto done; + } + if (hi) + lo = 0xfffffffe; // saturate + f->total_samples = lo; + + f->p_last.page_start = last_page_loc; + f->p_last.page_end = end; + f->p_last.last_decoded_sample = lo; + + done: + set_file_offset(f, restore_offset); + } + return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; } +float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) { + return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; +} +int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) { + int len, right, left, i; + if (IS_PUSH_MODE(f)) + return error(f, VORBIS_invalid_api_mixing); -int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) -{ - int len, right,left,i; - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - f->channel_buffer_start = f->channel_buffer_end = 0; - return 0; - } + if (!vorbis_decode_packet(f, &len, &left, &right)) { + f->channel_buffer_start = f->channel_buffer_end = 0; + return 0; + } - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; + len = vorbis_finish_frame(f, len, left, right); + for (i = 0; i < f->channels; ++i) + f->outputs[i] = f->channel_buffers[i] + left; - f->channel_buffer_start = left; - f->channel_buffer_end = left+len; + f->channel_buffer_start = left; + f->channel_buffer_end = left + len; - if (channels) *channels = f->channels; - if (output) *output = f->outputs; - return len; + if (channels) + *channels = f->channels; + if (output) + *output = f->outputs; + return len; } #ifndef STB_VORBIS_NO_STDIO -stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.f = file; - p.f_start = (uint32) ftell(file); - p.stream_len = length; - p.close_on_free = close_on_free; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; +stb_vorbis *stb_vorbis_open_file_section(FILE *file, + int close_on_free, + int *error, + const stb_vorbis_alloc *alloc, + unsigned int length) { + stb_vorbis *f, p; + vorbis_init(&p, alloc); + p.f = file; + p.f_start = (uint32) ftell(file); + p.stream_len = length; + p.close_on_free = close_on_free; + if (start_decoder(&p)) { + f = vorbis_alloc(&p); + if (f) { + *f = p; + vorbis_pump_first_frame(f); + return f; + } + } + if (error) + *error = p.error; + vorbis_deinit(&p); + return NULL; } -stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) -{ - unsigned int len, start; - start = (unsigned int) ftell(file); - fseek(file, 0, SEEK_END); - len = (unsigned int) (ftell(file) - start); - fseek(file, start, SEEK_SET); - return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); +stb_vorbis *stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) { + unsigned int len, start; + start = (unsigned int) ftell(file); + fseek(file, 0, SEEK_END); + len = (unsigned int) (ftell(file) - start); + fseek(file, start, SEEK_SET); + return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); } -stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) -{ - FILE *f; +stb_vorbis *stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) { + FILE *f; #if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__) - if (0 != fopen_s(&f, filename, "rb")) + if (0 != fopen_s(&f, filename, "rb")) f = NULL; #else - f = fopen(filename, "rb"); + f = fopen(filename, "rb"); #endif - if (f) - return stb_vorbis_open_file(f, TRUE, error, alloc); - if (error) *error = VORBIS_file_open_failure; - return NULL; + if (f) + return stb_vorbis_open_file(f, TRUE, error, alloc); + if (error) + *error = VORBIS_file_open_failure; + return NULL; } + #endif // STB_VORBIS_NO_STDIO -stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - if (!data) { - if (error) *error = VORBIS_unexpected_eof; - return NULL; - } - vorbis_init(&p, alloc); - p.stream = (uint8 *) data; - p.stream_end = (uint8 *) data + len; - p.stream_start = (uint8 *) p.stream; - p.stream_len = len; - p.push_mode = FALSE; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - if (error) *error = VORBIS__no_error; - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; +stb_vorbis *stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) { + stb_vorbis *f, p; + if (!data) { + if (error) + *error = VORBIS_unexpected_eof; + return NULL; + } + vorbis_init(&p, alloc); + p.stream = (uint8 *) data; + p.stream_end = (uint8 *) data + len; + p.stream_start = (uint8 *) p.stream; + p.stream_len = len; + p.push_mode = FALSE; + if (start_decoder(&p)) { + f = vorbis_alloc(&p); + if (f) { + *f = p; + vorbis_pump_first_frame(f); + if (error) + *error = VORBIS__no_error; + return f; + } + } + if (error) + *error = p.error; + vorbis_deinit(&p); + return NULL; } #ifndef STB_VORBIS_NO_INTEGER_CONVERSION @@ -5133,348 +5305,373 @@ stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *err #define R (PLAYBACK_RIGHT | PLAYBACK_MONO) static int8 channel_position[7][6] = -{ - { 0 }, - { C }, - { L, R }, - { L, C, R }, - { L, R, L, R }, - { L, C, R, L, R }, - { L, C, R, L, R, C }, -}; - + { + {0}, + {C}, + {L, R}, + {L, C, R}, + {L, R, L, R}, + {L, C, R, L, R}, + {L, C, R, L, R, C}, + }; #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - typedef union { - float f; - int i; - } float_conv; - typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; - #define FASTDEF(x) float_conv x - // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round - #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) - #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) - #define check_endianness() +typedef union { + float f; + int i; +} float_conv; +typedef char stb_vorbis_float_size_test[sizeof(float) == 4 && sizeof(int) == 4]; + #define FASTDEF(x) float_conv x +// add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round + #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) + #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) + #define FAST_SCALED_FLOAT_TO_INT(temp, x, s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) + #define check_endianness() #else - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) + #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) #define check_endianness() #define FASTDEF(x) #endif -static void copy_samples(short *dest, float *src, int len) -{ - int i; - check_endianness(); - for (i=0; i < len; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - dest[i] = v; - } +static void copy_samples(short *dest, float *src, int len) { + int i; + check_endianness(); + for (i = 0; i < len; ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i], 15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + dest[i] = v; + } } -static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) -{ - #define STB_BUFFER_SIZE 32 - float buffer[STB_BUFFER_SIZE]; - int i,j,o,n = STB_BUFFER_SIZE; - check_endianness(); - for (o = 0; o < len; o += STB_BUFFER_SIZE) { - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - if (channel_position[num_c][j] & mask) { - for (i=0; i < n; ++i) - buffer[i] += data[j][d_offset+o+i]; - } - } - for (i=0; i < n; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o+i] = v; - } - } - #undef STB_BUFFER_SIZE +static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) { + #define STB_BUFFER_SIZE 32 + float buffer[STB_BUFFER_SIZE]; + int i, j, o, n = STB_BUFFER_SIZE; + check_endianness(); + for (o = 0; o < len; o += STB_BUFFER_SIZE) { + memset(buffer, 0, sizeof(buffer)); + if (o + n > len) + n = len - o; + for (j = 0; j < num_c; ++j) { + if (channel_position[num_c][j] & mask) { + for (i = 0; i < n; ++i) + buffer[i] += data[j][d_offset + o + i]; + } + } + for (i = 0; i < n; ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp, buffer[i], 15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + output[o + i] = v; + } + } + #undef STB_BUFFER_SIZE } -static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) -{ - #define STB_BUFFER_SIZE 32 - float buffer[STB_BUFFER_SIZE]; - int i,j,o,n = STB_BUFFER_SIZE >> 1; - // o is the offset in the source data - check_endianness(); - for (o = 0; o < len; o += STB_BUFFER_SIZE >> 1) { - // o2 is the offset in the output data - int o2 = o << 1; - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); - if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_LEFT) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_RIGHT) { - for (i=0; i < n; ++i) { - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } - } - for (i=0; i < (n<<1); ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o2+i] = v; - } - } - #undef STB_BUFFER_SIZE +static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) { + #define STB_BUFFER_SIZE 32 + float buffer[STB_BUFFER_SIZE]; + int i, j, o, n = STB_BUFFER_SIZE >> 1; + // o is the offset in the source data + check_endianness(); + for (o = 0; o < len; o += STB_BUFFER_SIZE >> 1) { + // o2 is the offset in the output data + int o2 = o << 1; + memset(buffer, 0, sizeof(buffer)); + if (o + n > len) + n = len - o; + for (j = 0; j < num_c; ++j) { + int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); + if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { + for (i = 0; i < n; ++i) { + buffer[i * 2 + 0] += data[j][d_offset + o + i]; + buffer[i * 2 + 1] += data[j][d_offset + o + i]; + } + } else if (m == PLAYBACK_LEFT) { + for (i = 0; i < n; ++i) { + buffer[i * 2 + 0] += data[j][d_offset + o + i]; + } + } else if (m == PLAYBACK_RIGHT) { + for (i = 0; i < n; ++i) { + buffer[i * 2 + 1] += data[j][d_offset + o + i]; + } + } + } + for (i = 0; i < (n << 1); ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp, buffer[i], 15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + output[o2 + i] = v; + } + } + #undef STB_BUFFER_SIZE } -static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) -{ - int i; - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; - for (i=0; i < buf_c; ++i) - compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - for (i=0; i < limit; ++i) - copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); - for ( ; i < buf_c; ++i) - memset(buffer[i]+b_offset, 0, sizeof(short) * samples); - } +static void convert_samples_short(int buf_c, + short **buffer, + int b_offset, + int data_c, + float **data, + int d_offset, + int samples) { + int i; + if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { + static int channel_selector[3][2] = {{0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT}}; + for (i = 0; i < buf_c; ++i) + compute_samples(channel_selector[buf_c][i], buffer[i] + b_offset, data_c, data, d_offset, samples); + } else { + int limit = buf_c < data_c ? buf_c : data_c; + for (i = 0; i < limit; ++i) + copy_samples(buffer[i] + b_offset, data[i] + d_offset, samples); + for (; i < buf_c; ++i) + memset(buffer[i] + b_offset, 0, sizeof(short) * samples); + } } -int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) -{ - float **output = NULL; - int len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len > num_samples) len = num_samples; - if (len) - convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); - return len; +int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) { + float **output = NULL; + int len = stb_vorbis_get_frame_float(f, NULL, &output); + if (len > num_samples) + len = num_samples; + if (len) + convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); + return len; } -static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) -{ - int i; - check_endianness(); - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - assert(buf_c == 2); - for (i=0; i < buf_c; ++i) - compute_stereo_samples(buffer, data_c, data, d_offset, len); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - int j; - for (j=0; j < len; ++j) { - for (i=0; i < limit; ++i) { - FASTDEF(temp); - float f = data[i][d_offset+j]; - int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - *buffer++ = v; - } - for ( ; i < buf_c; ++i) - *buffer++ = 0; - } - } +static void convert_channels_short_interleaved(int buf_c, + short *buffer, + int data_c, + float **data, + int d_offset, + int len) { + int i; + check_endianness(); + if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { + assert(buf_c == 2); + for (i = 0; i < buf_c; ++i) + compute_stereo_samples(buffer, data_c, data, d_offset, len); + } else { + int limit = buf_c < data_c ? buf_c : data_c; + int j; + for (j = 0; j < len; ++j) { + for (i = 0; i < limit; ++i) { + FASTDEF(temp); + float f = data[i][d_offset + j]; + int v = FAST_SCALED_FLOAT_TO_INT(temp, f, 15);//data[i][d_offset+j],15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + *buffer++ = v; + } + for (; i < buf_c; ++i) + *buffer++ = 0; + } + } } -int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) -{ - float **output; - int len; - if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); - len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len) { - if (len*num_c > num_shorts) len = num_shorts / num_c; - convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); - } - return len; +int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) { + float **output; + int len; + if (num_c == 1) + return stb_vorbis_get_frame_short(f, num_c, &buffer, num_shorts); + len = stb_vorbis_get_frame_float(f, NULL, &output); + if (len) { + if (len * num_c > num_shorts) + len = num_shorts / num_c; + convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); + } + return len; } -int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) -{ - float **outputs; - int len = num_shorts / channels; - int n=0; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); - buffer += k*channels; - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; +int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) { + float **outputs; + int len = num_shorts / channels; + int n = 0; + while (n < len) { + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n + k >= len) + k = len - n; + if (k) + convert_channels_short_interleaved(channels, + buffer, + f->channels, + f->channel_buffers, + f->channel_buffer_start, + k); + buffer += k * channels; + n += k; + f->channel_buffer_start += k; + if (n == len) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; } -int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) -{ - float **outputs; - int n=0; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; +int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) { + float **outputs; + int n = 0; + while (n < len) { + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n + k >= len) + k = len - n; + if (k) + convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); + n += k; + f->channel_buffer_start += k; + if (n == len) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; } #ifndef STB_VORBIS_NO_STDIO -int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; + +int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) { + int data_len, offset, total, limit, error; + short *data; + stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); + if (v == NULL) + return -1; + limit = v->channels * 4096; + *channels = v->channels; + if (sample_rate) + *sample_rate = v->sample_rate; + offset = data_len = 0; + total = limit; + data = (short *) malloc(total * sizeof(*data)); + if (data == NULL) { + stb_vorbis_close(v); + return -2; + } + for (;;) { + int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data + offset, total - offset); + if (n == 0) + break; + data_len += n; + offset += n * v->channels; + if (offset + limit > total) { + short *data2; + total *= 2; + data2 = (short *) realloc(data, total * sizeof(*data)); + if (data2 == NULL) { + free(data); + stb_vorbis_close(v); + return -2; + } + data = data2; + } + } + *output = data; + stb_vorbis_close(v); + return data_len; } + #endif // NO_STDIO -int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; +int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) { + int data_len, offset, total, limit, error; + short *data; + stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); + if (v == NULL) + return -1; + limit = v->channels * 4096; + *channels = v->channels; + if (sample_rate) + *sample_rate = v->sample_rate; + offset = data_len = 0; + total = limit; + data = (short *) malloc(total * sizeof(*data)); + if (data == NULL) { + stb_vorbis_close(v); + return -2; + } + for (;;) { + int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data + offset, total - offset); + if (n == 0) + break; + data_len += n; + offset += n * v->channels; + if (offset + limit > total) { + short *data2; + total *= 2; + data2 = (short *) realloc(data, total * sizeof(*data)); + if (data2 == NULL) { + free(data); + stb_vorbis_close(v); + return -2; + } + data = data2; + } + } + *output = data; + stb_vorbis_close(v); + return data_len; } + #endif // STB_VORBIS_NO_INTEGER_CONVERSION -int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) -{ - float **outputs; - int len = num_floats / channels; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int i,j; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - for (j=0; j < k; ++j) { - for (i=0; i < z; ++i) - *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; - for ( ; i < channels; ++i) - *buffer++ = 0; - } - n += k; - f->channel_buffer_start += k; - if (n == len) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; +int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) { + float **outputs; + int len = num_floats / channels; + int n = 0; + int z = f->channels; + if (z > channels) + z = channels; + while (n < len) { + int i, j; + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n + k >= len) + k = len - n; + for (j = 0; j < k; ++j) { + for (i = 0; i < z; ++i) + *buffer++ = f->channel_buffers[i][f->channel_buffer_start + j]; + for (; i < channels; ++i) + *buffer++ = 0; + } + n += k; + f->channel_buffer_start += k; + if (n == len) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; } -int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) -{ - float **outputs; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < num_samples) { - int i; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= num_samples) k = num_samples - n; - if (k) { - for (i=0; i < z; ++i) - memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); - for ( ; i < channels; ++i) - memset(buffer[i]+n, 0, sizeof(float) * k); - } - n += k; - f->channel_buffer_start += k; - if (n == num_samples) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; +int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) { + float **outputs; + int n = 0; + int z = f->channels; + if (z > channels) + z = channels; + while (n < num_samples) { + int i; + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n + k >= num_samples) + k = num_samples - n; + if (k) { + for (i = 0; i < z; ++i) + memcpy(buffer[i] + n, f->channel_buffers[i] + f->channel_buffer_start, sizeof(float) * k); + for (; i < channels; ++i) + memset(buffer[i] + n, 0, sizeof(float) * k); + } + n += k; + f->channel_buffer_start += k; + if (n == num_samples) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; } + #endif // STB_VORBIS_NO_PULLDATA_API /* Version history diff --git a/fggl/util/CMakeLists.txt b/fggl/util/CMakeLists.txt index 1cb7bb3a9ef511c8e597acb0df303b3810485670..e2163a70087815e5671a01585e7954af19af2647 100644 --- a/fggl/util/CMakeLists.txt +++ b/fggl/util/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources(fggl - PRIVATE + PRIVATE guid.cpp -) \ No newline at end of file + ) \ No newline at end of file diff --git a/fggl/util/guid.cpp b/fggl/util/guid.cpp index ee0025bc480968d0af66b5a9cb2cfad5ced3aff0..1384301682a46c316505628678e6ac5d2dca8d9c 100644 --- a/fggl/util/guid.cpp +++ b/fggl/util/guid.cpp @@ -27,7 +27,7 @@ namespace fggl::util { std::map<GUID, std::string> guidTable; } - GUID internString(const char* str) { + GUID internString(const char *str) { assert(str != nullptr); GUID guid = make_guid(str); @@ -46,17 +46,17 @@ namespace fggl::util { return tableValue->second; } // it's not in the table... - return "UNKNOWN_GUID("+std::to_string(guid.get())+")"; + return "UNKNOWN_GUID(" + std::to_string(guid.get()) + ")"; } } -fggl::util::GUID operator "" _fid(const char* str) { +fggl::util::GUID operator "" _fid(const char *str) { fggl::util::internString(str); return fggl::util::make_guid(str); } -fggl::util::GUID operator "" _fid(const char* str, std::size_t) { +fggl::util::GUID operator "" _fid(const char *str, std::size_t) { fggl::util::internString(str); return fggl::util::make_guid(str); }