Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into developCCS

This commit is contained in:
samuele3 2013-11-05 17:37:54 +08:00
commit b9e5d4bc91
40 changed files with 423 additions and 416 deletions

View File

@ -13,6 +13,7 @@ cocos2d-x-3.0alpha1 @??? 2013
[NEW] Added Mouse Support For Desktop Platforms. [NEW] Added Mouse Support For Desktop Platforms.
[FIX] EventListeners can't be removed sometimes. [FIX] EventListeners can't be removed sometimes.
[FIX] When parsing XML using TinyXML, the data size has to be specified. [FIX] When parsing XML using TinyXML, the data size has to be specified.
[NEW] Arm64 support.
[Android] [Android]
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again [NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
@ -25,6 +26,8 @@ cocos2d-x-3.0alpha1 @??? 2013
[FIX] Removed unused CCLOG() from GL initialization [FIX] Removed unused CCLOG() from GL initialization
[iOS] [iOS]
[FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox. [FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox.
[Linux]
[NEW] Used CMake to build linux projects.
[Desktop] [Desktop]
[FIX] Trigger onKeyReleased only after the key has been released. [FIX] Trigger onKeyReleased only after the key has been released.
[Javascript binding] [Javascript binding]

View File

@ -1 +1 @@
db96f13af3f35778c8d9c2b6bec189fcdaf7216e 695569fbf5580abb74dbc9b9d9fc7ad8d21db805

View File

@ -1 +1 @@
b473303312be3b69891020b5fb470dd382f31284 13f41d81e48285159fafa45159fdd1c081b4bb06

View File

@ -65,55 +65,55 @@ ActionManager::~ActionManager(void)
// private // private
void ActionManager::deleteHashElement(tHashElement *pElement) void ActionManager::deleteHashElement(tHashElement *element)
{ {
ccArrayFree(pElement->actions); ccArrayFree(element->actions);
HASH_DEL(_targets, pElement); HASH_DEL(_targets, element);
pElement->target->release(); element->target->release();
free(pElement); free(element);
} }
void ActionManager::actionAllocWithHashElement(tHashElement *pElement) void ActionManager::actionAllocWithHashElement(tHashElement *element)
{ {
// 4 actions per Node by default // 4 actions per Node by default
if (pElement->actions == NULL) if (element->actions == NULL)
{ {
pElement->actions = ccArrayNew(4); element->actions = ccArrayNew(4);
}else }else
if (pElement->actions->num == pElement->actions->max) if (element->actions->num == element->actions->max)
{ {
ccArrayDoubleCapacity(pElement->actions); ccArrayDoubleCapacity(element->actions);
} }
} }
void ActionManager::removeActionAtIndex(int index, tHashElement *pElement) void ActionManager::removeActionAtIndex(long index, tHashElement *element)
{ {
Action *pAction = (Action*)pElement->actions->arr[index]; Action *action = (Action*)element->actions->arr[index];
if (pAction == pElement->currentAction && (! pElement->currentActionSalvaged)) if (action == element->currentAction && (! element->currentActionSalvaged))
{ {
pElement->currentAction->retain(); element->currentAction->retain();
pElement->currentActionSalvaged = true; element->currentActionSalvaged = true;
} }
ccArrayRemoveObjectAtIndex(pElement->actions, index, true); ccArrayRemoveObjectAtIndex(element->actions, index, true);
// update actionIndex in case we are in tick. looping over the actions // update actionIndex in case we are in tick. looping over the actions
if (pElement->actionIndex >= index) if (element->actionIndex >= index)
{ {
pElement->actionIndex--; element->actionIndex--;
} }
if (pElement->actions->num == 0) if (element->actions->num == 0)
{ {
if (_currentTarget == pElement) if (_currentTarget == element)
{ {
_currentTargetSalvaged = true; _currentTargetSalvaged = true;
} }
else else
{ {
deleteHashElement(pElement); deleteHashElement(element);
} }
} }
} }
@ -122,21 +122,21 @@ void ActionManager::removeActionAtIndex(int index, tHashElement *pElement)
void ActionManager::pauseTarget(Object *target) void ActionManager::pauseTarget(Object *target)
{ {
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
pElement->paused = true; element->paused = true;
} }
} }
void ActionManager::resumeTarget(Object *target) void ActionManager::resumeTarget(Object *target)
{ {
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
pElement->paused = false; element->paused = false;
} }
} }
@ -168,40 +168,40 @@ void ActionManager::resumeTargets(cocos2d::Set *targetsToResume)
// run // run
void ActionManager::addAction(Action *pAction, Node *target, bool paused) void ActionManager::addAction(Action *action, Node *target, bool paused)
{ {
CCASSERT(pAction != NULL, ""); CCASSERT(action != NULL, "");
CCASSERT(target != NULL, ""); CCASSERT(target != NULL, "");
tHashElement *pElement = NULL; tHashElement *element = NULL;
// we should convert it to Object*, because we save it as Object* // we should convert it to Object*, because we save it as Object*
Object *tmp = target; Object *tmp = target;
HASH_FIND_INT(_targets, &tmp, pElement); HASH_FIND_INT(_targets, &tmp, element);
if (! pElement) if (! element)
{ {
pElement = (tHashElement*)calloc(sizeof(*pElement), 1); element = (tHashElement*)calloc(sizeof(*element), 1);
pElement->paused = paused; element->paused = paused;
target->retain(); target->retain();
pElement->target = target; element->target = target;
HASH_ADD_INT(_targets, target, pElement); HASH_ADD_INT(_targets, target, element);
} }
actionAllocWithHashElement(pElement); actionAllocWithHashElement(element);
CCASSERT(! ccArrayContainsObject(pElement->actions, pAction), ""); CCASSERT(! ccArrayContainsObject(element->actions, action), "");
ccArrayAppendObject(pElement->actions, pAction); ccArrayAppendObject(element->actions, action);
pAction->startWithTarget(target); action->startWithTarget(target);
} }
// remove // remove
void ActionManager::removeAllActions(void) void ActionManager::removeAllActions(void)
{ {
for (tHashElement *pElement = _targets; pElement != NULL; ) for (tHashElement *element = _targets; element != NULL; )
{ {
Object *target = pElement->target; Object *target = element->target;
pElement = (tHashElement*)pElement->hh.next; element = (tHashElement*)element->hh.next;
removeAllActionsFromTarget(target); removeAllActionsFromTarget(target);
} }
} }
@ -214,24 +214,24 @@ void ActionManager::removeAllActionsFromTarget(Object *target)
return; return;
} }
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
if (ccArrayContainsObject(pElement->actions, pElement->currentAction) && (! pElement->currentActionSalvaged)) if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged))
{ {
pElement->currentAction->retain(); element->currentAction->retain();
pElement->currentActionSalvaged = true; element->currentActionSalvaged = true;
} }
ccArrayRemoveAllObjects(pElement->actions); ccArrayRemoveAllObjects(element->actions);
if (_currentTarget == pElement) if (_currentTarget == element)
{ {
_currentTargetSalvaged = true; _currentTargetSalvaged = true;
} }
else else
{ {
deleteHashElement(pElement); deleteHashElement(element);
} }
} }
else else
@ -240,23 +240,23 @@ void ActionManager::removeAllActionsFromTarget(Object *target)
} }
} }
void ActionManager::removeAction(Action *pAction) void ActionManager::removeAction(Action *action)
{ {
// explicit null handling // explicit null handling
if (pAction == NULL) if (action == NULL)
{ {
return; return;
} }
tHashElement *pElement = NULL; tHashElement *element = NULL;
Object *target = pAction->getOriginalTarget(); Object *target = action->getOriginalTarget();
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction); long i = ccArrayGetIndexOfObject(element->actions, action);
if (UINT_MAX != i) if (i != CC_INVALID_INDEX)
{ {
removeActionAtIndex(i, pElement); removeActionAtIndex(i, element);
} }
} }
else else
@ -270,19 +270,19 @@ void ActionManager::removeActionByTag(int tag, Object *target)
CCASSERT(tag != Action::INVALID_TAG, ""); CCASSERT(tag != Action::INVALID_TAG, "");
CCASSERT(target != NULL, ""); CCASSERT(target != NULL, "");
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
unsigned int limit = pElement->actions->num; long limit = element->actions->num;
for (unsigned int i = 0; i < limit; ++i) for (long i = 0; i < limit; ++i)
{ {
Action *pAction = (Action*)pElement->actions->arr[i]; Action *action = (Action*)element->actions->arr[i];
if (pAction->getTag() == (int)tag && pAction->getOriginalTarget() == target) if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
{ {
removeActionAtIndex(i, pElement); removeActionAtIndex(i, element);
break; break;
} }
} }
@ -297,21 +297,21 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
{ {
CCASSERT(tag != Action::INVALID_TAG, ""); CCASSERT(tag != Action::INVALID_TAG, "");
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
if (pElement->actions != NULL) if (element->actions != NULL)
{ {
unsigned int limit = pElement->actions->num; long limit = element->actions->num;
for (unsigned int i = 0; i < limit; ++i) for (long i = 0; i < limit; ++i)
{ {
Action *pAction = (Action*)pElement->actions->arr[i]; Action *action = (Action*)element->actions->arr[i];
if (pAction->getTag() == (int)tag) if (action->getTag() == (int)tag)
{ {
return pAction; return action;
} }
} }
} }
@ -329,11 +329,11 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
// and, it is not possible to get the address of a reference // and, it is not possible to get the address of a reference
unsigned int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const unsigned int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const
{ {
tHashElement *pElement = NULL; tHashElement *element = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, element);
if (pElement) if (element)
{ {
return pElement->actions ? pElement->actions->num : 0; return element->actions ? element->actions->num : 0;
} }
return 0; return 0;
@ -374,10 +374,10 @@ void ActionManager::update(float dt)
{ {
_currentTarget->currentAction->stop(); _currentTarget->currentAction->stop();
Action *pAction = _currentTarget->currentAction; Action *action = _currentTarget->currentAction;
// Make currentAction nil to prevent removeAction from salvaging it. // Make currentAction nil to prevent removeAction from salvaging it.
_currentTarget->currentAction = NULL; _currentTarget->currentAction = NULL;
removeAction(pAction); removeAction(action);
} }
_currentTarget->currentAction = NULL; _currentTarget->currentAction = NULL;

View File

@ -126,7 +126,7 @@ public:
protected: protected:
// declared in ActionManager.m // declared in ActionManager.m
void removeActionAtIndex(int index, struct _hashElement *pElement); void removeActionAtIndex(long index, struct _hashElement *pElement);
void deleteHashElement(struct _hashElement *pElement); void deleteHashElement(struct _hashElement *pElement);
void actionAllocWithHashElement(struct _hashElement *pElement); void actionAllocWithHashElement(struct _hashElement *pElement);
void update(float dt); void update(float dt);

View File

@ -75,7 +75,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
default: default:
if (customGlyphs) if (customGlyphs)
{ {
int lenght = strlen(customGlyphs); size_t lenght = strlen(customGlyphs);
_customGlyphs = new char [lenght + 2]; _customGlyphs = new char [lenght + 2];
memcpy(_customGlyphs, customGlyphs, lenght); memcpy(_customGlyphs, customGlyphs, lenght);

View File

@ -158,7 +158,7 @@ bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment
if (_commonLineHeight <= 0) if (_commonLineHeight <= 0)
return false; return false;
int numLetter = 0; // int numLetter = 0;
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender); unsigned short* utf16String = cc_utf8_to_utf16(stringToRender);
if(!utf16String) if(!utf16String)
return false; return false;

View File

@ -113,7 +113,7 @@ bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
//CCLabelAtlas - Atlas generation //CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues() void LabelAtlas::updateAtlasValues()
{ {
int n = _string.length(); size_t n = _string.length();
const unsigned char *s = (unsigned char*)_string.c_str(); const unsigned char *s = (unsigned char*)_string.c_str();
@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues()
//CCLabelAtlas - LabelProtocol //CCLabelAtlas - LabelProtocol
void LabelAtlas::setString(const char *label) void LabelAtlas::setString(const char *label)
{ {
int len = strlen(label); size_t len = strlen(label);
if (len > _textureAtlas->getTotalQuads()) if (len > _textureAtlas->getTotalQuads())
{ {
_textureAtlas->resizeCapacity(len); _textureAtlas->resizeCapacity(len);

View File

@ -200,7 +200,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
std::string strLeft = contents->getCString(); std::string strLeft = contents->getCString();
while (strLeft.length() > 0) while (strLeft.length() > 0)
{ {
int pos = strLeft.find('\n'); size_t pos = strLeft.find('\n');
if (pos != (int)std::string::npos) if (pos != (int)std::string::npos)
{ {
@ -267,8 +267,8 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// page ID. Sanity check // page ID. Sanity check
int index = line.find('=')+1; long index = line.find('=')+1;
int index2 = line.find(' ', index); long index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index); std::string value = line.substr(index, index2-index);
CCASSERT(atoi(value.c_str()) == 0, "LabelBMFont file could not be found"); CCASSERT(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
// file // file
@ -288,8 +288,8 @@ void CCBMFontConfiguration::parseInfoArguments(std::string line)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// padding // padding
int index = line.find("padding="); long index = line.find("padding=");
int index2 = line.find(' ', index); long index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index); std::string value = line.substr(index, index2-index);
sscanf(value.c_str(), "padding=%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left); sscanf(value.c_str(), "padding=%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);
CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom); CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom);
@ -303,8 +303,8 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Height // Height
int index = line.find("lineHeight="); long index = line.find("lineHeight=");
int index2 = line.find(' ', index); long index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index); std::string value = line.substr(index, index2-index);
sscanf(value.c_str(), "lineHeight=%d", &_commonHeight); sscanf(value.c_str(), "lineHeight=%d", &_commonHeight);
// scaleW. sanity check // scaleW. sanity check
@ -334,8 +334,8 @@ void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontD
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Character ID // Character ID
int index = line.find("id="); long index = line.find("id=");
int index2 = line.find(' ', index); long index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index); std::string value = line.substr(index, index2-index);
sscanf(value.c_str(), "id=%u", &characterDefinition->charID); sscanf(value.c_str(), "id=%u", &characterDefinition->charID);
@ -385,8 +385,8 @@ void CCBMFontConfiguration::parseKerningEntry(std::string line)
// first // first
int first; int first;
int index = line.find("first="); long index = line.find("first=");
int index2 = line.find(' ', index); long index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index); std::string value = line.substr(index, index2-index);
sscanf(value.c_str(), "first=%d", &first); sscanf(value.c_str(), "first=%d", &first);

View File

@ -402,7 +402,7 @@ void Node::setPositionY(float y)
setPosition(Point(_position.x, y)); setPosition(Point(_position.x, y));
} }
unsigned int Node::getChildrenCount() const long Node::getChildrenCount() const
{ {
return _children ? _children->count() : 0; return _children ? _children->count() : 0;
} }
@ -694,7 +694,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
return; return;
} }
int index = _children->getIndexOfObject(child); long index = _children->getIndexOfObject(child);
if( index != CC_INVALID_INDEX ) if( index != CC_INVALID_INDEX )
this->detachChild( child, index, cleanup ); this->detachChild( child, index, cleanup );
} }
@ -754,7 +754,7 @@ void Node::removeAllChildrenWithCleanup(bool cleanup)
} }
void Node::detachChild(Node *child, int childIndex, bool doCleanup) void Node::detachChild(Node *child, long childIndex, bool doCleanup)
{ {
// IMPORTANT: // IMPORTANT:
// -1st do onExit // -1st do onExit

View File

@ -644,7 +644,7 @@ public:
* *
* @return The amount of children. * @return The amount of children.
*/ */
unsigned int getChildrenCount() const; long getChildrenCount() const;
/** /**
* Sets the parent node * Sets the parent node
@ -1421,7 +1421,7 @@ protected:
void insertChild(Node* child, int z); void insertChild(Node* child, int z);
/// Removes a child, call child->onExit(), do cleanup, remove it from children array. /// Removes a child, call child->onExit(), do cleanup, remove it from children array.
void detachChild(Node *child, int index, bool doCleanup); void detachChild(Node *child, long index, bool doCleanup);
/// Convert cocos2d coordinates to UI windows coordinate. /// Convert cocos2d coordinates to UI windows coordinate.
Point convertToWindowSpace(const Point& nodePoint) const; Point convertToWindowSpace(const Point& nodePoint) const;

View File

@ -388,7 +388,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
const char *textureData = dictionary->valueForKey("textureImageData")->getCString(); const char *textureData = dictionary->valueForKey("textureImageData")->getCString();
CCASSERT(textureData, ""); CCASSERT(textureData, "");
int dataLen = strlen(textureData); long dataLen = strlen(textureData);
if(dataLen != 0) if(dataLen != 0)
{ {
// if it fails, try to get it from the base64-gzipped data // if it fails, try to get it from the base64-gzipped data

View File

@ -166,7 +166,7 @@ void ProfilingEndTimingBlock(const char *timerName)
CCASSERT(timer, "CCProfilingTimer not found"); CCASSERT(timer, "CCProfilingTimer not found");
int duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count(); long duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count();
timer->totalTime += duration; timer->totalTime += duration;
timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f; timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f;

View File

@ -134,12 +134,12 @@ public:
std::string _nameStr; std::string _nameStr;
std::chrono::high_resolution_clock::time_point _startTime; std::chrono::high_resolution_clock::time_point _startTime;
int _averageTime1; long _averageTime1;
int _averageTime2; long _averageTime2;
int minTime; long minTime;
int maxTime; long maxTime;
long long totalTime; long totalTime;
int numberOfCalls; long numberOfCalls;
}; };
extern void ProfilingBeginTimingBlock(const char *timerName); extern void ProfilingBeginTimingBlock(const char *timerName);

View File

@ -198,8 +198,8 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
// textures must be power of two squared // textures must be power of two squared
unsigned int powW = 0; long powW = 0;
unsigned int powH = 0; long powH = 0;
if (Configuration::getInstance()->supportsNPOT()) if (Configuration::getInstance()->supportsNPOT())
{ {
@ -212,7 +212,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
powH = ccNextPOT(h); powH = ccNextPOT(h);
} }
int dataLen = (int)(powW * powH * 4); long dataLen = (long)(powW * powH * 4);
data = malloc(dataLen); data = malloc(dataLen);
CC_BREAK_IF(! data); CC_BREAK_IF(! data);

View File

@ -64,7 +64,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity
* creation with File Image * creation with File Image
*/ */
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = DEFAULT_CAPACITY*/) SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, long capacity/* = DEFAULT_CAPACITY*/)
{ {
SpriteBatchNode *batchNode = new SpriteBatchNode(); SpriteBatchNode *batchNode = new SpriteBatchNode();
batchNode->initWithFile(fileImage, capacity); batchNode->initWithFile(fileImage, capacity);
@ -76,7 +76,7 @@ SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* =
/* /*
* init with Texture2D * init with Texture2D
*/ */
bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity) bool SpriteBatchNode::initWithTexture(Texture2D *tex, long capacity)
{ {
CCASSERT(capacity>=0, "Capacity must be >= 0"); CCASSERT(capacity>=0, "Capacity must be >= 0");
@ -112,7 +112,7 @@ bool SpriteBatchNode::init()
/* /*
* init with FileImage * init with FileImage
*/ */
bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity) bool SpriteBatchNode::initWithFile(const char* fileImage, long capacity)
{ {
Texture2D *texture2D = TextureCache::getInstance()->addImage(fileImage); Texture2D *texture2D = TextureCache::getInstance()->addImage(fileImage);
return initWithTexture(texture2D, capacity); return initWithTexture(texture2D, capacity);

View File

@ -74,7 +74,7 @@ public:
The capacity will be increased in 33% in runtime if it run out of space. The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr. The file will be loaded using the TextureMgr.
*/ */
static SpriteBatchNode* create(const char* fileImage, int capacity = DEFAULT_CAPACITY); static SpriteBatchNode* create(const char* fileImage, long capacity = DEFAULT_CAPACITY);
/** /**
* @js ctor * @js ctor
*/ */
@ -88,14 +88,14 @@ public:
/** initializes a SpriteBatchNode with a texture2d and capacity of children. /** initializes a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space. The capacity will be increased in 33% in runtime if it run out of space.
*/ */
bool initWithTexture(Texture2D *tex, int capacity); bool initWithTexture(Texture2D *tex, long capacity);
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children. /** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space. The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr. The file will be loaded using the TextureMgr.
* @js init * @js init
* @lua init * @lua init
*/ */
bool initWithFile(const char* fileImage, int capacity); bool initWithFile(const char* fileImage, long capacity);
bool init(); bool init();
/** returns the TextureAtlas object */ /** returns the TextureAtlas object */

View File

@ -119,7 +119,7 @@ static bool _PVRHaveAlphaPremultiplied = false;
//conventer function //conventer function
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBB // IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBB
void Texture2D::convertI8ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i=0; i < dataLen; ++i) for (int i=0; i < dataLen; ++i)
{ {
@ -130,7 +130,7 @@ void Texture2D::convertI8ToRGB888(const unsigned char* data, int dataLen, unsign
} }
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB // IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
void Texture2D::convertAI88ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
{ {
@ -141,7 +141,7 @@ void Texture2D::convertAI88ToRGB888(const unsigned char* data, int dataLen, unsi
} }
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBBAAAAAAAA // IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBBAAAAAAAA
void Texture2D::convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0; i < dataLen; ++i) for (int i = 0; i < dataLen; ++i)
{ {
@ -153,7 +153,7 @@ void Texture2D::convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsi
} }
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA // IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
{ {
@ -165,7 +165,7 @@ void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, int dataLen, un
} }
// IIIIIIII -> RRRRRGGGGGGBBBBB // IIIIIIII -> RRRRRGGGGGGBBBBB
void Texture2D::convertI8ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0; i < dataLen; ++i) for (int i = 0; i < dataLen; ++i)
@ -177,7 +177,7 @@ void Texture2D::convertI8ToRGB565(const unsigned char* data, int dataLen, unsign
} }
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB // IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB
void Texture2D::convertAI88ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
@ -189,7 +189,7 @@ void Texture2D::convertAI88ToRGB565(const unsigned char* data, int dataLen, unsi
} }
// IIIIIIII -> RRRRGGGGBBBBAAAA // IIIIIIII -> RRRRGGGGBBBBAAAA
void Texture2D::convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0; i < dataLen; ++i) for (int i = 0; i < dataLen; ++i)
@ -202,7 +202,7 @@ void Texture2D::convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsi
} }
// IIIIIIIIAAAAAAAA -> RRRRGGGGBBBBAAAA // IIIIIIIIAAAAAAAA -> RRRRGGGGBBBBAAAA
void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
@ -215,7 +215,7 @@ void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, int dataLen, un
} }
// IIIIIIII -> RRRRRGGGGGBBBBBA // IIIIIIII -> RRRRRGGGGGBBBBBA
void Texture2D::convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0; i < dataLen; ++i) for (int i = 0; i < dataLen; ++i)
@ -228,7 +228,7 @@ void Texture2D::convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsign
} }
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA // IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA
void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
@ -241,7 +241,7 @@ void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsi
} }
// IIIIIIII -> IIIIIIIIAAAAAAAA // IIIIIIII -> IIIIIIIIAAAAAAAA
void Texture2D::convertI8ToAI88(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0; i < dataLen; ++i) for (int i = 0; i < dataLen; ++i)
@ -252,7 +252,7 @@ void Texture2D::convertI8ToAI88(const unsigned char* data, int dataLen, unsigned
} }
// IIIIIIIIAAAAAAAA -> AAAAAAAA // IIIIIIIIAAAAAAAA -> AAAAAAAA
void Texture2D::convertAI88ToA8(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 1; i < dataLen; i += 2) for (int i = 1; i < dataLen; i += 2)
{ {
@ -261,7 +261,7 @@ void Texture2D::convertAI88ToA8(const unsigned char* data, int dataLen, unsigned
} }
// IIIIIIIIAAAAAAAA -> IIIIIIII // IIIIIIIIAAAAAAAA -> IIIIIIII
void Texture2D::convertAI88ToI8(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 1; i < l; i += 2) for (int i = 0, l = dataLen - 1; i < l; i += 2)
{ {
@ -270,7 +270,7 @@ void Texture2D::convertAI88ToI8(const unsigned char* data, int dataLen, unsigned
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (int i = 0, l = dataLen - 2; i < l; i += 3)
{ {
@ -282,7 +282,7 @@ void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, int dataLen,
} }
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 3; i < l; i += 4) for (int i = 0, l = dataLen - 3; i < l; i += 4)
{ {
@ -293,7 +293,7 @@ void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, int dataLen,
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGGBBBBB // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGGBBBBB
void Texture2D::convertRGB888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (int i = 0, l = dataLen - 2; i < l; i += 3)
@ -305,7 +305,7 @@ void Texture2D::convertRGB888ToRGB565(const unsigned char* data, int dataLen, un
} }
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGGGGGBBBBB // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGGGGGBBBBB
void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 3; i < l; i += 4) for (int i = 0, l = dataLen - 3; i < l; i += 4)
@ -317,7 +317,7 @@ void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, int dataLen,
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIII // RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIII
void Texture2D::convertRGB888ToI8(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (int i = 0, l = dataLen - 2; i < l; i += 3)
{ {
@ -326,7 +326,7 @@ void Texture2D::convertRGB888ToI8(const unsigned char* data, int dataLen, unsign
} }
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIII // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIII
void Texture2D::convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 3; i < l; i += 4) for (int i = 0, l = dataLen - 3; i < l; i += 4)
{ {
@ -335,7 +335,7 @@ void Texture2D::convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsi
} }
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAAAAAA // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAAAAAA
void Texture2D::convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen -3; i < l; i += 4) for (int i = 0, l = dataLen -3; i < l; i += 4)
{ {
@ -344,7 +344,7 @@ void Texture2D::convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsi
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIIIAAAAAAAA // RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIIIAAAAAAAA
void Texture2D::convertRGB888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (int i = 0, l = dataLen - 2; i < l; i += 3)
{ {
@ -355,7 +355,7 @@ void Texture2D::convertRGB888ToAI88(const unsigned char* data, int dataLen, unsi
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIIIAAAAAAAA // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIIIAAAAAAAA
void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
for (int i = 0, l = dataLen - 3; i < l; i += 4) for (int i = 0, l = dataLen - 3; i < l; i += 4)
{ {
@ -365,7 +365,7 @@ void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, int dataLen, un
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRGGGGBBBBAAAA // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRGGGGBBBBAAAA
void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (int i = 0, l = dataLen - 2; i < l; i += 3)
@ -378,7 +378,7 @@ void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, int dataLen,
} }
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRGGGGBBBBAAAA // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRGGGGBBBBAAAA
void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 3; i < l; i += 4) for (int i = 0, l = dataLen - 3; i < l; i += 4)
@ -391,10 +391,10 @@ void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 2; i < l; i += 3) for (long i = 0, l = dataLen - 2; i < l; i += 3)
{ {
*out16++ = (data[i] & 0x00F8) << 8 //R *out16++ = (data[i] & 0x00F8) << 8 //R
| (data[i + 1] & 0x00F8) << 3 //G | (data[i + 1] & 0x00F8) << 3 //G
@ -404,10 +404,10 @@ void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, un
} }
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData) void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
{ {
unsigned short* out16 = (unsigned short*)outData; unsigned short* out16 = (unsigned short*)outData;
for (int i = 0, l = dataLen - 2; i < l; i += 4) for (long i = 0, l = dataLen - 2; i < l; i += 4)
{ {
*out16++ = (data[i] & 0x00F8) << 8 //R *out16++ = (data[i] & 0x00F8) << 8 //R
| (data[i + 1] & 0x00F8) << 3 //G | (data[i + 1] & 0x00F8) << 3 //G
@ -451,12 +451,12 @@ Texture2D::PixelFormat Texture2D::getPixelFormat() const
return _pixelFormat; return _pixelFormat;
} }
unsigned int Texture2D::getPixelsWide() const long Texture2D::getPixelsWide() const
{ {
return _pixelsWide; return _pixelsWide;
} }
unsigned int Texture2D::getPixelsHigh() const long Texture2D::getPixelsHigh() const
{ {
return _pixelsHigh; return _pixelsHigh;
} }
@ -529,8 +529,10 @@ bool Texture2D::hasPremultipliedAlpha() const
return _hasPremultipliedAlpha; return _hasPremultipliedAlpha;
} }
bool Texture2D::initWithData(const void *data, int dataLen, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize) bool Texture2D::initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize)
{ {
CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size");
//if data has no mipmaps, we will consider it has only one mipmap //if data has no mipmaps, we will consider it has only one mipmap
MipmapInfo mipmap; MipmapInfo mipmap;
mipmap.address = (unsigned char*)data; mipmap.address = (unsigned char*)data;
@ -544,10 +546,11 @@ bool Texture2D::initWithData(const void *data, int dataLen, Texture2D::PixelForm
} }
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh) bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, long pixelsWide, long pixelsHigh)
{ {
//the pixelFormat must be a certain value //the pixelFormat must be a certain value
CCAssert(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!"); CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
CCASSERT(pixelsWide>0 && pixelsHigh>0, "Invalid size");
if (mipmapsNum <= 0) if (mipmapsNum <= 0)
{ {
@ -670,7 +673,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
const char* Texture2D::description(void) const const char* Texture2D::description(void) const
{ {
return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %u x %u | Coordinates = (%.2f, %.2f)>", _name, _pixelsWide, _pixelsHigh, _maxS, _maxT)->getCString(); return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %ld x %ld | Coordinates = (%.2f, %.2f)>", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT)->getCString();
} }
// implementation Texture2D (Image) // implementation Texture2D (Image)
@ -771,7 +774,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
} }
} }
Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen) Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
{ {
switch (format) switch (format)
{ {
@ -820,7 +823,7 @@ Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, i
return format; return format;
} }
Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen) Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
{ {
switch (format) switch (format)
{ {
@ -875,7 +878,7 @@ Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data,
return format; return format;
} }
Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen) Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
{ {
switch (format) switch (format)
{ {
@ -923,7 +926,7 @@ Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* dat
return format; return format;
} }
Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen) Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
{ {
switch (format) switch (format)
@ -995,7 +998,7 @@ rgb(2) -> 1235678
rgba(1) -> 12345678 rgba(1) -> 12345678
*/ */
Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, int dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen) Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen)
{ {
switch (originFormat) switch (originFormat)
{ {

View File

@ -120,13 +120,13 @@ public:
struct PixelFormatInfo { struct PixelFormatInfo {
PixelFormatInfo(GLenum internalFormat, GLenum format, GLenum type, int bpp, bool compressed, bool alpha) PixelFormatInfo(GLenum anInternalFormat, GLenum aFormat, GLenum aType, int aBpp, bool aCompressed, bool anAlpha)
: internalFormat(internalFormat) : internalFormat(anInternalFormat)
, format(format) , format(aFormat)
, type(type) , type(aType)
, bpp(bpp) , bpp(aBpp)
, compressed(compressed) , compressed(aCompressed)
, alpha(alpha) , alpha(anAlpha)
{} {}
GLenum internalFormat; GLenum internalFormat;
@ -216,10 +216,10 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
bool initWithData(const void *data, int dataLen, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize); bool initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize);
/** Initializes with mipmaps */ /** Initializes with mipmaps */
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh); bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh);
/** /**
Drawing extensions to make it easy to draw basic quads using a Texture2D object. Drawing extensions to make it easy to draw basic quads using a Texture2D object.
@ -326,10 +326,10 @@ public:
Texture2D::PixelFormat getPixelFormat() const; Texture2D::PixelFormat getPixelFormat() const;
/** Gets the width of the texture in pixels */ /** Gets the width of the texture in pixels */
unsigned int getPixelsWide() const; long getPixelsWide() const;
/** Gets the height of the texture in pixels */ /** Gets the height of the texture in pixels */
unsigned int getPixelsHigh() const; long getPixelsHigh() const;
/** Gets the texture name */ /** Gets the texture name */
GLuint getName() const; GLuint getName() const;
@ -360,56 +360,56 @@ private:
Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you. Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you.
It will return the converted format to you. if the outData != data, you must delete it manually. It will return the converted format to you. if the outData != data, you must delete it manually.
*/ */
static PixelFormat convertDataToFormat(const unsigned char* data, int dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen); static PixelFormat convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen);
static PixelFormat convertI8ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen); static PixelFormat convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
static PixelFormat convertAI88ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen); static PixelFormat convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
static PixelFormat convertRGB888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen); static PixelFormat convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen); static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
//I8 to XXX //I8 to XXX
static void convertI8ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertI8ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertI8ToAI88(const unsigned char* data, int dataLen, unsigned char* outData); static void convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
//AI88 to XXX //AI88 to XXX
static void convertAI88ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToA8(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertAI88ToI8(const unsigned char* data, int dataLen, unsigned char* outData); static void convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
//RGB888 to XXX //RGB888 to XXX
static void convertRGB888ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGB888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGB888ToI8(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGB888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGB888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
//RGBA8888 to XXX //RGBA8888 to XXX
static void convertRGBA8888ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
static void convertRGBA8888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData); static void convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
protected: protected:
/** pixel format of the texture */ /** pixel format of the texture */
Texture2D::PixelFormat _pixelFormat; Texture2D::PixelFormat _pixelFormat;
/** width in pixels */ /** width in pixels */
unsigned int _pixelsWide; long _pixelsWide;
/** height in pixels */ /** height in pixels */
unsigned int _pixelsHigh; long _pixelsHigh;
/** texture name */ /** texture name */
GLuint _name; GLuint _name;

View File

@ -107,7 +107,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
// TextureAtlas - alloc & init // TextureAtlas - alloc & init
TextureAtlas * TextureAtlas::create(const char* file, int capacity) TextureAtlas * TextureAtlas::create(const char* file, long capacity)
{ {
TextureAtlas * textureAtlas = new TextureAtlas(); TextureAtlas * textureAtlas = new TextureAtlas();
if(textureAtlas && textureAtlas->initWithFile(file, capacity)) if(textureAtlas && textureAtlas->initWithFile(file, capacity))
@ -119,7 +119,7 @@ TextureAtlas * TextureAtlas::create(const char* file, int capacity)
return NULL; return NULL;
} }
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity) TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, long capacity)
{ {
TextureAtlas * textureAtlas = new TextureAtlas(); TextureAtlas * textureAtlas = new TextureAtlas();
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity)) if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
@ -131,7 +131,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
return NULL; return NULL;
} }
bool TextureAtlas::initWithFile(const char * file, int capacity) bool TextureAtlas::initWithFile(const char * file, long capacity)
{ {
// retained in property // retained in property
Texture2D *texture = TextureCache::getInstance()->addImage(file); Texture2D *texture = TextureCache::getInstance()->addImage(file);
@ -147,7 +147,7 @@ bool TextureAtlas::initWithFile(const char * file, int capacity)
} }
} }
bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity) bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity)
{ {
CCASSERT(capacity>=0, "Capacity must be >= 0"); CCASSERT(capacity>=0, "Capacity must be >= 0");
@ -310,7 +310,7 @@ void TextureAtlas::mapBuffers()
// TextureAtlas - Update, Insert, Move & Remove // TextureAtlas - Update, Insert, Move & Remove
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index) void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, long index)
{ {
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index"); CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
@ -323,7 +323,7 @@ void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
} }
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index) void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, long index)
{ {
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index"); CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
@ -347,7 +347,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
} }
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount) void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
{ {
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount"); CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
@ -378,7 +378,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
_dirty = true; _dirty = true;
} }
void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex) void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex)
{ {
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
@ -407,7 +407,7 @@ void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
_dirty = true; _dirty = true;
} }
void TextureAtlas::removeQuadAtIndex(int index) void TextureAtlas::removeQuadAtIndex(long index)
{ {
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index"); CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
@ -426,7 +426,7 @@ void TextureAtlas::removeQuadAtIndex(int index)
_dirty = true; _dirty = true;
} }
void TextureAtlas::removeQuadsAtIndex(int index, int amount) void TextureAtlas::removeQuadsAtIndex(long index, long amount)
{ {
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds"); CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
@ -448,7 +448,7 @@ void TextureAtlas::removeAllQuads()
} }
// TextureAtlas - Resize // TextureAtlas - Resize
bool TextureAtlas::resizeCapacity(int newCapacity) bool TextureAtlas::resizeCapacity(long newCapacity)
{ {
CCASSERT(newCapacity>=0, "capacity >= 0"); CCASSERT(newCapacity>=0, "capacity >= 0");
if( newCapacity == _capacity ) if( newCapacity == _capacity )
@ -522,13 +522,13 @@ bool TextureAtlas::resizeCapacity(int newCapacity)
return true; return true;
} }
void TextureAtlas::increaseTotalQuadsWith(int amount) void TextureAtlas::increaseTotalQuadsWith(long amount)
{ {
CCASSERT(amount>=0, "amount >= 0"); CCASSERT(amount>=0, "amount >= 0");
_totalQuads += amount; _totalQuads += amount;
} }
void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex) void TextureAtlas::moveQuadsFromIndex(long oldIndex, long amount, long newIndex)
{ {
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0"); CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
@ -560,7 +560,7 @@ void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
_dirty = true; _dirty = true;
} }
void TextureAtlas::moveQuadsFromIndex(int index, int newIndex) void TextureAtlas::moveQuadsFromIndex(long index, long newIndex)
{ {
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0"); CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds"); CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
@ -568,7 +568,7 @@ void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0])); memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
} }
void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount) void TextureAtlas::fillWithEmptyQuadsFromIndex(long index, long amount)
{ {
CCASSERT(index>=0 && amount>=0, "values must be >= 0"); CCASSERT(index>=0 && amount>=0, "values must be >= 0");
V3F_C4B_T2F_Quad quad; V3F_C4B_T2F_Quad quad;
@ -588,13 +588,13 @@ void TextureAtlas::drawQuads()
this->drawNumberOfQuads(_totalQuads, 0); this->drawNumberOfQuads(_totalQuads, 0);
} }
void TextureAtlas::drawNumberOfQuads(int numberOfQuads) void TextureAtlas::drawNumberOfQuads(long numberOfQuads)
{ {
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0"); CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
this->drawNumberOfQuads(numberOfQuads, 0); this->drawNumberOfQuads(numberOfQuads, 0);
} }
void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start)
{ {
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0"); CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");

View File

@ -59,13 +59,13 @@ public:
/** creates a TextureAtlas with an filename and with an initial capacity for Quads. /** creates a TextureAtlas with an filename and with an initial capacity for Quads.
* The TextureAtlas capacity can be increased in runtime. * The TextureAtlas capacity can be increased in runtime.
*/ */
static TextureAtlas* create(const char* file , int capacity); static TextureAtlas* create(const char* file , long capacity);
/** creates a TextureAtlas with a previously initialized Texture2D object, and /** creates a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for n Quads. * with an initial capacity for n Quads.
* The TextureAtlas capacity can be increased in runtime. * The TextureAtlas capacity can be increased in runtime.
*/ */
static TextureAtlas* createWithTexture(Texture2D *texture, int capacity); static TextureAtlas* createWithTexture(Texture2D *texture, long capacity);
/** /**
* @js ctor * @js ctor
*/ */
@ -81,7 +81,7 @@ public:
* *
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/ */
bool initWithFile(const char* file, int capacity); bool initWithFile(const char* file, long capacity);
/** initializes a TextureAtlas with a previously initialized Texture2D object, and /** initializes a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for Quads. * with an initial capacity for Quads.
@ -89,43 +89,43 @@ public:
* *
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/ */
bool initWithTexture(Texture2D *texture, int capacity); bool initWithTexture(Texture2D *texture, long capacity);
/** updates a Quad (texture, vertex and color) at a certain index /** updates a Quad (texture, vertex and color) at a certain index
* index must be between 0 and the atlas capacity - 1 * index must be between 0 and the atlas capacity - 1
@since v0.8 @since v0.8
*/ */
void updateQuad(V3F_C4B_T2F_Quad* quad, int index); void updateQuad(V3F_C4B_T2F_Quad* quad, long index);
/** Inserts a Quad (texture, vertex and color) at a certain index /** Inserts a Quad (texture, vertex and color) at a certain index
index must be between 0 and the atlas capacity - 1 index must be between 0 and the atlas capacity - 1
@since v0.8 @since v0.8
*/ */
void insertQuad(V3F_C4B_T2F_Quad* quad, int index); void insertQuad(V3F_C4B_T2F_Quad* quad, long index);
/** Inserts a c array of quads at a given index /** Inserts a c array of quads at a given index
index must be between 0 and the atlas capacity - 1 index must be between 0 and the atlas capacity - 1
this method doesn't enlarge the array when amount + index > totalQuads this method doesn't enlarge the array when amount + index > totalQuads
@since v1.1 @since v1.1
*/ */
void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount); void insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount);
/** Removes the quad that is located at a certain index and inserts it at a new index /** Removes the quad that is located at a certain index and inserts it at a new index
This operation is faster than removing and inserting in a quad in 2 different steps This operation is faster than removing and inserting in a quad in 2 different steps
@since v0.7.2 @since v0.7.2
*/ */
void insertQuadFromIndex(int fromIndex, int newIndex); void insertQuadFromIndex(long fromIndex, long newIndex);
/** removes a quad at a given index number. /** removes a quad at a given index number.
The capacity remains the same, but the total number of quads to be drawn is reduced in 1 The capacity remains the same, but the total number of quads to be drawn is reduced in 1
@since v0.7.2 @since v0.7.2
*/ */
void removeQuadAtIndex(int index); void removeQuadAtIndex(long index);
/** removes a amount of quads starting from index /** removes a amount of quads starting from index
@since 1.1 @since 1.1
*/ */
void removeQuadsAtIndex(int index, int amount); void removeQuadsAtIndex(long index, long amount);
/** removes all Quads. /** removes all Quads.
The TextureAtlas capacity remains untouched. No memory is freed. The TextureAtlas capacity remains untouched. No memory is freed.
The total number of quads to be drawn will be 0 The total number of quads to be drawn will be 0
@ -138,19 +138,19 @@ public:
* It returns true if the resize was successful. * It returns true if the resize was successful.
* If it fails to resize the capacity it will return false with a new capacity of 0. * If it fails to resize the capacity it will return false with a new capacity of 0.
*/ */
bool resizeCapacity(int capacity); bool resizeCapacity(long capacity);
/** /**
Used internally by ParticleBatchNode Used internally by ParticleBatchNode
don't use this unless you know what you're doing don't use this unless you know what you're doing
@since 1.1 @since 1.1
*/ */
void increaseTotalQuadsWith(int amount); void increaseTotalQuadsWith(long amount);
/** Moves an amount of quads from oldIndex at newIndex /** Moves an amount of quads from oldIndex at newIndex
@since v1.1 @since v1.1
*/ */
void moveQuadsFromIndex(int oldIndex, int amount, int newIndex); void moveQuadsFromIndex(long oldIndex, long amount, long newIndex);
/** /**
Moves quads from index till totalQuads to the newIndex Moves quads from index till totalQuads to the newIndex
@ -158,26 +158,26 @@ public:
This method doesn't enlarge the array if newIndex + quads to be moved > capacity This method doesn't enlarge the array if newIndex + quads to be moved > capacity
@since 1.1 @since 1.1
*/ */
void moveQuadsFromIndex(int index, int newIndex); void moveQuadsFromIndex(long index, long newIndex);
/** /**
Ensures that after a realloc quads are still empty Ensures that after a realloc quads are still empty
Used internally by ParticleBatchNode Used internally by ParticleBatchNode
@since 1.1 @since 1.1
*/ */
void fillWithEmptyQuadsFromIndex(int index, int amount); void fillWithEmptyQuadsFromIndex(long index, long amount);
/** draws n quads /** draws n quads
* n can't be greater than the capacity of the Atlas * n can't be greater than the capacity of the Atlas
*/ */
void drawNumberOfQuads(int n); void drawNumberOfQuads(long n);
/** draws n quads from an index (offset). /** draws n quads from an index (offset).
n + start can't be greater than the capacity of the atlas n + start can't be greater than the capacity of the atlas
@since v1.0 @since v1.0
*/ */
void drawNumberOfQuads(int numberOfQuads, int start); void drawNumberOfQuads(long numberOfQuads, long start);
/** draws all the Atlas's Quads /** draws all the Atlas's Quads
*/ */

View File

@ -28,10 +28,10 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
const int CC_INVALID_INDEX = -1; const long CC_INVALID_INDEX = -1;
/** Allocates and initializes a new array with specified capacity */ /** Allocates and initializes a new array with specified capacity */
ccArray* ccArrayNew(int capacity) ccArray* ccArrayNew(long capacity)
{ {
if (capacity == 0) if (capacity == 0)
capacity = 7; capacity = 7;
@ -68,7 +68,7 @@ void ccArrayDoubleCapacity(ccArray *arr)
arr->arr = newArr; arr->arr = newArr;
} }
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra) void ccArrayEnsureExtraCapacity(ccArray *arr, long extra)
{ {
while (arr->max < arr->num + extra) while (arr->max < arr->num + extra)
{ {
@ -82,7 +82,7 @@ void ccArrayEnsureExtraCapacity(ccArray *arr, int extra)
void ccArrayShrink(ccArray *arr) void ccArrayShrink(ccArray *arr)
{ {
int newSize = 0; long newSize = 0;
//only resize when necessary //only resize when necessary
if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) if (arr->max > arr->num && !(arr->num==0 && arr->max==1))
@ -104,11 +104,11 @@ void ccArrayShrink(ccArray *arr)
} }
/** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */ /** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */
int ccArrayGetIndexOfObject(ccArray *arr, Object* object) long ccArrayGetIndexOfObject(ccArray *arr, Object* object)
{ {
const int arrNum = arr->num; const long arrNum = arr->num;
Object** ptr = arr->arr; Object** ptr = arr->arr;
for(int i = 0; i < arrNum; ++i, ++ptr) for(long i = 0; i < arrNum; ++i, ++ptr)
{ {
if( *ptr == object ) if( *ptr == object )
return i; return i;
@ -143,7 +143,7 @@ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object)
enough capacity. */ enough capacity. */
void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) void ccArrayAppendArray(ccArray *arr, ccArray *plusArr)
{ {
for(int i = 0; i < plusArr->num; i++) for(long i = 0; i < plusArr->num; i++)
{ {
ccArrayAppendObject(arr, plusArr->arr[i]); ccArrayAppendObject(arr, plusArr->arr[i]);
} }
@ -157,14 +157,14 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr)
} }
/** Inserts an object at index */ /** Inserts an object at index */
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index) void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index)
{ {
CCASSERT(index<=arr->num, "Invalid index. Out of bounds"); CCASSERT(index<=arr->num, "Invalid index. Out of bounds");
CCASSERT(object != NULL, "Invalid parameter!"); CCASSERT(object != NULL, "Invalid parameter!");
ccArrayEnsureExtraCapacity(arr, 1); ccArrayEnsureExtraCapacity(arr, 1);
int remaining = arr->num - index; long remaining = arr->num - index;
if( remaining > 0) if( remaining > 0)
{ {
memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining ); memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining );
@ -176,7 +176,7 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index)
} }
/** Swaps two objects */ /** Swaps two objects */
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2) void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2)
{ {
CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds"); CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds");
CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds"); CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds");
@ -198,7 +198,7 @@ void ccArrayRemoveAllObjects(ccArray *arr)
/** Removes object at specified index and pushes back all subsequent objects. /** Removes object at specified index and pushes back all subsequent objects.
Behavior undefined if index outside [0, num-1]. */ Behavior undefined if index outside [0, num-1]. */
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = true*/) void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj/* = true*/)
{ {
CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds"); CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds");
if (bReleaseObj) if (bReleaseObj)
@ -208,7 +208,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = tr
arr->num--; arr->num--;
int remaining = arr->num - index; long remaining = arr->num - index;
if(remaining>0) if(remaining>0)
{ {
memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*)); memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*));
@ -218,16 +218,16 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = tr
/** Removes object at specified index and fills the gap with the last object, /** Removes object at specified index and fills the gap with the last object,
thereby avoiding the need to push back subsequent objects. thereby avoiding the need to push back subsequent objects.
Behavior undefined if index outside [0, num-1]. */ Behavior undefined if index outside [0, num-1]. */
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index) void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index)
{ {
CC_SAFE_RELEASE(arr->arr[index]); CC_SAFE_RELEASE(arr->arr[index]);
int last = --arr->num; long last = --arr->num;
arr->arr[index] = arr->arr[last]; arr->arr[index] = arr->arr[last];
} }
void ccArrayFastRemoveObject(ccArray *arr, Object* object) void ccArrayFastRemoveObject(ccArray *arr, Object* object)
{ {
int index = ccArrayGetIndexOfObject(arr, object); long index = ccArrayGetIndexOfObject(arr, object);
if (index != CC_INVALID_INDEX) if (index != CC_INVALID_INDEX)
{ {
ccArrayFastRemoveObjectAtIndex(arr, index); ccArrayFastRemoveObjectAtIndex(arr, index);
@ -238,7 +238,7 @@ void ccArrayFastRemoveObject(ccArray *arr, Object* object)
found the function has no effect. */ found the function has no effect. */
void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true*/) void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true*/)
{ {
int index = ccArrayGetIndexOfObject(arr, object); long index = ccArrayGetIndexOfObject(arr, object);
if (index != CC_INVALID_INDEX) if (index != CC_INVALID_INDEX)
{ {
ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj);
@ -249,7 +249,7 @@ void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true
first matching instance in arr will be removed. */ first matching instance in arr will be removed. */
void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
{ {
for(int i = 0; i < minusArr->num; i++) for(long i = 0; i < minusArr->num; i++)
{ {
ccArrayRemoveObject(arr, minusArr->arr[i]); ccArrayRemoveObject(arr, minusArr->arr[i]);
} }
@ -259,8 +259,8 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
matching instances in arr will be removed. */ matching instances in arr will be removed. */
void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
{ {
int back = 0; long back = 0;
int i = 0; long i = 0;
for( i = 0; i < arr->num; i++) for( i = 0; i < arr->num; i++)
{ {
@ -282,7 +282,7 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
// #pragma mark ccCArray for Values (c structures) // #pragma mark ccCArray for Values (c structures)
/** Allocates and initializes a new C array with specified capacity */ /** Allocates and initializes a new C array with specified capacity */
ccCArray* ccCArrayNew(int capacity) ccCArray* ccCArrayNew(long capacity)
{ {
if (capacity == 0) if (capacity == 0)
{ {
@ -317,15 +317,15 @@ void ccCArrayDoubleCapacity(ccCArray *arr)
} }
/** Increases array capacity such that max >= num + extra. */ /** Increases array capacity such that max >= num + extra. */
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra) void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra)
{ {
ccArrayEnsureExtraCapacity((ccArray*)arr,extra); ccArrayEnsureExtraCapacity((ccArray*)arr,extra);
} }
/** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */ /** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) long ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
{ {
for( int i = 0; i < arr->num; i++) for(long i = 0; i < arr->num; i++)
{ {
if( arr->arr[i] == value ) if( arr->arr[i] == value )
return i; return i;
@ -340,11 +340,11 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value)
} }
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index) void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index)
{ {
CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index");
int remaining = arr->num - index; long remaining = arr->num - index;
// make sure it has enough capacity // make sure it has enough capacity
if (arr->num + 1 == arr->max) if (arr->num + 1 == arr->max)
{ {
@ -385,7 +385,7 @@ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value)
enough capacity. */ enough capacity. */
void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr)
{ {
for( int i = 0; i < plusArr->num; i++) for( long i = 0; i < plusArr->num; i++)
{ {
ccCArrayAppendValue(arr, plusArr->arr[i]); ccCArrayAppendValue(arr, plusArr->arr[i]);
} }
@ -408,9 +408,9 @@ void ccCArrayRemoveAllValues(ccCArray *arr)
Behavior undefined if index outside [0, num-1]. Behavior undefined if index outside [0, num-1].
@since v0.99.4 @since v0.99.4
*/ */
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index) void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index)
{ {
for( int last = --arr->num; index < last; index++) for( long last = --arr->num; index < last; index++)
{ {
arr->arr[index] = arr->arr[index + 1]; arr->arr[index] = arr->arr[index + 1];
} }
@ -421,9 +421,9 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index)
Behavior undefined if index outside [0, num-1]. Behavior undefined if index outside [0, num-1].
@since v0.99.4 @since v0.99.4
*/ */
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index) void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index)
{ {
int last = --arr->num; long last = --arr->num;
arr->arr[index] = arr->arr[last]; arr->arr[index] = arr->arr[last];
} }
@ -432,7 +432,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index)
*/ */
void ccCArrayRemoveValue(ccCArray *arr, void* value) void ccCArrayRemoveValue(ccCArray *arr, void* value)
{ {
int index = ccCArrayGetIndexOfValue(arr, value); long index = ccCArrayGetIndexOfValue(arr, value);
if (index != CC_INVALID_INDEX) if (index != CC_INVALID_INDEX)
{ {
ccCArrayRemoveValueAtIndex(arr, index); ccCArrayRemoveValueAtIndex(arr, index);
@ -444,7 +444,7 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value)
*/ */
void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
{ {
for(int i = 0; i < minusArr->num; i++) for(long i = 0; i < minusArr->num; i++)
{ {
ccCArrayRemoveValue(arr, minusArr->arr[i]); ccCArrayRemoveValue(arr, minusArr->arr[i]);
} }
@ -455,9 +455,9 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
*/ */
void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr)
{ {
int back = 0; long back = 0;
for(int i = 0; i < arr->num; i++) for(long i = 0; i < arr->num; i++)
{ {
if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) if( ccCArrayContainsValue(minusArr, arr->arr[i]) )
{ {

View File

@ -51,20 +51,20 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
extern const int CC_INVALID_INDEX; extern const long CC_INVALID_INDEX;
// Easy integration // Easy integration
#define CCARRAYDATA_FOREACH(__array__, __object__) \ #define CCARRAYDATA_FOREACH(__array__, __object__) \
__object__=__array__->arr[0]; for(int i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \ __object__=__array__->arr[0]; for(long i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
typedef struct _ccArray { typedef struct _ccArray {
int num, max; long num, max;
Object** arr; Object** arr;
} ccArray; } ccArray;
/** Allocates and initializes a new array with specified capacity */ /** Allocates and initializes a new array with specified capacity */
ccArray* ccArrayNew(int capacity); ccArray* ccArrayNew(long capacity);
/** Frees array after removing all remaining objects. Silently ignores nil arr. */ /** Frees array after removing all remaining objects. Silently ignores nil arr. */
void ccArrayFree(ccArray*& arr); void ccArrayFree(ccArray*& arr);
@ -73,13 +73,13 @@ void ccArrayFree(ccArray*& arr);
void ccArrayDoubleCapacity(ccArray *arr); void ccArrayDoubleCapacity(ccArray *arr);
/** Increases array capacity such that max >= num + extra. */ /** Increases array capacity such that max >= num + extra. */
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra); void ccArrayEnsureExtraCapacity(ccArray *arr, long extra);
/** shrinks the array so the memory footprint corresponds with the number of items */ /** shrinks the array so the memory footprint corresponds with the number of items */
void ccArrayShrink(ccArray *arr); void ccArrayShrink(ccArray *arr);
/** Returns index of first occurrence of object, NSNotFound if object not found. */ /** Returns index of first occurrence of object, NSNotFound if object not found. */
int ccArrayGetIndexOfObject(ccArray *arr, Object* object); long ccArrayGetIndexOfObject(ccArray *arr, Object* object);
/** Returns a Boolean value that indicates whether object is present in array. */ /** Returns a Boolean value that indicates whether object is present in array. */
bool ccArrayContainsObject(ccArray *arr, Object* object); bool ccArrayContainsObject(ccArray *arr, Object* object);
@ -98,22 +98,22 @@ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr);
void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr); void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr);
/** Inserts an object at index */ /** Inserts an object at index */
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index); void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index);
/** Swaps two objects */ /** Swaps two objects */
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2); void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2);
/** Removes all objects from arr */ /** Removes all objects from arr */
void ccArrayRemoveAllObjects(ccArray *arr); void ccArrayRemoveAllObjects(ccArray *arr);
/** Removes object at specified index and pushes back all subsequent objects. /** Removes object at specified index and pushes back all subsequent objects.
Behavior undefined if index outside [0, num-1]. */ Behavior undefined if index outside [0, num-1]. */
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj = true); void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj = true);
/** Removes object at specified index and fills the gap with the last object, /** Removes object at specified index and fills the gap with the last object,
thereby avoiding the need to push back subsequent objects. thereby avoiding the need to push back subsequent objects.
Behavior undefined if index outside [0, num-1]. */ Behavior undefined if index outside [0, num-1]. */
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index); void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index);
void ccArrayFastRemoveObject(ccArray *arr, Object* object); void ccArrayFastRemoveObject(ccArray *arr, Object* object);
@ -133,12 +133,12 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr);
// #pragma mark ccCArray for Values (c structures) // #pragma mark ccCArray for Values (c structures)
typedef struct _ccCArray { typedef struct _ccCArray {
int num, max; long num, max;
void** arr; void** arr;
} ccCArray; } ccCArray;
/** Allocates and initializes a new C array with specified capacity */ /** Allocates and initializes a new C array with specified capacity */
ccCArray* ccCArrayNew(int capacity); ccCArray* ccCArrayNew(long capacity);
/** Frees C array after removing all remaining values. Silently ignores nil arr. */ /** Frees C array after removing all remaining values. Silently ignores nil arr. */
void ccCArrayFree(ccCArray *arr); void ccCArrayFree(ccCArray *arr);
@ -147,16 +147,16 @@ void ccCArrayFree(ccCArray *arr);
void ccCArrayDoubleCapacity(ccCArray *arr); void ccCArrayDoubleCapacity(ccCArray *arr);
/** Increases array capacity such that max >= num + extra. */ /** Increases array capacity such that max >= num + extra. */
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra); void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra);
/** Returns index of first occurrence of value, NSNotFound if value not found. */ /** Returns index of first occurrence of value, NSNotFound if value not found. */
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value); long ccCArrayGetIndexOfValue(ccCArray *arr, void* value);
/** Returns a Boolean value that indicates whether value is present in the C array. */ /** Returns a Boolean value that indicates whether value is present in the C array. */
bool ccCArrayContainsValue(ccCArray *arr, void* value); bool ccCArrayContainsValue(ccCArray *arr, void* value);
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index); void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index);
/** Appends an value. Behavior undefined if array doesn't have enough capacity. */ /** Appends an value. Behavior undefined if array doesn't have enough capacity. */
void ccCArrayAppendValue(ccCArray *arr, void* value); void ccCArrayAppendValue(ccCArray *arr, void* value);
@ -178,14 +178,14 @@ void ccCArrayRemoveAllValues(ccCArray *arr);
Behavior undefined if index outside [0, num-1]. Behavior undefined if index outside [0, num-1].
@since v0.99.4 @since v0.99.4
*/ */
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index); void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index);
/** Removes value at specified index and fills the gap with the last value, /** Removes value at specified index and fills the gap with the last value,
thereby avoiding the need to push back subsequent values. thereby avoiding the need to push back subsequent values.
Behavior undefined if index outside [0, num-1]. Behavior undefined if index outside [0, num-1].
@since v0.99.4 @since v0.99.4
*/ */
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index); void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index);
/** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. /** Searches for the first occurrence of value and removes it. If value is not found the function has no effect.
@since v0.99.4 @since v0.99.4

View File

@ -12,7 +12,7 @@ namespace {
static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL }; static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL };
static unsigned int g_indexBitsUsed = 0; static unsigned int g_indexBitsUsed = 0;
// System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0 // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0
static std::map<int, int> g_touchIdReorderMap; static std::map<long, int> g_touchIdReorderMap;
static int getUnUsedIndex() static int getUnUsedIndex()
{ {
@ -201,9 +201,9 @@ const char* EGLViewProtocol::getViewName()
return _viewName; return _viewName;
} }
void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesBegin(int num, long ids[], float xs[], float ys[])
{ {
int id = 0; long id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
int nUnusedIndex = 0; int nUnusedIndex = 0;
@ -251,9 +251,9 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesMove(int num, long ids[], float xs[], float ys[])
{ {
int id = 0; long id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
EventTouch touchEvent; EventTouch touchEvent;
@ -283,7 +283,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
else else
{ {
// It is error, should return. // It is error, should return.
CCLOG("Moving touches with id: %d error", id); CCLOG("Moving touches with id: %ld error", id);
return; return;
} }
} }
@ -299,9 +299,9 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[])
{ {
int id = 0; long id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
EventTouch touchEvent; EventTouch touchEvent;
@ -336,7 +336,7 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
} }
else else
{ {
CCLOG("Ending touches with id: %d error", id); CCLOG("Ending touches with id: %ld error", id);
return; return;
} }
@ -359,12 +359,12 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
} }
} }
void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesEnd(int num, long ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
} }
void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesCancel(int num, long ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
} }

View File

@ -136,10 +136,10 @@ public:
const char* getViewName(); const char* getViewName();
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */ /** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesBegin(int num, long ids[], float xs[], float ys[]);
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesMove(int num, long ids[], float xs[], float ys[]);
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesEnd(int num, long ids[], float xs[], float ys[]);
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesCancel(int num, long ids[], float xs[], float ys[]);
/** /**
* Get the opengl view port rectangle. * Get the opengl view port rectangle.
@ -156,7 +156,7 @@ public:
*/ */
float getScaleY() const; float getScaleY() const;
private: private:
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]); void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[]);
protected: protected:
EGLTouchDelegate* _delegate; EGLTouchDelegate* _delegate;

View File

@ -451,7 +451,7 @@ NS_CC_BEGIN
/* The subclass FileUtilsApple should override these two method. */ /* The subclass FileUtilsApple should override these two method. */
Dictionary* FileUtils::createDictionaryWithContentsOfFile(const std::string& filename) {return NULL;} Dictionary* FileUtils::createDictionaryWithContentsOfFile(const std::string& filename) {return NULL;}
bool FileUtils::writeToFile(cocos2d::Dictionary *dict, const std::string &fullPath) {return NULL;} bool FileUtils::writeToFile(cocos2d::Dictionary *dict, const std::string &fullPath) {return false;}
Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {return NULL;} Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {return NULL;}
#endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */ #endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */

View File

@ -75,7 +75,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
#define IOS_MAX_TOUCHES_COUNT 10 #define IOS_MAX_TOUCHES_COUNT 10
static CCEAGLView *view = 0; static CCEAGLView *__view = 0;
@interface CCEAGLView (Private) @interface CCEAGLView (Private)
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; - (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
@ -117,7 +117,7 @@ static CCEAGLView *view = 0;
+ (id) sharedEGLView + (id) sharedEGLView
{ {
return view; return __view;
} }
- (id) initWithFrame:(CGRect)frame - (id) initWithFrame:(CGRect)frame
@ -147,14 +147,14 @@ static CCEAGLView *view = 0;
} }
view = self; __view = self;
originalRect_ = self.frame; originalRect_ = self.frame;
self.keyboardShowNotification = nil; self.keyboardShowNotification = nil;
if ([view respondsToSelector:@selector(setContentScaleFactor:)]) if ([__view respondsToSelector:@selector(setContentScaleFactor:)])
{ {
view.contentScaleFactor = [[UIScreen mainScreen] scale]; __view.contentScaleFactor = [[UIScreen mainScreen] scale];
} }
} }
@ -180,7 +180,7 @@ static CCEAGLView *view = 0;
} }
} }
view = self; __view = self;
return self; return self;
} }
@ -205,13 +205,13 @@ static CCEAGLView *view = 0;
-(int) getWidth -(int) getWidth
{ {
CGSize bound = [self bounds].size; CGSize bound = [self bounds].size;
return bound.width * self.contentScaleFactor; return (int)bound.width * self.contentScaleFactor;
} }
-(int) getHeight -(int) getHeight
{ {
CGSize bound = [self bounds].size; CGSize bound = [self bounds].size;
return bound.height * self.contentScaleFactor; return (int)bound.height * self.contentScaleFactor;
} }
@ -399,18 +399,18 @@ static CCEAGLView *view = 0;
return; return;
} }
int ids[IOS_MAX_TOUCHES_COUNT] = {0}; UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = (int)touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, ids, xs, ys); cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (long*)ids, xs, ys);
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
@ -419,18 +419,18 @@ static CCEAGLView *view = 0;
{ {
return; return;
} }
int ids[IOS_MAX_TOUCHES_COUNT] = {0}; UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = (int)touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesMove(i, ids, xs, ys); cocos2d::EGLView::getInstance()->handleTouchesMove(i, (long*)ids, xs, ys);
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
@ -440,18 +440,18 @@ static CCEAGLView *view = 0;
return; return;
} }
int ids[IOS_MAX_TOUCHES_COUNT] = {0}; UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = (int)touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, ids, xs, ys); cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (long*)ids, xs, ys);
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
@ -461,18 +461,18 @@ static CCEAGLView *view = 0;
return; return;
} }
int ids[IOS_MAX_TOUCHES_COUNT] = {0}; UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = (int)touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, ids, xs, ys); cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (long*)ids, xs, ys);
} }
#pragma mark - #pragma mark -

View File

@ -186,7 +186,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = true; s_captured = true;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -195,7 +195,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = false; s_captured = false;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -231,7 +231,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
{ {
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
} }
} }

View File

@ -202,7 +202,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = true; s_captured = true;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -211,7 +211,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = false; s_captured = false;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -249,7 +249,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
{ {
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
} }
} }

View File

@ -327,7 +327,7 @@ static CCEAGLView *view;
float x = local_point.x; float x = local_point.x;
float y = [self getHeight] - local_point.y; float y = [self getHeight] - local_point.y;
int ids[1] = {0}; NSInteger ids[1] = {0};
float xs[1] = {0.0f}; float xs[1] = {0.0f};
float ys[1] = {0.0f}; float ys[1] = {0.0f};
@ -335,7 +335,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_; xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_; ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (long*)ids, xs, ys);
} }
- (void)mouseMoved:(NSEvent *)theEvent - (void)mouseMoved:(NSEvent *)theEvent
@ -351,7 +351,7 @@ static CCEAGLView *view;
float x = local_point.x; float x = local_point.x;
float y = [self getHeight] - local_point.y; float y = [self getHeight] - local_point.y;
int ids[1] = {0}; NSInteger ids[1] = {0};
float xs[1] = {0.0f}; float xs[1] = {0.0f};
float ys[1] = {0.0f}; float ys[1] = {0.0f};
@ -359,7 +359,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_; xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_; ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (long*)ids, xs, ys);
} }
- (void)mouseUp:(NSEvent *)theEvent - (void)mouseUp:(NSEvent *)theEvent
@ -370,7 +370,7 @@ static CCEAGLView *view;
float x = local_point.x; float x = local_point.x;
float y = [self getHeight] - local_point.y; float y = [self getHeight] - local_point.y;
int ids[1] = {0}; NSInteger ids[1] = {0};
float xs[1] = {0.0f}; float xs[1] = {0.0f};
float ys[1] = {0.0f}; float ys[1] = {0.0f};
@ -378,7 +378,7 @@ static CCEAGLView *view;
xs[0] = x / frameZoomFactor_; xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_; ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (long*)ids, xs, ys);
} }
- (void)rightMouseDown:(NSEvent *)theEvent { - (void)rightMouseDown:(NSEvent *)theEvent {

View File

@ -303,7 +303,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = true; s_captured = true;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -312,7 +312,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
s_captured = false; s_captured = false;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
} }
} }
@ -348,7 +348,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
{ {
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY))) if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{ {
int id = 0; long id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY); eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
} }
} }

View File

@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray)
return otherArray->clone(); return otherArray->clone();
} }
Array* Array::createWithCapacity(int capacity) Array* Array::createWithCapacity(long capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...)
return ret; return ret;
} }
bool Array::initWithCapacity(int capacity) bool Array::initWithCapacity(long capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
@ -200,7 +200,7 @@ int Array::getIndexOfObject(Object* object) const
{ {
auto it = data.begin(); auto it = data.begin();
for (int i = 0; it != data.end(); ++it, ++i) for (long i = 0; it != data.end(); ++it, ++i)
{ {
if (it->get() == object) if (it->get() == object)
{ {
@ -238,7 +238,7 @@ bool Array::containsObject(Object* object) const
bool Array::isEqualToArray(Array* otherArray) bool Array::isEqualToArray(Array* otherArray)
{ {
for (int i = 0; i< this->count(); i++) for (long i = 0; i< this->count(); i++)
{ {
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
{ {
@ -279,7 +279,7 @@ void Array::removeObject(Object* object, bool releaseObj /* ignored */)
data.erase( std::remove( data.begin(), data.end(), object ) ); data.erase( std::remove( data.begin(), data.end(), object ) );
} }
void Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */) void Array::removeObjectAtIndex(long index, bool releaseObj /* ignored */)
{ {
auto obj = data[index]; auto obj = data[index];
data.erase( data.begin() + index ); data.erase( data.begin() + index );
@ -295,7 +295,7 @@ void Array::removeAllObjects()
data.erase(std::begin(data), std::end(data)); data.erase(std::begin(data), std::end(data));
} }
void Array::fastRemoveObjectAtIndex(int index) void Array::fastRemoveObjectAtIndex(long index)
{ {
removeObjectAtIndex(index); removeObjectAtIndex(index);
} }
@ -315,12 +315,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
std::swap( data[idx1], data[idx2] ); std::swap( data[idx1], data[idx2] );
} }
void Array::exchangeObjectAtIndex(int index1, int index2) void Array::exchangeObjectAtIndex(long index1, long index2)
{ {
std::swap( data[index1], data[index2] ); std::swap( data[index1], data[index2] );
} }
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */) void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject /* ignored */)
{ {
data[index] = object; data[index] = object;
} }
@ -448,7 +448,7 @@ Array* Array::createWithArray(Array* otherArray)
return otherArray->clone(); return otherArray->clone();
} }
Array* Array::createWithCapacity(int capacity) Array* Array::createWithCapacity(long capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
@ -531,7 +531,7 @@ bool Array::initWithObjects(Object* object, ...)
return ret; return ret;
} }
bool Array::initWithCapacity(int capacity) bool Array::initWithCapacity(long capacity)
{ {
CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized"); CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized");
@ -555,7 +555,7 @@ bool Array::initWithArray(Array* otherArray)
return ret; return ret;
} }
int Array::getIndexOfObject(Object* object) const long Array::getIndexOfObject(Object* object) const
{ {
return ccArrayGetIndexOfObject(data, object); return ccArrayGetIndexOfObject(data, object);
} }
@ -574,7 +574,7 @@ Object* Array::getRandomObject()
r = 0; r = 0;
} }
return data->arr[(int)(data->num * r)]; return data->arr[(long)(data->num * r)];
} }
bool Array::containsObject(Object* object) const bool Array::containsObject(Object* object) const
@ -584,7 +584,7 @@ bool Array::containsObject(Object* object) const
bool Array::isEqualToArray(Array* otherArray) bool Array::isEqualToArray(Array* otherArray)
{ {
for (int i = 0; i< this->count(); i++) for (long i = 0; i< this->count(); i++)
{ {
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
{ {
@ -606,13 +606,13 @@ void Array::addObjectsFromArray(Array* otherArray)
ccArrayAppendArrayWithResize(data, otherArray->data); ccArrayAppendArrayWithResize(data, otherArray->data);
} }
void Array::insertObject(Object* object, int index) void Array::insertObject(Object* object, long index)
{ {
CCASSERT(data, "Array not initialized"); CCASSERT(data, "Array not initialized");
ccArrayInsertObjectAtIndex(data, object, index); ccArrayInsertObjectAtIndex(data, object, index);
} }
void Array::setObject(Object* object, int index) void Array::setObject(Object* object, long index)
{ {
CCASSERT(index>=0 && index < count(), "Invalid index"); CCASSERT(index>=0 && index < count(), "Invalid index");
@ -635,7 +635,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/)
ccArrayRemoveObject(data, object, releaseObj); ccArrayRemoveObject(data, object, releaseObj);
} }
void Array::removeObjectAtIndex(int index, bool releaseObj) void Array::removeObjectAtIndex(long index, bool releaseObj)
{ {
ccArrayRemoveObjectAtIndex(data, index, releaseObj); ccArrayRemoveObjectAtIndex(data, index, releaseObj);
} }
@ -650,7 +650,7 @@ void Array::removeAllObjects()
ccArrayRemoveAllObjects(data); ccArrayRemoveAllObjects(data);
} }
void Array::fastRemoveObjectAtIndex(int index) void Array::fastRemoveObjectAtIndex(long index)
{ {
ccArrayFastRemoveObjectAtIndex(data, index); ccArrayFastRemoveObjectAtIndex(data, index);
} }
@ -662,14 +662,14 @@ void Array::fastRemoveObject(Object* object)
void Array::exchangeObject(Object* object1, Object* object2) void Array::exchangeObject(Object* object1, Object* object2)
{ {
int index1 = ccArrayGetIndexOfObject(data, object1); long index1 = ccArrayGetIndexOfObject(data, object1);
if (index1 == UINT_MAX) if (index1 == CC_INVALID_INDEX)
{ {
return; return;
} }
int index2 = ccArrayGetIndexOfObject(data, object2); long index2 = ccArrayGetIndexOfObject(data, object2);
if (index2 == UINT_MAX) if (index2 == CC_INVALID_INDEX)
{ {
return; return;
} }
@ -677,12 +677,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
ccArraySwapObjectsAtIndexes(data, index1, index2); ccArraySwapObjectsAtIndexes(data, index1, index2);
} }
void Array::exchangeObjectAtIndex(int index1, int index2) void Array::exchangeObjectAtIndex(long index1, long index2)
{ {
ccArraySwapObjectsAtIndexes(data, index1, index2); ccArraySwapObjectsAtIndexes(data, index1, index2);
} }
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/) void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject/* = true*/)
{ {
ccArrayInsertObjectAtIndex(data, object, index); ccArrayInsertObjectAtIndex(data, object, index);
ccArrayRemoveObjectAtIndex(data, index+1); ccArrayRemoveObjectAtIndex(data, index+1);
@ -693,10 +693,10 @@ void Array::reverseObjects()
if (data->num > 1) if (data->num > 1)
{ {
// floorf(), since in the case of an even number, the number of swaps stays the same // floorf(), since in the case of an even number, the number of swaps stays the same
int count = (int) floorf(data->num/2.f); long count = (long) floorf(data->num/2.f);
int maxIndex = data->num - 1; long maxIndex = data->num - 1;
for (int i = 0; i < count ; i++) for (long i = 0; i < count ; i++)
{ {
ccArraySwapObjectsAtIndexes(data, i, maxIndex); ccArraySwapObjectsAtIndexes(data, i, maxIndex);
--maxIndex; --maxIndex;

View File

@ -250,7 +250,7 @@ public:
/** Create an array with a default capacity /** Create an array with a default capacity
* @js NA * @js NA
*/ */
static Array* createWithCapacity(int capacity); static Array* createWithCapacity(long capacity);
/** Create an array with from an existing array /** Create an array with from an existing array
* @js NA * @js NA
*/ */
@ -295,7 +295,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
bool initWithCapacity(int capacity); bool initWithCapacity(long capacity);
/** Initializes an array with an existing array /** Initializes an array with an existing array
* @js NA * @js NA
* @lua NA * @lua NA
@ -307,7 +307,7 @@ public:
/** Returns element count of the array /** Returns element count of the array
* @js NA * @js NA
*/ */
int count() const long count() const
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
return data.size(); return data.size();
@ -318,7 +318,7 @@ public:
/** Returns capacity of the array /** Returns capacity of the array
* @js NA * @js NA
*/ */
int capacity() const long capacity() const
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
return data.capacity(); return data.capacity();
@ -330,17 +330,17 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
int getIndexOfObject(Object* object) const; long getIndexOfObject(Object* object) const;
/** /**
* @js NA * @js NA
*/ */
CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); } CC_DEPRECATED_ATTRIBUTE long indexOfObject(Object* object) const { return getIndexOfObject(object); }
/** Returns an element with a certain index /** Returns an element with a certain index
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Object* getObjectAtIndex(int index) Object* getObjectAtIndex(long index)
{ {
CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()");
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -349,7 +349,7 @@ public:
return data->arr[index]; return data->arr[index];
#endif #endif
} }
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); } CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(long index) { return getObjectAtIndex(index); }
/** Returns the last element of the array /** Returns the last element of the array
* @js NA * @js NA
*/ */
@ -401,17 +401,17 @@ public:
/** Insert a certain object at a certain index /** Insert a certain object at a certain index
* @js NA * @js NA
*/ */
void insertObject(Object* object, int index); void insertObject(Object* object, long index);
/** sets a certain object at a certain index /** sets a certain object at a certain index
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void setObject(Object* object, int index); void setObject(Object* object, long index);
/** sets a certain object at a certain index without retaining. Use it with caution /** sets a certain object at a certain index without retaining. Use it with caution
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void fastSetObject(Object* object, int index) void fastSetObject(Object* object, long index)
{ {
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
setObject(object, index); setObject(object, index);
@ -424,7 +424,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void swap( int indexOne, int indexTwo ) void swap( long indexOne, long indexTwo )
{ {
CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices");
#if CC_USE_ARRAY_VECTOR #if CC_USE_ARRAY_VECTOR
@ -447,7 +447,7 @@ public:
/** Remove an element with a certain index /** Remove an element with a certain index
* @js NA * @js NA
*/ */
void removeObjectAtIndex(int index, bool releaseObj = true); void removeObjectAtIndex(long index, bool releaseObj = true);
/** Remove all elements /** Remove all elements
* @js NA * @js NA
*/ */
@ -463,7 +463,7 @@ public:
/** Fast way to remove an element with a certain index /** Fast way to remove an element with a certain index
* @js NA * @js NA
*/ */
void fastRemoveObjectAtIndex(int index); void fastRemoveObjectAtIndex(long index);
// Rearranging Content // Rearranging Content
@ -474,12 +474,12 @@ public:
/** Swap two elements with certain indexes /** Swap two elements with certain indexes
* @js NA * @js NA
*/ */
void exchangeObjectAtIndex(int index1, int index2); void exchangeObjectAtIndex(long index1, long index2);
/** Replace object at index with another object. /** Replace object at index with another object.
* @js NA * @js NA
*/ */
void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true); void replaceObjectAtIndex(long index, Object* object, bool releaseObject = true);
/** Revers the array /** Revers the array
* @js NA * @js NA

View File

@ -424,7 +424,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
bool bFindFrame = false; bool bFindFrame = false;
ActionFrame* srcFrame = NULL; ActionFrame* srcFrame = NULL;
ActionFrame* destFrame = NULL; // ActionFrame* destFrame = NULL;
for (int n = 0; n < _frameArrayNum; n++) for (int n = 0; n < _frameArrayNum; n++)
{ {

View File

@ -216,7 +216,7 @@ kmMat4* const kmMat4Transpose(kmMat4* pOut, const kmMat4* pIn)
*/ */
kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2) kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2)
{ {
#if defined(__ARM_NEON__) #if defined(__ARM_NEON__) && !defined(__arm64__)
// It is possible to skip the memcpy() since "out" does not overwrite p1 or p2. // It is possible to skip the memcpy() since "out" does not overwrite p1 or p2.
// otherwise a temp must be needed. // otherwise a temp must be needed.

View File

@ -23,7 +23,8 @@
#include "kazmath/neon_matrix_impl.h" #include "kazmath/neon_matrix_impl.h"
#if defined(__ARM_NEON__) #if defined(__ARM_NEON__) && !defined(__arm64__)
void NEON_Matrix4Mul(const float* a, const float* b, float* output ) void NEON_Matrix4Mul(const float* a, const float* b, float* output )
{ {

View File

@ -600,7 +600,7 @@ Point* PhysicsShapePolygon::getPoints(Point* points) const
return PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts); return PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts);
} }
int PhysicsShapePolygon::getPointsCount() const long PhysicsShapePolygon::getPointsCount() const
{ {
return ((cpPolyShape*)_info->shapes.front())->numVerts; return ((cpPolyShape*)_info->shapes.front())->numVerts;
} }
@ -715,7 +715,7 @@ Point PhysicsShapeEdgePolygon::getCenter()
return _center; return _center;
} }
int PhysicsShapeEdgePolygon::getPointsCount() const long PhysicsShapeEdgePolygon::getPointsCount() const
{ {
return _info->shapes.size() + 1; return _info->shapes.size() + 1;
} }
@ -776,7 +776,7 @@ Point PhysicsShapeEdgeChain::getCenter()
return _center; return _center;
} }
int PhysicsShapeEdgeChain::getPointsCount() const long PhysicsShapeEdgeChain::getPointsCount() const
{ {
return _info->shapes.size() + 1; return _info->shapes.size() + 1;
} }

View File

@ -50,10 +50,10 @@ typedef struct PhysicsMaterial
, friction(0.0f) , friction(0.0f)
{} {}
PhysicsMaterial(float density, float restitution, float friction) PhysicsMaterial(float aDensity, float aRestitution, float aFriction)
: density(density) : density(aDensity)
, restitution(restitution) , restitution(aRestitution)
, friction(friction) , friction(aFriction)
{} {}
}PhysicsMaterial; }PhysicsMaterial;
@ -204,7 +204,7 @@ public:
float calculateDefaultMoment() override; float calculateDefaultMoment() override;
Point* getPoints(Point* points) const; Point* getPoints(Point* points) const;
int getPointsCount() const; long getPointsCount() const;
Point getCenter() override; Point getCenter() override;
protected: protected:
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0)); bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0));
@ -247,7 +247,7 @@ public:
static PhysicsShapeEdgeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, Point offset = Point(0, 0)); static PhysicsShapeEdgeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, Point offset = Point(0, 0));
Point getOffset() override { return _offset; } Point getOffset() override { return _offset; }
Point* getPoints(Point* points) const; Point* getPoints(Point* points) const;
int getPointsCount() const; long getPointsCount() const;
protected: protected:
bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, Point offset = Point(0, 0)); bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, Point offset = Point(0, 0));
@ -269,7 +269,7 @@ public:
static PhysicsShapeEdgePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); static PhysicsShapeEdgePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
Point getCenter() override; Point getCenter() override;
Point* getPoints(Point* points) const; Point* getPoints(Point* points) const;
int getPointsCount() const; long getPointsCount() const;
protected: protected:
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
@ -291,7 +291,7 @@ public:
static PhysicsShapeEdgeChain* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); static PhysicsShapeEdgeChain* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
Point getCenter() override; Point getCenter() override;
Point* getPoints(Point* points) const; Point* getPoints(Point* points) const;
int getPointsCount() const; long getPointsCount() const;
protected: protected:
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);

View File

@ -465,9 +465,9 @@ void PhysicsWorld::debugDraw()
} }
} }
void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joint) void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joints)
{ {
for (auto it = joint->_info->joints.begin(); it != joint->_info->joints.end(); ++it) for (auto it = joints->_info->joints.begin(); it != joints->_info->joints.end(); ++it)
{ {
cpConstraint *constraint = *it; cpConstraint *constraint = *it;
@ -526,9 +526,9 @@ void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joint)
} }
} }
void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shapes)
{ {
for (auto it = shape->_info->shapes.begin(); it != shape->_info->shapes.end(); ++it) for (auto it = shapes->_info->shapes.begin(); it != shapes->_info->shapes.end(); ++it)
{ {
cpShape *shape = *it; cpShape *shape = *it;

View File

@ -153,7 +153,7 @@
#endif #endif
/* The size of `long', as computed by sizeof. */ /* The size of `long', as computed by sizeof. */
#define CURL_SIZEOF_LONG 4 #define CURL_SIZEOF_LONG sizeof(long)
/* Integral data type used for curl_socklen_t. */ /* Integral data type used for curl_socklen_t. */
#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t #define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t