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

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

fn drop(&mut self)

impl ImageSize for Texture

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

fn get_width(&self) -> u32

fn get_height(&self) -> u32

impl CreateTexture<()> for Texture

type Error = String

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

impl UpdateTexture<()> for Texture

type Error = String

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