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

Setup

Available as meson wrap

or in ubuntu

$ sudo apt-get install libglfw3-dev

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

../glfw.cc:73:37: error: incomplete type ‘GrDirectContext’ used in nested name specifier

This is due to the following change

// a Factory has been introduced here within namespace GrDirectContext(s) to loose everyone
#include "include/gpu/ganesh/gl/GrGLDirectContext.h"

sContext = GrDirectContexts::MakeGL(interface).release();

see also

Written on October 5, 2024, Last update on November 23, 2024
game-engine opengl lib gui c++ in-progress