Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawNode: setLineWitdh() is no longer working #1411

Closed
aismann opened this issue Nov 1, 2023 · 2 comments
Closed

DrawNode: setLineWitdh() is no longer working #1411

aismann opened this issue Nov 1, 2023 · 2 comments
Labels
Milestone

Comments

@aismann
Copy link
Contributor

aismann commented Nov 1, 2023

Steps to Reproduce:
cpp-tests->31:Node:Draw>GitHub Issue #11942 (axmol #137)"

Wrong: Latest build:
image

Works: Thats a older version
image

@halx99
Copy link
Collaborator

halx99 commented Nov 1, 2023

Not recommand use setLineWith because the render backend opengl & metal have diferrent behavior:

  • GLES2: support glLineWidth
  • GLES3: only support glLineWidth (0~1)
  • Metal: not support lineWidth

@halx99 halx99 closed this as completed Nov 1, 2023
@halx99 halx99 added this to the HelpDesk milestone Nov 1, 2023
@halx99 halx99 added the HelpDesk label Nov 1, 2023
@joprice
Copy link

joprice commented Feb 22, 2024

I hit this as well and found a workaround by taking the drawSolidCircle code and calling drawPolygon instead ofdrawSolidPoly and passing thickness along:

 static void drawCircle(DrawNode &node, const Vec2 &center, float radius, float angle, int segments,
                         float scaleX, float scaleY, const Color4F &color, float thickness) {
    const float coef = 2.0f * (float)M_PI / static_cast<float>(segments);

    Vec2 *vertices = new (std::nothrow) Vec2[segments];
    if (vertices == nullptr)
      return;

    for (unsigned int i = 0; i < segments; i++) {
      float rads = static_cast<float>(i) * coef;
      float j = radius * cosf(rads + angle) * scaleX + center.x;
      float k = radius * sinf(rads + angle) * scaleY + center.y;

      vertices[i].x = j;
      vertices[i].y = k;
    }
    node.drawPolygon(vertices, segments, Color4F(), thickness, color);

    CC_SAFE_DELETE_ARRAY(vertices);
  }

Might be of help to someone, or could perhaps become a new helper if it seems useful enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants