浏览代码

compile on windows with visual studio

Former-commit-id: d44fcd8c4b73db82b23ae4b91c35dce5e00280d5
jalec 12 年之前
父节点
当前提交
9bc7464767

+ 1 - 1
include/igl/Camera.cpp

@@ -1,5 +1,5 @@
 #include "Camera.h"
-#include <igl/canonical_quaternions.h>
+#include "canonical_quaternions.h"
 #include <algorithm>
 
 igl::Camera::Camera():

+ 1 - 0
include/igl/create_index_vbo.h

@@ -11,6 +11,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
include/igl/create_mesh_vbo.h

@@ -11,6 +11,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
include/igl/create_shader_program.h

@@ -10,6 +10,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
include/igl/create_vector_vbo.h

@@ -11,6 +11,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 1
include/igl/destroy_shader_program.cpp

@@ -1,6 +1,6 @@
 #include "destroy_shader_program.h"
 #include <cstdio>
-#include <igl/report_gl_error.h>
+#include "report_gl_error.h"
 
 IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
 {

+ 1 - 0
include/igl/destroy_shader_program.h

@@ -8,6 +8,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 4 - 3
include/igl/draw_mesh.h

@@ -6,12 +6,13 @@
 
 #if __APPLE__
 #  include <OpenGL/gl.h>
-#else
-#  ifdef _WIN32
+#elif defined(_WIN32)
 #    define NOMINMAX
 #    include <Windows.h>
 #    undef NOMINMAX
-#  endif
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
 #  define GL_GLEXT_PROTOTYPES
 #  include <GL/gl.h>
 #  include <GL/glext.h>

+ 7 - 3
include/igl/draw_point.cpp

@@ -1,15 +1,19 @@
 #include "draw_point.h"
 
 // Implementation
+
 #if __APPLE__
 #  include <OpenGL/gl.h>
-#else
-#  ifdef _WIN32
+#elif defined(_WIN32)
 #    define NOMINMAX
 #    include <Windows.h>
 #    undef NOMINMAX
-#  endif
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
+#  define GL_GLEXT_PROTOTYPES
 #  include <GL/gl.h>
+#  include <GL/glext.h>
 #endif
 
 #include <cassert>

+ 2 - 2
include/igl/full.cpp

@@ -18,7 +18,7 @@ IGL_INLINE void igl::full(
 }
 
 template <typename DerivedA,typename DerivedB>
-IGL_INLINE bool igl::full(
+IGL_INLINE void igl::full(
   const Eigen::PlainObjectBase<DerivedA>& A,
   Eigen::PlainObjectBase<DerivedB>& B)
 {
@@ -28,7 +28,7 @@ IGL_INLINE bool igl::full(
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
-template bool igl::full<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::full<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> >&);
 // generated by autoexplicit.sh
 template void igl::full<double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 #endif

+ 1 - 1
include/igl/full.h

@@ -19,7 +19,7 @@ namespace igl
     Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & B);
   // If already full then this will just be a copy by assignment
   template <typename DerivedA,typename DerivedB>
-  IGL_INLINE bool full(
+  IGL_INLINE void full(
     const Eigen::PlainObjectBase<DerivedA>& A,
     Eigen::PlainObjectBase<DerivedB>& B);
 }

+ 1 - 0
include/igl/get_seconds_hires.cpp

@@ -2,6 +2,7 @@
 
 #if _WIN32
 #  include <windows.h>
+#  include <cassert>
 IGL_INLINE double igl::get_seconds_hires()
 {
   LARGE_INTEGER li_freq, li_current;

+ 5 - 0
include/igl/is_file.cpp

@@ -1,6 +1,11 @@
 #include "is_file.h"
 
 #include <sys/stat.h>
+#ifdef _WIN32
+#  ifndef S_ISREG
+#    define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
+#  endif
+#endif
 IGL_INLINE bool igl::is_file(const char * filename)
 {
   struct stat status;

+ 1 - 0
include/igl/load_shader.h

@@ -8,6 +8,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
include/igl/print_program_info_log.h

@@ -8,6 +8,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
include/igl/print_shader_info_log.h

@@ -8,6 +8,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 1
include/igl/readTGF.cpp

@@ -130,7 +130,7 @@ IGL_INLINE bool igl::readTGF(
 }
 
 #ifndef IGL_NO_EIGEN
-#include <igl/list_to_matrix.h>
+#include "list_to_matrix.h"
 
 IGL_INLINE bool igl::readTGF(
   const std::string tgf_filename,

+ 14 - 0
include/igl/remove_duplicate_vertices.cpp

@@ -50,9 +50,23 @@ IGL_INLINE void igl::remove_duplicate_vertices(
   using namespace std;
   remove_duplicate_vertices(V,epsilon,SV,SVI,SVJ);
   // remap faces
+#ifndef _WIN32
   SF = F.unaryExpr(bind1st(mem_fun( 
     static_cast<VectorXi::Scalar&(VectorXi::*)(VectorXi::Index)>
       (&VectorXi::operator())), &SVJ)).eval();
+#else
+  // Why doesn't the above compile on windows?
+#define __STR2__(x) #x
+#define __STR1__(x) __STR2__(x)
+#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "
+#pragma message(__LOC__"Using untested Windows-only code")
+  // This needs to be tested.
+  SF.resize(F.rows(),F.cols());
+  for(int f = 0;f<SF.size();f++)
+  {
+	  SF(f) = SVJ(f);
+  }
+#endif
 }
 
 #ifndef IGL_HEADER_ONLY

+ 15 - 0
include/igl/render_to_tga.cpp

@@ -1,5 +1,20 @@
 #include "render_to_tga.h"
 #include "tga.h"
+
+#if __APPLE__
+#  include <OpenGL/gl.h>
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#    include <GL/glew.h>
+#    include <GL/gl.h>
+#else
+#  define GL_GLEXT_PROTOTYPES
+#  include <GL/gl.h>
+#  include <GL/glext.h>
+#endif
+
 #include <cstdlib>
 
 IGL_INLINE bool igl::render_to_tga(

+ 4 - 2
include/igl/svd.cpp

@@ -1,7 +1,8 @@
+// This only works on MAC ...
+#ifdef __APPLE__
 #include "svd.h"
-
-#include <cstdlib>
 #include <Accelerate/Accelerate.h>
+#include <cstdlib>
 #include <cstdio>
 
 bool igl::svd3x3(double * a, double * u, double * s, double * vt)
@@ -36,3 +37,4 @@ bool igl::svd3x3(double * a, double * u, double * s, double * vt)
   free( (void*)work );
   return true;
 }
+#endif

+ 2 - 0
include/igl/svd.h

@@ -12,6 +12,8 @@ namespace igl
   //   vt  pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in
   //     row-major order
   // Returns true on success, false on failure
+  // 
+  // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen
   bool svd3x3(double * a, double * u, double * s, double * vt);
 };
 

+ 1 - 0
include/igl/texture_from_tga.h

@@ -8,6 +8,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 9 - 1
include/igl/tga.h

@@ -10,10 +10,18 @@
 #include <windows.h>
 #endif
 
-#ifdef __APPLE__
+#if __APPLE__
 #  include <OpenGL/gl.h>
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#    include <GL/glew.h>
+#    include <GL/gl.h>
 #else
+#  define GL_GLEXT_PROTOTYPES
 #  include <GL/gl.h>
+#  include <GL/glext.h>
 #endif
 
 namespace igl

+ 1 - 0
include/igl/uniform_type_to_string.h

@@ -10,6 +10,7 @@
 #  define NOMINMAX
 #  include <Windows.h>
 #  undef NOMINMAX
+#  include <GL/glew.h>
 #  include <GL/gl.h>
 #else
 #  define GL_GLEXT_PROTOTYPES

+ 1 - 0
todos.txt

@@ -21,3 +21,4 @@
 - consistent checks/asserts for: manifoldness, closedness, triangles-only
     e.g. check_mesh(V,F,MANIFOLD | CLOSED | TRIANGLES_ONLY)
 - clean up Timer.h
+- svd.* depends on lapack, should use eigen...

+ 20 - 0
tutorial.html

@@ -249,6 +249,26 @@ make
       <p>See also: <a href=style_guidelines.html>style guidlines</a>, <a
       href=doc.html>auto-documentation</a>, <a
       href=file-formats/index.html>file formats</a></p>
+      <h3>Including OpenGL</h3>
+      <p>
+      A standard include for the OpenGL headers should be placed in the .cpp file if possible. To ensure compilability on Mac OS X, Windows and Linux, use:
+      <pre><code>
+#if __APPLE__
+#  include &lt;OpenGL/gl.h&gt;
+#elif defined(_WIN32)
+#    define NOMINMAX
+#    include &lt;Windows.h&gt;
+#    undef NOMINMAX
+#    include &lt;GL/glew.h&gt;
+#    include &lt;GL/gl.h&gt;
+#else
+#  define GL_GLEXT_PROTOTYPES
+#  include &lt;GL/gl.h&gt;
+#  include &lt;GL/glext.h&gt;
+#endif
+      </code></pre>
+      </p>
+      <p><span class=todo>This should be encapsulated in a single utility header</span></p>
   </div>
   </body>
 </html>