Browse Source

Important BUG FIXES to create_*_vbo,
added print gl get (work in progress)


Former-commit-id: 9acc9ee22e4b024e8d33590b60e6902713c088ca

jalec 13 years ago
parent
commit
33cff94394
4 changed files with 65 additions and 15 deletions
  1. 3 3
      create_index_vbo.h
  2. 2 2
      create_mesh_vbo.h
  3. 10 10
      create_vector_vbo.h
  4. 50 0
      print_gl_get.h

+ 3 - 3
create_index_vbo.h

@@ -43,7 +43,7 @@ void igl::create_index_vbo(
   {
   {
     glBufferDataARB(
     glBufferDataARB(
       GL_ELEMENT_ARRAY_BUFFER_ARB,
       GL_ELEMENT_ARRAY_BUFFER_ARB,
-      sizeof(double)*F.size(),
+      sizeof(int)*F.size(),
       F.data(),
       F.data(),
       GL_STATIC_DRAW_ARB);
       GL_STATIC_DRAW_ARB);
   }else
   }else
@@ -53,9 +53,9 @@ void igl::create_index_vbo(
     // If its column major then we need to temporarily store a transpose
     // If its column major then we need to temporarily store a transpose
     glBufferDataARB(
     glBufferDataARB(
       GL_ELEMENT_ARRAY_BUFFER_ARB,
       GL_ELEMENT_ARRAY_BUFFER_ARB,
-      sizeof(double)*F.size(),
+      sizeof(int)*F.size(),
       FT.data(),
       FT.data(),
-      GL_STATIC_DRAW_ARB);
+      GL_STATIC_DRAW);
   }
   }
   // bind with 0, so, switch back to normal pointer operation
   // bind with 0, so, switch back to normal pointer operation
   glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
   glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);

+ 2 - 2
create_mesh_vbo.h

@@ -11,8 +11,8 @@
 #endif
 #endif
 
 
 // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one 
 // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one 
-// GL_ARRAY_BUFFER_ARB for the vertex positions (V) and one
-// GL_ELEMENT_ARRAY_BUFFER_ARB for the triangle indices (F)
+// GL_ARRAY_BUFFER for the vertex positions (V) and one
+// GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
 namespace igl
 namespace igl
 {
 {
 
 

+ 10 - 10
create_vector_vbo.h

@@ -11,7 +11,7 @@
 #endif
 #endif
 
 
 // Create a VBO (Vertex Buffer Object) for a list of vectors:
 // Create a VBO (Vertex Buffer Object) for a list of vectors:
-// GL_ARRAY_BUFFER_ARB for the vectors (V)
+// GL_ARRAY_BUFFER for the vectors (V)
 namespace igl
 namespace igl
 {
 {
 
 
@@ -37,32 +37,32 @@ void igl::create_vector_vbo(
   assert(V.cols() == 3);
   assert(V.cols() == 3);
 
 
   // Generate Buffers
   // Generate Buffers
-  glGenBuffersARB(1,&V_vbo_id);
+  glGenBuffers(1,&V_vbo_id);
   // Bind Buffers
   // Bind Buffers
-  glBindBufferARB(GL_ARRAY_BUFFER_ARB,V_vbo_id);
+  glBindBuffer(GL_ARRAY_BUFFER,V_vbo_id);
   // Copy data to buffers
   // Copy data to buffers
   // We expect a matrix with each vertex position on a row, we then want to
   // We expect a matrix with each vertex position on a row, we then want to
   // pass this data to OpenGL reading across rows (row-major)
   // pass this data to OpenGL reading across rows (row-major)
   if(V.Options & Eigen::RowMajor)
   if(V.Options & Eigen::RowMajor)
   {
   {
-    glBufferDataARB(
-      GL_ARRAY_BUFFER_ARB,
+    glBufferData(
+      GL_ARRAY_BUFFER,
       sizeof(double)*V.size(),
       sizeof(double)*V.size(),
       V.data(),
       V.data(),
-      GL_STATIC_DRAW_ARB);
+      GL_STATIC_DRAW);
   }else
   }else
   {
   {
     // Create temporary copy of transpose
     // Create temporary copy of transpose
     Eigen::MatrixXd VT = V.transpose();
     Eigen::MatrixXd VT = V.transpose();
     // If its column major then we need to temporarily store a transpose
     // If its column major then we need to temporarily store a transpose
-    glBufferDataARB(
-      GL_ARRAY_BUFFER_ARB,
+    glBufferData(
+      GL_ARRAY_BUFFER,
       sizeof(double)*V.size(),
       sizeof(double)*V.size(),
       VT.data(),
       VT.data(),
-      GL_STATIC_DRAW_ARB);
+      GL_STATIC_DRAW);
   }
   }
   // bind with 0, so, switch back to normal pointer operation
   // bind with 0, so, switch back to normal pointer operation
-  glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+  glBindBuffer(GL_ARRAY_BUFFER, 0);
 }
 }
 
 
 #endif
 #endif

+ 50 - 0
print_gl_get.h

@@ -0,0 +1,50 @@
+#ifndef PRINT_gl_get_H
+#define PRINT_gl_get_H
+
+#if __APPLE__
+#  include <OpenGL/gl.h>
+#else
+#  include <GL/gl.h>
+#endif
+
+namespace igl
+{
+  // Prints the value of pname found by issuing glGet*(pname,*)
+  // Inputs:
+  //   pname  enum key to gl parameter
+  void print_gl_get(GLenum pname);
+}
+
+
+// implementation
+#include <cstdio>
+void igl::print_gl_get(GLenum pname)
+{
+  double dM[16];
+
+  int rows = 4;
+  int cols = 4;
+  switch(pname)
+  {
+    case GL_MODELVIEW_MATRIX:
+    case GL_PROJECTION_MATRIX:
+    {
+      rows = 4;
+      cols = 4;
+      glGetDoublev(pname,dM);
+      for(int i = 0;i<rows;i++)
+      {
+        for(int j = 0;j<cols;j++)
+        {
+          printf("%lg ",dM[j*rows+i]);
+        }
+        printf("\n");
+      }
+      break;
+    }
+    default:
+      fprintf(stderr,"ERROR in print_gl_get(), gl enum not recognized.\n");
+  }
+}
+
+#endif