Skip to content

Instantly share code, notes, and snippets.

@aaronsherwood
Last active December 12, 2015 06:19
Show Gist options
  • Save aaronsherwood/4728265 to your computer and use it in GitHub Desktop.
Save aaronsherwood/4728265 to your computer and use it in GitHub Desktop.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
video.loadMovie("bridgeR.mov");
video.play();
ofBackground(0);
ofEnableAlphaBlending();
image.allocate(video.getWidth(), video.getHeight(), OF_IMAGE_COLOR);
mode=1;
rgbaFboFloat.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB);
rgbaFboFloat.begin();
ofClear(255,255,255, 0);
rgbaFboFloat.end();
screenGrab.allocate(ofGetWidth(),ofGetHeight(),GL_RGBA);
addIt.allocate(ofGetWidth(),ofGetHeight(),GL_RGBA);
ofHideCursor();
}
//--------------------------------------------------------------
void testApp::update(){
video.update();
if (mode==2) {
rgbaFboFloat.begin();
drawFboTest();
rgbaFboFloat.end();
}
}
//--------------------------------------------------------------
void testApp::drawFboTest(){
ofEnableAlphaBlending();
image.setFromPixels(video.getPixelsRef());
ofSetColor(255,255,255,200);
image.drawSubsection(0, 0,ofGetWidth(), ofGetHeight(),ofRandom(ofGetWidth()),ofRandom(ofGetHeight()), 200, 250);
}
//--------------------------------------------------------------
void testApp::draw(){
if (mode==1){
ofEnableBlendMode(OF_BLENDMODE_ADD);
ofSetColor(255, 255, 255,(ofMap(mouseX, 0, ofGetWidth(), 0, 255)));
video.draw(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(255, 255, 255,200);
screenGrab.draw(0, 0,ofGetWidth(), ofGetHeight());
screenGrab.loadScreenData(ofRandom(ofGetWidth()),ofRandom(ofGetHeight()), 200, 250);
ofDisableBlendMode();
}
if (mode==2){
ofEnableAlphaBlending();
ofSetColor(255,255,255,(ofMap(mouseX, 0, ofGetWidth(), 0, 255)));
addIt=rgbaFboFloat.getTextureReference();
ofEnableBlendMode(OF_BLENDMODE_ADD);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(255,255,255,ofClamp((ofMap(mouseX, 0, ofGetWidth(), 0, 255)), 50, 255));
addIt.draw(0, 0,ofGetWidth(), ofGetHeight());
ofDisableBlendMode();
}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
if (key=='1'){
mode=1;
}
if (key=='2'){
mode=2;
}
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
int width = ofGetWidth();
float pct = (float)x / (float)width;
video.setPosition(pct);
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
video.setPaused(true);
int width = ofGetWidth();
float pct = (float)x / (float)width;
video.setPosition(pct);
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
video.play();
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment