Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "testApp.h"
- #define stageWidth 1920
- bool linePos[stageWidth];
- double beltPos = 0;
- unsigned long lastUpdateTime;
- ofFbo mainFBO;
- int fboHeight = 700;
- bool bShowLines = true;
- float cnt = 0;
- int cstep;
- unsigned long dur = 0;
- int dstep;
- unsigned long ddur = 0;
- //--------------------------------------------------------------
- void testApp::setup(){
- ofSetVerticalSync(true);
- //ofSetFrameRate(30);
- mainFBO.allocate(stageWidth,fboHeight,GL_RGBA);
- ofBackground(255, 255, 0);
- // ofSetBackgroundAuto(false);
- }
- //--------------------------------------------------------------
- void testApp::update(){
- // unsigned long updateDT = ofGetElapsedTimeMicros() - lastUpdateTime;
- // lastUpdateTime = ofGetElapsedTimeMicros();
- // beltPos = beltPos + (beltSpeed * updateDT);
- // beltPos = (ofGetElapsedTimeMicros()/6000) % stageWidth;
- //1
- cout<<"upat";
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- beltPos += ofGetLastFrameTime()*200;
- if(beltPos > stageWidth) beltPos = 0;
- if(bShowLines){
- if(beltPos == 0){
- for(int i=0; i<stageWidth; i++){
- linePos[i] = false;
- }
- }
- linePos[int(beltPos)] = true;
- }
- //2
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- mainFBO.begin();
- //3
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- ofClear(255, 255, 255);
- //4
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- // ofFill();
- // ofSetColor(255);
- // ofRect(0, 0, stageWidth, fboHeight);
- if(bShowLines){
- ofSetColor(0, 0, 255);
- for(int i=0; i<stageWidth; i++){
- if(linePos[i] == true) ofLine(i,350,i,fboHeight);
- }
- }
- //5
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- mainFBO.end();
- //6
- cout<<" "<<ofGetElapsedTimeMicros() - dur<<"\t";
- dur = ofGetElapsedTimeMicros();
- cstep++;
- cnt+= 3.3;
- if(cnt > stageWidth) cnt = 0;
- cstep=0;
- //cout<<endl;
- }
- //--------------------------------------------------------------
- void testApp::draw(){
- //1
- cout<<"draw";
- cout<<" "<<ofGetElapsedTimeMicros() - ddur<<"\t";
- ddur = ofGetElapsedTimeMicros();
- dstep++;
- ofSetColor(255);
- mainFBO.draw(0,200,stageWidth,400);
- //2
- cout<<" "<<ofGetElapsedTimeMicros() - ddur<<"\t";
- ddur = ofGetElapsedTimeMicros();
- dstep++;
- if(bShowLines){
- ofSetColor(255, 0, 0);
- for(int i=0; i<stageWidth; i++){
- if(linePos[i] == true) ofLine(i,0,i,250);
- }
- }
- //3
- cout<<" "<<ofGetElapsedTimeMicros() - ddur<<"\t";
- ddur = ofGetElapsedTimeMicros();
- dstep++;
- ofSetColor(255, 0, 0);
- ofFill();
- //ofCircle(beltPos, 300, 50);
- ofRect(beltPos, 300, 50,50);
- //4
- cout<<" "<<ofGetElapsedTimeMicros() - ddur<<"\t";
- ddur = ofGetElapsedTimeMicros();
- dstep++;
- ofSetColor(0, 0, 255);
- // ofCircle(cnt, 350, 30);
- ofRect(cnt, 300, 30,30);
- //4
- cout<<" "<<ofGetElapsedTimeMicros() - ddur<<"\t";
- ddur = ofGetElapsedTimeMicros();
- dstep++;
- cout<<endl;
- dstep = 0;
- //ofCircle(mouseX,mouseY, 20, 20);
- }
- //--------------------------------------------------------------
- void testApp::keyPressed(int key){
- }
- //--------------------------------------------------------------
- void testApp::keyReleased(int key){
- if(key == 'f') ofToggleFullscreen();
- if(key == ' ') bShowLines =!bShowLines;
- }
- //--------------------------------------------------------------
- void testApp::mouseMoved(int x, int y){
- }
- //--------------------------------------------------------------
- void testApp::mouseDragged(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void testApp::mousePressed(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void testApp::mouseReleased(int x, int y, int button){
- }
- //--------------------------------------------------------------
- void testApp::windowResized(int w, int h){
- }
- //--------------------------------------------------------------
- void testApp::gotMessage(ofMessage msg){
- }
- //--------------------------------------------------------------
- void testApp::dragEvent(ofDragInfo dragInfo){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement