| 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
18 namespace OpenSubdiv {
19 namespace OPENSUBDIV_VERSION {
20
21 namespace Far{
22 class PatchTable;
23};
24
25 namespace Osd {
26
27 class GLPatchTable : private NonCopyable<GLPatchTable> {
28 public:
29 using ID = unsigned int; // GLuint resource ID
30 using VertexBufferBinding = ID; // buffer binding type
31
32 ~GLPatchTable();
33
34 static GLPatchTable *Create(Far::PatchTable const *farPatchTable,
35 void *deviceContext = NULL);
36
38 PatchArrayVector const &GetPatchArrays() const {
39 return _patchArrays;
40 }
41
43 ID GetPatchIndexBuffer() const {
44 return _patchIndexBuffer;
45 }
46
48 ID GetPatchParamBuffer() const {
49 return _patchParamBuffer;
50 }
51
53 ID GetPatchIndexTextureBuffer() const {
54 return _patchIndexTexture;
55 }
56
58 ID GetPatchParamTextureBuffer() const {
59 return _patchParamTexture;
60 }
61
63 PatchArrayVector const &GetVaryingPatchArrays() const {
64 return _varyingPatchArrays;
65 }
66
68 ID GetVaryingPatchIndexBuffer() const {
69 return _varyingIndexBuffer;
70 }
71
73 ID GetVaryingPatchIndexTextureBuffer() const {
74 return _varyingIndexTexture;
75 }
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
105 protected:
106 GLPatchTable();
107
108 // allocate buffers from patchTable
109 bool allocate(Far::PatchTable const *farPatchTable);
110
111 PatchArrayVector _patchArrays;
112
113 ID _patchIndexBuffer;
114 ID _patchParamBuffer;
115
116 ID _patchIndexTexture;
117 ID _patchParamTexture;
118
119 PatchArrayVector _varyingPatchArrays;
120 ID _varyingIndexBuffer;
121 ID _varyingIndexTexture;
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
135 using namespace OPENSUBDIV_VERSION;
136
137} // end namespace OpenSubdiv
138
139#endif // OPENSUBDIV3_OSD_GL_PATCH_TABLE_H
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetFVarPatchIndexBuffer
ID GetFVarPatchIndexBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying control vertices.
Definition glPatchTable.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetPatchArrays
PatchArrayVector const & GetPatchArrays() const
Returns the patch arrays for vertex index buffer data.
Definition glPatchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_varyingIndexTexture
ID _varyingIndexTexture
Definition glPatchTable.h:121
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_fvarIndexTextures
std::vector< ID > _fvarIndexTextures
Definition glPatchTable.h:125
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::~GLPatchTable
~GLPatchTable()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetPatchIndexBuffer
ID GetPatchIndexBuffer() const
Returns the GL index buffer containing the patch control vertices.
Definition glPatchTable.h:43
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::allocate
bool allocate(Far::PatchTable const *farPatchTable)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_patchIndexBuffer
ID _patchIndexBuffer
Definition glPatchTable.h:113
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_patchParamTexture
ID _patchParamTexture
Definition glPatchTable.h:117
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetPatchParamBuffer
ID GetPatchParamBuffer() const
Returns the GL index buffer containing the patch parameter.
Definition glPatchTable.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_patchIndexTexture
ID _patchIndexTexture
Definition glPatchTable.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::Create
static GLPatchTable * Create(Far::PatchTable const *farPatchTable, void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_varyingIndexBuffer
ID _varyingIndexBuffer
Definition glPatchTable.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetFVarPatchParamBuffer
ID GetFVarPatchParamBuffer(int fvarChannel=0) const
Returns the GL index buffer containing face-varying patch params.
Definition glPatchTable.h:96
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_fvarParamBuffers
std::vector< ID > _fvarParamBuffers
Definition glPatchTable.h:127
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_patchArrays
PatchArrayVector _patchArrays
Definition glPatchTable.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetVaryingPatchIndexTextureBuffer
ID GetVaryingPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the varying control vertices.
Definition glPatchTable.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetPatchIndexTextureBuffer
ID GetPatchIndexTextureBuffer() const
Returns the GL texture buffer containing the patch control vertices.
Definition glPatchTable.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetPatchParamTextureBuffer
ID GetPatchParamTextureBuffer() const
Returns the GL texture buffer containing the patch parameter.
Definition glPatchTable.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_fvarIndexBuffers
std::vector< ID > _fvarIndexBuffers
Definition glPatchTable.h:124
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GLPatchTable
GLPatchTable()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetFVarPatchParamTextureBuffer
ID GetFVarPatchParamTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying patch params.
Definition glPatchTable.h:101
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::VertexBufferBinding
ID VertexBufferBinding
Definition glPatchTable.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetNumFVarChannels
int GetNumFVarChannels() const
Returns the number of face-varying channel buffers.
Definition glPatchTable.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_fvarParamTextures
std::vector< ID > _fvarParamTextures
Definition glPatchTable.h:128
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetFVarPatchIndexTextureBuffer
ID GetFVarPatchIndexTextureBuffer(int fvarChannel=0) const
Returns the GL texture buffer containing face-varying control vertices.
Definition glPatchTable.h:91
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetFVarPatchArrays
PatchArrayVector const & GetFVarPatchArrays(int fvarChannel=0) const
Returns the patch arrays for face-varying index buffer data.
Definition glPatchTable.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_fvarPatchArrays
std::vector< PatchArrayVector > _fvarPatchArrays
Definition glPatchTable.h:123
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_patchParamBuffer
ID _patchParamBuffer
Definition glPatchTable.h:114
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::_varyingPatchArrays
PatchArrayVector _varyingPatchArrays
Definition glPatchTable.h:119
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetVaryingPatchIndexBuffer
ID GetVaryingPatchIndexBuffer() const
Returns the GL index buffer containing the varying control vertices.
Definition glPatchTable.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::GetVaryingPatchArrays
PatchArrayVector const & GetVaryingPatchArrays() const
Returns the patch arrays for varying index buffer data.
Definition glPatchTable.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Osd::GLPatchTable::ID
unsigned int ID
Definition glPatchTable.h:29
types.h