使用客户端顶点数组在没有VBO的opengl 3.1+中进行渲染 [英] Rendering in opengl 3.1+ without VBO using client side vertex array

查看:141
本文介绍了使用客户端顶点数组在没有VBO的opengl 3.1+中进行渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能在不使用VBO的情况下使用顶点数组(客户端渲染不是即时模式)绘制opengl 3.1+核心配置文件.我知道在opengl 3.1+核心配置文件中使用VAO是必不可少的.我想知道是否可以通过使用顶点数组(客户端顶点数组不是即时模式)而无需使用VBO进行绘制.

I want to know if its possible to draw in opengl 3.1+ core profile using vertex arrays ( client side rendering not immediate mode) without using the VBO. I know in opengl 3.1+ core profile use of VAO is essential. I want to know if its possible to draw without using VBO by using vertex arrays (client side vertex array not immediate mode).

PS我正在谈论客户端顶点数组而不是即时模式.我想知道是否可以在没有VBO的情况下创建VAO

PS I am talking about client side vertex array not immediate mode. I want to know if I can create a VAO without VBO

我在opengl spec中的某个地方阅读了此内容.立即模式顶点属性规范中,描述了客户端顶点数组.顶点属性必须存储在一个或多个缓冲区对象中,或者使用glVertexAttrib *()明确指定.由于OpenGL 3.2必须使用顶点数组对象. 所以这意味着我可以使用glVertexAttriPointer这样指定顶点数组数据

I read this somewhere in opengl spec Immediate-mode vertex attribute specification, client-side vertex arrays is depricated. Vertex Attributes must be stored in one or more Buffer Objects, or be specified explicitly using glVertexAttrib*()​. Since OpenGL 3.2 using Vertex Array Objects is mandatory. So does this means I can specify vertex array data using the glVertexAttriPointer like this

glBindVertexArray(m_vaoHandle);

glEnableVertexAttribArray(m_attributes[POSITION_HANDLE]);
glVertexAttribPointer(m_attributes[POSITION_HANDLE], 3, GL_FLOAT, false, 0,vertexArray);

glEnableVertexAttribArray(m_attributes[TEXCOORDINATE_HANDLE]);
glVertexAttribPointer(m_attributes[TEXCOORDINATE_HANDLE], 2, GL_FLOAT, false, 0, textureArray);

glBindVertexArray(0);

这里,vertexArray和textureArray是CPU上的两个数组,而不是VBO.然后在绘制它们时

Here vertexArray and textureArray are two arrays on CPU not VBO. Then while drawing them

glUseProgram(m_Program);

// Explicitly unbind buffer so attrib pointer knows to slurp in array.
glBindBuffer(GL_ARRAY_BUFFER, 0);

//bind vertex array object
glBindVertexArray(m_vaoHandle);

glDrawArrays(mode, 0, numVertices);

glBindVertexArray(0);

如果在OpenGL 3.1+中可以实现,我也想知道在OpenGLES 3.0中是否可以实现

If its possible in OpenGL 3.1+, I would also like to know if its possible in OpenGLES 3.0

推荐答案

OpenGL 3.2+的核心配置文件删除了使用客户端顶点数组的功能.

The core profile of OpenGL 3.2+ removed the ability to use client-side vertex arrays.

OpenGL ES 2.0确实允许使用客户端顶点数组,就像所有更高版本的ES一样.但是,使用客户端数组时,顶点着色器输入变量gl_VertexID(在GLSL ES 3.00中添加)为未定义.哦,附录F.1:旧版功能中提到了ES 3.0中的客户端顶点数组.关于他们,它说:

OpenGL ES 2.0 does allow the use of client-side vertex arrays, as do all higher versions of ES. However, the vertex shader input variable gl_VertexID (added in GLSL ES 3.00) is undefined when using client-side arrays. Oh, and client-side vertex arrays in ES 3.0 are mentioned in appendix F.1: Legacy Features. About them, it says:

存在以下功能是为了保持与OpenGL ES 2.0的向后兼容性,但是不建议使用这些功能,因为将来的版本中很可能会删除这些功能.

The following features 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.

虽然我不希望它们消失,但是显然建议您不要使用它们.

While I wouldn't expect them to ever go away, clearly you are being advised not to use them.

关于VAO是否完全可以与客户端指针一起使用的问题,是的(当然,当完全支持客户端指针时). VAO始终存储顶点阵列状态,无论这些阵列来自何处.用客户端指针调用glVertexAttribPointer会将指针存储在当前VAO内,就像将缓冲区object + offset存储在VAO内一样.

As to the question of whether VAOs can work with client-side pointers at all, yes (when client-side pointers are supported at all, of course). VAOs always store vertex array state, no matter where those arrays come from. Calling glVertexAttribPointer with a client-side pointer will store the pointer inside the current VAO, just like it would store the buffer object+offset inside the VAO.

这篇关于使用客户端顶点数组在没有VBO的opengl 3.1+中进行渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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