Last active
August 29, 2015 14:19
-
-
Save motoishmz/69ae9f6745a339cead2d to your computer and use it in GitHub Desktop.
tasukete
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 "ofMain.h" | |
class ofApp : public ofBaseApp | |
{ | |
ofFbo fbo_canvas; | |
ofFbo fbo_to_artnet; | |
public: | |
void setup() | |
{ | |
// fbo_canvas.allocate(27, 51, GL_RGB); // <-- NG: このサイズだとなんかピクピクしてる... | |
fbo_canvas.allocate(28, 50, GL_RGB); // <-- OK: このサイズだとOK! | |
fbo_to_artnet.allocate(512/3, 1, GL_RGB); | |
} | |
void update() | |
{ | |
ofPushStyle(); | |
{ | |
// canvasになんか絵をかく | |
fbo_canvas.begin(); | |
ofClear(0); | |
ofSetColor(255); | |
ofRect(10, 10, 1, 1); | |
fbo_canvas.end(); | |
// fbo_canvasで書いた絵をpixによみこみ | |
ofPixels pix; | |
fbo_canvas.readToPixels(pix); | |
// 最終的にartnetに渡す用に、1列に整列 | |
fbo_to_artnet.begin(); | |
for (int y=0; y<pix.getHeight(); y++) | |
{ | |
for (int x=0; x<pix.getWidth(); x++) | |
{ | |
const ofColor &color = pix.getColor(x, y); | |
ofSetColor(color); | |
ofNoFill(); | |
ofRect(y*pix.getWidth() + x, 0, 1, 1); | |
} | |
} | |
fbo_to_artnet.end(); | |
} | |
ofPopStyle(); | |
} | |
void draw() | |
{ | |
ofScale(5, 10); // 適当に大きくかく。コメントアウト可 | |
ofPushStyle(); | |
{ | |
ofSetColor(255); | |
fbo_canvas.draw(0, 0); | |
fbo_to_artnet.draw(0, fbo_canvas.getHeight() + 1); | |
} | |
ofPopStyle(); | |
} | |
}; | |
#pragma mark - | |
#pragma mark main | |
int main(){ | |
ofSetupOpenGL(1600, 900, OF_WINDOW); | |
ofRunApp(new ofApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment