Forráskód Böngészése

missing inlines and organization

Former-commit-id: 494069c8a4b290da6eef9996004487a2d4051812
jalec 13 éve
szülő
commit
0289f43a50
3 módosított fájl, 32 hozzáadás és 15 törlés
  1. 29 12
      create_shader_program.h
  2. 2 2
      dirname.h
  3. 1 1
      get_seconds.h

+ 29 - 12
create_shader_program.h

@@ -45,18 +45,15 @@ inline bool igl::create_shader_program(
   const std::map<std::string,GLuint> attrib,
   GLuint & id)
 {
-  // load vertex shader
-  GLuint v = igl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
-  if(v == 0)
-  {
-    return false;
-  }
-  // load fragment shader
-  GLuint f = igl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
-  if(f == 0)
+  if(vert_source == "" && frag_source == "")
   {
+    fprintf(
+      stderr,
+      "Error: create_shader_program() could not create shader program,"
+      " both .vert and .frag source given were empty\n");
     return false;
   }
+
   // create program
   id = glCreateProgram();
   if(id == 0)
@@ -66,9 +63,29 @@ inline bool igl::create_shader_program(
       "Error: create_shader_program() could not create shader program.\n");
     return false;
   }
-  // Attach vertex and frag shaders to program
-  glAttachShader(id,v);
-  glAttachShader(id,f);
+
+  if(vert_source != "")
+  {
+    // load vertex shader
+    GLuint v = igl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
+    if(v == 0)
+    {
+      return false;
+    }
+    glAttachShader(id,v);
+  }
+
+  if(frag_source != "")
+  {
+    // load fragment shader
+    GLuint f = igl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
+    if(f == 0)
+    {
+      return false;
+    }
+    glAttachShader(id,f);
+  }
+
   // loop over attributes
   for(
     std::map<std::string,GLuint>::const_iterator ait = attrib.begin();

+ 2 - 2
dirname.h

@@ -11,14 +11,14 @@ namespace igl
   // Returns string containing dirname (see php's dirname)
   //
   // See also: basename, pathinfo
-  std::string dirname(const std::string & path);
+  inline std::string dirname(const std::string & path);
 }
 
 // Implementation
 #include <algorithm>
 #include "verbose.h"
 
-std::string igl::dirname(const std::string & path)
+inline std::string igl::dirname(const std::string & path)
 {
   if(path == "")
   {

+ 1 - 1
get_seconds.h

@@ -1,6 +1,5 @@
 #ifndef IGL_GET_SECONDS_H
 #define IGL_GET_SECONDS_H
-#include <sys/time.h>
 
 namespace igl
 {
@@ -10,6 +9,7 @@ namespace igl
 }
 
 //Implementation
+#include <sys/time.h>
 
 inline double igl::get_seconds()
 {