Created
September 30, 2016 02:01
-
-
Save axjxwright/772eddede79b960666e521a8d1789d9c to your computer and use it in GitHub Desktop.
This file contains 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
#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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment