Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include "cinder/app/App.h"
  2. #include "cinder/app/RendererGl.h"
  3. #include "cinder/gl/gl.h"
  4.  
  5. #include "cinder/qtime/QuickTimeGl.h"
  6.  
  7. using namespace ci;
  8. using namespace ci::app;
  9. using namespace std;
  10.  
  11. class SphereTestApp : public App
  12. {
  13. public:
  14. void setup ( ) override;
  15. void update ( ) override;
  16. void draw ( ) override;
  17.  
  18. CameraPersp _camera;
  19.  
  20. gl::TextureRef _texture;
  21. gl::BatchRef _sphere;
  22. qtime::MovieGlRef _video;
  23. };
  24.  
  25. void SphereTestApp::setup()
  26. {
  27. gl::enableDepth();
  28.  
  29. _sphere = gl::Batch::create ( geom::Sphere().subdivisions(64).radius(32), gl::getStockShader( gl::ShaderDef().texture() ) );
  30.  
  31. _video = qtime::MovieGl::create( getAssetPath( "video.mp4" ) );
  32. _video->setLoop();
  33. _video->play();
  34.  
  35. _camera = CameraPersp ( getWindowWidth(), getWindowHeight(), 60.0f, 0.1f, 10000.0f );
  36. _camera.setWorldUp(vec3(0, -1, 0) );
  37. _camera.lookAt( vec3 ( 0 ), vec3 ( 0, 0, 1 ) );
  38. }
  39.  
  40. void SphereTestApp::update ( )
  41. {
  42. if ( _video->checkNewFrame() ) _texture = _video->getTexture();
  43.  
  44. float t = getElapsedSeconds() * 0.2f;
  45.  
  46. float x = std::sin ( t );
  47. float y = std::sin ( t * 2.0f ) * 0.2f;
  48. float z = std::cos ( t );
  49.  
  50. _camera.lookAt( vec3 ( x, y, z ) );
  51. }
  52.  
  53. void SphereTestApp::draw()
  54. {
  55. gl::clear( Color( 0, 0, 0 ) );
  56.  
  57. gl::setMatrices(_camera);
  58. if ( _texture )
  59. {
  60. gl::ScopedTextureBind tex0 ( _texture );
  61. _sphere->draw();
  62. }
  63. }
  64.  
  65. CINDER_APP( SphereTestApp, RendererGl );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement