如何计算android中Opengl对象的宽度
我正在解决一个问题,我需要绘制进度条并需要计算进度条的长度以便在其上显示进度。我正在使用 OpenGL 来绘制进度条纹理。
有人可以告诉我如何计算绘图顶点缓冲区使用的总长度吗?请指导。
我的顶点缓冲区如下。
private float vertices[] = {
-1.5f, -0.20f, 0.0f, // V1 - bottom left
-1.5f, 0.20f, 0.0f, // V2 - top left
1.5f, -0.20f, 0.0f, // V3 - bottom right
1.5f, 0.20f, 0.0f // V4 - top right
};
在这种情况下,我的纹理加载到该矩阵内。您能否解释一下如何在代码中使用计算来获取此纹理的宽度。我在这里想要实现的是操作进度条的顶点缓冲区,我可以在进度条上根据数据的当前值显示进度。
I am working on a problem where I need to draw a progressbar and need to calculate the length of the bar so as to display the progress on it. I am using OpenGL to draw my progressbar texture.
Can someone tell me how do I calculate the total length used by the drawing vertex buffer? Please guide.
I have my vertex buffer as following.
private float vertices[] = {
-1.5f, -0.20f, 0.0f, // V1 - bottom left
-1.5f, 0.20f, 0.0f, // V2 - top left
1.5f, -0.20f, 0.0f, // V3 - bottom right
1.5f, 0.20f, 0.0f // V4 - top right
};
In this case my texture loads inside this matrix. Can you explain how can I use calulations in my code to get width of this texture. What i'm trying to achieve here is to manipulate the vertex buffer for a progress bar on which I can show progress depending upon current value of data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将数据放入缓冲区中,因此您应该知道其中有什么。 OpenGL 没有“对象”或“宽度”或任何此类性质的概念。它只知道你向它发送了一些三角形来绘制。
如果您想知道输出三角形的“宽度”,那么您必须自己在 CPU 上进行转换。不要从缓冲区对象中读回它;只需手动保留一份副本即可。
You put the data in the buffer, so you should know what's in it. OpenGL has no concept of "object" or "width" or anything of that nature. All it knows is that you sent it some triangles to draw.
If you want to know the "width" of the output triangles, then you're going to have to do the transformations yourself on the CPU. Don't read it back from the buffer object; just keep a copy manually.