I want to put my computational stuff in secondary thread while keeping
main loop in main thread
I want to put my computational stuff in secondary thread while keeping
main loop in main thread.
For example I want a cube rotating around OY with changing texture. Cube
rotation is supported by idle function which rotates camera. But my
texture computations are too complex and need some time so I cannot just
put them into idle (I don't need to change the texture every time my cube
rotates). Can I use foo function that does some computational stuff,
creates texels buffer and sets new texture for the cube in a separate
thread? This piece of code from main function doesn't change texture of
spinning cube.
glutIdleFunc(idle);
boost::thread_group tgroup;
tgroup.create_thread(boost::bind(&foo));
glutMainLoop();
tgroup.join_all();
Also are there concurrency problems with setting new texture in a
different thread?
No comments:
Post a Comment