2013-08-12 10:44:58 +09:00
|
|
|
#include "ofApp.h"
|
2009-10-26 05:06:03 +08:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2016-08-25 16:40:21 -05:00
|
|
|
void ofApp::setup(){
|
2009-10-26 05:06:03 +08:00
|
|
|
counter = 0;
|
|
|
|
|
ofSetCircleResolution(100);
|
|
|
|
|
texScreen.allocate(300,300,GL_RGB);
|
|
|
|
|
ofBackground(230,230,240);
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::update(){
|
2009-10-26 05:06:03 +08:00
|
|
|
counter += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::draw(){
|
2009-10-26 05:06:03 +08:00
|
|
|
|
|
|
|
|
// 1st, draw on screen:
|
2016-08-25 16:40:21 -05:00
|
|
|
ofSetHexColor(0x66CC33);
|
2014-10-19 19:17:15 +02:00
|
|
|
ofDrawRectangle(100,100,300,300);
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2010-11-09 10:17:11 -05:00
|
|
|
ofSetHexColor(0xffffff);
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPushMatrix();
|
|
|
|
|
ofTranslate(200,200,0);
|
2016-08-25 16:40:21 -05:00
|
|
|
ofRotateDeg(counter,0,0,1);
|
2014-10-28 20:57:14 +03:00
|
|
|
ofDrawCircle(0,0,80);
|
|
|
|
|
ofDrawCircle(100,0,10); // a small one
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPopMatrix();
|
2010-11-09 10:17:11 -05:00
|
|
|
ofSetHexColor(0x333333);
|
2009-10-26 05:06:03 +08:00
|
|
|
ofDrawBitmapString("(a) on screen", 150,200);
|
|
|
|
|
|
2016-08-25 16:40:21 -05:00
|
|
|
ofSetHexColor(0xFFCC33);
|
2014-10-28 20:57:14 +03:00
|
|
|
ofDrawCircle(mouseX, mouseY,20);
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
|
|
|
|
|
// 2nd, grab a portion of the screen into a texture
|
|
|
|
|
// this is quicker then grabbing into an ofImage
|
|
|
|
|
// because the transfer is done in the graphics card
|
|
|
|
|
// as opposed to bringing pixels back to memory
|
|
|
|
|
// note: you need to allocate the texture to the right size
|
|
|
|
|
texScreen.loadScreenData(100,100,300,300);
|
2016-08-25 16:40:21 -05:00
|
|
|
|
|
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
|
|
|
|
|
// finally, draw that texture on screen, how ever you want
|
2016-08-25 16:40:21 -05:00
|
|
|
// (note: you can even draw the texture before you call loadScreenData,
|
2009-10-26 05:06:03 +08:00
|
|
|
// in order to make some trails or feedback type effects)
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPushMatrix();
|
2010-11-09 10:17:11 -05:00
|
|
|
ofSetHexColor(0xffffff);
|
2013-04-04 12:58:38 +02:00
|
|
|
ofTranslate(550,300,0);
|
2009-10-26 05:06:03 +08:00
|
|
|
//glRotatef(counter, 0.1f, 0.03f, 0);
|
|
|
|
|
float width = 200 + 100 * sin(counter/200.0f);
|
|
|
|
|
float height = 200 + 100 * sin(counter/200.0f);;
|
|
|
|
|
texScreen.draw(-width/2,-height/2,width,height);
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPopMatrix();
|
2009-10-26 05:06:03 +08:00
|
|
|
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPushMatrix();
|
2010-11-09 10:17:11 -05:00
|
|
|
ofSetHexColor(0xffffff);
|
2013-04-04 12:58:38 +02:00
|
|
|
ofTranslate(700,210,0);
|
2016-08-25 16:40:21 -05:00
|
|
|
ofRotateDeg(counter, 0.1f, 0.03f, 0);
|
2009-10-26 05:06:03 +08:00
|
|
|
texScreen.draw(-50,-50,100,100);
|
2013-04-04 12:58:38 +02:00
|
|
|
ofPopMatrix();
|
2009-10-26 05:06:03 +08:00
|
|
|
|
2010-11-09 10:17:11 -05:00
|
|
|
ofSetHexColor(0x333333);
|
2009-10-26 05:06:03 +08:00
|
|
|
ofDrawBitmapString("(b) in a texture, very meta!", 500,200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2016-08-25 16:40:21 -05:00
|
|
|
void ofApp::keyPressed (int key){
|
|
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2016-08-25 16:40:21 -05:00
|
|
|
void ofApp::keyReleased(int key){
|
|
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::mouseMoved(int x, int y ){
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::mouseDragged(int x, int y, int button){
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::mousePressed(int x, int y, int button){
|
2016-08-25 16:40:21 -05:00
|
|
|
|
2009-10-26 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
2009-05-27 16:44:48 +00:00
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::mouseReleased(int x, int y, int button){
|
2009-05-27 16:44:48 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:55:21 -04:00
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
void ofApp::mouseEntered(int x, int y){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
void ofApp::mouseExited(int x, int y){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-27 16:44:48 +00:00
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::windowResized(int w, int h){
|
2009-05-27 16:44:48 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-27 15:20:23 -05:00
|
|
|
//--------------------------------------------------------------
|
2013-08-12 10:44:58 +09:00
|
|
|
void ofApp::gotMessage(ofMessage msg){
|
2011-01-27 15:20:23 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
2016-08-25 16:40:21 -05:00
|
|
|
void ofApp::dragEvent(ofDragInfo dragInfo){
|
2011-01-27 15:20:23 -05:00
|
|
|
|
2013-04-04 12:58:38 +02:00
|
|
|
}
|