1 // Copyright 2013 Blender Foundation. All rights reserved.
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.
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.
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.
17 // Author: Sergey Sharybin
19 #ifndef OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
20 #define OPENSUBDIV_CAPI_GL_MESH_CAPI_H_
22 #include <stdint.h> // for bool
24 #include "opensubdiv_capi_type.h"
30 struct OpenSubdiv_GLMeshInternal;
32 // Mesh which is displayable in OpenGL context.
33 typedef struct OpenSubdiv_GLMesh {
34 //////////////////////////////////////////////////////////////////////////////
35 // Subdivision/topology part.
37 // Returns the GL index buffer containing the patch control vertices.
38 unsigned int (*getPatchIndexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh);
40 // Bind GL buffer which contains vertices (VBO).
41 // TODO(sergey): Is this a coarse vertices?
42 void (*bindVertexBuffer)(struct OpenSubdiv_GLMesh* gl_mesh);
44 // Set coarse positions from a continuous array of coordinates.
45 void (*setCoarsePositions)(struct OpenSubdiv_GLMesh* gl_mesh,
46 const float* positions,
47 const int start_vertex,
48 const int num_vertices);
49 // TODO(sergey): setCoarsePositionsFromBuffer().
51 // Refine after coarse positions update.
52 void (*refine)(struct OpenSubdiv_GLMesh* gl_mesh);
54 // Synchronize after coarse positions update and refine.
55 void (*synchronize)(struct OpenSubdiv_GLMesh* gl_mesh);
57 //////////////////////////////////////////////////////////////////////////////
60 // Prepare mesh for display.
61 void (*prepareDraw)(struct OpenSubdiv_GLMesh* gl_mesh,
62 const bool use_osd_glsl,
63 const int active_uv_index);
65 // Draw given range of patches.
67 // If fill_quads is false, then patches are drawn in wireframe.
68 void (*drawPatches)(struct OpenSubdiv_GLMesh *gl_mesh,
69 const bool fill_quads,
70 const int start_patch, const int num_patches);
72 // Internal storage for the use in this module only.
74 // Tease: This contains an actual OpenSubdiv's Mesh object.
75 struct OpenSubdiv_GLMeshInternal* internal;
78 OpenSubdiv_GLMesh* openSubdiv_createOsdGLMeshFromTopologyRefiner(
79 struct OpenSubdiv_TopologyRefiner* topology_refiner,
80 eOpenSubdivEvaluator evaluator_type);
82 void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
84 // Global resources needed for GL mesh drawing.
85 bool openSubdiv_initGLMeshDrawingResources(void);
86 void openSubdiv_deinitGLMeshDrawingResources(void);
92 #endif // OPENSUBDIV_CAPI_GL_MESH_CAPI_H_