瀏覽代碼

fix unix dependencies and added ifdef include windows around opengl includes

Former-commit-id: 46d389a9fee6d72fd3a2e8fee55cdf6a95060ec7
jalec 13 年之前
父節點
當前提交
7e8e5ed1f1
共有 19 個文件被更改,包括 148 次插入25 次删除
  1. 1 1
      colon.h
  2. 5 0
      create_index_vbo.h
  3. 5 0
      create_mesh_vbo.h
  4. 5 0
      create_shader_program.h
  5. 5 0
      create_vector_vbo.h
  6. 7 2
      destroy_shader_program.h
  7. 10 3
      get_seconds.h
  8. 5 0
      gl_type_size.h
  9. 9 0
      is_dir.h
  10. 20 3
      is_readable.h
  11. 20 0
      is_writable.h
  12. 7 2
      load_shader.h
  13. 5 0
      print_gl_get.h
  14. 7 2
      print_program_info_log.h
  15. 7 2
      print_shader_info_log.h
  16. 9 4
      project.h
  17. 9 4
      report_gl_error.h
  18. 7 2
      uniform_type_to_string.h
  19. 5 0
      unproject.h

+ 1 - 1
colon.h

@@ -76,7 +76,7 @@ inline void igl::colon(
     }
     }
   }
   }
   // resize output
   // resize output
-  int n = floor((hi-low)/step)+1;
+  int n = floor(double((hi-low)/step))+1;
   I.resize(n);
   I.resize(n);
   int i = 0;
   int i = 0;
   T v = (T)low;
   T v = (T)low;

+ 5 - 0
create_index_vbo.h

@@ -7,6 +7,11 @@
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #  include <GL/gl.h>
 #  include <GL/gl.h>
 #endif
 #endif
 
 

+ 5 - 0
create_mesh_vbo.h

@@ -7,6 +7,11 @@
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #  include <GL/gl.h>
 #  include <GL/gl.h>
 #endif
 #endif
 
 

+ 5 - 0
create_shader_program.h

@@ -6,6 +6,11 @@
 #ifdef __APPLE__
 #ifdef __APPLE__
 #   include <OpenGL/gl.h>
 #   include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #   include <GL/gl.h>
 #   include <GL/gl.h>
 #endif
 #endif
 
 

+ 5 - 0
create_vector_vbo.h

@@ -7,6 +7,11 @@
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #  include <GL/gl.h>
 #  include <GL/gl.h>
 #endif
 #endif
 
 

+ 7 - 2
destroy_shader_program.h

@@ -2,9 +2,14 @@
 #define IGL_DESTROY_SHADER_PROGRAM_H
 #define IGL_DESTROY_SHADER_PROGRAM_H
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
+#  include <OpenGL/gl.h>
 #else
 #else
-#   include <GL/gl.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
 #endif
 #endif
 
 
 namespace igl
 namespace igl

+ 10 - 3
get_seconds.h

@@ -9,9 +9,15 @@ namespace igl
 }
 }
 
 
 //Implementation
 //Implementation
-#include <sys/time.h>
-//#include <ctime>
-
+#if _WIN32
+#  include <ctime>
+inline double igl::get_seconds()
+{
+  // This does not work on mac os x with glut in the main loop
+  return double(clock())/CLOCKS_PER_SEC;
+}
+#else
+#  include <sys/time.h>
 inline double igl::get_seconds()
 inline double igl::get_seconds()
 {
 {
   timeval time;
   timeval time;
@@ -21,3 +27,4 @@ inline double igl::get_seconds()
   //return double(clock())/CLOCKS_PER_SEC;
   //return double(clock())/CLOCKS_PER_SEC;
 }
 }
 #endif
 #endif
+#endif

+ 5 - 0
gl_type_size.h

@@ -4,6 +4,11 @@
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #  include <GL/gl.h>
 #  include <GL/gl.h>
 #endif
 #endif
 
 

+ 9 - 0
is_dir.h

@@ -16,6 +16,15 @@ namespace igl
 
 
 // Implementation
 // Implementation
 #include <sys/stat.h>
 #include <sys/stat.h>
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
+#endif
+
 inline bool igl::is_dir(const char * filename)
 inline bool igl::is_dir(const char * filename)
 {
 {
   struct stat status;
   struct stat status;

+ 20 - 3
is_readable.h

@@ -8,14 +8,28 @@ namespace igl
   //   filename  path to file
   //   filename  path to file
   // Returns true if file exists and is readable and false if file doesn't
   // Returns true if file exists and is readable and false if file doesn't
   // exist or *is not readable*
   // exist or *is not readable*
+  //
+  // Note: Windows version will not check user or group ids
   inline bool is_readable(const char * filename);
   inline bool is_readable(const char * filename);
 }
 }
 
 
 
 
 // Implementation
 // Implementation
-#include <sys/stat.h>
-#include <unistd.h>
-
+#ifdef _WIN32
+#  include <cstdio>
+inline bool igl::is_readable(const char* filename)
+{
+  FILE * f = fopen(filename,"r");
+  if(f == NULL)
+  {
+    return false;
+  }
+  fclose(f);
+  return true;
+}
+#else
+#  include <sys/stat.h>
+#  include <unistd.h>
 inline bool igl::is_readable(const char* filename)
 inline bool igl::is_readable(const char* filename)
 {
 {
   // Check if file already exists
   // Check if file already exists
@@ -43,5 +57,8 @@ inline bool igl::is_readable(const char* filename)
 
 
   // Dealing with other
   // Dealing with other
   return S_IROTH & status.st_mode;
   return S_IROTH & status.st_mode;
+
 }
 }
 #endif
 #endif
+
+#endif

+ 20 - 0
is_writable.h

@@ -8,11 +8,30 @@ namespace igl
   //   filename  path to file
   //   filename  path to file
   // Returns true if file exists and is writable and false if file doesn't
   // Returns true if file exists and is writable and false if file doesn't
   // exist or *is not writable*
   // exist or *is not writable*
+  //
+  // Note: Windows version will not test group and user id
   inline bool is_writable(const char * filename);
   inline bool is_writable(const char * filename);
 }
 }
 
 
 
 
 // Implementation
 // Implementation
+#ifdef _WIN32
+#include <sys/stat.h>
+#ifndef S_IWUSR
+#  define S_IWUSR S_IWRITE
+#endif
+inline bool is_writable(const char* filename)
+{
+  // Check if file already exists
+  struct stat status;
+  if(stat(filename,&status)!=0)
+  {
+    return false;
+  }
+
+  return S_IWUSR & status.st_mode;
+}
+#else
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
@@ -45,3 +64,4 @@ inline bool igl::is_writable(const char* filename)
   return S_IWOTH & status.st_mode;
   return S_IWOTH & status.st_mode;
 }
 }
 #endif
 #endif
+#endif

+ 7 - 2
load_shader.h

@@ -2,9 +2,14 @@
 #define IGL_LOAD_SHADER_H 
 #define IGL_LOAD_SHADER_H 
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
+#  include <OpenGL/gl.h>
 #else
 #else
-#   include <GL/gl.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
 #endif
 #endif
 
 
 namespace igl
 namespace igl

+ 5 - 0
print_gl_get.h

@@ -4,6 +4,11 @@
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 #  include <GL/gl.h>
 #  include <GL/gl.h>
 #endif
 #endif
 
 

+ 7 - 2
print_program_info_log.h

@@ -2,9 +2,14 @@
 #define IGL_PRINT_PROGRAM_INFO_LOG_H
 #define IGL_PRINT_PROGRAM_INFO_LOG_H
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
+#  include <OpenGL/gl.h>
 #else
 #else
-#   include <GL/gl.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
 #endif
 #endif
 namespace igl
 namespace igl
 {
 {

+ 7 - 2
print_shader_info_log.h

@@ -2,9 +2,14 @@
 #define IGL_PRINT_SHADER_INFO_LOG_H
 #define IGL_PRINT_SHADER_INFO_LOG_H
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
+#  include <OpenGL/gl.h>
 #else
 #else
-#   include <GL/gl.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
 #endif
 #endif
 
 
 namespace igl
 namespace igl

+ 9 - 4
project.h

@@ -21,11 +21,16 @@ namespace igl
 // Implementation
 // Implementation
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
+#  include <OpenGL/gl.h>
+#  include <OpenGL/glu.h>
 #else
 #else
-# include <GL/gl.h>
-# include <GL/glu.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
+#  include <GL/glu.h>
 #endif
 #endif
 
 
 inline int igl::project(
 inline int igl::project(

+ 9 - 4
report_gl_error.h

@@ -2,11 +2,16 @@
 #define IGL_REPORT_GL_ERROR
 #define IGL_REPORT_GL_ERROR
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
-#   include <OpenGL/glu.h>
+#  include <OpenGL/gl.h>
+#  include <OpenGL/glu.h>
 #else
 #else
-#   include <GL/gl.h>
-#   include <GL/glu.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
+#  include <GL/glu.h>
 #endif
 #endif
 
 
 #include <cstdio>
 #include <cstdio>

+ 7 - 2
uniform_type_to_string.h

@@ -4,9 +4,14 @@
 #include <string>
 #include <string>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
-#   include <OpenGL/gl.h>
+#  include <OpenGL/gl.h>
 #else
 #else
-#   include <GL/gl.h>
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
+#  include <GL/gl.h>
 #endif
 #endif
 
 
 namespace igl
 namespace igl

+ 5 - 0
unproject.h

@@ -24,6 +24,11 @@ namespace igl
 # include <OpenGL/gl.h>
 # include <OpenGL/gl.h>
 # include <OpenGL/glu.h>
 # include <OpenGL/glu.h>
 #else
 #else
+#  ifdef _WIN32
+#    define NOMINMAX
+#    include <Windows.h>
+#    undef NOMINMAX
+#  endif
 # include <GL/gl.h>
 # include <GL/gl.h>
 # include <GL/glu.h>
 # include <GL/glu.h>
 #endif
 #endif