diff --git a/src/frame.rs b/src/frame.rs index 3bf06f3..2701a7a 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -156,12 +156,12 @@ impl<'a> Frame<'a> { self.frame_surface.clone() } - /// Get the frame buffer. + /// Get the raw texture of the frame. /// /// # Returns /// - /// The FrameBuffer containing the frame data. - pub fn buffer(&mut self) -> Result { + /// The ID3D11Texture2D representing the raw texture of the frame. + pub fn texture(&self) -> Result { // Texture Settings let texture_desc = D3D11_TEXTURE2D_DESC { Width: self.width, @@ -185,13 +185,25 @@ impl<'a> Frame<'a> { self.d3d_device .CreateTexture2D(&texture_desc, None, Some(&mut texture))?; }; + let texture = texture.unwrap(); - + // Copy the real texture to copy texture unsafe { self.context.CopyResource(&texture, &self.frame_texture); }; + Ok(texture) + } + + /// Get the frame buffer. + /// + /// # Returns + /// + /// The FrameBuffer containing the frame data. + pub fn buffer(&mut self) -> Result { + let texture = self.texture()?; + // Map the texture to enable CPU access let mut mapped_resource = D3D11_MAPPED_SUBRESOURCE::default(); unsafe {