4

I am trying to draw a line of specific width using libgdx shape renderer. I followed this link

The problem is if i specify more line width i.e more than 9 it does not show increased width. More than 9 either i specify 20 or 100 pixels it will have the same result as 9

shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.line(50, 70, 0, 50, 200, 0, Color.BLUE, Color.RED);
    int lineWidth = 20; // pixels
    Gdx.gl10.glLineWidth(lineWidth / camera.zoom);
     shapeRenderer.end();

Thanks Shakeel

Community
  • 1
  • 1
shakeel
  • 1,609
  • 1
  • 14
  • 14
  • See http://stackoverflow.com/questions/16680908/libgdx-gl10-gllinewidth?rq=1 – P.T. Sep 26 '13 at 15:01
  • Thanks P.T yeah the link you mentioned have exactly the same problem. No i am going to use rectangle for drawing thick lines. Thanks again – shakeel Sep 26 '13 at 20:25

4 Answers4

4

To query the range of supported widths and the size difference between supported widths within the range, call glGet with arguments GL_ALIASED_LINE_WIDTH_RANGE, GL_SMOOTH_LINE_WIDTH_RANGE, and GL_SMOOTH_LINE_WIDTH_GRANULARITY.

Reference

To avoid device specific behavior, I use a quad instead. Draw a 1x1 square from a small texture and then position, scale (depending on the width and height of the line you wanted to draw), color, and rotate it.

Community
  • 1
  • 1
Sajal Dutta
  • 18,272
  • 11
  • 52
  • 74
  • 1
    Thanks Sajal Dutta for the reply. yeah you are right i may better use rectangle for thicker or fat lines. I would like to add that width of line may vary for different systems. Better not to use lines if any body is thinking for fat lines. Better use rectangle. Thanks again – shakeel Sep 26 '13 at 20:20
0

You should use ShapaRenderer.rectLine. You can see a more detailed answer here

Community
  • 1
  • 1
0

Use this

shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
instead of shapeRenderer.begin(ShapeType.Line);
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
N N K Teja
  • 197
  • 1
  • 7
0

Replace 10 with line width you want

Gdx.gl.glLineWidth(10 / camera.zoom);

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154