create_mesh_vbo.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # include <GL/gl.h>
  13. #else
  14. # define GL_GLEXT_PROTOTYPES
  15. # include <GL/gl.h>
  16. # include <GL/glext.h>
  17. #endif
  18. // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one
  19. // GL_ARRAY_BUFFER for the vertex positions (V) and one
  20. // GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
  21. namespace igl
  22. {
  23. // Inputs:
  24. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  25. // F #F by 3 eigne Matrix of face (triangle) indices
  26. // Outputs:
  27. // V_vbo_id buffer id for vertex positions
  28. // F_vbo_id buffer id for face indices
  29. //
  30. // NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
  31. // MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
  32. //
  33. IGL_INLINE void create_mesh_vbo(
  34. const Eigen::MatrixXd & V,
  35. const Eigen::MatrixXi & F,
  36. GLuint & V_vbo_id,
  37. GLuint & F_vbo_id);
  38. // Inputs:
  39. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  40. // F #F by 3 eigne Matrix of face (triangle) indices
  41. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  42. // Outputs:
  43. // V_vbo_id buffer id for vertex positions
  44. // F_vbo_id buffer id for face indices
  45. // N_vbo_id buffer id for vertex positions
  46. IGL_INLINE void create_mesh_vbo(
  47. const Eigen::MatrixXd & V,
  48. const Eigen::MatrixXi & F,
  49. const Eigen::MatrixXd & N,
  50. GLuint & V_vbo_id,
  51. GLuint & F_vbo_id,
  52. GLuint & N_vbo_id);
  53. }
  54. #ifdef IGL_HEADER_ONLY
  55. # include "create_mesh_vbo.cpp"
  56. #endif
  57. #endif