pub struct DrapingRenderer<R: Resources> { /* private fields */ }
Expand description
Drives graphics operations.
This struct contains the shaders and stencil operations necessary to render draped polygons onto a terrain.
Implementations§
Source§impl<R: Resources> DrapingRenderer<R>
impl<R: Resources> DrapingRenderer<R>
Sourcepub fn new<F: Factory<R>>(factory: &mut F) -> DrapingRenderer<R>
pub fn new<F: Factory<R>>(factory: &mut F) -> DrapingRenderer<R>
Set up the pipeline state objects needed for rendering draped polygons.
Sourcepub fn render<C: CommandBuffer<R>>(
&self,
encoder: &mut Encoder<R, C>,
render_target: RenderTargetView<R, Srgba8>,
depth_stencil_target: DepthStencilView<R, DepthStencil>,
mvp: [[f32; 4]; 4],
color: [f32; 4],
buffer: &RenderablePolygonBuffer<R>,
indices: &RenderablePolygonIndices<R>,
)
pub fn render<C: CommandBuffer<R>>( &self, encoder: &mut Encoder<R, C>, render_target: RenderTargetView<R, Srgba8>, depth_stencil_target: DepthStencilView<R, DepthStencil>, mvp: [[f32; 4]; 4], color: [f32; 4], buffer: &RenderablePolygonBuffer<R>, indices: &RenderablePolygonIndices<R>, )
Render polygons in buffer
using indices
to choose the polygons.
The depth buffer in depth_stencil_target
should contain the depth values of your terrain
– in other words, draw your terrain just before you call this function, and make sure you
don’t clear the buffer until after rendering all the polygons you wish to draw.
In addition, the stencil buffer should be cleared to zero before calling this function. The stencil buffer is guaranteed to remain zero after each call, so there is no need to clear the stencil buffer between calls to this function.
mvp
should be a model-view-projection matrix. You probably want to use a different mvp
than what you’re normally using. The polygons will only render onto terrain with z-values
between 0 and 1; you should apply a transformation to alter these z-bounds. For example, if
your terrain is bounded in height between z_min
and z_max
, your mvp use you from this
library might be constructed as:
// With the relevant imports, this is working code when using the `cgmath` crate.
let translate_z = Matrix4::from_translation([0.0, 0.0, min_z].into());
let stretch_z = Matrix4::from_nonuniform_scale(1.0, 1.0, max_z - min_z);
let draping_mvp = usual_mvp * translate_z * stretch_z;
Trait Implementations§
Source§impl<R: Clone + Resources> Clone for DrapingRenderer<R>
impl<R: Clone + Resources> Clone for DrapingRenderer<R>
Source§fn clone(&self) -> DrapingRenderer<R>
fn clone(&self) -> DrapingRenderer<R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<R> Freeze for DrapingRenderer<R>
impl<R> RefUnwindSafe for DrapingRenderer<R>where
<R as Resources>::PipelineStateObject: RefUnwindSafe,
<R as Resources>::Program: RefUnwindSafe,
impl<R> Send for DrapingRenderer<R>
impl<R> Sync for DrapingRenderer<R>
impl<R> Unpin for DrapingRenderer<R>
impl<R> UnwindSafe for DrapingRenderer<R>where
<R as Resources>::PipelineStateObject: RefUnwindSafe,
<R as Resources>::Program: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.