Struct cgl_rs::graphics::Bloom

source ·
#[repr(C)]
pub struct Bloom { /* private fields */ }
Expand description

The Bloom Object

Implementations§

source§

impl Bloom

source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();

Trait Implementations§

source§

impl Clone for Bloom

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Drop for Bloom

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Bloom

§

impl !Send for Bloom

§

impl !Sync for Bloom

§

impl Unpin for Bloom

§

impl UnwindSafe for Bloom

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.