Created
May 11, 2012 17:31
-
-
Save ofTheo/2661196 to your computer and use it in GitHub Desktop.
fbo test example.
This file contains hidden or 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 "testApp.h" | |
ofFbo fbo; | |
//-------------------------------------------------------------- | |
void testApp::setup(){ | |
//ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); | |
bikers.loadImage("images/bikers.jpg"); | |
gears.loadImage("images/gears.gif"); | |
tdf.loadImage("images/tdf_1972_poster.jpg"); | |
tdfSmall.loadImage("images/tdf_1972_poster.jpg"); | |
tdfSmall.resize(tdf.width / 4, tdf.height / 4); | |
tdfSmall.setImageType(OF_IMAGE_GRAYSCALE); | |
transparency.loadImage("images/transparency.png"); | |
bikeIcon.loadImage("images/bike_icon.png"); | |
bikeIcon.setImageType(OF_IMAGE_GRAYSCALE); | |
fbo.allocate(640, 480); | |
} | |
//-------------------------------------------------------------- | |
void testApp::update(){ | |
ofBackground(255,255,255); | |
} | |
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
fbo.begin(); | |
ofClear(255, 255, 255); | |
ofPushMatrix(); | |
ofScale(0.5, 0.5, 1.0); | |
ofSetHexColor(0xFFFFFF); | |
bikers.draw(0,0); | |
gears.draw(600,0); | |
tdf.draw(600,300); | |
ofSetHexColor(0xDD3333); | |
tdfSmall.draw(200,300); | |
ofSetHexColor(0xFFFFFF); | |
ofEnableAlphaBlending(); | |
transparency.draw(sin(ofGetElapsedTimeMillis()/1000.0f) * 100 + 500,20); | |
ofDisableAlphaBlending(); | |
ofSetHexColor(0x000000); | |
// getting the pixels out of an image, | |
// and then use the values to draw circles | |
unsigned char * pixels = bikeIcon.getPixels(); | |
int w = bikeIcon.width; | |
int h = bikeIcon.height; | |
for (int i = 0; i < w; i++){ | |
for (int j = 0; j < h; j++){ | |
int value = pixels[j * w + i]; | |
float pct = 1 - (value / 255.0f); | |
ofCircle(i*10,500 + j*10,1 + 5*pct); | |
} | |
} | |
ofSetHexColor(0xFFFFFF); | |
bikeIcon.draw(300,500, 20,20); | |
ofPopMatrix(); | |
fbo.end(); | |
fbo.draw(0,0); | |
} | |
//-------------------------------------------------------------- | |
void testApp::exit(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchDown(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchMoved(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchUp(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchDoubleTap(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchCancelled(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::lostFocus(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::gotFocus(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::gotMemoryWarning(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::deviceOrientationChanged(int newOrientation){ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment