Hey all, currently I'm developing a particle simulator with SFML and Modern OpenGL, but I'm running into an issue and I need an opinion/help if I should even be doing this. I'm trying to introduce threads to hopefully simulate a parallelism curve, here's a quick drawing in paint I did that I want to reproduce:
To start off with this curve I want to launch a thread of **each** pixel and calculate it's next position on that given thread. My problem is I need to use window to grab the mouse coordinates in that thread to add force proportional to the mouses position, but passing window into the function is not an option because it is
sf::noncopyable
How can I go about doing this so I can access windows function while in each thread? Is it possible? Here is some code to demonstrate what I'm doing:
updateParticle:
void updateParticle(Particle& p,sf::Window const& window, glm::mat4& ViewMatrix, glm::mat4& ProjectionMatrix,
double& delta, glm::vec3& CameraPosition, GLfloat* g_particule_position_size_data, GLubyte* g_particule_color_data,
int& ParticlesCount);
during a for loop of all active particles on screen
//std::thread t[MAXTHREADS];
t[i] = std::thread(updateParticle,p,window,ViewMatrix,ProjectionMatrix, delta,CameraPosition,g_particule_position_size_data,g_particule_color_data,ParticlesCount);
of course this gives me an error, any workaround?
Note: if you want more code let me know, but the project is on my github at:
https://github.com/Gmercer015/ParticleSimulator . You'll find my troubles at main.cpp