Headers: src/system/hwlayer.h, src/system/resources.h, src/system/console.h, src/system/pakReader.h
Namespaces: glitter::system, glitter
glitter::system::HWLayer
Platform and windowing layer. Created first during engine init (before the renderer). Retrieve via engine::hwlayer().
Constructor
Methods
| Member | Returns | Description |
|---|
createWindow(title, width, height, framelimit, type) | Window& | Create the primary SDL window with the given frame rate limit and window type |
getRenderer() | Renderer& | Access the active renderer (throws if none is set) |
getRendererPtr() | Renderer* | Raw pointer to the renderer (nullptr before a renderer is attached) |
setRenderer(renderer) | void | Attach a renderer to this hardware layer |
getMonitors() | monitorArray& | List of detected monitors and their display modes |
getPaths() | ospaths& | Platform path helpers — base (executable dir) and pref (user prefs dir) |
clearDrawBuffer() | void | Clear the current draw buffer |
glitter::system::windowType
| Value | Description |
|---|
FULLSCREEN | True exclusive fullscreen |
FAKE_FULLSCREEN | Borderless fullscreen at desktop resolution |
WINDOWED | Normal windowed mode |
glitter::system::Window
The main SDL application window. Retrieve via engine::mainWindow().
Title
| Member | Returns | Description |
|---|
setTitle(str) | void | Set the window title |
setTitle(str, save) | void | Set the window title; if save = true, also save it as the persistent base title |
getTitle() | std::string | Get the current window title |
Display mode
| Member | Returns | Description |
|---|
makeFullscreen() | void | Switch to true exclusive fullscreen |
makeFakeFullscreen() | void | Switch to borderless fullscreen at desktop resolution |
makeWindowed() | void | Return to windowed mode |
Size
| Member | Returns | Description |
|---|
getWidth() | int | Current window width in pixels |
getHeight() | int | Current window height in pixels |
Rendering & timing
| Member | Returns | Description |
|---|
makeCurrent() | void | Make the renderer context current on the calling thread |
swap() | void | Present the back buffer immediately |
swapTick() | bool | Present the back buffer and enforce the frame rate limit. Returns true while the application is running; false when a quit has been signalled. |
getDelta() | double | Frame delta time in seconds since the last swapTick() |
Events
| Member | Returns | Description |
|---|
pollEvents() | void | Pump the SDL event queue into the internal queue |
hasEvents() | bool | true if there are unprocessed events in the queue |
currentEvent() | SDL_Event | Peek at the front event (call hasEvents() first) |
popEvent() | void | Remove the front event from the queue |
hasQuitSignal() | bool | true if a quit or window-close event was received |
| Member | Returns | Description |
|---|
setRelativeMouseMode(enable) | void | Hide the cursor and use relative motion (true) or restore it (false). Used by the free-fly camera. |
glitter::resources
URI-based resource system. All game data is accessed through scheme-mapped URIs. Retrieve via engine::resources().
Scheme registration
| Member | Returns | Description |
|---|
setAbsolutePath(scheme, directory) | void | Map a URI scheme to an absolute filesystem directory (read-write) |
setAbsolutePath(scheme, directory, readonly) | void | Map a URI scheme to a directory; readonly = true prevents writes |
deleteSchemeResources(scheme) | void | Unmap a scheme and release any cached data associated with it |
Reading resources
| Member | Returns | Description |
|---|
getResourceBytes(uri) | std::vector<std::byte> | Read raw bytes; throws on failure |
tryGetResourceBytes(uri) | expected<vector<byte>, string> | Read raw bytes; returns an error string on failure |
getResourceString(uri) | std::string | Read as a UTF-8 string; throws on failure |
tryGetResourceString(uri) | expected<string, string> | Read as string; returns an error string on failure |
getResourceJSON(uri) | nlohmann::json | Parse as JSON; throws on failure |
tryGetResourceJSON(uri) | expected<json, string> | Parse as JSON; returns an error string on failure |
Writing resources
| Member | Returns | Description |
|---|
setResourceData(uri, data) | void | Write raw byte data to a URI (writable schemes only) |
writeResourcePointer(uri) | SDL_IOStream* | Open a write stream to a URI; close with SDL_CloseIO when done |
readResourcePointer(uri) | SDL_IOStream* | Open a read stream from a URI; close with SDL_CloseIO when done |
Discovery
| Member | Returns | Description |
|---|
resourceExists(uri) | bool | Returns true if the resource file exists on disk |
listFiles(directoryUri) | std::vector<uri<void>> | List all entries (files and subdirectories) under a scheme directory |
getFilesystemPath(uri) | boost::filesystem::path | Resolve a URI to its absolute native filesystem path |
glitter::uri<T>
Lightweight URI handle used by all resource APIs. The base uri<void> accepts any full "scheme://address" string. Typed variants (e.g. uri<res::shader>) prepend the scheme automatically.
uri<void> — base untyped URI
src/system/resources.h
uri(const std::string& uriStr)
uri(const char* s)
uri(const uri<void>& parent, const std::string& child)
| Member | Returns | Description |
|---|
getScheme() | std::string | Scheme component (e.g. "scenes", "textures") |
getAddress() | std::string | Address component (path within the scheme) |
getNative() | std::string | Absolute native filesystem path |
getUri() | std::string | Full URI string ("scheme://address") |
getFilename() | std::string | Filename component only (no directory, no scheme) |
getParentUri() | uri<void> | Parent directory as a URI |
isFile() | bool | true when the address has a file extension |
isDirectory() | bool | true when the address has no file extension |
contentType() | std::string_view | RFC 2046 MIME type derived from the file extension |
uri<Tag> — typed URI
src/system/resources.h
template<typename Tag>
class uri : public uri<void> {
explicit uri(const std::string& filename);
explicit uri(const char* filename);
};
Typed URIs convert implicitly to uri<void> so all resource APIs accept them without any changes at the call site.
Well-known MIME types (glitter::mime)
| Constant | MIME type |
|---|
mime::json | application/json |
mime::png | image/png |
mime::jpeg | image/jpeg |
mime::hdr | image/x-hdr |
mime::ktx2 | image/ktx2 |
mime::gltfBinary | model/gltf-binary |
mime::gltfJson | model/gltf+json |
mime::spirv | application/spirv |
mime::glsl | text/x-glsl |
mime::text | text/plain |
mime::octetStream | application/octet-stream |
mime::directory | inode/directory |
glitter::system::Console
Valve-style developer console with a scrollable log pane and command line. Header: src/system/console.h.
Methods
| Member | Returns | Description |
|---|
registerCommand(name, description, handler) | void | Register a named command (stored lowercase) |
addLine(text, level) | void | Append a line to the log pane. Thread-safe — called from the spdlog sink. |
execute(line) | void | Parse and execute a command string |
draw() | void | Draw the ImGui console window. Call inside an active ImGui frame. |
toggle() | void | Toggle console open/closed |
isOpen() | bool | Whether the console is currently open |
entryCount() | size_t | Number of buffered log entries |
CommandArgs
| Member | Returns | Description |
|---|
positional | vector<string> | Positional (non-flag) arguments |
hasFlag(flag) | bool | Check if a --flag was present |
get(key) | optional<string_view> | Get a --key=value arg, or nullopt if absent |
glitter::system::PakReader
Reads .glitterpak archives (binary asset packages). Header: src/system/pakReader.h.
Static factory
src/system/pakReader.h
static tl::expected<PakReader, std::string> PakReader::open(std::vector<std::byte> archiveData);
Methods
| Member | Returns | Description |
|---|
findFile(path) | optional<FileInfo> | O(1) hash lookup for a file entry |
readFile(info) | expected<vector<byte>, string> | Read and decompress a file entry |
listDirectory(path) | vector<string> | List entries under a directory path |