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

Add LoadModelEx and UploadModel functions #4576

Closed
wants to merge 1 commit into from

Conversation

devdad
Copy link
Contributor

@devdad devdad commented Dec 5, 2024

To enable custom model and mesh batching in projects that use the official raylib and instancing, it is essential to have control over whether or not meshes are automatically uploaded to the GPU. In my opinion, this is the cleanest solution for achieving that flexibility.

New functions added:
// Load model from files (mesh and material) without automatically uploading vertex data to the GPU
Model LoadModelEx(const char *fileName, bool upload)

// Upload model data to the GPU (RAM and/or VRAM)
void UploadModel(const Model *model, bool dynamic)

The existing LoadModel function now calls LoadModelEx with upload = true.

Additionally, fixed LoadOBJ to match the behavior of other load functions by not automatically uploading meshes.

To enable custom model and mesh batching in projects that use the official raylib and instancing, it is essential to have control over whether or not meshes are automatically uploaded to the GPU. In my opinion, this is the cleanest solution for achieving that flexibility.

New functions added:
// Load model from files (mesh and material) without automatically uploading vertex data to the GPU Model LoadModelEx(const char *fileName, bool upload) // Upload model data to the GPU (RAM and/or VRAM)
void UploadModel(const Model *model, bool dynamic)

The existing LoadModel function now calls LoadModelEx with upload = true.

Additionally, fixed LoadOBJ to match the behavior of other load functions by not automatically uploading meshes.
@raysan5
Copy link
Owner

raysan5 commented Dec 8, 2024

@devdad I'm afraid I don't like this approach, I try to avoid functions with that kind of bool flags.

@raysan5 raysan5 closed this Dec 8, 2024
@devdad
Copy link
Contributor Author

devdad commented Dec 8, 2024

@raysan5 ok np, but do you have some better suggestion, what we have now it is clearly not good too, because it force meshes to be uploaded straight away and to do work around is so hard because we can't call static LoadOBJ and other similar functions. It is making so hard to optimise the drawing of meshes. I hope you understand what I am saying.

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.

2 participants