Drawing simple lines and changing line width

Hi all,
I am new to Cinder after using Processing for several projects, but am evaluating Cinder to see if it might be a better choice for some new projects. One of the frustrations is that, although there are a few books and online tutorials available, they all seem to be somewhat outdated and so far I have not found a good source that explains how to do simple things in the current version of Cinder and why/how they are different from the techniques shown in the books/tutorials.

For example, in Giovanni Dicanio’s tutorial on Pluralsight, he shows how to draw a simple diagonal line and change the color and linewidth. The draw loop looks something like:

void LinesApp:draw()
    gl::clear( Color( 0, 0, 0) );
    const int w = getWindowWidth();
    const in h = getWindowHeight();

    gl::color ( Color (1, 1, 0) );

    gl::drawLine(vec2(0, 0), vec2(w, h) );


(He uses Vec2f, which I figured out now has to be vec2).

When I run this, I do get a yellow line from upper left to lower right, but the width is unaffected by the lineWidth command. I’ve seen on the forum that gl::lineWidth is now deprecated, but I have not been able to find a simple replacement.

Can someone explain why gl::lineWidth was deprecated and what the way to do it now is?

Many thanks,

Haven’t got time to write a detailed response at the moment but the long story short is there’s many different ways to skin this particular cat depending on your use case. One of the methods in this article may work for you, or for a cinder-centric example, @paul.houx’s sample on his github is excellent too.


gl::lineWidth was deprecated because it was deprecated in OpenGL. Most GPU drivers no longer support it. Instead, you can draw a (rotated) rectangle if you want thick lines. For thick curved lines, you will have to do the math and create a mesh, as explained in the link provided by @lithium. Or this post.


Many thanks for these helpful comments.

A related question: since gl::lineWidth is deprecated, how can you change the stroke width when using gl::drawStrokedCircle? Is there no substitute for gl::lineWidth that restores a convenient way of changing stroke widths on simple geometry?


for circles with variable width, you can take a look at ci::geom::Ring, which helps you to create a mesh of a circle with the desired thickness. There are many more primitives in the ci::geom namespace. See the Geometry sample for more information.