Texture.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "GlSystem.hpp"
4 #include "../OpenGL/GlTexture.hpp"
5 
8 
9 #include <optional>
10 
11 namespace iv
12 {
13 
14 //---------------------------------------------------------------------------------------
17 class Texture
18 {
19 public:
20  enum class Filtering
21  {
22  Nearest,
23  SmoothMsdf,
24  Smooth2D,
25  Smooth3D
26  };
27 
28  struct Metadata
29  {
31  float density;
36 
37  bool hitmap;
39 
40  Metadata();
41  };
42 
43 public:
45 
46  Texture( Instance * inst );
47  Instance * instance() const;
48 
49  Metadata const & metadata() const;
50  GlTexture const * gl_texture() const;
51  bool hittest( int x, int y ) const;
52 
53 protected:
56  std::vector< bool > _hitmap;
57 
58 private:
59  Instance * inst;
60 };
61 
62 //---------------------------------------------------------------------------------------
65 class Texture_Resource : public SingularResource< Texture >
66 {
67 public:
70  SingularResource< Texture >( inst, path ),
71  cm( inst, this, "Texture_Resource" )
72  {
73  this->cm.inherits( this->SingularResource< Texture >::cm );
74  }
75 };
76 
77 //--------------------------------- StingIO ---------------------------------------------
78 template<>
79 struct StringIO< Texture::Filtering > : public StringIO_Table< Texture::Filtering >
80 {
81  static const ValuesType Values;
82 };
83 
84 }