libgdx Shaperenderer line .. How to draw line with a specific width

落爺英雄遲暮 提交于 2019-12-10 09:34:05

问题


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


回答1:


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.




回答2:


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




回答3:


Use this

shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
instead of shapeRenderer.begin(ShapeType.Line);


来源:https://stackoverflow.com/questions/19023913/libgdx-shaperenderer-line-how-to-draw-line-with-a-specific-width

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!