0.8.2 API documentation
storage.hpp
1 #pragma once
2 
3 // STD
4 #include <vector>
5 #include <queue>
6 #include <string>
7 #include <cassert>
8 #include <cmath>
9 #include <cstring>
10 #include <memory>
11 
12 #include "../type.hpp"
13 #include "../format.hpp"
14 
15 // GLM
16 #include <glm/gtc/round.hpp>
17 #include <glm/gtx/component_wise.hpp>
18 #include <glm/gtx/integer.hpp>
19 #include <glm/gtx/bit.hpp>
20 #include <glm/gtx/raw_data.hpp>
21 #include <glm/gtx/wrap.hpp>
22 
23 static_assert(GLM_VERSION >= 97, "GLI requires at least GLM 0.9.7");
24 
25 namespace gli
26 {
27  class storage_linear
28  {
29  public:
30  typedef extent3d extent_type;
31  typedef size_t size_type;
32  typedef gli::format format_type;
33  typedef glm::byte data_type;
34 
35  public:
36  storage_linear();
37 
38  storage_linear(
39  format_type Format,
40  extent_type const & Extent,
41  size_type Layers,
42  size_type Faces,
43  size_type Levels);
44 
45  bool empty() const;
46  size_type size() const; // Express is bytes
47  size_type layers() const;
48  size_type levels() const;
49  size_type faces() const;
50 
51  size_type block_size() const;
52  extent_type block_extent() const;
53  extent_type block_count(size_type Level) const;
54  extent_type extent(size_type Level) const;
55 
56  data_type* data();
57  data_type const* const data() const;
58 
60  size_type base_offset(
61  size_type Layer,
62  size_type Face,
63  size_type Level) const;
64 
66  void copy(
67  storage_linear const& StorageSrc,
68  size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& BlockIndexSrc,
69  size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& BlockIndexDst,
70  extent_type const& BlockCount);
71 
72  size_type level_size(
73  size_type Level) const;
74  size_type face_size(
75  size_type BaseLevel, size_type MaxLevel) const;
76  size_type layer_size(
77  size_type BaseFace, size_type MaxFace,
78  size_type BaseLevel, size_type MaxLevel) const;
79 
80  private:
81  size_type const Layers;
82  size_type const Faces;
83  size_type const Levels;
84  size_type const BlockSize;
85  extent_type const BlockCount;
86  extent_type const BlockExtent;
87  extent_type const Extent;
88  std::vector<data_type> Data;
89  };
90 }//namespace gli
91 
92 #include "storage_linear.inl"
ivec3 block_extent(format Format)
Return the dimensions in texels of the block for a format.
format
Texture data format.
Definition: format.hpp:12
void copy(texture_src_type const &TextureSrc, size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, texture_dst_type &TextureDst, size_t LayerDst, size_t FaceDst, size_t LevelDst)
Copy a specific image of a texture.
Namespace where all the classes and functions provided by GLI are exposed.
Definition: clear.hpp:6
size_t block_size(format Format)
Return the size in bytes of a block for a format.
T levels(vecType< T, P > const &Extent)
Compute the number of mipmaps levels necessary to create a mipmap complete texture.