转换顶点缓冲区的顶点数组 [英] convert Vertex buffer to Vertex array

查看:172
本文介绍了转换顶点缓冲区的顶点数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的OpenGL的计划,我必须计算边界框。我做了code做,但我不能让顶点坐标位置,从顶点缓冲区。有人可以给我解释一下一个简单的方法来从顶点缓冲区中的数据? 我使用的Java针对Android和OpenGL ES

I'm working on OpenGL program and I must calculate a bounding box . I made the code to do it but I can't get vertexes coordinations from vertex buffer . Someone can explain me an easy way to get data from vertex buffer? I'm using Java for android and OpenGL es

推荐答案

如果您使用的OpenGL ES 3.0或更高版本,可以使用 glMapBufferRange()来直接访问缓存数据。请参阅手册页有关功能的详细信息,并在<一个href="https://developer.android.com/reference/android/opengl/GLES30.html#glMapBufferRange(int,%20int,%20int,%20int)"相对=nofollow>有关Java绑定在Android的细节GLES30文档。

If you use OpenGL ES 3.0 or later, you can use glMapBufferRange() to access buffer data directly. See the man page for details about the functionality, and the GLES30 documentation for details about the Java bindings in Android.

我不认为有任何合理的方式来做到这一点ES 2.0。我能想到的绝对是可怕的方式,但我会心疼,带领你的那个方向。那么,对于完整性,但请不这样做:您可以渲染的东西,最终留下的顶点数据的渲染目标,并与 glReadPixels读回()

I don't think there's any reasonable way to do this in ES 2.0. I could think of absolutely awful ways, but I would feel bad to steer you in that direction. Well, for completeness, but please do not do this: You could render something that ends up leaving the vertex data in a render target, and read it back with glReadPixels().

如果你需要频繁访问的顶点数据在自己的code,它很可能会工作得更好,如果你把它的一个副本。你已经有了,当你调用数据 glBufferData()。如果你现在正在 glBufferData()通话后把它扔了,只是保持它周围,并使用它时,你需要访问顶点数据。

If you need frequent access to the vertex data in your own code, it will most likely work better if you keep a copy of it. You already had the data when you called glBufferData(). If you're currently throwing it away after the glBufferData() call, simply keep it around, and use it whenever you need access to vertex data.

这篇关于转换顶点缓冲区的顶点数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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