Skip to content

In the "Loading Models" chapter, tinyobj::loadObj(...) recieves invalid arguments, causing compilation to fail #404

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

Open
Daxturus opened this issue Apr 24, 2025 · 1 comment

Comments

@Daxturus
Copy link

Daxturus commented Apr 24, 2025

Earlier I raised issue #403, after I was unable to compile the source code give in the "Loading Models" section.

In the base code, two empty strings, &warn and &err, are passed to tinyobj::loadObj().

tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, MODEL_PATH.c_str())

However, currently, TinyObjLoader v1.0.6 does not have a function that accepts two strings for error handling. The closest match is this:

bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, std::vector<material_t> *materials, std::string *err, const char *filename, const char *mtl_basedir, bool trianglulate)

...which only has one input string for error handling.

Because the given example code passes both &err and &warn, it fails to compile with a "no matching function" error.

I was able to fix this by changing the code around line 1000... (in https://vulkan-tutorial.com/code/28_model_loading.cpp)

...From this:
std::string warn, err; if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, MODEL_PATH.c_str())) { throw std::runtime_error(warn + err); }

To this:
std::string err; if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, MODEL_PATH.c_str())) { throw std::runtime_error(err); }

I humbly suggest making these changes to the code given in https://vulkan-tutorial.com/Loading_models; hopefully no one else has to go through the process of figuring this out like I did o_o'. Thanks for reading this nonetheless.

@Daxturus Daxturus changed the title In the "Loading Models" chapter, tinyobj::loadObj(...) recieves invalid arguments, preventing compilation In the "Loading Models" chapter, tinyobj::loadObj(...) recieves invalid arguments, causes compilation to fail Apr 24, 2025
@Daxturus Daxturus changed the title In the "Loading Models" chapter, tinyobj::loadObj(...) recieves invalid arguments, causes compilation to fail In the "Loading Models" chapter, tinyobj::loadObj(...) recieves invalid arguments, causing compilation to fail Apr 25, 2025
@Overv
Copy link
Owner

Overv commented May 2, 2025

Hi @Daxturus, thanks for figuring this out! If you could submit a PR with these changes then I'll get right on to updating the site.

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

No branches or pull requests

2 participants