Skip to content

How to read keyin while arrayfire windows is focused? #356

Answered by 3togo
3togo asked this question in Q&A
Discussion options

You must be logged in to vote

As converting Array<u8> array to sdl2::surface is a GPU to CPU process, it is not desirable in terms of performance.
To ensure that it is a GPU to GPU conversion, Array<u8> needs to be converted to sdl2::texture directly. But, how?

fn gen_array() -> Array<u8> { 
    let (h, w) = (480, 640);
    let mut a = constant::<u8>(0, dim4!(h, w, 3));
    let b = constant::<u8>(97, dim4!(h, w, 1));
    eval!(a[1:1:0, 1:1:0, 0:0:1] = b);
    return a;on
}
    let a = gen_array();
    let [h, w, channels, ..] = a.dims().get().clone();
    let a = reorder_v2(&a, 2, 1, Some(vec![0]));
    let mut b = vec![u8::default(); a.elements()];
    a.host(&mut b);
  
    let d = Surface::from_data(
        &mut b…

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
9 replies
@3togo
Comment options

@9prady9
Comment options

@9prady9
Comment options

@3togo
Comment options

@9prady9
Comment options

Comment options

You must be logged in to vote
2 replies
@9prady9
Comment options

@3togo
Comment options

Answer selected by 3togo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants