map_texture.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef IGL_OPENGL_GLFW_MAP_TEXTURE_H
  2. #define IGL_OPENGL_GLFW_MAP_TEXTURE_H
  3. #ifdef IGL_OPENGL_4
  4. #include "../../igl_inline.h"
  5. #include <Eigen/Core>
  6. #include <vector>
  7. namespace igl
  8. {
  9. namespace opengl
  10. {
  11. namespace glfw
  12. {
  13. // Given a mesh (V,F) in [0,1]² and new positions (U) and a texture image
  14. // (in_data), _render_ a new image (out_data) of the same size.
  15. // Inputs:
  16. // V #V by 2 list of undeformed mesh vertex positions (matching texture)
  17. // F #F by 3 list of mesh triangle indices into V
  18. // U #U by 2 list of deformed vertex positions
  19. // in_data w*h*nc array of color values, channels, then columns, then
  20. // rows (e.g., what stbi_image returns and expects)
  21. // w width
  22. // h height
  23. // nc number of channels
  24. // Outputs:
  25. // out_data h*w*nc list of output colors in same order as input
  26. //
  27. template <typename DerivedV, typename DerivedF, typename DerivedU>
  28. IGL_INLINE bool map_texture(
  29. const Eigen::MatrixBase<DerivedV> & V,
  30. const Eigen::MatrixBase<DerivedF> & F,
  31. const Eigen::MatrixBase<DerivedU> & U,
  32. const unsigned char * in_data,
  33. const int w,
  34. const int h,
  35. const int nc,
  36. std::vector<unsigned char> & out_data);
  37. template <typename DerivedV, typename DerivedF, typename DerivedU>
  38. IGL_INLINE bool map_texture(
  39. const Eigen::MatrixBase<DerivedV> & _V,
  40. const Eigen::MatrixBase<DerivedF> & _F,
  41. const Eigen::MatrixBase<DerivedU> & _U,
  42. const unsigned char * in_data,
  43. const int w,
  44. const int h,
  45. const int nc,
  46. std::vector<unsigned char> & out_data,
  47. int & out_w,
  48. int & out_h,
  49. int & out_nc);
  50. }
  51. }
  52. }
  53. #ifndef IGL_STATIC_LIBRARY
  54. # include "map_texture.cpp"
  55. #endif
  56. #endif // IGL_OPENGL_4
  57. #endif