mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 10:45:53 +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,10 +15,15 @@ Simple OpenGL viewer for glTF geometry.
|
|||||||
> premake4 gmake
|
> premake4 gmake
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
### Windows(not tested)
|
### Windows(not tested well)
|
||||||
|
|
||||||
|
Edit glew and glfw path in `premake4.lua`, then
|
||||||
|
|
||||||
> premake5.exe vs2013
|
> premake5.exe vs2013
|
||||||
Open .sln in Visual Studio 2013
|
|
||||||
|
Open .sln in Visual Studio 2013
|
||||||
|
|
||||||
|
When running .exe, glew and glfw dll must exist in the working directory.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
@ -360,12 +360,15 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
|||||||
if ((it->first.compare("POSITION") == 0) ||
|
if ((it->first.compare("POSITION") == 0) ||
|
||||||
(it->first.compare("NORMAL") == 0) ||
|
(it->first.compare("NORMAL") == 0) ||
|
||||||
(it->first.compare("TEXCOORD_0") == 0)) {
|
(it->first.compare("TEXCOORD_0") == 0)) {
|
||||||
glVertexAttribPointer(
|
|
||||||
gGLProgramState.attribs[it->first], count, accessor.componentType,
|
if (gGLProgramState.attribs[it->first] >= 0) {
|
||||||
GL_FALSE, accessor.byteStride, BUFFER_OFFSET(accessor.byteOffset));
|
glVertexAttribPointer(
|
||||||
CheckErrors("vertex attrib pointer");
|
gGLProgramState.attribs[it->first], count, accessor.componentType,
|
||||||
glEnableVertexAttribArray(gGLProgramState.attribs[it->first]);
|
GL_FALSE, accessor.byteStride, BUFFER_OFFSET(accessor.byteOffset));
|
||||||
CheckErrors("enable vertex attrib array");
|
CheckErrors("vertex attrib pointer");
|
||||||
|
glEnableVertexAttribArray(gGLProgramState.attribs[it->first]);
|
||||||
|
CheckErrors("enable vertex attrib array");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +406,9 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
|||||||
if ((it->first.compare("POSITION") == 0) ||
|
if ((it->first.compare("POSITION") == 0) ||
|
||||||
(it->first.compare("NORMAL") == 0) ||
|
(it->first.compare("NORMAL") == 0) ||
|
||||||
(it->first.compare("TEXCOORD_0") == 0)) {
|
(it->first.compare("TEXCOORD_0") == 0)) {
|
||||||
glDisableVertexAttribArray(gGLProgramState.attribs[it->first]);
|
if (gGLProgramState.attribs[it->first] >= 0) {
|
||||||
|
glDisableVertexAttribArray(gGLProgramState.attribs[it->first]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +502,7 @@ int main(int argc, char **argv) {
|
|||||||
glfwSetMouseButtonCallback(window, clickFunc);
|
glfwSetMouseButtonCallback(window, clickFunc);
|
||||||
glfwSetCursorPosCallback(window, motionFunc);
|
glfwSetCursorPosCallback(window, motionFunc);
|
||||||
|
|
||||||
glewExperimental = true;
|
glewExperimental = true; // This may be only true for linux environment.
|
||||||
if (glewInit() != GLEW_OK) {
|
if (glewInit() != GLEW_OK) {
|
||||||
std::cerr << "Failed to initialize GLEW." << std::endl;
|
std::cerr << "Failed to initialize GLEW." << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
@ -523,17 +528,12 @@ int main(int argc, char **argv) {
|
|||||||
CheckErrors("link");
|
CheckErrors("link");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// At least `in_vertex` should be used in the shader.
|
||||||
GLint vtxLoc = glGetAttribLocation(progId, "in_vertex");
|
GLint vtxLoc = glGetAttribLocation(progId, "in_vertex");
|
||||||
if (vtxLoc < 0) {
|
if (vtxLoc < 0) {
|
||||||
printf("vertex loc not found.\n");
|
printf("vertex loc not found.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint tnLoc = glGetAttribLocation(progId, "in_normal");
|
|
||||||
if (tnLoc < 0) {
|
|
||||||
printf("normal loc not found.\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(progId);
|
glUseProgram(progId);
|
||||||
|
@ -1,36 +1,41 @@
|
|||||||
solution "glview"
|
solution "glview"
|
||||||
-- location ( "build" )
|
-- location ( "build" )
|
||||||
configurations { "Debug", "Release" }
|
configurations { "Debug", "Release" }
|
||||||
platforms {"native", "x64", "x32"}
|
platforms {"native", "x64", "x32"}
|
||||||
|
|
||||||
project "glview"
|
project "glview"
|
||||||
|
|
||||||
kind "ConsoleApp"
|
kind "ConsoleApp"
|
||||||
language "C++"
|
language "C++"
|
||||||
files { "glview.cc", "trackball.cc" }
|
files { "glview.cc", "trackball.cc" }
|
||||||
includedirs { "./" }
|
includedirs { "./" }
|
||||||
includedirs { "../../" }
|
includedirs { "../../" }
|
||||||
|
|
||||||
configuration { "linux" }
|
configuration { "linux" }
|
||||||
linkoptions { "`pkg-config --libs glfw3`" }
|
linkoptions { "`pkg-config --libs glfw3`" }
|
||||||
links { "GL", "GLU", "m", "GLEW", "X11", "Xrandr", "Xinerama", "Xi", "Xxf86vm", "Xcursor", "dl" }
|
links { "GL", "GLU", "m", "GLEW", "X11", "Xrandr", "Xinerama", "Xi", "Xxf86vm", "Xcursor", "dl" }
|
||||||
|
|
||||||
configuration { "windows" }
|
configuration { "windows" }
|
||||||
links { "glfw3", "gdi32", "winmm", "user32", "GLEW", "glu32","opengl32", "kernel32" }
|
-- Edit path to glew and GLFW3 fit to your environment.
|
||||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
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" }
|
configuration { "macosx" }
|
||||||
includedirs { "/usr/local/include" }
|
includedirs { "/usr/local/include" }
|
||||||
buildoptions { "-Wno-deprecated-declarations" }
|
buildoptions { "-Wno-deprecated-declarations" }
|
||||||
libdirs { "/usr/local/lib" }
|
libdirs { "/usr/local/lib" }
|
||||||
links { "glfw3", "GLEW" }
|
links { "glfw3", "GLEW" }
|
||||||
linkoptions { "-framework OpenGL", "-framework Cocoa", "-framework IOKit", "-framework CoreVideo" }
|
linkoptions { "-framework OpenGL", "-framework Cocoa", "-framework IOKit", "-framework CoreVideo" }
|
||||||
|
|
||||||
configuration "Debug"
|
configuration "Debug"
|
||||||
defines { "DEBUG" }
|
defines { "DEBUG" }
|
||||||
flags { "Symbols", "ExtraWarnings"}
|
flags { "Symbols", "ExtraWarnings"}
|
||||||
|
|
||||||
configuration "Release"
|
configuration "Release"
|
||||||
defines { "NDEBUG" }
|
defines { "NDEBUG" }
|
||||||
flags { "Optimize", "ExtraWarnings"}
|
flags { "Optimize", "ExtraWarnings"}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user