Browse Source

fixed verbose and merged

Former-commit-id: 22262593625162eae23384a71aebd868c1b04d52
jalec 13 years ago
parent
commit
9e49a8d87b

+ 1 - 1
examples/marching_cubes/example.REMOVED.git-id

@@ -1 +1 @@
-11981fc57745d19c0caed120a67c19f9a5b94507
+567ada890571088113289960fab13dc0d1fb938e

+ 6 - 0
include/igl/destroy_shader_program.cpp

@@ -1,5 +1,6 @@
 #include "destroy_shader_program.h"
 #include <cstdio>
+#include <igl/report_gl_error.h>
 
 IGL_INLINE bool igl::destroy_shader_program(const GLuint id)
 {
@@ -18,6 +19,11 @@ 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();
+    if (GL_NO_ERROR != err)
+    {
+      return false;
+    }
     // Check that we actually got *1*
     if(count == 1)
     {

+ 1 - 0
include/igl/dirname.cpp

@@ -30,3 +30,4 @@ IGL_INLINE std::string igl::dirname(const std::string & path)
   }
   return std::string(path.begin(),last_slash.base()-1);
 }
+

+ 4 - 0
include/igl/pathinfo.cpp

@@ -33,3 +33,7 @@ IGL_INLINE void igl::pathinfo(
     filename = std::string(basename.begin(),last_dot.base()-1);
   }
 }
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+#endif

+ 42 - 0
include/igl/project.cpp

@@ -1,4 +1,6 @@
 #include "project.h"
+#include <iostream>
+#include "report_gl_error.h"
 
 #ifdef __APPLE__
 #  include <OpenGL/gl.h>
@@ -21,12 +23,52 @@ IGL_INLINE int igl::project(
   double* winY,
   double* winZ)
 {
+  using namespace std;
+#ifdef EXTREME_VERBOSE
+  cout<<"project();"<<endl;
+#endif
   // Put model, projection, and viewport matrices into double arrays
   double MV[16];
   double P[16];
   int VP[4];
   glGetDoublev(GL_MODELVIEW_MATRIX,  MV);
+
+#ifdef EXTREME_VERBOSE
+  cout<<"MV=["<<endl<<
+    MV[0]<<" "<< MV[1]<<" "<< MV[2]<<" "<< MV[3]<<" "<<endl<<
+    MV[4]<<" "<< MV[5]<<" "<< MV[6]<<" "<< MV[7]<<" "<<endl<<
+    MV[8]<<" "<< MV[9]<<" "<< MV[10]<<" "<< MV[11]<<" "<<endl<<
+    MV[12]<<" "<< MV[13]<<" "<< MV[14]<<" "<< MV[15]<<" "<<endl<<
+    "];"<<endl;
+#endif
+#ifndef NDEBUG
+  igl::report_gl_error();
+#endif
+
   glGetDoublev(GL_PROJECTION_MATRIX, P);
+
+#ifdef EXTREME_VERBOSE
+  cout<<"P=["<<endl<<
+    P[0]<<" "<< P[1]<<" "<< P[2]<<" "<< P[3]<<" "<<endl<<
+    P[4]<<" "<< P[5]<<" "<< P[6]<<" "<< P[7]<<" "<<endl<<
+    P[8]<<" "<< P[9]<<" "<< P[10]<<" "<< P[11]<<" "<<endl<<
+    P[12]<<" "<< P[13]<<" "<< P[14]<<" "<< P[15]<<" "<<endl<<
+    "];"<<endl;
+#endif
+#ifndef NDEBUG
+  igl::report_gl_error();
+#endif
+
   glGetIntegerv(GL_VIEWPORT, VP);
+
+#ifdef EXTREME_VERBOSE
+  cout<<"VP=["<<endl<<
+    VP[0]<<" "<< VP[1]<<" "<< VP[2]<<" "<< VP[3]<<" "<<endl<<
+    "];"<<endl;
+#endif
+#ifndef NDEBUG
+  igl::report_gl_error();
+#endif
+
   return gluProject(objX,objY,objZ,MV,P,VP,winX,winY,winZ);
 }

+ 9 - 1
include/igl/readDMAT.cpp

@@ -3,7 +3,10 @@
 #include "verbose.h"
 #include <cstdio>
 
-IGL_INLINE bool igl::readDMAT(const std::string file_name, Eigen::MatrixXd & W)
+#include <Eigen/Dense>
+
+template <class Mat>
+IGL_INLINE bool igl::readDMAT(const std::string file_name, Mat & W)
 {
   FILE * fp = fopen(file_name.c_str(),"r");
   if(fp == NULL)
@@ -58,3 +61,8 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name, Eigen::MatrixXd & W)
   fclose(fp);
   return true;
 }
+
+#ifndef IGL_HEADER_ONLY
+// Explicit template specialization
+template bool igl::readDMAT<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::Matrix<double, -1, -1, 0, -1, -1> &);
+#endif

+ 2 - 2
include/igl/readDMAT.h

@@ -12,7 +12,6 @@
 //   corresponds to a .dmat file containing:
 //   3 2
 //   1 4 2 5 3 6
-#include <Eigen/Core>
 #include <string>
 namespace igl
 {
@@ -24,7 +23,8 @@ namespace igl
   //   W  eigen matrix containing read-in coefficients
   // Returns true on success, false on error
   //
-  IGL_INLINE bool readDMAT(const std::string file_name, Eigen::MatrixXd & W);
+  template <class Mat>
+  IGL_INLINE bool readDMAT(const std::string file_name, Mat & W);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 2 - 0
include/igl/texture_from_tga.cpp

@@ -1,6 +1,7 @@
 #include "texture_from_tga.h"
 
 #include "tga.h"
+#include "report_gl_error.h"
 
 IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
 {
@@ -48,6 +49,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();
   }
 
   // Load texture

+ 0 - 15
include/igl/verbose.cpp

@@ -1,15 +0,0 @@
-#include "verbose.h"
-
-// http://channel9.msdn.com/forums/techoff/254707-wrapping-printf-in-c/
-IGL_INLINE int igl::verbose(const char * msg,...)
-{
-#ifdef VERBOSE
-  va_list argList;
-  va_start(argList, msg);
-  int count = vprintf(msg, argList);
-  va_end(argList);
-  return count;
-#else
-  return 0;
-#endif
-}

+ 24 - 10
include/igl/verbose.h

@@ -1,21 +1,35 @@
 #ifndef IGL_VERBOSE_H
 #define IGL_VERBOSE_H
-#include "igl_inline.h"
-// Provide a macro for printf, called verbose that functions exactly like
-// printf if VERBOSE is defined and does exactly nothing if VERBOSE is
-// undefined
+
+// This function is only useful as a header-only inlined function
+
+namespace igl
+{
+  // Provide a wrapper for printf, called verbose that functions exactly like
+  // printf if VERBOSE is defined and does exactly nothing if VERBOSE is
+  // undefined
+  inline int verbose(const char * msg,...);
+}
+
+
+
 #include <cstdio>
 #ifdef VERBOSE
 #  include <cstdarg>
 #endif
 
-namespace igl
+// http://channel9.msdn.com/forums/techoff/254707-wrapping-printf-in-c/
+inline  int igl::verbose(const char * msg,...)
 {
-  IGL_INLINE int verbose(const char * msg,...);
-}
-
-#ifdef IGL_HEADER_ONLY
-#  include "verbose.cpp"
+#ifdef VERBOSE
+  va_list argList;
+  va_start(argList, msg);
+  int count = vprintf(msg, argList);
+  va_end(argList);
+  return count;
+#else
+  return 0;
 #endif
+}
 
 #endif

+ 1 - 1
include/igl/writeDMAT.cpp

@@ -3,7 +3,7 @@
 #include <cstdio>
 #include <Eigen/Dense>
 
-  template <class Mat>
+template <class Mat>
 IGL_INLINE bool igl::writeDMAT(const std::string file_name, const Mat & W)
 {
   FILE * fp = fopen(file_name.c_str(),"w");

+ 2 - 1
tutorial.html

@@ -46,7 +46,8 @@
         project to use the static library for most functionality from IGL, but then
         include a certain IGL function as an inlined function. This may be achieved
         by surrounding the relevant include with a define and undefine of the
-        <code>IGL_HEADER_ONLY</code> macro. Like so:
+        <code>IGL_HEADER_ONLY</code> macro. Here's an example of the little
+        widget:
       </p>
       <pre><code>
 ...