libgfx is a 2D graphics library written in modern C++23.
- An API that is easy to use right, and hard to use wrong
- Be cross-platform, portable and embeddable
Only the currently implemented platforms have a checkmark next to them.
Check out examples/, for on how to use libgfx with any of these technologies.
- Linux via glfw
- Linux via Wayland & EGL
- Linux via gtkmm
- Web via emscripten
- Linux via qt
- Windows via WinAPI
libgfx currently supports the following graphics APIs:
- OpenGL 4.5 on desktop
- WebGL2 on the browser
- User Interfaces
- Data Visualizations
- Animations
- Games
- glfw3
- freetype2
- any C++23 compiler (clang/gcc)
- cmake
- emscripten (if building for web)
Using Just
cd libgfx/
sudo just installcd libgfx/
cmake -Bbuild
cmake -Bbuild -GNinja # for faster builds using Ninja
cmake --build build
sudo cmake --install buildBuilding for Web using Emscripten
cd libgfx/
emcmake cmake -Bbuild
emmake make -C build -j$(nproc)
sudo cmake --install build#include <gfx/gfx.h>
int main() {
gfx::Window window(1600, 900, "my gfx application");
window.draw_loop([&](gfx::Renderer& rd) {
rd.clear_background(gfx::Color::black());
rd.draw_rectangle(0, 0, 100, 100, gfx::Color::white());
});
}This library comes with find_package() support for CMake, which means that after installing the library you can just insert this line into your CMakeLists.txt:
find_package(gfx REQUIRED)And then link to the gfx target using target_link_libraries().