Skip to content

Instantly share code, notes, and snippets.

@sansumbrella
Created February 3, 2015 23:17
Show Gist options
  • Save sansumbrella/2aff4563cd1e2e99b786 to your computer and use it in GitHub Desktop.
Save sansumbrella/2aff4563cd1e2e99b786 to your computer and use it in GitHub Desktop.
Async Movie Load
qtime::MovieGlRef loadMovie( const ci::gl::ContextRef &context, const ci::fs::path &path ) {
ci::ThreadSetup thread_setup;
try {
context->makeCurrent();
auto movie = qtime::MovieGl::create(path);
return movie;
}
catch( std::exception &exc ) {
CI_LOG_E( "Error loading texture: " << exc.what() );
return nullptr;
}
}
auto context = gl::Context::create(gl::context());
auto future = std::async(std::launch::async, loadMovie, context, movie_path);
future.wait();
movie = future.get();
movie->play(); // crash usually occurs at this point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment