简体   繁体   中英

Rendering in opengl 3.1+ without VBO using client side vertex array

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 I am talking about client side vertex array not immediate mode. I want to know if I can create a VAO without VBO

I read this somewhere in opengl spec 某处读到了这个 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);

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);

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

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

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:

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.

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.

As an appendix to the accepted answer, you can 'kind of' emulate client arrays with UBO/SSBO. On the other hand, it should not be too hard to implement your own 'client pointer' implementation via a hidden VBO and glBufferData.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM