Struct egui_directx11::Renderer

source ·
pub struct Renderer { /* private fields */ }
Expand description

The core of this crate. You can set up a renderer via Renderer::new and render the output from egui with Renderer::render.

Implementations§

source§

impl Renderer

source

pub fn new(device: &ID3D11Device) -> Result<Self>

Create a Renderer using the provided Direct3D11 device. The Renderer holds various Direct3D11 resources and states derived from the device.

If any Direct3D resource creation fails, this function will return an error. You can create the Direct3D11 device with debug layer enabled to find out details on the error.

source

pub fn render( &mut self, device_context: &ID3D11DeviceContext, render_target: &ID3D11RenderTargetView, egui_ctx: &Context, egui_output: RendererOutput, scale_factor: f32 ) -> Result<()>

Render the output of egui to the provided render target using the provided device context. The render target should use a linear color space (e.g. DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) for proper results.

The scale_factor should be the scale factor of your window and not confused with egui::Context::zoom_factor. If you are using winit, the scale_factor can be aquired using Window::scale_factor.

§Error Handling

If any Direct3D resource creation fails, this function will return an error. In this case you may have a incomplete or incorrect rendering result. You can create the Direct3D11 device with debug layer enabled to find out details on the error. If the device has been lost, you should drop the Renderer and create a new one.

§Pipeline State Management

This function sets up its own Direct3D11 pipeline state for rendering on the provided device context. It assumes that the hull shader, domain shader and geometry shader stages are not active on the provided device context without any further checks. It is all your responsibility to backup the current pipeline state and restore it afterwards if your rendering pipeline depends on it.

Particularly, it overrides:

  • The input layout, vertex buffer, index buffer and primitive topology in the input assembly stage;
  • The current shader in the vertex shader stage;
  • The viewport and rasterizer state in the rasterizer stage;
  • The current shader, shader resource slot 0 and sampler slot 0 in the pixel shader stage;
  • The render target(s) and blend state in the output merger stage;

See the egui-demo example for code examples.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.