Merge branch 'pr_raytrace_example' of github.com:Ybalrid/tinygltf into pr_raytrace_example

This commit is contained in:
Arthur Brainville (Ybalrid) 2018-02-23 14:26:55 +01:00
commit 55bff342c2
No known key found for this signature in database
GPG Key ID: BC05C4812A06BCF3
3 changed files with 13 additions and 10 deletions

View File

@ -2,7 +2,7 @@ Simple OpenGL viewer for glTF geometry.
## Requirements ## 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 * GLEW
* Ubuntu 16.04: sudo apt install libglew-dev * Ubuntu 16.04: sudo apt install libglew-dev
* glfw3 * glfw3
@ -19,7 +19,7 @@ Simple OpenGL viewer for glTF geometry.
### Windows(not tested well) ### 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 > premake5.exe vs2013

View File

@ -7,10 +7,10 @@ solution "glview"
kind "ConsoleApp" kind "ConsoleApp"
language "C++" language "C++"
cppdialect "C++11"
files { "glview.cc", "trackball.cc" } files { "glview.cc", "trackball.cc" }
includedirs { "./" } includedirs { "./" }
includedirs { "../../" } includedirs { "../../" }
flags "c++11"
configuration { "linux" } configuration { "linux" }
linkoptions { "`pkg-config --libs glfw3`" } linkoptions { "`pkg-config --libs glfw3`" }
@ -34,9 +34,10 @@ solution "glview"
configuration "Debug" configuration "Debug"
defines { "DEBUG" } defines { "DEBUG" }
flags { "Symbols", "ExtraWarnings"} symbols "On"
warnings "Extra"
configuration "Release" configuration "Release"
defines { "NDEBUG" } defines { "NDEBUG" }
flags { "Optimize", "ExtraWarnings"} optimize "On"
warnings "Extra"

View File

@ -70,7 +70,8 @@ bool LoadGLTF(const std::string &filename, float scale,
Mesh<float> loadedMesh(sizeof(float) * 3); Mesh<float> loadedMesh(sizeof(float) * 3);
v3f pMin, pMax; // To store the min and max of the buffer
v3f pMin = {}, pMax = {};
loadedMesh.name = gltfMesh.name; loadedMesh.name = gltfMesh.name;
for (const auto &meshPrimitive : gltfMesh.primitives) { 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 &indicesAccessor = model.accessors[meshPrimitive.indices];
auto &bufferView = model.bufferViews[indicesAccessor.bufferView]; auto &bufferView = model.bufferViews[indicesAccessor.bufferView];
auto &buffer = model.buffers[bufferView.buffer]; auto &buffer = model.buffers[bufferView.buffer];
unsigned char *dataAddress = buffer.data.data() + auto dataAddress = buffer.data.data() + bufferView.byteOffset +
bufferView.byteOffset + indicesAccessor.byteOffset;
indicesAccessor.byteOffset;
const auto byteStride = indicesAccessor.ByteStride(bufferView); const auto byteStride = indicesAccessor.ByteStride(bufferView);
const auto count = indicesAccessor.count; const auto count = indicesAccessor.count;
// Allocate the index array in the pointer-to-base declared in the
// parent scope
switch (indicesAccessor.componentType) { switch (indicesAccessor.componentType) {
case TINYGLTF_COMPONENT_TYPE_BYTE: case TINYGLTF_COMPONENT_TYPE_BYTE:
indicesArrayPtr = indicesArrayPtr =