Hi there, Yes I was not aware of this tutorial. Thanks.
First question I have is in regards to mutexes and getting data about what keys are pressed inside the onGetData function, which is where I believe I should generate my next batch of samples. (Say I generate 4410 at a time or something...?)
What's the best way to approach this?
I have a possible idea which is to have a globally accessible bool variable, which tells me whether the Z key is pressed or not. Then if I do something like...
// global
bool is_Z_pressed = false;
sf::Mutex mutex; // protect global variables?
int main()...
{
// main loop sets the bool is_Z_pressed to true/false
// wrap accessing the bool using sf::Lock(mutex)
// access to this variable in a local scope so that the mutex is unlocked when sf::Lock falls out of scope?
{
// local scope
sf::Lock(mutex);
if(event.key.code == Key::Z)
is_Z_pressed = true;
... etc
}
}
Then in my onGetData function, do the same thing, with a sf::Lock to lock the mutex before checking if Z is pressed?
Am I thinking about this in the correct manner? Perhaps I shouldn't be using global variables?