Ream v0.1.0-1
C++ graphics library for Linux
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
RCore Class Referenceabstract

Library entry point and global context. More...

#include <RCore.h>

+ Inheritance diagram for RCore:

Classes

struct  Options
 Options used to initialize RCore. More...
 

Public Member Functions

virtual void clearGarbage () noexcept=0
 Clears resources pending destruction.
 
const std::vector< RDevice * > & devices () const noexcept
 Returns all rendering devices enumerated by the library.
 
RDevicemainDevice () const noexcept
 Returns the main (default) device.
 
bool overrideMainDevice (RDevice *device) noexcept
 Overrides the main device.
 
RGraphicsAPI graphicsAPI () const noexcept
 Returns the active graphics API.
 
RPlatform platform () const noexcept
 Returns the active platform.
 
const Optionsoptions () const noexcept
 Returns the options RCore was created with.
 
std::shared_ptr< RGLCoreasGL () noexcept
 Attempts to cast this RCore instance to an RGLCore.
 
std::shared_ptr< RRSCoreasRS () noexcept
 Attempts to cast this RCore instance to an RRSCore.
 
std::shared_ptr< RVKCoreasVK () noexcept
 Attempts to cast this RCore instance to an RVKCore.
 
 ~RCore () noexcept
 Destructor.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RCoreMake (const Options &options) noexcept
 Creates and initializes the single RCore instance.
 
static std::shared_ptr< RCoreGet () noexcept
 Returns the current global RCore instance.
 

Detailed Description

Library entry point and global context.

RCore initializes Ream, selecting the platform (DRM, Wayland, Offscreen) and graphics API (Raster, OpenGL, Vulkan). It owns and exposes the available rendering devices (RDevice) and reports information about the active platform and GAPI.

A single instance exists per process; create it with RCore::Make() and access it globally via RCore::Get(). The graphics API can be forced with the CZ_REAM_GAPI environment variable when RGraphicsAPI::Auto is requested.


Class Documentation

◆ CZ::RCore::Options

struct CZ::RCore::Options

Options used to initialize RCore.

Class Members
RGraphicsAPI graphicsAPI { RGraphicsAPI::Auto } Graphics API to use.

When set to RGraphicsAPI::Auto, the API is selected automatically and can be forced through the CZ_REAM_GAPI environment variable ("GL", "VK" or "RS").

shared_ptr< RPlatformHandle > platformHandle Handle describing the target platform (DRM, Wayland, Offscreen).

Must not be null; RCore::Make() fails otherwise.

Constructor & Destructor Documentation

◆ ~RCore()

~RCore ( )
noexcept

Destructor.

Member Function Documentation

◆ Make()

static std::shared_ptr< RCore > Make ( const Options options)
staticnoexcept

Creates and initializes the single RCore instance.

Selects the graphics API and platform from options, enumerates the available devices, and logs library information. An explicitly requested API does not silently fall back; only RGraphicsAPI::Auto may fall back (e.g. to OpenGL).

Parameters
optionsInitialization options.
Returns
A shared pointer to the new RCore, or nullptr on failure or if an instance already exists.

◆ Get()

static std::shared_ptr< RCore > Get ( )
staticnoexcept

Returns the current global RCore instance.

Returns
The existing RCore instance, or nullptr if none has been created.

◆ clearGarbage()

virtual void clearGarbage ( )
pure virtualnoexcept

Clears resources pending destruction.

This is primarily used by the OpenGL graphics API. For example, an RGLImage may hold framebuffers, renderbuffers, or other GPU resources that were created in contexts on other threads.

Such resources are queued for deletion and will be released either when the owning thread is destroyed or when this function is called.

Implemented in RGLCore, RRSCore, and RVKCore.

◆ devices()

const std::vector< RDevice * > & devices ( ) const
inlinenoexcept

Returns all rendering devices enumerated by the library.

Returns
A reference to the vector of available devices. Ownership remains with RCore.

◆ mainDevice()

RDevice * mainDevice ( ) const
inlinenoexcept

Returns the main (default) device.

This is the device used whenever an RDevice* parameter is left as nullptr.

Returns
The main device. Always valid after successful initialization.

◆ overrideMainDevice()

bool overrideMainDevice ( RDevice device)
inlinenoexcept

Overrides the main device.

Warning
Must not be called after creating images, surfaces, or other resources.
Parameters
deviceThe device to set as main. Must not be null.
Returns
true if the device was set, false if device is null.

◆ graphicsAPI()

RGraphicsAPI graphicsAPI ( ) const
inlinenoexcept

Returns the active graphics API.

Returns
The resolved graphics API (never RGraphicsAPI::Auto after initialization).

◆ platform()

RPlatform platform ( ) const
inlinenoexcept

Returns the active platform.

Returns
The platform reported by the platform handle (DRM, Wayland, or Offscreen).

◆ options()

const Options & options ( ) const
inlinenoexcept

Returns the options RCore was created with.

◆ asGL()

std::shared_ptr< RGLCore > asGL ( )
noexcept

Attempts to cast this RCore instance to an RGLCore.

Returns
A shared pointer to RGLCore if this object is an instance of RGLCore, or nullptr otherwise.

◆ asRS()

std::shared_ptr< RRSCore > asRS ( )
noexcept

Attempts to cast this RCore instance to an RRSCore.

Returns
A shared pointer to RRSCore if the active API is Raster, or nullptr otherwise.

◆ asVK()

std::shared_ptr< RVKCore > asVK ( )
noexcept

Attempts to cast this RCore instance to an RVKCore.

Returns
A shared pointer to RVKCore if the active API is Vulkan, or nullptr otherwise.