Browse Source

move opengl functions to separate directories, lots of new templates

Former-commit-id: 577624e17e9ef3e23d670dfa13bdc737ab710939
Alec Jacobson 10 years ago
parent
commit
945ca3ac82
100 changed files with 1115 additions and 1531 deletions
  1. 3 3
      examples/Makefile.conf
  2. 8 8
      examples/ambient-occlusion/example.cpp
  3. 0 1
      examples/arap/Makefile
  4. 7 7
      examples/arap/example.cpp
  5. 16 16
      examples/beach-balls/BeachBall.cpp
  6. 2 2
      examples/beach-balls/example.cpp
  7. 8 8
      examples/camera/example.cpp
  8. 7 7
      examples/colored-mesh/example.cpp
  9. 1 1
      examples/components/Makefile
  10. 16 16
      examples/components/example.cpp
  11. 19 19
      examples/embree/example.cpp
  12. 16 16
      examples/flare-eyes/example.cpp
  13. 8 8
      examples/intersections/example.cpp
  14. 16 16
      examples/multi-viewport/example.cpp
  15. 1 1
      examples/patches/Makefile
  16. 8 8
      examples/patches/example.cpp
  17. 6 6
      examples/randomly-sample-mesh/example.cpp
  18. 8 8
      examples/rotate-widget/example.cpp
  19. 6 6
      examples/scene-rotation/example.cpp
  20. 1 1
      examples/scene-rotation/trackball.cpp
  21. 6 6
      examples/shadow-mapping/example.cpp
  22. 39 27
      examples/skeleton-builder/example.cpp
  23. 15 14
      examples/skeleton-poser/example.cpp
  24. 10 10
      examples/skeleton/example.cpp
  25. 7 8
      examples/textured-mesh/example.cpp
  26. 1 1
      examples/transparency/Makefile
  27. 12 12
      examples/transparency/example.cpp
  28. 5 5
      examples/upright/example.cpp
  29. 1 1
      include/igl/bounding_box_diagonal.cpp
  30. 1 1
      include/igl/cgal/mesh_to_polyhedron.cpp
  31. 1 1
      include/igl/cgal/polyhedron_to_mesh.cpp
  32. 1 0
      include/igl/colon.cpp
  33. 0 33
      include/igl/compile_and_link_program.h
  34. 0 38
      include/igl/compile_shader.h
  35. 1 0
      include/igl/components.cpp
  36. 0 63
      include/igl/create_mesh_vbo.h
  37. 0 65
      include/igl/create_shader_program.h
  38. 0 35
      include/igl/destroy_shader_program.h
  39. 1 1
      include/igl/directed_edge_orientations.cpp
  40. 1 1
      include/igl/directed_edge_parents.cpp
  41. 1 1
      include/igl/dqs.cpp
  42. 0 58
      include/igl/draw_floor.h
  43. 0 121
      include/igl/draw_mesh.h
  44. 0 45
      include/igl/draw_point.h
  45. 0 36
      include/igl/draw_rectangular_marquee.h
  46. 0 54
      include/igl/draw_skeleton_3d.h
  47. 0 53
      include/igl/draw_skeleton_vector_graphics.h
  48. 7 2
      include/igl/embree/EmbreeIntersector.h
  49. 1 1
      include/igl/embree/ambient_occlusion.cpp
  50. 1 1
      include/igl/embree/bone_visible.cpp
  51. 15 62
      include/igl/embree/unproject_in_mesh.cpp
  52. 30 42
      include/igl/embree/unproject_in_mesh.h
  53. 1 1
      include/igl/embree/unproject_onto_mesh.cpp
  54. 1 1
      include/igl/fit_rotations.cpp
  55. 0 1
      include/igl/flare_textures.h.REMOVED.git-id
  56. 1 1
      include/igl/forward_kinematics.cpp
  57. 1 1
      include/igl/group_sum_matrix.cpp
  58. 1 1
      include/igl/harmonic.cpp
  59. 0 39
      include/igl/init_render_to_texture.h
  60. 0 92
      include/igl/lens_flare.h
  61. 1 1
      include/igl/lim/lim.cpp
  62. 0 33
      include/igl/load_shader.h
  63. 2 5
      include/igl/opengl/OpenGL_convenience.h
  64. 4 6
      include/igl/opengl/compile_and_link_program.cpp
  65. 32 0
      include/igl/opengl/compile_and_link_program.h
  66. 4 8
      include/igl/opengl/compile_shader.cpp
  67. 38 0
      include/igl/opengl/compile_shader.h
  68. 1 3
      include/igl/opengl/create_index_vbo.cpp
  69. 14 15
      include/igl/opengl/create_index_vbo.h
  70. 2 4
      include/igl/opengl/create_mesh_vbo.cpp
  71. 64 0
      include/igl/opengl/create_mesh_vbo.h
  72. 11 9
      include/igl/opengl/create_shader_program.cpp
  73. 66 0
      include/igl/opengl/create_shader_program.h
  74. 3 5
      include/igl/opengl/create_vector_vbo.cpp
  75. 17 17
      include/igl/opengl/create_vector_vbo.h
  76. 6 3
      include/igl/opengl/destroy_shader_program.cpp
  77. 36 0
      include/igl/opengl/destroy_shader_program.h
  78. 1 3
      include/igl/opengl/gl_type_size.cpp
  79. 10 10
      include/igl/opengl/gl_type_size.h
  80. 1 5
      include/igl/opengl/init_render_to_texture.cpp
  81. 38 0
      include/igl/opengl/init_render_to_texture.h
  82. 2 4
      include/igl/opengl/load_shader.cpp
  83. 34 0
      include/igl/opengl/load_shader.h
  84. 1 3
      include/igl/opengl/print_program_info_log.cpp
  85. 9 8
      include/igl/opengl/print_program_info_log.h
  86. 1 3
      include/igl/opengl/print_shader_info_log.cpp
  87. 9 8
      include/igl/opengl/print_shader_info_log.h
  88. 3 2
      include/igl/opengl/render_to_tga.cpp
  89. 38 0
      include/igl/opengl/render_to_tga.h
  90. 60 0
      include/igl/opengl/report_gl_error.cpp
  91. 13 12
      include/igl/opengl/report_gl_error.h
  92. 4 3
      include/igl/opengl/texture_from_tga.cpp
  93. 14 13
      include/igl/opengl/texture_from_tga.h
  94. 8 10
      include/igl/opengl/tga.cpp
  95. 6 5
      include/igl/opengl/tga.h
  96. 1 3
      include/igl/opengl/uniform_type_to_string.cpp
  97. 12 11
      include/igl/opengl/uniform_type_to_string.h
  98. 142 139
      include/igl/opengl2/MouseController.h
  99. 86 83
      include/igl/opengl2/RotateWidget.h
  100. 2 4
      include/igl/opengl2/draw_beach_ball.cpp

+ 3 - 3
examples/Makefile.conf

@@ -18,7 +18,7 @@ CFLAGS += -std=c++11
 ifeq ($(UNAME), Linux)
 	DEFAULT_PREFIX=/usr/local/
 else
-	DEFAULT_PREFIX=/opt/local/
+	DEFAULT_PREFIX=/usr/local/
 	# I guess arch only works in Mac OSX
 	AFLAGS+=-arch x86_64 -m64 -march=corei7-avx
 endif
@@ -66,7 +66,7 @@ ifeq ($(IGL_USERNAME),ajx)
 #AFLAGS = -m64 -march="corei7-avx"
 	# msse4.2 is necessary for me to get embree to compile correctly
 	AFLAGS=-m64 -msse4.2
-	OPENMP=-fopenmp
+	#OPENMP=-fopenmp
 	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
 	#EIGEN3_INC=-I/Users/ajx/Documents/eigen -I/Users/ajx/Documents/eigen/unsupported
 endif
@@ -246,7 +246,7 @@ endif
 
 ifdef LIBIGL_USE_STATIC_LIBRARY
 	CFLAGS += -DIGL_STATIC_LIBRARY
-	LIBIGL_LIB=-L$(LIBIGL)/lib -ligl
+	LIBIGL_LIB=-L$(LIBIGL)/lib -ligl -liglopengl2 -liglopengl
 endif
 
 OPTFLAGS+=-O3 -DNDEBUG $(OPENMP)

+ 8 - 8
examples/ambient-occlusion/example.cpp

@@ -1,11 +1,11 @@
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_vertex_normals.h>
 #include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
 #include <igl/readOFF.h>
@@ -76,7 +76,7 @@ void reshape(int width,int height)
   TwWindowSize(width, height);
 }
 
-// Set up projection and model view of scene
+// Set up igl::opengl2::projection and model view of scene
 void push_scene()
 {
   using namespace igl;
@@ -204,7 +204,7 @@ void display()
   // Draw the model
   // Set material properties
   glEnable(GL_COLOR_MATERIAL);
-  draw_mesh(V,F,N,C);
+  igl::opengl2::draw_mesh(V,F,N,C);
 
   pop_object();
 
@@ -215,12 +215,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 0 - 1
examples/arap/Makefile

@@ -2,7 +2,6 @@
 
 # Shared flags etc.
 include ../Makefile.conf
-LIBIGL_LIB+=-liglsvd3x3
 
 all: example
 

+ 7 - 7
examples/arap/example.cpp

@@ -1,12 +1,12 @@
 #include <igl/Camera.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/PI.h>
 #include <igl/STR.h>
 #include <igl/arap.h>
 #include <igl/barycenter.h>
 #include <igl/cotmatrix.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/harmonic.h>
 #include <igl/invert_diag.h>
@@ -27,7 +27,7 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -420,7 +420,7 @@ void display()
   //glMaterialf (GL_BACK, GL_SHININESS, 128);
   glEnable(GL_COLOR_MATERIAL);
 
-  draw_mesh(U,F,N,C);
+  igl::opengl2::draw_mesh(U,F,N,C);
   glDisable(GL_COLOR_MATERIAL);
 
   pop_object();
@@ -435,12 +435,12 @@ void display()
   //const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
 
   //draw_floor(GREY,DARK_GREY);
-  draw_floor();
+  igl::opengl2::draw_floor();
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 16 - 16
examples/beach-balls/BeachBall.cpp

@@ -1,11 +1,11 @@
 #include "BeachBall.h"
 
 
-#include <igl/draw_beach_ball.h>
+#include <igl/opengl2/draw_beach_ball.h>
 #include <igl/quat_to_mat.h>
-#include <igl/unproject_to_zero_plane.h>
-#include <igl/unproject.h>
-#include <igl/project.h>
+#include <igl/opengl2/unproject_to_zero_plane.h>
+#include <igl/opengl2/unproject.h>
+#include <igl/opengl2/project.h>
 #include <igl/quat_mult.h>
 #include <igl/quat_conjugate.h>
 #include <igl/trackball.h>
@@ -76,7 +76,7 @@ void BeachBall::draw()
   glPushMatrix();
   glScaled(radius,radius,radius);
   // draw oriented glyph 
-  draw_beach_ball();
+  igl::opengl2::draw_beach_ball();
   // Pop scale
   glPopMatrix();
   // Reset lighting
@@ -93,8 +93,8 @@ bool BeachBall::in(const int x,const int y) const
   push();
   // Now origin is center of object
   double obj[3];
-  // Check if unprojected screen point is nearby
-  unproject_to_zero_plane(x,y, &obj[0], &obj[1], &obj[2]);
+  // Check if igl::opengl2::unprojected screen point is nearby
+  igl::opengl2::unproject_to_zero_plane(x,y, &obj[0], &obj[1], &obj[2]);
   bool near = (obj[0]*obj[0] + obj[1]*obj[1] + obj[2]*obj[2])<radius*radius;
   pop();
   popmv();
@@ -136,7 +136,7 @@ bool BeachBall::drag(const int x,const int y)
     pushmv();
     push();
     double origin[3];
-    project(0,0,0,&origin[0],&origin[1],&origin[2]);
+    igl::opengl2::project(0,0,0,&origin[0],&origin[1],&origin[2]);
     pop();
     popmv();
     double rot[4];
@@ -193,20 +193,20 @@ bool BeachBall::drag(const int x,const int y)
   }else
   {
     // We want that origin follows mouse move. First define plane we
-    // projecteing screen mouse movement to as perpendicular plan passing
+    // igl::opengl2::projecteing screen mouse movement to as perpendicular plan passing
     // through this origin.
     pushmv();
-    // down_t projected to screen to get depth value
+    // down_t igl::opengl2::projected to screen to get depth value
     double p[3];
-    project(down_t[0],down_t[1],down_t[2],&p[0],&p[1],&p[2]);
-    // unprojected down_x,down_y with down_t depth
+    igl::opengl2::project(down_t[0],down_t[1],down_t[2],&p[0],&p[1],&p[2]);
+    // igl::opengl2::unprojected down_x,down_y with down_t depth
     double du[3];
-    unproject(down_x,down_y,p[2],&du[0],&du[1],&du[2]);
-    // unprojected x,y with down_t depth
+    igl::opengl2::unproject(down_x,down_y,p[2],&du[0],&du[1],&du[2]);
+    // igl::opengl2::unprojected x,y with down_t depth
     double u[3];
-    unproject(x,y,p[2],&u[0], &u[1], &u[2]);
+    igl::opengl2::unproject(x,y,p[2],&u[0], &u[1], &u[2]);
     popmv();
-    // Then move this origin according to project mouse displacment
+    // Then move this origin according to igl::opengl2::project mouse displacment
     t[0] = down_t[0] + (u[0]-du[0]);
     t[1] = down_t[1] + (u[1]-du[1]);
     t[2] = down_t[2] + (u[2]-du[2]);

+ 2 - 2
examples/beach-balls/example.cpp

@@ -1,7 +1,7 @@
 #include "BeachBall.h"
 
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/trackball.h>
 #include <igl/canonical_quaternions.h>
 #include <igl/PI.h>
@@ -135,7 +135,7 @@ void display()
   //  }
   //}
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
   glutSwapBuffers();
   glutPostRedisplay();
 

+ 8 - 8
examples/camera/example.cpp

@@ -2,7 +2,7 @@
 #include <igl/Viewport.h>
 #include <igl/Camera.h>
 #include <igl/matlab_format.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
@@ -10,12 +10,12 @@
 #include <igl/EPS.h>
 #include <igl/get_seconds.h>
 #include <igl/material_colors.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/readOFF.h>
 #include <igl/per_face_normals.h>
-#include <igl/draw_floor.h>
-#include <igl/project.h>
-#include <igl/unproject.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/project.h>
+#include <igl/opengl2/unproject.h>
 
 #include <Eigen/Core>
 #include <Eigen/Geometry>
@@ -354,7 +354,7 @@ void draw_scene(const igl::Camera & v_camera,
   glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
   glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
   glMaterialf (GL_BACK, GL_SHININESS, 128);
-  draw_mesh(V,F,N);
+  igl::opengl2::draw_mesh(V,F,N);
   glDisable(GL_LIGHTING);
   glEnable(GL_COLOR_MATERIAL);
   //glLineWidth(3.f);
@@ -365,7 +365,7 @@ void draw_scene(const igl::Camera & v_camera,
   {
     glPushMatrix();
     glTranslated(0,-1,0);
-    draw_floor();
+    igl::opengl2::draw_floor();
     glPopMatrix();
   }
   
@@ -383,7 +383,7 @@ void draw_scene(const igl::Camera & v_camera,
   glPopMatrix();
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   if(render_to_texture)
   {

+ 7 - 7
examples/colored-mesh/example.cpp

@@ -1,12 +1,12 @@
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_vertex_normals.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
 #include <igl/readOFF.h>
@@ -258,7 +258,7 @@ void display()
   // Draw the model
   // Set material properties
   glEnable(GL_COLOR_MATERIAL);
-  draw_mesh(V,F,N,C);
+  igl::opengl2::draw_mesh(V,F,N,C);
 
   pop_object();
 
@@ -269,12 +269,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 1 - 1
examples/components/Makefile

@@ -2,7 +2,7 @@
 
 # Shared flags etc.
 include ../Makefile.conf
-LIBIGL_LIB+=-liglembree -liglboost
+LIBIGL_LIB+=-liglembree 
 
 all: obj example
 

+ 16 - 16
examples/components/example.cpp

@@ -2,16 +2,16 @@
 #include <igl/Camera.h>
 #include <igl/REDRUM.h>
 #include <igl/components.h>
-#include <igl/create_shader_program.h>
-#include <igl/draw_floor.h>
+#include <igl/opengl/create_shader_program.h>
+#include <igl/opengl2/draw_floor.h>
 #include <igl/get_seconds.h>
 #include <igl/hsv_to_rgb.h>
-#include <igl/init_render_to_texture.h>
+#include <igl/opengl/init_render_to_texture.h>
 #include <igl/jet.h>
 #include <igl/per_face_normals.h>
 #include <igl/randperm.h>
 #include <igl/read_triangle_mesh.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/rgb_to_hsv.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
@@ -152,8 +152,8 @@ void reshape(int width, int height)
   // Send the new window size to AntTweakBar
   TwWindowSize(width, height);
   s.camera.m_aspect = (double)width/(double)height;
-  igl::init_render_to_texture(width,height, pick_tex, pick_fbo, pick_dfbo);
-  igl::report_gl_error("init_render_to_texture: ");
+  igl::opengl::init_render_to_texture(width,height, pick_tex, pick_fbo, pick_dfbo);
+  igl::opengl::report_gl_error("init_render_to_texture: ");
   glutPostRedisplay();
 }
 
@@ -231,7 +231,7 @@ void draw_mesh(
 
     glBindBuffer(GL_ARRAY_BUFFER,sbo);
     glBufferData(GL_ARRAY_BUFFER,sizeof(float)*SR.size(),SR.data(),GL_STATIC_DRAW);
-    igl::report_gl_error("glBindBuffer: ");
+    igl::opengl::report_gl_error("glBindBuffer: ");
 
     scene_dirty = false;
   }
@@ -289,11 +289,11 @@ GLuint generate_1d_texture(
   glTexImage1D(GL_TEXTURE_1D, 0, colors.cols(),colors.rows(),
     0,GL_RGB, GL_UNSIGNED_BYTE,
     colors.data());
-  igl::report_gl_error("glTexImage1D: ");
+  igl::opengl::report_gl_error("glTexImage1D: ");
   glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
-  igl::report_gl_error("texture: ");
+  igl::opengl::report_gl_error("texture: ");
   return tex_id;
 }
  
@@ -333,7 +333,7 @@ void main()
     colors(id,2) = re;
   }
   tex_id = generate_1d_texture(colors);
-  return igl::create_shader_program(
+  return igl::opengl::create_shader_program(
     vertex_shader.c_str(), 
     fragment_shader.c_str(),
     {{"scalar_in",scalar_loc}}
@@ -519,12 +519,12 @@ void main()
 
     tex_id = generate_1d_texture(colors);
 
-    GLuint prog_id = igl::create_shader_program(
+    GLuint prog_id = igl::opengl::create_shader_program(
       vertex_shader.c_str(), 
       fragment_shader.c_str(),
       {{"scalar_in",scalar_loc}}
       );
-    igl::report_gl_error("create_shader_program: ");
+    igl::opengl::report_gl_error("create_shader_program: ");
     return prog_id;
   };
   static GLuint scalar_loc = 1;
@@ -547,7 +547,7 @@ void main()
     }else
     {
       glUseProgram(color_components_prog);
-      igl::report_gl_error("UseProgram: ");
+      igl::opengl::report_gl_error("UseProgram: ");
       draw_mesh(V,F,N,s.I,scalar_loc);
     }
   }
@@ -556,7 +556,7 @@ void main()
 
   glPushAttrib(GL_ALL_ATTRIB_BITS);
   glUseProgram(color_components_prog);
-    igl::report_gl_error("use: ");
+    igl::opengl::report_gl_error("use: ");
   glUniform1f(glGetUniformLocation(color_components_prog,"cmin"),s.I.minCoeff());
   glUniform1f(glGetUniformLocation(color_components_prog,"cmax"),s.I.maxCoeff());
   //glUniform1f(glGetUniformLocation(color_components_prog,"cc_selected"),cc_selected);
@@ -568,7 +568,7 @@ void main()
   glBindTexture(GL_TEXTURE_1D, s.mask_id);
   glUniform1i(glGetUniformLocation(color_components_prog,"selected_mask"),1);
 
-    igl::report_gl_error("unif: ");
+    igl::opengl::report_gl_error("unif: ");
   if(fill_visible)
   {
     glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
@@ -585,7 +585,7 @@ void main()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();

+ 19 - 19
examples/embree/example.cpp

@@ -1,13 +1,13 @@
-#include <igl/OpenGL_convenience.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl/OpenGL_convenience.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/normalize_row_lengths.h>
 #include <igl/per_face_normals.h>
 #include <igl/quat_to_mat.h>
 #include <igl/read_triangle_mesh.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/trackball.h>
-#include <igl/unproject.h>
+#include <igl/opengl2/unproject.h>
 #include <igl/embree/EmbreeIntersector.h>
 
 #ifdef __APPLE__
@@ -129,7 +129,7 @@ void lights()
   glLightfv(GL_LIGHT1,GL_POSITION,pos);
 }
 
-// Set up projection and model view of scene
+// Set up igl::opengl2::projection and model view of scene
 void push_scene()
 {
   using namespace igl;
@@ -208,7 +208,7 @@ void display()
 
   // Draw the model
   glEnable(GL_LIGHTING);
-  draw_mesh(V,F,N,C);
+  igl::opengl2::draw_mesh(V,F,N,C);
 
   // Draw all hits
   glBegin(GL_POINTS);
@@ -234,7 +234,7 @@ void display()
   glPushMatrix();
   glEnable(GL_LIGHTING);
   glTranslated(0,-1,0);
-  draw_floor();
+  igl::opengl2::draw_floor();
   glPopMatrix();
 
   // draw a transparent "projection screen" show model at time of hit (aka
@@ -290,7 +290,7 @@ void display()
     glVertex2fv(win_s.data());
     glEnd();
   }
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   glutSwapBuffers();
   glutPostRedisplay();
@@ -318,12 +318,12 @@ void mouse_move(int mouse_x, int mouse_y)
   // Unproject mouse at 0 depth and some positive depth
   win_s = Vector3f(mouse_x,height-mouse_y,0);
   Vector3f win_d(mouse_x,height-mouse_y,1);
-  unproject(win_s,s);
-  unproject(win_d,d);
+  igl::opengl2::unproject(win_s,s);
+  igl::opengl2::unproject(win_d,d);
   pop_object();
   pop_scene();
-  report_gl_error();
-  // Shoot ray at unprojected mouse in view direction
+  igl::opengl::report_gl_error();
+  // Shoot ray at igl::opengl2::unprojected mouse in view direction
   dir = d-s;
   int num_rays_shot;
   ei.intersectRay(s,dir,hits,num_rays_shot);
@@ -365,16 +365,16 @@ void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
       // Collect "projection screen" locations
       push_scene();
       push_object();
-      // unproject corners of window
+      // igl::opengl2::unproject corners of window
       const double depth = 0.999;
       Vector3d win_NW(    0,height,depth);
       Vector3d win_NE(width,height,depth);
       Vector3d win_SE(width,0,depth);
       Vector3d win_SW(0,0,depth);
-      unproject(win_NW,NW);
-      unproject(win_NE,NE);
-      unproject(win_SE,SE);
-      unproject(win_SW,SW);
+      igl::opengl2::unproject(win_NW,NW);
+      igl::opengl2::unproject(win_NE,NE);
+      igl::opengl2::unproject(win_SE,SE);
+      igl::opengl2::unproject(win_SW,SW);
       // render to framebuffer
       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id);
       glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dfbo_id);
@@ -386,7 +386,7 @@ void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
       glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
       glEnable(GL_LIGHTING);
       glEnable(GL_DEPTH_TEST);
-      draw_mesh(V,F,N,C);
+      igl::opengl2::draw_mesh(V,F,N,C);
       pop_object();
       pop_scene();
       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

+ 16 - 16
examples/flare-eyes/example.cpp

@@ -2,10 +2,10 @@
 #include <igl/PI.h>
 #include <igl/REDRUM.h>
 #include <igl/STR.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
-#include <igl/lens_flare.h>
+#include <igl/opengl2/lens_flare.h>
 #include <igl/list_to_matrix.h>
 #include <igl/material_colors.h>
 #include <igl/pathinfo.h>
@@ -16,8 +16,8 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/render_to_tga.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/render_to_tga.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -60,7 +60,7 @@
 bool eyes_visible = true;
 double x=6,y=232,z=61;
 
-std::vector<igl::Flare> flares;
+std::vector<igl::opengl2::Flare> flares;
 std::vector<GLuint> shine_ids;
 std::vector<GLuint> flare_ids;
 int shine_tic = 0;
@@ -222,7 +222,7 @@ void draw_flare()
   glScaled(bbd*0.5,bbd*0.5,bbd*0.5);
   glScaled(0.2,0.2,0.2);
   Vector3f light(0,0,0);
-  lens_flare_draw(flares,shine_ids,flare_ids,light,1.0,shine_tic);
+  igl::opengl2::lens_flare_draw(flares,shine_ids,flare_ids,light,1.0,shine_tic);
   glPopMatrix();
 }
 
@@ -335,7 +335,7 @@ void display()
     glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,  MIDNIGHT_BLUE_DIFFUSE);
     glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SILVER_SPECULAR);
     glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 128);
-    draw_mesh(V,F,N);
+    igl::opengl2::draw_mesh(V,F,N);
     pop_object();
     // Draw a nice floor
     glPushMatrix();
@@ -344,7 +344,7 @@ void display()
     glTranslated(0,floor_offset,0);
     const float GREY[4] = {0.5,0.5,0.6,1.0};
     const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-    draw_floor(GREY,DARK_GREY);
+    igl::opengl2::draw_floor(GREY,DARK_GREY);
     glPopMatrix();
 
     glEndList();
@@ -361,13 +361,13 @@ void display()
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   if(render_to_tga_on_next)
   {
     GLint viewport[4];
     glGetIntegerv(GL_VIEWPORT,viewport);
-    render_to_tga(
+    igl::opengl::render_to_tga(
       STR("./"<< "flare-eyes-" << setw(4) << setfill('0') << render_count++ << ".tga"),
       viewport[2],viewport[3],true);
     //render_to_tga_on_next = false;
@@ -722,16 +722,16 @@ int main(int argc, char * argv[])
   glutMotionFunc(mouse_drag);
   glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
   // Init flares
-  lens_flare_load_textures(shine_ids,flare_ids);
+  igl::opengl2::lens_flare_load_textures(shine_ids,flare_ids);
   const float RED[3] = {1,0,0};
   const float GREEN[3] = {0,1,0};
   const float BLUE[3] = {0,0,1};
   //lens_flare_create(RED,GREEN,BLUE,flares);
   flares.resize(4);
-  flares[0] = Flare(-1, 1.0f, 1.*0.1f,  RED, 1.0);
-  flares[1] = Flare(-1, 1.0f, 1.*0.15f, GREEN, 1.0);
-  flares[2] = Flare(-1, 1.0f, 1.*0.35f, BLUE, 1.0);
-  flares[3] = Flare( 2, 1.0f, 1.*0.1f, BLUE, 0.4);
+  flares[0] = igl::opengl2::Flare(-1, 1.0f, 1.*0.1f,  RED, 1.0);
+  flares[1] = igl::opengl2::Flare(-1, 1.0f, 1.*0.15f, GREEN, 1.0);
+  flares[2] = igl::opengl2::Flare(-1, 1.0f, 1.*0.35f, BLUE, 1.0);
+  flares[3] = igl::opengl2::Flare( 2, 1.0f, 1.*0.1f, BLUE, 0.4);
 
   glutMainLoop();
 

+ 8 - 8
examples/intersections/example.cpp

@@ -1,9 +1,9 @@
 #include <igl/Camera.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/barycenter.h>
 #include <igl/cat.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/list_to_matrix.h>
@@ -19,7 +19,7 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -278,7 +278,7 @@ void display()
     glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
     glPolygonOffset(1.0,1);
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-    draw_mesh(V,F,N,C);
+    igl::opengl2::draw_mesh(V,F,N,C);
     glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
     glDisable(GL_COLOR_MATERIAL);
     const float black[4] = {0,0,0,1};
@@ -290,7 +290,7 @@ void display()
     glLightfv(GL_LIGHT0, GL_DIFFUSE, black);
     glLineWidth(1.0);
     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-    draw_mesh(V,F,N,C);
+    igl::opengl2::draw_mesh(V,F,N,C);
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     glEnable(GL_COLOR_MATERIAL);
   };
@@ -312,12 +312,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 16 - 16
examples/multi-viewport/example.cpp

@@ -1,21 +1,21 @@
 #include <igl/Camera.h>
 #include <igl/EPS.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/STR.h>
 #include <igl/Viewport.h>
 #include <igl/canonical_quaternions.h>
-#include <igl/draw_beach_ball.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_beach_ball.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/normalize_row_lengths.h>
 #include <igl/per_face_normals.h>
-#include <igl/project.h>
+#include <igl/opengl2/project.h>
 #include <igl/quat_to_mat.h>
 #include <igl/read_triangle_mesh.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/trackball.h>
-#include <igl/unproject.h>
-#include <igl/unproject_to_zero_plane.h>
+#include <igl/opengl2/unproject.h>
+#include <igl/opengl2/unproject_to_zero_plane.h>
 
 #ifdef __APPLE__
 #  include <OpenGL/gl.h>
@@ -31,7 +31,7 @@
 #include <string>
 #include <algorithm>
 #define IGL_HEADER_ONLY
-#include <igl/draw_floor.h>
+#include <igl/opengl2/draw_floor.h>
 
 #define NUM_VIEWPORTS 4
 class AugViewport : public igl::Viewport
@@ -171,7 +171,7 @@ void lights()
   glLightfv(GL_LIGHT1,GL_POSITION,pos);
 }
 
-// Set up projection and model view of scene
+// Set up igl::opengl2::projection and model view of scene
 void push_scene(const AugViewport & vp)
 {
   using namespace igl;
@@ -246,7 +246,7 @@ void display()
     push_object();
     // Draw the model
     glEnable(GL_LIGHTING);
-    draw_mesh(V,F,N,C);
+    igl::opengl2::draw_mesh(V,F,N,C);
     pop_object();
 
     // Draw a nice floor
@@ -255,11 +255,11 @@ void display()
     glEnable(GL_CULL_FACE);
     glEnable(GL_LIGHTING);
     glTranslated(0,-1,0);
-    if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
+    if(igl::opengl2::project(Vector3d(0,0,0))(2) - igl::opengl2::project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
     {
-      draw_floor_outline();
+      igl::opengl2::draw_floor_outline();
     }
-    draw_floor();
+    igl::opengl2::draw_floor();
     glPopMatrix();
     glDisable(GL_CULL_FACE);
 
@@ -269,7 +269,7 @@ void display()
       glPushMatrix();
       glTranslated(ball(0),ball(1),ball(2));
       glScaled(0.1,0.1,0.1);
-      draw_beach_ball();
+      igl::opengl2::draw_beach_ball();
       glPopMatrix();
     }
 
@@ -318,7 +318,7 @@ void display()
   glEnd();
 
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   glutSwapBuffers();
 }
@@ -356,7 +356,7 @@ void mouse_move(int mouse_x, int mouse_y)
         viewports[in_vp].height);
       push_scene(viewports[in_vp]);
       Vector3d screen_ball(mouse_x,height-mouse_y,0);
-      unproject_to_zero_plane(screen_ball,ball);
+      igl::opengl2::unproject_to_zero_plane(screen_ball,ball);
       pop_scene();
     }
   }

+ 1 - 1
examples/patches/Makefile

@@ -3,7 +3,7 @@
 # Shared flags etc.
 include ../Makefile.conf
 ifdef LIBIGL_USE_STATIC_LIBRARY
-	LIBIGL_LIB+=-liglembree -liglboost
+	LIBIGL_LIB+=-liglembree
 endif
 
 all: obj example

+ 8 - 8
examples/patches/example.cpp

@@ -3,8 +3,8 @@
 #include <igl/REDRUM.h>
 #include <igl/bfs_orient.h>
 #include <igl/components.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/list_to_matrix.h>
@@ -21,7 +21,7 @@
 #include <igl/readOFF.h>
 #include <igl/readPLY.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -295,10 +295,10 @@ void display()
     if(fill_visible)
     {
       glColor3f(0,0,0);
-      draw_mesh(V,F,s.N);
+      igl::opengl2::draw_mesh(V,F,s.N);
     }else
     {
-      draw_mesh(V,F,s.N,s.C);
+      igl::opengl2::draw_mesh(V,F,s.N,s.C);
     }
 
     // visualize selected patch
@@ -338,7 +338,7 @@ void display()
   {
     glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
     glPolygonOffset(1.0, 0);
-    draw_mesh(V,F,s.N,s.C);
+    igl::opengl2::draw_mesh(V,F,s.N,s.C);
   }
 
   pop_object();
@@ -350,12 +350,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 6 - 6
examples/randomly-sample-mesh/example.cpp

@@ -1,7 +1,7 @@
 #include <igl/Camera.h>
 #include <igl/REDRUM.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/list_to_matrix.h>
 #include <igl/material_colors.h>
@@ -14,7 +14,7 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -240,7 +240,7 @@ void display()
   glMaterialf (GL_BACK, GL_SHININESS, 128);
 
 
-  draw_mesh(V,F,N);
+  igl::opengl2::draw_mesh(V,F,N);
 
   glPointSize(3.);
   glEnable(GL_POINT_SMOOTH);
@@ -262,12 +262,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 8 - 8
examples/rotate-widget/example.cpp

@@ -1,8 +1,8 @@
 #include <igl/Camera.h>
 #include <igl/REDRUM.h>
-#include <igl/RotateWidget.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/RotateWidget.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/list_to_matrix.h>
 #include <igl/material_colors.h>
@@ -15,7 +15,7 @@
 #include <igl/readOFF.h>
 #include <igl/readTGF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -63,7 +63,7 @@ Eigen::VectorXi P;
 struct State
 {
   igl::Camera camera;
-  igl::RotateWidget widget;
+  igl::opengl2::RotateWidget widget;
 } s;
 
 bool wireframe = false;
@@ -251,7 +251,7 @@ void display()
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   push_object();
@@ -272,7 +272,7 @@ void display()
   glTranslated( s.widget.pos(0), s.widget.pos(1), s.widget.pos(2));
   glMultMatrixd(Affine3d(s.widget.rot).matrix().data());
   glTranslated( -s.widget.pos(0), -s.widget.pos(1), -s.widget.pos(2));
-  draw_mesh(V,F,N);
+  igl::opengl2::draw_mesh(V,F,N);
   glPopMatrix();
 
   if(widget_on_top)
@@ -286,7 +286,7 @@ void display()
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 6 - 6
examples/scene-rotation/example.cpp

@@ -5,8 +5,8 @@
 
 #include <igl/Camera.h>
 #include <igl/REDRUM.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/list_to_matrix.h>
 #include <igl/material_colors.h>
@@ -18,7 +18,7 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -262,7 +262,7 @@ void display()
   glMaterialf (GL_BACK, GL_SHININESS, 128);
 
 
-  draw_mesh(V,F,N);
+  igl::opengl2::draw_mesh(V,F,N);
   pop_object();
 
   // Draw a nice floor
@@ -272,12 +272,12 @@ void display()
   glTranslated(0,floor_offset,0);
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 1 - 1
examples/scene-rotation/trackball.cpp

@@ -177,7 +177,7 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
     }
 
     /*
-     * First, figure out z-coordinates for projection of P1 and P2 to
+     * First, figure out z-coordinates for igl::opengl2::projection of P1 and P2 to
      * deformed sphere
      */
     vset(p1,p1x,p1y,tb_project_to_sphere(TRACKBALLSIZE,p1x,p1y));

+ 6 - 6
examples/shadow-mapping/example.cpp

@@ -3,8 +3,8 @@
 
 #include <igl/C_STR.h>
 #include <igl/REDRUM.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/list_to_matrix.h>
@@ -20,7 +20,7 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/trackball.h>
 #include <igl/unique_simplices.h>
@@ -244,7 +244,7 @@ void push_scene(
   double z_fix = 1.0;
   // 5 is far enough to see unit "things" well
   const double camera_z = 2;
-  // Test if should be using true orthographic projection
+  // Test if should be using true orthographic igl::opengl2::projection
   if(angle == 0)
   {
     glOrtho(
@@ -377,7 +377,7 @@ void draw_objects()
     glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 128);
     glPushMatrix();
     glMultMatrixd(mesh.a.matrix().data());
-    draw_mesh(mesh.V,mesh.F,mesh.N);
+    igl::opengl2::draw_mesh(mesh.V,mesh.F,mesh.N);
     glPopMatrix();
   }
 
@@ -472,7 +472,7 @@ void display()
 
   draw_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
   TwDraw();
   glutSwapBuffers();
   glutPostRedisplay();

+ 39 - 27
examples/skeleton-builder/example.cpp

@@ -6,10 +6,10 @@
 #include <igl/boundary_conditions.h>
 #include <igl/centroid.h>
 #include <igl/colon.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_skeleton_3d.h>
-#include <igl/draw_skeleton_vector_graphics.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_skeleton_3d.h>
+#include <igl/opengl2/draw_skeleton_vector_graphics.h>
 #include <igl/file_exists.h>
 #include <igl/forward_kinematics.h>
 #include <igl/get_seconds.h>
@@ -20,21 +20,22 @@
 #include <igl/normalize_row_sums.h>
 #include <igl/pathinfo.h>
 #include <igl/per_face_normals.h>
-#include <igl/project.h>
+#include <igl/opengl2/project.h>
 #include <igl/quat_to_mat.h>
 #include <igl/readTGF.h>
 #include <igl/read_triangle_mesh.h>
 #include <igl/remove_unreferenced.h>
-#include <igl/report_gl_error.h>
-#include <igl/right_axis.h>
+#include <igl/opengl/report_gl_error.h>
+#include <igl/opengl2/right_axis.h>
 #include <igl/slice.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/sort_triangles.h>
+#include <igl/opengl2/sort_triangles.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/unique.h>
-#include <igl/unproject.h>
+#include <igl/opengl2/unproject.h>
+#include <igl/opengl2/model_proj_viewport.h>
 #include <igl/writeOBJ.h>
 #include <igl/writeOFF.h>
 #include <igl/writeTGF.h>
@@ -248,7 +249,7 @@ void sort()
   push_scene();
   push_object();
   VectorXi I;
-  sort_triangles(V,F,sorted_F,I);
+  igl::opengl2::sort_triangles(V,F,sorted_F,I);
   slice(N,I,1,sorted_N);
   pop_object();
   pop_scene();
@@ -301,7 +302,7 @@ void display()
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glDisable(GL_CULL_FACE);
   glPopMatrix();
 
@@ -325,11 +326,11 @@ void display()
             }
           }
         }
-        draw_skeleton_3d(s.C,s.BE,MatrixXd(),colors,bbd*0.5);
+        igl::opengl2::draw_skeleton_3d(s.C,s.BE,MatrixXd(),colors,bbd*0.5);
         break;
       }
       case SKEL_STYLE_TYPE_VECTOR_GRAPHICS:
-        draw_skeleton_vector_graphics(s.C,s.BE);
+        igl::opengl2::draw_skeleton_vector_graphics(s.C,s.BE);
         break;
     }
   };
@@ -361,7 +362,7 @@ void display()
     glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
   }
   glLineWidth(1.0);
-  draw_mesh(V,sorted_F,sorted_N);
+  igl::opengl2::draw_mesh(V,sorted_F,sorted_N);
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
 
   if(skeleton_on_top)
@@ -373,7 +374,7 @@ void display()
   pop_object();
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();
@@ -468,7 +469,7 @@ bool ss_select(
   for(int c = 0;c<C.rows();c++)
   {
     const RowVector3d & Cc = C.row(c);
-    const auto Pc = project(Cc);
+    const auto Pc = igl::opengl2::project(Cc);
     const double SELECTION_DIST = 18;//pixels
     const double dist = (Pc.head(2)-RowVector2d(mouse_x,height-mouse_y)).norm();
     if(dist < SELECTION_DIST && (accum || dist < min_dist))
@@ -662,17 +663,24 @@ void mouse_drag(int mouse_x, int mouse_y)
       down_C = s.C;
       new_leaf_on_drag = false;
     }
+      Eigen::Matrix4f model,proj;
+      Eigen::Vector4f viewport;
+      igl::opengl2::model_proj_viewport(model,proj,viewport);
+      Eigen::Vector2f pos(mouse_x,height-mouse_y);
     if(new_root_on_drag)
     {
       // two new nodes
       s.C.conservativeResize(s.C.rows()+2,3);
       const int nc = s.C.rows();
       Vector3d obj;
-      int nhits = igl::embree::unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
+
+      int nhits = igl::embree::unproject_in_mesh(
+          pos,model,proj,viewport,ei,obj);
+
       if(nhits == 0)
       {
-        Vector3d pV_mid = project(Vcen);
-        obj = unproject(Vector3d(mouse_x,height-mouse_y,pV_mid(2)));
+        Vector3d pV_mid = igl::opengl2::project(Vcen);
+        obj = igl::opengl2::unproject(Vector3d(mouse_x,height-mouse_y,pV_mid(2)));
       }
       s.C.row(nc-2) = obj;
       s.C.row(nc-1) = obj;
@@ -688,21 +696,21 @@ void mouse_drag(int mouse_x, int mouse_y)
     }
     double z = 0;
     Vector3d obj,win;
-    int nhits = igl::embree::unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
-    project(obj,win);
+    int nhits = igl::embree::unproject_in_mesh(pos,model,proj,viewport,ei,obj);
+    igl::opengl2::project(obj,win);
     z = win(2);
 
     for(int si = 0;si<s.sel.size();si++)
     {
       const int c = s.sel(si);
-      Vector3d pc = project((RowVector3d) down_C.row(c));
+      Vector3d pc = igl::opengl2::project((RowVector3d) down_C.row(c));
       pc(0) += mouse_x-down_x;
       pc(1) += (height-mouse_y)-(height-down_y);
       if(nhits > 0)
       {
         pc(2) = z;
       }
-      s.C.row(c) = unproject(pc);
+      s.C.row(c) = igl::opengl2::unproject(pc);
     }
     pop_object();
     pop_scene();
@@ -762,7 +770,7 @@ void symmetrize()
   push_scene();
   push_object();
   Vector3d right;
-  right_axis(right.data(),right.data()+1,right.data()+2);
+  igl::opengl2::right_axis(right.data(),right.data()+1,right.data()+2);
   right.normalize();
   MatrixXd RC(s.C.rows(),s.C.cols());
   MatrixXd old_C = s.C;
@@ -1014,9 +1022,13 @@ void key(unsigned char key, int mouse_x, int mouse_y)
       push_object();
       for(int c = 0;c<s.C.rows();c++)
       {
-        Vector3d P = project((Vector3d)s.C.row(c));
+        Vector3d P = igl::opengl2::project((Vector3d)s.C.row(c));
         Vector3d obj;
-        int nhits = igl::embree::unproject_in_mesh(P(0),P(1),ei,obj);
+        Eigen::Matrix4f model,proj;
+        Eigen::Vector4f viewport;
+        igl::opengl2::model_proj_viewport(model,proj,viewport);
+        Eigen::Vector2f pos(P(0),P(1));
+        int nhits = igl::embree::unproject_in_mesh(pos,model,proj,viewport,ei,obj);
         if(nhits > 0)
         {
           s.C.row(c) = obj;
@@ -1105,7 +1117,7 @@ int main(int argc, char * argv[])
   cout<<"P,p                    Split \"parent\" bone(s) of selection by creating new node(s)."<<endl;
   cout<<"R,r                    Breadth first search at selection to redirect skeleton into tree."<<endl;
   cout<<"S,s                    Save current skeleton to output .tgf file."<<endl;
-  cout<<"U,u                    Project then unproject inside mesh (as if dragging each by ε)."<<endl;
+  cout<<"U,u                    Project then igl::opengl2::unproject inside mesh (as if dragging each by ε)."<<endl;
   cout<<"Y,Y                    Symmetrize selection over plane through object centroid and right vector."<<endl;
   cout<<"Z,z                    Snap to canonical view."<<endl;
   cout<<"⌘ Z                    Undo."<<endl;

+ 15 - 14
examples/skeleton-poser/example.cpp

@@ -1,5 +1,5 @@
 #include <igl/Camera.h>
-#include <igl/MouseController.h>
+#include <igl/opengl2/MouseController.h>
 #include <igl/REDRUM.h>
 #include <igl/STR.h>
 #include <igl/barycenter.h>
@@ -8,11 +8,11 @@
 #include <igl/boundary_facets.h>
 #include <igl/centroid.h>
 #include <igl/colon.h>
-#include <igl/draw_beach_ball.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_skeleton_3d.h>
-#include <igl/draw_skeleton_vector_graphics.h>
+#include <igl/opengl2/draw_beach_ball.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_skeleton_3d.h>
+#include <igl/opengl2/draw_skeleton_vector_graphics.h>
 #include <igl/forward_kinematics.h>
 #include <igl/get_seconds.h>
 #include <igl/lbs_matrix.h>
@@ -26,7 +26,7 @@
 #include <igl/readTGF.h>
 #include <igl/read_triangle_mesh.h>
 #include <igl/remove_unreferenced.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -97,7 +97,7 @@ Eigen::VectorXi P,RP;
 
 struct State
 {
-  igl::MouseController mouse;
+  igl::opengl2::MouseController mouse;
   Eigen::MatrixXf colors;
 } s;
 
@@ -295,7 +295,7 @@ void display()
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glDisable(GL_CULL_FACE);
   glPopMatrix();
 
@@ -308,11 +308,11 @@ void display()
       default:
       case SKEL_STYLE_TYPE_3D:
       {
-        draw_skeleton_3d(C,BE,T,s.colors,bbd*0.5);
+        igl::opengl2::draw_skeleton_3d(C,BE,T,s.colors,bbd*0.5);
         break;
       }
       case SKEL_STYLE_TYPE_VECTOR_GRAPHICS:
-        draw_skeleton_vector_graphics(C,BE,T);
+        igl::opengl2::draw_skeleton_vector_graphics(C,BE,T);
         break;
     }
   };
@@ -359,7 +359,7 @@ void display()
   MatrixXd U = M*T;
   MatrixXd UN;
   per_face_normals(U,F,UN);
-  draw_mesh(U,F,UN);
+  igl::opengl2::draw_mesh(U,F,UN);
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
   glDisable(GL_DEPTH_TEST);
   draw_skeleton(T);
@@ -375,7 +375,7 @@ void display()
     glScaled(0.1,0.1,0.1);
     glEnable(GL_POLYGON_OFFSET_FILL);
     glPolygonOffset(0,-100000);
-    draw_beach_ball();
+    igl::opengl2::draw_beach_ball();
     glDisable(GL_POLYGON_OFFSET_FILL);
     glPopMatrix();
   }
@@ -389,7 +389,7 @@ void display()
   pop_object();
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();
@@ -459,6 +459,7 @@ void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
           if(mouse_was_selecting)
           {
             s.mouse.set_selection_from_last_drag(C,BE,P,RP);
+            using namespace igl::opengl2;
             MouseController::VectorXb S;
             MouseController::propogate_to_descendants_if(
               s.mouse.selection(),P,S);

+ 10 - 10
examples/skeleton/example.cpp

@@ -1,10 +1,10 @@
 #include <igl/Camera.h>
 #include <igl/REDRUM.h>
 #include <igl/boundary_conditions.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_skeleton_3d.h>
-#include <igl/draw_skeleton_vector_graphics.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_skeleton_3d.h>
+#include <igl/opengl2/draw_skeleton_vector_graphics.h>
 #include <igl/forward_kinematics.h>
 #include <igl/get_seconds.h>
 #include <igl/lbs_matrix.h>
@@ -20,7 +20,7 @@
 #include <igl/readOFF.h>
 #include <igl/readTGF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/trackball.h>
@@ -255,7 +255,7 @@ void display()
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   push_object();
@@ -296,7 +296,7 @@ void display()
   glLineWidth(1.0);
   MatrixXd U = M*T;
   per_face_normals(U,F,N);
-  draw_mesh(U,F,N);
+  igl::opengl2::draw_mesh(U,F,N);
   glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
 
   if(skeleton_on_top)
@@ -308,10 +308,10 @@ void display()
   {
     default:
     case SKEL_STYLE_TYPE_3D:
-      draw_skeleton_3d(C,BE,T,MAYA_VIOLET,bbd*0.5);
+      igl::opengl2::draw_skeleton_3d(C,BE,T,MAYA_VIOLET,bbd*0.5);
       break;
     case SKEL_STYLE_TYPE_VECTOR_GRAPHICS:
-      draw_skeleton_vector_graphics(C,BE,T);
+      igl::opengl2::draw_skeleton_vector_graphics(C,BE,T);
       break;
   }
 
@@ -319,7 +319,7 @@ void display()
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 7 - 8
examples/textured-mesh/example.cpp

@@ -1,9 +1,9 @@
 #include <igl/Camera.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/STR.h>
 #include <igl/barycenter.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/list_to_matrix.h>
@@ -20,10 +20,9 @@
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/texture_from_tga.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/anttweakbar/ReAntTweakBar.h>
@@ -287,7 +286,7 @@ void display()
   }
   glMatrixMode(GL_MODELVIEW);
 
-  draw_mesh(V,F,N,MatrixXi(),MatrixXd(),TC,TF,MatrixXd(),0,MatrixXi(),0);
+  igl::opengl2::draw_mesh(V,F,N,MatrixXi(),MatrixXd(),TC,TF,MatrixXd(),0,MatrixXi(),0);
 
   glMatrixMode(GL_TEXTURE);
   glPopMatrix();
@@ -320,12 +319,12 @@ void display()
   glDisable(GL_POLYGON_OFFSET_FILL);
   glDisable(GL_TEXTURE_2D);
 
-  draw_floor(GREY,DARK_GREY);
+  igl::opengl2::draw_floor(GREY,DARK_GREY);
   glPopMatrix();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
 
   TwDraw();
   glutSwapBuffers();

+ 1 - 1
examples/transparency/Makefile

@@ -7,7 +7,7 @@ all: example
 
 .PHONY: example
 
-CFLAGS+=-O3 -fopenmp
+CFLAGS+=-O3 
 
 INC=$(LIBIGL_INC) $(ANTTWEAKBAR_INC) $(EIGEN3_INC)
 LIB=$(OPENGL_LIB) $(GLUT_LIB) $(ANTTWEAKBAR_LIB) $(LIBIGL_LIB)

+ 12 - 12
examples/transparency/example.cpp

@@ -1,8 +1,8 @@
 #include <igl/EPS.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/opengl/OpenGL_convenience.h>
 #include <igl/colon.h>
-#include <igl/draw_floor.h>
-#include <igl/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
 #include <igl/jet.h>
 #include <igl/material_colors.h>
 #include <igl/matlab_format.h>
@@ -10,12 +10,12 @@
 #include <igl/per_face_normals.h>
 #include <igl/quat_to_mat.h>
 #include <igl/read_triangle_mesh.h>
-#include <igl/report_gl_error.h>
-#include <igl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
+#include <igl/opengl/report_gl_error.h>
 #include <igl/slice.h>
-#include <igl/sort_triangles.h>
+#include <igl/opengl2/sort_triangles.h>
 #include <igl/trackball.h>
-#include <igl/unproject.h>
+#include <igl/opengl2/unproject.h>
 #include <igl/anttweakbar/ReAntTweakBar.h>
 
 #ifdef __APPLE__
@@ -87,7 +87,7 @@ void lights()
   glLightfv(GL_LIGHT1,GL_POSITION,pos);
 }
 
-// Set up projection and model view of scene
+// Set up igl::opengl2::projection and model view of scene
 void push_scene()
 {
   using namespace igl;
@@ -154,7 +154,7 @@ void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
       // sort!
       push_scene();
       push_object();
-      sort_triangles(V,F,sorted_F,I);
+      igl::opengl2::sort_triangles(V,F,sorted_F,I);
       slice(N,I,1,sorted_N);
       init_C(I);
       pop_object();
@@ -206,7 +206,7 @@ void display()
   glTranslated(0,-1000*FLOAT_EPS,0);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
-  draw_floor();
+  igl::opengl2::draw_floor();
   pop_object();
 
   glDisable(GL_CULL_FACE);
@@ -241,12 +241,12 @@ void display()
 
   push_object();
   // Draw the model
-  draw_mesh(V,sorted_F,sorted_N,C);
+  igl::opengl2::draw_mesh(V,sorted_F,sorted_N,C);
   pop_object();
 
   pop_scene();
 
-  report_gl_error();
+  igl::opengl::report_gl_error();
   glutSwapBuffers();
   glutPostRedisplay();
 }

+ 5 - 5
examples/upright/example.cpp

@@ -9,8 +9,8 @@
 // lost in the output file.
 //
 #include <igl/read_triangle_mesh.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
+#include <igl/opengl2/draw_mesh.h>
+#include <igl/opengl2/draw_floor.h>
 #include <igl/pathinfo.h>
 #include <igl/list_to_matrix.h>
 #include <igl/per_face_normals.h>
@@ -99,7 +99,7 @@ void push_scene()
   double z_fix = 1.0;
   // 5 is far enough to see unit "things" well
   const double camera_z = 2;
-  // Test if should be using true orthographic projection
+  // Test if should be using true orthographic igl::opengl2::projection
   if(angle == 0)
   {
     glOrtho(
@@ -194,7 +194,7 @@ void display()
   glMaterialf (GL_BACK, GL_SHININESS, 128);
 
 
-  draw_mesh(s.V,s.F,s.N);
+  igl::opengl2::draw_mesh(s.V,s.F,s.N);
 
   glDisable(GL_LIGHTING);
   glPushMatrix();
@@ -230,7 +230,7 @@ void display()
   glEnable(GL_LIGHTING);
   glPushMatrix();
   glTranslated(0,-1,0);
-  draw_floor();
+  igl::opengl2::draw_floor();
   glPopMatrix();
   pop_scene();
 

+ 1 - 1
include/igl/bounding_box_diagonal.cpp

@@ -22,5 +22,5 @@ IGL_INLINE double igl::bounding_box_diagonal(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #endif

+ 1 - 1
include/igl/cgal/mesh_to_polyhedron.cpp

@@ -47,7 +47,7 @@ IGL_INLINE bool igl::cgal::mesh_to_polyhedron(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.h>
 template bool igl::cgal::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);

+ 1 - 1
include/igl/cgal/polyhedron_to_mesh.cpp

@@ -57,7 +57,7 @@ IGL_INLINE void igl::cgal::polyhedron_to_mesh(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.h>
 template void igl::cgal::polyhedron_to_mesh<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);

+ 1 - 0
include/igl/colon.cpp

@@ -51,4 +51,5 @@ template void igl::colon<int, int, long, int>(int, int, long, Eigen::Matrix<int,
 template void igl::colon<int, long, int>(int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, int, int>(int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int,long long int,int>(int,long long int,Eigen::Matrix<int,-1,1,0,-1,1> &);
+template void igl::colon<int, int, int, int>(int, int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 #endif

+ 0 - 33
include/igl/compile_and_link_program.h

@@ -1,33 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COMPILE_AND_LINK_PROGRAM_H
-#define IGL_COMPILE_AND_LINK_PROGRAM_H
-#include "igl_inline.h"
-#include "OpenGL_convenience.h"
-namespace igl
-{
-  #ifndef IGL_NO_OPENGL
-
-  // Compile and link very simple vertex/fragment shaders
-  //
-  // Inputs:
-  //   v_str  string of vertex shader contents
-  //   f_str  string of fragment shader contents
-  // Returns id of program
-  //
-  // Known bugs: this seems to duplicate `create_shader_program` with less
-  // functionality.
-  IGL_INLINE GLuint compile_and_link_program(
-    const char * v_str, const char * f_str);
-
-  #endif
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "compile_and_link_program.cpp"
-#endif
-#endif

+ 0 - 38
include/igl/compile_shader.h

@@ -1,38 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COMPILE_SHADER_H
-#define IGL_COMPILE_SHADER_H
-#include "OpenGL_convenience.h"
-#include "igl_inline.h"
-namespace igl
-{
-  #ifndef IGL_NO_OPENGL
-  // Compile a shader given type and string of shader code
-  //
-  // Inputs:
-  //   type  either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
-  //   str  contents of shader code
-  // Returns result of glCreateShader (id of shader)
-  //
-  // Example:
-  //     GLuint vid = compile_shader(GL_VERTEX_SHADER,vertex_shader.c_str());
-  //     GLuint fid = compile_shader(GL_FRAGMENT_SHADER,fragment_shader.c_str());
-  //     GLuint prog_id = glCreateProgram();
-  //     glAttachShader(prog_id,vid);
-  //     glAttachShader(prog_id,fid);
-  //     glLinkProgram(prog_id);
-  //
-  // Known bugs: seems to be duplicate of `load_shader`
-  IGL_INLINE GLuint compile_shader(const GLint type, const char * str);
-  #endif
-
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "compile_shader.cpp"
-#endif
-#endif

+ 1 - 0
include/igl/components.cpp

@@ -88,4 +88,5 @@ IGL_INLINE void igl::components(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 template void igl::components<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::components<int, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<int, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 0 - 63
include/igl/create_mesh_vbo.h

@@ -1,63 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#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>
-
-#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
-// GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
-namespace igl
-{
-
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3 eigne Matrix of face (triangle) indices
-  // Outputs:
-  //   V_vbo_id  buffer id for vertex positions
-  //   F_vbo_id  buffer id for face indices
-  //
-  // NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
-  // MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
-  //
-  IGL_INLINE void create_mesh_vbo(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    GLuint & V_vbo_id,
-    GLuint & F_vbo_id);
-
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3 eigne Matrix of face (triangle) indices
-  //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
-  // Outputs:
-  //   V_vbo_id  buffer id for vertex positions
-  //   F_vbo_id  buffer id for face indices
-  //   N_vbo_id  buffer id for vertex positions
-  IGL_INLINE void create_mesh_vbo(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N,
-    GLuint & V_vbo_id,
-    GLuint & F_vbo_id,
-    GLuint & N_vbo_id);
-
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "create_mesh_vbo.cpp"
-#endif
-
-#endif
-#endif

+ 0 - 65
include/igl/create_shader_program.h

@@ -1,65 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CREATE_SHADER_PROGRAM_H
-#define IGL_CREATE_SHADER_PROGRAM_H
-
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
-#include <string>
-#include <map>
-
-#include "OpenGL_convenience.h"
-
-namespace igl
-{
-  // Create a shader program with a vertex and fragments shader loading from
-  // source strings and vertex attributes assigned from a map before linking the
-  // shaders to the program, making it ready to use with glUseProgram(id)
-  // Inputs:
-  //   geom_source  string containing source code of geometry shader (can be
-  //     "" to mean use default pass-through)
-  //   vert_source  string containing source code of vertex shader
-  //   frag_source  string containing source code of fragment shader
-  //   attrib  map containing table of vertex attribute strings add their
-  //   correspondingly ids (generated previously using glBindAttribLocation)
-  // Outputs:
-  //   id  index id of created shader, set to 0 on error
-  // Returns true on success, false on error
-  //
-  // Note: Caller is responsible for making sure that current value of id is not
-  // leaking a shader (since it will be overwritten)
-  //
-  // See also: destroy_shader_program
-  IGL_INLINE bool create_shader_program(
-    const std::string &geom_source,
-    const std::string &vert_source,
-    const std::string &frag_source,
-    const std::map<std::string,GLuint> &attrib,
-    GLuint & id);
-  IGL_INLINE bool create_shader_program(
-    const std::string &vert_source,
-    const std::string &frag_source,
-    const std::map<std::string,GLuint> &attrib,
-    GLuint & id);
-  IGL_INLINE GLuint create_shader_program(
-    const std::string & geom_source,
-    const std::string & vert_source,
-    const std::string & frag_source,
-    const std::map<std::string,GLuint> &attrib);
-  IGL_INLINE GLuint create_shader_program(
-    const std::string & vert_source,
-    const std::string & frag_source,
-    const std::map<std::string,GLuint> &attrib);
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "create_shader_program.cpp"
-#endif
-
-#endif
-#endif

+ 0 - 35
include/igl/destroy_shader_program.h

@@ -1,35 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DESTROY_SHADER_PROGRAM_H
-#define IGL_DESTROY_SHADER_PROGRAM_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
-
-#include "OpenGL_convenience.h"
-
-namespace igl
-{
-  // Properly destroy a shader program. Detach and delete each of its shaders
-  // and delete it
-  // Inputs:
-  //   id  index id of created shader, set to 0 on error
-  // Returns true on success, false on error
-  // 
-  // Note: caller is responsible for making sure he doesn't foolishly continue
-  // to use id as if it still contains a program
-  // 
-  // See also: create_shader_program
-  IGL_INLINE bool destroy_shader_program(const GLuint id);
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "destroy_shader_program.cpp"
-#endif
-
-#endif
-#endif

+ 1 - 1
include/igl/directed_edge_orientations.cpp

@@ -24,6 +24,6 @@ IGL_INLINE void igl::directed_edge_orientations(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::directed_edge_orientations<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<Eigen::Quaternion<double, 0>, Eigen::aligned_allocator<Eigen::Quaternion<double, 0> > >&);
 #endif

+ 1 - 1
include/igl/directed_edge_parents.cpp

@@ -29,6 +29,6 @@ IGL_INLINE void igl::directed_edge_parents(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::directed_edge_parents<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 1 - 1
include/igl/dqs.cpp

@@ -69,6 +69,6 @@ IGL_INLINE void igl::dqs(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::dqs<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Quaternion<double, 0>, Eigen::aligned_allocator<Eigen::Quaternion<double, 0> >, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, std::vector<Eigen::Quaternion<double, 0>, Eigen::aligned_allocator<Eigen::Quaternion<double, 0> > > const&, std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 0 - 58
include/igl/draw_floor.h

@@ -1,58 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_FLOOR_H
-#define IGL_DRAW_FLOOR_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
-namespace igl
-{
-  // Draw a checkerboard floor aligned with current (X,Z) plane using OpenGL
-  // calls. side=50 centered at (0,0):
-  //   (-25,-25)-->(-25,25)-->(25,25)-->(25,-25)
-  //
-  // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor.
-  // 
-  // Inputs:
-  //   colorA  float4 color
-  //   colorB  float4 color
-  //
-  // Example:
-  //   // Draw a nice floor
-  //   glPushMatrix();
-  //   glCullFace(GL_BACK);
-  //   glEnable(GL_CULL_FACE);
-  //   glEnable(GL_LIGHTING);
-  //   glTranslated(0,-1,0);
-  //   if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
-  //   {
-  //     draw_floor_outline();
-  //   }
-  //   draw_floor();
-  //   glPopMatrix();
-  //   glDisable(GL_CULL_FACE);
-  //
-  IGL_INLINE void draw_floor(
-    const float * colorA, 
-    const float * colorB, 
-    const int GridSizeX=100, 
-    const int GridSizeY=100);
-  // Wrapper with default colors
-  IGL_INLINE void draw_floor();
-  IGL_INLINE void draw_floor_outline(
-    const float * colorA, 
-    const float * colorB, 
-    const int GridSizeX=100, 
-    const int GridSizeY=100);
-  // Wrapper with default colors
-  IGL_INLINE void draw_floor_outline();
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_floor.cpp"
-#endif
-#endif
-#endif

+ 0 - 121
include/igl/draw_mesh.h

@@ -1,121 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_MESH_H
-#define IGL_DRAW_MESH_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
-
-#include <Eigen/Dense>
-
-#include "OpenGL_convenience.h"
-
-namespace igl
-{
-  // Draw OpenGL commands needed to display a mesh with normals
-  //
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3|4 eigen Matrix of face (triangle/quad) indices
-  //   N  #V|#F by 3 eigen Matrix of 3D normals
-  IGL_INLINE void draw_mesh(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N);
-  
-  // Draw OpenGL commands needed to display a mesh with normals and per-vertex
-  // colors
-  //
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3|4 eigen Matrix of face (triangle/quad) indices
-  //   N  #V|#F by 3 eigen Matrix of 3D normals
-  //   C  #V|#F|1 by 3 eigen Matrix of RGB colors
-  IGL_INLINE void draw_mesh(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N,
-    const Eigen::MatrixXd & C);
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3|4 eigen Matrix of face (triangle/quad) indices
-  //   N  #V|#F by 3 eigen Matrix of 3D normals
-  //   C  #V|#F|1 by 3 eigen Matrix of RGB colors
-  //   TC  #V|#F|1 by 3 eigen Matrix of Texture Coordinates
-  IGL_INLINE void draw_mesh(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N,
-    const Eigen::MatrixXd & C,
-    const Eigen::MatrixXd & TC);
-  
-  // Draw OpenGL commands needed to display a mesh with normals, per-vertex
-  // colors and LBS weights
-  //
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3|4 eigen Matrix of face (triangle/quad) indices
-  //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
-  //   C  #V by 3 eigen Matrix of mesh vertex RGB colors
-  //   TC  #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
-  //   W  #V by #H eigen Matrix of per mesh vertex, per handle weights
-  //   W_index  Specifies the index of the "weight" vertex attribute: see
-  //     glBindAttribLocation, if W_index is 0 then weights are ignored
-  //   WI  #V by #H eigen Matrix of per mesh vertex, per handle weight ids
-  //   WI_index  Specifies the index of the "weight" vertex attribute: see
-  //     glBindAttribLocation, if WI_index is 0 then weight indices are ignored
-  IGL_INLINE void draw_mesh(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N,
-    const Eigen::MatrixXd & C,
-    const Eigen::MatrixXd & TC,
-    const Eigen::MatrixXd & W,
-    const GLuint W_index,
-    const Eigen::MatrixXi & WI,
-    const GLuint WI_index);
-  
-  // Draw OpenGL commands needed to display a mesh with normals, per-vertex
-  // colors and LBS weights
-  //
-  // Inputs:
-  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F  #F by 3|4 eigen Matrix of face (triangle/quad) indices
-  //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
-  //   NF  #F by 3 eigen Matrix of face (triangle/quad) normal indices, <0
-  //     means no normal
-  //   C  #V by 3 eigen Matrix of mesh vertex RGB colors
-  //   TC  #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
-  //   TF  #F by 3 eigen Matrix of face (triangle/quad) texture indices, <0
-  //     means no texture
-  //   W  #V by #H eigen Matrix of per mesh vertex, per handle weights
-  //   W_index  Specifies the index of the "weight" vertex attribute: see
-  //     glBindAttribLocation, if W_index is 0 then weights are ignored
-  //   WI  #V by #H eigen Matrix of per mesh vertex, per handle weight ids
-  //   WI_index  Specifies the index of the "weight" vertex attribute: see
-  //     glBindAttribLocation, if WI_index is 0 then weight indices are ignored
-  IGL_INLINE void draw_mesh(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & N,
-    const Eigen::MatrixXi & NF,
-    const Eigen::MatrixXd & C,
-    const Eigen::MatrixXd & TC,
-    const Eigen::MatrixXi & TF,
-    const Eigen::MatrixXd & W,
-    const GLuint W_index,
-    const Eigen::MatrixXi & WI,
-    const GLuint WI_index);
-
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_mesh.cpp"
-#endif
-
-#endif
-#endif

+ 0 - 45
include/igl/draw_point.h

@@ -1,45 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_POINT_H
-#define IGL_DRAW_POINT_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
-#include <Eigen/Core>
-namespace igl
-{
-  //double POINT_COLOR[3] = {239./255.,213./255.,46./255.};
-  // Draw a nice looking, colored dot at a given point in 3d.
-  //
-  // Note: expects that GL_CURRENT_COLOR is set with the desired foreground color
-  // 
-  // Inputs:
-  //   x  x-coordinate of point, modelview coordinates
-  //   y  y-coordinate of point, modelview coordinates
-  //   z  z-coordinate of point, modelview coordinates
-  //   requested_r  outer-most radius of dot {7}, measured in screen space pixels
-  //   selected  fills inner circle with black {false}
-  // Asserts that requested_r does not exceed 0.5*GL_POINT_SIZE_MAX
-  IGL_INLINE void draw_point(
-    const double x,
-    const double y,
-    const double z,
-    const double requested_r = 7,
-    const bool selected = false);
-  template <typename DerivedP>
-  IGL_INLINE void draw_point(
-    const Eigen::PlainObjectBase<DerivedP> & P,
-    const double requested_r = 7,
-    const bool selected = false);
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_point.cpp"
-#endif
-
-#endif
-#endif

+ 0 - 36
include/igl/draw_rectangular_marquee.h

@@ -1,36 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_RECTANGULAR_MARQUEE_H
-#define IGL_DRAW_RECTANGULAR_MARQUEE_H
-#include "igl_inline.h"
-namespace igl
-{
-  #ifndef IGL_NO_OPENGL
-
-  // Draw a rectangular marquee (selection box) in screen space. This sets up
-  // screen space using current viewport.
-  //
-  // Inputs:
-  //   from_x  x coordinate of from point
-  //   from_y  y coordinate of from point
-  //   to_x  x coordinate of to point
-  //   to_y  y coordinate of to point
-  IGL_INLINE void draw_rectangular_marquee(
-    const int from_x,
-    const int from_y,
-    const int to_x,
-    const int to_y);
-
-    #endif
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_rectangular_marquee.cpp"
-#endif
-
-#endif

+ 0 - 54
include/igl/draw_skeleton_3d.h

@@ -1,54 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_SKELETON_3D_H
-#define IGL_DRAW_SKELETON_3D_H
-#include "igl_inline.h"
-#include "material_colors.h"
-#include <Eigen/Core>
-namespace igl
-{
-
-  #ifndef IGL_NO_OPENGL
-
-  // Draw a skeleton
-  //
-  // Inputs:
-  //   C  #C by dim List of joint rest positions
-  //   BE  #BE by 2 list of bone edge indices into C
-  //   T  #BE*(dim+1) by dim  matrix of stacked transposed bone transformations
-  //   color  #BE|1 by 4 list of color
-  //   half_bbd  half bounding box diagonal to determine scaling {1.0}
-  template <
-    typename DerivedC,
-    typename DerivedBE,
-    typename DerivedT,
-    typename Derivedcolor>
-  IGL_INLINE void draw_skeleton_3d(
-    const Eigen::PlainObjectBase<DerivedC> & C,
-    const Eigen::PlainObjectBase<DerivedBE> & BE,
-    const Eigen::PlainObjectBase<DerivedT> & T,
-    const Eigen::PlainObjectBase<Derivedcolor> & color,
-    const double half_bbd=0.5);
-  // Default color
-  template <typename DerivedC, typename DerivedBE, typename DerivedT>
-  IGL_INLINE void draw_skeleton_3d(
-    const Eigen::PlainObjectBase<DerivedC> & C,
-    const Eigen::PlainObjectBase<DerivedBE> & BE,
-    const Eigen::PlainObjectBase<DerivedT> & T);
-  template <typename DerivedC, typename DerivedBE>
-  IGL_INLINE void draw_skeleton_3d(
-    const Eigen::PlainObjectBase<DerivedC> & C,
-    const Eigen::PlainObjectBase<DerivedBE> & BE);
-};
-
-  #endif
-  
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_skeleton_3d.cpp"
-#endif
-#endif

+ 0 - 53
include/igl/draw_skeleton_vector_graphics.h

@@ -1,53 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_DRAW_SKELETON_VECTOR_GRAPHICS_H
-#define IGL_DRAW_SKELETON_VECTOR_GRAPHICS_H
-#include "igl_inline.h"
-#include <Eigen/Core>
-
-namespace igl
-{
-  #ifndef IGL_NO_OPENGL
-
-  // Draw a skeleton with a 2D vector graphcis style à la BBW, STBS, Monotonic,
-  // FAST papers.
-  //
-  // Inputs:
-  //   C  #C by dim list of joint positions
-  //   BE #BE by 2 list of bone edge indices into C
-  //  point_color  color of points
-  //  line_color  color of lines
-  IGL_INLINE void draw_skeleton_vector_graphics(
-    const Eigen::MatrixXd & C,
-    const Eigen::MatrixXi & BE,
-    const float * point_color,
-    const float * line_color);
-  // Use default colors (originally from BBW paper)
-  IGL_INLINE void draw_skeleton_vector_graphics(
-    const Eigen::MatrixXd & C,
-    const Eigen::MatrixXi & BE);
-  //   T  #BE*(dim+1) by dim  matrix of stacked transposed bone transformations
-  template <typename DerivedC, typename DerivedBE, typename DerivedT>
-  IGL_INLINE void draw_skeleton_vector_graphics(
-    const Eigen::PlainObjectBase<DerivedC> & C,
-    const Eigen::PlainObjectBase<DerivedBE> & BE,
-    const Eigen::PlainObjectBase<DerivedT> & T,
-    const float * point_color,
-    const float * line_color);
-  template <typename DerivedC, typename DerivedBE, typename DerivedT>
-  IGL_INLINE void draw_skeleton_vector_graphics(
-    const Eigen::PlainObjectBase<DerivedC> & C,
-    const Eigen::PlainObjectBase<DerivedBE> & BE,
-    const Eigen::PlainObjectBase<DerivedT> & T);
-
-    #endif
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "draw_skeleton_vector_graphics.cpp"
-#endif
-#endif

+ 7 - 2
include/igl/embree/EmbreeIntersector.h

@@ -400,8 +400,10 @@ inline bool igl::embree::EmbreeIntersector::intersectBeam(
   else
     bestHit.t = 0;
 
-  if(hasHit = (intersectRay(origin,direction,hit,tnear,tfar,mask) && (hit.gid == geoId || geoId == -1)))
+  if((intersectRay(origin,direction,hit,tnear,tfar,mask) && (hit.gid == geoId || geoId == -1)))
+  {
     bestHit = hit;
+  }
 
   // sample points around actual ray (conservative hitcheck)
   const float eps= 1e-5;
@@ -413,7 +415,10 @@ inline bool igl::embree::EmbreeIntersector::intersectBeam(
 
   for(int r=0;r<samples;r++)
   {
-    if(intersectRay(origin+offset*eps,direction,hit,tnear,tfar,mask) && ((closestHit && (hit.t < bestHit.t)) || (!closestHit && (hit.t > bestHit.t))) && (hit.gid == geoId || geoId == -1))
+    if(intersectRay(origin+offset*eps,direction,hit,tnear,tfar,mask) && 
+        ((closestHit && (hit.t < bestHit.t)) || 
+           (!closestHit && (hit.t > bestHit.t)))  &&
+        (hit.gid == geoId || geoId == -1))
     {
       bestHit = hit;
       hasHit = true;

+ 1 - 1
include/igl/embree/ambient_occlusion.cpp

@@ -77,7 +77,7 @@ IGL_INLINE void igl::embree::ambient_occlusion(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);

+ 1 - 1
include/igl/embree/bone_visible.cpp

@@ -139,7 +139,7 @@ IGL_INLINE void igl::embree::bone_visible(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::embree::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 template void igl::embree::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 #endif

+ 15 - 62
include/igl/embree/unproject_in_mesh.cpp

@@ -7,66 +7,9 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "unproject_in_mesh.h"
 #include "EmbreeIntersector.h"
-#include <igl/unproject.h>
+#include "../unproject.h"
 #include <vector>
 
-#ifndef IGL_OPENGL_4
-template <
-  typename Derivedobj>
-IGL_INLINE int igl::embree::unproject_in_mesh(
-  const double x,
-  const double y,
-  const EmbreeIntersector & ei,
-  Eigen::PlainObjectBase<Derivedobj> & obj)
-{
-  std::vector<igl::embree::Hit> hits;
-  return unproject_in_mesh(x,y,ei,obj,hits);
-}
-
-template <
-  typename Derivedobj>
-IGL_INLINE int igl::embree::unproject_in_mesh(
-  const double x,
-  const double y,
-  const EmbreeIntersector & ei,
-  Eigen::PlainObjectBase<Derivedobj> & obj,
-  std::vector<igl::embree::Hit > & hits)
-{
-  using namespace igl;
-  using namespace std;
-  using namespace Eigen;
-  // Source and direction on screen
-  Vector3f win_s = Vector3f(x,y,0);
-  Vector3f win_d(x,y,1);
-  // Source, destination and direction in world
-  Vector3f s,d,dir;
-  unproject(win_s,s);
-  unproject(win_d,d);
-  dir = d-s;
-  // Shoot ray, collect all hits (could just collect first two)
-  int num_rays_shot;
-  hits.clear();
-  ei.intersectRay(s,dir,hits,num_rays_shot);
-  switch(hits.size())
-  {
-    case 0:
-      break;
-    case 1:
-    {
-      obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
-      break;
-    }
-    case 2:
-    default:
-    {
-      obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
-      break;
-    }
-  }
-  return hits.size();
-}
-#endif
-
 template <typename Derivedobj>
 IGL_INLINE int igl::embree::unproject_in_mesh(
   const Eigen::Vector2f& pos,
@@ -112,12 +55,22 @@ IGL_INLINE int igl::embree::unproject_in_mesh(
   return hits.size();
 }
 
+template <typename Derivedobj>
+IGL_INLINE int igl::embree::unproject_in_mesh(
+    const Eigen::Vector2f& pos,
+    const Eigen::Matrix4f& model,
+    const Eigen::Matrix4f& proj,
+    const Eigen::Vector4f& viewport,
+    const EmbreeIntersector & ei,
+    Eigen::PlainObjectBase<Derivedobj> & obj)
+{
+  std::vector<igl::embree::Hit> hits;
+  return unproject_in_mesh(pos,model,proj,viewport,ei,obj,hits);
+}
+
 
 #ifdef IGL_STATIC_LIBRARY
-#  ifndef IGL_OPENLGL_4
-//template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
-//template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
-#  endif
 template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
 template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
+template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
 #endif

+ 30 - 42
include/igl/embree/unproject_in_mesh.h

@@ -20,62 +20,50 @@ namespace igl
     // Forward define
     class EmbreeIntersector;
   
-    #ifndef IGL_OPENGL_4
     // Unproject a screen location (using current opengl viewport, projection, and
     // model view) to a 3D position _inside_ a given mesh. If the ray through the
     // given screen location (x,y) _hits_ the mesh more than twice then the 3D
     // midpoint between the first two hits is return. If it hits once, then that
     // point is return. If it does not hit the mesh then obj is not set.
     //
+    //
     // Inputs:
-    //    x  x-coordinate of mouse location
-    //    y  y-coordinate of mouse location
-    //    ei  EmbreeIntersector containing (V,F)
+    //    pos        screen space coordinates
+    //    model      model matrix
+    //    proj       projection matrix
+    //    viewport   vieweport vector
+    //    ei         EmbreeIntersector containing (V,F)
     // Outputs:
-    //    obj  3d unprojected mouse point in mesh
+    //    obj        3d unprojected mouse point in mesh
+    //    hits       vector of embree hits
     // Returns number of hits
     //
-    template <
-      typename Derivedobj>
-    IGL_INLINE int unproject_in_mesh(
-      const double x,
-      const double y,
-      const EmbreeIntersector & ei,
-      Eigen::PlainObjectBase<Derivedobj> & obj);
-  
-    template <
-      typename Derivedobj>
+    // Note: Previous prototype did not require model, proj, and viewport. This
+    // has been removed. Instead replace with:
+    //
+    //     Eigen::Matrix4f model,proj;
+    //     Eigen::Vector4f viewport;
+    //     igl::opengl2::model_proj_viewport(model,proj,viewport);
+    //     igl::embree::unproject_in_mesh(Vector2f(x,y),model,proj,viewport,ei,obj,hits);
+    //
+    template < typename Derivedobj>
     IGL_INLINE int unproject_in_mesh(
-      const double x,
-      const double y,
+      const Eigen::Vector2f& pos,
+      const Eigen::Matrix4f& model,
+      const Eigen::Matrix4f& proj,
+      const Eigen::Vector4f& viewport,
       const EmbreeIntersector & ei,
       Eigen::PlainObjectBase<Derivedobj> & obj,
       std::vector<igl::embree::Hit > & hits);
-    #endif
-  
-  // Unproject a screen location (using the given model, proj and viewewport) to a 3D position
-  // and a set of hits
-  //
-  // Inputs:
-  //    pos        screen space coordinates
-  //    model      model matrix
-  //    proj       projection matrix
-  //    viewport   vieweport vector
-  //    ei         EmbreeIntersector containing (V,F)
-  // Outputs:
-  //    obj        3d unprojected mouse point in mesh
-  //    hits       vector of embree hits
-  // Returns number of hits
-  template <
-    typename Derivedobj>
-  IGL_INLINE int unproject_in_mesh(
-    const Eigen::Vector2f& pos,
-    const Eigen::Matrix4f& model,
-    const Eigen::Matrix4f& proj,
-    const Eigen::Vector4f& viewport,
-    const EmbreeIntersector & ei,
-    Eigen::PlainObjectBase<Derivedobj> & obj,
-    std::vector<igl::embree::Hit > & hits);
+    template < typename Derivedobj>
+    IGL_INLINE int unproject_in_mesh(
+      const Eigen::Vector2f& pos,
+      const Eigen::Matrix4f& model,
+      const Eigen::Matrix4f& proj,
+      const Eigen::Vector4f& viewport,
+      const EmbreeIntersector & ei,
+      Eigen::PlainObjectBase<Derivedobj> & obj);
+
   }
 }
 #ifndef IGL_STATIC_LIBRARY

+ 1 - 1
include/igl/embree/unproject_onto_mesh.cpp

@@ -62,5 +62,5 @@ IGL_INLINE bool igl::embree::unproject_onto_mesh(
 
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #endif

+ 1 - 1
include/igl/fit_rotations.cpp

@@ -217,7 +217,7 @@ IGL_INLINE void igl::fit_rotations_AVX(
 #endif
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::fit_rotations<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template void igl::fit_rotations_planar<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template void igl::fit_rotations_planar<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);

+ 0 - 1
include/igl/flare_textures.h.REMOVED.git-id

@@ -1 +0,0 @@
-3d9ea820d2a9d829dd08bbdb0fe53b38ee19a50c

+ 1 - 1
include/igl/forward_kinematics.cpp

@@ -80,5 +80,5 @@ IGL_INLINE void igl::forward_kinematics(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #endif

+ 1 - 1
include/igl/group_sum_matrix.cpp

@@ -40,7 +40,7 @@ IGL_INLINE void igl::group_sum_matrix(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template void igl::group_sum_matrix<double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int, Eigen::SparseMatrix<double, 0, int>&);
 template void igl::group_sum_matrix<double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 1 - 1
include/igl/harmonic.cpp

@@ -65,7 +65,7 @@ IGL_INLINE bool igl::harmonic(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 template bool igl::harmonic<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&); 
 template bool igl::harmonic<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 0 - 39
include/igl/init_render_to_texture.h

@@ -1,39 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_INIT_RENDER_TO_TEXTURE_H
-#define IGL_INIT_RENDER_TO_TEXTURE_H
-#include "igl_inline.h"
-#include "OpenGL_convenience.h"
-#include <cstdlib>
-namespace igl
-{
-  #ifndef IGL_NO_OPENGL
-
-  // Create a texture+framebuffer+depthbuffer triplet bound for rendering into
-  // the texture;
-  //
-  // Inputs:
-  //   width  image width
-  //   height image height
-  // Outputs:
-  //   tex_id  id of the texture
-  //   fbo_id  id of the frame buffer object
-  //   dfbo_id  id of the depth frame buffer object
-  IGL_INLINE void init_render_to_texture(
-    const size_t width,
-    const size_t height,
-    GLuint & tex_id,
-    GLuint & fbo_id,
-    GLuint & dfbo_id);
-
-  #endif
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "init_render_to_texture.cpp"
-#endif
-#endif

+ 0 - 92
include/igl/lens_flare.h

@@ -1,92 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_LENS_FLARE_H
-#define IGL_LENS_FLARE_H
-
-#ifndef IGL_NO_OPENGL
-#include <igl/OpenGL_convenience.h>
-#include <Eigen/Core>
-#include "igl_inline.h"
-
-#include <vector>
-
-namespace igl
-{
-  struct Flare{
-    int type;             /* flare texture index, 0..5 */
-    float scale;
-    float loc;            /* postion on axis */
-    float color[3];
-    Flare():
-      type(-1),
-      scale(0),
-      loc(0)
-    {}
-    Flare(int type, float location, float scale, const float color[3], float colorScale) :
-      type(type),
-      scale(scale),
-      loc(location)
-    {
-      this->color[0] = color[0] * colorScale;
-      this->color[1] = color[1] * colorScale;
-      this->color[2] = color[2] * colorScale;
-    }
-  };
-  
-  
-  // Initialize shared data for lens flates
-  //
-  // Inputs:
-  //   start_id   starting texture id location (should have at least id:id+16 free)
-  // Outputs:
-  //   shine  list of texture ids for shines
-  //   flare  list of texture ids for flares
-  IGL_INLINE void lens_flare_load_textures(
-    std::vector<GLuint> & shine_ids,
-    std::vector<GLuint> & flare_ids);
-  
-  // Create a set of lens flares
-  //
-  // Inputs:
-  //   A  primary color
-  //   B  secondary color
-  //   C  secondary color
-  // Outputs:
-  //   flares  list of flare objects
-  IGL_INLINE void lens_flare_create(
-    const float * A,
-    const float * B,
-    const float * C,
-    std::vector<Flare> & flares);
-  
-  // Draw lens flares
-  //
-  // Inputs:
-  //   flares  list of Flare objects
-  //   shine_ids  list of shine textures
-  //   flare_ids  list of flare texture ids
-  //   light  position of light
-  //   near_clip  near clipping plane
-  //   shine_tic  current "tic" in shine textures
-  // Outputs:
-  //   shine_tic  current "tic" in shine textures
-  IGL_INLINE void lens_flare_draw(
-    const std::vector<Flare> & flares,
-    const std::vector<GLuint> & shine_ids,
-    const std::vector<GLuint> & flare_ids,
-    const Eigen::Vector3f & light,
-    const float near_clip,
-    int & shine_tic);
-};
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "lens_flare.cpp"
-#endif
-
-#endif
-#endif

+ 1 - 1
include/igl/lim/lim.cpp

@@ -132,5 +132,5 @@ IGL_INLINE int igl::lim(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template instanciation
+// Explicit template specialization
 #endif

+ 0 - 33
include/igl/load_shader.h

@@ -1,33 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_LOAD_SHADER_H 
-#define IGL_LOAD_SHADER_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h" 
-
-#include "OpenGL_convenience.h"
-
-namespace igl
-{
-  // Creates and compiles a shader from a given string
-  // Inputs:
-  //   src  string containing GLSL shader code
-  //   type  GLSL type of shader, one of:
-  //     GL_VERTEX_SHADER
-  //     GL_FRAGMENT_SHADER
-  //     GL_GEOMETRY_SHADER
-  // Returns  index id of the newly created shader, 0 on error
-  IGL_INLINE GLuint load_shader(const char *src,const GLenum type);
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "load_shader.cpp"
-#endif
-
-#endif
-#endif

+ 2 - 5
include/igl/OpenGL_convenience.h → include/igl/opengl/OpenGL_convenience.h

@@ -5,9 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_OPENGL_CONVENIENCE_H
-#define IGL_OPENGL_CONVENIENCE_H
-#ifndef IGL_NO_OPENGL
+#ifndef IGL_OPENGL_OPENGL_CONVENIENCE_H
+#define IGL_OPENGL_OPENGL_CONVENIENCE_H
 
 // Always use this:
 //     #include "OpenGL_convenience.h"
@@ -33,5 +32,3 @@
 #endif
 
 #endif
-#endif
-

+ 4 - 6
include/igl/compile_and_link_program.cpp → include/igl/opengl/compile_and_link_program.cpp

@@ -11,9 +11,8 @@
 #include <iostream>
 #include <cassert>
 
-#ifndef IGL_NO_OPENGL
 
-IGL_INLINE GLuint igl::compile_and_link_program(
+IGL_INLINE GLuint igl::opengl::compile_and_link_program(
   const char * v_str, const char * f_str)
 {
   GLuint vid = compile_shader(GL_VERTEX_SHADER,v_str);
@@ -22,12 +21,12 @@ IGL_INLINE GLuint igl::compile_and_link_program(
   GLuint prog_id = glCreateProgram();
   assert(prog_id != 0 && "Failed to create shader.");
   glAttachShader(prog_id,vid);
-  igl::report_gl_error("glAttachShader (vid): ");
+  report_gl_error("glAttachShader (vid): ");
   glAttachShader(prog_id,fid);
-  igl::report_gl_error("glAttachShader (fid): ");
+  report_gl_error("glAttachShader (fid): ");
 
   glLinkProgram(prog_id);
-  igl::report_gl_error("glLinkProgram: ");
+  report_gl_error("glLinkProgram: ");
 
   GLint status;
   glGetProgramiv(prog_id, GL_LINK_STATUS, &status);
@@ -41,4 +40,3 @@ IGL_INLINE GLuint igl::compile_and_link_program(
   return prog_id;
 }
 
-#endif

+ 32 - 0
include/igl/opengl/compile_and_link_program.h

@@ -0,0 +1,32 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_COMPILE_AND_LINK_PROGRAM_H
+#define IGL_OPENGL_COMPILE_AND_LINK_PROGRAM_H
+#include "../igl_inline.h"
+#include "OpenGL_convenience.h"
+namespace igl
+{
+  namespace opengl
+  {
+    // Compile and link very simple vertex/fragment shaders
+    //
+    // Inputs:
+    //   v_str  string of vertex shader contents
+    //   f_str  string of fragment shader contents
+    // Returns id of program
+    //
+    // Known bugs: this seems to duplicate `create_shader_program` with less
+    // functionality.
+    IGL_INLINE GLuint compile_and_link_program(
+      const char * v_str, const char * f_str);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "compile_and_link_program.cpp"
+#endif
+#endif

+ 4 - 8
include/igl/compile_shader.cpp → include/igl/opengl/compile_shader.cpp

@@ -9,16 +9,14 @@
 #include "report_gl_error.h"
 #include <iostream>
 
-#ifndef IGL_NO_OPENGL
-
-IGL_INLINE GLuint igl::compile_shader(const GLint type, const char * str)
+IGL_INLINE GLuint igl::opengl::compile_shader(const GLint type, const char * str)
 {
   GLuint id = glCreateShader(type);
-  igl::report_gl_error("glCreateShader: ");
+  report_gl_error("glCreateShader: ");
   glShaderSource(id,1,&str,NULL);
-  igl::report_gl_error("glShaderSource: ");
+  report_gl_error("glShaderSource: ");
   glCompileShader(id);
-  igl::report_gl_error("glCompileShader: ");
+  report_gl_error("glCompileShader: ");
 
   GLint status;
   glGetShaderiv(id, GL_COMPILE_STATUS, &status);
@@ -35,5 +33,3 @@ IGL_INLINE GLuint igl::compile_shader(const GLint type, const char * str)
   }
   return id;
 }
-
-#endif

+ 38 - 0
include/igl/opengl/compile_shader.h

@@ -0,0 +1,38 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_COMPILE_SHADER_H
+#define IGL_OPENGL_COMPILE_SHADER_H
+#include "OpenGL_convenience.h"
+#include "../igl_inline.h"
+namespace igl
+{
+  namespace opengl
+  {
+    // Compile a shader given type and string of shader code
+    //
+    // Inputs:
+    //   type  either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
+    //   str  contents of shader code
+    // Returns result of glCreateShader (id of shader)
+    //
+    // Example:
+    //     GLuint vid = compile_shader(GL_VERTEX_SHADER,vertex_shader.c_str());
+    //     GLuint fid = compile_shader(GL_FRAGMENT_SHADER,fragment_shader.c_str());
+    //     GLuint prog_id = glCreateProgram();
+    //     glAttachShader(prog_id,vid);
+    //     glAttachShader(prog_id,fid);
+    //     glLinkProgram(prog_id);
+    //
+    // Known bugs: seems to be duplicate of `load_shader`
+    IGL_INLINE GLuint compile_shader(const GLint type, const char * str);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "compile_shader.cpp"
+#endif
+#endif

+ 1 - 3
include/igl/create_index_vbo.cpp → include/igl/opengl/create_index_vbo.cpp

@@ -7,9 +7,8 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #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(
+IGL_INLINE void igl::opengl::create_index_vbo(
   const Eigen::MatrixXi & F,
   GLuint & F_vbo_id)
 {
@@ -41,7 +40,6 @@ 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
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization

+ 14 - 15
include/igl/create_index_vbo.h → include/igl/opengl/create_index_vbo.h

@@ -5,29 +5,29 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CREATE_INDEX_VBO_H
-#define IGL_CREATE_INDEX_VBO_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_CREATE_INDEX_VBO_H
+#define IGL_OPENGL_CREATE_INDEX_VBO_H
+#include "../igl_inline.h"
 // NOTE: It wouldn't be so hard to template this using Eigen's templates
 
 #include <Eigen/Core>
-
 #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)
 namespace igl
 {
-
-  // Inputs:
-  //   F  #F by 3 eigen Matrix of face (triangle) indices
-  // Outputs:
-  //   F_vbo_id  buffer id for face indices
-  //
-  IGL_INLINE void create_index_vbo(
-    const Eigen::MatrixXi & F,
-    GLuint & F_vbo_id);
+  namespace opengl
+  {
+    // Inputs:
+    //   F  #F by 3 eigen Matrix of face (triangle) indices
+    // Outputs:
+    //   F_vbo_id  buffer id for face indices
+    //
+    IGL_INLINE void create_index_vbo(
+      const Eigen::MatrixXi & F,
+      GLuint & F_vbo_id);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -35,4 +35,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 2 - 4
include/igl/create_mesh_vbo.cpp → include/igl/opengl/create_mesh_vbo.cpp

@@ -6,13 +6,12 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "create_mesh_vbo.h"
-#ifndef IGL_NO_OPENGL
 
 #include "create_vector_vbo.h"
 #include "create_index_vbo.h"
 
 // http://www.songho.ca/opengl/gl_vbo.html#create
-IGL_INLINE void igl::create_mesh_vbo(
+IGL_INLINE void igl::opengl::create_mesh_vbo(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   GLuint & V_vbo_id,
@@ -25,7 +24,7 @@ IGL_INLINE void igl::create_mesh_vbo(
 }
 
 // http://www.songho.ca/opengl/gl_vbo.html#create
-IGL_INLINE void igl::create_mesh_vbo(
+IGL_INLINE void igl::opengl::create_mesh_vbo(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & N,
@@ -42,4 +41,3 @@ IGL_INLINE void igl::create_mesh_vbo(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 #endif
-#endif

+ 64 - 0
include/igl/opengl/create_mesh_vbo.h

@@ -0,0 +1,64 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_CREATE_MESH_VBO_H
+#define IGL_OPENGL_CREATE_MESH_VBO_H
+#include "../igl_inline.h"
+// NOTE: It wouldn't be so hard to template this using Eigen's templates
+
+#include <Eigen/Core>
+
+#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
+// GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
+namespace igl
+{
+  namespace opengl
+  {
+  
+    // Inputs:
+    //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
+    //   F  #F by 3 eigne Matrix of face (triangle) indices
+    // Outputs:
+    //   V_vbo_id  buffer id for vertex positions
+    //   F_vbo_id  buffer id for face indices
+    //
+    // NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
+    // MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
+    //
+    IGL_INLINE void create_mesh_vbo(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      GLuint & V_vbo_id,
+      GLuint & F_vbo_id);
+  
+    // Inputs:
+    //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
+    //   F  #F by 3 eigne Matrix of face (triangle) indices
+    //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
+    // Outputs:
+    //   V_vbo_id  buffer id for vertex positions
+    //   F_vbo_id  buffer id for face indices
+    //   N_vbo_id  buffer id for vertex positions
+    IGL_INLINE void create_mesh_vbo(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      const Eigen::MatrixXd & N,
+      GLuint & V_vbo_id,
+      GLuint & F_vbo_id,
+      GLuint & N_vbo_id);
+  }
+
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "create_mesh_vbo.cpp"
+#endif
+
+#endif

+ 11 - 9
include/igl/create_shader_program.cpp → include/igl/opengl/create_shader_program.cpp

@@ -6,14 +6,13 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "create_shader_program.h"
-#ifndef IGL_NO_OPENGL
 
 #include "load_shader.h"
 #include "print_program_info_log.h"
 #include <iostream>
 #include <cstdio>
 
-IGL_INLINE bool igl::create_shader_program(
+IGL_INLINE bool igl::opengl::create_shader_program(
   const std::string & geom_source,
   const std::string & vert_source,
   const std::string & frag_source,
@@ -40,7 +39,7 @@ IGL_INLINE bool igl::create_shader_program(
   if(geom_source != "")
   {
     // load vertex shader
-    GLuint g = igl::load_shader(geom_source.c_str(),GL_GEOMETRY_SHADER_EXT);
+    GLuint g = igl::opengl::load_shader(geom_source.c_str(),GL_GEOMETRY_SHADER_EXT);
     if(g == 0)
     {
       cerr<<"geometry shader failed to compile."<<endl;
@@ -52,7 +51,7 @@ IGL_INLINE bool igl::create_shader_program(
   if(vert_source != "")
   {
     // load vertex shader
-    GLuint v = igl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
+    GLuint v = igl::opengl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
     if(v == 0)
     {
       cerr<<"vertex shader failed to compile."<<endl;
@@ -64,7 +63,7 @@ IGL_INLINE bool igl::create_shader_program(
   if(frag_source != "")
   {
     // load fragment shader
-    GLuint f = igl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
+    GLuint f = igl::opengl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
     if(f == 0)
     {
       cerr<<"fragment shader failed to compile."<<endl;
@@ -88,12 +87,12 @@ IGL_INLINE bool igl::create_shader_program(
   glLinkProgram(id);
 
   // print log if any
-  igl::print_program_info_log(id);
+  igl::opengl::print_program_info_log(id);
 
   return true;
 }
 
-IGL_INLINE bool igl::create_shader_program(
+IGL_INLINE bool igl::opengl::create_shader_program(
   const std::string & vert_source,
   const std::string & frag_source,
   const std::map<std::string,GLuint> & attrib,
@@ -103,7 +102,7 @@ IGL_INLINE bool igl::create_shader_program(
 }
 
 
-IGL_INLINE GLuint igl::create_shader_program(
+IGL_INLINE GLuint igl::opengl::create_shader_program(
   const std::string & geom_source,
   const std::string & vert_source,
   const std::string & frag_source,
@@ -114,7 +113,7 @@ IGL_INLINE GLuint igl::create_shader_program(
   return prog_id;
 }
 
-IGL_INLINE GLuint igl::create_shader_program(
+IGL_INLINE GLuint igl::opengl::create_shader_program(
   const std::string & vert_source,
   const std::string & frag_source,
   const std::map<std::string,GLuint> & attrib)
@@ -124,4 +123,7 @@ IGL_INLINE GLuint igl::create_shader_program(
   return prog_id;
 }
 
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
 #endif
+

+ 66 - 0
include/igl/opengl/create_shader_program.h

@@ -0,0 +1,66 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_CREATE_SHADER_PROGRAM_H
+#define IGL_OPENGL_CREATE_SHADER_PROGRAM_H
+
+#include "../igl_inline.h"
+#include <string>
+#include <map>
+
+#include "OpenGL_convenience.h"
+
+namespace igl
+{
+  namespace opengl
+  {
+    // Create a shader program with a vertex and fragments shader loading from
+    // source strings and vertex attributes assigned from a map before linking the
+    // shaders to the program, making it ready to use with glUseProgram(id)
+    // Inputs:
+    //   geom_source  string containing source code of geometry shader (can be
+    //     "" to mean use default pass-through)
+    //   vert_source  string containing source code of vertex shader
+    //   frag_source  string containing source code of fragment shader
+    //   attrib  map containing table of vertex attribute strings add their
+    //   correspondingly ids (generated previously using glBindAttribLocation)
+    // Outputs:
+    //   id  index id of created shader, set to 0 on error
+    // Returns true on success, false on error
+    //
+    // Note: Caller is responsible for making sure that current value of id is not
+    // leaking a shader (since it will be overwritten)
+    //
+    // See also: destroy_shader_program
+    IGL_INLINE bool create_shader_program(
+      const std::string &geom_source,
+      const std::string &vert_source,
+      const std::string &frag_source,
+      const std::map<std::string,GLuint> &attrib,
+      GLuint & id);
+    IGL_INLINE bool create_shader_program(
+      const std::string &vert_source,
+      const std::string &frag_source,
+      const std::map<std::string,GLuint> &attrib,
+      GLuint & id);
+    IGL_INLINE GLuint create_shader_program(
+      const std::string & geom_source,
+      const std::string & vert_source,
+      const std::string & frag_source,
+      const std::map<std::string,GLuint> &attrib);
+    IGL_INLINE GLuint create_shader_program(
+      const std::string & vert_source,
+      const std::string & frag_source,
+      const std::map<std::string,GLuint> &attrib);
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "create_shader_program.cpp"
+#endif
+
+#endif

+ 3 - 5
include/igl/create_vector_vbo.cpp → include/igl/opengl/create_vector_vbo.cpp

@@ -6,13 +6,12 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "create_vector_vbo.h"
-#ifndef IGL_NO_OPENGL
 
 #include <cassert>
 
 // http://www.songho.ca/opengl/gl_vbo.html#create
 template <typename T>
-IGL_INLINE void igl::create_vector_vbo(
+IGL_INLINE void igl::opengl::create_vector_vbo(
   const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & V,
   GLuint & V_vbo_id)
 {
@@ -51,9 +50,8 @@ IGL_INLINE void igl::create_vector_vbo(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // generated by autoexplicit.sh
-template void igl::create_vector_vbo<int>(Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, unsigned int&);
+template void igl::opengl::create_vector_vbo<int>(Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, unsigned int&);
 // generated by autoexplicit.sh
-template void igl::create_vector_vbo<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, unsigned int&);
+template void igl::opengl::create_vector_vbo<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, unsigned int&);
 #endif
 
-#endif

+ 17 - 17
include/igl/create_vector_vbo.h → include/igl/opengl/create_vector_vbo.h

@@ -5,10 +5,9 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CREATE_VECTOR_VBO_H
-#define IGL_CREATE_VECTOR_VBO_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_CREATE_VECTOR_VBO_H
+#define IGL_OPENGL_CREATE_VECTOR_VBO_H
+#include "../igl_inline.h"
 // NOTE: It wouldn't be so hard to template this using Eigen's templates
 
 #include <Eigen/Core>
@@ -19,18 +18,20 @@
 // GL_ARRAY_BUFFER for the vectors (V)
 namespace igl
 {
-
-  // Templates:
-  //   T  should be a eigen matrix primitive type like int or double
-  // Inputs:
-  //   V  m by n eigen Matrix of type T values
-  // Outputs:
-  //   V_vbo_id  buffer id for vectors
-  //
-  template <typename T>
-  IGL_INLINE void create_vector_vbo(
-    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & V,
-    GLuint & V_vbo_id);
+  namespace opengl
+  {
+    // Templates:
+    //   T  should be a eigen matrix primitive type like int or double
+    // Inputs:
+    //   V  m by n eigen Matrix of type T values
+    // Outputs:
+    //   V_vbo_id  buffer id for vectors
+    //
+    template <typename T>
+    IGL_INLINE void create_vector_vbo(
+      const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & V,
+      GLuint & V_vbo_id);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -38,4 +39,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 6 - 3
include/igl/destroy_shader_program.cpp → include/igl/opengl/destroy_shader_program.cpp

@@ -6,11 +6,10 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "destroy_shader_program.h"
-#ifndef IGL_NO_OPENGL
 #include <cstdio>
 #include "report_gl_error.h"
 
-IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
+IGL_INLINE bool igl::opengl::destroy_shader_program(const GLuint id)
 {
   // Don't try to destroy id == 0 (no shader program)
   if(id == 0)
@@ -27,7 +26,7 @@ IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
   {
     // Try to get at most *1* attached shader
     glGetAttachedShaders(id,1,&count,&s);
-    GLenum err = igl::report_gl_error();
+    GLenum err = igl::opengl::report_gl_error();
     if (GL_NO_ERROR != err)
     {
       return false;
@@ -44,4 +43,8 @@ IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
   glDeleteProgram(id);
   return true;
 }
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
 #endif
+

+ 36 - 0
include/igl/opengl/destroy_shader_program.h

@@ -0,0 +1,36 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_DESTROY_SHADER_PROGRAM_H
+#define IGL_OPENGL_DESTROY_SHADER_PROGRAM_H
+#include "../igl_inline.h"
+
+#include "OpenGL_convenience.h"
+
+namespace igl
+{
+  namespace opengl
+  {
+    // Properly destroy a shader program. Detach and delete each of its shaders
+    // and delete it
+    // Inputs:
+    //   id  index id of created shader, set to 0 on error
+    // Returns true on success, false on error
+    // 
+    // Note: caller is responsible for making sure he doesn't foolishly continue
+    // to use id as if it still contains a program
+    // 
+    // See also: create_shader_program
+    IGL_INLINE bool destroy_shader_program(const GLuint id);
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "destroy_shader_program.cpp"
+#endif
+
+#endif

+ 1 - 3
include/igl/gl_type_size.cpp → include/igl/opengl/gl_type_size.cpp

@@ -6,10 +6,9 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "gl_type_size.h"
-#ifndef IGL_NO_OPENGL
 #include <cassert>
 
-IGL_INLINE int igl::gl_type_size(const GLenum type)
+IGL_INLINE int igl::opengl::gl_type_size(const GLenum type)
 {
   switch(type)
   {
@@ -29,4 +28,3 @@ IGL_INLINE int igl::gl_type_size(const GLenum type)
   }
   return -1;
 }
-#endif

+ 10 - 10
include/igl/gl_type_size.h → include/igl/opengl/gl_type_size.h

@@ -5,20 +5,21 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_GL_TYPE_SIZE_H
-#define IGL_GL_TYPE_SIZE_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_GL_TYPE_SIZE_H
+#define IGL_OPENGL_GL_TYPE_SIZE_H
+#include "../igl_inline.h"
 
 #include "OpenGL_convenience.h"
 
 namespace igl
 {
-  // Return the number of bytes for a given OpenGL type
-  // Inputs:
-  //   type  enum value of opengl type
-  // Returns size in bytes of type
-  IGL_INLINE int gl_type_size(const GLenum type);
+  namespace opengl
+  {
+    // Return the number of bytes for a given OpenGL type // Inputs:
+    //   type  enum value of opengl type
+    // Returns size in bytes of type
+    IGL_INLINE int gl_type_size(const GLenum type);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -26,4 +27,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 1 - 5
include/igl/init_render_to_texture.cpp → include/igl/opengl/init_render_to_texture.cpp

@@ -8,9 +8,7 @@
 #include "init_render_to_texture.h"
 #include <cassert>
 
-#ifndef IGL_NO_OPENGL
-
-IGL_INLINE void igl::init_render_to_texture(
+IGL_INLINE void igl::opengl::init_render_to_texture(
   const size_t width,
   const size_t height,
   GLuint & tex_id,
@@ -52,5 +50,3 @@ IGL_INLINE void igl::init_render_to_texture(
   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 }
-
-#endif

+ 38 - 0
include/igl/opengl/init_render_to_texture.h

@@ -0,0 +1,38 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_INIT_RENDER_TO_TEXTURE_H
+#define IGL_OPENGL_INIT_RENDER_TO_TEXTURE_H
+#include "../igl_inline.h"
+#include "OpenGL_convenience.h"
+#include <cstdlib>
+namespace igl
+{
+  namespace opengl
+  {
+    // Create a texture+framebuffer+depthbuffer triplet bound for rendering into
+    // the texture;
+    //
+    // Inputs:
+    //   width  image width
+    //   height image height
+    // Outputs:
+    //   tex_id  id of the texture
+    //   fbo_id  id of the frame buffer object
+    //   dfbo_id  id of the depth frame buffer object
+    IGL_INLINE void init_render_to_texture(
+      const size_t width,
+      const size_t height,
+      GLuint & tex_id,
+      GLuint & fbo_id,
+      GLuint & dfbo_id);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "init_render_to_texture.cpp"
+#endif
+#endif

+ 2 - 4
include/igl/load_shader.cpp → include/igl/opengl/load_shader.cpp

@@ -6,12 +6,11 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "load_shader.h"
-#ifndef IGL_NO_OPENGL
 
 // Copyright Denis Kovacs 4/10/08
 #include "print_shader_info_log.h"
 #include <cstdio>
-IGL_INLINE GLuint igl::load_shader(const char *src,const GLenum type)
+IGL_INLINE GLuint igl::opengl::load_shader(const char *src,const GLenum type)
 {
   GLuint s = glCreateShader(type);
   if(s == 0)
@@ -23,7 +22,6 @@ IGL_INLINE GLuint igl::load_shader(const char *src,const GLenum type)
   glShaderSource(s, 1, &src, NULL);
   glCompileShader(s);
   // Print info log (if any)
-  igl::print_shader_info_log(s);
+  igl::opengl::print_shader_info_log(s);
   return s;
 }
-#endif

+ 34 - 0
include/igl/opengl/load_shader.h

@@ -0,0 +1,34 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_LOAD_SHADER_H 
+#define IGL_OPENGL_LOAD_SHADER_H
+#include "../igl_inline.h" 
+
+#include "OpenGL_convenience.h"
+
+namespace igl
+{
+  namespace opengl
+  {
+    // Creates and compiles a shader from a given string
+    // Inputs:
+    //   src  string containing GLSL shader code
+    //   type  GLSL type of shader, one of:
+    //     GL_VERTEX_SHADER
+    //     GL_FRAGMENT_SHADER
+    //     GL_GEOMETRY_SHADER
+    // Returns  index id of the newly created shader, 0 on error
+    IGL_INLINE GLuint load_shader(const char *src,const GLenum type);
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "load_shader.cpp"
+#endif
+
+#endif

+ 1 - 3
include/igl/print_program_info_log.cpp → include/igl/opengl/print_program_info_log.cpp

@@ -6,12 +6,11 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "print_program_info_log.h"
-#ifndef IGL_NO_OPENGL
 
 #include <cstdio>
 #include <stdlib.h>
 // Copyright Denis Kovacs 4/10/08
-IGL_INLINE void igl::print_program_info_log(const GLuint obj)
+IGL_INLINE void igl::opengl::print_program_info_log(const GLuint obj)
 {
   GLint infologLength = 0;
   GLint charsWritten  = 0;
@@ -27,4 +26,3 @@ IGL_INLINE void igl::print_program_info_log(const GLuint obj)
     free(infoLog);
   }
 }
-#endif

+ 9 - 8
include/igl/print_program_info_log.h → include/igl/opengl/print_program_info_log.h

@@ -5,18 +5,20 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_PRINT_PROGRAM_INFO_LOG_H
-#define IGL_PRINT_PROGRAM_INFO_LOG_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_PRINT_PROGRAM_INFO_LOG_H
+#define IGL_OPENGL_PRINT_PROGRAM_INFO_LOG_H
+#include "../igl_inline.h"
 
 #include "OpenGL_convenience.h"
 
 namespace igl
 {
-  // Inputs:
-  //   obj  OpenGL index of program to print info log about
-  IGL_INLINE void print_program_info_log(const GLuint obj);
+  namespace opengl
+  {
+    // Inputs:
+    //   obj  OpenGL index of program to print info log about
+    IGL_INLINE void print_program_info_log(const GLuint obj);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -24,4 +26,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 1 - 3
include/igl/print_shader_info_log.cpp → include/igl/opengl/print_shader_info_log.cpp

@@ -6,12 +6,11 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "print_shader_info_log.h"
-#ifndef IGL_NO_OPENGL
 
 #include <cstdio>
 #include <stdlib.h>
 // Copyright Denis Kovacs 4/10/08
-IGL_INLINE void igl::print_shader_info_log(const GLuint obj)
+IGL_INLINE void igl::opengl::print_shader_info_log(const GLuint obj)
 {
   GLint infologLength = 0;
   GLint charsWritten  = 0;
@@ -28,4 +27,3 @@ IGL_INLINE void igl::print_shader_info_log(const GLuint obj)
     free(infoLog);
   }
 }
-#endif

+ 9 - 8
include/igl/print_shader_info_log.h → include/igl/opengl/print_shader_info_log.h

@@ -5,18 +5,20 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_PRINT_SHADER_INFO_LOG_H
-#define IGL_PRINT_SHADER_INFO_LOG_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_PRINT_SHADER_INFO_LOG_H
+#define IGL_OPENGL_PRINT_SHADER_INFO_LOG_H
+#include "../igl_inline.h"
 
 #include "OpenGL_convenience.h"
 
 namespace igl
 {
-  // Inputs:
-  //   obj  OpenGL index of shader to print info log about
-  IGL_INLINE void print_shader_info_log(const GLuint obj);
+  namespace opengl
+  {
+    // Inputs:
+    //   obj  OpenGL index of shader to print info log about
+    IGL_INLINE void print_shader_info_log(const GLuint obj);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -24,4 +26,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 3 - 2
include/igl/render_to_tga.cpp → include/igl/opengl/render_to_tga.cpp

@@ -6,14 +6,13 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "render_to_tga.h"
-#ifndef IGL_NO_OPENGL
 #include "tga.h"
 
 #include "OpenGL_convenience.h"
 
 #include <cstdlib>
 
-IGL_INLINE bool igl::render_to_tga(
+IGL_INLINE bool igl::opengl::render_to_tga(
   const std::string tga_file,
   const int width,
   const int height,
@@ -83,4 +82,6 @@ IGL_INLINE bool igl::render_to_tga(
   return fclose(imgFile) == 0;
 }
 
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
 #endif

+ 38 - 0
include/igl/opengl/render_to_tga.h

@@ -0,0 +1,38 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_OPENGL_RENDER_TO_TGA_H
+#define IGL_OPENGL_RENDER_TO_TGA_H
+#include "../igl_inline.h"
+
+#include <string>
+namespace igl
+{
+  namespace opengl
+  {
+    // Render current open GL image to .tga file
+    // Inputs:
+    //   tga_file  path to output .tga file
+    //   width  width of scene and resulting image
+    //   height height of scene and resulting image
+    ///  alpha  whether to include alpha channel
+    // Returns true only if no errors occured
+    //
+    // See also: png/render_to_png which is slower but writes .png files
+    IGL_INLINE bool render_to_tga(
+      const std::string tga_file,
+      const int width,
+      const int height,
+      const bool alpha);
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "render_to_tga.cpp"
+#endif
+
+#endif

+ 60 - 0
include/igl/opengl/report_gl_error.cpp

@@ -0,0 +1,60 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "report_gl_error.h"
+
+#include <cstdio>
+#include "../verbose.h"
+
+IGL_INLINE GLenum igl::opengl::report_gl_error(const std::string id)
+{
+  // http://stackoverflow.com/q/28485180/148668
+
+  // gluErrorString was deprecated
+  const auto gluErrorString = [](GLenum errorCode)->const char *
+  {
+    switch(errorCode)
+    {
+      default:
+        return "unknown error code";
+      case GL_NO_ERROR:
+        return "no error";
+      case GL_INVALID_ENUM:
+        return "invalid enumerant";
+      case GL_INVALID_VALUE:
+        return "invalid value";
+      case GL_INVALID_OPERATION:
+        return "invalid operation";
+      case GL_STACK_OVERFLOW:
+        return "stack overflow";
+      case GL_STACK_UNDERFLOW:
+        return "stack underflow";
+      case GL_OUT_OF_MEMORY:
+        return "out of memory";
+      case GL_TABLE_TOO_LARGE:
+        return "table too large";
+#ifdef GL_EXT_framebuffer_object
+      case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
+        return "invalid framebuffer operation";
+#endif
+    }
+  };
+
+  GLenum err = glGetError();
+  if(GL_NO_ERROR != err)
+  {
+    verbose("GL_ERROR: ");
+    fprintf(stderr,"%s%s\n",id.c_str(),gluErrorString(err));
+  }
+  return err;
+}
+
+IGL_INLINE GLenum igl::opengl::report_gl_error()
+{
+  return igl::opengl::report_gl_error(std::string(""));
+}
+

+ 13 - 12
include/igl/report_gl_error.h → include/igl/opengl/report_gl_error.h

@@ -5,10 +5,9 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_REPORT_GL_ERROR_H
-#define IGL_REPORT_GL_ERROR_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_REPORT_GL_ERROR_H
+#define IGL_OPENGL_REPORT_GL_ERROR_H
+#include "../igl_inline.h"
 
 #include "OpenGL_convenience.h"
 
@@ -16,13 +15,16 @@
 
 namespace igl
 {
-  // Print last OpenGL error to stderr prefixed by specified id string
-  // Inputs:
-  //   id   string to appear before any error msgs
-  // Returns result of glGetError() 
-  IGL_INLINE GLenum report_gl_error(const std::string id);
-  // No prefix
-  IGL_INLINE GLenum report_gl_error();
+  namespace opengl
+  {
+    // Print last OpenGL error to stderr prefixed by specified id string
+    // Inputs:
+    //   id   string to appear before any error msgs
+    // Returns result of glGetError() 
+    IGL_INLINE GLenum report_gl_error(const std::string id);
+    // No prefix
+    IGL_INLINE GLenum report_gl_error();
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -30,4 +32,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 4 - 3
include/igl/texture_from_tga.cpp → include/igl/opengl/texture_from_tga.cpp

@@ -6,13 +6,12 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "texture_from_tga.h"
-#ifndef IGL_NO_OPENGL
 
 #include "tga.h"
 #include "report_gl_error.h"
 #include <cstring>
 
-IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
+IGL_INLINE bool igl::opengl::texture_from_tga(const std::string tga_file, GLuint & id)
 {
   using namespace std;
 
@@ -57,7 +56,7 @@ IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
     img->format == GL_BGR))
   {
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    igl::report_gl_error();
+    igl::opengl::report_gl_error();
   }
 
   // Load texture
@@ -67,4 +66,6 @@ IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
   return id;
 }
 
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
 #endif

+ 14 - 13
include/igl/texture_from_tga.h → include/igl/opengl/texture_from_tga.h

@@ -5,10 +5,9 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_TEXTURE_FROM_TGA_H
-#define IGL_TEXTURE_FROM_TGA_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_TEXTURE_FROM_TGA_H
+#define IGL_OPENGL_TEXTURE_FROM_TGA_H
+#include "../igl_inline.h"
 
 #include "OpenGL_convenience.h"
 
@@ -16,14 +15,17 @@
 
 namespace igl
 {
-  // Read an image from a .tga file and use it as a texture
-  //
-  // Input:
-  //  tga_file  path to .tga file
-  // Output:
-  //  id  of generated openGL texture
-  // Returns true on success, false on failure
-  IGL_INLINE bool texture_from_tga(const std::string tga_file, GLuint & id);
+  namespace opengl
+  {
+    // Read an image from a .tga file and use it as a texture
+    //
+    // Input:
+    //  tga_file  path to .tga file
+    // Output:
+    //  id  of generated openGL texture
+    // Returns true on success, false on failure
+    IGL_INLINE bool texture_from_tga(const std::string tga_file, GLuint & id);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -31,4 +33,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 8 - 10
include/igl/tga.cpp → include/igl/opengl/tga.cpp

@@ -46,7 +46,6 @@
 #include <assert.h>
 
 #include "tga.h"
-#ifndef IGL_NO_OPENGL
 
 
 static char error[256];
@@ -184,11 +183,11 @@ rle_fread(RLEstate *rleInfo, unsigned char *vbuf, size_t datasize, size_t nelems
   return nelems;
 }
 
-IGL_INLINE igl::gliGenericImage *
-igl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
+IGL_INLINE igl::opengl::gliGenericImage *
+igl::opengl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
 {
-  igl::TgaHeader tgaHeader;
-  igl::TgaFooter tgaFooter;
+  igl::opengl::TgaHeader tgaHeader;
+  igl::opengl::TgaFooter tgaFooter;
   char horzrev, vertrev;
   int width, height, bpp;
   int start, end, dir;
@@ -202,7 +201,7 @@ igl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
   int index, colors, length;
   GLubyte *cmap, *pixels, *data;
   int (*myfread)(RLEstate *rleInfo, unsigned char*, size_t, size_t, FILE*);
-  igl::gliGenericImage *genericImage;
+  igl::opengl::gliGenericImage *genericImage;
 
   /* Check the footer. */
   if (fseek(fp, 0L - sizeof(tgaFooter), SEEK_END)
@@ -455,7 +454,7 @@ igl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
     if (_verbose) printf ("TGA: too much input data, ignoring extra...\n");
   }
 
-  genericImage = (igl::gliGenericImage*) malloc(sizeof(igl::gliGenericImage));
+  genericImage = (igl::opengl::gliGenericImage*) malloc(sizeof(igl::opengl::gliGenericImage));
   genericImage->width = width;
   genericImage->height = height;
   genericImage->format = format;
@@ -468,7 +467,7 @@ igl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
   return genericImage;
 }
 
-IGL_INLINE int igl::gli_verbose(int new_verbose)
+IGL_INLINE int igl::opengl::gli_verbose(int new_verbose)
 {
   _verbose = new_verbose;
   return _verbose;
@@ -514,7 +513,7 @@ IGL_INLINE void write16bit(int n, FILE* fp) {
 
 
 
-IGL_INLINE void igl::writeTGA( igl::gliGenericImage* image, FILE *fp) {
+IGL_INLINE void igl::opengl::writeTGA( igl::opengl::gliGenericImage* image, FILE *fp) {
 
   assert(!image->cmap); // we do not deal with color map images
     
@@ -549,4 +548,3 @@ IGL_INLINE void igl::writeTGA( igl::gliGenericImage* image, FILE *fp) {
   fwrite(image->pixels, image->height*image->width*image->components, sizeof(char),fp);
 }
 
-#endif

+ 6 - 5
include/igl/tga.h → include/igl/opengl/tga.h

@@ -5,10 +5,9 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_TGA_H
-#define IGL_TGA_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_TGA_H
+#define IGL_OPENGL_TGA_H
+#include "../igl_inline.h"
 // See license in tga.cpp
 
 /* tga.h - interface for TrueVision (TGA) image file loader */
@@ -23,6 +22,8 @@
 
 namespace igl
 {
+namespace opengl
+{
 
 typedef struct {
 
@@ -99,10 +100,10 @@ IGL_INLINE void writeTGA( gliGenericImage* image, FILE *fp);
 
 
 } // end of igl namespace
+}
 
 #ifndef IGL_STATIC_LIBRARY
 #  include "tga.cpp"
 #endif
 
 #endif 
-#endif 

+ 1 - 3
include/igl/uniform_type_to_string.cpp → include/igl/opengl/uniform_type_to_string.cpp

@@ -6,9 +6,8 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "uniform_type_to_string.h"
-#ifndef IGL_NO_OPENGL
 
-IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type)
+IGL_INLINE std::string igl::opengl::uniform_type_to_string(const GLenum type)
 {
   switch(type)
   {
@@ -70,4 +69,3 @@ IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type)
       return "UNKNOWN_TYPE";
   }
 }
-#endif

+ 12 - 11
include/igl/uniform_type_to_string.h → include/igl/opengl/uniform_type_to_string.h

@@ -5,10 +5,9 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_UNIFORM_TYPE_TO_STRING_H
-#define IGL_UNIFORM_TYPE_TO_STRING_H
-#ifndef IGL_NO_OPENGL
-#include "igl_inline.h"
+#ifndef IGL_OPENGL_UNIFORM_TYPE_TO_STRING_H
+#define IGL_OPENGL_UNIFORM_TYPE_TO_STRING_H
+#include "../igl_inline.h"
 
 #include <string>
 
@@ -16,12 +15,15 @@
 
 namespace igl
 {
-  // Convert a GL uniform variable type (say, returned from
-  // glGetActiveUniform) and output a string naming that type
-  // Inputs:
-  //   type  enum for given type
-  // Returns string name of that type
-  IGL_INLINE std::string uniform_type_to_string(const GLenum type);
+  namespace opengl
+  {
+    // Convert a GL uniform variable type (say, returned from
+    // glGetActiveUniform) and output a string naming that type
+    // Inputs:
+    //   type  enum for given type
+    // Returns string name of that type
+    IGL_INLINE std::string uniform_type_to_string(const GLenum type);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY
@@ -29,4 +31,3 @@ namespace igl
 #endif
 
 #endif
-#endif

+ 142 - 139
include/igl/MouseController.h → include/igl/opengl2/MouseController.h

@@ -5,11 +5,11 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_MOUSECONTROLLER_H
-#define IGL_MOUSECONTROLLER_H
+#ifndef IGL_OPENGL2_MOUSECONTROLLER_H
+#define IGL_OPENGL2_MOUSECONTROLLER_H
 // Needs to be included before others
 #include <Eigen/StdVector>
-#include <igl/RotateWidget.h>
+#include "RotateWidget.h"
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <vector>
@@ -17,135 +17,138 @@
 // Class for control a skeletal FK rig with the mouse.
 namespace igl
 {
-  class MouseController
+  namespace opengl2
   {
-    public:
-      typedef Eigen::VectorXi VectorXb;
-      // Propogate selection to descendants so that selected bones and their
-      // subtrees are all selected.
-      //
-      // Input:
-      //   S  #S list of whether selected
-      //   P  #S list of bone parents
-      // Output:
-      //   T  #S list of whether selected
-      static inline void propogate_to_descendants_if(
-        const VectorXb & S,
-        const Eigen::VectorXi & P,
-        VectorXb & T);
-      // Create a matrix of colors for the selection and their descendants.
-      //
-      // Inputs:
-      //   selection  #S list of whether a bone is selected
-      //   selected_color  color for selected bones
-      //   unselected_color  color for unselected bones
-      // Outputs:
-      //   C  #P by 4 list of colors
-      static inline void color_if(
-        const VectorXb & S,
-        const Eigen::Vector4f & selected_color,
-        const Eigen::Vector4f & unselected_color,
-        Eigen::MatrixXf & C);
-    private:
-      // m_is_selecting  whether currently selecting 
-      // m_selection  #m_rotations list of whether a bone is selected
-      // m_down_x  x-coordinate of mouse location at down
-      // m_down_y  y-coordinate 〃
-      // m_drag_x  x-coordinate of mouse location at drag
-      // m_drag_y  y-coordinate 〃
-      // m_widget  rotation widget for selected bone
-      // m_width  width of containing window
-      // m_height  height 〃
-      // m_rotations  list of rotations for each bone
-      // m_rotations_at_selection  list of rotations for each bone at time of
-      //   selection
-      // m_fk_rotations_at_selection  list of rotations for each bone at time of
-      //   selection
-      // m_root_enabled  Whether root is enabled
-      bool m_is_selecting;
-      VectorXb m_selection;
-      int m_down_x,m_down_y,m_drag_x,m_drag_y;
-      int m_width,m_height;
-      igl::RotateWidget m_widget;
-      Eigen::Quaterniond m_widget_rot_at_selection;
-      typedef std::vector<
-        Eigen::Quaterniond,
-        Eigen::aligned_allocator<Eigen::Quaterniond> > RotationList;
-      RotationList 
-        m_rotations,m_rotations_at_selection,m_fk_rotations_at_selection;
-      bool m_root_enabled;
-    public:
-      MouseController();
-      // Returns const reference to m_selection
-      inline const VectorXb & selection() const{return m_selection;};
-      //                          〃 m_is_selecting
-      inline const bool & is_selecting() const{return m_is_selecting;}
-      inline bool is_widget_down() const{return m_widget.is_down();}
-      //                          〃 m_rotations
-      inline const RotationList & rotations() const{return m_rotations;}
-      // Returns non-const reference to m_root_enabled
-      inline bool & root_enabled(){ return m_root_enabled;}
-      inline void reshape(const int w, const int h);
-      // Process down, drag, up mouse events
-      //
-      // Inputs:
-      //   x  x-coordinate of mouse click with respect to container
-      //   y  y-coordinate 〃 
-      // Returns true if accepted (action taken).
-      inline bool down(const int x, const int y);
-      inline bool drag(const int x, const int y);
-      inline bool up(const int x, const int y);
-      // Draw selection box and widget
-      inline void draw() const;
-      // Set `m_selection` based on the last drag selection and initialize
-      // widget.
-      //
-      // Inputs:
-      //   C  #C by dim list of joint positions at rest
-      //   BE  #BE by 2 list of bone indices at rest
-      //   P  #P list of bone parents
-      inline void set_selection_from_last_drag(
-        const Eigen::MatrixXd & C,
-        const Eigen::MatrixXi & BE,
-        const Eigen::VectorXi & P,
-        const Eigen::VectorXi & RP);
-      // Set from explicit selection
-      inline void set_selection(
-        const Eigen::VectorXi & S,
-        const Eigen::MatrixXd & C,
-        const Eigen::MatrixXi & BE,
-        const Eigen::VectorXi & P,
-        const Eigen::VectorXi & RP);
-      // Set size of skeleton
-      //
-      // Inputs:
-      //  n  number of bones
-      inline void set_size(const int n);
-      // Resets m_rotation elements to identity
-      inline void reset_rotations();
-      inline void reset_selected_rotations();
-      inline bool set_rotations(const RotationList & vQ);
-      // Sets all entries in m_selection to false
-      inline void clear_selection();
-      // Returns true iff some element in m_selection is true
-      inline bool any_selection() const;
-    public:
-        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
-  };
+    class MouseController
+    {
+      public:
+        typedef Eigen::VectorXi VectorXb;
+        // Propogate selection to descendants so that selected bones and their
+        // subtrees are all selected.
+        //
+        // Input:
+        //   S  #S list of whether selected
+        //   P  #S list of bone parents
+        // Output:
+        //   T  #S list of whether selected
+        static inline void propogate_to_descendants_if(
+          const VectorXb & S,
+          const Eigen::VectorXi & P,
+          VectorXb & T);
+        // Create a matrix of colors for the selection and their descendants.
+        //
+        // Inputs:
+        //   selection  #S list of whether a bone is selected
+        //   selected_color  color for selected bones
+        //   unselected_color  color for unselected bones
+        // Outputs:
+        //   C  #P by 4 list of colors
+        static inline void color_if(
+          const VectorXb & S,
+          const Eigen::Vector4f & selected_color,
+          const Eigen::Vector4f & unselected_color,
+          Eigen::MatrixXf & C);
+      private:
+        // m_is_selecting  whether currently selecting 
+        // m_selection  #m_rotations list of whether a bone is selected
+        // m_down_x  x-coordinate of mouse location at down
+        // m_down_y  y-coordinate 〃
+        // m_drag_x  x-coordinate of mouse location at drag
+        // m_drag_y  y-coordinate 〃
+        // m_widget  rotation widget for selected bone
+        // m_width  width of containing window
+        // m_height  height 〃
+        // m_rotations  list of rotations for each bone
+        // m_rotations_at_selection  list of rotations for each bone at time of
+        //   selection
+        // m_fk_rotations_at_selection  list of rotations for each bone at time of
+        //   selection
+        // m_root_enabled  Whether root is enabled
+        bool m_is_selecting;
+        VectorXb m_selection;
+        int m_down_x,m_down_y,m_drag_x,m_drag_y;
+        int m_width,m_height;
+        igl::opengl2::RotateWidget m_widget;
+        Eigen::Quaterniond m_widget_rot_at_selection;
+        typedef std::vector<
+          Eigen::Quaterniond,
+          Eigen::aligned_allocator<Eigen::Quaterniond> > RotationList;
+        RotationList 
+          m_rotations,m_rotations_at_selection,m_fk_rotations_at_selection;
+        bool m_root_enabled;
+      public:
+        MouseController();
+        // Returns const reference to m_selection
+        inline const VectorXb & selection() const{return m_selection;};
+        //                          〃 m_is_selecting
+        inline const bool & is_selecting() const{return m_is_selecting;}
+        inline bool is_widget_down() const{return m_widget.is_down();}
+        //                          〃 m_rotations
+        inline const RotationList & rotations() const{return m_rotations;}
+        // Returns non-const reference to m_root_enabled
+        inline bool & root_enabled(){ return m_root_enabled;}
+        inline void reshape(const int w, const int h);
+        // Process down, drag, up mouse events
+        //
+        // Inputs:
+        //   x  x-coordinate of mouse click with respect to container
+        //   y  y-coordinate 〃 
+        // Returns true if accepted (action taken).
+        inline bool down(const int x, const int y);
+        inline bool drag(const int x, const int y);
+        inline bool up(const int x, const int y);
+        // Draw selection box and widget
+        inline void draw() const;
+        // Set `m_selection` based on the last drag selection and initialize
+        // widget.
+        //
+        // Inputs:
+        //   C  #C by dim list of joint positions at rest
+        //   BE  #BE by 2 list of bone indices at rest
+        //   P  #P list of bone parents
+        inline void set_selection_from_last_drag(
+          const Eigen::MatrixXd & C,
+          const Eigen::MatrixXi & BE,
+          const Eigen::VectorXi & P,
+          const Eigen::VectorXi & RP);
+        // Set from explicit selection
+        inline void set_selection(
+          const Eigen::VectorXi & S,
+          const Eigen::MatrixXd & C,
+          const Eigen::MatrixXi & BE,
+          const Eigen::VectorXi & P,
+          const Eigen::VectorXi & RP);
+        // Set size of skeleton
+        //
+        // Inputs:
+        //  n  number of bones
+        inline void set_size(const int n);
+        // Resets m_rotation elements to identity
+        inline void reset_rotations();
+        inline void reset_selected_rotations();
+        inline bool set_rotations(const RotationList & vQ);
+        // Sets all entries in m_selection to false
+        inline void clear_selection();
+        // Returns true iff some element in m_selection is true
+        inline bool any_selection() const;
+      public:
+          EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+    };
+  }
 }
 
 // Implementation
-#include <igl/line_segment_in_rectangle.h>
-#include <igl/draw_rectangular_marquee.h>
-#include <igl/project.h>
-#include <igl/forward_kinematics.h>
-#include <igl/matlab_format.h>
-#include <igl/any_of.h>
+#include "../line_segment_in_rectangle.h"
+#include "draw_rectangular_marquee.h"
+#include "project.h"
+#include "../forward_kinematics.h"
+#include "../matlab_format.h"
+#include "../any_of.h"
 #include <iostream>
 #include <algorithm>
 #include <functional>
 
-inline void igl::MouseController::propogate_to_descendants_if(
+inline void igl::opengl2::MouseController::propogate_to_descendants_if(
   const VectorXb & S,
   const Eigen::VectorXi & P,
   VectorXb & T)
@@ -179,7 +182,7 @@ inline void igl::MouseController::propogate_to_descendants_if(
   }
 }
 
-inline void igl::MouseController::color_if(
+inline void igl::opengl2::MouseController::color_if(
   const VectorXb & S,
   const Eigen::Vector4f & selected_color,
   const Eigen::Vector4f & unselected_color,
@@ -192,7 +195,7 @@ inline void igl::MouseController::color_if(
   }
 }
 
-inline igl::MouseController::MouseController():
+inline igl::opengl2::MouseController::MouseController():
   m_is_selecting(false),
   m_selection(),
   m_down_x(-1),m_down_y(-1),m_drag_x(-1),m_drag_y(-1),
@@ -205,13 +208,13 @@ inline igl::MouseController::MouseController():
 {
 }
 
-inline void igl::MouseController::reshape(const int w, const int h)
+inline void igl::opengl2::MouseController::reshape(const int w, const int h)
 {
   m_width = w;
   m_height = h;
 }
 
-inline bool igl::MouseController::down(const int x, const int y)
+inline bool igl::opengl2::MouseController::down(const int x, const int y)
 {
   using namespace std;
   m_down_x = m_drag_x =x;
@@ -224,7 +227,7 @@ inline bool igl::MouseController::down(const int x, const int y)
   return m_is_selecting || widget_down;
 }
 
-inline bool igl::MouseController::drag(const int x, const int y)
+inline bool igl::opengl2::MouseController::drag(const int x, const int y)
 {
   using namespace std;
   using namespace Eigen;
@@ -281,14 +284,14 @@ inline bool igl::MouseController::drag(const int x, const int y)
   }
 }
 
-inline bool igl::MouseController::up(const int x, const int y)
+inline bool igl::opengl2::MouseController::up(const int x, const int y)
 {
   m_is_selecting = false;
   m_widget.up(x,m_height-y);
   return false;
 }
 
-inline void igl::MouseController::draw() const
+inline void igl::opengl2::MouseController::draw() const
 {
   using namespace igl;
   if(any_selection())
@@ -331,7 +334,7 @@ inline void igl::MouseController::draw() const
   }
 }
 
-inline void igl::MouseController::set_selection_from_last_drag(
+inline void igl::opengl2::MouseController::set_selection_from_last_drag(
   const Eigen::MatrixXd & C,
   const Eigen::MatrixXi & BE,
   const Eigen::VectorXi & P,
@@ -368,7 +371,7 @@ inline void igl::MouseController::set_selection_from_last_drag(
   return set_selection(m_selection,C,BE,P,RP);
 }
 
-inline void igl::MouseController::set_selection(
+inline void igl::opengl2::MouseController::set_selection(
     const Eigen::VectorXi & S,
     const Eigen::MatrixXd & C,
     const Eigen::MatrixXi & BE,
@@ -484,7 +487,7 @@ inline void igl::MouseController::set_selection(
   }
 }
 
-inline void igl::MouseController::set_size(const int n)
+inline void igl::opengl2::MouseController::set_size(const int n)
 {
   using namespace Eigen;
   clear_selection();
@@ -493,7 +496,7 @@ inline void igl::MouseController::set_size(const int n)
   m_selection = VectorXb::Zero(n);
 }
 
-inline void igl::MouseController::reset_rotations()
+inline void igl::opengl2::MouseController::reset_rotations()
 {
   using namespace Eigen;
   using namespace std;
@@ -502,7 +505,7 @@ inline void igl::MouseController::reset_rotations()
   clear_selection();
 }
 
-inline void igl::MouseController::reset_selected_rotations()
+inline void igl::opengl2::MouseController::reset_selected_rotations()
 {
   using namespace Eigen;
   for(int e = 0;e<m_selection.size();e++)
@@ -514,7 +517,7 @@ inline void igl::MouseController::reset_selected_rotations()
   }
 }
 
-inline bool igl::MouseController::set_rotations(const RotationList & vQ)
+inline bool igl::opengl2::MouseController::set_rotations(const RotationList & vQ)
 {
   if(vQ.size() != m_rotations.size())
   {
@@ -525,12 +528,12 @@ inline bool igl::MouseController::set_rotations(const RotationList & vQ)
   return true;
 }
 
-inline void igl::MouseController::clear_selection()
+inline void igl::opengl2::MouseController::clear_selection()
 {
   m_selection.setConstant(false);
 }
 
-inline bool igl::MouseController::any_selection() const
+inline bool igl::opengl2::MouseController::any_selection() const
 {
   return igl::any_of(m_selection);
 }

+ 86 - 83
include/igl/RotateWidget.h → include/igl/opengl2/RotateWidget.h

@@ -5,89 +5,92 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_ROTATE_WIDGET_H
-#define IGL_ROTATE_WIDGET_H
+#ifndef IGL_OPENGL2_ROTATE_WIDGET_H
+#define IGL_OPENGL2_ROTATE_WIDGET_H
 #include <Eigen/Geometry>
 #include <Eigen/Core>
 #include <vector>
-#include <igl/material_colors.h>
+#include "../material_colors.h"
 
 namespace igl
 {
-  // 3D Rotate tool widget similar to Maya's. Works best if field of view angle
-  // is less than ~25.
-  class RotateWidget
+  namespace opengl2
   {
-      // If a is true then use A else use desaturated A
-      static inline void glColor4fv(const bool a, const Eigen::Vector4f & A);
-    public:
-      inline static Eigen::Quaterniond axis_q(const int a);
-      inline static Eigen::Vector3d view_direction(const int x, const int y);
-      inline static Eigen::Vector3d view_direction(const Eigen::Vector3d & pos);
-      Eigen::Vector3d pos;
-      Eigen::Quaterniond rot,down_rot;
-      // This line causes trouble if RotateWidget.h is included before bbw.h
-      Eigen::Vector2d down_xy,drag_xy,down_dir;
-      Eigen::Vector3d udown,udrag;
-      double outer_radius_on_screen;
-      double outer_over_inner;
-      bool m_is_enabled;
-      enum DownType
-      {
-        DOWN_TYPE_X = 0,
-        DOWN_TYPE_Y = 1,
-        DOWN_TYPE_Z = 2,
-        DOWN_TYPE_OUTLINE = 3,
-        DOWN_TYPE_TRACKBALL = 4,
-        DOWN_TYPE_NONE = 5,
-        NUM_DOWN_TYPES = 6
-      } down_type, selected_type;
-      inline RotateWidget();
-      // Vector from origin to mouse click "Unprojected" onto plane with depth of
-      // origin and scale to so that outer radius is 1
-      // 
-      // Inputs:
-      //   x  mouse x position
-      //   y  mouse y position
-      // Returns vector
-      inline Eigen::Vector3d unproject_onto(const int x, const int y) const;
-      // Shoot ray from mouse click to sphere
-      //
-      // Inputs:
-      //   x  mouse x position
-      //   y  mouse y position
-      // Outputs:
-      //   hit  position of hit
-      // Returns true only if there was a hit
-      inline bool intersect(
-        const int x, 
-        const int y, 
-        Eigen::Vector3d & hit) const;
-      inline double unprojected_inner_radius() const;
-      inline bool down(const int x, const int y);
-      inline bool drag(const int x, const int y);
-      inline bool up(const int x, const int y);
-      inline bool is_down() const;
-      inline void draw() const;
-      inline void draw_guide() const;
-    public:
-        EIGEN_MAKE_ALIGNED_OPERATOR_NEW
-  };
+    // 3D Rotate tool widget similar to Maya's. Works best if field of view angle
+    // is less than ~25.
+    class RotateWidget
+    {
+        // If a is true then use A else use desaturated A
+        static inline void glColor4fv(const bool a, const Eigen::Vector4f & A);
+      public:
+        inline static Eigen::Quaterniond axis_q(const int a);
+        inline static Eigen::Vector3d view_direction(const int x, const int y);
+        inline static Eigen::Vector3d view_direction(const Eigen::Vector3d & pos);
+        Eigen::Vector3d pos;
+        Eigen::Quaterniond rot,down_rot;
+        // This line causes trouble if RotateWidget.h is included before bbw.h
+        Eigen::Vector2d down_xy,drag_xy,down_dir;
+        Eigen::Vector3d udown,udrag;
+        double outer_radius_on_screen;
+        double outer_over_inner;
+        bool m_is_enabled;
+        enum DownType
+        {
+          DOWN_TYPE_X = 0,
+          DOWN_TYPE_Y = 1,
+          DOWN_TYPE_Z = 2,
+          DOWN_TYPE_OUTLINE = 3,
+          DOWN_TYPE_TRACKBALL = 4,
+          DOWN_TYPE_NONE = 5,
+          NUM_DOWN_TYPES = 6
+        } down_type, selected_type;
+        inline RotateWidget();
+        // Vector from origin to mouse click "Unprojected" onto plane with depth of
+        // origin and scale to so that outer radius is 1
+        // 
+        // Inputs:
+        //   x  mouse x position
+        //   y  mouse y position
+        // Returns vector
+        inline Eigen::Vector3d unproject_onto(const int x, const int y) const;
+        // Shoot ray from mouse click to sphere
+        //
+        // Inputs:
+        //   x  mouse x position
+        //   y  mouse y position
+        // Outputs:
+        //   hit  position of hit
+        // Returns true only if there was a hit
+        inline bool intersect(
+          const int x, 
+          const int y, 
+          Eigen::Vector3d & hit) const;
+        inline double unprojected_inner_radius() const;
+        inline bool down(const int x, const int y);
+        inline bool drag(const int x, const int y);
+        inline bool up(const int x, const int y);
+        inline bool is_down() const;
+        inline void draw() const;
+        inline void draw_guide() const;
+      public:
+          EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+    };
+  }
 }
 
 // Implementation
-#include <igl/OpenGL_convenience.h>
-#include <igl/PI.h>
-#include <igl/EPS.h>
-#include <igl/ray_sphere_intersect.h>
-#include <igl/project.h>
-#include <igl/mat_to_quat.h>
-#include <igl/trackball.h>
-#include <igl/unproject.h>
+#include "../opengl/OpenGL_convenience.h"
+#include "../PI.h"
+#include "../EPS.h"
+#include "../ray_sphere_intersect.h"
+#include "../mat_to_quat.h"
+#include "../trackball.h"
+#include "project.h"
+#include "unproject.h"
 #include <iostream>
 #include <cassert>
 
-inline void igl::RotateWidget::glColor4fv(
+inline void igl::opengl2::RotateWidget::glColor4fv(
     const bool a,
     const Eigen::Vector4f & A)
 {
@@ -105,7 +108,7 @@ inline void igl::RotateWidget::glColor4fv(
   }
 }
 
-inline Eigen::Quaterniond igl::RotateWidget::axis_q(const int a)
+inline Eigen::Quaterniond igl::opengl2::RotateWidget::axis_q(const int a)
 {
   assert(a<3 && a>=0);
   const Eigen::Quaterniond axes[3] = {
@@ -115,7 +118,7 @@ inline Eigen::Quaterniond igl::RotateWidget::axis_q(const int a)
   return axes[a];
 }
 
-inline Eigen::Vector3d igl::RotateWidget::view_direction(const int x, const int y)
+inline Eigen::Vector3d igl::opengl2::RotateWidget::view_direction(const int x, const int y)
 {
   using namespace Eigen;
   const Vector3d win_s(x,y,0), win_d(x,y,1);
@@ -124,14 +127,14 @@ inline Eigen::Vector3d igl::RotateWidget::view_direction(const int x, const int
   return d-s;
 }
 
-inline Eigen::Vector3d igl::RotateWidget::view_direction(const Eigen::Vector3d & pos)
+inline Eigen::Vector3d igl::opengl2::RotateWidget::view_direction(const Eigen::Vector3d & pos)
 {
   using namespace Eigen;
   const Vector3d ppos = project(pos);
   return view_direction(ppos(0),ppos(1));
 }
 
-inline igl::RotateWidget::RotateWidget():
+inline igl::opengl2::RotateWidget::RotateWidget():
   pos(0,0,0),
   rot(Eigen::Quaterniond::Identity()),
   down_rot(rot),
@@ -144,7 +147,7 @@ inline igl::RotateWidget::RotateWidget():
 {
 }
 
-inline Eigen::Vector3d igl::RotateWidget::unproject_onto(
+inline Eigen::Vector3d igl::opengl2::RotateWidget::unproject_onto(
   const int x, 
   const int y) const
 {
@@ -170,7 +173,7 @@ inline Eigen::Vector3d igl::RotateWidget::unproject_onto(
   return (uxy-pos)/unprojected_inner_radius()*outer_over_inner*outer_over_inner;
 }
 
-inline bool igl::RotateWidget::intersect(
+inline bool igl::opengl2::RotateWidget::intersect(
   const int x, 
   const int y,
   Eigen::Vector3d & hit) const
@@ -189,7 +192,7 @@ inline bool igl::RotateWidget::intersect(
 }
 
 
-inline double igl::RotateWidget::unprojected_inner_radius() const
+inline double igl::opengl2::RotateWidget::unprojected_inner_radius() const
 {
   using namespace Eigen;
   Vector3d off,ppos,ppos_off,pos_off;
@@ -199,7 +202,7 @@ inline double igl::RotateWidget::unprojected_inner_radius() const
   unproject(ppos_off,pos_off);
   return (pos-pos_off).norm();
 }
-inline bool igl::RotateWidget::down(const int x, const int y)
+inline bool igl::opengl2::RotateWidget::down(const int x, const int y)
 {
   using namespace Eigen;
   using namespace std;
@@ -281,7 +284,7 @@ inline bool igl::RotateWidget::down(const int x, const int y)
   }
 }
 
-inline bool igl::RotateWidget::drag(const int x, const int y)
+inline bool igl::opengl2::RotateWidget::drag(const int x, const int y)
 {
   using namespace std;
   using namespace Eigen;
@@ -355,19 +358,19 @@ inline bool igl::RotateWidget::drag(const int x, const int y)
   }
 }
 
-inline bool igl::RotateWidget::up(const int /*x*/, const int /*y*/)
+inline bool igl::opengl2::RotateWidget::up(const int /*x*/, const int /*y*/)
 {
   // even if disabled process up
   down_type = DOWN_TYPE_NONE;
   return false;
 }
 
-inline bool igl::RotateWidget::is_down() const
+inline bool igl::opengl2::RotateWidget::is_down() const
 {
   return down_type != DOWN_TYPE_NONE;
 }
 
-inline void igl::RotateWidget::draw() const
+inline void igl::opengl2::RotateWidget::draw() const
 {
   using namespace Eigen;
   using namespace std;
@@ -462,7 +465,7 @@ inline void igl::RotateWidget::draw() const
   glPopAttrib();
 };
 
-inline void igl::RotateWidget::draw_guide() const
+inline void igl::opengl2::RotateWidget::draw_guide() const
 {
   using namespace Eigen;
   using namespace std;

+ 2 - 4
include/igl/draw_beach_ball.cpp → include/igl/opengl2/draw_beach_ball.cpp

@@ -6,9 +6,8 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "draw_beach_ball.h"
-#ifndef IGL_NO_OPENGL
 
-#include "OpenGL_convenience.h"
+#include "../opengl/OpenGL_convenience.h"
 
 // I'm not sure why windows would need it this way:
 // http://lists.cairographics.org/archives/cairo/2008-January/012722.html
@@ -231,7 +230,7 @@ static const float  FLOAT_PI      = 3.14159265358979323846f;
 // End Copied Straight from AntTweakBar
 ////////////////////////////////////////////////////////////////////////////
 
-IGL_INLINE void igl::draw_beach_ball()
+IGL_INLINE void igl::opengl2::draw_beach_ball()
 {
   using namespace std;
 
@@ -283,4 +282,3 @@ IGL_INLINE void igl::draw_beach_ball()
 
   (cm ? glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL));
 }
-#endif

Some files were not shown because too many files changed in this diff