Skip to content

Instantly share code, notes, and snippets.

@yusuketomoto
Last active August 29, 2015 14:08
Show Gist options
  • Save yusuketomoto/ffc6a8c7f654c9d3f3e8 to your computer and use it in GitHub Desktop.
Save yusuketomoto/ffc6a8c7f654c9d3f3e8 to your computer and use it in GitHub Desktop.
#include "ofMain.h"
static const bool USE_CAM = true;
static const string MOVIE_PATH = "";
template <bool Cond, class Then, class Else>
struct if_;
template <class Then, class Else>
struct if_<true, Then, Else> {
typedef Then type;
};
template <class Then, class Else>
struct if_<false, Then, Else> {
typedef Else type;
};
template <class T>
void setup_(T& v) {}
template <>
void setup_(ofVideoGrabber& v) { v.initGrabber(640, 480); }
template <>
void setup_(ofVideoPlayer& v) { v.loadMovie(MOVIE_PATH); v.play(); }
class ofApp : public ofBaseApp {
if_<USE_CAM, ofVideoGrabber, ofVideoPlayer>::type video;
public:
void setup() {
ofSetFrameRate(60);
ofSetVerticalSync(true);
ofBackground(0);
setup_(video);
}
void update() {
video.update();
}
void draw() {
video.draw(0, 0);
}
};
//========================================================================
int main( ){
ofSetupOpenGL(640,480,OF_WINDOW);
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment