You.i Engine
YiMaterial.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_MATERIAL_H_
3 #define _YI_MATERIAL_H_
4 
7 #include "framework/YiPredef.h"
11 #include "utility/YiColor.h"
12 
13 #include <glm/fwd.hpp>
14 
27 {
28 public:
38  enum class WrapMode : uint8_t
39  {
41  ClampToEdge,
42  Mirror,
43  Repeat
44  };
45 
49  struct WrapModes
50  {
53  };
54 
58  CYIMaterial();
59 
63  ~CYIMaterial();
64 
69  std::shared_ptr<CYIAssetTextureBase> GetTexture(uint32_t slot) const;
70 
84  void SetTexture(uint32_t slot, const std::shared_ptr<CYIAssetTextureBase> &pTexture, float *pTextureMatrix = nullptr);
85  void SetTexture(uint32_t slot, const std::shared_ptr<CYIAssetTextureBase> &pTexture, const glm::mat3 textureMatrix);
86 
90  const glm::mat3 &GetTextureMatrix(uint32_t slot) const;
91 
96  const std::shared_ptr<CYIAssetShaderProgram> &GetShaderProgram() const;
97 
102  const std::shared_ptr<IYIUniformBufferObject> &GetShaderUniforms() const;
103 
107  void SetShaderProgram(const std::shared_ptr<CYIAssetShaderProgram> &pShaderProgram);
108 
112  const std::map<uint32_t, std::shared_ptr<CYIAssetTextureBase>> &GetTextureBindings() const;
113 
118  void ClearTextureSlot(uint32_t slot);
119 
124 
129 
133  void SetColor(const CYIColor &color);
134 
138  const CYIColor &GetColor() const;
139 
143  void SetCullFace(CYIRenderSystem::CullFace cullingMode);
144 
149 
156 
161  WrapModes GetWrapModes() const;
162 
167  CYIAssetTextureBase::TextureConfig GetTextureWrapModes(const std::shared_ptr<CYIAssetTextureBase> &pAssetTexture) const;
168 
172  bool IsLoaded() const;
173 
174 private:
175  uint32_t GetMaxTexUnits() const;
176 
177  std::map<uint32_t, std::shared_ptr<CYIAssetTextureBase>> m_textureBindings;
178  std::map<uint32_t, glm::mat3> m_textureMatrix;
179  std::shared_ptr<IYIUniformBufferObject> m_pShaderUniforms;
180  std::shared_ptr<CYIAssetShaderProgram> m_pShaderProgram;
181  uint32_t m_maxTexUnits;
182  CYIRenderSystem::BlendMode m_BlendMode;
183  CYIRenderSystem::CullFace m_cullFace;
184  CYIColor m_Color;
185  WrapModes m_wrapModes;
186  mutable bool m_isLoaded;
187 };
188 
191 #endif /* _YI_MATERIAL_H_ */
std::shared_ptr< CYIAssetTextureBase > GetTexture(uint32_t slot) const
void SetWrapModes(WrapMode horizontal=WrapMode::DefaultFromTexture, WrapMode vertical=WrapMode::DefaultFromTexture)
Definition: YiAssetTextureBase.h:65
BlendMode
Definition: YiRenderSystem.h:34
const std::shared_ptr< IYIUniformBufferObject > & GetShaderUniforms() const
void ClearTextureSlot(uint32_t slot)
WrapMode
Definition: YiMaterial.h:38
CYIMaterial is a place holder for all the drawing parameters required by the renderer to draw a mesh/...
Definition: YiMaterial.h:26
Mirror texture coordinates. This wrap mode will draw the same image but mirrored horizontally or vert...
CYIAssetTextureBase::TextureConfig GetTextureWrapModes(const std::shared_ptr< CYIAssetTextureBase > &pAssetTexture) const
const CYIColor & GetColor() const
WrapModes GetWrapModes() const
WrapMode horizontal
The wrap mode in the horizontal axis (also known as S axis).
Definition: YiMaterial.h:51
Repeats the texture – often used for tiling a background. This wrap mode will repeat the image in th...
const std::shared_ptr< CYIAssetShaderProgram > & GetShaderProgram() const
WrapMode vertical
The wrap mode in the vertical axis (also known as T axis).
Definition: YiMaterial.h:52
void SetBlendMode(CYIRenderSystem::BlendMode mode)
Indicates that the wrap mode from the texture should be used. This is the default.
void SetColor(const CYIColor &color)
CullFace
Definition: YiRenderSystem.h:111
bool IsLoaded() const
Clamp texture to edge of image. This wrap mode will repeat the last pixel on the edge in the directio...
void SetTexture(uint32_t slot, const std::shared_ptr< CYIAssetTextureBase > &pTexture, float *pTextureMatrix=nullptr)
const std::map< uint32_t, std::shared_ptr< CYIAssetTextureBase > > & GetTextureBindings() const
void SetCullFace(CYIRenderSystem::CullFace cullingMode)
const glm::mat3 & GetTextureMatrix(uint32_t slot) const
A class used to represent a color value.
Definition: YiColor.h:31
CYIRenderSystem::CullFace GetCullFace() const
void SetShaderProgram(const std::shared_ptr< CYIAssetShaderProgram > &pShaderProgram)
CYIRenderSystem::BlendMode GetBlendMode() const
Definition: YiMaterial.h:49