Albin Johansson Centurion Versions Save

A modern C++ wrapper library for SDL2 in order to improve type-safety, memory safety and overall ease-of-use.

v7.3.0

11 months ago

Release notes

This is likely the last release before Centurion 8 (which will target SDL3).

  • Fixed a compilation issue related to basic_surface when CENTURION_NO_SDL_IMAGE was defined
  • Rearranged headers. This is a potentially breaking change, but you should be fine if you've included the main centurion.hpp header.
  • Exception messages are now copied and stored in exception objects themselves (thanks @v1993)
  • Added file overloads to various constructors and factory functions (thanks @v1993)
  • Added close and release functions to file (thanks @v1993)
  • Updated to SDL 2.26
    • Added basic_window::size_in_pixels
    • Added basic_joystick::get_guid_info
    • Added new mouse position functions to mouse_wheel_event
  • Tweak formatting
  • Test dependencies are now installed using Vcpkg
  • Minor CI improvements
  • Minor build script improvements
  • Minor documentation improvements
  • Removed Doxygen documentation, use the wiki instead. Or you can build the documentation yourself using the root Doxyfile.

v.7.2.0

1 year ago

Release notes

This release adds support for SDL 2.24, SDL_ttf 2.20, SDL_mixer 2.6, and SDL_image 2.6.

SDL

  • display_count() now returns an optional value
  • Added class joy_battery_event
  • Added class virtual_joystick_desc
  • Added event_type::joy_battery_updated
  • Added keyboard::reset()
  • Added display_with() functions
  • Added basic_controller::firmware_version()
  • Added basic_controller::path()
  • Added basic_joystick::firmware_version()
  • Added basic_joystick::path()
  • Added virtual_joystick_desc overload of basic_joystick::attach_virtual()
  • Added gl_attribute::float_buffers
  • Fixed compilation issue with some overloads of message_box::show(), thanks @gxm11!

SDL_ttf

  • Added enum wrap_alignment
  • Added font::set_wrap_align()
  • Added font::wrap_align()

SDL_mixer

  • Added basic_sound_effect::set_master_volume()
  • Added basic_sound_effect::master_volume()
  • Added music::current_title()
  • Added music::title()
  • Added music::title_tag()
  • Added music::artist_tag()
  • Added music::album_tag()
  • Added music::copyright_tag()
  • Added music::position()
  • Added music::duration()
  • Added music::loop_start_time()
  • Added music::loop_end_time()
  • Added music::loop_length()

SDL_image

  • Added animation class
  • Added file::is_avif()
  • Added file::is_jxl()
  • Added file::is_qoi()

v7.1.0

1 year ago

Release notes

This release adds support for SDL 2.0.22.

  • Added get_window(renderer_handle) function for getting the window associated with a renderer
  • Added text_editing_ext_event
  • Other minor improvements

v7.0.0

2 years ago

Notes

This release brings the same changes outlined in the release notes for the v7.0.0 beta, with the following differences.

  • Add fwd.hpp header with forward declarations of most Centurion types
  • Put font_bundle in cen::experimental namespace
  • Functions with create_ prefix now use make_
    • basic_window::create_renderer() -> basic_window::make_renderer()
    • basic_renderer::create_texture() -> basic_renderer::make_texture()
    • vk::create_surface() -> vk::make_surface()

v6.3.2

2 years ago
  • Fixed a special case in color functions as_rgb(), as_rgba(), and as_argb() when using std::format()
  • Removed some invalid documentation comments referencing the non-existent release 6.4.0

v7.0.0-beta

2 years ago

This major release includes many naming changes and improvements, and many APIs have either been overhauled or removed.

Note, this list is incomplete.

General

  • Added support for SDL 2.0.18 and 2.0.20
  • Added support for SDL_ttf 2.0.18
  • Removed support for amalgamated header mode
  • Greatly reduced the amount of headers
  • Removed comparison operators between Centurion and SDL2 enums
  • Removed header everything.hpp
  • Removed header macros.hpp
  • Added more examples

:building_construction: Common

  • Added alias bounded_array_ref
  • Added alias enable_for_enum_t
  • Added milliseconds aliases u16ms, u32ms, and u64ms
  • Added Unicode aliases unicode_t and unicode32_t
  • Renamed integer aliases
    • u8 -> uint8
    • u16 -> uint16
    • u32 -> uint32
    • u64 -> uint64
    • i8 -> int8
    • i16 -> int16
    • i32 -> int32
    • i64 -> int64
  • Overhauled SFINAE helper aliases
    • enable_if_pointer_v -> enable_for_pointer_t
    • enable_if_convertible_t -> enable_for_convertible_t
    • Replaced alias enable_if_number_t with variable template is_number<T>
  • Removed string aliases str, czstring, and zstring
  • Removed alias not_null
  • Overhauled literal operators
    • Removed _u8, _u16, _u32, _u64, _i8, _i16, _i32, and _i64
    • Removed _ns, _us, and _s
    • Put _ms literal operator in inline namespace time_literals (full qualification is now cen::literals::time_literals)
    • _ms literal operator now returns u64ms when using SDL 2.0.18 or later
  • Renamed cen_error to exception

Feature detection

  • Removed macro CENTURION_HAS_STD_MEMORY_RESOURCE
  • Removed macro CENTURION_HAS_FEATURE_MEMORY_RESOURCE
  • Added macro CENTURION_HAS_FEATURE_CHARCONV

Compiler

  • Replaced is_debug_build() with is_debug_build constant
  • Replaced is_release_build() with is_release_build constant
  • Replaced on_msvc() with on_msvc constant
  • Replaced on_gcc() with on_gcc constant
  • Replaced on_clang() with on_clang constant
  • Removed on_emscripten()
  • Removed on_intel_cpp()

Initialization

  • Removed hint API
  • Removed library class, replaced by sdl, img, mix, and ttf classes

Logging

  • Added support for custom log categories
  • Removed namespace cen::log
    • log::reset_priorities() -> reset_priorities()
    • log::set_priority() -> set_priority()
    • log::get_priority() -> get_priority()
    • log::max_message_size() -> max_log_message_size()
    • log::msg() -> log()
    • log::error() -> log_error()
    • log::critical() -> log_critical()
    • log::warn() -> log_warn()
    • log::debug() -> log_debug()
    • log::info() -> log_info()
    • log::verbose() -> log_verbose()
    • Removed log::put()
    • Removed log::set_output_function()
    • Removed log::use_preset_output_function()

Math

  • Replaced basic_rect::isFloating withbasic_rect::floating
  • Replaced basic_rect::isIntegral withbasic_rect::integral
  • Added new terse conversion functions as_i()/as_f() to math types

Versioning

  • version is no longer initalized to the current Centurion version by default
  • Added current_version()

:sound: Audio

  • Removed alias channel_index
  • Removed alias group_index
  • Removed alias music_finished_callback
  • Removed alias channel_finished_callback
  • Removed alias sound_font_visit_callback
  • Removed set_sound_fonts()
  • Removed get_sound_fonts()
  • Removed each_sound_font()
  • Removed namespace cen::channels and all of its functions

music

  • Added alias ms_type
  • Added is_fading_in()
  • Added is_fading_out()
  • Removed explicit conversions to Mix_Music* and const Mix_Music*

basic_sound_effect

  • Added alias ms_type
  • Removed explicit conversions to Mix_Chunk* and const Mix_Chunk*

🧶 Concurrency

  • Removed alias thread::id

:eyes: Events

  • Renamed common_event to event_base
  • Renamed event to event_handler
  • Added support for user events (with custom type identifiers)

event_handler

  • Added overload of is() accepting an event_type enumerator
  • Removed constructors accepting events
  • Removed overload of push() accepting a non-const event handler
  • Added raw_type()
  • Renamed is_empty() to empty()

keyboard_event

  • Renamed functions
    • set_scan_code() -> set_scan()
    • set_key_code() -> set_key()
    • set_button_state() -> set_state()
    • is_only_any_of_active() -> is_only_subset_active()
  • Removed get_scan_code()
  • Removed get_key_code()

:file_folder: Filesystem

file_mode

  • Renamed enumerators
    • read_existing -> r
    • read_existing_binary -> rb
    • write -> w
    • write_binary -> wb
    • append_or_create -> a
    • append_or_create_binary -> ab
    • read_write_existing -> rx
    • read_write_existing_binary -> rbx
    • read_write_replace -> wx
    • read_write_replace_binary -> wbx
    • read_append -> ax
    • read_append_binary -> abx

file_type

  • Renamed enumerators
    • win32 -> win
    • stdio -> std

🔡 Text

  • Moved text rendering functions from basic_renderer to font
  • Removed rendering convenience functions from font_cache
  • Added experimental font_bundle class

🎮 Input

  • Removed haptic API
  • Removed touch namespace and all of its functions
  • Added class finger
  • Renamed finger_state to controller_finger_state
  • Renamed key_modifier to key_mod (and removed key_mod alias)
  • Added is_active(key_mod)
  • Added is_only_active(key_mod)
  • Added is_only_subset_active(key_mod)

key_mod

  • Renamed enumerators
    • left_shift -> lshift
    • right_shift -> rshift
    • left_ctrl -> lctrl
    • right_ctrl -> rctrl
    • left_alt -> lalt
    • right_alt -> ralt
    • left_gui -> lgui
    • right_gui -> rgui

keyboard

  • Renamed update() to refresh()
  • Renamed key_count() to size()
  • Removed key modifier functions is_active(), is_only_active(), and is_only_any_of_active()

mouse

  • Added warp()
  • Added warp_in_window()
  • Added set_relative_mode()
  • Added is_relative_mode_enabled()
  • Added update()
  • Added update(const basic_renderer&)
  • Added is_middle_pressed()
  • Added was_middle_released()
  • Added position_relative_window()
  • Added position_relative_desktop()
  • Added delta()
  • Added is_haptic()
  • Renamed functions
    • is_left_button_pressed() -> is_left_pressed()
    • is_right_button_pressed() -> is_right_pressed()
    • was_left_button_released() -> was_left_released()
    • was_right_button_released() -> was_right_released()
  • Removed update(int, int)
  • Removed update(iarea)
  • Removed reset()
  • Removed set_logical_width()
  • Removed set_logical_height()
  • Removed set_logical_size()
  • Removed logical_width()
  • Removed logical_height()
  • Removed logical_size()

:computer: System

  • Removed namespace cen::counter
    • counter::frequency() -> frequency()
    • counter::now() -> now()
    • counter::now_in_seconds() -> now_in_seconds()
    • counter::ticks() -> ticks32()
  • Removed namespace cen::clipboard
    • clipboard::has_text() -> has_clipboard()
    • clipboard::get_text() -> get_clipboard()
    • clipboard::set_text() -> set_clipboard()
  • Removed namespace cen::ram
    • ram::amount_mb() -> ram_mb()
    • ram::amount_gb() -> ram_gb()
  • Added ticks64()

Platform

  • Renamed platform_id enumerator mac_osx to macos

Power

  • Removed battery::exists()
  • Removed namespace cen::battery
    • battery::seconds_left() -> battery_seconds()
    • battery::minutes_left() -> battery_minutes()
    • battery::percentage() -> battery_percentage()
    • battery::state() -> query_battery()
    • battery::is_available() -> is_battery_available()
    • battery::is_charging() -> is_battery_charging()
    • battery::is_charged() -> is_battery_charged()

:desktop_computer: Video

  • Renderers are now created using basic_window::create_renderer()
  • Textures are now created using basic_renderer::create_texture()
  • The as_rgb(), as_rgba(), and as_argb() functions in color now use std::format, if available
  • Removed double overload of blend() function

Rendering

  • Removed font handling API from basic_renderer
  • Removed translated rendering API from basic_renderer
  • Removed text rendering functions from basic_renderer, and moved them to font

v6.3.1

2 years ago

Release notes

  • Fix incorrect point distance calculation (thanks @twantonie)

v6.3.0

2 years ago

Release notes

This release brings a few minor improvements, features and fixes. Such as adding support for more events and explicitly supporting not using the amalgamated centurion.hpp header (i.e. it's now supported to include the headers in the src folder directly).

Audio

  • [+] fade_status_count()
  • [+] music_type_count()

Core

  • [~] Optimized log::use_preset_output_function() by formatting to a stack buffer (using std::format_to_n)

Compiler

  • [+] CENTURION_HAS_FEATURE_TO_ARRAY

Events

  • [+] Added enumerators to event_type
    • app_will_enter_foreground
    • locale_changed
    • controller_touchpad_down
    • controller_touchpad_up
    • controller_touchpad_motion
    • controller_sensor_update
  • [+] display_event
  • [+] sensor_event
  • [+] user_event
  • [+] controller_touchpad_event
  • [-] Removed deprecated dollar_gesture_event::fingers() function
  • [-] Removed deprecated keyboard_event::modifier_active() function
  • [-] Removed deprecated keyboard_event::shift_active() function
  • [-] Removed deprecated keyboard_event::ctrl_active() function
  • [-] Removed deprecated keyboard_event::alt_active() function
  • [-] Removed deprecated keyboard_event::gui_active() function
  • [-] Removed deprecated keyboard_event::caps_active() function
  • [-] Removed deprecated keyboard_event::num_active() function
  • [-] Removed deprecated multi_gesture_event::set_fingers() function
  • [-] Removed deprecated multi_gesture_event::fingers() function

Video

  • [~] Fixed special case in the color::as_{rgb/rgba/argb} functions which could result in the resulting string being shorter than expected
  • [+] blend_factor enum
  • [+] blend_op enum
  • [+] blend_task struct
  • [+] compose_blend_mode()
  • [-] Removed deprecated overloads of from_hsv() and from_hsl() from color

v6.2.0

2 years ago

Release notes

The major features of this release includes adding support for SDL 2.0.16 and using C++20 facilities wherever possible, whilst still remaining compatible with C++17.

Audio

  • [~] Fixed one of the operator!= overloads for fade_status incorrectly taking two Mix_Fading values as arguments
  • [+] Added overloads of to_string() and operator<< for fade_status
  • [+] Added overloads of to_string() and operator<< for music_type

Compiler

  • [+] CENTURION_NODISCARD_CTOR
  • [+] CENTURION_HAS_FEATURE_CPP20
  • [+] CENTURION_HAS_FEATURE_FORMAT
  • [+] CENTURION_HAS_FEATURE_CONCEPTS
  • [+] CENTURION_HAS_FEATURE_MEMORY_RESOURCE
  • [+] CENTURION_HAS_FEATURE_LERP
  • [+] CENTURION_HAS_FEATURE_SPACESHIP
  • [+] CENTURION_HAS_FEATURE_CHRONO_TIME_ZONES

Core

  • [+] Added str alias for const char*
  • [+] log_priority_count()
  • [+] log::set_output_function() (C++20 only)
  • [+] log::use_preset_output_function() (C++20 only)
  • [~] Deprecated czstring alias
  • [~] Deprecated zstring alias
  • [~] Marked library constructors as nodiscard (C++20 only)
  • [~] Deprecated CENTURION_HAS_STD_MEMORY_RESOURCE macro
  • [+] Concept is_stateless_callable (C++20 only)
  • [+] Added overloads of to_string() and operator<< for log_category
  • [+] Added overloads of to_string() and operator<< for log_priority

Events

  • [+] Added overloads of to_string() and operator<< for event_type
  • [+] Added overloads of to_string() and operator<< for mouse_wheel_direction
  • [+] Added overloads of to_string() and operator<< for window_event_id

Filesystem

  • [+] Added overloads of to_string() and operator<< for file_mode
  • [+] Added overloads of to_string() and operator<< for file_type
  • [+] Added overloads of to_string() and operator<< for seek_mode

Hints

  • [+] hint::audio_include_monitors
  • [+] hint::audio_device_stream_role
  • [~] get_hint() is no longer incorrectly marked as noexcept
  • [~] get_hint() now has an explicit return type
  • [~] Replaced hint::joystick::hidapi_correlate_xinput with hint::joystick::rawinput_correlate_xinput on SDL 2.0.16 or later
  • [+] Concept is_hint_callback (C++20 only)
  • [+] add_hint_callback_ex() (C++20 only)

Input

  • [-] Removed deprecated key_state alias
  • [-] Removed deprecated mouse_state alias
  • [~] haptic_feature enum now uses uint as underlying type
  • [~] haptic_direction_type enum now uses u8 as underlying type
  • [~] mouse_wheel_direction enum now uses u32 as underlying type
  • [+] controller_type::amazon_luna
  • [+] controller_type::google_stadia
  • [+] basic_controller::get_sensor_data_rate()
  • [+] basic_controller::send_effect()
  • [+] basic_joystick::send_effect()
  • [+] set_modifiers()
  • [+] get_modifiers()
  • [+] keyboard::is_only_active(key_mod)
  • [+] keyboard::is_only_any_of_active(key_mod)
  • [+] Added touch_device_type alias for touch::device_type
  • [+] Added touch_finger_state alias for touch::finger_state
  • [+] Added overloads of to_string() and operator<< for button_state
  • [+] Added overloads of to_string() and operator<< for keyboard
  • [+] Added overloads of to_string() and operator<< for mouse
  • [+] Added overloads of to_string() and operator<< for mouse_button
  • [+] Added overloads of to_string() and operator<< for controller_type
  • [+] Added overloads of to_string() and operator<< for controller_axis
  • [+] Added overloads of to_string() and operator<< for controller_button
  • [+] Added overloads of to_string() and operator<< for controller_bind_type
  • [+] Added overloads of to_string() and operator<< for joy_hat_position
  • [+] Added overloads of to_string() and operator<< for joystick_power
  • [+] Added overloads of to_string() and operator<< for joystick_type
  • [+] Added overloads of to_string() and operator<< for hat_state
  • [+] Added overloads of to_string() and operator<< for sensor_type
  • [+] Added overloads of to_string() and operator<< for touch_device_type
  • [+] Added overloads of to_string() and operator<< for button_order
  • [+] Added overloads of to_string() and operator<< for haptic_direction_type
  • [+] Added overloads of to_string() and operator<< for haptic_feature
  • [+] Added overloads of to_string() and operator<< for key_modifier
  • [+] Added overloads of to_string() and operator<< for basic_controller::mapping_result

Math

  • [~] Added operator<=> to vector3 (C++20 only)
  • [~] Added defaulted operator== for basic_area (C++20 only)
  • [~] Made operator== and operator!= overloads for basic_point templated

System

  • [+] Added overloads of to_string() and operator<< for platform_id
  • [+] Added overloads of to_string() and operator<< for power_state

Threads

  • [+] thread::init(): Constrained factory functions, supporting non-void user data or no user data at all (along with optional return values) (C++20 only)
  • [~] Deprecated thread::id, use thread_id instead
  • [~] Marked thread constructor as nodiscard (C++20 only)
  • [~] Marked scoped_lock constructors as nodiscard (C++20 only)
  • [~] Marked try_lock constructor as nodiscard (C++20 only)
  • [+] Added overloads of to_string() and operator<< for lock_status
  • [+] Added overloads of to_string() and operator<< for thread_priority

Video

  • [+] flash_op enum
  • [+] basic_window::flash()
  • [+] basic_window::set_always_on_top()
  • [+] Additional overload of blend() function for colors that accepts a float bias
  • [~] Deprecated double bias overload of blend() for colors
  • [~] Marked gl_library constructor as nodiscard (C++20 only)
  • [~] Marked vk_library constructor as nodiscard (C++20 only)
  • [+] system_cursor_count()
  • [+] Added overloads of to_string() and operator<< for basic_pixel_format_info
  • [+] Added overloads of to_string() and operator<< for gl_attribute
  • [+] Added overloads of to_string() and operator<< for gl_swap_interval
  • [+] Added overloads of to_string() and operator<< for blend_mode
  • [+] Added overloads of to_string() and operator<< for font_hint
  • [+] Added overloads of to_string() and operator<< for message_box::color_id
  • [+] Added overloads of to_string() and operator<< for message_box::default_button
  • [+] Added overloads of to_string() and operator<< for message_box_type
  • [+] Added overloads of to_string() and operator<< for pixel_format
  • [+] Added overloads of to_string() and operator<< for scale_mode
  • [+] Added overloads of to_string() and operator<< for screen_orientation
  • [+] Added overloads of to_string() and operator<< for system_cursor
  • [+] Added overloads of to_string() and operator<< for texture_access

Miscellaneous

  • [~] Switched to using a doxygen-awesome theme
  • [~] Replaced the wiki with new Doxygen pages
  • [+] The CI test suites are now run using both C++17 and C++20
  • [~] Use std::format in to_string() overloads (C++20 only)

v6.1.0

2 years ago

Release notes

This release features a collection of smaller quality-of-life improvements and fixes, along a few more considerable additions such as the possibility to opt-out from using any of the SDL extension libraries and the color class supporting construction/conversion from/to hexadecimal color strings and normalized color values.

Configuration

  • [+] Added opt-out macros to exclude all Centurion classes and functions related to the SDL extension libraries
    • [+] CENTURION_NO_SDL_TTF
    • [+] CENTURION_NO_SDL_MIXER
    • [+] CENTURION_NO_SDL_IMAGE

Events

  • [~] Deprecated keyboard_event::modifier_active()
  • [~] Deprecated dollar_gesture_event::fingers()
  • [~] Deprecated multi_gesture_event::fingers()
  • [~] Deprecated multi_gesture_event::set_fingers()
  • [+] key_mod alias for key_modifier
  • [+] operator| for key_modifier
  • [+] operator& for key_modifier
  • [+] operator~ for key_modifier
  • [+] keyboard_event::is_active(key_modifier)
  • [+] keyboard_event::is_only_active(key_modifier)
  • [+] keyboard_event::is_only_any_of_active(key_modifier)
  • [~] Deprecated keyboard_event::shift_active()
  • [~] Deprecated keyboard_event::ctrl_active()
  • [~] Deprecated keyboard_event::alt_active()
  • [~] Deprecated keyboard_event::gui_active()
  • [~] Deprecated keyboard_event::caps_active()
  • [~] Deprecated keyboard_event::num_active()
  • [+] dollar_gesture_event::finger_count()
  • [+] multi_gesture_event::set_finger_count()
  • [+] multi_gesture_event::finger_count() (fixes incorrect float return type with previous fingers() function)
  • [+] event::data()

Input

  • [+] Added shift, ctrl, alt, gui and reserved enumerators to key_modifier enum.

Video

  • [~] Relaxed pre-conditions of color::from_hsv() and color::from_hsl(), these functions will now clamp the arguments to be within the respective ranges
  • [~] Deprecated double overloads of color::from_hsv() and color::from_hsl(), use the new float overloads instead
  • [+] color::from_rgb()
  • [+] color::from_rgba()
  • [+] color::from_argb()
  • [+] color::from_norm()
  • [+] color::as_rgb()
  • [+] color::as_rgba()
  • [+] color::as_argb()
  • [+] color::red_norm()
  • [+] color::green_norm()
  • [+] color::blue_norm()
  • [+] color::alpha_norm()
  • [+] gl::bind()
  • [+] gl::unbind()
  • [+] gl_context/gl_context_handle aliases for gl::context/gl::context_handle, since classes are usually not located in subnamespaces in the rest of the library

Misc

  • [+] usize alias for std::size_t
  • [~] Improved performance of to_string() overloads