CCTexturePVR

#ifndef __CCPVRTEXTURE_H__

#define __CCPVRTEXTURE_H__


#include "CCStdC.h"

#include "CCGL.h"

#include "cocoa/CCObject.h"

#include "cocoa/CCArray.h"


NS_CC_BEGIN


/**

 * @addtogroup textures

 * @{

 */


/**

 @brief Structure which can tell where mipmap begins and how long is it

*/

struct CCPVRMipmap {

    unsigned char *address;

    unsigned int len;

};


typedef struct _ccPVRTexturePixelFormatInfo {

GLenum internalFormat;

GLenum format;

GLenum type;

uint32_t bpp;

bool compressed;

bool alpha;

CCTexture2DPixelFormat ccPixelFormat;

} ccPVRTexturePixelFormatInfo;


/**

 @brief Determine how many mipmaps can we have. 

 Its same as define but it respects namespaces

*/

enum {

    CC_PVRMIPMAP_MAX = 16,

};



/** CCTexturePVR

     

 Object that loads PVR images.


 Supported PVR formats:

    - RGBA8888

    - BGRA8888

    - RGBA4444

    - RGBA5551

    - RGB565

    - A8

    - I8

    - AI88

    - PVRTC 4BPP

    - PVRTC 2BPP

     

 Limitations:

    Pre-generated mipmaps, such as PVR textures with mipmap levels embedded in file,

    are only supported if all individual sprites are of _square_ size. 

    To use mipmaps with non-square textures, instead call CCTexture2D#generateMipmap on the sheet texture itself

    (and to save space, save the PVR sprite sheet without mip maps included).

*/

class CCTexturePVR : public CCObject

{

public:

    CCTexturePVR();

    virtual ~CCTexturePVR();


    /** initializes a CCTexturePVR with a path */

    bool initWithContentsOfFile(const char* path);


    /** creates and initializes a CCTexturePVR with a path */

    static CCTexturePVR* create(const char* path);

    

    // properties 

    

    /** texture id name */

    inline unsigned int getName() { return m_uName; }

    /** texture width */

    inline unsigned int getWidth() { return m_uWidth; }

    /** texture height */

    inline unsigned int getHeight() { return m_uHeight; }

    /** whether or not the texture has alpha */

    inline bool hasAlpha() { return m_bHasAlpha; }

    /** whether or not the texture has premultiplied alpha */

    inline bool hasPremultipliedAlpha() { return m_bHasPremultipliedAlpha; }

    /** whether or not the texture should use hasPremultipliedAlpha instead of global default */

    inline bool isForcePremultipliedAlpha() { return m_bForcePremultipliedAlpha; }

    /** how many mipmaps the texture has. 1 means one level (level 0 */

    inline unsigned int getNumberOfMipmaps() { return m_uNumberOfMipmaps; }

    inline CCTexture2DPixelFormat getFormat() { return m_eFormat; }

    inline bool isRetainName() { return m_bRetainName; }

    inline void setRetainName(bool retainName) { m_bRetainName = retainName; }


private:

    bool unpackPVRv2Data(unsigned char* data, unsigned int len);

    bool unpackPVRv3Data(unsigned char* dataPointer, unsigned int dataLength);

    bool createGLTexture();

    

protected:

    struct CCPVRMipmap m_asMipmaps[CC_PVRMIPMAP_MAX];   // pointer to mipmap images    

    unsigned int m_uNumberOfMipmaps;                    // number of mipmap used

    

    unsigned int m_uWidth, m_uHeight;

    GLuint m_uName;

    bool m_bHasAlpha;

    bool m_bHasPremultipliedAlpha;

    bool m_bForcePremultipliedAlpha;

    

    // cocos2d integration

    bool m_bRetainName;

    CCTexture2DPixelFormat m_eFormat;

    

   const ccPVRTexturePixelFormatInfo *m_pPixelFormatInfo;

};


// end of textures group

/// @}


NS_CC_END



#endif //__CCPVRTEXTURE_H__

转载于:https://www.cnblogs.com/sssssnian/p/3748624.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值