Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rlgl] Implementing rlReloadVertexBuffer() and rlReloadVertexBufferElement() #4775

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mikeemm
Copy link
Contributor

@mikeemm mikeemm commented Feb 17, 2025

Currently, a VBO/EBO cannot be resized after being loaded with rlLoadVertexBuffer() or its element counterpart. Using rlUpdateVertexBuffer() 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 with rlLoadVertexBuffer(), 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() and rlReloadVertexBufferElement(), 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.

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.

1 participant