Struct opengl_graphics::Texture [] [src]

pub struct Texture {
    // some fields omitted
}

Wraps OpenGL texture data. The texture gets deleted when running out of scope.

In order to create a texture the function GenTextures must be loaded. This is done automatically by the window back-ends in Piston.

Methods

impl Texture
[src]

fn new(id: GLuint, width: u32, height: u32) -> Self

Creates a new texture.

fn get_id(&self) -> GLuint

Gets the OpenGL id of the texture.

fn from_memory_alpha(buf: &[u8], width: u32, height: u32, settings: &TextureSettings) -> Result<Self, String>

Loads image from memory, the format is 8-bit greyscale.

fn from_path<P>(path: P) -> Result<Self, String> where P: AsRef<Path>

Loads image by relative file name to the asset root.

fn from_image(img: &RgbaImage, settings: &TextureSettings) -> Self

Creates a texture from image.

fn update(&mut self, img: &RgbaImage)

Updates image with a new one.

Trait Implementations

impl Drop for Texture
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more

impl ImageSize for Texture
[src]

fn get_size(&self) -> (u32, u32)

Get the image size.

fn get_width(&self) -> u32

Gets the image width.

fn get_height(&self) -> u32

Gets the image height.

impl CreateTexture<()> for Texture
[src]

type Error = String

The error when creating texture.

fn create<S: Into<[u32; 2]>>(_factory: &mut (), _format: Format, memory: &[u8], size: S, settings: &TextureSettings) -> Result<Self, Self::Error>

Create texture from memory.

impl UpdateTexture<()> for Texture
[src]

type Error = String

The error when updating texture.

fn update<O: Into<[u32; 2]>, S: Into<[u32; 2]>>(&mut self, _factory: &mut (), _format: Format, memory: &[u8], offset: O, size: S) -> Result<(), Self::Error>

Update the texture. Read more