All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
udimTexture.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_UDIMTEXTURE_H
25 #define GLF_UDIMTEXTURE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 
32 #include "pxr/imaging/glf/texture.h"
33 
34 #include <string>
35 #include <vector>
36 #include <tuple>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
47 GLF_API bool GlfIsSupportedUdimTexture(std::string const& imageFilePath);
48 
49 class GlfUdimTexture;
50 TF_DECLARE_WEAK_AND_REF_PTRS(GlfUdimTexture);
51 
52 class GlfUdimTexture : public GlfTexture {
53 public:
54  GLF_API
55  ~GlfUdimTexture() override;
56 
57  GLF_API
58  static GlfUdimTextureRefPtr New(
59  TfToken const& imageFilePath,
60  GlfImage::ImageOriginLocation originLocation,
61  std::vector<std::tuple<int, TfToken>>&& tiles);
62 
63  GLF_API
64  GlfTexture::BindingVector GetBindings(
65  TfToken const& identifier,
66  GLuint samplerId) override;
67 
68  GLF_API
69  VtDictionary GetTextureInfo(bool forceLoad) override;
70 
71  GLuint GetGlTextureName() override;
72 
73  GLuint GetGlLayoutName() {
74  _ReadImage();
75  return _layout;
76  }
77 
78 protected:
79  GLF_API
80  GlfUdimTexture(
81  TfToken const& imageFilePath,
82  GlfImage::ImageOriginLocation originLocation,
83  std::vector<std::tuple<int, TfToken>>&& tiles);
84 
85  GLF_API
86  void _FreeTextureObject();
87 
88  GLF_API
89  void _ReadImage();
90 
91  GLF_API
92  void _OnMemoryRequestedDirty() override;
93 private:
94  std::vector<std::tuple<int, TfToken>> _tiles;
95  unsigned int _width = 0;
96  unsigned int _height = 0;
97  unsigned int _depth = 0;
98  unsigned int _format = 0;
99  GLuint _imageArray = 0;
100  GLuint _layout = 0;
101  bool _loaded = false;
102 };
103 
104 PXR_NAMESPACE_CLOSE_SCOPE
105 
106 #endif // GLF_UDIMTEXTURE_H
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
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual GLuint GetGlTextureName()=0
Returns the OpenGl texture name for the texture.
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:60
virtual BindingVector GetBindings(TfToken const &identifier, GLuint samplerId=0)=0
Returns the bindings to use this texture for the shader resource named identifier.
GLF_API bool GlfIsSupportedUdimTexture(std::string const &imageFilePath)
Returns true if the file given by imageFilePath represents a udim file, and false otherwise...
Represents a texture object in Glf.
Definition: texture.h:63