Hi. I’m trying to set vertex attribute pointers using the DSA technique. As a test I’m trying to substitute something that already works in a test program. The following two lines (including relevant function) worked in my program:
void setVertexAttribPointer(GLuint shaderProgram, const char* name, GLint numComponents, GLenum type, GLsizei stride, int offset)
{
GLint attrib = glGetAttribLocation(shaderProgram, name);
glEnableVertexAttribArray(attrib);
glVertexAttribPointer(attrib, numComponents, type, GL_FALSE, stride, (void*)((intptr_t)offset));
}
// in main.cpp:
setVertexAttribPointer(skylineShader, "position", 2, GL_FLOAT, 5*sizeof(GLfloat), 0);
setVertexAttribPointer(skylineShader, "color", 3, GL_FLOAT, 5*sizeof(GLfloat), 2*sizeof(GLfloat));
Now I have changed that to:
GLint attrib = glGetAttribLocation(skylineShader, "position");
glEnableVertexArrayAttrib(skylineVAO, attrib);
glVertexArrayVertexAttribOffsetEXT(skylineVAO, skylineBuffer, attrib, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), 0);
I didn’t include the lines setting up the vertex attribute pointers for “color”, as the program crashes after the function call to glVertexArrayVertexAttribOffsetEXT.
Here is more of the context, and here are the functions I used in that code - it should not be necessary to pay too much attention to those.
As you can see, skylineBuffer is the output of glGenBuffers, and it’s sent to glVertexArrayVertexAttribOffsetEXT after uploading the vertices (just the same as in the working test case).
I would greatly appreciate any help that can point me in the right direction.
Thanks!