All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
arrayTexture.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_ARRAYTEXTURE_H
25 #define GLF_ARRAYTEXTURE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 #include "pxr/imaging/glf/image.h"
32 #include "pxr/imaging/glf/uvTexture.h"
33 
34 #include "pxr/base/tf/declarePtrs.h"
35 #include "pxr/base/tf/token.h"
36 
37 #include <string>
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
41 
43 
51 
52 class GlfArrayTexture : public GlfUVTexture {
53 public:
54 
55  typedef GlfUVTexture Parent;
56  typedef GlfArrayTexture This;
57 
62  GLF_API
63  static GlfArrayTextureRefPtr New(
64  TfTokenVector const &imageFilePaths,
65  unsigned int arraySize ,
66  unsigned int cropTop = 0,
67  unsigned int cropBottom = 0,
68  unsigned int cropLeft = 0,
69  unsigned int cropRight = 0,
70  GlfImage::ImageOriginLocation originLocation =
71  GlfImage::OriginUpperLeft);
72 
73  GLF_API
74  static GlfArrayTextureRefPtr New(
75  std::vector<std::string> const &imageFilePaths,
76  unsigned int arraySize ,
77  unsigned int cropTop = 0,
78  unsigned int cropBottom = 0,
79  unsigned int cropLeft = 0,
80  unsigned int cropRight = 0,
81  GlfImage::ImageOriginLocation originLocation =
82  GlfImage::OriginUpperLeft);
83 
84  GLF_API
85  static bool IsSupportedImageFile(TfToken const &imageFilePath);
86 
87  // GlfBaseTexture overrides
88  GLF_API
89  virtual BindingVector GetBindings(TfToken const & identifier,
90  GLuint samplerName);
91 
92 protected:
93  GLF_API
95  TfTokenVector const &imageFilePaths,
96  unsigned int arraySize,
97  unsigned int cropTop,
98  unsigned int cropBottom,
99  unsigned int cropLeft,
100  unsigned int cropRight,
101  GlfImage::ImageOriginLocation originLocation =
102  GlfImage::OriginUpperLeft);
103 
104  GLF_API
105  virtual void _ReadTexture();
106  GLF_API
107  const TfToken& _GetImageFilePath(size_t index) const;
108  using GlfUVTexture::_GetImageFilePath;
109 
110  GLF_API
111  void _CreateTexture(GlfBaseTextureDataConstRefPtrVector texDataVec,
112  bool const generateMipmap);
113 
114 private:
115 
116  TfTokenVector _imageFilePaths;
117  const unsigned int _arraySize;
118 };
119 
120 
121 PXR_NAMESPACE_CLOSE_SCOPE
122 
123 #endif // GLF_ARRAYTEXTURE_H
Represents an array of texture objects in Glf.
Definition: arrayTexture.h:52
Represents a texture object in Glf.
Definition: uvTexture.h:50
#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
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:60
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
static GLF_API GlfArrayTextureRefPtr New(TfTokenVector const &imageFilePaths, unsigned int arraySize, unsigned int cropTop=0, unsigned int cropBottom=0, unsigned int cropLeft=0, unsigned int cropRight=0, GlfImage::ImageOriginLocation originLocation=GlfImage::OriginUpperLeft)
Creates a new texture instance for the image file at imageFilePath.
virtual GLF_API BindingVector GetBindings(TfToken const &identifier, GLuint samplerName)
Returns the bindings to use this texture for the shader resource named identifier.