本文介绍了线宽限制在OpenGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个Android应用程序显示使用OpenGL的地理数据(如谷歌地图),它似乎是OpenGL的具有线宽的限制绘制线条时:

I am trying to build an android application for display the geographic data(like google map) with opengl ,and it seems that opengl have a limitation of the line width when drawing lines:

        gl.glLineWidth(10); //or gl.glLineWidth(20);
        ......
        gl.glDrawArrays(GL10.GL_LINES, 0, 2);

这是我得到了什么:

And this is what I got:

看来,这是OpenGL的渲染线的最大宽度。

It seems that this is the max width of a line rendered by opengl.

然而,当我看到了谷歌地图,我发现它可以呈现为这样的道路宽得多行:

However when I see the google map, I found that it can render a much width line for a road like this:

有什么问题?

顺便说一句,我不知道它是理想的在我的应用程序中使用的游戏引擎?

BTW, I wonder if it is desirable to use a game engine in my application?

推荐答案

是的,OpenGL的实现也有线宽的限制。我相信,通过执行不同而不同。有几个选择,但最简单的一种是只画一个矩形就是因为你需要为高,从A点延伸如果你需要一个50点的线宽,例如,你可以得到4个角到B点。通过从A查找矢量B和突出+和矩形 - 在端点沿法线25指向矢量

Yes, OpenGL implementations do have a limitation for line widths. I believe it varies by implementation. There are a few options, but the easiest one is to just draw a rectangle that is as tall as you need and extends from point A to point B. If you need a 50 point line width, for example, you can get the 4 corners of the rectangle by finding the vector from A to B and projecting + and - 25 points along the normal to that vector at the end points.

这篇关于线宽限制在OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:58