create_mesh_vbo.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef IGL_CREATE_MESH_VBO_H
  2. #define IGL_CREATE_MESH_VBO_H
  3. #ifndef IGL_NO_OPENGL
  4. #include "igl_inline.h"
  5. // NOTE: It wouldn't be so hard to template this using Eigen's templates
  6. #include <Eigen/Core>
  7. #include "OpenGL_convenience.h"
  8. // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one
  9. // GL_ARRAY_BUFFER for the vertex positions (V) and one
  10. // GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
  11. namespace igl
  12. {
  13. // Inputs:
  14. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  15. // F #F by 3 eigne Matrix of face (triangle) indices
  16. // Outputs:
  17. // V_vbo_id buffer id for vertex positions
  18. // F_vbo_id buffer id for face indices
  19. //
  20. // NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
  21. // MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
  22. //
  23. IGL_INLINE void create_mesh_vbo(
  24. const Eigen::MatrixXd & V,
  25. const Eigen::MatrixXi & F,
  26. GLuint & V_vbo_id,
  27. GLuint & F_vbo_id);
  28. // Inputs:
  29. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  30. // F #F by 3 eigne Matrix of face (triangle) indices
  31. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  32. // Outputs:
  33. // V_vbo_id buffer id for vertex positions
  34. // F_vbo_id buffer id for face indices
  35. // N_vbo_id buffer id for vertex positions
  36. IGL_INLINE void create_mesh_vbo(
  37. const Eigen::MatrixXd & V,
  38. const Eigen::MatrixXi & F,
  39. const Eigen::MatrixXd & N,
  40. GLuint & V_vbo_id,
  41. GLuint & F_vbo_id,
  42. GLuint & N_vbo_id);
  43. }
  44. #ifdef IGL_HEADER_ONLY
  45. # include "create_mesh_vbo.cpp"
  46. #endif
  47. #endif
  48. #endif