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_GLMeshFVarData;
36 struct OpenSubdiv_TopologyRefinerDescr;
38 typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh;
41 struct OpenSubdiv_GLMeshDescr;
43 typedef struct OpenSubdiv_GLMesh {
45 OpenSubdiv_GLMeshDescr *descriptor;
46 OpenSubdiv_TopologyRefinerDescr *topology_refiner;
47 OpenSubdiv_GLMeshFVarData *fvar_data;
51 // Keep this a bitmask os it's possible to pass available
52 // evaluators to Blender.
54 OPENSUBDIV_EVALUATOR_CPU = (1 << 0),
55 OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1),
56 OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2),
57 OPENSUBDIV_EVALUATOR_CUDA = (1 << 3),
58 OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4),
59 OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5),
63 OPENSUBDIV_SCHEME_CATMARK,
64 OPENSUBDIV_SCHEME_BILINEAR,
65 OPENSUBDIV_SCHEME_LOOP,
68 /* TODO(sergey): Re-name and avoid bad level data access. */
69 OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
70 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
74 void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
75 unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(
76 OpenSubdiv_GLMesh *gl_mesh);
77 unsigned int openSubdiv_getOsdGLMeshVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
78 void openSubdiv_osdGLMeshUpdateVertexBuffer(OpenSubdiv_GLMesh *gl_mesh,
79 const float *vertex_data,
82 void openSubdiv_osdGLMeshRefine(OpenSubdiv_GLMesh *gl_mesh);
83 void openSubdiv_osdGLMeshSynchronize(OpenSubdiv_GLMesh *gl_mesh);
84 void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
86 const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner(
87 OpenSubdiv_GLMesh *gl_mesh);
89 /* ** Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs ** */
90 bool openSubdiv_osdGLDisplayInit(void);
91 void openSubdiv_osdGLDisplayDeinit(void);
93 /* ** Evaluator API ** */
95 struct OpenSubdiv_EvaluatorDescr;
96 typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr;
98 /* TODO(sergey): Avoid bad-level data access, */
99 OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(
100 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
103 void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr);
105 void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr,
110 void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr,
115 void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr,
117 float face_u, float face_v,
122 void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr,
124 float face_u, float face_v,
127 /* ** Actual drawing ** */
129 /* Initialize all the invariants which stays the same for every single path,
130 * for example lighting model stays untouched for the whole mesh.
132 * TODO(sergey): Some of the stuff could be initialized once for all meshes.
134 void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl);
136 /* Draw specified patches. */
137 void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
142 void openSubdiv_osdGLAllocFVar(OpenSubdiv_GLMesh *gl_mesh,
143 const float *fvar_data);
144 void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh);
146 /* ** Utility functions ** */
147 int openSubdiv_supportGPUDisplay(void);
148 int openSubdiv_getAvailableEvaluators(void);
149 void openSubdiv_init(bool gpu_legacy_support);
150 void openSubdiv_cleanup(void);
151 bool openSubdiv_gpu_legacy_support(void);
157 #endif // __OPENSUBDIV_CAPI_H__