SCExample#
Always give a good example
SCExample is a small GUI application based on sokol_app / sokol_gfx libraries, providing window abstraction and graphics api abstraction and dear-imgui for the UI. Building this application has been mostly documented in the following YouTube videos:
First step has been putting together a pure cross platform GUI application (win/linux/macos), making sure to pause the render loop in absence of user inputs:
Second step has been integrating the GUI event loop with the SC::Async I/O library (always cross-platform).
And lastly showcasing the integration of SC::FileSystemWatcher and SC::Plugin to watch source files that are being hot-reloaded as plugins (dynamic libraries).
Also in this case the cross-platform aspect has been preserved.
- SCExample: Create (sokol+dear imgui) app re-drawing on user input only
- SCExample: Display number of reloads and last load time of hot-reloaded plugins
- SCExample: Implement simple hot-reload to showcase Plugin and FileSystemWatcher libraries
- SCExample: Integrate SC::AsyncEventLoop by using SC::AsyncEventLoopMonitor
- SCExample: Transform floating window into a toolbar
SC::Async#
A single event loop is never enough
A small but useful addition to the SC::Async
library has been the SC::AsyncEventLoopMonitor
class.
This class wraps most of the required machinery to integrate SC::Async
event loop in an application that has a different main event loop (GUI or IO)
SC::Plugin#
Hot-Reload like there is no tomorrow
SC::Plugin
library has been receiving some love, with the addition of a queryInterface-like mechanism helping to define contracts between plugins and the host application.
It's possible to control linking libc / libc++, adding some custom include directories and disabling exceptions.
SC::Plugin now monitors CFLAGS
and LDFLAGS
environment variables (if defined) of the host environment, to allow linking the correct sysroot on posix systems.
Some fixes too have been needed on macOS where duplicated plugin symbols from different compiled .dylibs
can wrongly increment their refcount, preventing from unloading them.
- Plugin: Add PluginCompilerEnvironment to intercept and use CFLAGS and LDFLAGS
- Plugin: Add PluginDynamicLibrary::queryInterface
- Plugin: Add PluginSysroot and build options to allow linking libc and libc
- Plugin: Allow multiple include paths
- Plugin: Change appendDefinitions into replaceDefinitions
- Plugin: Disable exceptions under MSVC
- Plugin: Hide Plugin symbols by default on macOS
- Plugin: Track number of reloads and last load time for all plugins
SC::FileSystemWatcher#
Make it actually usable
Using SC::FileSystemWatcher
inside SC::Example has exposed some usability issues and bugs (mainly repeated notifications), that have been promptly fixed.
SC::Build#
Spaces and GUI Apps
SC::Build
can now generate Xcode projects for gui applications creating app bundles on macOS for the Xcode backend.
The configure phase will download required dependencies (like sokol or dear-imgui for SCExample).
This is not ideal as it requires internet connection, so it will be probably be made optional in some future update.
It can now build from paths with spaces (even when using the Makefile backend...) and generates Xcode projects avoiding any warning.
Some of the fixes have ramifications also on the SC::Tools that bootstraps SC::Build.
- Build: Collapse all non-apple TARGET_OS to just linux
- Build: Escape quotes in Make and Xcode backends
- Build: Fix generation of compile_commands.json file
- Build: Fix Makefile force clean on platform specific makefiles
- Build: Generate makefiles supporting building from paths with spaces
- Build: Improve Xcode generator not to produce warnings under Xcode 15
- Build: Support creating app bundles on Xcode
- Tools: Improve Makefile
- Tools: Support building a tool from path containing spaces
Additional fixes#
Fix fix fix
And just like every month, working on SCExample has generated a number of minor fixes, API improvements / refactoring.
All of them have been proudly committed to the main branch!
- Containers: Fix bug in VectorMap::remove
- FileSystem: Add writeStringAppend
- Foundation: Add Host Operating System detection
- Process: Avoid creating windows when spawning a new process
- Process: Improve ProcessTest compatibility
- Process: Rename StringsTable to StringsArena
- Reflection: Disable SC_REFLECT_AUTOMATIC on older clang versions
- Reflection: Fix compile error due to a GCC bug
- Strings: Add StringHashFNV
- Strings: Do not let StringBuilder leave unterminated string when format fails
- Time: Make HighResolutionCounter::snap return reference to HighResolutionCounter itself
- Documentation: Add SCExample to the Examples page
- Documentation: Update README with latest video
- Documentation: Update README with May 2024 blog post
- Documentation: Update SCExample documentation