erhe is a C++ library for modern OpenGL experiments.
- Uses direct state access (DSA)
- Uses bindless textures (when supported by driver)
- Uses persistently mapped buffers (can be disabled)
- Uses multi draw indirect
- Uses latest OpenGL and GLSL versions
- Uses multiple threads and OpenGL contexts (disabled by default due to issues with some drivers)
- Uses abstraction for OpenGL pipeline state a bit similar to Vulkan (see
erhe::graphics) - Uses render pass abstraction for eventual support for vulkan and metal
- Simple type safe(r) wrapper for GL API (see
erhe::gl) - Supports Windows and Linux
erhe is evolution of RenderStack https://github.com/tksuoran/RenderStack
All dependencies of erhe are either included directly in src/ for
small libraries, or git pulled from their repositories using CMake
CPM during CMake configure step.
-
C++ compiler. Visual Studio 2022 with msbuild has been tested. Ninjabuild GCC and clang may also work, and some older versions of Visual Studio.
-
Python 3
-
CMake
-
Optional: ninja from https://github.com/ninja-build/ninja/releases
- Recent enough CMake
- Ubuntu 24.04 and 22.04 have been tested
- https://apt.kitware.com/ may help to get recent CMake
- New enough C++ compiler
- clang and GCC which is not older than couple of years should be ok
- python 3
- packages such
libwayland-dev libxkbcommon-dev xorg-dev - arch packages:
gcc ninja cmake git less openssh libx11 libxrandr libxi libxinerama libxcursor mesa wayland wayland-protocols python
For IDE:
- Visual Studio Code with CMake and C++ extensions is supported
- CLion has been tested at some point in the past
git clone https://github.com/tksuoran/erhe- In x64 native tools command prompt for vs 2022, cd to the erhe directory
scripts\configure_vs2022.bat- Open solution from the build directory with Visual Studio
- Build solution, or editor executable
erhe has initial CLion support. Caustion: These instructions have not been tested for a while.
At the time of writing, CLion did not fully support CMake presets. Enable Debug profile only.
If you want to make a release build, edit settings for that profile, instead of trying
to use the other CMake preset profiles.
- Get from VCS: URL:
https://github.com/tksuoran/erhe - Clone
- Keep
DebugCMake profile enabled, do not enable other profiles - Either default toolchain
MinGWorVisual Studio - Wait for CMake configure to complete. It will say
[Finished]in CMake tab - Build Project or Build 'editor'
- Run
editor
For IDE:
- Visual Studio Code with CMake and C++ extensions is supported
- CLion is supported
git clone https://github.com/tksuoran/erhe- Open erhe folder in Visual Studio code
- Execute command: CMake: Select Configure Preset
- Execute command: CMake: Configure
- Execute command: CMake: Build
There are several configuration options that can be set when configuring erhe with CMake:
| Option | Description | Recognized values |
|---|---|---|
| ERHE_AUDIO_LIBRARY | Audio library | miniaudio, none |
| ERHE_FONT_RASTERIZATION_LIBRARY | Font rasterization library | freetype, none |
| ERHE_GLTF_LIBRARY | glTF library | fastgltf, none |
| ERHE_GUI_LIBRARY | GUI library | imgui, none |
| ERHE_PHYSICS_LIBRARY | Physics library | jolt, none |
| ERHE_PROFILE_LIBRARY | Profile library | nvtx, superluminal, tracy, none |
| ERHE_RAYTRACE_LIBRARY | Raytrace library | embree, bvh, none |
| ERHE_SVG_LIBRARY | SVG loading library | plutosvg, none |
| ERHE_TEXT_LAYOUT_LIBRARY | Text layout library | harfbuzz, freetype, none |
| ERHE_WINDOW_LIBRARY | Window library | sdl, glfw |
| ERHE_XR_LIBRARY | XR library | OpenXR, none |
Main purposes of these configuration options are
- Allow faster build times by disabling features that are not used (during development)
- Allow to choose different physics and raytrace backends
The main physics backend is currently jolt.
The main raytrace backend is currently bvh. Even the bvh backend is incomplete,
causing performance issues when creating larger scenes. The embree raytrace backend
has been rotting for a while, it would require some work to get it back to working.
By default erhe (editor) uses raytrace for mouse picking models from 3D viewports.
Alternatively, when raytrace backend is set to none, mouse picking uses GPU rendering
based, where GPU renders ID buffer (unique color per object and triangle) and the image
is read back to the CPU.
The main profile library is Tracy.
Superluminal was briefly tested, but support for it is likely rotten.
'SDL' and glfw are currently supported as window library in erhe.
Only openxr is currently supported as XR library in erhe.
Disabling xr library removes ability to enable headset rendering in erhe editor.
Only plutosvg is current supported as SVG loading library in erhe.
Disabling SVG library removes erhe editor scene node icons.
Disabling glTF library removes capability to parse glTF files in erhe editor. erhe uses fastgltf for importing and exporting glTF files.
Currently, audio library is only used with some code (VR theremin) that is currently not functional.
miniaudio can be enabled, but at the moment it is best to use none.
Currently, only freetype is supported. Disabling font rasterization library removes
native text rendering in erhe. ImGui content is not affected.
Currently, only harfbuzz is supported. Freetype as text layout support is rotten
but might be resurrected.
Disabling font layout library removes native text rendering in erhe. ImGui content is not affected.
Editor is a sandbox like experimentation executable with a random set of functionality
- Scene is (mostly) procedurally generated
- A primitive glTF parser can load glTF file content
- A primitive obj parser can load OBJ file content
- ImGui is used extensively for user interface
- Content can be viewed with OpenXR compatible headset (if enabled from
erhe.ini) - Scene nodes can be manipulated with a basic translation / rotation gizmo
- When physics backend is enabled, scene models can interact physically
- Scene model geometries can be manipulated with operations such as Catmull-Clark
- Scene models can be created using a brush tool (must have selected brush and material)
Major libraries
erhe::geometry provides classes manipulating geometric, polygon based 3D objects.
Geogram library is used as backend for geometry
data structures. Geogram Mesh uses facets, facet corners, vertices and edges, and
attributes can be associated to each of them. Geogram classes are designed for manipulating
3D objects, not for rendering them.
See erhe::scene and erhe::scene_renderer how to render geometry objects.
Some features:
- Catmull-Clark subdivision operation
- Sqrt3 subdivision operation
- Conway operators:
- Ambo
- Chamfer (experimental)
- Dual
- Gyro
- Join
- Kis
- Meta
- Truncate
- CSG / boolean operations using Geogram are experimental, they need more work to be more usable.
erhe::gl provides python generated low level C++ wrappers for OpenGL API.
Some features:
- Strongly typed C++ enums
- Optional API call logging, with enum and bitfield values shown as human readable strings
- Queries for checking GL extension and command support
- Helper functions to map enum values to/from zero based integers (to help with ImGui, hashing, serialization)
erhe::graphics provides classes basic 3D rendering with modern OpenGL.
Currently, erhe uses OpenGL as graphics API. The erhe::graphics builds a Vulkan-like
abstraction on top of OpenGL:
erhe::graphics::Pipelinecapsulates all relevant GL state.
erhe::imgui provides custom ImGui backend and helper classes to manage
and implement ImGui Windows.
erhe::log provides helpers / wrappers for spdlog logging.
erhe::primitive provides classes to convert erhe::geometry::Geometry
to renderable (or raytraceable) vertex and index buffers.
erhe::renderer provides classes to assist rendering generic 3D content.
GPU_ring_bufferprovides recycled memory that is filled by the CPU for each use.Line_renderercan be used to draw debug linesText_renderercan be used to draw 2D text (labels) into 3D viewport
erhe::item provides base object classes for "entities".
Itemhas name, source asset path, flags, unique idHierarchyextendsItemby adding pointer to parent, and vector of children
erhe::scene provides classes for basic 3D scene graph.
NodeextendsItemby adding 3D transformation and glTF-like attachment points for Camera, Light, MeshCamerais like glTF Camera, which can be attached toNodeLightis like glTF Light, which can be attached toNodeMeshis like glTF Mesh (containing a number ofPrimitives), which can be attached to NodeSceneis collection ofNodes
erhe::rendergraph provides classes for arranging rendering passes into a graph
-
Rendergraph_nodelists a number of inputs (dependencies) and outputs. ARendergraph_nodecan be executed as part ofRendergraph. -
Rendergraphis a collection ofRendergraph_nodes.Rendergraphcan be executed, this will execute rendergraph nodes in order that is based on connections between nodes in the graph.
erhe::scene_renderer provides classes for rendering erhe::scene content.
It uses and extends functionality from erhe::renderer.
erhe::window provides windowing system abstraction, currently
using SDL or GLFW.
erhe::verify provides a simple VERIFY(condition) and FATAL(format, ...) macros,
which can be used in place of assert() and unrecoverable error.
erhe::physics provides minimal abstraction / wrappers for Jolt physics library.
PVS-Studio - static analyzer for C, C++, C#, and Java code.