2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2013 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Sergey Sharybin
23 * ***** END GPL LICENSE BLOCK *****
26 #ifndef __OPENSUBDIV_CAPI_H__
27 #define __OPENSUBDIV_CAPI_H__
34 struct OpenSubdiv_GLMesh;
35 struct OpenSubdiv_TopologyRefinerDescr;
37 typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh;
40 struct OpenSubdiv_GLMeshDescr;
41 typedef struct OpenSubdiv_GLMesh {
43 OpenSubdiv_GLMeshDescr *descriptor;
44 OpenSubdiv_TopologyRefinerDescr *topology_refiner;
48 // Keep this a bitmask os it's possible to pass available
49 // evaluators to Blender.
51 OPENSUBDIV_EVALUATOR_CPU = (1 << 0),
52 OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1),
53 OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2),
54 OPENSUBDIV_EVALUATOR_CUDA = (1 << 3),
55 OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4),
56 OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5),
60 OPENSUBDIV_SCHEME_CATMARK,
61 OPENSUBDIV_SCHEME_BILINEAR,
62 OPENSUBDIV_SCHEME_LOOP,
65 /* TODO(sergey): Re-name and avoid bad level data access. */
66 OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
67 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
72 void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
73 unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(
74 OpenSubdiv_GLMesh *gl_mesh);
75 unsigned int openSubdiv_getOsdGLMeshVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
76 void openSubdiv_osdGLMeshUpdateVertexBuffer(OpenSubdiv_GLMesh *gl_mesh,
77 const float *vertex_data,
80 void openSubdiv_osdGLMeshRefine(OpenSubdiv_GLMesh *gl_mesh);
81 void openSubdiv_osdGLMeshSynchronize(OpenSubdiv_GLMesh *gl_mesh);
82 void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
84 const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner(
85 OpenSubdiv_GLMesh *gl_mesh);
87 /* ** Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs ** */
88 bool openSubdiv_osdGLDisplayInit(void);
89 void openSubdiv_osdGLDisplayDeinit(void);
91 /* ** Evaluator API ** */
93 struct OpenSubdiv_EvaluatorDescr;
94 typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr;
96 /* TODO(sergey): Avoid bad-level data access, */
97 OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(
98 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
101 void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr);
103 void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr,
108 void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr,
113 void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr,
115 float face_u, float face_v,
120 void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr,
122 float face_u, float face_v,
125 /* ** Actual drawing ** */
127 /* Initialize all the invariants which stays the same for every single path,
128 * for example lighting model stays untouched for the whole mesh.
130 * TODO(sergey): Some of the stuff could be initialized once for all meshes.
132 void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl,
133 int active_uv_index);
135 /* Draw specified patches. */
136 void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
141 /* ** Utility functions ** */
142 int openSubdiv_supportGPUDisplay(void);
143 int openSubdiv_getAvailableEvaluators(void);
144 void openSubdiv_init(bool gpu_legacy_support);
145 void openSubdiv_cleanup(void);
146 bool openSubdiv_gpu_legacy_support(void);
152 #endif // __OPENSUBDIV_CAPI_H__