2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2013 Blender Foundation.
17 * All rights reserved.
20 #ifndef __OPENSUBDIV_CAPI_H__
21 #define __OPENSUBDIV_CAPI_H__
28 struct OpenSubdiv_GLMesh;
29 struct OpenSubdiv_GLMeshFVarData;
30 struct OpenSubdiv_TopologyRefinerDescr;
32 typedef struct OpenSubdiv_GLMesh OpenSubdiv_GLMesh;
35 struct OpenSubdiv_GLMeshDescr;
37 typedef struct OpenSubdiv_GLMesh {
39 OpenSubdiv_GLMeshDescr *descriptor;
40 OpenSubdiv_TopologyRefinerDescr *topology_refiner;
41 OpenSubdiv_GLMeshFVarData *fvar_data;
45 // Keep this a bitmask os it's possible to pass available
46 // evaluators to Blender.
48 OPENSUBDIV_EVALUATOR_CPU = (1 << 0),
49 OPENSUBDIV_EVALUATOR_OPENMP = (1 << 1),
50 OPENSUBDIV_EVALUATOR_OPENCL = (1 << 2),
51 OPENSUBDIV_EVALUATOR_CUDA = (1 << 3),
52 OPENSUBDIV_EVALUATOR_GLSL_TRANSFORM_FEEDBACK = (1 << 4),
53 OPENSUBDIV_EVALUATOR_GLSL_COMPUTE = (1 << 5),
57 OPENSUBDIV_SCHEME_CATMARK,
58 OPENSUBDIV_SCHEME_BILINEAR,
59 OPENSUBDIV_SCHEME_LOOP,
62 /* TODO(sergey): Re-name and avoid bad level data access. */
63 OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
64 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
68 void openSubdiv_deleteOsdGLMesh(OpenSubdiv_GLMesh *gl_mesh);
69 unsigned int openSubdiv_getOsdGLMeshPatchIndexBuffer(
70 OpenSubdiv_GLMesh *gl_mesh);
71 unsigned int openSubdiv_getOsdGLMeshVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
72 void openSubdiv_osdGLMeshUpdateVertexBuffer(OpenSubdiv_GLMesh *gl_mesh,
73 const float *vertex_data,
76 void openSubdiv_osdGLMeshRefine(OpenSubdiv_GLMesh *gl_mesh);
77 void openSubdiv_osdGLMeshSynchronize(OpenSubdiv_GLMesh *gl_mesh);
78 void openSubdiv_osdGLMeshBindVertexBuffer(OpenSubdiv_GLMesh *gl_mesh);
80 const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefiner(
81 OpenSubdiv_GLMesh *gl_mesh);
83 /* ** Initialize/Deinitialize global OpenGL drawing buffers/GLSL programs ** */
84 bool openSubdiv_osdGLDisplayInit(void);
85 void openSubdiv_osdGLDisplayDeinit(void);
87 /* ** Evaluator API ** */
89 struct OpenSubdiv_EvaluatorDescr;
90 typedef struct OpenSubdiv_EvaluatorDescr OpenSubdiv_EvaluatorDescr;
92 /* TODO(sergey): Avoid bad-level data access, */
93 OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(
94 struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
97 void openSubdiv_deleteEvaluatorDescr(OpenSubdiv_EvaluatorDescr *evaluator_descr);
99 void openSubdiv_setEvaluatorCoarsePositions(OpenSubdiv_EvaluatorDescr *evaluator_descr,
104 void openSubdiv_setEvaluatorVaryingData(OpenSubdiv_EvaluatorDescr *evaluator_descr,
109 void openSubdiv_evaluateLimit(OpenSubdiv_EvaluatorDescr *evaluator_descr,
111 float face_u, float face_v,
116 void openSubdiv_evaluateVarying(OpenSubdiv_EvaluatorDescr *evaluator_descr,
118 float face_u, float face_v,
121 /* ** Actual drawing ** */
123 /* Initialize all the invariants which stays the same for every single path,
124 * for example lighting model stays untouched for the whole mesh.
126 * TODO(sergey): Some of the stuff could be initialized once for all meshes.
128 void openSubdiv_osdGLMeshDisplayPrepare(int use_osd_glsl,
129 int active_uv_index);
131 /* Draw specified patches. */
132 void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
137 void openSubdiv_osdGLAllocFVar(struct OpenSubdiv_TopologyRefinerDescr *topology_refiner,
138 OpenSubdiv_GLMesh *gl_mesh,
139 const float *fvar_data);
140 void openSubdiv_osdGLDestroyFVar(OpenSubdiv_GLMesh *gl_mesh);
142 /* ** Utility functions ** */
143 int openSubdiv_supportGPUDisplay(void);
144 int openSubdiv_getAvailableEvaluators(void);
145 void openSubdiv_init(bool gpu_legacy_support);
146 void openSubdiv_cleanup(void);
147 bool openSubdiv_gpu_legacy_support(void);
149 int openSubdiv_getVersionHex(void);
155 #endif // __OPENSUBDIV_CAPI_H__