All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
glDrawContext.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 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 OSD_GL_DRAW_CONTEXT_H
26 #define OSD_GL_DRAW_CONTEXT_H
27 
28 #include "../version.h"
29 
30 #include "../far/patchTables.h"
31 #include "../osd/drawContext.h"
32 #include "../osd/drawRegistry.h"
33 #include "../osd/vertex.h"
34 
35 #include "../osd/opengl.h"
36 
37 #include <map>
38 
39 namespace OpenSubdiv {
40 namespace OPENSUBDIV_VERSION {
41 
42 namespace Osd {
43 
54 class GLDrawContext : public DrawContext {
55 public:
56  typedef GLuint VertexBufferBinding;
57 
58  virtual ~GLDrawContext();
59 
66  static GLDrawContext * Create(Far::PatchTables const * patchTables, int numVertexElements);
67 
72  template<class VERTEX_BUFFER>
73  void UpdateVertexTexture(VERTEX_BUFFER *vbo) {
74  if (vbo)
75  updateVertexTexture(vbo->BindVBO());
76  }
77 
79  static bool SupportsAdaptiveTessellation();
80 
82  GLuint GetPatchIndexBuffer() const {
83  return _patchIndexBuffer;
84  }
85 
88  GLuint GetPatchParamTextureBuffer() const {
90  }
91 
93  GLuint GetVertexTextureBuffer() const {
94  return _vertexTextureBuffer;
95  }
96 
101  }
102 
107  }
108 
110  GLuint GetFvarDataTextureBuffer() const {
111  return _fvarDataTextureBuffer;
112  }
113 
124  bool SetFVarDataTexture(Far::PatchTables const & patchTables,
125  int fvarWidth, FVarData const & fvarData);
126 
127 protected:
128 
130 
133 
137 
138  GLDrawContext();
139 
140  // allocate buffers from patchTables
141  bool create(Far::PatchTables const & patchTables, int numElements);
142 
143  void updateVertexTexture(GLuint vbo);
144 };
145 
146 } // end namespace Osd
147 
148 } // end namespace OPENSUBDIV_VERSION
149 using namespace OPENSUBDIV_VERSION;
150 
151 } // end namespace OpenSubdiv
152 
153 #endif /* OSD_DRAW_CONTEXT_H */
154 
static bool SupportsAdaptiveTessellation()
true if the GL version detected supports shader tessellation
Container for patch vertex indices tables.
Definition: patchTables.h:49
bool create(Far::PatchTables const &patchTables, int numElements)
GLuint GetVertexTextureBuffer() const
Returns the GL texture buffer containing the vertex data.
Definition: glDrawContext.h:93
GLuint GetFvarDataTextureBuffer() const
Returns the GL texture buffer containing fvar data.
GLuint GetPatchIndexBuffer() const
Returns the GL texture buffer containing the patch control vertices array.
Definition: glDrawContext.h:82
bool SetFVarDataTexture(Far::PatchTables const &patchTables, int fvarWidth, FVarData const &fvarData)
static GLDrawContext * Create(Far::PatchTables const *patchTables, int numVertexElements)
Create an GLDraContext from Far::PatchTables.
OpenGL specialized DrawContext class.
Definition: glDrawContext.h:54