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,
unsigned int format = XB_FMT_A8R8G8B8);
41 static std::unique_ptr<CTexture> CreateTexture(
unsigned int width = 0,
42 unsigned int height = 0,
43 unsigned int 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,
unsigned int height,
unsigned int pitch,
unsigned int format,
bool hasAlpha,
const unsigned char* pixels);
77 bool LoadPaletted(
unsigned int width,
unsigned int height,
unsigned int pitch,
unsigned int format,
const unsigned char *pixels,
const COLOR *palette);
79 bool HasAlpha()
const;
82 bool IsMipmapped()
const;
83 void SetScalingMethod(TEXTURE_SCALING scalingMethod) { m_scalingMethod = scalingMethod; }
84 TEXTURE_SCALING GetScalingMethod()
const {
return m_scalingMethod; }
85 void SetCacheMemory(
bool bCacheMemory) { m_bCacheMemory = bCacheMemory; }
86 bool GetCacheMemory()
const {
return m_bCacheMemory; }
88 virtual void CreateTextureObject() = 0;
89 virtual void DestroyTextureObject() = 0;
90 virtual void LoadToGPU() = 0;
91 virtual void BindToUnit(
unsigned int unit) = 0;
93 unsigned char* GetPixels()
const {
return m_pixels; }
94 unsigned int GetPitch()
const {
return GetPitch(m_textureWidth); }
95 unsigned int GetRows()
const {
return GetRows(m_textureHeight); }
96 unsigned int GetTextureWidth()
const {
return m_textureWidth; }
97 unsigned int GetTextureHeight()
const {
return m_textureHeight; }
98 unsigned int GetWidth()
const {
return m_imageWidth; }
99 unsigned int GetHeight()
const {
return m_imageHeight; }
105 int GetOrientation()
const {
return m_orientation; }
106 void SetOrientation(
int orientation) { m_orientation = orientation; }
108 void Update(
unsigned int width,
unsigned int height,
unsigned int pitch,
unsigned int format,
const unsigned char *pixels,
bool loadToGPU);
109 void Allocate(
unsigned int width,
unsigned int height,
unsigned int format);
112 static unsigned int PadPow2(
unsigned int x);
113 static bool SwapBlueRed(
unsigned char *pixels,
unsigned int height,
unsigned int pitch,
unsigned int elements = 4,
unsigned int offset=0);
120 bool LoadFromFileInMem(
unsigned char* buffer,
size_t size,
const std::string& mimeType,
121 unsigned int maxWidth,
unsigned int maxHeight);
122 bool LoadFromFileInternal(
const std::string& texturePath,
unsigned int maxWidth,
unsigned int maxHeight,
bool requirePixels,
const std::string& strMimeType =
"");
123 bool LoadIImage(
IImage* pImage,
unsigned char* buffer,
unsigned int bufSize,
unsigned int width,
unsigned int height);
125 unsigned int GetPitch(
unsigned int width)
const;
126 unsigned int GetRows(
unsigned int height)
const;
127 unsigned int GetBlockSize()
const;
129 unsigned int m_imageWidth;
130 unsigned int m_imageHeight;
131 unsigned int m_textureWidth;
132 unsigned int m_textureHeight;
136 unsigned char* m_pixels;
138 unsigned int m_format;
140 bool m_hasAlpha = true ;
141 bool m_mipmapping = false ;
142 TEXTURE_SCALING m_scalingMethod = TEXTURE_SCALING::LINEAR;
143 bool m_bCacheMemory =
false;
unsigned int m_originalHeight
original image height before scaling or cropping
Definition: Texture.h:134
unsigned int GetOriginalWidth() const
return the original width of the image, before scaling/cropping
Definition: Texture.h:101
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:133
unsigned int GetOriginalHeight() const
return the original height of the image, before scaling/cropping
Definition: Texture.h:103