{"id":13439337,"url":"https://github.com/recp/cglm","last_synced_at":"2025-05-13T21:05:30.127Z","repository":{"id":37579989,"uuid":"67952038","full_name":"recp/cglm","owner":"recp","description":"📽 Highly Optimized 2D / 3D Graphics Math (glm) for C","archived":false,"fork":false,"pushed_at":"2025-04-24T13:07:51.000Z","size":2686,"stargazers_count":2515,"open_issues_count":72,"forks_count":254,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-06T11:36:24.541Z","etag":null,"topics":["3d","3d-math","affine-transform-matrices","avx","bezier","bounding-boxes","c","euler","frustum","marix-inverse","math","matrix","matrix-decompositions","neon","opengl","opengl-math","simd","sse","vector","wasm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["recp"],"patreon":"recp","open_collective":"cglm","ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2016-09-11T20:15:35.000Z","updated_at":"2025-05-06T04:28:31.000Z","dependencies_parsed_at":"2024-11-06T20:40:54.961Z","dependency_job_id":"335fb68a-2f04-47da-9083-cde419d11d81","html_url":"https://github.com/recp/cglm","commit_stats":{"total_commits":1390,"total_committers":77,"mean_commits":"18.051948051948052","dds":"0.28129496402877696","last_synced_commit":"5861c37a93bab9d68482a30cf5519bc3ec89e8a4"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Fcglm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Fcglm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Fcglm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Fcglm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recp","download_url":"https://codeload.github.com/recp/cglm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253171200,"owners_count":21865279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-math","affine-transform-matrices","avx","bezier","bounding-boxes","c","euler","frustum","marix-inverse","math","matrix","matrix-decompositions","neon","opengl","opengl-math","simd","sse","vector","wasm"],"created_at":"2024-07-31T03:01:13.074Z","updated_at":"2025-05-13T21:05:30.081Z","avatar_url":"https://github.com/recp.png","language":"C","readme":"# 🎥 OpenGL Mathematics (glm) for `C`\n\n\u003cp align=\"center\"\u003e\n   \u003cimg alt=\"\" src=\"cglm.png\" width=\"550\" /\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/recp/cglm/actions/workflows/ci.yml\"\u003e\n        \u003cimg src=\"https://github.com/recp/cglm/actions/workflows/ci.yml/badge.svg\"\n             alt=\"Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://cglm.readthedocs.io/en/latest/?badge=latest\"\u003e\n        \u003cimg src=\"https://readthedocs.org/projects/cglm/badge/?version=latest\"\n             alt=\"Documentation Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.codacy.com/app/recp/cglm?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=recp/cglm\u0026amp;utm_campaign=Badge_Grade\"\u003e\n        \u003cimg src=\"https://api.codacy.com/project/badge/Grade/6a62b37d5f214f178ebef269dc4a6bf1\"\n             alt=\"Codacy Badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/recp/cglm?branch=master\"\u003e\n        \u003cimg src=\"https://coveralls.io/repos/github/recp/cglm/badge.svg?branch=master\"\n             alt=\"Coverage Status\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/recp/cglm\"\u003e\n        \u003cimg src=\"https://codecov.io/gh/recp/cglm/branch/master/graph/badge.svg\"\n             alt=\"Coverage Status\"/\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\u003cbr /\u003e\n    \u003ca href=\"#sponsors\"\u003e\n        \u003cimg src=\"https://opencollective.com/cglm/sponsors/badge.svg\"\n             alt=\"Sponsors on Open Collective\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#backers\"\u003e\n        \u003cimg src=\"https://opencollective.com/cglm/backers/badge.svg\"\n             alt=\"Backers on Open Collective\"/\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\nA highly optimized 2D|3D math library. Also known as OpenGL Mathematics (glm) for C. \u003cb\u003ecglm\u003c/b\u003e provides fast and ergonomic math functions to ease graphics programming. It is community friendly – feel free to report any bugs and issues you face. \u003cbr\u003e\n\u003ci\u003eIf you're using C++, you might want to check out \u003ca href=\"https://github.com/g-truc/glm\"\u003eGLM\u003c/a\u003e\u003c/i\u003e\n\u003c/p\u003e\n\n - Allocation-free\n - Header-only\n - SIMD-optimized\n - API-agnostic\n\n---\n\n### 📚 Documentation\n\nAll functions and their parameters are documented above their declaration inside their corresponding headers. \u003cbr /\u003e\nAlternatively, you can read the complete documentation [here](http://cglm.readthedocs.io).\n\n### 🔨 Building\n\ncglm can be used in it's entirety as a header-only library simply by including `cglm/cglm.h`. If you wish to link against it instead, it can be built using one of the supported build systems. Detailed information about building on individual platforms and build systems along with the instructions for building the documentation can be found in [BUILDING.md](./BUILDING.md).\n\n### ✅ Usage\n\n#### Header-only\n\nInclude the `cglm/cglm.h` header and use functions with the `glm_` prefix.\n```c\n#include \"cglm/cglm.h\"\n\n// ...\n\nvec2 vector;\nglm_vec2_zero(vector);\n```\n\n#### Struct API\n\nInclude `cglm/struct.h` and use `glms_`.\n```c\n#include \"cglm/struct.h\"\n\n// ...\n\nvec2s vector = glms_vec2_zero();\n```\n\n#### Linked\n\nInclude `cglm/call.h` and use `glmc_`.\n```c\n#include \"cglm/call.h\"\n\n// ...\n\nvec2 vector;\nglmc_vec2_zero(vector);\n```\n\n### ❗ Alignment\n\nWhile cglm by default aligns what's necessary, it is possible to disable this by defining `CGLM_ALL_UNALIGNED`. If you're targeting machines with any kind of SIMD support, make sure that all `vec4`, `mat4` and `mat2` arguments you pass to cglm functions are aligned to prevent unexpected crashes, alternatively use the unaligned versions if present. \n\n### Struct API\n\nThe struct API works as follows (note the `s` suffix on types, `glms_` prefix on functions and `GLMS_` on constants):\n\n```C\n#include \u003ccglm/struct.h\u003e\n\nmat4s mat = GLMS_MAT4_IDENTITY_INIT;\nmat4s inv = glms_mat4_inv(mat);\n```\n\nStruct functions generally take parameters *by copy* and *return* the results rather than taking pointers and writing to out parameters. That means your variables can usually be `const`, if you're into that.\n\nThe types used are actually unions that allow access to the same data in multiple ways. One of these involves anonymous structures available since C11. MSVC supports them in earlier versions out of the box and GCC/Clang as well if you enable `-fms-extensions`.\nTo explicitly enable anonymous structures `#define CGLM_USE_ANONYMOUS_STRUCT 1`, or `0` to disable them.\nFor backwards compatibility, you can also `#define CGLM_NO_ANONYMOUS_STRUCT` to disable them. If you don't specify explicitly, cglm will attempt a best guess based on your compiler and C version.\n\n### 📌 Migration notes:\n\n- `_dup` (duplicate) functions were renamed to `_copy`. For instance: `glm_vec_dup` -\u003e `glm_vec3_copy`.\n- OpenGL related functions were dropped to make cglm API independent.\n- **[bugfix]** Euler angles had been previously implemented in reverse order (extrinsic). This was fixed to be intrinsic.\n- **[major change]** Starting with **v0.4.0**, quaternions are stored as [x, y, z, w]. Previously it was [w, x, y, z].\n- **[api rename]** Starting with **v0.4.5**, `glm_simd_` functions are renamed to `glmm_`.\n- **[new option]** Starting with **v0.4.5**, alignment requirements can be disabled. Read more in the documentation.  \n- **[major change]** Starting with **v0.5.0**, vec3 functions occupy the **glm_vec3_** namespace. This used to be **glm_vec_** in earlier versions.\n- **[major change]** Starting with **v0.5.1**, `vec3` and `mat3` types are not aligned by default.\n- **[major change]** Starting with **v0.7.3**, inline print functions are disabled by default in release mode to eliminate printing costs (see the Options chapter of the docs). \u003cbr\u003e Colored output can be disabled (see documentation).\n- **[major change]** Starting with **v0.8.3**, alternate clipspace configurations are supported. The `CGLM_FORCE_DEPTH_ZERO_TO_ONE` and `CGLM_FORCE_LEFT_HANDED` flags are provided to control clip depth and handedness. This makes it easier to incorporate cglm into projects using graphics APIs such as Vulkan or Metal. See https://cglm.readthedocs.io/en/latest/opt.html#clipspace-option-s\n\n### 🚀 Features\n\n- scalar and simd (sse, avx, neon...) optimizations\n- general purpose matrix operations (mat4, mat3)\n- chain matrix multiplication (square only)\n- general purpose vector operations (cross, dot, rotate, proj, angle...)\n- affine transformations\n- matrix decomposition (extract rotation, scaling factor)\n- optimized affine transform matrices (mul, rigid-body inverse)\n- camera (lookat)\n- projections (ortho, perspective)\n- quaternions\n- euler angles / yaw-pitch-roll to matrix\n- extract euler angles\n- frustum (extract view frustum planes, corners...)\n- bounding box (AABB in Frustum (culling), crop, merge...)\n- bounding sphere\n- project, unproject\n- easing functions\n- curves\n- curve interpolation helpers (SMC, deCasteljau...)\n- comversion helpers from cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides\n- ray intersection helpers\n---\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\n        \u003cdiv\u003eLike other graphics libraries (especially OpenGL), cglm uses column-major layout to keep matrices in memory. \u003c/div\u003e\n        \u003cdiv\u003e\u0026nbsp;\u003c/div\u003e\n        \u003cdiv\u003eWhile we might support row-major matrices in the future, currently if you need your matrices to be in row-major layout you have to transpose them. \u003c/div\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n        \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/3/3f/Matrix_Columns.svg\" width=\"300px\" /\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n---\n\ncglm contains general purpose mat4 product and inverse functions but also provides optimized versions for affine transformations. If you want to multiply two affine transformation matrices you can use glm_mul instead of glm_mat4_mul and glm_inv_tr (ROT + TR) instead glm_mat4_inv.\n```C\n/* multiplication */\nmat4 modelMat;\nglm_mul(T, R, modelMat);\n\n/* othonormal rot + tr matrix inverse (rigid-body) */\nglm_inv_tr(modelMat);\n```\n\n## Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]\n\u003ca href=\"https://github.com/recp/cglm/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/cglm/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n\n## Backers\n\nThank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/cglm#backer)]\n\n\u003ca href=\"https://opencollective.com/cglm#backers\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/backers.svg?width=890\"\u003e\u003c/a\u003e\n\n\n## Sponsors\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/cglm#sponsor)]\n\n\u003ca href=\"https://opencollective.com/cglm/sponsor/0/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/1/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/2/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/3/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/4/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/5/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/6/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/7/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/8/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/cglm/sponsor/9/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/cglm/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/recp","https://patreon.com/recp","https://opencollective.com/cglm"],"categories":["C","Game Programming","Game-Math","游戏编程","Maths","其他_机器视觉","Game Development","Libraries"],"sub_categories":["资源传输下载","C"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Fcglm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecp%2Fcglm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Fcglm/lists"}