A modern C++ wrapper library for SDL2 in order to improve type-safety, memory safety and overall ease-of-use.
MIT License
Bot releases are visible (Hide)
This is likely the last release before Centurion 8 (which will target SDL3).
basic_surface
when CENTURION_NO_SDL_IMAGE
was definedcenturion.hpp
header.file
overloads to various constructors and factory functions (thanks @v1993)close
and release
functions to file
(thanks @v1993)basic_window::size_in_pixels
basic_joystick::get_guid_info
mouse_wheel_event
Doxyfile
.Published by albin-johansson about 2 years ago
This release adds support for SDL 2.24, SDL_ttf 2.20, SDL_mixer 2.6, and SDL_image 2.6.
display_count()
now returns an optional valuejoy_battery_event
virtual_joystick_desc
event_type::joy_battery_updated
keyboard::reset()
display_with()
functionsbasic_controller::firmware_version()
basic_controller::path()
basic_joystick::firmware_version()
basic_joystick::path()
virtual_joystick_desc
overload of basic_joystick::attach_virtual()
gl_attribute::float_buffers
message_box::show()
, thanks @gxm11!wrap_alignment
font::set_wrap_align()
font::wrap_align()
basic_sound_effect::set_master_volume()
basic_sound_effect::master_volume()
music::current_title()
music::title()
music::title_tag()
music::artist_tag()
music::album_tag()
music::copyright_tag()
music::position()
music::duration()
music::loop_start_time()
music::loop_end_time()
music::loop_length()
animation
classfile::is_avif()
file::is_jxl()
file::is_qoi()
Published by albin-johansson about 2 years ago
This release adds support for SDL 2.0.22.
get_window(renderer_handle)
function for getting the window associated with a renderertext_editing_ext_event
Published by albin-johansson over 2 years ago
This release brings the same changes outlined in the release notes for the v7.0.0 beta, with the following differences.
fwd.hpp
header with forward declarations of most Centurion typesfont_bundle
in cen::experimental
namespacecreate_
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()
Published by albin-johansson over 2 years ago
color
functions as_rgb()
, as_rgba()
, and as_argb()
when using std::format()
Published by albin-johansson over 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.
everything.hpp
macros.hpp
bounded_array_ref
enable_for_enum_t
milliseconds
aliases u16ms
, u32ms
, and u64ms
unicode_t
and unicode32_t
u8
-> uint8
u16
-> uint16
u32
-> uint32
u64
-> uint64
i8
-> int8
i16
-> int16
i32
-> int32
i64
-> int64
enable_if_pointer_v
-> enable_for_pointer_t
enable_if_convertible_t
-> enable_for_convertible_t
enable_if_number_t
with variable template is_number<T>
str
, czstring
, and zstring
not_null
_u8
, _u16
, _u32
, _u64
, _i8
, _i16
, _i32
, and _i64
_ns
, _us
, and _s
_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 latercen_error
to exception
CENTURION_HAS_STD_MEMORY_RESOURCE
CENTURION_HAS_FEATURE_MEMORY_RESOURCE
CENTURION_HAS_FEATURE_CHARCONV
is_debug_build()
with is_debug_build
constantis_release_build()
with is_release_build
constanton_msvc()
with on_msvc
constanton_gcc()
with on_gcc
constanton_clang()
with on_clang
constanton_emscripten()
on_intel_cpp()
library
class, replaced by sdl
, img
, mix
, and ttf
classescen::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()
log::put()
log::set_output_function()
log::use_preset_output_function()
basic_rect::isFloating
withbasic_rect::floating
basic_rect::isIntegral
withbasic_rect::integral
as_i()
/as_f()
to math typesversion
is no longer initalized to the current Centurion version by defaultcurrent_version()
channel_index
group_index
music_finished_callback
channel_finished_callback
sound_font_visit_callback
set_sound_fonts()
get_sound_fonts()
each_sound_font()
cen::channels
and all of its functionsmusic
ms_type
is_fading_in()
is_fading_out()
Mix_Music*
and const Mix_Music*
basic_sound_effect
ms_type
Mix_Chunk*
and const Mix_Chunk*
thread::id
common_event
to event_base
event
to event_handler
event_handler
is()
accepting an event_type
enumeratorpush()
accepting a non-const event handlerraw_type()
is_empty()
to empty()
keyboard_event
set_scan_code()
-> set_scan()
set_key_code()
-> set_key()
set_button_state()
-> set_state()
is_only_any_of_active()
-> is_only_subset_active()
get_scan_code()
get_key_code()
file_mode
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
win32
-> win
stdio
-> std
basic_renderer
to font
font_cache
font_bundle
classtouch
namespace and all of its functionsfinger
finger_state
to controller_finger_state
key_modifier
to key_mod
(and removed key_mod
alias)is_active(key_mod)
is_only_active(key_mod)
is_only_subset_active(key_mod)
key_mod
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
update()
to refresh()
key_count()
to size()
is_active()
, is_only_active()
, and is_only_any_of_active()
mouse
warp()
warp_in_window()
set_relative_mode()
is_relative_mode_enabled()
update()
update(const basic_renderer&)
is_middle_pressed()
was_middle_released()
position_relative_window()
position_relative_desktop()
delta()
is_haptic()
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()
update(int, int)
update(iarea)
reset()
set_logical_width()
set_logical_height()
set_logical_size()
logical_width()
logical_height()
logical_size()
cen::counter
counter::frequency()
-> frequency()
counter::now()
-> now()
counter::now_in_seconds()
-> now_in_seconds()
counter::ticks()
-> ticks32()
cen::clipboard
clipboard::has_text()
-> has_clipboard()
clipboard::get_text()
-> get_clipboard()
clipboard::set_text()
-> set_clipboard()
cen::ram
ram::amount_mb()
-> ram_mb()
ram::amount_gb()
-> ram_gb()
ticks64()
platform_id
enumerator mac_osx
to macos
battery::exists()
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()
basic_window::create_renderer()
basic_renderer::create_texture()
as_rgb()
, as_rgba()
, and as_argb()
functions in color
now use std::format
, if availabledouble
overload of blend()
functionbasic_renderer
basic_renderer
basic_renderer
, and moved them to font
Published by albin-johansson almost 3 years ago
Published by albin-johansson about 3 years ago
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).
fade_status_count()
music_type_count()
log::use_preset_output_function()
by formatting to a stack buffer (using std::format_to_n
)CENTURION_HAS_FEATURE_TO_ARRAY
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
dollar_gesture_event::fingers()
functionkeyboard_event::modifier_active()
functionkeyboard_event::shift_active()
functionkeyboard_event::ctrl_active()
functionkeyboard_event::alt_active()
functionkeyboard_event::gui_active()
functionkeyboard_event::caps_active()
functionkeyboard_event::num_active()
functionmulti_gesture_event::set_fingers()
functionmulti_gesture_event::fingers()
functioncolor::as_{rgb/rgba/argb}
functions which could result in the resulting string being shorter than expectedblend_factor
enumblend_op
enumblend_task
structcompose_blend_mode()
from_hsv()
and from_hsl()
from color
Published by albin-johansson about 3 years ago
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.
operator!=
overloads for fade_status
incorrectly taking two Mix_Fading
values as argumentsto_string()
and operator<<
for fade_status
to_string()
and operator<<
for music_type
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
str
alias for const char*
log_priority_count()
log::set_output_function()
(C++20 only)log::use_preset_output_function()
(C++20 only)czstring
aliaszstring
aliaslibrary
constructors as nodiscard (C++20 only)CENTURION_HAS_STD_MEMORY_RESOURCE
macrois_stateless_callable
(C++20 only)to_string()
and operator<<
for log_category
to_string()
and operator<<
for log_priority
to_string()
and operator<<
for event_type
to_string()
and operator<<
for mouse_wheel_direction
to_string()
and operator<<
for window_event_id
to_string()
and operator<<
for file_mode
to_string()
and operator<<
for file_type
to_string()
and operator<<
for seek_mode
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 typehint::joystick::hidapi_correlate_xinput
with hint::joystick::rawinput_correlate_xinput
on SDL 2.0.16 or lateris_hint_callback
(C++20 only)add_hint_callback_ex()
(C++20 only)key_state
aliasmouse_state
aliashaptic_feature
enum now uses uint
as underlying typehaptic_direction_type
enum now uses u8
as underlying typemouse_wheel_direction
enum now uses u32
as underlying typecontroller_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)
touch_device_type
alias for touch::device_type
touch_finger_state
alias for touch::finger_state
to_string()
and operator<<
for button_state
to_string()
and operator<<
for keyboard
to_string()
and operator<<
for mouse
to_string()
and operator<<
for mouse_button
to_string()
and operator<<
for controller_type
to_string()
and operator<<
for controller_axis
to_string()
and operator<<
for controller_button
to_string()
and operator<<
for controller_bind_type
to_string()
and operator<<
for joy_hat_position
to_string()
and operator<<
for joystick_power
to_string()
and operator<<
for joystick_type
to_string()
and operator<<
for hat_state
to_string()
and operator<<
for sensor_type
to_string()
and operator<<
for touch_device_type
to_string()
and operator<<
for button_order
to_string()
and operator<<
for haptic_direction_type
to_string()
and operator<<
for haptic_feature
to_string()
and operator<<
for key_modifier
to_string()
and operator<<
for basic_controller::mapping_result
operator<=>
to vector3
(C++20 only)operator==
for basic_area
(C++20 only)operator==
and operator!=
overloads for basic_point
templatedto_string()
and operator<<
for platform_id
to_string()
and operator<<
for power_state
thread::init()
: Constrained factory functions, supporting non-void
user data or no user data at all (along with optional return values) (C++20 only)thread::id
, use thread_id
insteadthread
constructor as nodiscard (C++20 only)scoped_lock
constructors as nodiscard (C++20 only)try_lock
constructor as nodiscard (C++20 only)to_string()
and operator<<
for lock_status
to_string()
and operator<<
for thread_priority
flash_op
enumbasic_window::flash()
basic_window::set_always_on_top()
blend()
function for colors that accepts a float
biasdouble
bias overload of blend()
for colorsgl_library
constructor as nodiscard (C++20 only)vk_library
constructor as nodiscard (C++20 only)system_cursor_count()
to_string()
and operator<<
for basic_pixel_format_info
to_string()
and operator<<
for gl_attribute
to_string()
and operator<<
for gl_swap_interval
to_string()
and operator<<
for blend_mode
to_string()
and operator<<
for font_hint
to_string()
and operator<<
for message_box::color_id
to_string()
and operator<<
for message_box::default_button
to_string()
and operator<<
for message_box_type
to_string()
and operator<<
for pixel_format
to_string()
and operator<<
for scale_mode
to_string()
and operator<<
for screen_orientation
to_string()
and operator<<
for system_cursor
to_string()
and operator<<
for texture_access
std::format
in to_string()
overloads (C++20 only)Published by albin-johansson over 3 years ago
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.
CENTURION_NO_SDL_TTF
CENTURION_NO_SDL_MIXER
CENTURION_NO_SDL_IMAGE
keyboard_event::modifier_active()
dollar_gesture_event::fingers()
multi_gesture_event::fingers()
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)
keyboard_event::shift_active()
keyboard_event::ctrl_active()
keyboard_event::alt_active()
keyboard_event::gui_active()
keyboard_event::caps_active()
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()
shift
, ctrl
, alt
, gui
and reserved
enumerators to key_modifier
enum.color::from_hsv()
and color::from_hsl()
, these functions will now clamp the arguments to be within the respective rangesdouble
overloads of color::from_hsv()
and color::from_hsl()
, use the new float
overloads insteadcolor::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 libraryusize
alias for std::size_t
to_string()
overloadsPublished by albin-johansson over 3 years ago
vk::required_extensions()
no longer always returns an empty std::vector
Published by albin-johansson over 3 years ago
src/centurion
is no longer officially supported, use the include/centurion.hpp
header insteadexception
to cen_error
basic_area
is now final
noexcept
optimizations to several functions, since MSVC marks many functions as noexcept
, even if they aren't required to be by the standardbool
s to indicate their success, now return result
values, which is a new classresult
class, used to indicate the success of functions (see success
and failure
)CENTURION_VERSION_MAJOR
CENTURION_VERSION_MINOR
CENTURION_VERSION_PATCH
CENTURION_VERSION_NUMBER
CENTURION_MAKE_VERSION_NUMBER
CENTURION_VERSION_AT_LEAST
version
structversion_at_least()
sdl_image_linked_version()
sdl_mixer_linked_version()
sdl_ttf_linked_version()
to_underlying()
str_or_na()
uint
aliasulonglong
aliaslog::category
enum and renamed it to log_category
log::priority
enum and renamed it to log_priority
hint::gamecontroller
namespace to hint::controller
event
event::refresh()
to event::update()
N/A
key_state
to keyboard
mouse_state
to mouse
touch::num_devices()
to touch::device_count()
touch::num_fingers()
to touch::finger_count()
has_screen_keyboard()
keyboard
keyboard::was_just_released()
to just_released()
keyboard::was_just_pressed()
to just_pressed()
keyboard::modifier_active()
to is_active()
keyboard::update()
is no longer marked as noexcept
keyboard::is_held()
is now only noexcept
on MSVCkeyboard::just_pressed()
is now only noexcept
on MSVCkeyboard::just_released()
is now only noexcept
on MSVCmouse
mouse::was_mouse_moved()
to was_moved()
mouse::mouse_x()
to x()
mouse::mouse_y()
to y()
mouse::mouse_pos()
to position()
basic_joystick
basic_joystick::type
enum has been extracted from basic_joystick
and renamed to joystick_type
basic_joystick::power
enum has been extracted from basic_joystick
and renamed to joystick_power
basic_joystick::hat_state
enum has been extracted from basic_joystick
basic_joystick::ball_axis_change
struct has been extracted from basic_joystick
basic_joystick::get_type()
to type()
basic_joystick::axis_pos()
no longer returns an optional
value.basic_joystick::num_hats()
basic_joystick::num_axes()
basic_joystick::num_trackballs()
basic_joystick::num_buttons()
basic_controller
basic_controller::num_mappings()
to mapping_count()
get_window_from_id()
to get_window()
num_render_drivers()
to render_driver_count()
num_video_drivers()
to video_driver_count()
gl_library
classgl_attribute
enumgl_swap_interval
enumgl::basic_context
class, with gl::context
and gl::context_handle
aliasesgl::swap()
gl::drawable_size()
gl::set()
gl::get()
gl::reset_attributes()
gl::set_swap_interval()
gl::swap_interval()
gl::get_window()
gl::get_context()
gl::is_extension_supported()
vk_library
classvk::get_instance_proc_addr()
vk::create_surface()
vk::required_extensions()
vk::drawable_size()
palette
classrenderer_info
classmake_window_and_renderer()
get_info()
screen
screen_saver_enabled()
to is_screen_saver_enabled()
set_screen_saver_enabled()
and is_screen_saver_enabled()
out of the screen
namespacestd::optional
values0
screen::orientation
out of the screen
namespace and renamed it to screen_orientation
screen::dpi_info
out of the screen
namespacebasic_cursor
basic_cursor::num_system_cursors()
to basic_cursor::count()
unicode_string
unicode_string::operator[]()
overloads are now conditionally noexcept
basic_renderer
SDL_RendererFlags
to u32
basic_renderer::default_flags()
is now publicbasic_renderer::has_font()
is no longer marked as noexcept
basic_renderer::set_logical_integer_scale()
to set_logical_integer_scaling()
basic_renderer::set_target()
now takes a non-const
reference to a centurion texture as parameterbasic_renderer::set_scale()
now have preconditions that the supplied scales are greater than zerobasic_renderer::set_logical_scale()
now have preconditions that the supplied dimensions aren't negativebasic_renderer::clear()
now returns result
basic_renderer::draw_rect()
now returns result
basic_renderer::fill_rect()
now returns result
basic_renderer::draw_line()
now returns result
basic_renderer::draw_lines()
now returns result
basic_renderer::draw_rect_t()
now returns result
basic_renderer::fill_rect_t()
now returns result
basic_renderer::render()
overloads now returns result
basic_renderer::set_color()
now returns result
basic_renderer::set_clip()
now returns result
basic_renderer::set_blend_mode()
now returns result
basic_renderer::set_target()
now returns result
basic_renderer::set_scale()
now returns result
basic_renderer::set_logical_size()
now returns result
basic_renderer::set_logical_integer_scaling()
now returns result
basic_renderer::reset_target()
basic_renderer::draw_point()
basic_renderer::draw_point_t()
basic_renderer::draw_circle()
basic_renderer::draw_circle_t()
basic_renderer::fill_circle()
basic_renderer::fill_circle_t()
renderer_flags
enumbasic_renderer::info()
basic_renderer::flags()
basic_renderer::is_vsync_enabled()
basic_renderer::is_accelerated()
basic_renderer::is_software_based()
basic_renderer::supports_target_textures()
basic_window
basic_window
s title/size constructor.basic_window::always_on_top()
to is_always_on_top()
basic_window::set_fullscreen()
now returns a result
basic_window::set_fullscreen_desktop()
now returns a result
basic_window::set_opacity()
now returns a result
basic_window::set_capturing_mouse()
now returns a result
basic_window::set_size()
has new preconditionsbasic_window::set_min_size()
has new preconditionsbasic_window::set_max_size()
has new preconditionsbasic_window::is_screen_keyboard_shown()
basic_window::has_grabbed_input()
basic_window::is_high_dpi()
basic_window::is_hidden()
basic_window::is_metal()
basic_window::is_utility()
basic_window::is_tooltip()
basic_window::is_popup_menu()
basic_window::is_excluded_from_taskbar()
window_flags
enumbasic_surface
std::string
overload for basic_surface::with_format()
std::string
overload for basic_surface::from_bmp()
std::string
overload for basic_surface::save_as_bmp()
basic_surface::save_as_png()
basic_surface::save_as_jpg()
color
blend()
color::data()
font
font::hint
enum has been extracted renamed to font_hint
std::optional
valuesmessage_box
message_box::type
enum has been extracted and renamed to message_box_type
message_box::button_order
enum has been extracted to the default cen
namespacemessage_box::get_type()
to type()
platform
namespaceplatform_id::linuxx
to platform_id::linux_os
platform::id()
function to current_platform()
platform::name()
function to platform_name()
battery::power_state
enum out of battery
namespacesimd_block
out of cpu
namespaceget_pref_path()
to preferred_path()
get_base_path()
to base_path()
counter::now_sec()
to now_in_seconds()
counter::high_res_freq()
to frequency()
std::string
overload for preferred_path()
screen::display_mode()
base_path
classpref_path
classN/A
area()
point()
rect()
basic_rect
basic_rect::offset_x()
basic_rect::offset_y()
basic_rect::offset_width()
basic_rect::offset_height()
sound_effect
and sound_effect_handle
aliases.get_sound()
channels::on_finished()
channels::allocate()
channels::reserve()
channels::expire()
channels::remove_expiration()
channels::set_group()
channels::reset_group()
channels::group_count()
channels::first_available()
channels::most_recent()
channels::oldest()
music
music::play()
now returns std::optional<int>
, which indicates the channel used to play the musicmusic::fade_in()
now returns a bool
music::fade_out()
now returns a bool
music::set_hook()
music::reset_hook()
music::get_hook_data()
music::get_decoder()
music::has_decoder()
music::decoder_count()
basic_sound_effect
basic_sound_effect::play()
now returns a bool
basic_sound_effect(Mix_Chunk*)
constructorbasic_sound_effect::get_decoder()
basic_sound_effect::has_decoder()
basic_sound_effect::decoder_count()
to_string()
implementationscolor::blend()
was turned into a free functionPublished by albin-johansson over 3 years ago
This is a preview release of Centurion 6.0.0. Most APIs should be relatively stable, but they might still change before the release of v6.0.0.
Published by albin-johansson over 3 years ago
With this release, the minimum supported SDL version is 2.0.10! This is the default version on the current LTS of Ubuntu, which motivated the change. This release also brings serialization support, based on the Cereal library API, along with several improvements to the basic_surface
class, and more. Furthermore, this release removes all library components that were deprecated in version 5.1.0.
The structure of the project has changed slightly, with all headers being located in src/centurion
, with a new composite header located in include
called centurion.hpp
, which contains the contents of all other centurion headers! However, you can still use the library in the old way by including said headers under src/centurion
.
The library is now continuously tested on macOS!
basic_surface::lock()
is now publicbasic_surface::unlock()
is now publicbasic_surface::must_lock()
is now publicbasic_controller::get_button()
now takes a not_null<czstring>
as a parameter, instead of czstring
to_string()
output format from [component | foo: bar]
to component{foo: bar}
counter::ticks()
is no longer marked as noexcept
.file
class, along with several associated enumsshared_object
classswap_byte_order()
swap_big_endian()
swap_little_endian()
serialize()
functions that accept an "archive", which serializes the associated data using operator()
.
basic_area
basic_point
basic_rect
color
key_code
scan_code
unicode_string
vector3
integers.hpp
_u8
_u16
_u32
_u64
_i8
_i16
_i32
_i64
basic_surface::data()
function for API consistency, which returns the same pointer as basic_surface::pixels()
basic_surface(iarea, pixel_format)
constructorbasic_surface::from_bmp()
basic_surface::save_as_bmp()
basic_area::value_type
aliasbasic_renderer::capture()
function for capturing a snapshot of the current rendering target as a surfacebasic_rect
constructor that accepts an SDL rectanglebasic_rect
constructor that takes x, y, width and height as separate valuesbasic_window::restore()
area_of()
std::string
overloads
clipboard::set_text()
basic_controller::get_axis()
basic_controller::get_button()
basic_controller::add_mapping()
basic_controller::load_mappings()
font
constructorfont::string_width()
font::string_height()
font::string_size()
font_cache::store_blended_utf8()
font_cache::store_blended_wrapped_utf8()
font_cache::store_shaded_utf8()
font_cache::store_solid_utf8()
font_cache::store_blended_latin1()
font_cache::store_blended_wrapped_latin1()
font_cache::store_shaded_latin1()
font_cache::store_solid_latin1()
basic_joystick::guid_from_string()
key_code
key name constructorkey_code
key name assignment operatorscan_code
key name constructorscan_code
key name assignment operatorsound_effect
constructoropen_url()
basic_surface
path constructormusic
constructorbasic_texture
path constructorbasic_texture::streaming()
basic_window
title/size constructorbasic_window::set_title()
basic_renderer::render_blended_utf8()
basic_renderer::render_blended_wrapped_utf8()
basic_renderer::render_shaded_utf8()
basic_renderer::render_solid_utf8()
basic_renderer::render_blended_latin1()
basic_renderer::render_blended_wrapped_latin1()
basic_renderer::render_shaded_latin1()
basic_renderer::render_solid_latin1()
constexpr
functions intended to be used for conditional compilation, based on the current OS
platform::ifdef_win32()
platform::ifdef_win64()
platform::ifdef_linux()
platform::ifdef_android()
platform::ifdef_apple()
constexpr
functions for querying information about the compiler and build mode.
is_debug_build()
is_release_build()
on_msvc()
on_gcc()
on_clang()
on_emscripten()
on_intel_cpp()
isize()
, for getting the size of a container as an int
mouse_state::update(iarea)
mouse_state::set_logical_size()
color::from_hsv()
color::from_hsl()
event::in_queue()
event::num_queued()
, use event::queue_count()
insteadevent::num_queued(event_type)
, use event::queue_count(event_type)
insteadtypes.hpp
headercenturion_api.hpp
headerbasic_texture::is_static()
basic_rect::resize()
basic_rect::move_to()
sound_effect::loopForever
music::loopForever
message_box::get_title()
message_box::get_message()
key_state::amount_of_keys()
basic_joystick::amount()
ttf_version()
nn_czstring
event::empty()
common_event
default constructorfont::kerning()
font::bold()
font::italic()
font::underlined()
font::strikethrough()
font::outlined()
Published by albin-johansson over 3 years ago
This release makes library now compatible with both SDL2 2.0.12 and 2.0.14! Overall, this release does not bring any source-breaking changes, but there are a couple of behavioral changes and signature tweaks such as the noexcept
-ness of certain functions. Furthermore, this release includes a few new APIs, such as the sensor and haptic APIs!
basic_texture::streaming()
now throws sdl_error
instead of exception
if a temporary texture cannot be locked.basic_texture::set_pixel()
is no longer marked as noexcept
, it will now throw if pixel format information cannot be obtained.basic_renderer::render_glyph()
now has no effect if the specified glyph doesn't exist in the font cache.basic_renderer::render_text()
no longer has a precondition that all glyphs in the string must have been previously cached.basic_controller::rumble()
is no longer marked as noexcept
, and it now returns a bool
to indicate the success of the rumble.sound_effect::fade_in
is no longer marked as noexcept
.sound_effect::fade_out
is no longer marked as noexcept
.music::fade_in
is no longer marked as noexcept
.music::fade_out
is no longer marked as noexcept
.milliseconds
overload of condition::wait()
is no longer marked as noexcept
.basic_joystick::rumble()
is no longer marked as noexcept
.semaphore::acquire()
is no longer marked as noexcept
.thread::sleep()
is no longer marked as noexcept
.basic_joystick::from_joystick()
now takes a templated basic_joystick
as a parameter, instead of a joystick_handle
.basic_joystick
now uses 0
as the default index.basic_texture::release
, it's only available for owning textures. It would have caused a compilation error if used with a handle, which is the correct behavior, but would likely lead to a confusing error message.pixel_format::bgr444
enumerator.haptic.hpp
.sensor.hpp
.locale.hpp
.vector3<T>
struct, located in the new vector3.hpp
header.basic_pixel_format_info
, along with pixel_format_info
and pixel_format_info_handle
aliases, located in pixel_format.hpp
.platform::is_tablet()
function in the platform.hpp
header.platform::open_url()
function in the platform.hpp
header.basic_surface::with_format()
, extracted from a lambda in the implementation of the basic_texture
class.basic_surface::format_info()
, made possible by pixel_format_info_handle
.basic_surface::size()
basic_surface::set_rle_hint()
basic_surface::is_rle_enabled()
font_cache::try_at()
basic_rect::data()
basic_point::data()
get_base_path()
in base_path.hpp
, replacement for the base_path
class.get_pref_path()
in pref_path.hpp
, replacement for the pref_path
class.sdl_linked_version()
, located in centurion.hpp
.cast()
specializations for basic_area
.pixel_format
enumerators
pixel_format::xrgb4444
pixel_format::xbgr4444
pixel_format::xrgb1555
pixel_format::xbgr1555
pixel_format::xrgb8888
pixel_format::xbgr8888
basic_controller::count()
basic_controller::serial()
basic_controller::has_axis()
basic_controller::rumble_triggers()
basic_controller::set_sensor_enabled()
basic_controller::has_sensor()
basic_controller::is_sensor_enabled()
basic_controller::get_sensor_data()
basic_controller::set_led_color()
basic_controller::has_led()
basic_joystick::rumble_triggers()
basic_joystick::set_led()
basic_joystick::serial()
basic_joystick::has_led()
basic_joystick::attach_virtual()
basic_joystick::detach_virtual()
basic_joystick::set_virtual_axis()
basic_joystick::set_virtual_button()
basic_joystick::set_virtual_hat()
basic_joystick::is_virtual()
hint::joystick::use_hidapi_ps5
hint::joystick::use_raw_input
hint::joystick::hidapi_correlate_xinput
hint::mouse::relative_scaling
hint::preferred_locales
hint::emscripten::asyncify
hint::android::pause_background_audio
hint::thread_priority_policy
hint::treat_time_critical_as_real_time
hint::linux_use_deadzones
hint::audio_device_app_name
hint::audio_device_stream_name
cpu::simd_block
base_path
, including the associated to_string()
and operator<<
overloads. Use the get_base_path()
function instead.pref_path
, including the associated to_string()
and operator<<
overloads. Use the get_pref_path()
function instead.basic_joystick::num_hats()
, use basic_joystick::hat_count()
instead.basic_joystick::num_axes()
, use basic_joystick::axis_count()
instead.basic_joystick::num_trackballs()
, use basic_joystick::trackball_count()
instead.basic_joystick::num_buttons()
, use basic_joystick::button_count()
instead.None.
Published by albin-johansson almost 4 years ago
This release turns the library into a header-only library! This change is not considered to break ABI since there is no ABI anymore. Furthermore, this release brings quite a few deprecations along with some new APIs. There shouldn't be any major source breaking changes in this release.
ttf_version()
in centurion.hpp
header constexpr
.battery::exists()
now returns true
if the power state is any of: on_battery
, charged
or charging
.sound_effect::fade_in()
and sound_effect::fade_out
now have preconditions that the durations must be greater than zero.music::fade_in()
and music::fade_out
now have preconditions that the durations must be greater than zero.basic_window::set_fullscreen()
no longer resets brightness to 1
when exiting fullscreen mode.basic_window::set_brightness()
now returns a bool
- true
if successful, false
otherwise. It will also try to set the brightness even when the window isn't in fullscreen mode.event::type()
now returns std::optional<event_type>
since there might not be an internal event instance.basic_controller::load_mappings()
no longer throws upon failure, instead it returns a std::optional<int>
, this means that it is now marked as noexcept
.basic_controller::add_mapping()
no longer throws upon failure, instead it returns an enum that indicates the result. As a result, it is now noexcept
.basic_controller
now defaults to 0
.cast()
function definition is now located in the new cast.hpp
header.sdl_error
, ttf_error
, img_error
and mix_error
) now default to the latest error message from thebasic_joystick(SDL_Joystick*)
constructor being private, it is now public.basic_renderer::set_logical_size()
not having any effect if any of the supplied components were 0
.basic_controller::get_axis(controller_axis)
to i16
(was previously i32
).message_box::button_order
enumerators not being equal to corresponding SDL_MessageBoxFlags
values.message_box::show(const basic_window&)
actually compile when instantiated.battery::seconds_left()
is no longer marked as noexcept
(because of std::chrono::duration
contructor).battery::minutes_left()
is no longer marked as noexcept
(because of std::chrono::duration
contructor).message_box::has_button()
is no longer markes as noexcept
(because of std::any_of
).event_dispatcher.hpp
header, which includes the event_dispatcher
and event_sink
classes.integers.hpp
header, provides the uX
and iX
integer aliases (e.g. u16
and i32
).time.hpp
header, provides the time related aliases such as seconds
and milliseconds
along with the associated literals.not_null.hpp
header, provides the not_null
alias.sdl_version()
in centurion.hpp
.sdl_image_version()
in centurion.hpp
.sdl_mixer_version()
in centurion.hpp
.sdl_ttf_version()
in centurion.hpp
.basic_renderer::fill()
basic_renderer::fill_with()
.battery::is_charging()
.battery::is_charged()
.battery::is_available()
.key_code::to_scan_code()
.scan_code::to_key_code()
.scan_code::count()
.sound_effect::is_any_playing()
sound_effect::channel()
event::push(const common_event<T>&)
as_sdl_event(const common_event<T>&)
function in event.hpp
.basic_rect::set_max_x()
.basic_rect::set_max_y()
.CENTURION_API
macro.CENTURION_QUERY
macro.validate_event()
from cen
namespace, it was never meant to be used for anything but testing.centurion_api.hpp
header.types.hpp
header, use the new more explicit headers instead.
nn_czstring
alias, use not_null<czstring>
instead.buffer
alias.font_id
alias.ttf_version()
, use sdl_ttf_version()
instead.font::kerning()
, use font::has_kerning()
instead.font::bold()
, use font::is_bold()
instead.font::italic()
, use font::is_italic()
instead.font::underlined()
, use font::is_underlined()
instead.font::strikethrough()
, use font::is_strikethrough()
instead.font::outlined()
, use font::is_outlined()
instead.texture::is_static()
, use texture::is_no_lock()
instead.event::empty()
, use event::is_empty()
instead.key_state::amount_of_keys()
, use key_state::key_count()
instead.music::loopForever
, use music::forever
instead.sound_effect::loopForever
, use sound_effect::forever
instead.message_box::get_title()
, use message_box::title()
instead.message_box::get_message()
, use message_box::message()
instead.common_event
default constructor.basic_joystick::amount()
, use basic_joystick::count()
instead.basic_rect::move_to()
, use basic_rect::set_position()
instead.basic_rect::resize()
, use basic_rect::set_size()
instead.unicode_string::append()
, but it still behaves exactly the same as before.not_null
. However, you should not rely on this, supplying a null pointer when a parameter is marked as not_null
is effectively undefined behaviour.Published by albin-johansson almost 4 years ago
This is a big update of the library. Many things have changed and a lot of stuff has been added. Some of the new features are a threading API, a new performant glyph-based text rendering API, owning and non-owning versions of classes, full C++17 utilization and much more. Far from all changes are documented in the following notes. However, the major changes are listed.
Note, this release breaks compatibility with C++11 and C++14.
cen
instead of centurion
.CENTURION_NODISCARD
macro with [[nodiscard]]
attribute.tl::optional
with std::optional
.gsl-lite
dependency.snake_case
, as per the standard library..hpp
extension._handle
, e.g. renderer
(owning) and renderer_handle
(non-owning).thread
class, provides a similar API to std::thread
.
delay
function to sleep
, and moved it to the thread
class.mutex
class, located in mutex.hpp
.scoped_lock
class, located in scoped_lock.hpp
.try_lock
class, located in try_lock.hpp
.semaphore
class, located in semaphore.hpp
.condition
class, located in condition.hpp
.clipboard.hpp
font_cache
, in font_cache.hpp
.unicode_string
, located in unicode_string.hpp
.centurion.hpp
header no longer includes the rest of the library.
Centurion
class to library
.CenturionConfig
class to config
.Battery
class with the battery
namespace.CPU
class with the cpu
namespace.Platform
class with the platform
namespace.Log
class with the log
namespace.Screen
class with the screen
namespace.Timer
class with the counter
namespace.get
member function, static_cast
or ctn::cast
function.RAM
class with the ram
namespace.
size_gb
to amount_gb
.size_mb
to amount_mb
.std::chrono
time unit types for improved type-safety and correctness of conversions of milliseconds, nanoseconds, minutes, etc.noexcept
specifiers.if constexpr
, the rendering API has become less bloated and more elegant. For instance, render
will now delegate to either SDL_RenderCopy
or SDL_RenderCopyF
depending on the parameter types.renderer
class now uses std::size_t
as keys instead of std::string
.to_string
functions with a non-member equivalent, i.e. you now stringify entities using cen::to_string(obj);
instead of obj.to_string();
,<<
) for types that provide a to_string
overload.color
class is now constexpr
.
color::with_alpha
.event.hpp
.event
class.
event::as_
functions.event::is<T>
.event::get<T>
.event::try_get<T>
.event::empty
.event::num_queued
.SysWMEvent
entirely.Colour
alias.color::max
and color::min
constants.font
.base_path
and pref_path
in separate headers.sound_effect::is_fading
method that returns true
if the sound effect is being faded.basic_renderer::clear_with
method, for clearing the rendering target with a specified color.get_grabbed_window
and get_window_from_id
functions to window_utils.hpp
.CENTURION_USE_PRAGMA_ONCE
macro in centurion_cfg.hpp
, which is used to specify whether or not #pragma once
should be used by the Centurion headers.inline static constexpr
.texture_handle
Published by albin-johansson about 4 years ago
Note: This is a pre-release of version 5.0.0.
This is a big update of the library. Many things have changed and a lot of stuff has been added. Some of the new features are a threading API, a new performant glyph-based text rendering API, owning and non-owning versions of classes, full C++17 utilization and much more. Far from all changes are documented in the following notes. However, the major changes are listed.
Note, this release breaks compatibility with C++11 and C++14.
CENTURION_NODISCARD
macro with [[nodiscard]]
attribute.tl::optional
with std::optional
.gsl-lite
with gsl
by Microsoft.EnTT
as dependency, since it provides so many useful C++17 utilities.snake_case
, as per the standard library..hpp
extension.variable_timestep_loop
, semi_fixed_timestep_loop
and fixed_timestep_loop
. Located in game_loop.hpp
. No virtual inheritance necessary!_handle
, e.g. renderer
(owning) and renderer_handle
(non-owning). Various APIs have been refactored to support both owning and non-owning versions of components where possible.
renderer_handle
, a non-owning wrapper around SDL_Renderer*
.window_handle
, a non-owning wrapper around SDL_Window*
.thread
class, provides a similar API to std::thread
.
delay
function to sleep
, and moved it to the thread
class.mutex
class, located in mutex.hpp
.scoped_lock
class, located in scoped_lock.hpp
.try_lock
class, located in try_lock.hpp
.semaphore
class, located in semaphore.hpp
.condition
class, located in condition.hpp
.clipboard.hpp
font_cache
, in font_cache.hpp
.unicode_string
, located in unicode_string.hpp
.centurion.hpp
header no longer includes the rest of the library.
Centurion
class to centurion_lib
.Battery
class with the battery
namespace.CPU
class with the cpu
namespace.Platform
class with the platform
namespace.Log
class with the log
namespace.Screen
class with the screen
namespace.Timer
class with the counter
namespace.get
member function, static_cast
or ctn::cast
function.RAM
class with the ram
namespace.
size_gb
to amount_gb
.size_mb
to amount_mb
.std::chrono
time unit types for improved type-safety and correctness of conversions of milliseconds, nanoseconds, minutes, etc.noexcept
specifiers.if constexpr
, the rendering API has become less bloated and more elegant. For instance, render
will now delegate to either SDL_RenderCopy
or SDL_RenderCopyF
depending on the parameter types.renderer
class now uses entt::id_type
as keys, which can be created from compile-time hashed strings, e.g. "foo"_hs
.to_string
functions with a non-member equivalent, i.e. you now stringify entities using ctn::to_string(obj);
instead of obj.to_string();
, this enables usage of ADL to delegate to either std::to_string
or ctn::to_string
.<<
) for types that provide a to_string
overload.color
class is now constexpr
.event.hpp
.event
class.
event::as_
methods from event
.event::is<T>
method.event::get<T>
method.event::try_get<T>
method.event::empty
method.SysWMEvent
entirely.Colour
alias.color::max
and color::min
constants.font
..ipp
headers. (You don't have to include these explicitly).sound_effect::is_fading
method that returns true
if the sound effect is being faded.basic_renderer::clear_with
method, for clearing the rendering target with a specified color.CENTURION_USE_PRAGMA_ONCE
macro in centurion_cfg.hpp
, which is used to specify whether or not #pragma once
should be used by the Centurion headers.inline static constexpr
.Published by albin-johansson over 4 years ago
This is a small release that adds a touch API and minor improvements to Joystick
.
touch.h
.Joystick
enums.Published by albin-johansson over 4 years ago
This version bring a joystick API, improvements to the Rect
class and minor documentation improvements.
joystick.h
.Rect
class.
void move_to(Point<T>)
, for setting the position of the rectangle easily.T area()
, that simply returns the area of the rectangle.