Guide-to-Modern-OpenGL-Functions icon indicating copy to clipboard operation
Guide-to-Modern-OpenGL-Functions copied to clipboard

It is not necessary to use the GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT parameter for the example of storing index and vertex data in a single buffer.

Open eharquin opened this issue 2 years ago • 1 comments

Everything is in the title, your example is good but I don't understand why you use GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.

Solution :

`GLuint vao = GL_NONE; GLuint buffer = GL_NONE;

auto const ind_len = GLsizei(ind_count * sizeof(element_t)); auto const vrt_len = GLsizei(vrt_count * sizeof(vertex));

auto const ind_offset = vrt_len; auto const vrt_offset = 0;

glCreateBuffers(1, &buffer); glNamedBufferStorage(buffer, ind_len + vrt_len, nullptr, GL_DYNAMIC_STORAGE_BIT);

glNamedBufferSubData(buffer, ind_offset, ind_len, ind_data); glNamedBufferSubData(buffer, vrt_offset, vrt_len, vrt_data);

glCreateVertexArrays(1, &vao); glVertexArrayVertexBuffer(vao, 0, buffer, vrt_offset, sizeof(vertex)); glVertexArrayElementBuffer(vao, buffer);`

eharquin avatar Feb 16 '23 14:02 eharquin