4

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

Pankaj Bansal
  • 889
  • 1
  • 12
  • 37
  • 1
    No. Read [the docs](https://www.opengl.org/sdk/docs/man/html/glVertexAttribPointer.xhtml). Specifically, about the last parameter. – Ivan Aksamentov - Drop May 12 '16 at 06:36
  • 1
    It means exactly what you quote from the spec. No client-side vertex arrays. `glVertexAttrib*()` refers to calls like `glVertexAttrib4fv()`, which let you specify "constant" values for vertex attributes, i.e. attributes where all vertices share the same value. – Reto Koradi May 12 '16 at 07:02

2 Answers2

4

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
0

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.

Anton Duzenko
  • 2,366
  • 1
  • 21
  • 26