Struct gfx_draping::DrapingRenderer
[−]
[src]
pub struct DrapingRenderer<R: Resources> { /* fields omitted */ }
Drives graphics operations.
This struct contains the shaders and stencil operations necessary to render draped polygons onto a terrain.
Methods
impl<R: Resources> DrapingRenderer<R>
[src]
fn new<F: Factory<R>>(factory: &mut F) -> DrapingRenderer<R>
[src]
Set up the pipeline state objects needed for rendering draped polygons.
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>
)
[src]
&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
impl<R: Clone + Resources> Clone for DrapingRenderer<R>
[src]
fn clone(&self) -> DrapingRenderer<R>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more