rust/lib-hedgewars-engine/src/render/gl.rs
changeset 15294 fd20e0a134af
parent 15291 16bd389fc735
--- a/rust/lib-hedgewars-engine/src/render/gl.rs	Sat Aug 03 02:51:19 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/render/gl.rs	Sat Aug 03 04:16:36 2019 +0300
@@ -134,8 +134,8 @@
                     0,             // texture level
                     region.left(), // texture region
                     region.top(),
-                    region.right(),
-                    region.bottom(),
+                    region.width() as i32,
+                    region.height() as i32,
                     format,                    // data format
                     ty,                        // data type
                     data.as_ptr() as *const _, // data ptr
@@ -143,6 +143,21 @@
             }
         }
     }
+
+    pub fn retrieve(&self, data: &mut [u8]) {
+        if let Some(handle) = self.handle {
+            unsafe {
+                gl::BindTexture(gl::TEXTURE_2D, handle.get());
+                gl::GetTexImage(
+                    gl::TEXTURE_2D,
+                    0,                           // texture level
+                    gl::RGBA,                    // data format
+                    gl::UNSIGNED_BYTE,           // data type
+                    data.as_mut_ptr() as *mut _, // data ptr
+                );
+            }
+        }
+    }
 }
 
 #[derive(Debug)]