Skip to content

Conversation

trevex
Copy link
Contributor

@trevex trevex commented Jul 19, 2015

…e indices as well (fixes #277).

@ocornut
Copy link
Owner

ocornut commented Jul 19, 2015

Thanks!

Do you see any reason for not using glBufferData() the same way for the vertex buffer? instead of glMapBufferRange() etc.

@ocornut ocornut merged commit bc9bae6 into ocornut:master Jul 19, 2015
@ocornut
Copy link
Owner

ocornut commented Jul 19, 2015

Much shorter :) not sure if the old way had any benefit

        glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
        glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_STREAM_DRAW);

        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_STREAM_DRAW);

@ocornut ocornut mentioned this pull request Jul 19, 2015
@trevex
Copy link
Contributor Author

trevex commented Jul 19, 2015

Didn't spot the possible simplification, but in this case it seems viable. glMapBufferRange can be more powerful, if used wisely. A possible future optimisation would be to double buffer the VBO and element buffer. This would allow to use the GL_MAP_UNSYNCHRONIZED_BIT and reduce the driver overhead and possible stalling.

@ocornut
Copy link
Owner

ocornut commented Jul 20, 2015

We should aim to keep the example as simple as possible really.
If people really want to squeeze extra on the small rendering cost of imgui I'm sure this sort of people will have no issue with doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenGL3 example broken on OSX
2 participants