#[repr(C)]pub struct Bloom { /* private fields */ }
Expand description
The Bloom Object
Implementations§
source§impl Bloom
impl Bloom
sourcepub fn new(
width: i32,
height: i32,
iterations: i32
) -> Result<Bloom, &'static str>
pub fn new( width: i32, height: i32, iterations: i32 ) -> Result<Bloom, &'static str>
Creates a new Bloom object with the specified width, height, and number of iterations.
Arguments
width
- The width of the Bloom effect.height
- The height of the Bloom effect.iterations
- The number of iterations to apply the Bloom effect.
Returns
Returns a new Bloom object if successful, otherwise returns an error message.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn destroy(&mut self)
pub fn destroy(&mut self)
Destroys the texture and frees its resources. If the texture has already been destroyed, this method does nothing.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let mut bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
bloom.destroy(); // optional
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn set_threshold(&self, val: f32)
pub fn set_threshold(&self, val: f32)
Sets the threshold value for the Bloom effect.
Arguments
val
- The threshold value to set.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
bloom.set_threshold(0.5);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn get_threshold(&self) -> f32
pub fn get_threshold(&self) -> f32
Gets the threshold value for the Bloom effect.
Returns
Returns the current threshold value.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let threshold = bloom.get_threshold();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn set_knee(&self, val: f32)
pub fn set_knee(&self, val: f32)
Sets the knee value for the Bloom effect.
Arguments
val
- The knee value to set.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
bloom.set_knee(0.5);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn get_knee(&self) -> f32
pub fn get_knee(&self) -> f32
Gets the knee value for the Bloom effect.
Returns
Returns the current knee value.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let knee = bloom.get_knee();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn set_offset(&self, x: f32, y: f32)
pub fn set_offset(&self, x: f32, y: f32)
Sets the offset values for the Bloom effect.
Arguments
x
- The x offset value to set.y
- The y offset value to set.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
bloom.set_offset(0.5, 0.5);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn apply(&self, tex: &Texture)
pub fn apply(&self, tex: &Texture)
Applies the Bloom effect to a texture.
Arguments
tex
- The texture to apply the Bloom effect to.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let texture = cgl_rs::graphics::Texture::dummy2(600, 600).unwrap();
bloom.apply(&texture);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn apply2(&self, tex_src: &Texture, tex_dst: &Texture)
pub fn apply2(&self, tex_src: &Texture, tex_dst: &Texture)
Applies the Bloom effect to a source texture and writes the result to a destination texture.
Arguments
tex_src
- The source texture to apply the Bloom effect to.tex_dst
- The destination texture to write the result to.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let texture_src = cgl_rs::graphics::Texture::dummy2(600, 600).unwrap();
let texture_dst = cgl_rs::graphics::Texture::dummy2(600, 600).unwrap();
bloom.apply2(&texture_src, &texture_dst);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn get_iterations(&self) -> i32
pub fn get_iterations(&self) -> i32
Gets the value of the number of iterations for the Bloom effect.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let iterations = bloom.get_iterations();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn get_lod_texture(&self, index: i32) -> Result<Texture, &'static str>
pub fn get_lod_texture(&self, index: i32) -> Result<Texture, &'static str>
Gets the texture for a specific level of detail (LOD) for the Bloom effect.
This texture is owned and managed by the Bloom effect and should not be destroyed manually.
Arguments
index
- The index of the LOD texture to retrieve.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let lod_texture = bloom.get_lod_texture(0);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
sourcepub fn get_prefiltered_texture(&self) -> Result<Texture, &'static str>
pub fn get_prefiltered_texture(&self) -> Result<Texture, &'static str>
Gets the prefiltered texture for the Bloom effect.
This texture is owned and managed by the Bloom effect and should not be destroyed manually.
Example
cgl_rs::init();
let mut window = cgl_rs::Window::new("Hello, World!", 800, 600).unwrap();
cgl_rs::graphics::init();
{
let bloom = cgl_rs::graphics::Bloom::new(800, 600, 3).unwrap();
let prefiltered_texture = bloom.get_prefiltered_texture();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();