DrawNode line width don't work

DrawNode line width don't work
0.0 0


Cocos2dx, 3-13.

Why does the following code dosen’t change line width at all?

auto d = DrawNode::create(50);
d->drawCircle(Vec2(0, 0), 50, 360, 360, false, Color4F::BLUE);
d->drawLine(Vec2(0, 0), Vec2(100, 100), Color4F::BLUE);
addChild(d, 20);

How can I ensure proper line width?

Final topic about Anti-Aliasing disease

I had this problem last week, and I think there is a maximum line width. Apparently there is an OpenGL command to get the maximum width, although the quick attempt I had with it didn’t seem to work. (It just returns 1 for me.) Here’s a link just in case it helps: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glLineWidth.xhtml

I just ended up create using a sprite and altering its polygons instead of using lines.


I ended up drawing lines by triangles (like here ).
Can you explain a little bit more about your approach? What sprite do you use and what do you do with it?


I just remembered that DrawNode has a drawPolygon, so you could use that and some math to draw your circle and line with the width of your choice. Of course, if you’re trying to use this for the curved lines in your link, then this won’t work because you can’t set the opacity of individual vertices. It does have the benefit of just specifying the vertices, though, rather than each and every triangle.

The Sprite technique I used is detailed here: http://fedoraus.livejournal.com/25026.html. Basically, you take a Sprite and alter its vertices and edges to create whatever shape you want. You still have to manually calculate each triangle, but one benefit is that the resulting shape is textured. This means you could create a texture with faded edges instead of giving vertices an opacity of 0, which would give you more control over the faded area.

In your link, you ask what is the benefit of using the engine if you need to draw the triangles yourself. Not too sure, but some benefits are probably being able to easily move, scale and rotate your object, automatically moving with the parent, ability to run actions on it and easily handle the draw order. If you don’t need to do any of that, then I’m not sure if there is a benefit. (I have never drawn shapes with OpenGL outside of cocos before.)