libgdx Shaperenderer line .. 如何绘制具有特定宽度的线 [英] libgdx Shaperenderer line .. How to draw line with a specific width

查看:26
本文介绍了libgdx Shaperenderer line .. 如何绘制具有特定宽度的线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 libgdx 形状渲染器绘制一条特定宽度的线.我关注了这个 链接

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

问题是如果我指定更多的线宽,即超过 9,它不会显示增加的宽度.超过 9 时,我指定 20 或 100 像素,结果与 9 相同

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();

谢谢沙克尔

推荐答案

查询支持的宽度范围和大小之间的差异范围内支持的宽度,使用参数调用 glGetGL_ALIASED_LINE_WIDTH_RANGE、GL_SMOOTH_LINE_WIDTH_RANGE 和GL_SMOOTH_LINE_WIDTH_GRANULARITY.

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.

参考

为了避免特定于设备的行为,我使用了四边形.从一个小纹理中绘制一个 1x1 的正方形,然后定位、缩放(取决于您要绘制的线条的宽度和高度)、颜色和旋转它.

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.

这篇关于libgdx Shaperenderer line .. 如何绘制具有特定宽度的线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆