Permalink
Browse files

ofCairoRenderer: set style every frame, cairo doesn't preserve style …

…every page. Closes #629
  • Loading branch information...
arturoc committed Jul 8, 2011
1 parent 6c662b1 commit a0734cd78be8ab2aabd9634bcbee1fcfce6f2911
@@ -20,6 +20,11 @@ ofGLRenderer::ofGLRenderer(bool useShapeColor){
currentFbo = NULL;
}
+//----------------------------------------------------------
+void ofGLRenderer::update(){
+
+}
+
//----------------------------------------------------------
void ofGLRenderer::draw(ofMesh & vertexData){
if(vertexData.getNumVertices()){
@@ -16,6 +16,8 @@ class ofGLRenderer: public ofBaseRenderer{
void setCurrentFBO(ofFbo * fbo);
+ void update();
+
void draw(ofMesh & vertexData);
void draw(ofMesh & vertexData, ofPolyRenderMode renderType);
void draw(ofPolyline & poly);
@@ -68,6 +68,21 @@ void ofCairoRenderer::close(){
}
}
+void ofCairoRenderer::update(){
+ cairo_surface_flush(surface);
+ if(page==0 || !multiPage){
+ page=1;
+ }else{
+ page++;
+ if(bClearBg()){
+ cairo_show_page(cr);
+ }else{
+ cairo_copy_page(cr);
+ }
+ }
+ ofSetStyle(ofGetStyle());
+}
+
void ofCairoRenderer::draw(ofPath & shape){
cairo_new_path(cr);
vector<ofSubPath> & paths = shape.getSubPaths();
@@ -611,18 +626,9 @@ void ofCairoRenderer::viewport(float x, float y, float width, float height, bool
y = ofGetWindowHeight() - (y + height);
}
- cairo_surface_flush(surface);
+
viewportRect.set(x, y, width, height);
- if(page==0 || !multiPage){
- page=1;
- }else{
- page++;
- if(bClearBg()){
- cairo_show_page(cr);
- }else{
- cairo_copy_page(cr);
- }
- }
+
cairo_reset_clip(cr);
cairo_new_path(cr);
cairo_move_to(cr,viewportRect.x,viewportRect.y);
@@ -26,6 +26,8 @@ class ofCairoRenderer: public ofBaseRenderer{
void setup(string filename, Type type=ofCairoRenderer::PDF, bool multiPage=true, bool b3D=false, ofRectangle viewport = ofRectangle(0,0,0,0));
void close();
+ void update();
+
void draw(ofPath & shape);
void draw(ofSubPath & path);
void draw(ofPolyline & poly);
@@ -18,6 +18,14 @@ class ofRendererCollection: public ofBaseRenderer{
}
bool rendersPathPrimitives(){return true;}
+
+ void update(){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->update();
+ }
+ }
+
+
void draw(ofPolyline & poly){
for(int i=0;i<(int)renderers.size();i++){
renderers[i]->draw(poly);
@@ -273,6 +273,8 @@ class ofBaseRenderer{
virtual string getType()=0;
+ virtual void update()=0;
+
virtual void draw(ofPolyline & poly)=0;
virtual void draw(ofPath & shape)=0;
virtual void draw(ofMesh & vertexData)=0;

0 comments on commit a0734cd

Please sign in to comment.