0.8.0 API documentation
texture2d.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "texture.hpp"
7 #include "image.hpp"
8 #include "index.hpp"
9 
10 namespace gli
11 {
13  class texture2d : public texture
14  {
15  public:
16  typedef extent2d extent_type;
17 
19  texture2d();
20 
22  explicit texture2d(
23  format_type Format,
24  extent_type const& Extent,
25  size_type Levels,
26  swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
27 
29  explicit texture2d(
30  format_type Format,
31  extent_type const& Extent,
32  swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
33 
35  explicit texture2d(
36  texture const& Texture);
37 
39  explicit texture2d(
40  texture const& Texture,
41  format_type Format,
42  size_type BaseLayer, size_type MaxLayer,
43  size_type BaseFace, size_type MaxFace,
44  size_type BaseLevel, size_type MaxLevel,
45  swizzles_type const & Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
46 
48  explicit texture2d(
49  texture2d const& Texture,
50  size_type BaseLevel, size_type MaxLevel);
51 
53  image operator[](size_type Level) const;
54 
56  extent_type extent(size_type Level = 0) const;
57 
59  template <typename genType>
60  genType load(extent_type const& TexelCoord, size_type Level) const;
61 
63  template <typename genType>
64  void store(extent_type const& TexelCoord, size_type Level, genType const& Texel);
65 
67  void clear();
68 
71  template <typename genType>
72  void clear(genType const& Texel);
73 
75  template <typename genType>
76  void clear(size_type Level, genType const& Texel);
77 
78  private:
79  struct cache
80  {
81  std::uint8_t* Data;
82  extent_type Extent;
83 # ifndef NDEBUG
84  size_type Size;
85 # endif
86  };
87 
88  void build_cache();
89  size_type index_cache(size_type Level) const;
90 
91  std::vector<cache> Caches;
92  };
93 }//namespace gli
94 
95 #include "./core/texture2d.inl"
Genetic texture class. It can support any target.
Definition: texture.hpp:12
image operator[](size_type Level) const
Create a view of the image identified by Level in the mipmap chain of the texture.
Namespace where all the classes and functions provided by GLI are exposed.
Definition: comparison.hpp:15
texture2d()
Create an empty texture 2D.
genType load(extent_type const &TexelCoord, size_type Level) const
Fetch a texel from a texture. The texture format must be uncompressed.
Include to compute offset in a texture storage memory.
format
Texture data format.
Definition: format.hpp:12
void clear()
Clear the entire texture storage with zeros.
2d texture
Definition: texture2d.hpp:13
Image, representation for a single texture level.
Definition: image.hpp:11
Include to use images, a representation of a single texture level.
extent_type extent(size_type Level=0) const
Return the dimensions of a texture instance: width and height.
Include to use generic textures which can represent any texture target but they don't have target spe...
void store(extent_type const &TexelCoord, size_type Level, genType const &Texel)
Write a texel to a texture. The texture format must be uncompressed.