Image.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <ewol/debug.hpp>
10 #include <gale/resource/Program.hpp>
11 #include <ewol/resource/Image.hpp>
13 
14 namespace ewol {
15  namespace compositing {
16  class Image : public ewol::Compositing {
17  public:
18  static const int32_t sizeAuto;
19  private:
20  std::string m_filename;
21  ivec2 m_requestSize;
22  vec3 m_position;
23  vec3 m_clippingPosStart;
24  vec3 m_clippingPosStop;
25  bool m_clippingEnable;
26  private:
27  etk::Color<> m_color;
28  float m_angle;
29  private:
31  int32_t m_GLPosition;
32  int32_t m_GLMatrix;
33  int32_t m_GLColor;
34  int32_t m_GLtexture;
35  int32_t m_GLtexID;
36  private:
37  bool m_distanceFieldMode;
40  std::vector<vec3 > m_coord;
41  std::vector<vec2 > m_coordTex;
42  std::vector<etk::Color<float> > m_coordColor;
43  private:
47  void loadProgram();
48  public:
55  Image(const std::string& _imageName="",
56  bool _df=false,
57  int32_t _size=ewol::compositing::Image::sizeAuto);
61  virtual ~Image();
62  public:
67  void draw(bool _disableDepthTest=true);
71  void clear();
76  const vec3& getPos() {
77  return m_position;
78  };
83  void setPos(const vec3& _pos) {
84  m_position = _pos;
85  };
86  inline void setPos(const vec2& _pos) {
87  setPos(vec3(_pos.x(),_pos.y(),0));
88  };
93  void setRelPos(const vec3& _pos) {
94  m_position += _pos;
95  };
96  inline void setRelPos(const vec2& _pos) {
97  setRelPos(vec3(_pos.x(),_pos.y(),0));
98  };
103  void setColor(const etk::Color<>& _color) {
104  m_color = _color;
105  };
111  void setClippingWidth(const vec3& _pos, vec3 _width) {
112  setClipping(_pos, _pos+_width);
113  };
114  inline void setClippingWidth(const vec2& _pos, const vec2& _width) {
115  setClippingWidth(vec3(_pos.x(),_pos.y(),0), vec3(_width.x(),_width.y(),0));
116  };
122  void setClipping(const vec3& _pos, vec3 _posEnd);
123  inline void setClipping(const vec2& _pos, const vec2& _posEnd) {
124  setClipping(vec3(_pos.x(),_pos.y(),0), vec3(_posEnd.x(),_posEnd.y(),0));
125  };
130  void setClippingMode(bool _newMode) {
131  m_clippingEnable = _newMode;
132  };
137  void setAngle(float _angleRad);
142  void print(const ivec2& _size) {
143  print(vec2(_size.x(),_size.y()));
144  };
145  void print(const vec2& _size);
152  void printPart(const vec2& _size,
153  const vec2& _sourcePosStart,
154  const vec2& _sourcePosStop);
160  void setSource(const std::string& _newFile, int32_t _size=32) {
161  setSource(_newFile, vec2(_size,_size));
162  };
163  void setSource(const std::string& _newFile, const vec2& _size);
168  bool hasSources();
173  vec2 getRealSize();
174  public:
179  void setDistanceFieldMode(bool _mode);
184  bool getDistanceFieldMode() const {
185  return m_distanceFieldMode;
186  }
187  };
188  };
189 };
190 
const T & x() const
Image(const std::string &_imageName="", bool _df=false, int32_t _size=ewol::compositing::Image::sizeAuto)
generic constructor
void printPart(const vec2 &_size, const vec2 &_sourcePosStart, const vec2 &_sourcePosStop)
add a part of the image to display with the requested size
void draw(bool _disableDepthTest=true)
draw All the refistered text in the current element on openGL
bool getDistanceFieldMode() const
Get the render methode.
Definition: Image.hpp:184
void setClipping(const vec3 &_pos, vec3 _posEnd)
Request a clipping area for the text (next draw only)
void setClippingMode(bool _newMode)
enable/Disable the clipping (without lose the current clipping position)
Definition: Image.hpp:130
void setRelPos(const vec3 &_pos)
set relative position for the next text writen
Definition: Image.hpp:93
void setSource(const std::string &_newFile, int32_t _size=32)
change the image Source == > can not be done to display 2 images at the same time ...
Definition: Image.hpp:160
bool hasSources()
Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ...
void setColor(const etk::Color<> &_color)
set the Color of the current foreground font
Definition: Image.hpp:103
Definition: Area.hpp:16
const T & y() const
void clear()
clear alll tre registered element in the current element
Definition: Compositing.hpp:13
Definition: Image.hpp:16
const vec3 & getPos()
get the current display position (sometime needed in the gui control)
Definition: Image.hpp:76
void setAngle(float _angleRad)
set a unique rotation of this element (not set in the rotate Generic system)
void setDistanceFieldMode(bool _mode)
Set render mode of the image.
void setPos(const vec3 &_pos)
set position for the next text writen
Definition: Image.hpp:83
virtual ~Image()
generic destructor
vec2 getRealSize()
get the source image registered size in the file (<0 when multiple size image)
void print(const ivec2 &_size)
add a compleate of the image to display with the requested size
Definition: Image.hpp:142
void setClippingWidth(const vec3 &_pos, vec3 _width)
Request a clipping area for the text (next draw only)
Definition: Image.hpp:111