diff --git a/examples/models/models_first_person_maze.cpp b/examples/models/models_first_person_maze.cpp index 4910aa79..a62b1258 100644 --- a/examples/models/models_first_person_maze.cpp +++ b/examples/models/models_first_person_maze.cpp @@ -25,7 +25,7 @@ int main(void) raylib::Image imMap("resources/cubicmap.png"); // Load cubicmap image (RAM) raylib::Texture cubicmap(imMap); // Convert image to texture to display (VRAM) - raylib::MeshUnmanaged mesh = raylib::MeshUnmanaged::Cubicmap(imMap, Vector3{ 1.0f, 1.0f, 1.0f }); // Use MeshUnmanaged, Mesh will be handled by Model + raylib::MeshUnmanaged mesh = raylib::Mesh::Cubicmap(imMap, Vector3{ 1.0f, 1.0f, 1.0f }); // Use MeshUnmanaged, Mesh will be handled by Model raylib::Model model(mesh); // NOTE: By default each cube is mapped to one part of texture atlas diff --git a/include/Model.hpp b/include/Model.hpp index a2e1cf97..65fbcfe1 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -43,6 +43,15 @@ class Model : public ::Model { Load(mesh); } + /* + * Overloaded constructor to catch when passing in a `raylib::Mesh`. It expects a `raylib::MeshUnmanaged or `::Mesh`. + * + * @throws raylib::RaylibException Since the model takes ownership of the Mesh, a `::Mesh` or `raylib::UnmanagedMesh` is required here. + */ + Model(const raylib::Mesh& mesh) { + throw raylib::RaylibException("Model(mesh) constructor expects a ::Mesh or raylib::MeshUnmanaged, as it takes ownership of the Mesh itself."); + } + ~Model() { Unload(); }