diff --git a/examples/glview/README.md b/examples/glview/README.md index 747c367..34a0c3b 100644 --- a/examples/glview/README.md +++ b/examples/glview/README.md @@ -2,7 +2,7 @@ Simple OpenGL viewer for glTF geometry. ## Requirements -* premake4 : Requires recent `premake4` for macosx and linux, `premake5` for windows. +* premake5 : Requires recent `premake5`(alpha12 or later) for macosx and linux. `premake5` for windows is included in `$tinygltf/tools/window` directory. * GLEW * Ubuntu 16.04: sudo apt install libglew-dev * glfw3 @@ -19,7 +19,7 @@ Simple OpenGL viewer for glTF geometry. ### Windows(not tested well) -Edit glew and glfw path in `premake4.lua`, then +Edit glew and glfw path in `premake5.lua`, then > premake5.exe vs2013 diff --git a/examples/glview/premake4.lua b/examples/glview/premake5.lua similarity index 92% rename from examples/glview/premake4.lua rename to examples/glview/premake5.lua index b43be97..98bffc8 100644 --- a/examples/glview/premake4.lua +++ b/examples/glview/premake5.lua @@ -7,10 +7,10 @@ solution "glview" kind "ConsoleApp" language "C++" + cppdialect "C++11" files { "glview.cc", "trackball.cc" } includedirs { "./" } includedirs { "../../" } - flags "c++11" configuration { "linux" } linkoptions { "`pkg-config --libs glfw3`" } @@ -34,9 +34,10 @@ solution "glview" configuration "Debug" defines { "DEBUG" } - flags { "Symbols", "ExtraWarnings"} + symbols "On" + warnings "Extra" configuration "Release" defines { "NDEBUG" } - flags { "Optimize", "ExtraWarnings"} - + optimize "On" + warnings "Extra" diff --git a/examples/raytrace/gltf-loader.cc b/examples/raytrace/gltf-loader.cc index 176bbee..981a689 100644 --- a/examples/raytrace/gltf-loader.cc +++ b/examples/raytrace/gltf-loader.cc @@ -70,7 +70,8 @@ bool LoadGLTF(const std::string &filename, float scale, Mesh loadedMesh(sizeof(float) * 3); - v3f pMin, pMax; + // To store the min and max of the buffer + v3f pMin = {}, pMax = {}; loadedMesh.name = gltfMesh.name; for (const auto &meshPrimitive : gltfMesh.primitives) { @@ -80,12 +81,13 @@ bool LoadGLTF(const std::string &filename, float scale, auto &indicesAccessor = model.accessors[meshPrimitive.indices]; auto &bufferView = model.bufferViews[indicesAccessor.bufferView]; auto &buffer = model.buffers[bufferView.buffer]; - unsigned char *dataAddress = buffer.data.data() + - bufferView.byteOffset + - indicesAccessor.byteOffset; + auto dataAddress = buffer.data.data() + bufferView.byteOffset + + indicesAccessor.byteOffset; const auto byteStride = indicesAccessor.ByteStride(bufferView); const auto count = indicesAccessor.count; + // Allocate the index array in the pointer-to-base declared in the + // parent scope switch (indicesAccessor.componentType) { case TINYGLTF_COMPONENT_TYPE_BYTE: indicesArrayPtr =