Export to vector/PDF/high res

does anyone know anything about expoting an openGL world so that everything is vector? or how to get very high res exports?



There is actually an ofxVectorGraphics addon coming for 005.

It basically provides you with mirror functions of ofGraphics - lines, curves, polygons etc. But you can then save what you see on the screen to high quality vector graphics in the form of a postscript file.

This is a different approach than a lot of openGL Postscript libraries which grab the vertexes directly from the graphics card, but end up having quite messy vector output (too many points - all the tessellated triangles of a poly instead of a clean outline, no curves ).

The plus side of grabbing from the graphics card is 3D support but you can do 3D with ofxVectorGraphics with a neat openGL trick. Let me know if you want me to put up a quick example of 3D to 2D Postscript - with ofxVectorGraphics.

Mantissa has already started using ofxVectorGraphics for some experiments: http://flickr.com/photos/mantissa/2356170707/

Anyway if you are interested you can download the addon
It comes with an example app that shows how you should use it.

As long as the ofxVectorGraphics/src/ ofxVectorGraphics/lib/ folders are included in your project you should be able to use it in your code by

#include “ofxVectorGraphics.h”


Hope that helps!

Ohh man Theo you are killing it. Thanks can’t wait to try this out.


it works great. Question about opacity, is there a way to have alpha shapes?

I was looking for that too.
But it looks like Transparency is not properly supported in postscript, therefore also not in ofxVectorGraphics. http://en.wikipedia.org/wiki/Transparency-(graphic#Transparency_in_PostScript

If you are curious about CreEps the library ofxVectorGraphics wraps you can check out the documentation here


it looks like this library has blending options:


gl2ps is one of the “feedback buffer” type output-ers, that outputs triangles. It can do pdf and svg in addition to ps, and I guess in those you can have transparency. I’ve used it before with good results, although theo’s library produces remarkably cleaner to use output, since everything gl2ps gives you is a triangle in the end. you can’t see the difference when you print, but in manipulating it’s a big pain.

take care!

Cairo would be nice too. Heard a lot of good things about it.


(playing with it right now)


I’ve got some code for high-res openGL screenshots if anyone is interested…

The only downside is that the openGL window has to be square shaped, although this could probably eventually be solved.
This method produces bitmaps so file sizes can get pretty huge e.g. 12000x12000 pixels = 410 MB , therefore a postscript equivalent would be pretty useful. However the bitmap method does capture pixel level fx, such as shaders and the like.

grimus, I would be very interested in seeing your code for that

@ grimus

Out of curiosity, why does a high-res screen grab have to be square? I can’t think of any OpenGL limitation off-hand that would require this, so I’d be interested to find out.

I’ve used this in the past to make high resolution screenshots:

It makes large bitmap images though, not vector. Also you’ll need to make some slight modifications to your code.


Wow, I wish I’d come across the TR library before…it looks pretty comprehensive.

I’ll post my image saving code shortly once I have some spare time…it needs cleaning up and could benefit from some OF integration.

A high-res openGL screenshot doesn’t have to be square…but the very simple algorithm I use does. I subdivide the image into squares and then call glFrustum to change the perspective and enlarge the subsections. Dealing with non-square sections of the image result (in this case) in headache inducing frustum parameters. See the Game Programming Gems II article by Alex Vlachos and Evan Hart
for more info on this.


i’ve been working on a separate implementation akin to the TR library that’ll work as an add-on for oF. i’m planning be using it to make a series of large prints. it uses glfrustrum() to zoom into sections of the opengl context, copying the pixels, and saves the entire output as a png file.

here’s what i’ve got so far:


let me know if you run into any problems …


Excellent, thanks Jeremy.
haven’t tried it yet but at a glance that does the job nicely.
Are you going to bundle that as an extension? It would be good to strip the image saving code out of the testApp.ccp file to make it more generic…

[quote author=“stefanix”]Cairo would be nice too. Heard a lot of good things about it.


(playing with it right now)


Wow - all this stuff looks awesome - Stefan did you manage to get Cairo hooked up?
I tried running it in xcode with OF but it was a bit overwhelming.


to zach:

did you get gl2ps to work within of? I am currently trying but it does not really seem to do anything.

Solved after finding this thread:

Another question about gl2ps. Maybe someone has a solution for that. I want to render alot of shapes that are overlapping. gl2ps outputs an .eps file which alot of triangles that are put in one group so its kind of hard to select only one of the shapes(since they are overlapping). Is there a way to group each shape seperately so you can easily edit the whole composition within illustrator or any other vector software?