Last active
June 1, 2016 02:21
-
-
Save elliotwoods/783ec8e64a447973f28371468ac87851 to your computer and use it in GitHub Desktop.
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 "ofMain.h" | |
#include "ofApp.h" | |
//======================================================================== | |
int main( ){ | |
ofGLFWWindowSettings windowSettings; | |
windowSettings.glVersionMajor = 4; | |
windowSettings.glVersionMinor = 0; | |
auto window = ofCreateWindow(windowSettings); | |
ofRunApp(new ofApp()); | |
} |
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 "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
//setup an fbo | |
{ | |
ofFbo::Settings fboSettings; | |
fboSettings.width = 512; | |
fboSettings.height = 512; | |
fboSettings.internalformat = GL_RGBA32F; | |
this->fbo.allocate(fboSettings); | |
} | |
//setup the window | |
{ | |
ofGLFWWindowSettings windowSettings; | |
windowSettings.shareContextWith = ofGetCurrentWindow(); | |
windowSettings.width = 640; | |
windowSettings.height = 480; | |
windowSettings.setPosition({ 1000, 40 }); | |
this->window = make_shared<ofAppGLFWWindow>(); | |
this->window->setup(windowSettings); | |
this->window->update(); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
//draw to the fbo | |
{ | |
this->fbo.begin(); | |
{ | |
ofClear(0, 255); | |
ofPushStyle(); | |
{ | |
ofSetColor(255, 100, 100); | |
ofDrawCircle(30, 30, 100); | |
} | |
ofPopStyle(); | |
ofDrawBitmapStringHighlight("this is the fbo", 10, 10); | |
} | |
this->fbo.end(); | |
} | |
//cache the app window for later | |
auto appWindow = ofGetCurrentWindow(); | |
//draw the window | |
window->update(); | |
window->makeCurrent(); | |
{ | |
window->renderer()->startRender(); | |
ofClear(0, 0); | |
ofPushView(); | |
{ | |
ofSetupScreenOrtho(); | |
ofDrawCircle(50, 50, 50); | |
ofDrawBitmapStringHighlight("this is the client window", 20, 20); | |
this->fbo.draw(20, 50); | |
} | |
ofPopView(); | |
window->swapBuffers(); | |
window->renderer()->finishRender(); | |
} | |
appWindow->makeCurrent(); | |
ofDrawBitmapStringHighlight("this is the main window in update", 20, 20); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
ofDrawBitmapStringHighlight("this is the new main window in draw", 20, 30); | |
fbo.draw(20, 50); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseEntered(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseExited(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
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
#pragma once | |
#include "ofMain.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); | |
shared_ptr<ofAppBaseWindow> window; | |
ofFbo fbo; | |
ofTexture textureCopy; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment