GLI  0.5.1
storage.hpp
Go to the documentation of this file.
1 
29 #ifndef GLI_CORE_STORAGE_INCLUDED
30 #define GLI_CORE_STORAGE_INCLUDED
31 
32 // STD
33 #include <vector>
34 #include <queue>
35 #include <string>
36 #include <cassert>
37 #include <cmath>
38 #include <cstring>
39 
40 // GLM
41 #define GLM_FORCE_RADIANS
42 #include <glm/glm.hpp>
43 #include <glm/gtx/component_wise.hpp>
44 #include <glm/gtx/gradient_paint.hpp>
45 #include <glm/gtx/integer.hpp>
46 #include <glm/gtx/bit.hpp>
47 #include <glm/gtx/multiple.hpp>
48 #include <glm/gtx/number_precision.hpp>
49 #include <glm/gtx/raw_data.hpp>
50 #include <glm/gtx/scalar_relational.hpp>
51 
52 #include "shared_ptr.hpp"
53 #include "header.hpp"
54 #include "format.hpp"
55 
56 namespace gli{
57 namespace detail
58 {
59  typedef std::size_t size_type;
60  typedef glm::uint dimensions1_type;
61  typedef glm::uvec2 dimensions2_type;
62  typedef glm::uvec3 dimensions3_type;
63  typedef glm::uvec4 dimensions4_type;
64 }//namespace detail
65 
66  class storage
67  {
68  public:
69  typedef glm::uint dimensions1_type;
70  typedef glm::uvec2 dimensions2_type;
71  typedef glm::uvec3 dimensions3_type;
72  typedef glm::uvec4 dimensions4_type;
74  typedef float texcoord1_type;
75  typedef glm::vec2 texcoord2_type;
76  typedef glm::vec3 texcoord3_type;
77  typedef glm::vec4 texcoord4_type;
78  typedef std::size_t size_type;
80 
81  public:
82  storage();
83 
84  storage(
85  size_type const & Layers,
86  size_type const & Faces,
87  size_type const & Levels,
88  format_type const & Format,
89  dimensions_type const & Dimensions);
90 
91  storage(
92  size_type const & Layers,
93  size_type const & Faces,
94  size_type const & Levels,
95  dimensions_type const & Dimensions,
96  format_type const & Format,
97  size_type const & BlockSize,
98  dimensions_type const & BlockDimensions);
99 
100  bool empty() const;
101  size_type size() const; // Express is bytes
102  format_type format() const;
103  size_type layers() const;
104  size_type faces() const;
105  size_type levels() const;
106 
107  size_type blockSize() const; // Express is bytes
108  dimensions_type blockDimensions() const; // Express is bytes
109  dimensions_type dimensions(size_type const & Level) const;
110 
111  glm::byte * data();
112  glm::byte const * data() const;
113 
115  size_type const & Level) const;
117  size_type const & BaseLevel,
118  size_type const & MaxLevel) const;
120  size_type const & BaseFace,
121  size_type const & MaxFace,
122  size_type const & BaseLevel,
123  size_type const & MaxLevel) const;
124 
125  private:
126  struct impl
127  {
128  impl();
129 
130  explicit impl(
131  size_type const & Layers,
132  size_type const & Faces,
133  size_type const & Levels,
134  format_type const & Format,
135  dimensions_type const & Dimensions,
136  size_type const & BlockSize,
137  dimensions_type const & BlockDimensions);
138 
139  size_type const Layers;
140  size_type const Faces;
141  size_type const Levels;
142  format_type const Format;
143  dimensions_type const Dimensions;
144  size_type const BlockSize;
145  dimensions_type const BlockDimensions;
146  std::vector<glm::byte> Data;
147  };
148 
149  shared_ptr<impl> Impl;
150  };
151 
152 /*
153  storage extractLayers(
154  storage const & Storage,
155  storage::size_type const & Offset,
156  storage::size_type const & Size);
157 */
158 /*
159  storage extractFace(
160  storage const & Storage,
161  face const & Face);
162 */
163 /*
164  storage extractLevels(
165  storage const & Storage,
166  storage::size_type const & Offset,
167  storage::size_type const & Size);
168 */
169 /*
170  void copy_layers(
171  storage const & SourceStorage,
172  storage::size_type const & SourceLayerOffset,
173  storage::size_type const & SourceLayerSize,
174  storage & DestinationStorage,
175  storage::size_type const & DestinationLayerOffset);
176 
177  void copy_faces(
178  storage const & SourceStorage,
179  storage::size_type const & SourceLayerOffset,
180  storage::size_type const & SourceFaceOffset,
181  storage::size_type const & SourceLayerSize,
182  storage & DestinationStorage,
183  storage::size_type const & DestinationLayerOffset,
184  storage::size_type const & DestinationFaceOffset);
185 
186  void copy_levels(
187  storage const & SourceStorage,
188  storage::size_type const & SourceLayerOffset,
189  storage::size_type const & SourceFaceOffset,
190  storage::size_type const & SourceLevelOffset,
191  storage::size_type const & SourceLayerSize,
192  storage & DestinationStorage,
193  storage::size_type const & DestinationLayerOffset,
194  storage::size_type const & DestinationFaceOffset,
195  storage::size_type const & DestinationlevelOffset);
196 */
197 
198  std::size_t block_size(format const & Format);
199  glm::uvec3 block_dimensions(format const & Format);
200  std::size_t component_count(format const & Format);
201  bool is_compressed(format const & Format);
202 
203  std::size_t level_count(storage::dimensions1_type const & Dimensions);
204  std::size_t level_count(storage::dimensions2_type const & Dimensions);
205  std::size_t level_count(storage::dimensions3_type const & Dimensions);
206 
207 }//namespace gli
208 
209 #include "storage.inl"
210 
211 #endif//GLI_CORE_STORAGE_INCLUDED
glm::uvec4 dimensions4_type
Definition: storage.hpp:63
float texcoord1_type
Definition: storage.hpp:74
OpenGL Image (gli.g-truc.net)
size_type size() const
glm::uvec4 dimensions4_type
Definition: storage.hpp:72
size_type layers() const
glm::uint dimensions1_type
Definition: storage.hpp:69
glm::uvec2 dimensions2_type
Definition: storage.hpp:70
std::size_t component_count(format const &Format)
glm::byte * data()
size_type blockSize() const
glm::vec4 texcoord4_type
Definition: storage.hpp:77
glm::uvec3 dimensions3_type
Definition: storage.hpp:62
size_type faceSize(size_type const &BaseLevel, size_type const &MaxLevel) const
dimensions_type dimensions(size_type const &Level) const
bool is_compressed(format const &Format)
glm::uvec3 block_dimensions(format const &Format)
OpenGL Image (gli.g-truc.net)
std::size_t size_type
Definition: storage.hpp:78
glm::uint dimensions1_type
Definition: storage.hpp:60
std::size_t size_type
Definition: storage.hpp:59
format
Definition: format.hpp:34
size_type faces() const
bool empty() const
format_type format() const
gli::format format_type
Definition: storage.hpp:79
glm::uvec2 dimensions2_type
Definition: storage.hpp:61
dimensions_type blockDimensions() const
glm::vec2 texcoord2_type
Definition: storage.hpp:75
OpenGL Image (gli.g-truc.net)
std::size_t level_count(storage::dimensions1_type const &Dimensions)
glm::uvec3 dimensions3_type
Definition: storage.hpp:71
size_type layerSize(size_type const &BaseFace, size_type const &MaxFace, size_type const &BaseLevel, size_type const &MaxLevel) const
std::size_t block_size(format const &Format)
dimensions3_type dimensions_type
Definition: storage.hpp:73
size_type levels() const
size_type levelSize(size_type const &Level) const
glm::vec3 texcoord3_type
Definition: storage.hpp:76