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

gl_viewer crashes on models without textures #36

Closed
droettger opened this issue Dec 11, 2023 · 1 comment
Closed

gl_viewer crashes on models without textures #36

droettger opened this issue Dec 11, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@droettger
Copy link

This line inside the gl_viewer example
https://github.com/spnda/fastgltf/blob/main/examples/gl_viewer/gl_viewer.cpp#L421C3-L421C3
will crash with an out-of-bounds access inside the asset.accessors if it->findAttribute("TEXCOORD_0") returns it->attributes.end().
Happens with the Khronos model
https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/BrainStem/glTF/BrainStem.gltf

@spnda
Copy link
Owner

spnda commented Dec 11, 2023

A crash does seem like unintended behaviour but I think what I was trying to do is require a model to have textures. The same applies for the code I wrote that you mentioned in #37.

The example wasn't made to cover absolutely every possibility and is only fairly rudimentary, but I will try and look into adding support for non-textured models, probably by adding a default white texture and just setting their vertex UVs to {0,0}.

That would also simultaneously fix the issue with #37, so I'll close that issue and leave this open to track addition of a default texture to gl_viewer.

I seem to have misunderstood #37, and forgot that the shaders were written with non-textures in mind. So this issue was fairly trivial to fix. Thank you for mentioning this to me.

@spnda spnda added the bug Something isn't working label Dec 11, 2023
@spnda spnda self-assigned this Dec 11, 2023
@spnda spnda changed the title gl_viewer out-of-bounds access on models without TEXCOORD_0 attribute gl_viewer crashes on models without textures Dec 11, 2023
@spnda spnda closed this as completed in da9b790 Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants