OpenSubdiv
Loading...
Searching...
No Matches
glPatchTable.h
Go to the documentation of this file.
1//
2// Copyright 2015 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
9#define OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
10
11#include "../version.h"
12
13#include "../osd/nonCopyable.h"
14#include "../osd/types.h"
15
16#include <vector>
17
18namespace OpenSubdiv {
19namespace OPENSUBDIV_VERSION {
20
21namespace Far{
22 class PatchTable;
23};
24
25namespace Osd {
26
27class GLPatchTable : private NonCopyable<GLPatchTable> {
28public:
29 using ID = unsigned int; // GLuint resource ID
30 using VertexBufferBinding = ID; // buffer binding type
31
33
34 static GLPatchTable *Create(Far::PatchTable const *farPatchTable,
35 void *deviceContext = NULL);
36
39 return _patchArrays;
40 }
41
44 return _patchIndexBuffer;
45 }
46
49 return _patchParamBuffer;
50 }
51
56
61
66
71
76
78 int GetNumFVarChannels() const { return (int)_fvarPatchArrays.size(); }
79
81 PatchArrayVector const &GetFVarPatchArrays(int fvarChannel = 0) const {
82 return _fvarPatchArrays[fvarChannel];
83 }
84
86 ID GetFVarPatchIndexBuffer(int fvarChannel = 0) const {
87 return _fvarIndexBuffers[fvarChannel];
88 }
89
91 ID GetFVarPatchIndexTextureBuffer(int fvarChannel = 0) const {
92 return _fvarIndexTextures[fvarChannel];
93 }
94
96 ID GetFVarPatchParamBuffer(int fvarChannel = 0) const {
97 return _fvarParamBuffers[fvarChannel];
98 }
99
101 ID GetFVarPatchParamTextureBuffer(int fvarChannel = 0) const {
102 return _fvarParamTextures[fvarChannel];
103 }
104
105protected:
107
108 // allocate buffers from patchTable
109 bool allocate(Far::PatchTable const *farPatchTable);
110
112
115
118
122
123 std::vector<PatchArrayVector> _fvarPatchArrays;
124 std::vector<ID> _fvarIndexBuffers;
125 std::vector<ID> _fvarIndexTextures;
126
127 std::vector<ID> _fvarParamBuffers;
128 std::vector<ID> _fvarParamTextures;
129};
130
131
132} // end namespace Osd
133
134} // end namespace OPENSUBDIV_VERSION
135using namespace OPENSUBDIV_VERSION;
136
137} // end namespace OpenSubdiv
138
139#endif // OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
Container for arrays of parametric patches.
Definition patchTable.h:38
ID GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying control vertices.
PatchArrayVector const & GetPatchArrays() const
Returns the patch arrays for vertex index buffer data.
ID GetPatchIndexBuffer() const
Returns the GL index buffer containing the patch control vertices.
bool allocate(Far::PatchTable const *farPatchTable)
ID GetPatchParamBuffer() const
Returns the GL index buffer containing the patch parameter.
static GLPatchTable * Create(Far::PatchTable const *farPatchTable, void *deviceContext=NULL)
ID GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying patch params.
ID GetVaryingPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the varying control vertices.
ID GetPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the patch control vertices.
ID GetPatchParamTextureBuffer() const
Returns the GL texture buffer containing the patch parameter.
ID GetFVarPatchParamTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying patch params.
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.
ID GetFVarPatchIndexTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying control vertices.
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Returns the patch arrays for face-varying index buffer data.
std::vector< PatchArrayVector > _fvarPatchArrays
ID 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.