GLFW (GLFrameWork) 🚧
an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contexts and surfaces, receiving input and events. - Home
It is similar to LibSDL, but is more lightweight and GPU-centric. GLFW is designed more with greenfield projects in mind, whereas LibSDL was designed from the beginning to help with porting existing code. - HN
- Notably it is missing any kind of audio support, but you probably want to ues FMOD, Wwise, or iirKlang anyway.
- SDL is all of that, plus various utilities for porting and some platform abstractions that are no longer needed. For example, logging, assertions, blitting, endian conversion, file abstraction, threads and atomics. There are a few associated helper libraries designed to work with SDL, like SDL_image, SDL_ttf, and SDL_mixer. These are optional.
- SFML is all of that, plus the interface is written in C++, there’s all sorts of things like sprite drawing, texture loading, and audio systems mixed in, plus a bunch of extra random functionality like HTTP clients, OpenGL wrappers, etc.
GLFW + Skia + ImGui
Rational:
- GLFW provide the windows layer
- Skia provide a 2D vector layer (with far more advanced feature than sfml)
- ImGui provide an interactive GUI on top of that.
Should be ideal for some basic to advanced visualisation without requiring 3D.
Cairo could have been an option, but Cairo does not natively support opengl as rendered (you have to manuall render and then export to a texture).
User Input
- Handling mouse click in GLFW+ImGui - retrieve mouse coordinate and distinguish ImGui from canvas interaction
- Attach user data for callback
- Use a Global or Static Variable
- Use glfwSetWindowUserPointer()
- in which case you can also use a lambda for defining the callback
- Use glfwSetWindowUserPointer()
- Attach user data for callback
- Use a Global or Static Variable
- key callback
Setup
Available as meson wrap
or in ubuntu
Can be easily used with ImGui
Introduction
Integration with Skia
There are some challenge (and they are all achivable):
- need to compile SKIA with openGL support - using google specific tools
- need to accomodate to latest braking change in SKIA (see below for 2024 setup).
see glfw_ship.cpp - instructions to use skia and glfw together. (download, installation, first program). as of Sept 2023, Windows is broken but this is still sadly the best starting resource for skia on Windows too.
This part doesn’t compile yet - issue with access to
This is due to the following change
see also
- GLFW and Dear ImGui
- glad - (Multi-Language GL/GLES/EGL/GLX/WGL Loader-Generator)
- GLFW + ImGUI -> 5 threads ?
- RGFW - an alternative Single-header C99 window abstraction library