HDK
 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 PXR_IMAGING_GLF_UDIM_TEXTURE_H
25 #define PXR_IMAGING_GLF_UDIM_TEXTURE_H
26 
27 /// \file glf/udimTexture.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 
33 
34 #include <string>
35 #include <vector>
36 #include <tuple>
37 
39 
40 /// Returns true if the file given by \p imageFilePath represents a udim file,
41 /// and false otherwise.
42 ///
43 /// This function simply checks the existence of the <udim> tag in the
44 /// file name and does not otherwise guarantee that
45 /// the file is in any way valid for reading.
46 ///
47 GLF_API bool GlfIsSupportedUdimTexture(std::string const& imageFilePath);
48 
49 class 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
65  TfToken const& identifier,
66  GLuint samplerId) override;
67 
68  GLF_API
69  VtDictionary GetTextureInfo(bool forceLoad) override;
70 
71  GLuint GetGlTextureName() override;
72 
74  _ReadImage();
75  return _layout;
76  }
77 
78 protected:
79  GLF_API
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 
105 
106 #endif // PXR_IMAGING_GLF_UDIM_TEXTURE_H
GLF_API void _ReadImage()
#define GLF_API
Definition: api.h:40
GLF_API GlfTexture::BindingVector GetBindings(TfToken const &identifier, GLuint samplerId) override
ImageOriginLocation
Definition: image.h:58
unsigned int GLuint
Definition: cl.hpp:167
GLF_API GlfUdimTexture(TfToken const &imageFilePath, GlfImage::ImageOriginLocation originLocation, std::vector< std::tuple< int, TfToken >> &&tiles)
GLF_API VtDictionary GetTextureInfo(bool forceLoad) override
GLF_API void _OnMemoryRequestedDirty() override
Definition: token.h:87
TF_DECLARE_WEAK_AND_REF_PTRS(GlfUdimTexture)
GLuint GetGlLayoutName()
Definition: udimTexture.h:73
GLF_API ~GlfUdimTexture() override
GLF_API void _FreeTextureObject()
GLsizei const GLchar *const * string
Definition: glew.h:1844
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
PXR_NAMESPACE_OPEN_SCOPE GLF_API bool GlfIsSupportedUdimTexture(std::string const &imageFilePath)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static GLF_API GlfUdimTextureRefPtr New(TfToken const &imageFilePath, GlfImage::ImageOriginLocation originLocation, std::vector< std::tuple< int, TfToken >> &&tiles)
std::vector< Binding > BindingVector
Definition: texture.h:88
GLuint GetGlTextureName() override
Returns the OpenGl texture name for the texture.