Преглед изворни кода

expose parameter to flip image first

Former-commit-id: 3de9538f81128deaf9bad67b3791326a21872f19
Alec Jacobson пре 9 година
родитељ
комит
42be15198b
2 измењених фајлова са 12 додато и 2 уклоњено
  1. 10 2
      include/igl/png/texture_from_png.cpp
  2. 2 0
      include/igl/png/texture_from_png.h

+ 10 - 2
include/igl/png/texture_from_png.cpp

@@ -10,7 +10,7 @@
 #include "../opengl/report_gl_error.h"
 #include <YImage.hpp>
 
-IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint & id)
+IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const bool flip, GLuint & id)
 {
   YImage yimg;
   if(!yimg.load(png_file.c_str()))
@@ -18,7 +18,10 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint &
     return false;
   }
   // Why do I need to flip?
-  //yimg.flip();
+  if(flip)
+  {
+    yimg.flip();
+  }
   glGenTextures(1, &id);
   glBindTexture(GL_TEXTURE_2D, id);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -32,6 +35,11 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint &
   return true;
 }
 
+IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint & id)
+{
+  return texture_from_png(png_file,false,id);
+}
+
 
 IGL_INLINE bool igl::png::texture_from_png(
   const std::string png_file,

+ 2 - 0
include/igl/png/texture_from_png.h

@@ -22,9 +22,11 @@ namespace igl
     //
     // Input:
     //  png_file  path to .png file
+    //  flip  whether to flip the image vertically (A --> ∀)
     // Output:
     //  id  of generated openGL texture
     // Returns true on success, false on failure
+    IGL_INLINE bool texture_from_png(const std::string png_file, const bool flip, GLuint & id);
     IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
   }
 }