瀏覽代碼

Merge commit 'cdcf34637fa2d9c3039f28c455e26fe5edbfa1a4 [formerly 2341af78cad7d594d7c3b1ebe91d8fb52ec19773]'

Conflicts:
	tutorial/607_LIM/main.cpp

- viewer timer is now cross platform
- glew is now properyl included in all the viewer files


Former-commit-id: 8505d91055c29aa2a2525065c2bb1bf4e9a7f88b
Daniele Panozzo 11 年之前
父節點
當前提交
bd29dddc76

+ 3 - 3
build/Makefile_viewer

@@ -16,7 +16,7 @@ OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
 # include igl headers
 INC+=-I../include/
 
-# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY 
+# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY
 
 # Eigen dependency
 EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
@@ -35,7 +35,7 @@ endif
 ANTTWEAKBAR_INC=-I$(ANTTWEAKBAR)/include -I$(ANTTWEAKBAR)/src
 INC+=$(ANTTWEAKBAR_INC)
 
-obj: 
+obj:
 	mkdir -p obj
 
 ../lib/libiglviewer.a: $(OBJ_FILES)
@@ -43,7 +43,7 @@ obj:
 	ar cqs $@ $(OBJ_FILES)
 
 obj/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h
-	g++ $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)
+	$(GG) $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)
 
 clean:
 	rm -f obj/*.o

+ 5 - 0
include/igl/viewer/OpenGL_shader.cpp

@@ -8,6 +8,11 @@
 
 #include "OpenGL_shader.h"
 
+#ifndef __APPLE__
+#  define GLEW_STATIC
+#  include <GL/glew.h>
+#endif
+
 #ifdef __APPLE__
 #   include <OpenGL/gl3.h>
 #   define __gl_h_ /* Prevent inclusion of the old gl.h */

+ 11 - 0
include/igl/viewer/OpenGL_shader.h

@@ -13,6 +13,17 @@
 #include <string>
 #include <Eigen/Core>
 
+#ifdef _WIN32
+#  include <windows.h>
+#  undef max
+#  undef min
+#endif
+
+#ifndef __APPLE__
+#  define GLEW_STATIC
+#  include <GL/glew.h>
+#endif
+
 #ifdef __APPLE__
 #   include <OpenGL/gl3.h>
 #   define __gl_h_ /* Prevent inclusion of the old gl.h */

+ 3 - 4
include/igl/viewer/Viewer.cpp

@@ -15,8 +15,8 @@
 #  undef min
 #endif
 
-// Todo: windows equivalent for `usleep`
-#include <unistd.h>
+#include <chrono>
+#include <thread>
 
 #ifndef __APPLE__
 #  define GLEW_STATIC
@@ -1052,8 +1052,7 @@ namespace igl
         const double min_duration = 1000000./core.animation_max_fps;
         if(duration<min_duration)
         {
-          // TODO: windows equivalent
-          usleep(min_duration-duration);
+          std::this_thread::sleep_for(std::chrono::microseconds((int)(min_duration-duration)));
         }
       }
       else

+ 1 - 1
include/igl/viewer/ViewerCore.cpp

@@ -159,7 +159,7 @@ IGL_INLINE void igl::ViewerCore::get_scale_and_shift_to_fit_mesh(
   double x_scale = fabs(max_point[0] - min_point[0]);
   double y_scale = fabs(max_point[1] - min_point[1]);
   double z_scale = fabs(max_point[2] - min_point[2]);
-  zoom = 2.0/ std::max(z_scale,std::max(x_scale,y_scale));
+  zoom = 2.0 / std::max(z_scale,std::max(x_scale,y_scale));
 }
 
 IGL_INLINE void igl::ViewerCore::clear_framebuffers()

+ 3 - 2
tutorial/607_LIM/main.cpp

@@ -27,7 +27,7 @@ bool key_down(igl::Viewer& viewer,unsigned char key,int modifier)
   using namespace std;
   using namespace Eigen;
 
-  if(key >= '1' && key <= '5' || key == 'B')
+  if(key >= '0' && key <= '5' || key == 'B')
   {
     // compute locally injective map
     int energy = key - '1';
@@ -44,7 +44,8 @@ bool key_down(igl::Viewer& viewer,unsigned char key,int modifier)
         energyType = energy;
     }
 
-    igl::compute_lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
+    if(key != '0')
+      igl::compute_lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
 
     // set mesh
     viewer.set_vertices(V1);

+ 1 - 1
tutorial/CMakeLists.txt

@@ -53,8 +53,8 @@ add_subdirectory("505_MIQ")
 add_subdirectory("506_FrameField")
 add_subdirectory("507_PolyVectorField")
 add_subdirectory("508_ConjugateField")
-endif(LIBCOMISO_FOUND)
 add_subdirectory("509_Planarization")
+endif(LIBCOMISO_FOUND)
 
 
 # Chapter 6