[ Video ]
[ About ]
複数のWindowで1枚の画像を表示してみました。
I tried display one image in multiple windows.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#pragma once #include "ofMain.h" #include "ofAppGLFWWindow.h" class ofApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed(int key) {}; void keyReleased(int key) {}; void mouseMoved(int x, int y) {}; void mouseDragged(int x, int y, int button) {}; void mousePressed(int x, int y, int button) {}; void mouseReleased(int x, int y, int button) {}; void mouseEntered(int x, int y) {}; void mouseExited(int x, int y) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofImage image; int screen_width, screen_height; int window_width, window_height; float noise_seed_x, noise_seed_y; ofPoint window_position; }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofSetColor(0); ofSetColor(255); this->image.loadImage("images/image.jpg"); this->screen_width = ofGetScreenWidth(); this->screen_height = ofGetScreenHeight(); this->window_width = ofGetWindowWidth(); this->window_height = ofGetWindowHeight(); this->noise_seed_x = ofRandom(100); this->noise_seed_y = ofRandom(100); } //-------------------------------------------------------------- void ofApp::update() { int x = ofMap(ofNoise(this->noise_seed_x + ofGetFrameNum() * 0.03), 0, 1, this->screen_width * -0.2, this->screen_width * 1.2) - this->window_width * 0.5; int y = ofMap(ofNoise(this->noise_seed_y + ofGetFrameNum() * 0.03), 0, 1, this->screen_height * -0.2, this->screen_height * 1.2) - this->window_height * 0.5; this->window_position = ofPoint(x, y); ofSetWindowPosition(this->window_position.x, this->window_position.y); } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(this->window_position * -1); this->image.draw(0, 0); } //-------------------------------------------------------------- int main() { ofGLFWWindowSettings settings; settings.setSize(200, 200); settings.resizable = false; for (int i = 0; i < 32; i++) { shared_ptr<ofAppBaseWindow> window = ofCreateWindow(settings); shared_ptr<ofApp> window_app(new ofApp); ofRunApp(window, window_app); } ofRunMainLoop(); } |