You.i Engine
YiAssetTextureBase.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_ASSET_TEXTURE_BASE_H_
3 #define _YI_ASSET_TEXTURE_BASE_H_
4 
10 #include "asset/YiAssetHardware.h"
11 #include "framework/YiPredef.h"
12 #include "graphics/YiBitmap.h"
14 #include "utility/YiRtti.h"
15 
25 {
26 public:
30  enum class Filtering
31  {
32  Linear,
33  Nearest
34  };
35 
41  enum class WrapMode
42  {
43  ClampToEdge,
44  Mirror,
45  Repeat
46  };
47 
51  enum class Usage
52  {
53  Static,
54  Dynamic,
55  RenderTarget
56  };
57 
62  {
63  TextureConfig();
64  WrapMode wrapS, wrapT;
65  Filtering minFilter, magFilter;
66  bool useMipmaps;
67  };
68 
70 
71  virtual ~CYIAssetTextureBase() override;
72 
84  void AddDirtyRegion(const YI_RECT_REL &dirtyRectangle);
85 
97  void GrowDirtyRegion(const YI_RECT_REL &dirtyRectangle);
98 
102  void ClearDirtyRegions();
103 
107  const std::vector<YI_RECT_REL> &GetDirtyRegions() const;
108 
112  const TextureConfig &GetConfiguration() const;
113 
117  virtual int32_t GetWidth() const;
118 
122  virtual int32_t GetHeight() const;
123 
128 
132  void SetConfiguration(const TextureConfig &config);
133 
141 
161  void SetMipmappingEnabled(bool enable);
162 
166  bool IsMipmappingEnabled() const;
167 
176 
180  virtual bool HasExtendedDimensions() const;
181 
185  Usage GetUsage() const;
186 
187  virtual void ApplyRetainmentPolicy() override;
188 
189 protected:
194  virtual std::shared_ptr<IYIGPUObject> CreateGPUObject() const override = 0;
195 
196  virtual void OnUnload() override = 0;
197 
201  virtual void DirtyEntireTexture();
202 
206  void SetWidth(int32_t width);
207 
211  void SetHeight(int32_t height);
212 
217 
218 private:
219  int32_t m_width;
220  int32_t m_height;
221  IYIMaterialFactory::ColorSpace m_colorSpace;
222 
223  TextureConfig m_textureConfiguration;
224  std::vector<YI_RECT_REL> m_dirtyRegions;
225  Usage m_usage;
226 
228 };
229 
232 #endif // _YI_ASSET_TEXTURE_BASE_H_
Usage GetUsage() const
Definition: YiAssetTextureBase.h:61
void SetMinificationFilter(Filtering minFilter=Filtering::Linear, Filtering magFilter=Filtering::Linear)
Definition: YiPredef.h:291
void SetWidth(int32_t width)
ColorSpace
Definition: YiMaterialFactory.h:37
virtual void OnUnload() override=0
Filtering minFilter
Definition: YiAssetTextureBase.h:65
const TextureConfig & GetConfiguration() const
Filtering
Definition: YiAssetTextureBase.h:30
bool IsMipmappingEnabled() const
void GrowDirtyRegion(const YI_RECT_REL &dirtyRectangle)
IYIMaterialFactory::ColorSpace GetColorSpace() const
CYIAssetTextureBase(Usage usage=Usage::Static)
void SetTextureWrap(WrapMode wrapS=WrapMode::ClampToEdge, WrapMode wrapT=WrapMode::ClampToEdge)
void SetHeight(int32_t height)
virtual bool HasExtendedDimensions() const
Hardware-mirrored asset. These assets contain IYIGPUObject counterparts.
Definition: YiAssetHardware.h:20
void SetColorSpace(IYIMaterialFactory::ColorSpace colorSpace)
void SetConfiguration(const TextureConfig &config)
virtual std::shared_ptr< IYIGPUObject > CreateGPUObject() const override=0
This asset represents the base class for POT (Power Of Two) and NPOT (Non-Power Of Two) textures...
Definition: YiAssetTextureBase.h:24
Usage
Definition: YiAssetTextureBase.h:51
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
const std::vector< YI_RECT_REL > & GetDirtyRegions() const
void AddDirtyRegion(const YI_RECT_REL &dirtyRectangle)
This file contains the classes and macros used to implement RTTI in You.i Engine. ...
virtual void ApplyRetainmentPolicy() override
virtual ~CYIAssetTextureBase() override
void SetMipmappingEnabled(bool enable)
virtual int32_t GetWidth() const
WrapMode wrapT
Definition: YiAssetTextureBase.h:64
WrapMode
Definition: YiAssetTextureBase.h:41
virtual int32_t GetHeight() const
virtual void DirtyEntireTexture()
bool useMipmaps
Definition: YiAssetTextureBase.h:66