{"id":18183641,"url":"https://github.com/jaysmito101/cgl","last_synced_at":"2025-05-14T22:09:53.326Z","repository":{"id":58871892,"uuid":"527896392","full_name":"Jaysmito101/cgl","owner":"Jaysmito101","description":"CGL (C Game Library) is a multipurpose library mainly for recreational coding / demo scenes / prototyping / small games / experimentation. ","archived":false,"fork":false,"pushed_at":"2025-02-02T13:09:05.000Z","size":83116,"stargazers_count":436,"open_issues_count":6,"forks_count":40,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T00:44:10.589Z","etag":null,"topics":["3d","c9","cpp","game","gamedev","graphics","hacktoberfest","opengl","phong-lighting","python","rendering","rust","tilemap"],"latest_commit_sha":null,"homepage":"https://jaysmito101.github.io/cgl/","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/Jaysmito101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"Jaysmito101","patreon":"jaysmito101"}},"created_at":"2022-08-23T08:19:58.000Z","updated_at":"2025-04-05T15:41:58.000Z","dependencies_parsed_at":"2025-02-10T09:01:34.494Z","dependency_job_id":"b76df5ec-64b2-43fe-80ca-89f7ea0a6c3c","html_url":"https://github.com/Jaysmito101/cgl","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaysmito101%2Fcgl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaysmito101%2Fcgl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaysmito101%2Fcgl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaysmito101%2Fcgl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jaysmito101","download_url":"https://codeload.github.com/Jaysmito101/cgl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"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","c9","cpp","game","gamedev","graphics","hacktoberfest","opengl","phong-lighting","python","rendering","rust","tilemap"],"created_at":"2024-11-02T20:03:42.482Z","updated_at":"2025-05-14T22:09:48.307Z","avatar_url":"https://github.com/Jaysmito101.png","language":"C","funding_links":["https://github.com/sponsors/Jaysmito101","https://patreon.com/jaysmito101"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"300\" src=\"https://raw.githubusercontent.com/Jaysmito101/cgl/main/images/CGL_logo_low_mid_res.png\" border=\"0\"\u003e\n\u003c/p\u003e\n\n\n\n\u003cp align=\"center\"\u003e\n\n\u003cimg src=\"https://img.shields.io/github/issues-pr/Jaysmito101/cgl?style=for-the-badge\" /\u003e\n\u003cimg alt=\"Lines of code\" src=\"https://img.shields.io/tokei/lines/github/Jaysmito101/cgl?style=for-the-badge\" /\u003e\n\u003cimg src=\"https://img.shields.io/github/repo-size/Jaysmito101/cgl?style=for-the-badge\" /\u003e\n\u003ca href=\"https://patreon.com/jaysmito101\"\u003e\u003cimg src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Djaysmito101%26type%3Dpledges\u0026style=for-the-badge\" alt=\"Support me on Patreon\" /\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003cbr/\u003e\n\n\n\n# Index\n* [Intro](#cgl)\n* [Platforms](#target-platforms)\n* [Features](#what-does-cgl-provide)\n* [Showreels](#showreels)\n\n\u003cbr\u003e\n\n# CGL\nCGL (C Graphics Library) is a multipurpose library mainly for recreational coding /  demo scenes / prototyping / small games / experimentation. This has a **lot of utilities for graphics**. And best of all all of it is inside a single header file `cgl.h`.  Also CGL is made purely in C but is also compatible with C++. \n\n**NOTE** : Do not think that header only means its going to increase compile time as the implementation needs be enabled only for 1 file using `#define CGL_IMPLEMENTATION`. See [Examples](./examples)\n\n\u003cbr\u003e\n\n## Target Platforms\n\n- \u003cb\u003e\u003ci\u003eWindows\u003c/b\u003e\u003c/i\u003e\n- \u003cb\u003e\u003ci\u003eLinux\u003c/b\u003e\u003c/i\u003e\n- \u003cb\u003e\u003ci\u003eMacOS (untested)\u003c/b\u003e\u003c/i\u003e\n- \u003cb\u003e\u003ci\u003eWebAssembly (Beta)\u003c/b\u003e\u003c/i\u003e\n- \u003cb\u003e\u003ci\u003eAndroid (Coming Soon)\u003c/b\u003e\u003c/i\u003e\n\n\u003cbr\u003e\n\n## What does CGL Provide? \n\n* cgl-rs\n  - A Rust wrapper ( https://crates.io/crates/cgl-rs )\n\n* cgl-py\n  - A python wrapper ( https://pypi.org/project/cgl-py )\n\n* Windowing library (Optional)\n  - You can completely disable it by `#define CGL_EXCLUDE_WINDOW_API`\n  - This windowing library is primarily a wrapper GLFW along with a few extra functionalities. **Example** : In case you are using some library like `nuklear` for GUI it will mess up all `glfw` callbacks so with CGL you can restore the CGL callbacks with a call to `CGL_window_resecure_callbacks`\n\n* Utility functionalities\n  - Reading/Writing files\n  - Random float/int/bool/vec2/vec3/color generation\n  - CRC32/CRC64\n  - ROT13 encryption\n  - General Purpose Hashing Functions [refer here]( http://www.azillionmonkeys.com/qed/hash.html)\n  - Colored printf (red, green, blue, gray/yellow)\n  - Point/Triangle intersection check\n  - 3D transform API (matrix calculation, etc)\n  - TODO: [ MD5 / SHA 256 / SHA 128 / AES ]\n \n \n\n* Noise API\n  - Multiple faster Alternatives to libc's rand\n  - Procedural Coherent Noise Algorithms\n    - Perlin's Noise (Improved Version)\n    - OpenSimplex2\n    - Value Noise\n    - Worley Noise (or Cellular Noise)\n  - Fractals like FBm, Rigid, Billow, PingPong\n  - Parameters for Octaves/Lacunarity/Weighted Strength/Gain\n \n* Triangulation\n   - Bower Watson Algorithm for Delaunay Triangulator\n   \n* Artificial Intelligence\n  - Neural Networks\n  - Backpropagation\n  - Serializing/Deserializing networks\n  - Multi Variable Linear Regression\n\n* Graph Algorithms\n  - A* Path Finding (general purpose)\n  - N Dimensional Spatial Partition and Localization (n dimensional version of a quad tree)\n\n* Data structures\n  - List(dynamic array) + Stack (implemented together)\n  - Hashtable -\u003e This hashtable is general purpose. Key can be string or a n-bit buffer. The value can be anything int, string, float, custom types, ...\n     - Hashtable Iterator -\u003e Iterate through the hashtable using a [simple](https://github.com/Jaysmito101/cgl/blob/main/examples/c/using_hashtable_iterator.c) API\n  \n* Logger\n  - Can be enabled/disabled by `#define CGL_DISABLE_LOGGER`\n  - Log to multiple log files simultaneously\n  - Log to console with colored output for separate log levels\n  - Logger with auto timestamps\n  \n* Cross Platform Networking (Optional)\n  - You can disable all networking by `#define CGL_EXCLUDE_NETWORKING`\n  - Low-level sockets \n  - SSL sockets (optional) (requires  OpenSSL)\n  - HTTP/HTTPS request (beta)\n  \n* General Purpose Markov Chains (Optional) [Example](./examples/c/markov_text_generation.c)\n  - Can work with any type of data ( text / image / etc.  )\n  - Train/Generate with 3 - 4 lines of code\n  - Trainer implemented for text generation (n-gram based)\n  - Custom trainer API for custom scenarios\n\n* Cross Platform Threading\n  - Threads\n  - Mutex\n  - Condition Variables (TODO)\n  - NOTE: Implemented using `Win32 Threads` on Windows and `pthread` on Linux. (on Linux you need to link `pthread` to build)\n\n* Bloom\n  - Apply bloom to any tuxtures with just 1 line of code\n  - Implementation based of Unity's bloom\n  - Custom thresholding\n  - Custom downsample/upsample passes\n  - Entirely done in Compute Shaders\n  \n* 2D Collision Detection\n  - Detect collisions between 2D polygons\n  - Generate Separating Axes for polygons\n  - Get Overlap distance\n  - GJK (Gilbert–Johnson–Keerthi distance algorithm)\n  - EPA (Expanding Polytope Algorithm)\n  - SAT (Separate Axis Theorem)\n\n* Marching Square\n  - Fully Customizablt Marcher\n  - Linear Interpolation supported\n  - Generates 2D Mesh (Triangles) for CGL\n\n* Toon Post Processor\n  - Outline Effect\n  - Toon Shading Effect\n  - Hatching Effect\n  - All in a single post process call ( no per object calculation)\n  - Completely implemented in Compute Shader\n  - Customizable\n\n* CGL Ray Cast\n  - Fast 2D Ray Cast\n  - Custom Walls \n  - Bake to Triangle Mesh\n  - Public ray cast functions\n\n* CGL Node Editor\n  - Very fast as its powered by CGL Widgets\n  - Custom nodes, pins, links\n  - Minimal \u0026 Powerful\n  - Render your own nodes \u0026 links type API\n  - Zoom In/Out\n  - Global Offsets\n \n* CGL Audio API\n  - Cross Platform (OpenAL backend)\n  - Simple API\n  - WAV File Loader/Sampler \n\n* CSV API\n  - CSV parser\n  - CSV serializer\n  - CSV document data structure\n\n* CGL Widgets (Optional)\n  - You can disable it by `#define CGL_EXCLUDE_WIDGETS`\n  - API Like [p5.js](https://p5js.org/)\n  - Text widgets (render high quality crisp text without loading or baking any font)\n  - Batch Renderer backend (very fast even for a large number of widgets)\n  - draw (filled or stroked) :\n    - triangle [`CGL_widgets_add_triangle`]\n    - general quad [`CGL_widgets_add_quad`]\n    - rectangle [`CGL_widgets_add_rect` `CGL_widgets_add_rect2f`]\n    - line [`CGL_widgets_add_line`]\n    - circle [`CGL_widgets_add_circle` `CGL_widgets_add_circle2f`]\n    - oval [`CGL_widgets_add_oval`, `CGL_widgets_add_oval2f`]\n    - arc \n  - Plot \n    - Scatter plot\n    - Bar Graph (vertical/horizontal)\n    - Pie Chart\n    - Plot a function\n  - font based text widgets (load custom font for high quality text rendering with widgets api)\n  - Surrport for rendering 3D meshes with widgets API\n  - Support for Textures to Widgets API (efficient)\n  - Advanced Bezier Curve( lines or dotted) widget\n  - Add individual vertices\n  - Adjust stroke color/thickness\n  - Customize Batch renderer max vertices capacity (for low memory systems)\n\n* Math library\n  - Advanced Matrix Library (this is separate from matrix lib for graphics)\n    - Linear Algebra for matrixx math\n  - vec2/vec3/vec4\n  - mat3/mat4 (for graphics)\n  - add/sub/mul/div/scale/length/normalize/lerp/min/max/equal for vec2/vec3/vec4\n  - rotate_x/rotate_y/rotate_z for vec3\n  - scale/translate/rotate_x/rotate_y/rotate_z/add/sub/mul for mat4\n  - perspective for mat4\n  - transpose for mat4/(mat3 TODO)\n  - Rotation Matrices using Goldman's Method\n  - look_at matrix \n  - Quaternion math\n  - Transform vectors\n  - **NOTE:** Most of math functions are implemented via macros so will be **totally inclined** and quite fast without any unnecessary function calls\n\n* High Level OpenGL API for (Optional)\n  - You can completely disable it by `#define CGL_EXCLUDE_GRAPHICS_API`\n  - Texture (2D / 2D Array / Cube map) \n  - Framebuffers\n  - SSBO (Shader Storage Buffer Object)\n  - UBO (Uniform Buffer Object)\n  - Shaders \n    - Vertex \u0026 Fragment (Geometry Shader not included as its not very widely used)\n    - Compute Shader API \n\n* CGL Mesh API\n  - CGL has a high level API for handling meshes\n  - 2 types of meshes are there\n    - CPU mesh -\u003e stores the data also used for mesh operations like\n      - generate triangle\n      - generate quad\n      - load OBJ (beta)\n      - generate cube\n      - generate plane\n      - generate  cylinder\n      - generate sphere\n      - generate mesh out of any parametric surface function [refer here](https://stackoverflow.com/a/31326534/14911094)\n      - calculate normals \n      - perform operation on meshes\n        - add 2 meshes\n        - offset vertices\n        - etc .\n    - GPU mesh -\u003e the pointer to the data stored on GPU side (internally handles the Vertex buffer, Index buffer, Vertex Array) and can used for\n      - render\n      - render instanced\n      - render wireframe\n      - render wireframe instanced\n      \n* CGL camera\n  - CGL provides a proper camera abstraction\n  - Perspective \u0026 Orthographic\n  - It internally handles all matrix calculations (just input the position and rotation)\n  - Auto calculates the Up, Right, Front vectors\n \n* Text Rendering (Optional) (Requires [FreeType2](http://freetype.org/))\n  - You can completely disable it with `#define CGL_EXCLUDE_TEXT_RENDER`\n  - Load Fonts from `.ttf` files\n  - Bake bitmaps for characters\n  - Bake textures from strings\n\n* Trail Renderer\n  - Fast 3D Trail Renderer\n  - Bake to mesh\n  - Custom Shader support\n  - Fully customizable\n  \n \n* Sky Renderer (Optional)\n  - You can completely disable it with `#define CGL_EXCLUDE_SKY_RENDERER`\n  - Supports both a Sky Box (cube mesh) and Sky Sphere/Dome (sphere mesh)\n  - Supports Cube map Textured Sky \n  - Supports Realtime Procedurally Generated Sky ( + procedural clouds)\n  - Render a beautiful sky with just 3 - 5 lines of code\n\n* Phong Renderer (Optional) \n  - You can disable it via `#define CGL_EXCLUDE_PHONG_RENDERER`\n  - It has:\n    - Phone Pipeline -\u003e it is the pipeline holding shader data and global engine data. Options available are\n      - enable/disable blinn correction\n      - enable/disable depth test\n      - enable/disable gamma correction\n      - setup ambient lighting\n      - add/remove lights\n    - Phong Light -\u003e It can be of 3 types:\n      - Directional -\u003e it takes (direction, color, intensity)\n      - Point -\u003e it takes (position, color, itensity, constant, linear, quadratic)\n      - Spot (TODO)\n    - Phong Material\n      - dissuse texture/color\n      - specular texture/color\n      - shininess\n      - normal maps (TODO)\n\n* Tilemap Renderer (Optional)\n   - You can disable it with `#define CGL_EXCLUDE_TILEMAP_RENDERER`\n   - Renders a NxN tilemap with a single line of code\n   - Each tile can have following states\n     - clear (transparent or disabled)\n     - solid color\n     - texture -\u003e Texture can be supplied via:\n       - texture 2d array -\u003e you need to provide depth for each tile\n       - tileset or texture atlas -\u003e you have to provide bounds (normalized 0.0-1.0) of the area of the alas to be used on tile\n    - NOTE: this tile render renders only 4 vertices and has only 1 draw call  (not a instanced call so its quite fast\n    \n  \n ## Things that are being worked on:\n \n * PBR renderer (optional)\n * IBL (optional)\n \n ## Showreels\n \n Checkout out: [here](https://www.youtube.com/@jaysmito101/shorts)\n\n\n**For more see [Examples](./examples)\n\n\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaysmito101%2Fcgl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaysmito101%2Fcgl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaysmito101%2Fcgl/lists"}