C++ Complementary Library
Published on December 26, 2023.
Written by Daniel T. McGinnis.
I am pleased to announce the release of CCL 0.2 Beta. This version contains bug fixes and new features.
FreeBSD is now an officially supported operating system. CCL 0.2 Beta runs on Windows, macOS,
Linux-based systems, and FreeBSD. You can query whether you are on FreeBSD by testing whether
the CMP_OS_FREEBSD
preprocessor constant is defined. If you are on FreeBSD, the
preprocessor constant CMP_OS_NAME
will be set to "FreeBSD"
. CCL's
entire feature set, including its wonderful Unicode-aware I/O capabilities, are now available
on FreeBSD.
You can now set a string property on cmp::application
to hold the copyright notice for
your application. You do it by calling set_copyright_notice
. You would do that in the
main
function, just after instantiating your application object. Here's some example
code (it assumes you're making a console application, but if you were making a desktop GUI application
then the type of the application object would really be cmp::desktop_gui_application
):
#include <cmp/core/application.hpp>
int
main (
int argc,
char** argv
) {
cmp::application app{argc, argv};
app.set_copyright_notice(u8"your copyright notice goes here");
// the rest of your main function goes here
return 0;
} // function -----------------------------------------------------------------
A new package is being introduced in version 0.2 Beta, and that is CCL Desktop GUI.
This package allows you to portably create a window and detect input. All you have to do is subclass
cmp::window
, override the event handling functions to react appropriately to such events
as key presses, key releases, window resizes, and window close requests (that is, when the user clicks
the button to close the window), and then instantiate your class and call the show
function.
To set the title of a window, you simply call set_title
and supply a std::u8string
with the Unicode text you want to be displayed in the window's title bar. A conversion to UTF-16 is done
automatically on Windows so you can just work with UTF-8 everywhere and get consistent results on all
platforms.
In your cmp::window
subclass, you can override the update
function, which
is called automatically by CCL in the event loop. This design makes it easy to integrate a game
engine with CCL's windowing capabilities. CCL calls the update
function with two
double
arguments, one telling you how much time has elapsed since the last
call to update
(called delta_seconds
), and one telling you how much
time has elapsed since the window was first created (called total_seconds
). The
delta_seconds
argument is specifically intended to facilitate per-frame computation,
so you can use it to update your game state, simulate physics and render your next frame.
This package works on all platforms that CCL already supported and the newly supported FreeBSD. Windows and macOS provide their own GUI API, but Linux and FreeBSD are different in that you can choose from a variety of desktop environments for your GUI needs, and different desktop environments may have different GUI APIs. For example, while it is true that GTK and Qt are cross-platform, GTK is the native GUI API of GNOME, and Qt is the native GUI API of KDE. CCL is written entirely from scratch and does not have any third-party dependencies (outside of the standard library and the operating system's native API), so the Windows backend of CCL Desktop GUI uses the Win32 API, the macOS backend uses the official AppKit provided by Apple, and both the Linux backend and the FreeBSD backend use GTK. This means that CCL is still fully licensed under the Boost Software License despite GTK being LGPL-licensed, because CCL links with GTK dynamically and GTK is only used to the extent that it is a system-provided API, it is not bundled with CCL. I plan on adding support for Qt in the Linux and FreeBSD backends in the future to provide a lean and seamless experience on KDE.
CCL Desktop GUI is still very bare-bones, it doesn't even support detecting mouse input yet. This will, however, change. I plan on adding support for mouse input detection as well as support for a whole host of native widgets that you can place on the window. This includes things like push buttons, radio buttons, check boxes, combo boxes, and so on. It's going to be rad!
Starting with version 0.2 Beta, CCL now recognizes wchar_t
-based strings (such as
std::wstring
, wchar_t*
, etc.) as UTF-16 on platforms where wchar_t
is 2 bytes long, and as UTF-32 on platforms where wchar_t
is 4 bytes long. Typically,
wchar_t
is 2 bytes long on Windows and 4 bytes long on Linux. This means that if you
are writing platform-specific code that uses Unicode strings based on wchar_t
, then
you can use all of CCL's Unicode facilities on those strings, so long as CCL's assumption (that
a 2-byte wchar_t
is a UTF-16 code unit and that a 4-byte wchar_t
is a
UTF-32 code unit) holds true.
You can now get a pointer to the application object by calling cmp::app()
, which gives back
a pointer to cmp::application
. If your application is a desktop GUI application, then call
cmp::dgui_app()
and you'll get back a pointer to cmp::desktop_gui_application
.
You can now use ASCII strings (that is, char
-based strings like std::string
and char*
) in the same places where you can use Unicode strings. This lets you do things
like test whether a Unicode string starts with an ASCII string. This works because Unicode is a superset
of ASCII.
You can now flush a stream by inserting cmp::flush
. Like this:
cmp::uout << u8"Hello" << cmp::flush;
This makes it more convenient to flush the stream than calling the flush
member function when you want to intersperse flushes among regular insertions.
I hope you find as much excitement in CCL 0.2 Beta as I do. It really is a bummer that CCL is still in Beta, and I am just dying for sponsorships so that I can focus on CCL. While it is true that it's just a matter of time until I get CCL to a point where it's finally stable, it is taking longer than I expected. I desperately want funding so that I can get there sooner. I am accepting funding via GitHub Sponsors. All six spots for early diamond sponsors are still available, so if your company is heavily invested in C++ tooling and you believe in my vision, then now is the best time to become a diamond sponsor. The first six diamond sponsors will be considered "early" diamond sponsors and will be featured at the top of every page of this website, in addition to being featured at the bottom of every page. Be an early adopter of this amazing technology! ;)
That does it for now. Keep being awesome!
Copyright © 2022-2025 Daniel T. McGinnis