A C++ application that combines Cairo for 2D vector graphics rendering with SDL3 for window management and hardware-accelerated display.
┌─────────────────────────────────────────┐
│ Application │
│ (app.cpp) │
├─────────────────────────────────────────┤
│ Cairo Drawing Layer │
│ (drawing.cpp) │
│ (Vector graphics, shapes, text) │
├─────────────────────────────────────────┤
│ SDL3 Surface/Texture Bridge │
│ (renderer.cpp) │
│ (Cairo surface → SDL texture transfer) │
├─────────────────────────────────────────┤
│ SDL3 Window/Renderer │
│ (Window, events, hardware rendering) │
└─────────────────────────────────────────┘
cpp_libsdl3_graphics_cairo/
├── CMakeLists.txt # Build configuration
├── .gitignore # Git ignore rules
├── docs/
│ └── readme.md # This documentation
├── src/
│ ├── main.cpp # Entry point
│ ├── app.hpp/cpp # Application lifecycle & event loop
│ ├── renderer.hpp/cpp # Cairo-SDL3 bridge
│ └── drawing.hpp/cpp # Cairo drawing utilities
└── build/ # Build output (gitignored)
| File | Purpose |
|---|---|
main.cpp |
Entry point, creates and runs the App |
app.hpp/cpp |
Application class managing window, events, and render loop |
renderer.hpp/cpp |
Bridges Cairo surfaces with SDL3 textures |
drawing.hpp/cpp |
Cairo drawing utilities and animated demo |
- SDL3 creates a window and hardware-accelerated renderer
- SDL_Surface is created with ARGB8888 format (Cairo-compatible)
- Cairo surface wraps the SDL surface's pixel buffer
- Cairo context draws vector graphics to the surface
- SDL_Texture is updated from the surface and rendered to screen
- Animated shapes (circles, rounded rectangles)
- Gradient fills
- Bezier curves
- Text rendering
- Window resizing support
- ~60 FPS frame rate
- SDL3 - Window management, input, rendering
- Cairo - 2D vector graphics library
- CMake 3.16+ - Build system
- C++17 compiler
sudo apt install libcairo2-dev cmake build-essential
# SDL3 may need to be built from sourcemkdir build && cd build
cmake ..
make./build/cairo_sdl3_appPress ESC to exit the application.
| Key | Action |
|---|---|
| ESC | Exit application |
| Window resize | Automatically adapts |