[rlgl] Implementing rlReloadVertexBuffer()
and rlReloadVertexBufferElement()
#4775
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, a VBO/EBO cannot be resized after being loaded with
rlLoadVertexBuffer()
or its element counterpart. UsingrlUpdateVertexBuffer()
only works if your new vertex data is as big or smaller than what was initially allocated; not if it is bigger. The buffer's usage is also not modifiable this way.At the moment, the raylib-only solution is to use
rlUnloadVertexBuffer
on the old buffer and load it anew withrlLoadVertexBuffer()
, while also recreating any VAOs using these VBO/EBOs. Implementing a solution within your own code doesn't seem to be possible out of the box considering that the OpenGL functions it requires don't seem to be exposed by Raylib.With these changes we get
rlReloadVertexBuffer()
andrlReloadVertexBufferElement()
, which reload an existing vertex buffer without requiring new bindings. I believe this is a really simple addition that can be really helpful in cases when you may want to modify parts of an existing mesh without destroying and recreating it completely, or when you're handling vertex buffer objects on your own without using Raylib's structures directly.