【问题标题】:Why Libgdx Gdx.gl10.glLineWidth(width); does not react to change projection properities为什么选择 Libgdx Gdx.gl 10.Line Width(width);不会对更改投影属性做出反应
【发布时间】:2012-09-10 09:56:29
【问题描述】:

我有典型的带有 render() 函数的 Libgdx 类。

在 render() 函数中我有 ShapeRenderer 批处理:

Gdx.gl10.glLineWidth(width);
renderer.begin(ShapeType.Line);
renderer.setColor(25,0, 0, alpha);
renderer.line(point_x1, point_y1, point_x2, point_y2);
renderer.end(); 

在这个函数中我也有:

        camera.update();
        renderer.setProjectionMatrix(camera.combined);

当投影属性改变时,线点被正确转换,但线宽仍然相同

有没有办法根据投影宽度和高度来改变线宽??

问候

【问题讨论】:

    标签: java android opengl-es libgdx


    【解决方案1】:

    线宽以像素为单位,不受任何投影变换的影响。因此,没有简单的方法可以使线宽依赖于当前的投影变换,而且您无法用真正的二维几何体(即旋转的矩形或类似的东西)替换您的线。

    【讨论】:

    • 感谢您的回答。我的意思是你说的。所以也许你知道另一种在 open gl es 中通过控制线宽来画线的方法?
    【解决方案2】:

    您没有指定使用的相机类型,但如果是OrthographicCamera,您可以使用zoom 根据相机的缩放系数修改线宽:

    例如,当您在未放大/缩小时有 1 像素宽度的线时,您可以使用:

    OrthographicCamera camera = ...
    int lineWidth = 1; // pixels
    
    Gdx.gl10.glLineWidth(lineWidth / camera.zoom);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-05
      • 2013-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 2022-10-08
      • 2014-12-29
      相关资源
      最近更新 更多