pub struct Renderer { /* private fields */ }
Expand description
Implementations§
source§impl Renderer
impl Renderer
sourcepub fn create(config: Config) -> Result<Self, CreationError>
pub fn create(config: Config) -> Result<Self, CreationError>
Create the Ultralight Renderer directly.
Unlike App::new
, this does not use any native windows for drawing and allows you to manage
your own runloop and painting. This method is recommended for those wishing to integrate the
library into a game.
This instance manages the lifetime of all View
s and coordinates all painting, rendering,
network requests, and event dispatch.
You should only call this once per process lifetime.
You shoud set up your platform handlers (eg,
platform::set_gpu_driver
,
platform::set_logger
,
platform::enable_default_logger
,
platform::enable_platform_filesystem
,
etc.) before calling this.
You will also need to define a font loader before calling this –
currently the only way to do this is
platform::enable_platform_fontloader
.
You should not call this if you are using App::new
,
it creates its own renderer and provides default implementations for
various platform handlers automatically.
source§impl Renderer
impl Renderer
sourcepub fn update(&self)
pub fn update(&self)
Update timers and dispatch internal callbacks. You should call this often from your main application loop.
sourcepub fn render(&self)
pub fn render(&self)
Render all active views to their respective render-targets/surfaces.
You should call this once per frame (usually in synchrony with the monitor’s refresh rate).
View
s are only repainted if they actually need painting.
(See View::needs_paint
)
sourcepub fn purge_memory(&self)
pub fn purge_memory(&self)
Attempt to release as much memory as possible. Don’t call this from any callbacks or driver code.
sourcepub fn log_memory_usage(&self)
pub fn log_memory_usage(&self)
Print detailed memory usage statistics to the log.
(See platform::set_logger
or
platform::enable_default_logger
)
sourcepub fn create_session(
&self,
is_persistent: bool,
name: &str
) -> Result<Session, CreationError>
pub fn create_session( &self, is_persistent: bool, name: &str ) -> Result<Session, CreationError>
Create a Session to store local data in (such as cookies, local storage, application cache, indexed db, etc).
A default, persistent Session is already created for you. You only need to call this
if you want to create private, in-memory session or use a separate session for each
View
.
§Arguments
is_persistent
- Whether or not to store the session on disk. Persistent sessions will be written to the path set inConfigBuilder::cache_path
.name
- A unique name for this session, this will be used to generate a unique disk path for persistent sessions.
sourcepub fn default_session(&self) -> &Session
pub fn default_session(&self) -> &Session
Get the default Session. This session is persistent (backed to disk) and has the name “default”.