mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 11:05:52 +08:00
Improve windows build.
Don't report error when `in_normal` is not used in the shader.
This commit is contained in:
parent
9a478238c7
commit
8317ffbe8a
@ -15,11 +15,16 @@ Simple OpenGL viewer for glTF geometry.
|
||||
> premake4 gmake
|
||||
$ make
|
||||
|
||||
### Windows(not tested)
|
||||
### Windows(not tested well)
|
||||
|
||||
Edit glew and glfw path in `premake4.lua`, then
|
||||
|
||||
> premake5.exe vs2013
|
||||
|
||||
Open .sln in Visual Studio 2013
|
||||
|
||||
When running .exe, glew and glfw dll must exist in the working directory.
|
||||
|
||||
## TODO
|
||||
|
||||
* [x] Texture
|
||||
|
@ -360,6 +360,8 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
||||
if ((it->first.compare("POSITION") == 0) ||
|
||||
(it->first.compare("NORMAL") == 0) ||
|
||||
(it->first.compare("TEXCOORD_0") == 0)) {
|
||||
|
||||
if (gGLProgramState.attribs[it->first] >= 0) {
|
||||
glVertexAttribPointer(
|
||||
gGLProgramState.attribs[it->first], count, accessor.componentType,
|
||||
GL_FALSE, accessor.byteStride, BUFFER_OFFSET(accessor.byteOffset));
|
||||
@ -368,6 +370,7 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
||||
CheckErrors("enable vertex attrib array");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tinygltf::Accessor &indexAccessor = scene.accessors[primitive.indices];
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
|
||||
@ -403,12 +406,14 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
||||
if ((it->first.compare("POSITION") == 0) ||
|
||||
(it->first.compare("NORMAL") == 0) ||
|
||||
(it->first.compare("TEXCOORD_0") == 0)) {
|
||||
if (gGLProgramState.attribs[it->first] >= 0) {
|
||||
glDisableVertexAttribArray(gGLProgramState.attribs[it->first]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawScene(tinygltf::Scene &scene) {
|
||||
std::map<std::string, tinygltf::Mesh>::const_iterator it(scene.meshes.begin());
|
||||
@ -497,7 +502,7 @@ int main(int argc, char **argv) {
|
||||
glfwSetMouseButtonCallback(window, clickFunc);
|
||||
glfwSetCursorPosCallback(window, motionFunc);
|
||||
|
||||
glewExperimental = true;
|
||||
glewExperimental = true; // This may be only true for linux environment.
|
||||
if (glewInit() != GLEW_OK) {
|
||||
std::cerr << "Failed to initialize GLEW." << std::endl;
|
||||
return -1;
|
||||
@ -523,17 +528,12 @@ int main(int argc, char **argv) {
|
||||
CheckErrors("link");
|
||||
|
||||
{
|
||||
// At least `in_vertex` should be used in the shader.
|
||||
GLint vtxLoc = glGetAttribLocation(progId, "in_vertex");
|
||||
if (vtxLoc < 0) {
|
||||
printf("vertex loc not found.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
GLint tnLoc = glGetAttribLocation(progId, "in_normal");
|
||||
if (tnLoc < 0) {
|
||||
printf("normal loc not found.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
glUseProgram(progId);
|
||||
|
@ -16,7 +16,12 @@ solution "glview"
|
||||
links { "GL", "GLU", "m", "GLEW", "X11", "Xrandr", "Xinerama", "Xi", "Xxf86vm", "Xcursor", "dl" }
|
||||
|
||||
configuration { "windows" }
|
||||
links { "glfw3", "gdi32", "winmm", "user32", "GLEW", "glu32","opengl32", "kernel32" }
|
||||
-- Edit path to glew and GLFW3 fit to your environment.
|
||||
includedirs { "../../../../local/glew-1.13.0/include/" }
|
||||
includedirs { "../../../../local/glfw-3.2.bin.WIN32/include/" }
|
||||
libdirs { "../../../../local/glew-1.13.0/lib/Release/Win32/" }
|
||||
libdirs { "../../../../local/glfw-3.2.bin.WIN32/lib-vc2013/" }
|
||||
links { "glfw3", "gdi32", "winmm", "user32", "glew32", "glu32","opengl32", "kernel32" }
|
||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
||||
|
||||
configuration { "macosx" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user