pub struct GlTexture { /* private fields */ }
Implementations§
Source§impl GlTexture
impl GlTexture
Sourcepub fn new(
server: &GlGraphicsServer,
desc: GpuTextureDescriptor<'_>,
) -> Result<GlTexture, FrameworkError>
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.
pub fn bind(&self, server: &GlGraphicsServer, sampler_index: u32)
pub fn id(&self) -> <Context as HasContext>::Texture
Trait Implementations§
Source§impl GpuTexture for GlTexture
impl GpuTexture for GlTexture
Source§fn set_anisotropy(&mut self, anisotropy: f32)
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
fn anisotropy(&self) -> f32
Returns current anisotropy level.
Source§fn set_minification_filter(&mut self, filter: MinificationFilter)
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
fn minification_filter(&self) -> MinificationFilter
Returns current minification filter.
Source§fn set_magnification_filter(&mut self, filter: MagnificationFilter)
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
fn magnification_filter(&self) -> MagnificationFilter
Returns current magnification filter.
Source§fn set_wrap(&mut self, coordinate: Coordinate, wrap: WrapMode)
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
fn wrap_mode(&self, coordinate: Coordinate) -> WrapMode
Returns current wrap mode for the given coordinate.
Source§fn set_border_color(&mut self, color: Color)
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>
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> ⓘ
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 kind(&self) -> GpuTextureKind
fn kind(&self) -> GpuTextureKind
Returns kind of the texture.
Source§fn pixel_kind(&self) -> PixelKind
fn pixel_kind(&self) -> PixelKind
Returns pixel kind of the texture.
Source§fn set_base_level(&mut self, level: usize)
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
fn base_level(&self) -> usize
Returns the index of the lowest defined mipmap level.
Source§fn set_max_level(&mut self, level: usize)
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 set_min_lod(&mut self, min_lod: f32)
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
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)
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
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)
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
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§
impl Freeze for GlTexture
impl !RefUnwindSafe for GlTexture
impl !Send for GlTexture
impl !Sync for GlTexture
impl Unpin for GlTexture
impl !UnwindSafe for GlTexture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
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)
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.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.