8000 GitHub - bigsfr/cgl: CGL (C Graphics Library) is a multipurpose library mainly for recreational coding / demo scenes / prototyping / small games / experimentation.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ cgl Public
forked from Jaysmito101/cgl

CGL (C Graphics Library) is a multipurpose library mainly for recreational coding / demo scenes / prototyping / small games / experimentation.

License

Notifications You must be signed in to change notification settings

bigsfr/cgl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



GitHub repo size Lines of code GitHub commit activity
Maintenance Support me on Patreon


CGL

CGL (C Graphics Library) is a multipurpose library mainly for recreational coding / demoscenes / proptotyping / small games / experementation. 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++.

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

Examples

What does CGL provide?

  • Windowing library

    • This windowing library is primarily a wrapper GLFW along with a few extra functionalities. For 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
  • Utility functionalities

    • Reading/Writing files
    • Random float/int/bool/vec2/vec3/color generation
    • TODO: add more
  • Data structures

    • List(dynamic array) + Stack (implemented together)
    • Hashtable (TODO)
  • Cross platform threading

    • Threads
    • Mutex
    • Condition Variables (TODO)
    • NOTE: Implmented using Win32 Threads on Windows and pthread on linux. (on linux you need to link pthread to build)
  • Math library

    • vec2/vec3/vec4
    • mat3/mat4
    • add/sub/mul/div/scale/length/normalize/lerm/min/max/equal for vec2/vec3/vec4
    • rotate_x/rotate_y/rotate_z for vec3
    • scale/translate/rotate_x/rotate_y/rotate_z/add/sub/mul for mat4
    • perspective for mat4
    • transpose for mat4/ (mat3 TODO)
    • look_at matrix
    • NOTE: Most of math functions are implemented via macros so wil be totally inlined and quite fast without any unnecessary function calls
  • High Level OpenGL API for

    • Texture (2D / 2D Array) (3D & Cubemap TODO)
    • Framebuffers
    • SSBO (Shader Storge Buffer Object)
    • Shaders (Geometry shader TODO)
  • CGL Mesh API

    • CGL has a higl level api for handling meshes
    • 2 types of meshes are there
      • CPU mesh -> stores the data also used for mesh operations like
        • generate triangle
        • generate quad
        • load obj (beta)
        • generate cube
        • calculate normals (TODO)
      • GPU mesh -> the pointer to the data stored on GPU side (internally handles the Vertex buffer, Index buffer, Vertex Array) and can used for
        • render
        • render instanced
        • render wireframe
        • reander wireframe instanced
  • CGL camera

    • CGL provides a proper camera abstraction
    • Perspective & Orthographic
    • It internally handles all matrix calculations (just input the position and rotation)
    • Auto calculates the Up, Right, Front vectors
  • Phong Renderer (Optional)

    • You can disable it via #define CGL_EXCLUDE_PHONG_RENDERER
    • It has:
      • Phone Pipeline -> it is the pipeline holding shader data and global engine data. Options available are
        • enable/disable blinn correction
        • enable/disable depth test
        • enable/disable gamma correction
        • setup ambient lighting
        • add/remove lights
      • Phong Light -> It can be of 3 types:
        • Directional -> it takes (direction, color, intensity)
        • Point -> it takes (position, color, itensity, constant, linear, quadratic)
        • Spot (TODO)
      • Phong Material
        • dissuse texture/color
        • specular texture/color
        • shininess
        • normal maps (TODO)
  • Tilemap Renderer (Optional)

    • You can disable it with #define CGL_EXCLUDE_TILEMAP_RENDERER
    • Renders a NxN tilemap with a single line of code
    • Each tile can have following states
      • clear (transparent or disabled)
      • solid color
      • texture -> Texture can be supplied via:
        • texture 2d array -> you need to provide depth for each tile
        • tileset or texture atlas -> you have to provide bounds (normalized 0.0-1.0) of the area of the alas to be used on tile
    • NOTE: this tile render renders only 4 vertices and has only 1 draw call (not a instanced call so its quite fast

Things that are being worked on:

  • cubemaps and skybox + skysphere
  • procedural sky (refer here )
  • text rendering (static and dynamic) (optional) (requires stb_truetype)
  • PBR renderer (optional)
  • IBL (optional)

Requirements

  • GLFW
  • Glad

About

CGL (C Graphics Library) is a multipurpose library mainly for recreational coding / demo scenes / prototyping / small games / experimentation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%
0