syoyo / tinygltf

Header only C++11 tiny glTF 2.0 library
MIT License
2.02k stars 410 forks source link

Segmentation fault in basic_viewer example (Blender default scene) #251

Closed F1r3Hydr4nt closed 4 years ago

F1r3Hydr4nt commented 4 years ago

Hello,

I am trying to use the basic_viewer loading scene packaged with tinygltf to load a default blender scene (open blender-> export to gltf: https://pastebin.com/17L6HtVW).

To reproduce: ./bin/native/Debug/basic_viewer ../../models/blenderdefaultscene.gltf Mesa DRI Intel(R) Haswell Mobile , 4.5 (Core Profile) Mesa 19.3.3 Linking program Loaded glTF: ../../models/blenderdefaultscene.gltf bufferview.target 34962 buffer.data.size = 840, bufferview.byteOffset = 0 bufferview.target 34962 buffer.data.size = 840, bufferview.byteOffset = 288 bufferview.target 34962 buffer.data.size = 840, bufferview.byteOffset = 576 bufferview.target 34963 buffer.data.size = 840, bufferview.byteOffset = 768 Segmentation fault

This error mirrors one that I am receiving with another basic custom model...

Any ideas?

syoyo commented 4 years ago

basic example did not support glTF scene without textures(+ images). At least it now does not segfault(but will be shaded in black color)

F1r3Hydr4nt commented 4 years ago

Great, thanks...

In fact, it still segfaults due to line 197 but that can be wrapped in:

if ((node.mesh >= 0) && (node.mesh < model.meshes.size())) {
    drawMesh(model, model.meshes[node.mesh]);
  }

The simple model I am trying to render still does not render anything but the very first mesh for some reason: https://zerobin.net/?007810b42cd3537d#WBFoJ4uuOR/rAr4yIUsxsh+GU1UoEYfb0UMSH79BIB4=

I think I will move to tinyobjloader despite the larger file size, I just can't seem to figure this out ¯_(ツ)_/¯

syoyo commented 4 years ago

@freddiehonohan You are better to take a look at Vulkan-glTF-PBR: https://github.com/SaschaWillems/Vulkan-glTF-PBR

It has feature rich support of rendering glTF scene using tinygltf

it still segfaults due to line 197 but that can be wrapped in:

You can contribute! PR is always welcome.