Skip to content

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. #12

@eharquin

Description

@eharquin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions