简体   繁体   English

ByteBuffer.allocateDirect()和glGenBuffers()之间的区别

[英]Difference between ByteBuffer.allocateDirect() and glGenBuffers()

What is difference between ByteBuffer.allocateDirect() and glGenBuffers() ? ByteBuffer.allocateDirect()glGenBuffers()什么区别? Why we use on android ByteBuffer.allocateDirect() instead of glGenBuffers() like in classic OpenGL? 为什么像经典OpenGL中那样在android ByteBuffer.allocateDirect()而不是glGenBuffers()

But why in every basic OpenGL Tutorial for rendering triangle is used OpenGL object and in every Android OpenGL ES tutorial for rendering triangle is used java object instead of OpenGL object? 但是,为什么在每个用于渲染三角形的基本OpenGL教程中都使用OpenGL对象,而在每个用于渲染三角形的Android OpenGL ES教程中又都使用java对象而不是OpenGL对象?

Because they can. 因为他们可以。

ByteBuffer represents a CPU memory allocation. ByteBuffer表示CPU内存分配。 An OpenGL buffer object represents a GPU -accessible memory allocation. OpenGL缓冲区对象表示GPU可访问的内存分配。

OpenGL ES 2.0 allows users to specify vertex data from either CPU memory or buffer objects. OpenGL ES 2.0允许用户从CPU内存或缓冲区对象指定顶点数据。 Desktop core OpenGL removed this ability since 2009. So modern desktop OpenGL tutorials use buffer objects for vertex data. 自2009年以来,桌面核心OpenGL 取消了此功能。因此,现代桌面OpenGL教程使用缓冲区对象存储顶点数据。

Note that ES 3.0 explicitly says that "client-side vertex arrays": 请注意,ES 3.0明确表示“客户端顶点数组”:

are present to maintain backward compatibility with OpenGL ES 2.0, but their use in not recommended as it is likely for these features to be removed in a future version. 保留了与OpenGL ES 2.0的向后兼容性,但是不建议使用它们,因为将来的版本中很可能会删除这些功能。

They haven't been removed yet. 它们尚未被删除。 But they do interfere with a number of features. 但是它们确实干扰了许多功能。 For example, they make gl_VertexID undefined. 例如,它们使gl_VertexID不确定。

So you should never use ByteBuffer directly for vertex arrays. 因此,永远不要将ByteBuffer直接用于顶点数组。 And you should avoid learning materials that do so, as they may teach you other bad practices. 而且,您应该避免学习这样做的材料,因为它们可能会教给您其他不良做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ByteBuffer.allocateDirect()和MappedByteBuffer.load()之间的区别 - Difference between ByteBuffer.allocateDirect() and MappedByteBuffer.load() GSON 和 ByteBuffer.allocateDirect - GSON and ByteBuffer.allocateDirect `ByteBuffer.allocateDirect`和Xmx - `ByteBuffer.allocateDirect` and Xmx 为什么ByteBuffer.allocate()和ByteBuffer.allocateDirect()之间的奇怪性能曲线差异 - Why the odd performance curve differential between ByteBuffer.allocate() and ByteBuffer.allocateDirect() ByteBuffer.allocate()与ByteBuffer.allocateDirect() - ByteBuffer.allocate() vs. ByteBuffer.allocateDirect() JAVA NIO Bytebuffer.allocateDirect()在int上的大小限制 - JAVA NIO Bytebuffer.allocateDirect() size limit over the int 为什么在ByteBuffer.allocateDirect(10).array()上获得UnsupportedOperationException - Why get UnsupportedOperationException on ByteBuffer.allocateDirect(10).array() ByteBuffer.allocateDirect(size)在Android 2.2模拟器中未创建后备byte [] - ByteBuffer.allocateDirect(size) is not creating backing byte[] in Android 2.2 emulator ByteBuffer.allocateDirect()。asFloatBuffer()与BufferUtils.createFloatBuffer() - ByteBuffer.allocateDirect().asFloatBuffer() vs BufferUtils.createFloatBuffer() Android,OpenGL ES 2.0-为什么要为ByteBuffer.allocateDirect调用的每个浮点数设置4个字节? - Android, OpenGL ES 2.0 - Why do you set 4 bytes per float for the ByteBuffer.allocateDirect call?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM