Cannot set line thickness

Seems pretty simple, but I can’t find the answer.

The easiest way to draw a plain line seems to be with ofDrawLine and I tought that ofSetLineWidth would change the line thickness but this code:

ofSetLineWidth(300);
ofDrawLine(10, 10, 10, 200);

gives me the same result as not setting ofSetLineWidth at all… so… what am I missing?

Hey @Ignis – the line width is capped at 8px (at least that what it seems like to me), and I’m sure it’s got something to do with how OpenGL works - and I’m sure someone else here can give a far better answer. That being said:

If drawing lines and you need big stroke sizes, I’d suggest looking into 2 things: (besides just drawing a rectangle :wink: )

ofxFatLines - a powerful addon based on VaseRenderer ( http://tyt2y3.github.io/vaser-web/ ) which lets you draw lines with smooth varied colors and thicknesses.
https://github.com/roymacdonald/ofxFatLines

ofxShivaVG - an alternative renderer designed for smooth 2D vector graphics, though I’m not sure if it is working with 0.9.0+

cheers!

As I’m working on a school project I can’t add anything outside vanilla OpenFrameworks… I guess I’ll have to deal with rectangles and the ofPath object for tilted lines?

line width is definitely capped by the graphics card, it usually works until 10 pixels or so but it varies.

you can do thick lines with rectangles or triangles – here’s an example that takes a polyline and adds some thickness to it, drawing it in a mesh made out of a triangle strip:

1 Like

Oh… you’re totally right that I can use triangles for pretty much anything. Ill keep a copy of the code you sent me as well. Ty for the responses :slightly_smiling: