dxfilter/lib.rs
1#![doc = include_str ! ("../README.md")]
2
3use win_desktop_duplication::texture::Texture;
4use windows::Win32::Graphics::Direct3D11::{ID3D11Device4, ID3D11DeviceContext4};
5
6#[cfg(not(doc))]
7pub use shader_macro::compile_shader;
8
9
10#[macro_use]
11#[doc(hidden)]
12pub mod shader_generator;
13
14pub mod error;
15
16pub use error::DxResult as Result;
17
18pub mod shader;
19
20pub mod color;
21
22mod common_filters;
23
24pub mod utils;
25
26pub use common_filters::*;
27
28/// Interface for interacting with various filters. Interface is defined so that you could create
29/// Directx pipelines that involve multiple filters.
30///
31/// ## Example Usage:
32/// ```
33/// fn main () {
34/// //...
35/// let (device, context) = // acquire Device and DeviceContext
36///
37/// let input_tex = // create an input texture
38/// let output_tex = // create an output texture
39///
40/// // create some directx filter. for example the following
41/// let filter = ScaleARGBOrAYUV::new(&input_tex,&output_tex,&device);
42///
43/// // apply the filter
44/// filter.apply_filter(&context);
45///
46/// // read from the output_texture
47/// }
48/// ```
49pub trait DxFilter {
50 /// takes directx device context and applies various vertex and pixel shaders to apply the filter.
51 fn apply_filter(&self, ctx: &ID3D11DeviceContext4) -> Result<()>;
52
53 /// configure the filter to use different input texture.
54 fn set_input_tex(&mut self, tex: &Texture) -> Result<()>;
55
56 /// configure the filter to use different output texture.
57 fn set_output_tex(&mut self, tex: &Texture) -> Result<()>;
58}