0.7.0
texture.hpp
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include "image.hpp"
32 #include "target.hpp"
33 
34 namespace gli
35 {
37  class texture
38  {
39  public:
40  typedef size_t size_type;
41  typedef gli::format format_type;
42  typedef gli::target target_type;
43  typedef storage::dim_type dim_type;
44  typedef storage::data_type data_type;
45 
47  texture();
48 
50  texture(
51  target_type Target,
52  format_type Format,
53  dim_type const & Dimensions,
54  size_type Layers,
55  size_type Faces,
56  size_type Levels);
57 
63  texture(
64  texture const & Texture,
65  target_type Target,
66  format_type Format,
67  size_type BaseLayer, size_type MaxLayer,
68  size_type BaseFace, size_type MaxFace,
69  size_type BaseLevel, size_type MaxLevel);
70 
74  texture(
75  texture const & Texture,
76  target_type Target,
77  format_type Format);
78 
79  virtual ~texture(){}
80 
82  bool empty() const;
83 
85  target_type target() const{return this->Target;}
86 
88  format_type format() const;
89 
91  size_type base_layer() const;
92 
94  size_type max_layer() const;
95 
97  size_type layers() const;
98 
100  size_type base_face() const;
101 
103  size_type max_face() const;
104 
106  size_type faces() const;
107 
109  size_type base_level() const;
110 
112  size_type max_level() const;
113 
115  size_type levels() const;
116 
118  dim_type dimensions(size_type Level = 0) const;
119 
121  size_type size() const;
122 
125  template <typename genType>
126  size_type size() const;
127 
129  size_type size(size_type Level) const;
130 
133  template <typename genType>
134  size_type size(size_type Level) const;
135 
137  void * data();
138 
140  template <typename genType>
141  genType * data();
142 
144  void const * data() const;
145 
147  template <typename genType>
148  genType const * data() const;
149 
151  void * data(size_type Layer, size_type Face, size_type Level);
152 
154  void const * data(size_type Layer, size_type Face, size_type Level) const;
155 
157  template <typename genType>
158  genType * data(size_type Layer, size_type Face, size_type Level);
159 
161  template <typename genType>
162  genType const * data(size_type Layer, size_type Face, size_type Level) const;
163 
165  void clear();
166 
169  template <typename genType>
170  void clear(genType const & Texel);
171 
172  protected:
174  size_type offset(size_type Layer, size_type Face, size_type Level) const;
175 
176  struct cache
177  {
178  data_type * Data;
179  size_type Size;
180  };
181 
182  std::shared_ptr<storage> Storage;
183  target_type const Target;
184  format_type const Format;
185  size_type const BaseLayer;
186  size_type const MaxLayer;
187  size_type const BaseFace;
188  size_type const MaxFace;
189  size_type const BaseLevel;
190  size_type const MaxLevel;
191  cache Cache;
192 
193  private:
194  void build_cache();
195  };
196 
197 }//namespace gli
198 
199 #include "./core/texture.inl"
200 
size_type max_face() const
Return the max face of the texture instance, effectively a memory offset to the beginning of the last...
texture()
Create an empty texture instance.
OpenGL Image (gli.g-truc.net)
void * data()
Return a pointer to the beginning of the texture instance data.
size_type levels() const
Return max_level() - base_level() + 1.
size_type size() const
Return the memory size of a texture instance storage in bytes.
size_type base_layer() const
Return the base layer of the texture instance, effectively a memory offset in the actual texture stor...
size_type faces() const
Return max_face() - base_face() + 1.
void clear()
Clear the entire texture storage with zeros.
dim_type dimensions(size_type Level=0) const
Return the dimensions of a texture instance: width, height and depth.
size_type offset(size_type Layer, size_type Face, size_type Level) const
Compute the relative memory offset to access the data for a specific layer, face and level...
size_type base_face() const
Return the base face of the texture instance, effectively a memory offset in the actual texture stora...
size_type base_level() const
Return the base level of the texture instance, effectively a memory offset in the actual texture stor...
format_type format() const
Return the texture instance format.
target_type target() const
Return the target of a texture instance.
Definition: texture.hpp:85
size_type max_level() const
Return the max level of the texture instance, effectively a memory offset to the beginning of the las...
bool empty() const
Return whether the texture instance is empty, no storage or description have been assigned to the ins...
Genetic texture class. It can support any target.
Definition: texture.hpp:37
size_type layers() const
Return max_layer() - base_layer() + 1.
OpenGL Image (gli.g-truc.net)
size_type max_layer() const
Return the max layer of the texture instance, effectively a memory offset to the beginning of the las...