merge commit 928a28e37d3469fcd41aff14cb136b1415f2fc86

This commit is contained in:
minggo 2012-04-08 14:16:29 +08:00
parent 40ec8a3b3d
commit 355e27dada
32 changed files with 2730 additions and 2478 deletions

View File

@ -504,9 +504,10 @@ void CCRepeatForever::step(ccTime dt)
m_pInnerAction->step(dt);
if (m_pInnerAction->isDone())
{
ccTime diff = dt + m_pInnerAction->getDuration() - m_pInnerAction->getElapsed();
ccTime diff = m_pInnerAction->getElapsed() - m_pInnerAction->getDuration();
m_pInnerAction->startWithTarget(m_pTarget);
// to prevent jerk. issue #390
// to prevent jerk. issue #390, 1247
m_pInnerAction->step(0.0f);
m_pInnerAction->step(diff);
}
}

View File

@ -126,11 +126,10 @@ public:
Note that RGBA type textures will have their alpha premultiplied - use the blending mode (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).
*/
/** Initializes a texture from a UIImage object */
#if 0// TODO: (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
bool initWithImage(CCImage * uiImage, ccResolutionType resolution);
#else
bool initWithImage(CCImage * uiImage);
#endif
bool initWithImage(CCImage *uiImage, ccResolutionType resolution);
/**
Extensions to make it easy to create a CCTexture2D object from a string of text.
@ -259,7 +258,7 @@ private:
@since v1.1
*/
CC_SYNTHESIZE(ccResolutionType, m_resolutionType, ResolutionType);
CC_SYNTHESIZE(ccResolutionType, m_eResolutionType, ResolutionType);
#endif
};

View File

@ -211,36 +211,6 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
#define CC_TEXTURE_NPOT_SUPPORT 0
#endif
/** @def CC_RETINA_DISPLAY_SUPPORT
If enabled, cocos2d supports retina display.
For performance reasons, it's recommended disable it in games without retina display support, like iPad only games.
To enable set it to 1. Use 0 to disable it. Enabled by default.
This value governs only the PNG, GIF, BMP, images.
This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
@deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
@since v0.99.5
*/
#ifndef CC_RETINA_DISPLAY_SUPPORT
#define CC_RETINA_DISPLAY_SUPPORT 1
#endif
/** @def CC_RETINA_DISPLAY_FILENAME_SUFFIX
It's the suffix that will be appended to the files in order to load "retina display" images.
On an iPhone4 with Retina Display support enabled, the file @"sprite-hd.png" will be loaded instead of @"sprite.png".
If the file doesn't exist it will use the non-retina display image.
Platforms: Only used on Retina Display devices like iPhone 4.
@since v0.99.5
*/
#ifndef CC_RETINA_DISPLAY_FILENAME_SUFFIX
#define CC_RETINA_DISPLAY_FILENAME_SUFFIX "-hd"
#endif
/** @def CC_USE_LA88_LABELS
If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects.
@ -312,12 +282,6 @@ To enable set it to a value different than 0. Disabled by default.
#define CC_ENABLE_PROFILERS 0
#endif
#if CC_RETINA_DISPLAY_SUPPORT
#define CC_IS_RETINA_DISPLAY_SUPPORTED 1
#else
#define CC_IS_RETINA_DISPLAY_SUPPORTED 0
#endif
/** Enable Lua engine debug log */
#ifndef CC_LUA_ENGINE_DEBUG
#define CC_LUA_ENGINE_DEBUG 0

View File

@ -99,12 +99,6 @@ typedef struct _ccColor4F {
GLfloat a;
} ccColor4F;
static inline ccColor4F
ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)
{
ccColor4F c = {r, g, b, a};
return c;
}
/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
@since v0.99.1
@ -115,6 +109,13 @@ static inline ccColor4F ccc4FFromccc3B(ccColor3B c)
return c4;
}
//! helper that creates a ccColor4f type
static inline ccColor4F
ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)
{
return (ccColor4F){r, g, b, a};
}
/** Returns a ccColor4F from a ccColor4B.
@since v0.99.1
*/
@ -332,6 +333,29 @@ typedef enum
CCTextAlignmentRight,
} CCTextAlignment;
// types for animation in particle systems
// texture coordinates for a quad
typedef struct _ccT2F_Quad
{
//! bottom left
ccTex2F bl;
//! bottom right
ccTex2F br;
//! top left
ccTex2F tl;
//! top right
ccTex2F tr;
} ccT2F_Quad;
// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad
typedef struct
{
ccT2F_Quad texCoords;
ccTime delay;
CCSize size;
} ccAnimationFrameData;
}//namespace cocos2d
#endif //__CCTYPES_H__

View File

@ -38,6 +38,10 @@ THE SOFTWARE.
NS_CC_BEGIN;
static const char *__suffixiPhoneRetinaDisplay = "-hd";
static const char *__suffixiPad = "-ipad";
static const char *__suffixiPadRetinaDisplay = "-ipadhd";
typedef enum
{
SAX_NONE = 0,
@ -266,25 +270,24 @@ public:
}
};
std::string& CCFileUtils::ccRemoveHDSuffixFromFile(std::string& path)
std::string& CCFileUtils::removeSuffixFromFile(std::string& path)
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
// XXX win32 now can only support iphone retina, because
// we don't know it is ipad retina or iphone retina.
// fixe me later
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
std::string::size_type pos = path.rfind("/") + 1; // the begin index of last part of path
std::string::size_type suffixPos = path.rfind(CC_RETINA_DISPLAY_FILENAME_SUFFIX);
std::string::size_type suffixPos = path.rfind(__suffixiPhoneRetinaDisplay);
if (std::string::npos != suffixPos && suffixPos > pos)
{
CCLog("cocos2d: FilePath(%s) contains suffix(%s), remove it.", path.c_str(),
CC_RETINA_DISPLAY_FILENAME_SUFFIX);
path.replace(suffixPos, strlen(CC_RETINA_DISPLAY_FILENAME_SUFFIX), "");
__suffixiPhoneRetinaDisplay);
path.replace(suffixPos, strlen(__suffixiPhoneRetinaDisplay), "");
}
}
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return path;
}
@ -344,6 +347,47 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
return pBuffer;
}
/// functions iOS specific
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType)
{
assert(0);
return "";
}
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
assert(0);
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
assert(0);
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
assert(0);
}
bool CCFileUtils::iPadFileExistsAtPath(const char *filename)
{
assert(0);
return false;
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *filename)
{
assert(0);
return false;
}
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *filename)
{
assert(0);
return false;
}
//////////////////////////////////////////////////////////////////////////
// Notification support when getFileData from invalid file path.
//////////////////////////////////////////////////////////////////////////

View File

@ -53,11 +53,15 @@ public:
*/
static unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize);
/** removes the HD suffix from a path
@returns const char * without the HD suffix
/** removes the suffix from a path
* On RetinaDisplay it will remove the -hd suffix
* On iPad it will remove the -ipad suffix
* On iPhone it will remove the (empty) suffix
Only valid on iOS. Not valid for OS X.
@since v0.99.5
*/
static std::string& ccRemoveHDSuffixFromFile(std::string& path);
static std::string& removeSuffixFromFile(std::string& path);
/**
@brief Generate the absolute path of the file.
@ -69,10 +73,68 @@ public:
*/
static const char* fullPathFromRelativePath(const char *pszRelativePath);
/** Returns the fullpath of an filename including the resolution of the image.
If in RetinaDisplay mode, and a RetinaDisplay file is found, it will return that path.
If in iPad mode, and an iPad file is found, it will return that path.
Examples:
* In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists)
* In RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists)
If an iPad file is found, it will set resolution type to kCCResolutioniPad
If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay
*/
static const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType);
/// @cond
static const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
/// @endcond
/** Sets the iPhone RetinaDisplay suffix to load resources.
By default it is "-hd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
static void setiPhoneRetinaDisplaySuffix(const char *suffix);
/** Sets the iPad suffix to load resources.
By default it is "".
Only valid on iOS. Not valid for OS X.
*/
static void setiPadSuffix(const char *suffix);
/** Sets the iPad Retina Display suffix to load resources.
By default it is "-ipadhd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
static void setiPadRetinaDisplaySuffix(const char *suffix);
/** Returns whether or not a given filename exists with the iPad suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPadFileExistsAtPath(const char *filename);
/** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
*/
bool iPadRetinaDisplayFileExistsAtPath(const char *filename);
/** Returns whether or not a given path exists with the iPhone RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPhoneRetinaDisplayFileExistsAtPath(const char *filename);
/**
@brief Set the ResourcePath,we will find resource in this path
@param pszResourcePath The absolute resource path

View File

@ -61,6 +61,11 @@ void CCEGLView::setFrameWidthAndHeight(int width, int height)
m_sSizeInPixel.height = height;
}
bool CCEGLView::isIpad()
{
return false;
}
void CCEGLView::create(int width, int height)
{
if (width == 0 || height == 0)

View File

@ -40,6 +40,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
/**
* the width and height is the real size of phone
*/

View File

@ -241,6 +241,11 @@ CCRect CCEGLView::getFrame()
return rc;
}
bool CCEGLView::isIpad()
{
return false;
}
bool CCEGLView::isOpenGLReady()
{
return (NULL != m_pEGL);

View File

@ -55,6 +55,7 @@ public:
CCRect getFrame();
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();

View File

@ -42,6 +42,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool canSetContentScaleFactor();
bool isIpad();
void setContentScaleFactor(float contentScaleFactor);
// keep compatible

View File

@ -47,6 +47,11 @@ cocos2d::CCSize CCEGLView::getSize()
return size;
}
bool CCEGLView::isIpad()
{
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
}
bool CCEGLView::isOpenGLReady()
{
return [EAGLView sharedEGLView] != NULL;

View File

@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <Foundation/Foundation.h>
#import <UIKit/UIDevice.h>
#include <string>
#include <stack>
@ -42,47 +43,50 @@ using namespace cocos2d;
static void static_addValueToCCDict(id key, id value, CCDictionary* pDict);
static void static_addItemToCCArray(id item, CCArray* pArray);
static const char *static_ccRemoveHDSuffixFromFile( const char *pszPath)
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
static NSString *__suffixiPhoneRetinaDisplay =@"-hd";
static NSString *__suffixiPad =@"-ipad";
static NSString *__suffixiPadRetinaDisplay =@"-ipadhd";
static NSFileManager *__localFileManager= [[NSFileManager alloc] init];
static NSString* removeSuffixFromPath(NSString *suffix, NSString *path)
{
// quick return
if( ! suffix || [suffix length] == 0 )
{
return path;
}
if(cocos2d::CC_CONTENT_SCALE_FACTOR() == 2 ) {
NSString *path = [NSString stringWithUTF8String: pszPath];
NSString *name = [path lastPathComponent];
NSString *suffix = [NSString stringWithUTF8String: CC_RETINA_DISPLAY_FILENAME_SUFFIX];
// check if path already has the suffix.
if( [name rangeOfString: suffix].location != NSNotFound ) {
if( [name rangeOfString:suffix].location != NSNotFound ) {
CCLOG("cocos2d: Filename(%@) contains %@ suffix. Removing it. See cocos2d issue #1040", path, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
CCLOG("cocos2d: Filename(%s) contains %s suffix. Removing it. See cocos2d issue #1040", [path UTF8String], [suffix UTF8String]);
NSString *newLastname = [name stringByReplacingOccurrencesOfString: suffix withString:@""];
NSString *newLastname = [name stringByReplacingOccurrencesOfString:suffix withString:@""];
NSString *pathWithoutLastname = [path stringByDeletingLastPathComponent];
return [[pathWithoutLastname stringByAppendingPathComponent:newLastname] UTF8String];
}
return [pathWithoutLastname stringByAppendingPathComponent:newLastname];
}
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return pszPath;
return path;
}
static NSString* getDoubleResolutionImage(NSString* path)
static NSString* getPathForSuffix(NSString *path, NSString *suffix)
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
if( cocos2d::CC_CONTENT_SCALE_FACTOR() == 2 )
// quick return
if( ! suffix || [suffix length] == 0 )
{
return path;
}
NSString *pathWithoutExtension = [path stringByDeletingPathExtension];
NSString *name = [pathWithoutExtension lastPathComponent];
NSString *suffix = [NSString stringWithUTF8String: CC_RETINA_DISPLAY_FILENAME_SUFFIX];
// check if path already has the suffix.
if( [name rangeOfString: suffix].location != NSNotFound ) {
if( [name rangeOfString:suffix].location != NSNotFound ) {
CCLOG("cocos2d: WARNING Filename(%@) already has the suffix %@. Using it.", name, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
CCLOG("cocos2d: WARNING Filename(%s) already has the suffix %s. Using it.", [name UTF8String], [suffix UTF8String]);
return path;
}
@ -98,48 +102,15 @@ static NSString* getDoubleResolutionImage(NSString* path)
}
NSString *retinaName = [pathWithoutExtension stringByAppendingString: suffix];
retinaName = [retinaName stringByAppendingPathExtension:extension];
NSString *newName = [pathWithoutExtension stringByAppendingString:suffix];
newName = [newName stringByAppendingPathExtension:extension];
NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
if( [fileManager fileExistsAtPath:retinaName] )
return retinaName;
if( [__localFileManager fileExistsAtPath:newName] )
return newName;
CCLOG("cocos2d: CCFileUtils: Warning HD file not found: %@", [retinaName lastPathComponent] );
}
CCLOG("cocos2d: CCFileUtils: Warning file not found: %s", [[newName lastPathComponent] UTF8String] );
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return path;
}
static const char* static_fullPathFromRelativePath(const char *pszRelativePath)
{
// NSAssert(pszRelativePath != nil, @"CCFileUtils: Invalid path");
// do not convert an absolute path (starting with '/')
NSString *relPath = [NSString stringWithUTF8String: pszRelativePath];
NSString *fullpath = nil;
// only if it is not an absolute path
if( ! [relPath isAbsolutePath] )
{
NSString *file = [relPath lastPathComponent];
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectory];
}
if (fullpath == nil)
fullpath = relPath;
fullpath = getDoubleResolutionImage(fullpath);
return [fullpath UTF8String];
return nil;
}
static void static_addItemToCCArray(id item, CCArray *pArray)
@ -274,15 +245,164 @@ namespace cocos2d {
return size;
}
std::string& CCFileUtils::ccRemoveHDSuffixFromFile(std::string& path )
std::string& CCFileUtils::removeSuffixFromFile(std::string& cpath )
{
path = static_ccRemoveHDSuffixFromFile(path.c_str());
return path;
NSString *ret = nil;
NSString *path = [NSString stringWithUTF8String:cpath.c_str()];
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPadRetinaDisplay, path);
}
else
{
ret = removeSuffixFromPath(__suffixiPad, path);
}
}
else
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPhoneRetinaDisplay, [NSString stringWithUTF8String:cpath.c_str()]);
}
else
{
ret = path;
}
}
cpath = [ret UTF8String];
return cpath;
}
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPhoneRetinaDisplay release];
__suffixiPhoneRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
[__suffixiPad release];
__suffixiPad = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPadRetinaDisplay release];
__suffixiPadRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
}
bool fileExistsAtPath(const char *cpath, const char *csuffix)
{
NSString *fullpath = nil;
NSString *relPath = [NSString stringWithUTF8String:cpath];
NSString *suffix = [NSString stringWithUTF8String:csuffix];
// only if it is not an absolute path
if( ! [relPath isAbsolutePath] ) {
// pathForResource also searches in .lproj directories. issue #1230
NSString *file = [relPath lastPathComponent];
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectory];
}
if (fullpath == nil)
fullpath = relPath;
NSString *path = getPathForSuffix(fullpath, suffix);
return ( path != nil );
}
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPhoneRetinaDisplay UTF8String]);
}
bool CCFileUtils::iPadFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPad UTF8String]);
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPadRetinaDisplay UTF8String]);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
return static_fullPathFromRelativePath(pszRelativePath);
ccResolutionType ignore;
return fullPathFromRelativePath(pszRelativePath, &ignore);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType)
{
CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path");
NSString *fullpath = nil;
NSString *relPath = [NSString stringWithUTF8String:pszRelativePath];
// only if it is not an absolute path
if( ! [relPath isAbsolutePath] ) {
// pathForResource also searches in .lproj directories. issue #1230
NSString *file = [relPath lastPathComponent];
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectory];
}
if (fullpath == nil)
{
fullpath = relPath;
}
NSString *ret = nil;
// iPad?
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPadRetinaDisplay);
*pResolutionType = kCCResolutioniPadRetinaDisplay;
}
else
{
ret = getPathForSuffix(fullpath, __suffixiPad);
*pResolutionType = kCCResolutioniPad;
}
}
// iPhone ?
else
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPhoneRetinaDisplay);
*pResolutionType = kCCResolutioniPhoneRetinaDisplay;
}
}
// If it is iPhone Non RetinaDisplay, or if the previous "getPath" failed, then use iPhone images.
if( ret == nil )
{
*pResolutionType = kCCResolutioniPhone;
ret = fullpath;
}
return [ret UTF8String];
}
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)

View File

@ -278,6 +278,11 @@ bool CCEGLView::isOpenGLReady()
return bIsInit;
}
bool CCEGLView::isIpad()
{
return false;
}
void CCEGLView::release()
{
/* Exits from GLFW */

View File

@ -38,6 +38,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();

View File

@ -265,6 +265,11 @@ bool CCEGLView::isOpenGLReady()
return (IwGLIsInitialised() && m_sSizeInPixel.width != 0 && m_sSizeInPixel.height !=0);
}
bool CCEGLView::isIpad()
{
return false;
}
void CCEGLView::release()
{
IW_CALLSTACK("CCEGLView::release");

View File

@ -45,6 +45,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
/**
* the width and height is the real size of phone
*/

View File

@ -786,6 +786,11 @@ bool CCEGLView::isOpenGLReady()
return (m_isGLInitialized && m_sSizeInPixel.width != 0 && m_sSizeInPixel.height != 0);
}
bool CCEGLView::isIpad()
{
return false;
}
void CCEGLView::release()
{
if (!m_eglContext || !m_eglDisplay)

View File

@ -53,6 +53,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
/**
* the width and height is the real size of phone
*/

View File

@ -419,6 +419,11 @@ bool CCEGLView::isOpenGLReady()
return (NULL != m_pEGL);
}
bool CCEGLView::isIpad()
{
return false;
}
void CCEGLView::release()
{
if (m_hWnd)

View File

@ -47,6 +47,7 @@ public:
CCSize getSize();
bool isOpenGLReady();
bool isIpad();
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();

View File

@ -218,9 +218,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor
m_bHasPremultipliedAlpha = false;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
m_resolutionType = kCCResolutionUnknown;
#endif
m_eResolutionType = kCCResolutionUnknown;
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture));
return true;
@ -235,11 +233,13 @@ char * CCTexture2D::description(void)
}
// implementation CCTexture2D (Image)
#if 0// TODO: #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
bool CCTexture2D::initWithImage(CCImage *uiImage)
{
return initWithImage(uiImage, kCCResolutionUnknown);
}
bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
#else
bool CCTexture2D::initWithImage(CCImage * uiImage)
#endif
{
unsigned int POTWide, POTHigh;
@ -273,9 +273,7 @@ bool CCTexture2D::initWithImage(CCImage * uiImage)
return NULL;
}
#if 0//TODO (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
m_resolutionType = resolution;
#endif
m_eResolutionType = resolution;
// always load premultiplied images
return initPremultipliedATextureWithImage(uiImage, POTWide, POTHigh);
@ -486,11 +484,8 @@ bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCT
{
return false;
}
#if 0// TODO: (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
return initWithImage(&image, m_resolutionType);
#else
return initWithImage(&image);
#endif
}

View File

@ -205,7 +205,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
// optimization
std::string pathKey = path;
CCFileUtils::ccRemoveHDSuffixFromFile(pathKey);
CCFileUtils::removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -330,7 +330,8 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
// remove possible -HD suffix to prevent caching the same image twice (issue #1040)
std::string pathKey = path;
CCFileUtils::ccRemoveHDSuffixFromFile(pathKey);
ccResolutionType resolution;
CCFileUtils::removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -360,7 +361,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, CCImage::kFmtJpg));
texture = new CCTexture2D();
texture->initWithImage(&image);
texture->initWithImage(&image, resolution);
if( texture )
{
@ -388,7 +389,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, CCImage::kFmtPng));
texture = new CCTexture2D();
texture->initWithImage(&image);
texture->initWithImage(&image, resolution);
if( texture )
{
@ -423,7 +424,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl
CCTexture2D * texture;
std::string temp(path);
CCFileUtils::ccRemoveHDSuffixFromFile(temp);
CCFileUtils::removeSuffixFromFile(temp);
if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) )
{
@ -459,7 +460,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
CCTexture2D * tex;
std::string key(path);
// remove possible -HD suffix to prevent caching the same image twice (issue #1040)
CCFileUtils::ccRemoveHDSuffixFromFile(key);
CCFileUtils::removeSuffixFromFile(key);
if( (tex = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) )
{
@ -511,7 +512,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
// prevents overloading the autorelease pool
texture = new CCTexture2D();
texture->initWithImage(image);
texture->initWithImage(image, kCCResolutionUnknown);
if(key && texture)
{