RobLoach / raylib-cpp

C++ Object Oriented Wrapper for raylib
https://robloach.github.io/raylib-cpp/
zlib License
630 stars 79 forks source link

Add MeshUnmanaged (#299) #304

Closed furudbat closed 6 months ago

furudbat commented 6 months ago

I'm still not 100% happy with the solution, you can still mess up the construction via implicit cast.

raylib::Mesh mesh = raylib::Mesh::Cubicmap(imMap, Vector3{ 1.0f, 1.0f, 1.0f });     // Use MeshUnmanaged, Mesh will be handled by Model
    raylib::Model model(mesh);
INFO: TEXTURE: [ID 4] Unloaded texture data from VRAM (GPU)
INFO: VAO: [ID 2] Unloaded vertex array data from VRAM (GPU)
INFO: MODEL: Unloaded model (and meshes) from RAM and VRAM
INFO: VAO: [ID 2] Unloaded vertex array data from VRAM (GPU)
double free or corruption (!prev)

Process finished with exit code 134 (interrupted by signal 6:SIGABRT)
furudbat commented 6 months ago

Maybe making the Load() method using r-value ref, can prevent some mishap.

void Load(const ::Mesh& mesh) = delete;
void Load(::Mesh&& mesh) { ... }
void Load(const raylib::Mesh& mesh) = delete;
void Load(raylib::Mesh&& mesh) { ... }