2011-06-14 14:31:25 +08:00
|
|
|
|
|
|
|
typedef enum {
|
2012-06-15 10:51:53 +08:00
|
|
|
// kCCTexture2DPixelFormat_Automatic = 0,
|
2012-02-02 14:26:38 +08:00
|
|
|
//! 32-bit texture: RGBA8888
|
|
|
|
kCCTexture2DPixelFormat_RGBA8888,
|
|
|
|
//! 24-bit texture: RGBA888
|
|
|
|
kCCTexture2DPixelFormat_RGB888,
|
|
|
|
//! 16-bit texture without Alpha channel
|
|
|
|
kCCTexture2DPixelFormat_RGB565,
|
|
|
|
//! 8-bit textures used as masks
|
|
|
|
kCCTexture2DPixelFormat_A8,
|
|
|
|
//! 8-bit intensity texture
|
|
|
|
kCCTexture2DPixelFormat_I8,
|
|
|
|
//! 16-bit textures used as masks
|
|
|
|
kCCTexture2DPixelFormat_AI88,
|
|
|
|
//! 16-bit textures: RGBA4444
|
|
|
|
kCCTexture2DPixelFormat_RGBA4444,
|
|
|
|
//! 16-bit textures: RGB5A1
|
|
|
|
kCCTexture2DPixelFormat_RGB5A1,
|
|
|
|
//! 4-bit PVRTC-compressed texture: PVRTC4
|
|
|
|
kCCTexture2DPixelFormat_PVRTC4,
|
|
|
|
//! 2-bit PVRTC-compressed texture: PVRTC2
|
|
|
|
kCCTexture2DPixelFormat_PVRTC2,
|
|
|
|
|
|
|
|
//! Default texture format: RGBA8888
|
|
|
|
kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888,
|
|
|
|
|
|
|
|
// backward compatibility stuff
|
2012-06-15 10:51:53 +08:00
|
|
|
// kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic,
|
2012-02-02 14:26:38 +08:00
|
|
|
kTexture2DPixelFormat_RGBA8888 = kCCTexture2DPixelFormat_RGBA8888,
|
|
|
|
kTexture2DPixelFormat_RGB888 = kCCTexture2DPixelFormat_RGB888,
|
|
|
|
kTexture2DPixelFormat_RGB565 = kCCTexture2DPixelFormat_RGB565,
|
|
|
|
kTexture2DPixelFormat_A8 = kCCTexture2DPixelFormat_A8,
|
|
|
|
kTexture2DPixelFormat_RGBA4444 = kCCTexture2DPixelFormat_RGBA4444,
|
|
|
|
kTexture2DPixelFormat_RGB5A1 = kCCTexture2DPixelFormat_RGB5A1,
|
|
|
|
kTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_Default
|
2011-06-14 14:31:25 +08:00
|
|
|
} CCTexture2DPixelFormat;
|
|
|
|
|
2012-09-20 23:37:23 +08:00
|
|
|
class ccTexParams {
|
|
|
|
ccTexParams(void);
|
|
|
|
GLuint minFilter;
|
|
|
|
GLuint magFilter;
|
|
|
|
GLuint wrapS;
|
|
|
|
GLuint wrapT;
|
|
|
|
};
|
|
|
|
|
2011-06-14 14:31:25 +08:00
|
|
|
class CCTexture2D : public CCObject
|
|
|
|
{
|
2012-08-10 18:14:04 +08:00
|
|
|
void releaseData(void* data);
|
|
|
|
void* keepData(void* data, unsigned int length);
|
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
CCTexture2DPixelFormat getPixelFormat();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
unsigned int getPixelsWide();
|
|
|
|
unsigned int getPixelsHigh();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
GLuint getName();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
CCSize getContentSizeInPixels();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
void setMaxS(GLfloat val);
|
|
|
|
GLfloat getMaxS();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
GLfloat getMaxT();
|
|
|
|
void setMaxT(GLfloat val);
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-06-15 17:26:11 +08:00
|
|
|
bool hasPremultipliedAlpha();
|
|
|
|
bool hasMipmaps();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
void drawAtPoint(CCPoint point);
|
|
|
|
void drawInRect(CCRect rect);
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
CCSize getContentSize(void);
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
void setTexParameters(ccTexParams* texParams);
|
|
|
|
void setAntiAliasTexParameters();
|
|
|
|
void setAliasTexParameters();
|
|
|
|
void generateMipmap();
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-08-10 18:14:04 +08:00
|
|
|
const char* stringForFormat();
|
|
|
|
unsigned int bitsPerPixelForFormat();
|
|
|
|
unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format);
|
2011-06-14 14:31:25 +08:00
|
|
|
|
2012-02-02 14:26:38 +08:00
|
|
|
static void setDefaultAlphaPixelFormat(CCTexture2DPixelFormat format);
|
|
|
|
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
|
2011-06-14 14:31:25 +08:00
|
|
|
};
|