create_mesh_vbo.h 1.7 KB

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