11 #include "guilib/TextureFormats.h" 21 struct COLOR {
unsigned char b,g,r,x;};
24 enum class TEXTURE_SCALING
38 CTexture(
unsigned int width = 0,
unsigned int height = 0, XB_FMT format = XB_FMT_A8R8G8B8);
41 static std::unique_ptr<CTexture> CreateTexture(
unsigned int width = 0,
42 unsigned int height = 0,
43 XB_FMT format = XB_FMT_A8R8G8B8);
54 static std::unique_ptr<CTexture> LoadFromFile(
const std::string& texturePath,
55 unsigned int idealWidth = 0,
56 unsigned int idealHeight = 0,
57 bool requirePixels =
false,
58 const std::string& strMimeType =
"");
70 static std::unique_ptr<CTexture> LoadFromFileInMemory(
unsigned char* buffer,
72 const std::string& mimeType,
73 unsigned int idealWidth = 0,
74 unsigned int idealHeight = 0);
76 bool LoadFromMemory(
unsigned int width,
81 const unsigned char* pixels);
82 bool LoadPaletted(
unsigned int width,
86 const unsigned char* pixels,
87 const COLOR* palette);
89 bool HasAlpha()
const;
90 void SetAlpha(
bool hasAlpha) { m_hasAlpha = hasAlpha; }
93 bool IsMipmapped()
const;
94 void SetScalingMethod(TEXTURE_SCALING scalingMethod) { m_scalingMethod = scalingMethod; }
95 TEXTURE_SCALING GetScalingMethod()
const {
return m_scalingMethod; }
96 void SetCacheMemory(
bool bCacheMemory) { m_bCacheMemory = bCacheMemory; }
97 bool GetCacheMemory()
const {
return m_bCacheMemory; }
99 virtual void CreateTextureObject() = 0;
100 virtual void DestroyTextureObject() = 0;
101 virtual void LoadToGPU() = 0;
102 virtual void BindToUnit(
unsigned int unit) = 0;
104 unsigned char* GetPixels()
const {
return m_pixels; }
105 unsigned int GetPitch()
const {
return GetPitch(m_textureWidth); }
106 unsigned int GetRows()
const {
return GetRows(m_textureHeight); }
107 unsigned int GetTextureWidth()
const {
return m_textureWidth; }
108 unsigned int GetTextureHeight()
const {
return m_textureHeight; }
109 unsigned int GetWidth()
const {
return m_imageWidth; }
110 unsigned int GetHeight()
const {
return m_imageHeight; }
116 int GetOrientation()
const {
return m_orientation; }
117 void SetOrientation(
int orientation) { m_orientation = orientation; }
119 void Update(
unsigned int width,
123 const unsigned char* pixels,
125 void Allocate(
unsigned int width,
unsigned int height, XB_FMT format);
128 static unsigned int PadPow2(
unsigned int x);
129 static bool SwapBlueRed(
unsigned char *pixels,
unsigned int height,
unsigned int pitch,
unsigned int elements = 4,
unsigned int offset=0);
136 bool LoadFromFileInMem(
unsigned char* buffer,
size_t size,
const std::string& mimeType,
137 unsigned int maxWidth,
unsigned int maxHeight);
138 bool LoadFromFileInternal(
const std::string& texturePath,
unsigned int maxWidth,
unsigned int maxHeight,
bool requirePixels,
const std::string& strMimeType =
"");
139 bool LoadIImage(
IImage* pImage,
unsigned char* buffer,
unsigned int bufSize,
unsigned int width,
unsigned int height);
141 unsigned int GetPitch(
unsigned int width)
const;
142 unsigned int GetRows(
unsigned int height)
const;
143 unsigned int GetBlockSize()
const;
145 unsigned int m_imageWidth;
146 unsigned int m_imageHeight;
147 unsigned int m_textureWidth;
148 unsigned int m_textureHeight;
152 unsigned char* m_pixels;
156 bool m_hasAlpha = true ;
157 bool m_mipmapping = false ;
158 TEXTURE_SCALING m_scalingMethod = TEXTURE_SCALING::LINEAR;
159 bool m_bCacheMemory =
false;
unsigned int m_originalHeight
original image height before scaling or cropping
Definition: Texture.h:150
unsigned int GetOriginalWidth() const
return the original width of the image, before scaling/cropping
Definition: Texture.h:112
Base texture class, subclasses of which depend on the render spec (DX, GL etc.)
Definition: Texture.h:34
unsigned int m_originalWidth
original image width before scaling or cropping
Definition: Texture.h:149
unsigned int GetOriginalHeight() const
return the original height of the image, before scaling/cropping
Definition: Texture.h:114