Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cinder/app/App.h"
- #include "cinder/app/RendererGl.h"
- #include "cinder/gl/gl.h"
- #include "cinder/qtime/QuickTimeGl.h"
- using namespace ci;
- using namespace ci::app;
- using namespace std;
- class SphereTestApp : public App
- {
- public:
- void setup ( ) override;
- void update ( ) override;
- void draw ( ) override;
- CameraPersp _camera;
- gl::TextureRef _texture;
- gl::BatchRef _sphere;
- qtime::MovieGlRef _video;
- };
- void SphereTestApp::setup()
- {
- gl::enableDepth();
- _sphere = gl::Batch::create ( geom::Sphere().subdivisions(64).radius(32), gl::getStockShader( gl::ShaderDef().texture() ) );
- _video = qtime::MovieGl::create( getAssetPath( "video.mp4" ) );
- _video->setLoop();
- _video->play();
- _camera = CameraPersp ( getWindowWidth(), getWindowHeight(), 60.0f, 0.1f, 10000.0f );
- _camera.setWorldUp(vec3(0, -1, 0) );
- _camera.lookAt( vec3 ( 0 ), vec3 ( 0, 0, 1 ) );
- }
- void SphereTestApp::update ( )
- {
- if ( _video->checkNewFrame() ) _texture = _video->getTexture();
- float t = getElapsedSeconds() * 0.2f;
- float x = std::sin ( t );
- float y = std::sin ( t * 2.0f ) * 0.2f;
- float z = std::cos ( t );
- _camera.lookAt( vec3 ( x, y, z ) );
- }
- void SphereTestApp::draw()
- {
- gl::clear( Color( 0, 0, 0 ) );
- gl::setMatrices(_camera);
- if ( _texture )
- {
- gl::ScopedTextureBind tex0 ( _texture );
- _sphere->draw();
- }
- }
- CINDER_APP( SphereTestApp, RendererGl );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement