Texture

Struct Texture 

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

Implementations§

Source§

impl Texture

Source

pub const fn new() -> Texture

Source

pub fn load(&mut self, library: &OpenGraphicsLibrary)

Source§

impl Texture

Source

pub fn generate_one(&self, texture: &mut u32)

Generates a texture name.

Source

pub unsafe fn delete_one(&self, texture: &u32)

Deletes a named texture.

Silently ignores 0’s and names that do not correspond to existing textures.

If a texture that is currently bound is deleted, the binding reverts to 0 (the default texture).

Source

pub unsafe fn generate(&self, textures: &mut [u32])

Generates texture names.

Source

pub fn delete(&self, textures: &[u32])

Deletes named textures.

Silently ignores 0’s and names that do not correspond to existing textures.

If a texture that is currently bound is deleted, the binding reverts to 0 (the default texture).

Source

pub unsafe fn bind(&self, target: TextureBindTarget, texture_id: u32)

Binds a texture to a texturing target.

When a texture is bound to a target, the previous binding for that target is automatically broken.

When a texture is first bound, it assumes the specified target: A texture first bound to GL_TEXTURE_1D becomes one-dimensional texture, a texture first bound to GL_TEXTURE_2D becomes two-dimensional texture, and so on.

GLError::InvalidValue is generated if target is not a name returned from a previous call to glGenTextures.

GLError::InvalidOperation is generated if texture was previously created with a target that doesn’t match that of target.

Source§

impl Texture

Texture parameters.

Source

pub fn set_base_level(&self, target: TextureParameterTarget, level: i32)

Specifies the index of the lowest defined mipmap level.

The initial value is 0.

Source

pub fn set_compare_function( &self, target: TextureParameterTarget, function: TextureCompareFunction, )

Specifies the comparison operator.

The comparison operator is used when TextureCompareMode::CompareRefToTexture is set (see Texture::set_compare_mode).

Source

pub fn set_compare_mode( &self, target: TextureParameterTarget, mode: TextureCompareMode, )

Specifies the texture comparison mode for currently bound depth textures (the iternal format = DEPTH_COMPONENT).

Source

pub fn set_mag_filter( &self, target: TextureParameterTarget, filter: TextureMagFilter, )

Specifies the texture magnification function.

The texture magnification function is used whenever the level-of-detail function used when sampling from the texture determines that the texture should be magified.

Initially, it is set to TextureMagFilter::Linear.

Source

pub fn set_min_filter( &self, target: TextureParameterTarget, filter: TextureMinFilter, )

Specifies the texture minifying function.

The texture minifying function is used whenever the level-of-detail function used when sampling from the texture determines that the texture should be minified.

Initially, it is set to TextureMinFilter::LinearMipmapLinear.

Source

pub fn set_wrap_s(&self, target: TextureParameterTarget, value: TextureWrap)

Sets the wrap parameter for texture coordinate s.

Initially, it is set to TextureWrap::Repeat.

Source

pub fn set_wrap_t(&self, target: TextureParameterTarget, value: TextureWrap)

Sets the wrap parameter for texture coordinate t.

Initially, it is set to TextureWrap::Repeat.

Source

pub fn set_wrap_r(&self, target: TextureParameterTarget, value: TextureWrap)

Sets the wrap parameter for texture coordinate r.

Initially, it is set to TextureWrap::Repeat.

Source§

impl Texture

Texture 2D data.

Source

pub unsafe fn rewrite_image_2d<I: Sized>( &self, target: Texture2DRewriteTarget, mipmap_level: i32, internal_format: Texture2DInternalFormat, [width, height]: [i32; 2], image_data_format: ImageDataFormat, data: *const I, )

Specify a two-dimensional texture image.

target - Specifies the target texture.

mipmap_level - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. If target is Texture2DRewriteTarget::TextureRectangle or Texture2DRewriteTarget::ProxyTextureRectangle, level must be 0.

internal_format - Specifies the number of color components in the texture.

width - Specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide.

height - Specifies the height of the texture image, or the number of layers in a texture array, in the case of the Texture1DArray and ProxyTexture1DArray targets. All implementations support 2D texture images that are at least 1024 texels high, and texture arrays that are at least 256 layers deep.

image_format - Specifies the format of the pixel data.

image_data_type - Specifies the data type of the pixel data.

data - Specifies a pointer to the image data in memory.

GLError::InvalidEnum is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.

GLError::InvalidValue is generated if width is less than 0 or greater than GL_MAX_TEXTURE_SIZE, if target is not GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than GL_MAX_TEXTURE_SIZE, if target is GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than GL_MAX_ARRAY_TEXTURE_LAYERS, if mipmap_level is less than 0, if mipmap_level is greater than log2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE, if width or height is less than 0 or greater than GL_MAX_TEXTURE_SIZE, if non-power-of-two textures are not supported and the width or height cannot be represented as 2^kfor some integer value ofk, if target is GL_TEXTURE_RECTANGLEorGL_PROXY_TEXTURE_RECTANGLEandmipmap_levelis not0`.

Source

pub unsafe fn write_image_2d<I: Sized>( &self, target: Texture2DWriteTarget, mipmap_level: i32, [x, y, width, height]: [i32; 4], image_data_format: ImageDataFormat, data: *const I, )

Specify a two-dimensional texture subimage.

target - Specifies the target texture.

mipmap_level - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.

x - Specifies a texel offset in the x direction within the texture array.

y - Specifies a texel offset in the y direction within the texture array.

width - Specifies the width of the texture subimage.

height - Specifies the height of the texture subimage.

image_format - Specifies the format of the pixel data.

image_data_type - Specifies the data type of the pixel data.

data - Specifies a pointer to the image data in memory.

Source

pub unsafe fn copy_image_2d( &self, target: Texture2DCopyTarget, mipmap_level: i32, [read_x, read_y]: [i32; 2], [write_x, write_y]: [i32; 2], [width, height]: [i32; 2], )

Copies a two-dimensional texture subimage.

Replaces a rectangular portion of a two-dimensional texture image or cube-map texture image with pixels from the current READ_BUFFER.

target - Specifies the target texture.

mipmap_level - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.

read_x, read_y - Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.

write_x - Specifies a texel offset in the x direction within the texture array.

write_y - Specifies a texel offset in the y direction within the texture array.

width - Specifies the width of the texture subimage.

height - Specifies the height of the texture subimage.

GLError::InvalidOperation is generated if the texture array has not been defined by a previous Texture::rewrite_image_2d() or Texture::copy_image_2d() operation.

GLError::InvalidValue is generated if mipmap_level is less than 0, if mipmap_level>log2(max), where max is the returned value of MAX_TEXTURE_SIZE, if write_x<0, (write_x+width)>w, write_y<0, or (write_y+height)>h, where w is the TEXTURE_WIDTH, and h is the TEXTURE_HEIGHT of the texture image being modified.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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