A cross-platform scene-oriented 3D rendering engine for modern C++
VGLX is a rendering engine for modern C++ focused on immediacy and control. It uses a familiar scene-graph built from objects, meshes, cameras, and lights with native performance and explicit GPU access. The engine is fully cross-platform and runs on Windows, macOS, and Linux.
- Manual: https://www.vglx.org/manual/
- API reference: https://www.vglx.org/reference/
- Starter template: https://github.com/shlomnissan/vglx-starter
The easiest way to install VGLX is with the Python installer included in the repository. It guides the process and builds the engine using the correct presets for your system.
# clone the repository
git clone https://github.com/shlomnissan/vglx.git
cd vglx
# run the installer
python3 -m tools.installer.mainThe installer checks for CMake, detects your compiler, and asks for an installation prefix.
#include <vglx/vglx.hpp>
#include <print>
using namespace vglx;
auto main() -> int {
auto window = Window {{
.title = "Hello VGLX",
.width = 1280,
.height = 720,
.vsync = true
}};
if (auto result = window.Initialize(); !result.has_value()) {
std::println(stderr, "{}", result.error());
return 1;
}
auto renderer = Renderer {{
.framebuffer_width = window.FramebufferWidth(),
.framebuffer_height = window.FramebufferHeight(),
.sample_count = 4,
}};
if (auto result = renderer.Initialize(); !result.has_value()) {
std::println(stderr, "{}", result.error());
return 1;
}
auto camera = PerspectiveCamera::Create({
.fov = math::DegToRad(60.0f),
.aspect = window.AspectRatio(),
.near = 0.1f,
.far = 1000.0f
});
auto scene = Scene::Create();
scene->Add(OrbitControls::Create(camera.get(), {
.radius = 3.0f,
}));
scene->Add(Mesh::Create(
BoxGeometry::Create(),
PhongMaterial::Create({.color = 0x049EF4})
));
scene->Add(PointLight::Create({
.color = 0xFFFFFF,
.intensity = 1.0f
}))->transform.Translate({2.0f, 2.5f, 4.0f});
auto timer = FrameTimer {true};
while (!window.ShouldClose()) {
window.PollEvents();
scene->Advance(timer.Tick());
renderer.Render(scene.get(), camera.get());
window.SwapBuffers();
}
return 0;
}If you run into problems, please open an issue on GitHub. If possible include:
- Your OS and compiler version
- CMake command you ran
- Installer or compiler logs
___ ___ ________ ___ ___ ___
|\ \ / /|\ ____\|\ \ |\ \ / /|
\ \ \ / / | \ \___|\ \ \ \ \ \/ / /
\ \ \/ / / \ \ \ __\ \ \ \ \ / /
\ \ / / \ \ \|\ \ \ \____ / \/
\ \__/ / \ \_______\ \_______\/ /\ \
\|__|/ \|_______|\|_______/__/ /\ __\
|__|/ \|__|
The MIT License (MIT)
Copyright (c) 2024-present Shlomi Nissan
https://www.vglx.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.