rust/lib-hedgewars-engine/src/render/gl.rs
changeset 14719 abc6aaf481c4
parent 14707 5237b4c44d11
child 15285 6382a14c9e83
--- a/rust/lib-hedgewars-engine/src/render/gl.rs	Sun Mar 24 20:11:55 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/render/gl.rs	Sun Mar 24 20:40:12 2019 +0300
@@ -2,6 +2,34 @@
 
 use std::{ffi, ffi::CString, mem, ptr, slice};
 
+#[derive(Default)]
+pub struct PipelineState {
+    blending: bool,
+}
+
+impl PipelineState {
+    pub fn new() -> Self {
+        Self::default()
+    }
+
+    pub fn with_blend(mut self) -> Self {
+        unsafe {
+            gl::Enable(gl::BLEND);
+            gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
+        }
+        self.blending = true;
+        self
+    }
+}
+
+impl Drop for PipelineState {
+    fn drop(&mut self) {
+        if self.blending {
+            unsafe { gl::Disable(gl::BLEND) }
+        }
+    }
+}
+
 #[derive(Debug)]
 pub struct Texture2D {
     pub handle: u32,