Struct easy_opengl::textures::Texture2D
source · pub struct Texture2D {
pub id: u32,
pub width: u32,
pub height: u32,
pub config: Option<TextureConfig>,
}
Expand description
A abstract representation of a 2D texture
Example
let mut texture1 = Texture2D::new();
texture1.load_from_file("./src/a.png", TextureConfig::new());
texture1.send_data(30, 30, 1, 1, 0xFF000000 as ptr); // Set a red pixel on x: 30, y: 30
let data = vec![...];
let texture2 = Texture2D::new();
texture2.gen_texture(TextureConfig::new());
texture2.send_data(0, 0, 100, 200, data as ptr);
let texture3 = Texture2D::new();
texture3.load_from_memory(data as ptr, TextureConfig::new());
Fields
id: u32
width: u32
height: u32
config: Option<TextureConfig>
Implementations
sourceimpl Texture2D
impl Texture2D
pub fn new() -> Self
pub fn gen_texture(&mut self, config: TextureConfig)
pub fn send_data(
&self,
xoffset: u32,
yoffset: u32,
width: u32,
height: u32,
data: *const c_void
)
pub fn load_from_memory(
&mut self,
width: u32,
height: u32,
data: *const c_void,
config: TextureConfig
)
pub fn load_from_file(&mut self, filepath: &str, config: TextureConfig)
pub fn bind(&self)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Texture2D
impl Send for Texture2D
impl Sync for Texture2D
impl Unpin for Texture2D
impl UnwindSafe for Texture2D
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more