How do I draw lines of a reasonable thickness on a very large canvas given OpenGL constraints?

On my computer OpenGL and my graphics card restricts line width to about 10px. This is usually fine for a drawing that fits within 1000x1000px. However I am required to prepare a file that is 8000x8000px so a line of 10px is not scaled appropriately.

How can I either scale up a small drawing or how can I draw lines of a more appropriate thickness?


You can check out ofxFatlines, which can build you a mesh at a desired thickness from an ofPolyline.

i recently found ofxNanoVG

it is a wrapper for the nanoVG library and it seems to do a really good job in drawing antialiased 2d vector graphics.

PS: in the example remember to change

assert(canvas.loadFont("Roboto-Regular.ttf", "sans"));


canvas.loadFont("Roboto-Regular.ttf", "sans");

if you are building in release mode.

I wrote that addon. It is quite outdated, although it should work still. I stopped developing it as ofxNanoVG and ofxShivaVG made a much better job.

Thanks all, will check out ofxShivaVG as a top choice with fallback to ofxNanoVG

Or you may draw solid filled rectangles instead of lines. I use always this workaround and for me it works fine.

I use the rectangle approach. if you wanted to draw a line from ofPoint a to ofPoint b with thickness 40, it would look like this (untested code, just off the top of my head):

ofPoint diff = (b - a).getNormalized();
diff.rotate(90, ofPoint(0,0,1));
ofMesh m;
m.addVertex(a + diff * 20.0);
m.addVertex(a - diff * 20.0);
m.addVertex(b + diff * 20.0);
m.addVertex(b - diff * 20.0);
1 Like