c++openglopengl-es

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

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


Solution

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

    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, sometimes (when client-side pointers are supported at all, of course). VAOs are meant to store vertex array state, no matter where those arrays come from. Calling glVertexAttribPointer with a client-side pointer can store the pointer inside the current VAO, just like it would store the buffer object+offset inside the VAO.

    However, compatibility GL 4.4+ removed the ability for VAOs to store client-side pointers. This may have been as a consequence of the addition of newer vertex format functionality (multi-buffer binding and/or separate attribute format).