Libgdx gl10.glLineWidth() [英] Libgdx gl10.glLineWidth()

查看:126
本文介绍了Libgdx gl10.glLineWidth()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这一行:
Gdx.gl10.glLineWidth(width);
现在,我打算绘制一条相当粗的线条,不幸的是,当我输入1或5这样的小值时,线条显然很小。但是,一旦我超过像10这样的东西,它就不再变大了。我在这些情况下传递直接值,因此,我认为GL有限制或者某种东西......我会是正确的吗?这是我的代码:

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 small. But once I surpass soemthing like 10, it no longer gets larger. I am passing in direct values in these instances, and so, I am under the impression that GL has a limit or something.... Would I be correct? Here's my code:

Gdx.gl.glClearColor(0,0,0,1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(cam.combined);
    batch.begin();
    batch.draw(bg,0,0,WIDTH,HEIGHT);
    for(Spell a : spells){
        a.draw(batch);
    }
    lc.draw(batch);
    batch.end();
    //((ppux+ppuy)/2f)*4
    Gdx.gl10.glLineWidth(50);//average and then say 1/4 a unit)
    renderer.setProjectionMatrix(cam.combined);
    renderer.begin(ShapeType.Line);
    lp.drawLines(renderer);
    renderer.end();
    batch.begin();
    lp.draw(batch);
    batch.end();

lp.drawLines(渲染器)调用以下内容(我只调用set color和draw line):

lp.drawLines(renderer) calls the following(I just call set color, and draw line):

renderer.setColor(1,1,1,1);
    Elem a = elems.get(spellcombo.get(0));
    Vector2 last = new Vector2(a.x(),a.y());
    for(int i = 1; i < spellcombo.size(); i++){
        a = elems.get(spellcombo.get(i));
        Vector2 cur = new Vector2(a.x(),a.y());
        renderer.line(last.x, last.y, cur.x, cur.y);
        last = cur;
    }
    renderer.line(last.x,last.y,mx,my);
    Gdx.gl.glEnable(GL10.GL_BLEND);
    Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    renderer.setColor(1, 0, 0, .2f);
    for(Elem e : elems){
        int id = elems.indexOf(e);
        if(ComboManager.validSpell(spellcombo,id))
            renderer.line(last.x,last.y,e.x(),e.y());
    }

屏幕截图:

图像与glLineWidth()设置到1

图像使用glLineWidth()设置到5

图像使用glLineWidth()设置到10

图像使用glLineWidth()设置到20

图像使用glLineWidth()设置到200

Screenshots:
Image with glLineWidth() set to 1 Image with glLineWidth() set to 5 Image with glLineWidth() set to 10 Image with glLineWidth() set to 20 Image with glLineWidth() set to 200

我真的不知道如何解决,谷歌并不特别有帮助。
谢谢!

I don't really know how to fix, and google wasn't particularily helpfull. Thanks!

推荐答案

在Libgdx中 Gdx.gl10 object是OpenGL 1.x API的包装器。因此,调用所有(基本上)调用OpenGL ES(在Android上)或常规OpenGL(在桌面上)。有时Java层会对API进行更改,但通常它是一个非常简单的映射。 (在桌面上,Libgdx尝试模拟ES变体,因此所提供的API仅包含与ES相关的API。)

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.)

OpenGL ES中的线条绘制支持是一个地方ES从常规OpenGL变化。两者都支持线宽限制,但在常规OpenGL中,限制似乎仅适用于消除锯齿线。

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.

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


支持的行宽范围。只支持宽度1
;其他人依赖于实施。要查询
支持的宽度范围,请使用参数
GL_ALIASED_LINE_WIDTH_RANGE调用glGet。

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


有一个范围支持的线宽。只支持宽度1
;其他人依赖于实施。要查询
支持的宽度范围,请使用参数
GL_ALIASED_LINE_WIDTH_RANGE调用glGet。

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.

查询限制Libgdx,使用类似这样的东西:

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

所有这一切的结果是因为OpenGL上的线条图(宽度1.0除外) ES在不同平台上有不同的运行时限制,您可能应该使用不同的方案(如矩形)来绘制胖线。

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.

这篇关于Libgdx gl10.glLineWidth()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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