Skip to content

Commit

Permalink
Add Model(raylib::Mesh) constructor to throw an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Mar 9, 2024
1 parent 9176e0a commit ae8b4d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/models/models_first_person_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ class Model : public ::Model {
Load(mesh);
}

/*
* Load a model from a mesh.
*
* @throws raylib::RaylibException Throws if failed to load the Modal.
*/
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();
}
Expand Down

0 comments on commit ae8b4d1

Please sign in to comment.