All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
glPatchTable.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
26 #define OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
27 
28 #include "../version.h"
29 
30 #include "../osd/nonCopyable.h"
31 #include "../osd/opengl.h"
32 #include "../osd/types.h"
33 
34 #include <vector>
35 
36 namespace OpenSubdiv {
37 namespace OPENSUBDIV_VERSION {
38 
39 namespace Far{
40  class PatchTable;
41 };
42 
43 namespace Osd {
44 
45 class GLPatchTable : private NonCopyable<GLPatchTable> {
46 public:
47  typedef GLuint VertexBufferBinding;
48 
49  ~GLPatchTable();
50 
51  static GLPatchTable *Create(Far::PatchTable const *farPatchTable,
52  void *deviceContext = NULL);
53 
56  return _patchArrays;
57  }
58 
60  GLuint GetPatchIndexBuffer() const {
61  return _patchIndexBuffer;
62  }
63 
65  GLuint GetPatchParamBuffer() const {
66  return _patchParamBuffer;
67  }
68 
70  GLuint GetPatchIndexTextureBuffer() const {
71  return _patchIndexTexture;
72  }
73 
75  GLuint GetPatchParamTextureBuffer() const {
76  return _patchParamTexture;
77  }
78 
81  return _varyingPatchArrays;
82  }
83 
85  GLuint GetVaryingPatchIndexBuffer() const {
86  return _varyingIndexBuffer;
87  }
88 
91  return _varyingIndexTexture;
92  }
93 
95  int GetNumFVarChannels() const { return (int)_fvarPatchArrays.size(); }
96 
98  PatchArrayVector const &GetFVarPatchArrays(int fvarChannel = 0) const {
99  return _fvarPatchArrays[fvarChannel];
100  }
101 
103  GLuint GetFVarPatchIndexBuffer(int fvarChannel = 0) const {
104  return _fvarIndexBuffers[fvarChannel];
105  }
106 
108  GLuint GetFVarPatchIndexTextureBuffer(int fvarChannel = 0) const {
109  return _fvarIndexTextures[fvarChannel];
110  }
111 
113  GLuint GetFVarPatchParamBuffer(int fvarChannel = 0) const {
114  return _fvarParamBuffers[fvarChannel];
115  }
116 
118  GLuint GetFVarPatchParamTextureBuffer(int fvarChannel = 0) const {
119  return _fvarParamTextures[fvarChannel];
120  }
121 
122 protected:
123  GLPatchTable();
124 
125  // allocate buffers from patchTable
126  bool allocate(Far::PatchTable const *farPatchTable);
127 
129 
132 
135 
139 
140  std::vector<PatchArrayVector> _fvarPatchArrays;
141  std::vector<GLuint> _fvarIndexBuffers;
142  std::vector<GLuint> _fvarIndexTextures;
143 
144  std::vector<GLuint> _fvarParamBuffers;
145  std::vector<GLuint> _fvarParamTextures;
146 };
147 
148 
149 } // end namespace Osd
150 
151 } // end namespace OPENSUBDIV_VERSION
152 using namespace OPENSUBDIV_VERSION;
153 
154 } // end namespace OpenSubdiv
155 
156 #endif // OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
GLuint GetVaryingPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the varying control vertices.
Definition: glPatchTable.h:90
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.
Definition: glPatchTable.h:95
PatchArrayVector const & GetVaryingPatchArrays() const
Returns the patch arrays for varying index buffer data.
Definition: glPatchTable.h:80
static GLPatchTable * Create(Far::PatchTable const *farPatchTable, void *deviceContext=NULL)
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Returns the patch arrays for face-varying index buffer data.
Definition: glPatchTable.h:98
GLuint GetPatchParamTextureBuffer() const
Returns the GL texture buffer containing the patch parameter.
Definition: glPatchTable.h:75
GLuint GetPatchIndexBuffer() const
Returns the GL index buffer containing the patch control vertices.
Definition: glPatchTable.h:60
GLuint GetPatchParamBuffer() const
Returns the GL index buffer containing the patch parameter.
Definition: glPatchTable.h:65
Container for arrays of parametric patches.
Definition: patchTable.h:55
GLuint GetFVarPatchParamTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying patch params.
Definition: glPatchTable.h:118
GLuint GetPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the patch control vertices.
Definition: glPatchTable.h:70
GLuint GetVaryingPatchIndexBuffer() const
Returns the GL index buffer containing the varying control vertices.
Definition: glPatchTable.h:85
PatchArrayVector const & GetPatchArrays() const
Returns the patch arrays for vertex index buffer data.
Definition: glPatchTable.h:55
GLuint GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying patch params.
Definition: glPatchTable.h:113
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
GLuint GetFVarPatchIndexTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying control vertices.
Definition: glPatchTable.h:108
std::vector< PatchArrayVector > _fvarPatchArrays
Definition: glPatchTable.h:140
bool allocate(Far::PatchTable const *farPatchTable)
GLuint GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying control vertices.
Definition: glPatchTable.h:103