Created
February 3, 2015 23:17
-
-
Save sansumbrella/2aff4563cd1e2e99b786 to your computer and use it in GitHub Desktop.
Async Movie Load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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