create_mesh_vbo.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_CREATE_MESH_VBO_H
  9. #define IGL_CREATE_MESH_VBO_H
  10. #ifndef IGL_NO_OPENGL
  11. #include "igl_inline.h"
  12. // NOTE: It wouldn't be so hard to template this using Eigen's templates
  13. #include <Eigen/Core>
  14. #include "OpenGL_convenience.h"
  15. // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one
  16. // GL_ARRAY_BUFFER for the vertex positions (V) and one
  17. // GL_ELEMENT_ARRAY_BUFFER for the triangle indices (F)
  18. namespace igl
  19. {
  20. // Inputs:
  21. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  22. // F #F by 3 eigne Matrix of face (triangle) indices
  23. // Outputs:
  24. // V_vbo_id buffer id for vertex positions
  25. // F_vbo_id buffer id for face indices
  26. //
  27. // NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
  28. // MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
  29. //
  30. IGL_INLINE void create_mesh_vbo(
  31. const Eigen::MatrixXd & V,
  32. const Eigen::MatrixXi & F,
  33. GLuint & V_vbo_id,
  34. GLuint & F_vbo_id);
  35. // Inputs:
  36. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  37. // F #F by 3 eigne Matrix of face (triangle) indices
  38. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  39. // Outputs:
  40. // V_vbo_id buffer id for vertex positions
  41. // F_vbo_id buffer id for face indices
  42. // N_vbo_id buffer id for vertex positions
  43. IGL_INLINE void create_mesh_vbo(
  44. const Eigen::MatrixXd & V,
  45. const Eigen::MatrixXi & F,
  46. const Eigen::MatrixXd & N,
  47. GLuint & V_vbo_id,
  48. GLuint & F_vbo_id,
  49. GLuint & N_vbo_id);
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. # include "create_mesh_vbo.cpp"
  53. #endif
  54. #endif
  55. #endif