Graphics, audio, GUI and retro-computing library for the ESP32
Turn a few dollars of hardware into a complete computer: VGA or composite video, PS/2 keyboard and mouse, multi-channel sound, windows and controls, an ANSI terminal and emulators of classic CPUs. FabGL2 is a native ESP-IDF component (ESP-IDF 6.1 or newer), with no Arduino dependency.
Made with FabGL2
Every picture comes from one of the examples included in the repository, captured from a TTGO VGA32 board (an ESP32 and a handful of resistors).
FabGL Synth
8-voice polyphonic synthesizer: resonant ladder filter, LFO, arpeggiator, 64 presets and Bluetooth MIDI
FabGL Drum
Drum machine with 16 instruments, 32 step sequencer, song mode and 8 kits
IBM PC/XT emulator
8086 with CGA and Hercules graphics: MS-DOS, Windows 3.0, GEM, GEOS, ELKS
What is inside
Video output
VGA with 2 to 64 colors and resolutions up to 1280x768 (Linux-style modelines), a low-memory text mode, direct scanline rendering and PAL/NTSC color composite video from the internal DAC.
Display controllers Graphics
Lines, rectangles, ellipses, paths, bitmaps, fonts and scrolling, executed during the vertical retrace (no flicker), double buffering and unlimited sprites with collision detection.
Canvas ·
Sprites Keyboard and mouse
PS/2 keyboard with international layouts and PS/2 mouse, handled by the ULP coprocessor: both CPU cores stay free for the application.
Keyboard and mouse Sound
Multi-channel mixer with waveform generators and samples, an 8-voice polyphonic synthesizer, a drum machine engine and Bluetooth LE MIDI input.
Sound Graphical user interface
Overlapping windows, mouse support, buttons, edits, lists, sliders, knobs, faders, graphs, an on-screen piano, a dark theme and ready-made dialogs (
InputBox).
GUI Terminal
ANSI/VT100 compatible terminal with VT52, ADM-3A, ADM-31, Hazeltine 1500, Osborne I and Kaypro emulations, plus escape sequences for graphics, sound and GPIOs.
Terminal Emulation
Intel 8080, Zilog Z80, MOS 6502 and Intel 8086 CPU cores and peripheral chips (VIA 6522, 8250 UART, 8253 PIT, 8259 PIC, MC146818 RTC...).
PC ·
VIC-20 ·
Altair Utilities
SD card and SPIFFS file browser, NVS preferences, WiFi, HTTP/HTTPS downloads, TCP and ICMP, serial port, I2C, DS3231 real-time clock and MCP23S17 GPIO expander.
Memory and performance tips
Hello, VGA
A complete ESP-IDF application that prints text on a VGA monitor:
extern "C" void app_main()
{
DisplayController.
begin();
cv.clear();
cv.drawText(10, 10, "Hello from FabGL2!");
}
Provides a set of drawing methods.
VGA bitmapped display controller with 16 colors.
void begin(gpio_num_t redGPIO, gpio_num_t greenGPIO, gpio_num_t blueGPIO, gpio_num_t HSyncGPIO, gpio_num_t VSyncGPIO)
Initializer for 8 colors (5 GPIOs).
Single include file of the FabGL library.
Getting started shows how to add the component to a project and how to continue from here. The FabGL2 Tutorial (PDF, about 100 pages) goes from the installation of ESP-IDF on macOS, Windows and Linux to complete applications: a game, a GUI application, a synthesizer, a drum machine, a Z80 computer. Coming from FabGL 1.x? Read the migration guide.
Hardware
FabGL2 runs on the ESP32 (revision 1 or later). Ready-made boards such as the TTGO VGA32 and the Olimex ESP32-SBC-FabGL have everything on board; otherwise the circuits are simple:
- VGA: a resistor DAC, three 270 Ohm resistors for 8 colors or six for 64 colors (schema)
- PS/2 keyboard and mouse: a few resistors on the GPIOs (schema)
- Audio: GPIO 25 through the internal DAC (schema)
- Composite video: no external components
Main classes
| Area | Classes |
| Display | fabgl::VGAController (64 colors), fabgl::VGA2Controller, fabgl::VGA4Controller, fabgl::VGA8Controller, fabgl::VGA16Controller, fabgl::VGATextController, fabgl::VGADirectController, fabgl::CVBS16Controller |
| Drawing | fabgl::Canvas, fabgl::Bitmap, fabgl::Sprite, fabgl::Scene |
| Input | fabgl::PS2Controller, fabgl::Keyboard, fabgl::Mouse |
| GUI | fabgl::uiApp, fabgl::uiFrame and the other ui controls, fabgl::uiDarkTheme, fabgl::InputBox |
| Terminal | fabgl::Terminal (see the vttest score), fabgl::LineEditor |
| Sound | fabgl::SoundGenerator, fabgl::PolySynth, fabgl::DrumMachine, fabgl::BLEMIDI |
| Emulation | fabgl::Z80, fabgl::i8080, fabgl::MOS6502, fabgl::i8086, fabgl::VIA6522 |
| System | fabgl::FileBrowser, fabgl::Preferences, fabgl::SerialPort, fabgl::UARTStream, fabgl::I2C, fabgl::DS3231, fabgl::MCP23S17 |
| Network | fabgl::WiFiScanner, fabgl::WiFiConnection, fabgl::TCPClient, fabgl::HTTPRequest, fabgl::ICMP |
The "Topics" section groups all the classes by subsystem.
License
Created by Fabrizio Di Vittorio. Copyright (c) 2019-2026 Fabrizio Di Vittorio. All rights reserved.
FabGL2 is free software released under the GNU General Public License v3. For a commercial license, please contact fdivi.nosp@m.tto2.nosp@m.013@g.nosp@m.mail.nosp@m..com. You can support the development by purchasing the ESP32-SBC-FabGL board from Olimex.