All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ptexTexture.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef GLF_PTEXTEXTURE_H
25 #define GLF_PTEXTEXTURE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 
32 #include <string>
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 
45 GLF_API bool GlfIsSupportedPtexTexture(std::string const & imageFilePath);
46 
47 
48 PXR_NAMESPACE_CLOSE_SCOPE
49 
50 
51 #if defined(PXR_PTEX_SUPPORT_ENABLED) || defined(doxygen)
52 
53 #include "pxr/imaging/glf/texture.h"
54 
55 #include "pxr/base/tf/declarePtrs.h"
56 #include "pxr/base/tf/token.h"
57 #include "pxr/base/tf/refPtr.h"
58 #include "pxr/base/tf/weakPtr.h"
59 
60 PXR_NAMESPACE_OPEN_SCOPE
61 
63 
81 
82 class GlfPtexTexture : public GlfTexture {
83 public:
84  GLF_API
85  ~GlfPtexTexture() override;
86 
88  GLF_API
89  static GlfPtexTextureRefPtr New(const TfToken &imageFilePath);
90 
92  GLF_API
93  BindingVector GetBindings(TfToken const & identifier,
94  GLuint samplerName) override;
95 
96  GLF_API
97  VtDictionary GetTextureInfo(bool forceLoad) override;
98 
99  GLF_API
100  bool IsMinFilterSupported(GLenum filter) override;
101 
102  GLF_API
103  bool IsMagFilterSupported(GLenum filter) override;
104 
105  // get/set guttering control variables
106  static int GetGutterWidth() { return _gutterWidth; }
107 
108  static int GetPageMargin() { return _pageMargin; }
109 
110  // return GL texture for layout texture buffer
111  GLF_API
112  GLuint GetLayoutTextureName();
113 
114  // return GL texture for texels data texture
115  GLF_API
116  GLuint GetGlTextureName() override;
117 
118 protected:
119  GLF_API
120  GlfPtexTexture(const TfToken &imageFilePath);
121 
122  GLF_API
123  void _FreePtexTextureObject();
124 
125  GLF_API
126  void _OnMemoryRequestedDirty() override;
127 
128 private:
129  bool _ReadImage();
130 
131  bool _loaded;
132 
133  GLuint _layout; // per-face lookup table
134  GLuint _texels; // texel data
135 
136  GLsizei _width, _height, _depth;
137  GLint _format;
138 
139  static int _gutterWidth, _pageMargin;
140 
141  const TfToken _imageFilePath;
142 };
143 
144 PXR_NAMESPACE_CLOSE_SCOPE
145 
146 #endif // PXR_PTEX_SUPPORT_ENABLED
147 
148 #endif // GLF_TEXTURE_H
GLF_API BindingVector GetBindings(TfToken const &identifier, GLuint samplerName) override
GlfTexture overrides.
A map with string keys and VtValue values.
Definition: dictionary.h:61
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
static GLF_API GlfPtexTextureRefPtr New(const TfToken &imageFilePath)
Creates a new instance.
Represents a Ptex (per-face texture) object in Glf.
Definition: ptexTexture.h:82
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
GLF_API bool GlfIsSupportedPtexTexture(std::string const &imageFilePath)
Returns true if the file given by imageFilePath represents a ptex file, and false otherwise...
Represents a texture object in Glf.
Definition: texture.h:63
GLF_API GLuint GetGlTextureName() override
Returns the OpenGl texture name for the texture.