mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-11 15:39:12 +08:00
Show value when printing UNKNOWN
This commit is contained in:
parent
0de4d7c05f
commit
0c0b993639
@ -19,7 +19,8 @@
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "tiny_gltf.h"
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
||||
//#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
||||
#define BUFFER_OFFSET(i) (reinterpret_cast<void *>(i))
|
||||
|
||||
#define CheckGLErrors(desc) \
|
||||
{ \
|
||||
@ -677,7 +678,7 @@ static void DrawNode(tinygltf::Model &model, const tinygltf::Node &node) {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
static void DrawModel(tinygltf::Model &model) {
|
||||
static void DrawModel(tinygltf::Model &model, size_t scene_idx) {
|
||||
#if 0
|
||||
std::map<std::string, tinygltf::Mesh>::const_iterator it(scene.meshes.begin());
|
||||
std::map<std::string, tinygltf::Mesh>::const_iterator itEnd(scene.meshes.end());
|
||||
@ -688,9 +689,8 @@ static void DrawModel(tinygltf::Model &model) {
|
||||
}
|
||||
#else
|
||||
|
||||
// TODO(syoyo): Support non-default scenes.
|
||||
assert(model.defaultScene >= 0);
|
||||
const tinygltf::Scene &scene = model.scenes[model.defaultScene];
|
||||
assert(scene_idx < model.scenes.size());
|
||||
const tinygltf::Scene &scene = model.scenes[scene_idx];
|
||||
for (size_t i = 0; i < scene.nodes.size(); i++) {
|
||||
DrawNode(model, model.nodes[scene.nodes[i]]);
|
||||
}
|
||||
@ -760,8 +760,18 @@ int main(int argc, char **argv) {
|
||||
|
||||
Init();
|
||||
|
||||
if (model.scenes.empty()) {
|
||||
std::cerr << "glTF model does not have scenes" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// DBG
|
||||
PrintNodes(model.scenes[model.defaultScene]);
|
||||
size_t scene_idx = size_t(model.defaultScene);
|
||||
if (model.defaultScene == -1) {
|
||||
scene_idx = 0;
|
||||
}
|
||||
|
||||
PrintNodes(model.scenes[scene_idx]);
|
||||
|
||||
if (!glfwInit()) {
|
||||
std::cerr << "Failed to initialize GLFW." << std::endl;
|
||||
@ -853,7 +863,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
glScalef(scale, scale, scale);
|
||||
|
||||
DrawModel(model);
|
||||
DrawModel(model, scene_idx);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
@ -30,7 +30,8 @@ static std::string PrintMode(int mode) {
|
||||
} else if (mode == TINYGLTF_MODE_TRIANGLE_STRIP) {
|
||||
return "TRIANGLE_STRIP";
|
||||
}
|
||||
return "**UNKNOWN**";
|
||||
|
||||
return "**UNKNOWN**(" + std::to_string(mode) + ")";
|
||||
}
|
||||
|
||||
static std::string PrintTarget(int target) {
|
||||
@ -39,7 +40,7 @@ static std::string PrintTarget(int target) {
|
||||
} else if (target == 34963) {
|
||||
return "GL_ELEMENT_ARRAY_BUFFER";
|
||||
} else {
|
||||
return "**UNKNOWN**";
|
||||
return "**UNKNOWN**(" + std::to_string(target) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ static std::string PrintType(int ty) {
|
||||
} else if (ty == TINYGLTF_TYPE_MAT4) {
|
||||
return "MAT4";
|
||||
}
|
||||
return "**UNKNOWN**";
|
||||
return "**UNKNOWN**(" + std::to_string(ty) + ")";
|
||||
}
|
||||
|
||||
static std::string PrintComponentType(int ty) {
|
||||
@ -85,7 +86,7 @@ static std::string PrintComponentType(int ty) {
|
||||
return "DOUBLE";
|
||||
}
|
||||
|
||||
return "**UNKNOWN**";
|
||||
return "**UNKNOWN**(" + std::to_string(ty) + ")";
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -147,7 +148,7 @@ static std::string PrintWrapMode(int mode) {
|
||||
return "MIRRORED_REPEAT";
|
||||
}
|
||||
|
||||
return "**UNKNOWN**";
|
||||
return "**UNKNOWN**(" + std::to_string(mode) + ")";
|
||||
}
|
||||
|
||||
static std::string PrintFilterMode(int mode) {
|
||||
@ -164,7 +165,7 @@ static std::string PrintFilterMode(int mode) {
|
||||
} else if (mode == TINYGLTF_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR) {
|
||||
return "LINEAR_MIPMAP_LINEAR";
|
||||
}
|
||||
return "**UNKNOWN**";
|
||||
return "**UNKNOWN**(" + std::to_string(mode) + ")";
|
||||
}
|
||||
|
||||
static std::string PrintIntArray(const std::vector<int> &arr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user