pub struct RenderContext {
pub model_stack: Vec<Model>,
pub cache: RenderCache,
}
Expand description
The render context.
Keeps a stack of model nodes and the render cache.
Fields§
§model_stack: Vec<Model>
Model stack.
cache: RenderCache
Render cache.
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn init(model: &Model, resolution: RenderResolution) -> RenderResult<Self>
pub fn init(model: &Model, resolution: RenderResolution) -> RenderResult<Self>
Initialize context with current model and prerender model.
Sourcepub fn with_model<T>(
&mut self,
model: Model,
f: impl FnOnce(&mut RenderContext) -> T,
) -> T
pub fn with_model<T>( &mut self, model: Model, f: impl FnOnce(&mut RenderContext) -> T, ) -> T
Run the closure f
within the given model
.
Sourcepub fn update_2d(
&mut self,
f: impl FnOnce(&mut RenderContext, Model, RenderResolution) -> RenderResult<Geometry2DOutput>,
) -> RenderResult<Geometry2DOutput>
pub fn update_2d( &mut self, f: impl FnOnce(&mut RenderContext, Model, RenderResolution) -> RenderResult<Geometry2DOutput>, ) -> RenderResult<Geometry2DOutput>
Update a 2D geometry if it is not in cache.
TODO Add cache look up functionality.
Sourcepub fn update_3d(
&mut self,
f: impl FnOnce(&mut RenderContext, Model, RenderResolution) -> RenderResult<Geometry3DOutput>,
) -> RenderResult<Geometry3DOutput>
pub fn update_3d( &mut self, f: impl FnOnce(&mut RenderContext, Model, RenderResolution) -> RenderResult<Geometry3DOutput>, ) -> RenderResult<Geometry3DOutput>
Update a 3D geometry if it is not in cache.
TODO Add cache look up functionality.
Sourcepub fn current_resolution(&self) -> RenderResolution
pub fn current_resolution(&self) -> RenderResolution
Return current render resolution.
Trait Implementations§
Source§impl Default for RenderContext
impl Default for RenderContext
Source§fn default() -> RenderContext
fn default() -> RenderContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RenderContext
impl !RefUnwindSafe for RenderContext
impl !Send for RenderContext
impl !Sync for RenderContext
impl Unpin for RenderContext
impl !UnwindSafe for RenderContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more