summaryrefslogtreecommitdiff
path: root/src/texture.rs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-01-15 21:21:22 -0500
committerLLLL Colonq <llll@colonq>2025-01-15 21:21:22 -0500
commit82d1c94d999654bda5d40108393eade80b77342c (patch)
tree2a05c0ffe34ba47933ca39ebef3c3609fb6a5d2a /src/texture.rs
parentf1b47ccb8a92280df51bb28b495829f8f7f8127e (diff)
Update
Diffstat (limited to 'src/texture.rs')
-rw-r--r--src/texture.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/texture.rs b/src/texture.rs
index 2fd9aab..68272cb 100644
--- a/src/texture.rs
+++ b/src/texture.rs
@@ -8,6 +8,20 @@ pub struct Texture {
}
impl Texture {
+ pub fn new_empty(ctx: &context::Context) -> Self {
+ unsafe {
+ let tex = ctx.gl.create_texture().expect("failed to create texture");
+ ctx.gl.bind_texture(glow::TEXTURE_2D, Some(tex));
+ ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_WRAP_S, glow::CLAMP_TO_EDGE as i32);
+ ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_WRAP_T, glow::CLAMP_TO_EDGE as i32);
+ ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MIN_FILTER, glow::NEAREST as i32);
+ ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MAG_FILTER, glow::NEAREST as i32);
+ Self {
+ tex,
+ }
+ }
+ }
+
pub fn new(ctx: &context::Context, bytes: &[u8]) -> Self {
let rgba = image::io::Reader::new(std::io::Cursor::new(bytes))
.with_guessed_format()