opensubdiv_gl_mesh_capi.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright 2013 Blender Foundation. All rights reserved.
  2. //
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the GNU General Public License
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software Foundation,
  15. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. //
  17. // Author: Sergey Sharybin
  18. #ifndef OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
  19. #define OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
  20. #include <stdint.h> // for bool
  21. #include "opensubdiv_capi_type.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. struct OpenSubdiv_GLMeshInternal;
  26. // Mesh which is displayable in OpenGL context.
  27. typedef struct OpenSubdiv_GLMesh {
  28. //////////////////////////////////////////////////////////////////////////////
  29. // Subdivision/topology part.
  30. // Returns the GL index buffer containing the patch control vertices.
  31. unsigned int (*getPatchIndexBuffer)(struct OpenSubdiv_GLMesh *gl_mesh);
  32. // Bind GL buffer which contains vertices (VBO).
  33. // TODO(sergey): Is this a coarse vertices?
  34. void (*bindVertexBuffer)(struct OpenSubdiv_GLMesh *gl_mesh);
  35. // Set coarse positions from a continuous array of coordinates.
  36. void (*setCoarsePositions)(struct OpenSubdiv_GLMesh *gl_mesh,
  37. const float *positions,
  38. const int start_vertex,
  39. const int num_vertices);
  40. // TODO(sergey): setCoarsePositionsFromBuffer().
  41. // Refine after coarse positions update.
  42. void (*refine)(struct OpenSubdiv_GLMesh *gl_mesh);
  43. // Synchronize after coarse positions update and refine.
  44. void (*synchronize)(struct OpenSubdiv_GLMesh *gl_mesh);
  45. //////////////////////////////////////////////////////////////////////////////
  46. // Drawing part.
  47. // Prepare mesh for display.
  48. void (*prepareDraw)(struct OpenSubdiv_GLMesh *gl_mesh,
  49. const bool use_osd_glsl,
  50. const int active_uv_index);
  51. // Draw given range of patches.
  52. //
  53. // If fill_quads is false, then patches are drawn in wireframe.
  54. void (*drawPatches)(struct OpenSubdiv_GLMesh *gl_mesh,
  55. const bool fill_quads,
  56. const int start_patch,
  57. const int num_patches);
  58. // Internal storage for the use in this module only.
  59. //
  60. // Tease: This contains an actual OpenSubdiv's Mesh object.
  61. struct OpenSubdiv_GLMeshInternal *internal;
  62. } OpenSubdiv_GLMesh;
  63. OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
  64. struct OpenSubdiv_TopologyRefiner *topology_refiner, eOpenSubdivEvaluator evaluator_type);
  65. void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
  66. // Global resources needed for GL mesh drawing.
  67. bool openSubdiv_initGLMeshDrawingResources(void);
  68. void openSubdiv_deinitGLMeshDrawingResources(void);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif // OPENSUBDIV_CAPI_GL_MESH_CAPI_H_