Permalink
Browse files

simplification by using ofFbo.readToPixels(...)

  • Loading branch information...
1 parent d9e9eb7 commit 5cf6f256a7dfeded8b3156a8cf5d58a08e4eeda6 @fx-lange committed Jan 10, 2012
Showing with 6 additions and 18 deletions.
  1. +1 −10 src/ofxVoronoiGL.cpp
  2. +5 −8 src/ofxVoronoiGL.h
View
@@ -6,7 +6,6 @@ void ofxVoronoiGL::setup(int _width, int _height, float _error){
error = _error;
fbo.allocate(width,height,GL_RGB,1);
- fboImage.allocate(width,height,OF_IMAGE_COLOR);
R = sqrt(width*width + height*height);
//TODO musst be calculate by 2cos⁽⁻¹⁾(R-E / R)
@@ -25,16 +24,8 @@ void ofxVoronoiGL::update(){
createVoronoi();
cam.end();
fbo.end();
-
- //preDraw to be able to use opencv methods
- //TODO performance bottleneck - try readPixels in an extra function
- ofSetColor(255,255,255);
- fbo.draw(0,0);
- fbo.getTextureReference();
- fboImage.grabScreen(0,0,width,height);
- ofFill();
- ofRect(0,0,width,height);
}
+
void ofxVoronoiGL::setPoint(int x,int y){
points.push_back(ofxVoronoiCell(x,y,SPTAColor()));
}
View
@@ -51,12 +51,9 @@ class ofxVoronoiGL{
fbo.draw(x,y);
}
- void drawFBOImg(int x,int y){
- fboImage.draw(x,y);
- }
-
- unsigned char * getFBOPixels(){//TODO use fbo.readPixels... => refactor update
- return fboImage.getPixels();
+ unsigned char * getFBOPixels(){
+ fbo.readToPixels(pixels);
+ return pixels.getPixels();
}
void setPoint(int x,int y);
@@ -68,11 +65,11 @@ class ofxVoronoiGL{
}
float alpha;
- bool drawPoly,perFeatureV,skeleton,drawCenters;
+ bool drawPoly,perFeatureV,skeleton,drawCenters;//TODO check which is still used - rename!
protected:
ofFbo fbo;
- ofImage fboImage;
+ ofPixels pixels;
ofEasyCam cam;
std::vector<ofxVoronoiCell> points;

0 comments on commit 5cf6f25

Please sign in to comment.