Libgdx gl10.glLineWidth()

前端 未结 2 1005
小蘑菇
小蘑菇 2020-12-03 18:59

I have this line: Gdx.gl10.glLineWidth(width); Now, I do intend to draw a pretty thick line, and, unfortunately when I type in small values like 1 or 5 the line is obviously

2条回答
  •  有刺的猬
    2020-12-03 19:44

    In Libgdx the Gdx.gl10 object is the wrapper for the OpenGL 1.x API. So, the calls there are all (basically) calls into OpenGL ES (on Android) or regular OpenGL (on the desktop). Sometimes the Java layer makes changes to the API, but generally its a pretty straightforward mapping. (On the Desktop, Libgdx tries to emulate the ES variant so the API presented contains only ES-relevant APIs.)

    The line-drawing support in OpenGL ES is one place where ES changes from regular OpenGL. Both have limitations on supported line width, though in regular OpenGL the limitations seem to apply only to anti-aliased lines.

    Regular OpenGL

    http://www.opengl.org/sdk/docs/man/xhtml/glLineWidth.xml

    There is a range of supported line widths. Only width 1 is guaranteed to be supported; others depend on the implementation. To query the range of supported widths, call glGet with argument GL_ALIASED_LINE_WIDTH_RANGE.

    OpenGL ES

    http://www.khronos.org/opengles/sdk/docs/man/xhtml/glLineWidth.xml

    There is a range of supported line widths. Only width 1 is guaranteed to be supported; others depend on the implementation. To query the range of supported widths, call glGet with argument GL_ALIASED_LINE_WIDTH_RANGE.

    To query the limits in Libgdx, use something like this:

    int[] results = new int[1];
    Gdx.gl10.glGetIntegerv(GL20.GL_ALIASED_LINE_WIDTH_RANGE, results, 0); 
    

    The upshot of all of this though, is that because line drawing (other than width 1.0) on OpenGL ES has different run-time limitations on different platforms, you probably should use a different scheme (like rectangles) to draw fat lines.

提交回复
热议问题