Struct GlTexture

Source
pub struct GlTexture { /* private fields */ }

Implementations§

Source§

impl GlTexture

Source

pub fn new( server: &GlGraphicsServer, desc: GpuTextureDescriptor<'_>, ) -> Result<GlTexture, FrameworkError>

Creates new GPU texture of specified kind. Mip count must be at least 1, it means that there is only main level of detail.

§Data layout

In case of Cube texture, bytes should contain all 6 cube faces ordered like so, +X, -X, +Y, -Y, +Z, -Z. Cube mips must follow one after another.

Produced texture can be used as render target for framebuffer, in this case data parameter can be None.

§Compressed textures

For compressed textures data must contain all mips, where each mip must be 2 times smaller than previous.

Source

pub fn bind(&self, server: &GlGraphicsServer, sampler_index: u32)

Source

pub fn id(&self) -> <Context as HasContext>::Texture

Trait Implementations§

Source§

impl Drop for GlTexture

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl GpuTexture for GlTexture

Source§

fn set_anisotropy(&mut self, anisotropy: f32)

Max samples for anisotropic filtering. Default value is 16.0 (max). However, real value passed to GPU will be clamped to maximum supported by current GPU. To disable anisotropic filtering set this to 1.0. Typical values are 2.0, 4.0, 8.0, 16.0.
Source§

fn anisotropy(&self) -> f32

Returns current anisotropy level.
Source§

fn set_minification_filter(&mut self, filter: MinificationFilter)

Sets new minification filter. It is used when texture becomes smaller. See MinificationFilter docs for more info.
Source§

fn minification_filter(&self) -> MinificationFilter

Returns current minification filter.
Source§

fn set_magnification_filter(&mut self, filter: MagnificationFilter)

Sets new magnification filter. It is used when texture is “stretching”. See MagnificationFilter docs for more info.
Source§

fn magnification_filter(&self) -> MagnificationFilter

Returns current magnification filter.
Source§

fn set_wrap(&mut self, coordinate: Coordinate, wrap: WrapMode)

Sets new wrap mode for the given coordinate. See WrapMode for more info.
Source§

fn wrap_mode(&self, coordinate: Coordinate) -> WrapMode

Returns current wrap mode for the given coordinate.
Source§

fn set_border_color(&mut self, color: Color)

Sets border color of the texture. Works together with WrapMode::ClampToBorder and essentially forces the GPU to use the given color when it tries to read outside the texture bounds.
Source§

fn set_data( &mut self, kind: GpuTextureKind, pixel_kind: PixelKind, mip_count: usize, data: Option<&[u8]>, ) -> Result<(), FrameworkError>

Sets the new data of the texture. This method is also able to change the kind of the texture and its pixel kind.
Source§

fn get_image(&self, level: usize) -> Vec<u8>

Reads the texture data at the given mip level. This method could block current thread until the data comes from GPU to CPU side.
Source§

fn read_pixels(&self) -> Vec<u8>

Reads texture pixels.
Source§

fn kind(&self) -> GpuTextureKind

Returns kind of the texture.
Source§

fn pixel_kind(&self) -> PixelKind

Returns pixel kind of the texture.
Source§

fn set_base_level(&mut self, level: usize)

Specifies the index of the lowest defined mipmap level. Keep in mind, that the texture data should provide the actual mip map level defined by the provided value, otherwise the rendering will be incorrect (probably just black on majority of implementations) and glitchy.
Source§

fn base_level(&self) -> usize

Returns the index of the lowest defined mipmap level.
Source§

fn set_max_level(&mut self, level: usize)

Sets the index of the highest defined mipmap level. Keep in mind, that the texture data should provide the actual mip map level defined by the provided value, otherwise the rendering will be incorrect (probably just black on majority of implementations) and glitchy.
Source§

fn max_level(&self) -> usize

Returns the index of the highest defined mipmap level.
Source§

fn set_min_lod(&mut self, min_lod: f32)

Sets the minimum level-of-detail parameter. This floating-point value limits the selection of highest resolution mipmap (lowest mipmap level). The initial value is -1000.0.
Source§

fn min_lod(&self) -> f32

Returns the minimum level-of-detail parameter. See Self::set_min_lod for more info.
Source§

fn set_max_lod(&mut self, max_lod: f32)

Sets the maximum level-of-detail parameter. This floating-point value limits the selection of the lowest resolution mipmap (highest mipmap level). The initial value is 1000.
Source§

fn max_lod(&self) -> f32

Returns the maximum level-of-detail parameter. See Self::set_max_lod for more info.
Source§

fn set_lod_bias(&mut self, bias: f32)

Specifies a fixed bias value that is to be added to the level-of-detail parameter for the texture before texture sampling. The specified value is added to the shader-supplied bias value (if any) and subsequently clamped into the implementation-defined range −bias_max..bias_max, where bias_max is the value that can be fetched from the current graphics server. The initial value is 0.0.
Source§

fn lod_bias(&self) -> f32

Returns a fixed bias value that is to be added to the level-of-detail parameter for the texture before texture sampling. See Self::set_lod_bias for more info.

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> FieldValue for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more