소스 검색

compress in tutorial, better header in compress, ifndef IGL_NO_OPENGL and IGL_NO_ANTTWEAKBAR guards, compress compiles without these, undo svd

Former-commit-id: 7acb90973774999334a0245e22bcbb4b2177265f
Alec Jacobson (jalec 11 년 전
부모
커밋
79341b5bd6
58개의 변경된 파일508개의 추가작업 그리고 539개의 파일을 삭제
  1. 2 1
      Makefile
  2. 6 4
      Makefile.conf
  3. 1 0
      RELEASE_HISTORY.txt
  4. 1 1
      VERSION.txt
  5. 97 96
      examples/svd/example.cpp
  6. 1 1
      include/igl/ONE.h
  7. 2 0
      include/igl/ReAntTweakBar.cpp
  8. 2 0
      include/igl/ReAntTweakBar.h
  9. 2 0
      include/igl/cocoa_key_to_anttweakbar_key.cpp
  10. 2 0
      include/igl/cocoa_key_to_anttweakbar_key.h
  11. 2 0
      include/igl/create_index_vbo.cpp
  12. 3 13
      include/igl/create_index_vbo.h
  13. 2 0
      include/igl/create_mesh_vbo.cpp
  14. 3 13
      include/igl/create_mesh_vbo.h
  15. 2 0
      include/igl/create_shader_program.cpp
  16. 4 13
      include/igl/create_shader_program.h
  17. 3 0
      include/igl/create_vector_vbo.cpp
  18. 3 13
      include/igl/create_vector_vbo.h
  19. 2 0
      include/igl/destroy_shader_program.cpp
  20. 3 13
      include/igl/destroy_shader_program.h
  21. 3 10
      include/igl/draw_beach_ball.cpp
  22. 2 0
      include/igl/draw_beach_ball.h
  23. 2 0
      include/igl/draw_mesh.cpp
  24. 3 13
      include/igl/draw_mesh.h
  25. 3 14
      include/igl/draw_point.cpp
  26. 2 0
      include/igl/draw_point.h
  27. 2 0
      include/igl/gl_type_size.cpp
  28. 3 13
      include/igl/gl_type_size.h
  29. 2 0
      include/igl/load_shader.cpp
  30. 3 13
      include/igl/load_shader.h
  31. 2 0
      include/igl/print_gl_get.cpp
  32. 3 12
      include/igl/print_gl_get.h
  33. 2 0
      include/igl/print_program_info_log.cpp
  34. 3 13
      include/igl/print_program_info_log.h
  35. 2 0
      include/igl/print_shader_info_log.cpp
  36. 3 13
      include/igl/print_shader_info_log.h
  37. 3 12
      include/igl/project.cpp
  38. 4 13
      include/igl/render_to_tga.cpp
  39. 2 0
      include/igl/repdiag.cpp
  40. 2 0
      include/igl/report_gl_error.cpp
  41. 3 12
      include/igl/report_gl_error.h
  42. 3 13
      include/igl/right_axis.cpp
  43. 40 40
      include/igl/svd.cpp
  44. 25 23
      include/igl/svd.h
  45. 3 0
      include/igl/texture_from_tga.cpp
  46. 3 13
      include/igl/texture_from_tga.h
  47. 2 0
      include/igl/tga.cpp
  48. 3 13
      include/igl/tga.h
  49. 2 0
      include/igl/uniform_type_to_string.cpp
  50. 3 13
      include/igl/uniform_type_to_string.h
  51. 3 12
      include/igl/unproject.cpp
  52. 3 12
      include/igl/unproject_to_zero_plane.cpp
  53. 3 13
      include/igl/up_axis.cpp
  54. 3 13
      include/igl/view_axis.cpp
  55. 0 1
      readme.txt
  56. 3 0
      scripts/compress.sh
  57. 54 5
      style.css
  58. 158 62
      tutorial.html

+ 2 - 1
Makefile

@@ -14,10 +14,11 @@ $(info Hello, $(IGL_USERNAME)!)
 
 # optimized default settings
 all: LFLAGS +=
-OPTFLAGS+=-O3 -DNDEBUG $(OPENMP) $(SSE) 
+OPTFLAGS+=-O3 -DNDEBUG $(OPENMP)
 #debug: OPTFLAGS= -g -Wall -Werror
 debug: OPTFLAGS= -g -Wall
 CFLAGS += $(OPTFLAGS)
+#CFLAGS += -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR
 
 EXTRA_DIRS=
 ifeq ($(IGL_WITH_TETGEN),1)

+ 6 - 4
Makefile.conf

@@ -33,8 +33,6 @@ ifeq ($(IGL_USERNAME),ajx)
 	# msse4.2 is necessary for me to get embree to compile correctly
 	AFLAGS = -m64 -msse4.2
 	OPENMP=-fopenmp
-#SSE=-mavx
-	SSE=-msse
 endif
 
 ifeq ($(IGL_USERNAME),alecjaco) 
@@ -45,7 +43,8 @@ ifeq ($(IGL_USERNAME),alecjaco)
 	#IGL_WITH_MOSEK=1
 	OPENGL_INC=-I$(DEFAULT_PREFIX)/include
 	OPENGL_LIB=-lGL -lGLU
-	#GLUT_LIB=-lglut
+	# Glut is needed only for examples
+	GLUT_LIB=-lglut
 	ANTTWEAKBAR_LIB=-lAntTweakBar
 	OPENMP=-fopenmp
 endif
@@ -64,6 +63,7 @@ ifeq ($(IGL_USERNAME),jalec_linux)
 	IGL_WITH_MATLAB=0
 	IGL_WITH_MOSEK=1
 	OPENGL_LIB=-lGL -lGLU
+	# Glut is needed only for examples
 	GLUT_LIB=-lglut
 	ANTTWEAKBAR_LIB=-lAntTweakBar
 	IGL_WITH_PNG=1
@@ -85,6 +85,7 @@ ifeq ($(IGL_USERNAME),chrsch)
     IGL_WITH_MOSEK=0
     #MOSEKPLATFORM=linux64x86
     OPENGL_LIB=-lGL -lGLU
+    # Glut is needed only for examples
     GLUT_LIB=-lglut
     ANTTWEAKBAR_LIB=-lAntTweakBar
     OPENMP=-fopenmp
@@ -97,7 +98,8 @@ ifeq ($(IGL_USERNAME),chrsch)
     IGL_WITH_MOSEK=0
     OPENGL_INC=-I$(DEFAULT_PREFIX)/include
     OPENGL_LIB=-lGL -lGLU
-    #GLUT_LIB=-lglut
+    # Glut is needed only for examples
+    GLUT_LIB=-lglut
     ANTTWEAKBAR_LIB=-lAntTweakBar
     OPENMP=-fopenmp
     AFLAGS = -m64

+ 1 - 0
RELEASE_HISTORY.txt

@@ -1,3 +1,4 @@
+0.2.3  More explicits, active set method, opengl/anttweakbar guards
 0.2.2  More explicit instanciations, faster sorts and uniques
 0.2.1  Bug fixes in barycenter and doublearea found by Martin Bisson
 0.2.0  XML serializer more stable and fixed bug in remove_duplicate_vertices

+ 1 - 1
VERSION.txt

@@ -3,4 +3,4 @@
 # Anyone may increment Minor to indicate a small change.
 # Major indicates a large change or large number of changes (upload to website)
 # World indicates a substantial change or release
-0.2.3
+0.2.4

+ 97 - 96
examples/svd/example.cpp

@@ -1,96 +1,97 @@
-#include <igl/svd.h>
-#include <cstdlib>
-#include <Accelerate/Accelerate.h>
-#include <cstdio>
-
-/* Auxiliary routines prototypes */
-extern void print_matrix( char* desc, int m, int n, double* a, int lda );
-
-/* Parameters */
-
-void print3x3(const char * s, double * a)
-{
-  printf("%s =\n",s);
-  for(int i = 0;i<3;i++)
-  {
-    for(int j = 0;j<3;j++)
-    {
-      printf("%g ",a[j*3+i]);
-    }
-    printf("\n");
-  }
-  printf("\n");
-}
-
-int main(int argc, char * argv[])
-{
-  //// List of rest positions
-  ////        (0,1)
-  ////         / \
-  ////        /   \
-  ////       /     \
-  ////      /       \
-  ////  (-1,0)-----(1,0)
-  ////
-  //double rest[3][3] = {
-  //  {-1,0,0},
-  //  {1,0,0},
-  //  {0,1,0}};
-  //// List of pose positions
-  //// 
-  //// (0,1)
-  ////  |   \
-  ////  |    \
-  ////  |     (1,0)
-  ////  |    /
-  ////  |   /
-  //// (0,-1)
-  //double pose[3][3] = {
-  //  {0,1,0},
-  //  {0,-1,0},
-  //  {1,0,0}};
-  //// Compute covariance matrix C
-  //double C[3*3];
-  //// Initialize to zero
-  //for(int i = 0;i<3*3;i++)
-  //{
-  //  C[i] = 0;
-  //}
-
-  //// Loop over vertices
-  //for(int i = 0;i<3;i++)
-  //{
-  //  // Compute outer product rest[i] * pose[i]
-  //  // Loop over coordinates
-  //  for(int j = 0;j<3;j++)
-  //  {
-  //    // Loop over coordinates
-  //    for(int k = 0;k<3;k++)
-  //    {
-  //      C[k*3+j] = rest[i][j] * pose[i][k];
-  //    }
-  //  }
-  //}
-  //print3x3("C",C);
-
-
-  //
-  //double C[3*3] = {8,3,4,1,5,9,6,7,2};
-  double C[3*3] = {5242.55,3364,-0,-8170.15,-5242.56,0,-0,-0,0};
-  double u[3*3],s[3],vt[3*3];
-  print3x3("C",C);
-  // Compute SVD of C
-  igl::svd3x3(C,u,s,vt);
-  print3x3("u",u);
-  print3x3("vt",vt);
-
-  // Compute R = u*vt
-  double R[3*3];
-  const double _3 = 3;
-  const double _1 = 1;
-  cblas_dgemm(CblasColMajor, CblasNoTrans,CblasNoTrans,3,3,3,1,u,3,vt,3,1,R,3);
-  print3x3("RT (transposed to be row-major)",R);
-
-
-  return 0;
-}
+int main(){}
+//#include <igl/svd.h>
+//#include <cstdlib>
+//#include <Accelerate/Accelerate.h>
+//#include <cstdio>
+//
+///* Auxiliary routines prototypes */
+//extern void print_matrix( char* desc, int m, int n, double* a, int lda );
+//
+///* Parameters */
+//
+//void print3x3(const char * s, double * a)
+//{
+//  printf("%s =\n",s);
+//  for(int i = 0;i<3;i++)
+//  {
+//    for(int j = 0;j<3;j++)
+//    {
+//      printf("%g ",a[j*3+i]);
+//    }
+//    printf("\n");
+//  }
+//  printf("\n");
+//}
+//
+//int main(int argc, char * argv[])
+//{
+//  //// List of rest positions
+//  ////        (0,1)
+//  ////         / \
+//  ////        /   \
+//  ////       /     \
+//  ////      /       \
+//  ////  (-1,0)-----(1,0)
+//  ////
+//  //double rest[3][3] = {
+//  //  {-1,0,0},
+//  //  {1,0,0},
+//  //  {0,1,0}};
+//  //// List of pose positions
+//  //// 
+//  //// (0,1)
+//  ////  |   \
+//  ////  |    \
+//  ////  |     (1,0)
+//  ////  |    /
+//  ////  |   /
+//  //// (0,-1)
+//  //double pose[3][3] = {
+//  //  {0,1,0},
+//  //  {0,-1,0},
+//  //  {1,0,0}};
+//  //// Compute covariance matrix C
+//  //double C[3*3];
+//  //// Initialize to zero
+//  //for(int i = 0;i<3*3;i++)
+//  //{
+//  //  C[i] = 0;
+//  //}
+//
+//  //// Loop over vertices
+//  //for(int i = 0;i<3;i++)
+//  //{
+//  //  // Compute outer product rest[i] * pose[i]
+//  //  // Loop over coordinates
+//  //  for(int j = 0;j<3;j++)
+//  //  {
+//  //    // Loop over coordinates
+//  //    for(int k = 0;k<3;k++)
+//  //    {
+//  //      C[k*3+j] = rest[i][j] * pose[i][k];
+//  //    }
+//  //  }
+//  //}
+//  //print3x3("C",C);
+//
+//
+//  //
+//  //double C[3*3] = {8,3,4,1,5,9,6,7,2};
+//  double C[3*3] = {5242.55,3364,-0,-8170.15,-5242.56,0,-0,-0,0};
+//  double u[3*3],s[3],vt[3*3];
+//  print3x3("C",C);
+//  // Compute SVD of C
+//  igl::svd3x3(C,u,s,vt);
+//  print3x3("u",u);
+//  print3x3("vt",vt);
+//
+//  // Compute R = u*vt
+//  double R[3*3];
+//  const double _3 = 3;
+//  const double _1 = 1;
+//  cblas_dgemm(CblasColMajor, CblasNoTrans,CblasNoTrans,3,3,3,1,u,3,vt,3,1,R,3);
+//  print3x3("RT (transposed to be row-major)",R);
+//
+//
+//  return 0;
+//}

+ 1 - 1
include/igl/ONE.h

@@ -1,6 +1,6 @@
 #ifndef IGL_ONE_H
 #define IGL_ONE_H
-// Often one needs a reference to a dummy variable containing zero as its
+// Often one needs a reference to a dummy variable containing one as its
 // value, for example when using AntTweakBar's
 // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ONE);
 namespace igl

+ 2 - 0
include/igl/ReAntTweakBar.cpp

@@ -1,4 +1,5 @@
 #include "ReAntTweakBar.h"
+#ifndef IGL_NO_ANTTWEAKBAR
 
 #include <cstdio>
 #include <cstring>
@@ -834,3 +835,4 @@ const std::vector<igl::ReTwCBItem> & igl::ReTwBar::get_cb_items()
 {
   return cb_items;
 }
+#endif

+ 2 - 0
include/igl/ReAntTweakBar.h

@@ -1,5 +1,6 @@
 #ifndef IGL_REANTTWEAKBAR_H
 #define IGL_REANTTWEAKBAR_H
+#ifndef IGL_NO_ANTTWEAKBAR
 #include "igl_inline.h"
 // ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
 // "bars" to be saved and load from disk. Changing your existing app that uses
@@ -273,3 +274,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/cocoa_key_to_anttweakbar_key.cpp

@@ -1,4 +1,5 @@
 #include "cocoa_key_to_anttweakbar_key.h"
+#ifndef IGL_NO_ANTTWEAKBAR
 
 #include <AntTweakBar.h>
 
@@ -72,3 +73,4 @@ IGL_INLINE int igl::cocoa_key_to_anttweakbar_key(int key)
   }
   return key;
 }
+#endif

+ 2 - 0
include/igl/cocoa_key_to_anttweakbar_key.h

@@ -1,5 +1,6 @@
 #ifndef IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
 #define IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
+#ifndef IGL_NO_ANTTWEAKBAR
 #include "igl_inline.h"
 
 
@@ -19,3 +20,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/create_index_vbo.cpp

@@ -1,5 +1,6 @@
 #include "create_index_vbo.h"
 
+#ifndef IGL_NO_OPENGL
 // http://www.songho.ca/opengl/gl_vbo.html#create
 IGL_INLINE void igl::create_index_vbo(
   const Eigen::MatrixXi & F,
@@ -33,6 +34,7 @@ IGL_INLINE void igl::create_index_vbo(
   // bind with 0, so, switch back to normal pointer operation
   glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
 }
+#endif
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization

+ 3 - 13
include/igl/create_index_vbo.h

@@ -1,23 +1,12 @@
 #ifndef IGL_CREATE_INDEX_VBO_H
 #define IGL_CREATE_INDEX_VBO_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 // NOTE: It wouldn't be so hard to template this using Eigen's templates
 
 #include <Eigen/Core>
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 // Create a VBO (Vertex Buffer Object) for a list of indices:
 // GL_ELEMENT_ARRAY_BUFFER_ARB for the triangle indices (F)
@@ -39,3 +28,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/create_mesh_vbo.cpp

@@ -1,4 +1,5 @@
 #include "create_mesh_vbo.h"
+#ifndef IGL_NO_OPENGL
 
 #include "create_vector_vbo.h"
 #include "create_index_vbo.h"
@@ -34,3 +35,4 @@ IGL_INLINE void igl::create_mesh_vbo(
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 #endif
+#endif

+ 3 - 13
include/igl/create_mesh_vbo.h

@@ -1,23 +1,12 @@
 #ifndef IGL_CREATE_MESH_VBO_H
 #define IGL_CREATE_MESH_VBO_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 // NOTE: It wouldn't be so hard to template this using Eigen's templates
 
 #include <Eigen/Core>
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one 
 // GL_ARRAY_BUFFER for the vertex positions (V) and one
@@ -64,3 +53,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/create_shader_program.cpp

@@ -1,4 +1,5 @@
 #include "create_shader_program.h"
+#ifndef IGL_NO_OPENGL
 
 #include "load_shader.h"
 #include "print_program_info_log.h"
@@ -70,3 +71,4 @@ IGL_INLINE bool igl::create_shader_program(
 
   return true;
 }
+#endif

+ 4 - 13
include/igl/create_shader_program.h

@@ -1,22 +1,12 @@
 #ifndef IGL_CREATE_SHADER_PROGRAM_H
 #define IGL_CREATE_SHADER_PROGRAM_H
+
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 #include <string>
 #include <map>
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -48,3 +38,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 0
include/igl/create_vector_vbo.cpp

@@ -1,4 +1,5 @@
 #include "create_vector_vbo.h"
+#ifndef IGL_NO_OPENGL
 
 #include <cassert>
 
@@ -47,3 +48,5 @@ template void igl::create_vector_vbo<int>(Eigen::Matrix<int, -1, -1, 0, -1, -1>
 // generated by autoexplicit.sh
 template void igl::create_vector_vbo<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, unsigned int&);
 #endif
+
+#endif

+ 3 - 13
include/igl/create_vector_vbo.h

@@ -1,23 +1,12 @@
 #ifndef IGL_CREATE_VECTOR_VBO_H
 #define IGL_CREATE_VECTOR_VBO_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 // NOTE: It wouldn't be so hard to template this using Eigen's templates
 
 #include <Eigen/Core>
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 // Create a VBO (Vertex Buffer Object) for a list of vectors:
 // GL_ARRAY_BUFFER for the vectors (V)
@@ -42,3 +31,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/destroy_shader_program.cpp

@@ -1,4 +1,5 @@
 #include "destroy_shader_program.h"
+#ifndef IGL_NO_OPENGL
 #include <cstdio>
 #include "report_gl_error.h"
 
@@ -36,3 +37,4 @@ IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
   glDeleteProgram(id);
   return true;
 }
+#endif

+ 3 - 13
include/igl/destroy_shader_program.h

@@ -1,20 +1,9 @@
 #ifndef IGL_DESTROY_SHADER_PROGRAM_H
 #define IGL_DESTROY_SHADER_PROGRAM_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -36,3 +25,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 10
include/igl/draw_beach_ball.cpp

@@ -1,15 +1,7 @@
 #include "draw_beach_ball.h"
+#ifndef IGL_NO_OPENGL
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/gl.h>
-#else
-#  include <GL/gl.h>
-#endif
+#include "OpenGL_convenience.h"
 
 // I'm not sure why windows would need it this way:
 // http://lists.cairographics.org/archives/cairo/2008-January/012722.html
@@ -285,3 +277,4 @@ IGL_INLINE void igl::draw_beach_ball()
 
   (cm ? glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL));
 }
+#endif

+ 2 - 0
include/igl/draw_beach_ball.h

@@ -1,5 +1,6 @@
 #ifndef IGL_DRAW_BEACH_BALL_H
 #define IGL_DRAW_BEACH_BALL_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
 namespace igl
@@ -14,3 +15,4 @@ namespace igl
 }
 
 #endif
+#endif

+ 2 - 0
include/igl/draw_mesh.cpp

@@ -1,4 +1,5 @@
 #include "draw_mesh.h"
+#ifndef IGL_NO_OPENGL
 
 IGL_INLINE void igl::draw_mesh(
   const Eigen::MatrixXd & V,
@@ -337,3 +338,4 @@ IGL_INLINE void igl::draw_mesh(
   glEnd();
 }
 
+#endif

+ 3 - 13
include/igl/draw_mesh.h

@@ -1,22 +1,11 @@
 #ifndef IGL_DRAW_MESH_H
 #define IGL_DRAW_MESH_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
 #include <Eigen/Dense>
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -110,3 +99,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 14
include/igl/draw_point.cpp

@@ -1,20 +1,8 @@
 #include "draw_point.h"
+#ifndef IGL_NO_OPENGL
 
 // Implementation
-
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 #include <cassert>
 #include <cmath>
@@ -85,3 +73,4 @@ IGL_INLINE void igl::draw_point(
   //if(old_depth_test) glEnable(GL_DEPTH_TEST);
 }
 
+#endif

+ 2 - 0
include/igl/draw_point.h

@@ -1,5 +1,6 @@
 #ifndef IGL_DRAW_POINT_H
 #define IGL_DRAW_POINT_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 namespace igl
 {
@@ -28,3 +29,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/gl_type_size.cpp

@@ -1,4 +1,5 @@
 #include "gl_type_size.h"
+#ifndef IGL_NO_OPENGL
 #include <cassert>
 
 IGL_INLINE int igl::gl_type_size(const GLenum type)
@@ -21,3 +22,4 @@ IGL_INLINE int igl::gl_type_size(const GLenum type)
   }
   return -1;
 }
+#endif

+ 3 - 13
include/igl/gl_type_size.h

@@ -1,20 +1,9 @@
 #ifndef IGL_GL_TYPE_SIZE_H
 #define IGL_GL_TYPE_SIZE_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -30,3 +19,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/load_shader.cpp

@@ -1,4 +1,5 @@
 #include "load_shader.h"
+#ifndef IGL_NO_OPENGL
 
 // Copyright Denis Kovacs 4/10/08
 #include "print_shader_info_log.h"
@@ -18,3 +19,4 @@ IGL_INLINE GLuint igl::load_shader(const char *src,const GLenum type)
   igl::print_shader_info_log(s);
   return s;
 }
+#endif

+ 3 - 13
include/igl/load_shader.h

@@ -1,20 +1,9 @@
 #ifndef IGL_LOAD_SHADER_H 
 #define IGL_LOAD_SHADER_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h" 
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -34,3 +23,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/print_gl_get.cpp

@@ -1,4 +1,5 @@
 #include "print_gl_get.h"
+#ifndef IGL_NO_OPENGL
 
 #include <cstdio>
 IGL_INLINE void igl::print_gl_get(GLenum pname)
@@ -29,3 +30,4 @@ IGL_INLINE void igl::print_gl_get(GLenum pname)
       fprintf(stderr,"ERROR in print_gl_get(), gl enum not recognized.\n");
   }
 }
+#endif

+ 3 - 12
include/igl/print_gl_get.h

@@ -1,19 +1,9 @@
 #ifndef IGL_PRINT_GL_GET_H
 #define IGL_PRINT_GL_GET_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -28,3 +18,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/print_program_info_log.cpp

@@ -1,4 +1,5 @@
 #include "print_program_info_log.h"
+#ifndef IGL_NO_OPENGL
 
 #include <cstdio>
 #include <stdlib.h>
@@ -19,3 +20,4 @@ IGL_INLINE void igl::print_program_info_log(const GLuint obj)
     free(infoLog);
   }
 }
+#endif

+ 3 - 13
include/igl/print_program_info_log.h

@@ -1,20 +1,9 @@
 #ifndef IGL_PRINT_PROGRAM_INFO_LOG_H
 #define IGL_PRINT_PROGRAM_INFO_LOG_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -28,3 +17,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/print_shader_info_log.cpp

@@ -1,4 +1,5 @@
 #include "print_shader_info_log.h"
+#ifndef IGL_NO_OPENGL
 
 #include <cstdio>
 #include <stdlib.h>
@@ -20,3 +21,4 @@ IGL_INLINE void igl::print_shader_info_log(const GLuint obj)
     free(infoLog);
   }
 }
+#endif

+ 3 - 13
include/igl/print_shader_info_log.h

@@ -1,20 +1,9 @@
 #ifndef IGL_PRINT_SHADER_INFO_LOG_H
 #define IGL_PRINT_SHADER_INFO_LOG_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -28,3 +17,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 12
include/igl/project.cpp

@@ -1,19 +1,9 @@
 #include "project.h"
+#ifndef IGL_NO_OPENGL
 #include <iostream>
 #include "report_gl_error.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#  include <OpenGL/glu.h>
-#else
-#  ifdef _WIN32
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#  endif
-#  include <GL/gl.h>
-#  include <GL/glu.h>
-#endif
+#include "OpenGL_convenience.h"
 
 IGL_INLINE int igl::project(
   const double objX,
@@ -72,3 +62,4 @@ IGL_INLINE int igl::project(
 
   return gluProject(objX,objY,objZ,MV,P,VP,winX,winY,winZ);
 }
+#endif

+ 4 - 13
include/igl/render_to_tga.cpp

@@ -1,19 +1,8 @@
 #include "render_to_tga.h"
+#ifndef IGL_NO_OPENGL
 #include "tga.h"
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 #include <cstdlib>
 
@@ -86,3 +75,5 @@ IGL_INLINE bool igl::render_to_tga(
   free(genericImage);
   return fclose(imgFile) == 0;
 }
+
+#endif

+ 2 - 0
include/igl/repdiag.cpp

@@ -1,4 +1,5 @@
 #include "repdiag.h"
+#ifndef IGL_NO_OPENGL
 
 // Bug in unsupported/Eigen/SparseExtra needs iostream first
 #include <iostream>
@@ -70,3 +71,4 @@ template void igl::repdiag<double>(Eigen::SparseMatrix<double, 0, int> const&, i
 // generated by autoexplicit.sh
 template Eigen::SparseMatrix<double, 0, int> igl::repdiag<Eigen::SparseMatrix<double, 0, int> >(Eigen::SparseMatrix<double, 0, int> const&, int);
 #endif
+#endif

+ 2 - 0
include/igl/report_gl_error.cpp

@@ -1,4 +1,5 @@
 #include "report_gl_error.h"
+#ifndef IGL_NO_OPENGL
 
 #include "verbose.h"
 
@@ -17,3 +18,4 @@ IGL_INLINE GLenum igl::report_gl_error()
 {
   return igl::report_gl_error(std::string(""));
 }
+#endif

+ 3 - 12
include/igl/report_gl_error.h

@@ -1,19 +1,9 @@
 #ifndef IGL_REPORT_GL_ERROR_H
 #define IGL_REPORT_GL_ERROR_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#  include <OpenGL/glu.h>
-#else
-#  ifdef _WIN32
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#  endif
-#  include <GL/gl.h>
-#  include <GL/glu.h>
-#endif
+#include "OpenGL_convenience.h"
 
 #include <cstdio>
 #include <string>
@@ -34,3 +24,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 13
include/igl/right_axis.cpp

@@ -1,18 +1,7 @@
 #include "right_axis.h"
+#ifndef IGL_NO_OPENGL
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 IGL_INLINE void igl::right_axis(double * x, double * y, double * z)
 {
@@ -28,3 +17,4 @@ IGL_INLINE void igl::right_axis(const double * mv,double * x, double * y, double
   *z = -mv[2*4+0];
 }
 
+#endif

+ 40 - 40
include/igl/svd.cpp

@@ -1,40 +1,40 @@
-// This only works on MAC ...
-#ifdef __APPLE__
-#include "svd.h"
-#include <Accelerate/Accelerate.h>
-#include <cstdlib>
-#include <cstdio>
-
-bool igl::svd3x3(double * a, double * u, double * s, double * vt)
-{
-  /* Locals */
-  int m = 3, n = 3, lda = 3, ldu = 3, ldvt = 3, info, lwork;
-  double wkopt;
-  double* work;
-  /* Local arrays */
-  /* iwork dimension should be at least 8*min(m,n) */
-  int iwork[8*3];
-  //double s[3], u[3*3], vt[3*3];
-  //double a[3*3] = {8,3,4,1,5,9,6,7,2};
-  /* Query and allocate the optimal workspace */
-  lwork = -1;
-  dgesdd_( 
-    "Singular vectors",
-    &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &wkopt, &lwork, iwork, &info);
-  lwork = (int)wkopt;
-  work = (double*)malloc( lwork*sizeof(double) );
-  /* Compute SVD */
-  dgesdd_(
-    "Singular vectors",
-    &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info );
-  /* Check for convergence */
-  if( info > 0 )
-  {
-    printf("The algorithm computing SVD failed to converge.\n" );
-    return false;
-  }
-  /* Free workspace */
-  free( (void*)work );
-  return true;
-}
-#endif
+//// This only works on MAC ...
+//#ifdef __APPLE__
+//#include "svd.h"
+//#include <Accelerate/Accelerate.h>
+//#include <cstdlib>
+//#include <cstdio>
+//
+//bool igl::svd3x3(double * a, double * u, double * s, double * vt)
+//{
+//  /* Locals */
+//  int m = 3, n = 3, lda = 3, ldu = 3, ldvt = 3, info, lwork;
+//  double wkopt;
+//  double* work;
+//  /* Local arrays */
+//  /* iwork dimension should be at least 8*min(m,n) */
+//  int iwork[8*3];
+//  //double s[3], u[3*3], vt[3*3];
+//  //double a[3*3] = {8,3,4,1,5,9,6,7,2};
+//  /* Query and allocate the optimal workspace */
+//  lwork = -1;
+//  dgesdd_( 
+//    "Singular vectors",
+//    &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &wkopt, &lwork, iwork, &info);
+//  lwork = (int)wkopt;
+//  work = (double*)malloc( lwork*sizeof(double) );
+//  /* Compute SVD */
+//  dgesdd_(
+//    "Singular vectors",
+//    &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info );
+//  /* Check for convergence */
+//  if( info > 0 )
+//  {
+//    printf("The algorithm computing SVD failed to converge.\n" );
+//    return false;
+//  }
+//  /* Free workspace */
+//  free( (void*)work );
+//  return true;
+//}
+//#endif

+ 25 - 23
include/igl/svd.h

@@ -1,24 +1,26 @@
-#ifndef IGL_SVD_H
-#define IGL_SVD_H
-namespace igl
-{
-  // Compute 3x3 SVD using lapack's dgesdd_ function
-  //
-  // Input:
-  //   a  pointer to 3x3 matrix in COLUMN MAJOR order
-  // Outputs:
-  //   u  pointer to 3x3 matrix in COLUMN MAJOR order
-  //   s  pointer to 3 vector 
-  //   vt  pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in
-  //     row-major order
-  // Returns true on success, false on failure
-  // 
-  // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen
-  bool svd3x3(double * a, double * u, double * s, double * vt);
-};
+//THIS DEPENDS ON BLAS. WHY? WHY NOT EIGEN?
 
-#ifdef IGL_HEADER_ONLY
-#include "svd.cpp"
-#endif
-
-#endif
+//#ifndef IGL_SVD_H
+//#define IGL_SVD_H
+//namespace igl
+//{
+//  // Compute 3x3 SVD using lapack's dgesdd_ function
+//  //
+//  // Input:
+//  //   a  pointer to 3x3 matrix in COLUMN MAJOR order
+//  // Outputs:
+//  //   u  pointer to 3x3 matrix in COLUMN MAJOR order
+//  //   s  pointer to 3 vector 
+//  //   vt  pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in
+//  //     row-major order
+//  // Returns true on success, false on failure
+//  // 
+//  // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen
+//  bool svd3x3(double * a, double * u, double * s, double * vt);
+//};
+//
+//#ifdef IGL_HEADER_ONLY
+//#include "svd.cpp"
+//#endif
+//
+//#endif

+ 3 - 0
include/igl/texture_from_tga.cpp

@@ -1,4 +1,5 @@
 #include "texture_from_tga.h"
+#ifndef IGL_NO_OPENGL
 
 #include "tga.h"
 #include "report_gl_error.h"
@@ -59,3 +60,5 @@ IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
     img->pixels);
   return id;
 }
+
+#endif

+ 3 - 13
include/igl/texture_from_tga.h

@@ -1,20 +1,9 @@
 #ifndef IGL_TEXTURE_FROM_TGA_H
 #define IGL_TEXTURE_FROM_TGA_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 #include <string>
 
@@ -35,3 +24,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 2 - 0
include/igl/tga.cpp

@@ -46,6 +46,7 @@
 #include <assert.h>
 
 #include "tga.h"
+#ifndef IGL_NO_OPENGL
 
 
 static char error[256];
@@ -548,3 +549,4 @@ void igl::writeTGA( igl::gliGenericImage* image, FILE *fp) {
   fwrite(image->pixels, image->height*image->width*image->components, sizeof(char),fp);
 }
 
+#endif

+ 3 - 13
include/igl/tga.h

@@ -1,5 +1,6 @@
 #ifndef IGL_TGA_H
 #define IGL_TGA_H
+#ifndef IGL_NO_OPENGL
 // See license in tga.cpp
 
 /* tga.h - interface for TrueVision (TGA) image file loader */
@@ -10,19 +11,7 @@
 #include <windows.h>
 #endif
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -108,3 +97,4 @@ void writeTGA( gliGenericImage* image, FILE *fp);
 #endif
 
 #endif 
+#endif 

+ 2 - 0
include/igl/uniform_type_to_string.cpp

@@ -1,4 +1,5 @@
 #include "uniform_type_to_string.h"
+#ifndef IGL_NO_OPENGL
 
 IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type)
 {
@@ -62,3 +63,4 @@ IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type)
       return "UNKNOWN_TYPE";
   }
 }
+#endif

+ 3 - 13
include/igl/uniform_type_to_string.h

@@ -1,22 +1,11 @@
 #ifndef IGL_UNIFORM_TYPE_TO_STRING_H
 #define IGL_UNIFORM_TYPE_TO_STRING_H
+#ifndef IGL_NO_OPENGL
 #include "igl_inline.h"
 
 #include <string>
 
-#ifdef __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#  define NOMINMAX
-#  include <Windows.h>
-#  undef NOMINMAX
-#  include <GL/glew.h>
-#  include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 namespace igl
 {
@@ -33,3 +22,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 3 - 12
include/igl/unproject.cpp

@@ -1,17 +1,7 @@
 #include "unproject.h"
+#ifndef IGL_NO_OPENGL
 
-#ifdef __APPLE__
-# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
-#else
-#  ifdef _WIN32
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#  endif
-# include <GL/gl.h>
-# include <GL/glu.h>
-#endif
+#include "OpenGL_convenience.h"
 
 IGL_INLINE int igl::unproject(
   const double winX,
@@ -30,3 +20,4 @@ IGL_INLINE int igl::unproject(
   glGetIntegerv(GL_VIEWPORT, VP);
   return gluUnProject(winX,winY,winZ,MV,P,VP,objX,objY,objZ);
 }
+#endif

+ 3 - 12
include/igl/unproject_to_zero_plane.cpp

@@ -1,17 +1,7 @@
 #include "unproject_to_zero_plane.h"
+#ifndef IGL_NO_OPENGL
 
-#ifdef __APPLE__
-# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
-#else
-#  ifdef _WIN32
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#  endif
-# include <GL/gl.h>
-# include <GL/glu.h>
-#endif
+#include "OpenGL_convenience.h"
 
 #include "project.h"
 #include "unproject.h"
@@ -28,3 +18,4 @@ IGL_INLINE int igl::unproject_to_zero_plane(
   return igl::unproject(winX, winY, winOrigin[2], objX, objY, objZ);
 }
 
+#endif

+ 3 - 13
include/igl/up_axis.cpp

@@ -1,18 +1,7 @@
 #include "up_axis.h"
+#ifndef IGL_NO_OPENGL
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 IGL_INLINE void igl::up_axis(double * x, double * y, double * z)
 {
@@ -28,3 +17,4 @@ IGL_INLINE void igl::up_axis(const double *mv, double * x, double * y, double *
   *z = -mv[2*4+1];
 }
 
+#endif

+ 3 - 13
include/igl/view_axis.cpp

@@ -1,18 +1,7 @@
 #include "view_axis.h"
+#ifndef IGL_NO_OPENGL
 
-#if __APPLE__
-#  include <OpenGL/gl.h>
-#elif defined(_WIN32)
-#    define NOMINMAX
-#    include <Windows.h>
-#    undef NOMINMAX
-#    include <GL/glew.h>
-#    include <GL/gl.h>
-#else
-#  define GL_GLEXT_PROTOTYPES
-#  include <GL/gl.h>
-#  include <GL/glext.h>
-#endif
+#include "OpenGL_convenience.h"
 
 IGL_INLINE void igl::view_axis(double * x, double * y, double * z)
 {
@@ -27,3 +16,4 @@ IGL_INLINE void igl::view_axis(const double * mv, double * x, double * y, double
   *y = -mv[1*4+2];
   *z = -mv[2*4+2];
 }
+#endif

+ 0 - 1
readme.txt

@@ -14,7 +14,6 @@ listed below.
 Eigen3  Last tested with Eigen Version 3.1.2
 AntTweakBar  Last tested 1.14 (see External)
 OpenGL
-GLUT
 GLEW  Windows only
 
   = Optional =

+ 3 - 0
scripts/compress.sh

@@ -35,6 +35,8 @@ rm -f $H_OUT
 rm -f $CPP_OUT
 
 HEADER="
+Automatically generated by libigl/scripts/compress.sh **Do not edit**
+
 libigl - A simple c++ geometry processing library
 
 http://igl.ethz.ch/projects/libigl/
@@ -128,6 +130,7 @@ fi
 echo "Compile with:"
 echo ""
 echo "    g++ -o igl.o -c igl.cpp -I/opt/local/include/eigen3"
+echo "    rm -f libigl.a"
 echo "    ar cqs libigl.a igl.o"
 echo "    rm igl.o"
 echo ""

+ 54 - 5
style.css

@@ -8,6 +8,7 @@ tr.header th
   background-color: #ffb;
   padding-left: 10px;
   padding-right: 20px;
+  text-align: left;
 }
 tr.d0 td 
 {
@@ -120,22 +121,70 @@ img.center
   margin-right: auto;
 }
 
-.article_body
+body, html
 {
   margin: 0px;
   padding: 0px;
-  text-align: center;
   background-color: #bbb;
+  font-family: "HelveticaNeueLight", "HelveticaNeue-Light", "Helvetica Neue Light", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosRegular', "Helvetica", "Tahoma", "Geneva", "Arial", sans-serif; font-weight:300; font-stretch:normal;
+  height: 100%;
+}
+
+.article_outer
+{
+  padding: 0px;
+  margin:0px auto;
+  /* 600px = 2*300px wider that article_inner*/
+  width: 1415px;
 }
 
-.article
+.article_inner
 {
+  padding: 20px;
+  position:relative;
   font-size: 14pt;
   background-color: #fff;
   margin:0px auto;
-  padding: 20px;
   border-left: 1px solid #888;
   border-right: 1px solid #888;
-  width: 960px;
+  width: 815px;
   text-align: left;
 }
+
+#container
+{
+  position:absolute;
+  top:0px;
+  bottom: -0px;
+  left:0px;
+  right:0px;
+  overflow:auto;
+}
+
+#fixed_sidebar
+{
+  margin: 0px;
+  position:absolute;
+  padding: 5px 10px;
+  top:10px;
+  left:0px;
+  right:0px;
+  background-color: #fff;
+  overflow:hidden;
+  width: 250px;
+  z-index:100;
+  border-right: 1px solid #888;
+  border-top: 1px solid #888;
+  border-bottom: 1px solid #888;
+}
+ul
+{
+  margin:0px;
+  padding: 0px 20px;
+  list-style-type:none;
+}
+li { font-size: 100% }
+li li { font-size: 90% }
+li li li { font-size: 80% }
+li li li li { font-size: 70% }
+li li li li li { font-size: 60%}

+ 158 - 62
tutorial.html

@@ -3,24 +3,53 @@
     <title>libigl developer tutorial</title>
     <link href="./style.css" rel="stylesheet" type="text/css">
   </head>
-  <body class=article_body>
-    <div class=article>
-    <a href=.><img src=libigl-logo.jpg alt="igl logo" class=center></a>
-    <h1>Using the libigl library</h1>
-    <p>
-      The <a href=.>libigl</a> library is a collection of useful/reusable/sharable C++ functions
-      with very few external <a href="#dependencies">dependencies</a>. The
-      library may be used as a <a href="#header_library">"headers only"
-      library</a> or a <a href=#static_library>statically linked library</a>.
-    </p>
+  <body>
+    <div id=fixed_sidebar>
+      <ul>
+        <li>
+          <a href=#header_library>Headers (.h) only library</a>
+          <ul>
+            <li><a href=#widget>IGL_HEADER_ONLY widget</a></li>
+            <li><a href=#header_benefits_drawbacks>Benefits and drawbacks</a></li>
+          </ul>
+        </li>
+        <li> 
+          <a href=#static_library>Statically linked library (libigl.a)</a>
+          <ul>
+            <li><a href=#static_benefits_drawbacks>Benefits and drawbacks</a></li>
+          </ul>
+        </li>
+        <li> 
+          <a href=#compress>Compressed igl.h/igl.cpp pair</a>
+          <ul>
+            <li><a href=#compress_benefits_drawbacks>Benefits and drawbacks</a></li>
+          </ul>
+        </li>
+        <li>
+          <a href=#dependencies>Dependencies</a>
+        </li>
+        <li><a href=#matlab>Conversion from matlab</a>
+      <ul>
+    </div> 
+    <div id=container>
+    <div class=article_outer>
+    <div class=article_inner>
+      <a href=.><img src=libigl-logo.jpg alt="igl logo" class=center></a>
+      <h1>Using the libigl library</h1>
+      <p>
+        The <a href=.>libigl</a> library is a collection of useful/reusable/sharable C++ functions
+        with very few external <a href="#dependencies">dependencies</a>. The
+        library may be used as a <a href="#header_library">"headers only"
+        library</a>, a <a href=#static_library>statically linked library</a>, or as a compressed <a href="#compress">.h/.cpp pair</a>.
+      </p>
 
-    <p>
-      This duality is illustrated in the example
-      <code>examples/example_fun</code>. When built this example compiles two
-      binaries, one using the <code>example_fun</code> routine of the igl
-      library, either as a headers-only library or linking against the igl
-      static library.
-    </p>
+      <p>
+        This duality between statically compiled and header-only is illustrated
+        in the example <code>examples/example_fun</code>. When built, this example
+        compiles two binaries, one using the <code>example_fun</code> routine of
+        the igl library, either as a headers-only library or linking against the
+        igl static library.
+      </p>
 
       <h2 id=header_library>Headers (.h) only library</h2>
       <p>
@@ -40,7 +69,7 @@
         at compile time if need be.
       </p>
 
-      <p>
+      <p id=widget>
         One may also define <code>IGL_HEADER_ONLY</code> not only on a per-file
         basis, but a <i>per-include</i> basis. For example it may be useful for a
         project to use the static library for most functionality from IGL, but then
@@ -70,7 +99,7 @@
       purposes.</div>
       
 
-      <h3>Benefits of headers-only library</h3>
+      <h3 id=header_benefits_drawbacks>Benefits of headers-only library</h3>
       <ul>
         <li><strong>Easy templates:</strong> When using the libigl library as a
         headers-only library no special care need be taken when using templated
@@ -189,7 +218,7 @@ make clean
 make
         </code></pre>
 
-        <h3>Benefits of static library</h3>
+        <h3 id=static_benefits_drawbacks>Benefits of static library</h3>
         <ul>
           <li><strong>Faster compile time:</strong> Because the libigl library
           is already compiled, only the new code in ones project must be
@@ -208,35 +237,107 @@ make
           exposing templated functions.</li>
         </ul>
 
+      <h2 id=compress>Compressed .h/.cpp pair</h2>
+      <p>Calling the script:</p>
+      <pre><code>scripts/compress.sh igl.h igl.cpp</code></pre>
+      <p>will create a single header
+      <code>igl.h</code> and a single cpp file <code>igl.cpp</code>. 
+
+      <p>Alternatively, you can also compress everything into a single header file (analagous to IGL_HEADER_ONLY):</p>
+      <pre><code>scripts/compress.sh igl.h</code></pre>
+      
+      <h3 id=compress_benefits_drawbacks>Benefits of compressed .h/.cpp pair</h3>
+      <ul>
+        <li><strong>Easy incorporation:</strong> This can be easily incorporated
+        into external projects.</li>
+      </ul>
+      <h3>Drawbacks of compressed .h/.cpp pair</h3>
+      <ul>
+        <li><strong>Hard to debug/edit:</strong> The compressed files are
+        automatically generated. They're huge and should not be edited. Thus
+        debugging and editting are near impossible.</li>
+        <li><strong>Compounded dependencies:</strong>
+        An immediate disadvantage of this
+        seems to be that even to use a single function (e.g.
+        <code>cotmatrix</code>), compiling and linking against
+        <code>igl.cpp</code> will require linking to all of <code>libigl</code>'s
+        dependencies (<code>OpenGL</code>, <code>GLUT</code>,
+        <code>AntTweakBar</code>, <code>BLAS</code>). However, because all
+        depencies other than Eigen should be encapsulated between
+        <code>#ifndef</code> guards (e.g. <code>#ifndef IGL_NO_OPENGL</code>, it
+        is possible to ignore certain functions that have such dependencies.</li>
+        <li><strong>Long compile:</strong> Compiling <code>igl.cpp</code> takes a long time and isn't easily parallelized (no <code>make -j12</code> equivalent).</li>
+      </ul>
+
+      <p>Here's a tiny test example using <code>igl.h</code> and <code>igl.cpp</code>. Save the following in <code>test.cpp</code>:</p>
+      <pre><code>
+#include &lt;igl.h&gt;
+#include &lt;Eigen/Core&gt;
+
+int main(int argc, char * argv[])
+{
+  Eigen::MatrixXd V;
+  Eigen::MatrixXi F;
+  return (argc&gt;=2 &amp;&amp; igl::read(argv[1],V,F)?0:1);
+}
+      </code></pre>
+      <p>Then compile <code>igl.cpp</code> with:
+      <pre><code>
+g++ -o igl.o -c igl.cpp -I/opt/local/include/eigen3 -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR
+      </code></pre>
+      <p>Notice that we're using <code>-DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR</code> to disable any libigl dependencies on OpenGL and AntTweakBar.</p>
+
+      <p>Now compile <code>test.cpp</code> with:
+      <pre><code>
+g++ -g -I/opt/local/include/eigen3/ -I/usr/local/igl/libigl/ -L/usr/local/igl/libigl/ -ligl -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR -o test
+      </code></pre>
+
+      <p>Try running it with:</p>
+      <pre><code>
+./test path/to/mesh.obj
+      </code></pre>
+
       <h2 id="dependencies">Dependencies</h2>
       <p>
         By design the libigl library has very few external dependencies.
       </p>
         <h3>Mandatory dependencies</h3>
-        <p>
-          Besides the standard C++ library, there are a few dependencies,
-          without which the main library will not compile or work properly.
-          These are:
+        <p> <a href=http://eigen.tuxfamily.org/>Eigen3</a> and the Standard
+        Template Library (STL) are the only truly mandatory dependencies.
+        Without them libigl will not compile or work properly.</p>
+        <p> OpenGL is an <i>assumed</i> dependency, but is in fact also
+        optional. All OpenGL-dependent functions may be disabled by defining
+        the <code>IGL_NO_OPENGL</code> preprocessor macro.</p>
         </p>
-        <ul>
-          <li><a href=http://eigen.tuxfamily.org/>Eigen3</a></li>
-          <li>OpenGL <span class=todo>implement IGL_NO_OPENGL compiler option</span></li>
-          <li>GLUT <span class=todo>implement IGL_NO_GLUT compiler option</span></li>
-        </ul>
+        <p> Likewise, 
+          <a href="http://www.antisphere.com/Wiki/tools:anttweakbar">AntTweakBar</a>
+          is an 
+        <i>assumed</i> dependency, similarly diabled by defining 
+        the <code>IGL_NO_ANTTWEAKBAR</code> preprocessor macro.</p>
+
+        <p><span class=todo>Each IGL_NO_XXX should just be replaced by a libiglXXX.a extra</span></p>
         <h3>Optional dependencies</h3>
         <p>
-          Certain functions and classes included the libigl library have
-          external dependencies by construction (e.g. the matlab_interface
-          routines are only useful when matlab is present anyway). These are
-          <strong>never</strong> compiled by default into the static igl
-          library <span class=todo>and are only exposed through compiler
-          options</span>. These are:
+          Certain <i>extra</i> functions and classes included the libigl
+          library have external dependencies by construction (e.g. the
+          matlab_interface routines are only useful when matlab is present
+          anyway). These are <strong>never</strong> compiled by default into
+          the static igl library, rather they are compiled as "extras" (e.g.
+          libiglmatlab.a contains the MATLAB-dependent functions).
         </p>
-        <ul>
-          <li>MATLAB</li>
-          <li><a href="http://www.antisphere.com/Wiki/tools:anttweakbar">AntTweakBar</a></li>
-        </ul>
-      <h1>Converting matlab code to C++ using IGL and Eigen</h1>
+        <p>Currently these include:<p>
+        <table>
+          <tr class=header><th>Extra</th><th>Dependency</th></tr>
+          <tr class=d0><td>libiglmatlab.a</td><td>MATLAB</td></tr>
+          <tr class=d1><td>libiglmosek.a</td><td>Mosek</td></tr>
+          <tr class=d0><td>libigltetgen.a</td><td>TetGen</td></tr>
+          <tr class=d1><td>libiglxml.a</td><td>TinyXml2</td></tr>
+          <tr class=d0><td>libiglpng.a</td><td>LibPNG</td></tr>
+          <tr class=d1><td>libiglembree.a</td><td>Embree</td></tr>
+        </table>
+        <p>Some of our examples (<code>libigl/examples</code>) also depend on GLUT.</p>
+
+      <h2 id=matlab>Converting matlab code to C++ using IGL and Eigen</h2>
       <p>
         Eigen's matrix API often makes it fairly to translate to and from
         matlab code (Eigen provides a <a
@@ -246,10 +347,17 @@ make
         href="matlab-to-eigen.html">Our own translation table</a> shows a list
         of common matlab functions and their igl-eigen equivalents.  
       </p>
-      <p>See also: <a href=style_guidelines.html>style guidlines</a>, <a
-      href=doc.html>auto-documentation</a>, <a
-      href=file-formats/index.html>file formats</a></p>
+
       <h3>Including OpenGL</h3>
+      <p>Just include the convenience header, which takes care of system dependent paths, <code>glew</code>, etc.:</p>
+      <pre><code>
+#include "OpenGL_convenience.h"
+      </code></pre>
+      <!--<p>Likewise for GLUT:</p>
+      <pre><code>
+#include "GLUT_convenience.h"
+      </code></pre>-->
+      <del>
       <p>
       A standard include for the OpenGL headers should be placed in the .cpp file if possible. To ensure compilability on Mac OS X, Windows and Linux, use:
       <pre><code>
@@ -268,7 +376,7 @@ make
 #endif
       </code></pre>
       </p>
-      <p><span class=todo>This should be encapsulated in a single utility header</span></p>
+      </del>
       <h3>Including headers to other igl functions</h3>
       <p>
       Source files in the main igl directory should include other libigl headers using the name of the file in quotation marks:
@@ -290,26 +398,14 @@ make
 #include &lt;igl/extra/some_extra_function.h&gt;
       </code></pre>
 
-      <h2 id=compress>Compressing into a single  .h/.cpp pair</h2>
-      <p>Calling the script:</p>
-      <pre><code>scripts/compress.sh igl.h igl.cpp</code></pre>
-      <p>will create a single header
-      <code>igl.h</code> and a single cpp file <code>igl.cpp</code>. This can
-      be easily incorporated into external projects. The disadvantage of this
-      seems to be that even to use a single function (e.g.
-      <code>cotmatrix</code>), compiling and linking against
-      <code>igl.cpp</code> will require linking to all of <code>libigl</code>'s
-      dependencies (<code>OpenGL</code>, <code>GLUT</code>,
-      <code>AntTweakBar</code>, <code>BLAS</code>).</p>
-
-      <p>Alternatively, you can compress everything into a single header file (analagous to IGL_HEADER_ONLY):</p>
-      <pre><code>scripts/compress.sh igl.h</code></pre>
-      <p>This seems to have the seem linking dependency troubles as above.</p>
-
-      <p><span class=todo>One option would be to be better about enclosing
-      things in <code>#ifndef IGL_NO_ANTTWEAKBAR</code> type guards.</span></p>
 
+      <hr>
+      <p>See also: <a href=style_guidelines.html>style guidlines</a>, <a
+      href=doc.html>auto-documentation</a>, <a
+      href=file-formats/index.html>file formats</a></p>
 
+  </div>
+  </div>
   </div>
   </body>
 </html>