Aether
SDL2 based UI Framework for NX
Texture.hpp
1 #ifndef AETHER_TEXTURE_HPP
2 #define AETHER_TEXTURE_HPP
3 
4 #include "Aether/base/Element.hpp"
5 #include <atomic>
6 
7 namespace Aether {
11  enum class Render {
12  Sync,
13  Async,
14  Wait,
15  };
16 
24  class Texture : public Element {
25  private:
26  // Forward declare nested class
27  class RenderJob;
28 
33  enum class AsyncStatus {
34  Waiting,
35  Rendering,
36  NeedsConvert,
37  Done
38  };
39 
40  int asyncID;
41  std::function<void()> onRenderDoneFunc;
42  std::atomic<AsyncStatus> status;
44  Colour colour_;
45  Drawable * drawable;
46  Drawable * tmpDrawable;
51  void setupDrawable();
52 
53  protected:
57  virtual Drawable * renderDrawable() = 0;
58 
59  public:
66  Texture(const int x = 0, const int y = 0);
67 
74  void onRenderDone(const std::function<void()> func);
75 
81  Colour colour();
82 
88  void setColour(const Colour & col);
89 
96  int textureWidth();
97 
104  int textureHeight();
105 
117  void setMask(const int x, const int y, const unsigned int w, const unsigned int h);
118 
123  void destroy();
124 
130  bool ready();
131 
137  void renderSync();
138 
144  void renderAsync();
145 
152  void update(unsigned int dt);
153 
158  void render();
159 
163  ~Texture();
164  };
165 };
166 
167 #endif
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
Stores either a surface or texture which can be drawn on screen by providing a renderer to render()...
Definition: Drawable.hpp:22
A Texture is an element that stores a texture to render in the window. It can&#39;t be instantiated alone...
Definition: Texture.hpp:24
Element is the base class to be inherited to form all other types of elements.
Definition: Element.hpp:18
Base namespace for all Aether related classes and functions.
Extends a thread pool job to render the given texture element on a separate thread.
Definition: Texture.RenderJob.hpp:12
Render
Supported "on create" texture rendering options.
Definition: Texture.hpp:11