GLuint Mesh_Setup(GLuint render_prog, GLuint comp_prog, struct VertexPos *vert_pos, struct VertexCol *vert_col, GLuint num_verts, GLuint *inds, GLuint num_inds)
{
GLuint vao;
glCreateVertexArrays(1, &vao);
GLuint pos_attrib_loc = glGetAttribLocation(render_prog, "pos");
GLuint col_attrib_loc = glGetAttribLocation(render_prog, "col");
glVertexArrayAttribFormat(vao, pos_attrib_loc, 4, GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribFormat(vao, col_attrib_loc, 4, GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribBinding(vao, pos_attrib_loc, 0);
glVertexArrayAttribBinding(vao, col_attrib_loc, 1);
glEnableVertexArrayAttrib(vao, pos_attrib_loc);
glEnableVertexArrayAttrib(vao, col_attrib_loc);
GLuint pos_vbo;
glCreateBuffers(1, &pos_vbo);
glNamedBufferData(pos_vbo, sizeof(GLfloat) * 4 * num_verts, vert_pos, GL_DYNAMIC_COPY);
glVertexArrayVertexBuffer(vao, 0, pos_vbo, 0, sizeof(struct VertexPos));
GLuint col_vbo;
glCreateBuffers(1, &col_vbo);
glNamedBufferStorage(col_vbo, sizeof(GLfloat) * 4 * num_verts, vert_col, 0);
glVertexArrayVertexBuffer(vao, 1, col_vbo, 0, sizeof(struct VertexCol));
GLuint ebo;
glCreateBuffers(1, &ebo);
glNamedBufferStorage(ebo, sizeof(GLuint) * num_inds, inds, 0);
glVertexArrayElementBuffer(vao, ebo);
return vao;
}
If I’m getting this code right, glVeretxArrayVertexBuffer is being used to pass data to an GL_ARRAY_BUFFER and glVertexArrayElementBuffer is being used to pass data into an GL_ELEMENT_ARRAY_BUFFER, so is there an GL_SHADER_STORAGE_BUFFER equivalent like glVertexArrayShaderStorageBuffer to pass data which can be manipulated in the computed shader? I would like to pass the same pos_buf data to the compute shader.