Skip to content

lukasx999/libgfx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

486 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libgfx

libgfx is a 2D graphics library written in modern C++23.

Goals

  • An API that is easy to use right, and hard to use wrong
  • Be cross-platform, portable and embeddable

Platforms

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

Graphics APIs

libgfx currently supports the following graphics APIs:

  • OpenGL 4.5 on desktop
  • WebGL2 on the browser

Use cases

  • User Interfaces
  • Data Visualizations
  • Animations
  • Games

Build Instructions

Requirements

  • glfw3
  • freetype2
  • any C++23 compiler (clang/gcc)
  • cmake
  • emscripten (if building for web)

Using Just

cd libgfx/
sudo just install

Using CMake

cd libgfx/
cmake -Bbuild
cmake -Bbuild -GNinja # for faster builds using Ninja
cmake --build build
sudo cmake --install build

Building for Web using Emscripten

cd libgfx/
emcmake cmake -Bbuild
emmake make -C build -j$(nproc)
sudo cmake --install build

Example

#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());
    });

}

Building Your Application

Using CMake

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().

About

C++ Graphics Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors