Halcyon is a barebones SDL wrapper written in modern C++.
Performance is the main priority here, but work has also been put into making sure there is some level of safety as well.
Namespaces are not cluttered, everything is neatly organized—proper C++ design, plain and simple.
After including Halcyon via add_subdirectory(), link against Halcyon::Halcyon.
The following libraries are required:
- SDL3
- SDL3_image
- SDL3_ttf
Halcyon wraps SDL with several concepts:
- Init: Manages SDL subsystem initialization via RAII.
- Proxy: Provides subsystem functionality.
Tip
These are empty classes. You are encouraged to use them with [[no_unique_address]] (also defined as HAL_NO_SIZE for MSVC compatibility).
This library is still under development; some namespaces etc. might not be up-to-date, but the structure should remain the same.
#include <halcyon/video.hpp>
#include <halcyon/main.hpp>
int main(int, char*[]) {
static_assert(hal::is_correct_main<main>);
hal::cleanup_init<hal::system::video> vid;
hal::window wnd{vid, "Example", {640, 480}};
hal::renderer rnd{wnd};
hal::event::variant evt;
while (true) {
while (vid.events.poll(evt)) {
if (evt.kind() == hal::event::type::quit_requested)
return EXIT_SUCCESS; // Normal termination.
}
rnd.present_and_clear();
}
return EXIT_SUCCESS;
}
Halcyon provides several macro functions for a better debugging experience.
"Vital" variants preserve the condition in case debugging is disabled. Use when your condition has side effects.
HAL_PRINT- print a variadic amount of arguments (must support std::ostream::operator<<).HAL_ASSERT[_VITAL]- Assert that a condition is true, panic if not.HAL_WARN_IF[_VITAL]- Print a warning message if a condition is true.HAL_PANIC- Print where the panic occurred along with variadic user-supplied information, then exit.
These debugging facilities are configured via the HAL_DEBUG_ENABLED macro, which also gets automatically defined if NDEBUG isn't defined.
Important
On Windows, GUI applications don't get visible console output by default. As such, Halcyon can create one for you via the HALCYON_WIN32_AUX_CONSOLE CMake variable.
Some things I'd like to eventually implement.
- Audio subsystem
- GPU subsystem