OpenSubdiv
Loading...
Searching...
No Matches
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
36namespace OpenSubdiv {
37namespace OPENSUBDIV_VERSION {
38
39namespace Far{
40 class PatchTable;
41};
42
43namespace Osd {
44
45class GLPatchTable : private NonCopyable<GLPatchTable> {
46public:
47 typedef GLuint VertexBufferBinding;
48
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
71 return _patchIndexTexture;
72 }
73
76 return _patchParamTexture;
77 }
78
83
87 }
88
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
122protected:
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
152using namespace OPENSUBDIV_VERSION;
153
154} // end namespace OpenSubdiv
155
156#endif // OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
std::vector< PatchArray > PatchArrayVector
Definition types.h:132
Container for arrays of parametric patches.
Definition patchTable.h:55
PatchArrayVector const & GetPatchArrays() const
Returns the patch arrays for vertex index buffer data.
GLuint GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying control vertices.
GLuint GetPatchParamTextureBuffer() const
Returns the GL texture buffer containing the patch parameter.
bool allocate(Far::PatchTable const *farPatchTable)
static GLPatchTable * Create(Far::PatchTable const *farPatchTable, void *deviceContext=NULL)
GLuint GetPatchParamBuffer() const
Returns the GL index buffer containing the patch parameter.
GLuint GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying patch params.
GLuint GetFVarPatchIndexTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying control vertices.
GLuint GetFVarPatchParamTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying patch params.
GLuint GetPatchIndexBuffer() const
Returns the GL index buffer containing the patch control vertices.
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Returns the patch arrays for face-varying index buffer data.
std::vector< PatchArrayVector > _fvarPatchArrays
GLuint GetPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the patch control vertices.
GLuint GetVaryingPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the varying control vertices.
GLuint GetVaryingPatchIndexBuffer() const
Returns the GL index buffer containing the varying control vertices.
PatchArrayVector const & GetVaryingPatchArrays() const
Returns the patch arrays for varying index buffer data.