Skip to content
Uğur Güney edited this page Feb 11, 2024 · 3 revisions

This project is not a renderer, but a helper library to make writing of graphics app easier. I think of it as a workshop full of tools. It is a thin abstraction over OpenGL.

My goal is to have a handy workshop using which I can implement computer graphics techniques. An application can be written by just using the OpenGL abstractions, or it can be written using the full-feature set, such as lighting system, asset manager, Editor etc. This way it is up to the author to choose how simple/complex, compact/explicit etc the app will be.

Current features

It has RAII abstractions over following OpenGL objects/resources:

GlHandle

  • Immovable id
  • ...

Textures

  • Abstracts over OpenGL Texture
  • Read from file, or generate programmatically
  • Write into file
  • Resize
  • Bind to a unit
  • Cubemaps made of 6 images
  • A Specs struct that holds info on texture parameters via enum classes such as Format, Filter, Wrap. (It does conversion from these abstractions to internal OpenGL texture creation parameters).

Models

  • Abstracts over OpenGL Vertex Array, Index Buffer and Vertex Buffer
  • read (and write?) OBJ files
  • default set of vertex attributes: position, 2 sets of UV, normal, color and a custom vec4
  • procedural generation for Quad, Box, Torus and Axes
  • Stores a copy of vertex, index data on C++ side

Shaders

  • Abstracts over OpenGL shaders and programs
  • Creates shader by source code or file
  • Can handle compute shader, vertex+fragment shaders, or vertex+geometry+fragment shaders
  • Has a reload method, which only replaces existing program if new shader code compiles and links successfully, that enables hot reloading without reloading the app and without breaking the app by submitting a broken shader.
  • Has a library of shader snippets which can be included in shaders using GL_ARB_shading_language_include. Any file added to the shader library under assets/shaders/lib becomes a "named string" that can be included in app shaders.
  • Has a common/utility library functions stored in name strings to be used in other shaders (without a fear of including same file more than once)
  • Has methods for uploading uniforms such as setInteger, setVector3, setMatrix4
  • Also has helper utilities to reflect on uniforms (their name, type, location) and uniform blocks (uniform names and offsets) in the shader (especially used by the Material system)

Framebuffers

  • Abstracts over OpenGL Framebuffer
  • Takes a vector of specs for color attachments and optionally one spec for depth buffer
  • resizeIfNeeded resizes all attachment textures if given new size is different than current size (very useful for making apps with resizable windows)
  • has default constructors, and factory function such as makeDefaultColorOnly, makeDefaultDepthOnly
  • can get a reference to any attachment to be used as input textures of further passes

Uniform Buffers

Other abstractions that does not correspond 1-to-1 with an OpenGL object

Workshop

  • The backbone of the app. has begin frame, end frame methods ...

Camera

Lights

Scene

Hierarchy

Asset Manager

  • very simple structure that's only

Material

Asset Library

  • shaders (phong, skybox, solid color, unlit, full screen sampler), models (want to bring all standard computer graphics models such as teapot, dragon, that church, damaged helmet, cow etc), images stored in the version control

Inputs

  • keyboard keys
  • mouse cursor, and buttons
  • drag helper
  • for GLFW and ImGui

UI features

  • Hierarchy Window
  • Inspector Window
  • TextureViewer Window
  • Editor Window

Dependencies

minimum requirements for an OpenGL app are glad and GLFW. But we mostly want to do some math operations, which bring glm. And ImGui brings the UI functionality. stb enables loading/saving image files, and tinyobjloader enables loading OBJ files. I see all these as default dependencies for any 3D graphics application.

  • glad
  • GLFW
  • GLM
  • Google Test
  • ImGui
  • ImPlot (not used yet)
  • stb
  • tinyobjloader
  • vivid
  • xatlas

Example apps