Skip to content

How to get pixel color from the buffer ? #3542

Answered by sak96
sak96 asked this question in Q&A
Discussion options

You must be logged in to vote

adding padded_buffer to scope seems to have fixed issue but not sure if that is really a fix.

let buffer_slice = self.output_buffer.slice(..);
let (tx, rx) = channel::oneshot::channel();
buffer_slice.map_async(wgpu::MapMode::Read, move |result| {
    tx.send(result).unwrap();
});
self.device.poll(wgpu::Maintain::Wait);
if block_on(async {rx.await}).is_ok() {
  let padded_buffer = buffer_slice.get_mapped_range();
  todo!();
}
output_buffer.unmap();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sak96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant