ofxFBOTexture coordinates go all wrong when going FullScreen, please help!

Hi everyone this is my first post in the forums, I’ve just begun using ofx, I’d used processing in the past and decided to try out ofx as it seemed the natural move, so far so good except now Im kinda stucked with what I think must be a simple problem but dont have a clue how to solve. What Im doing is this, Im basically parsing some data and plotting it, the data are the coordinates of multitouch events sent from an iphone i.e. the finger touches, the program simply draws a circle for each touch at its coordinates, this works ok and all, the problem came when I wanted it to also draw fading trails for each touch (I wanted the trails to be left by the path of the touch not the circle, this is done drawing a line from the current and previous touch positions), after reading a bit I found it could be done with an ofxFBOTexture so what the program does in the end is just draw the trails on the fbo, fades them by painting a transparent rectangle over them and then draw the fbo on the screen as if it were the background and then drawing the circles on top. This all works fine, the problem is when I go fullscreen the coordinates of the trails on the fbo seem to be off in a weird way. Here’s my testApp.cpp

  
#include "testApp.h"  
  
void testApp::setup(){  
  my_buffer.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA, 4);  
  my_buffer.begin();  
  ofSetBackgroundAuto(false);  
  ofBackground(255,255,255);  
  my_buffer.end();  
  isfs = false;  
  radius = 20;  
  for(int i = 0; i < 5; i++){  
    ofPoint pt;  
    pt.x = 0;  
    pt.y = 0;  
    pt.z = 0;  
    pts.push_back(pt);  
  }  
}  
  
void testApp::update(){  
  string line;  
  ifstream file("../../../../../../../../../Sites/FinalTouchP5/data/my_pipe");  
  if(file.is_open()){  
    while(file.good()){  
      getline(file, line);  
      cout<<line<<endl;  
      vector <string> sdata = ofSplitString(line, ",");  
      for(int i = 0; i < sdata.size(); i++)  
        data[i] = atoi(sdata[i].c_str());  
    }  
    file.close();  
  }  
  else cout<<"unable to open file"<<endl;  
}  
  
void testApp::draw(){  
  my_buffer.begin();  
  ofEnableAlphaBlending();  
  ofSetColor(255, 255, 255, 10);  
  ofFill();  
  ofRect(0,0,ofGetWidth(), ofGetHeight());  
  ofDisableAlphaBlending();  
  my_buffer.end();  
  my_buffer.draw(0,0, ofGetWidth(), ofGetHeight());  
  //ofBackground(255,255,255);  
  for(int i = 0; i < 10/2; i++){              
    if(data[i*2] != 0 && data[i*2+1] != 0){  
      pts[i].z++;  
      (isfs) ? radius = 40: radius = 20;  
      x = ofMap(data[i*2], 0, 476, 0, ofGetWidth());  
      y = ofMap(data[i*2+1], 0, 290, 0, ofGetHeight());  
      if(pts[i].z == 1){  
        pts[i].x = x;  
        pts[i].y = y;  
      }else{  
        my_buffer.begin();  
        ofSetColor(0,0,0);  
        ofLine(pts[i].x, pts[i].y, x, y);  
        my_buffer.end();  
        pts[i].x = x;  
        pts[i].y = y;  
  
        ofFill();  
        ofSetColor(0,0,0);  
        ofCircle(x,y,radius);  
      }  
    }else{  
      pts[i].z = 0;  
    }  
  }  
}  
  
void testApp::keyPressed(int key){  
  ofToggleFullscreen();  
  isfs = (isfs) ? false : true;  
}  
  
void testApp::keyReleased(int key){}  
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){}  
  

Can anyone help?, I really have no idea how to fix this. Thanx!

Hey there,

Glad to hear you are diving into OF! Looks like you’ve already gotten into some fun stuff =)

It looks like the reason the transparent overlay stops working when you go full screen is that your FBO was allocated with the original ofGetWidth() and ofGetHeight(), so that when you are full screen you are actually stretching the original sized smaller FBO canvas across the now-larger window.

To fix it you would need to call setup() again on your frame buffer whenever the screen size changes.

the windowResized(int w, int h) event may be a good place for this.

hope this helps,

That solved it Thanks a lot!!!