Merge pull request #1231 from donaldalanmorrison/gles20

Gles20
This commit is contained in:
minggo 2012-08-26 20:17:40 -07:00
commit c7d365ca1c
11 changed files with 36 additions and 37 deletions

2
.gitignore vendored
View File

@ -27,6 +27,8 @@ obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
ipch/
*.opensdf
# Ignore files build by ndk and eclipse
libs/

View File

@ -119,9 +119,7 @@ void calculate_line_normal(kmVec2 p1, kmVec2 p2, kmVec2* normal_out) {
kmBool kmRay2IntersectTriangle(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, const kmVec2* p3, kmVec2* intersection, kmVec2* normal_out) {
kmVec2 intersect;
kmVec2 final_intersect;
kmVec2 normal;
//kmVec2 final_intersect = {.x = 0, .y = 0}, normal = {.x = 0, .y = 0}; // Silencing LLVM SA
kmVec2 final_intersect = {0., 0.}, normal = {0., 0.}; // Silencing LLVM SA.
kmScalar distance = 10000.0f;
kmBool intersected = KM_FALSE;

View File

@ -235,7 +235,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
CGContextRelease(context);
return true;
}
// TODO: rename _initWithImage, it also makes a draw call.
static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double scaleX, double scaleY)
{
NSUInteger POTWide, POTHigh;
@ -258,10 +258,8 @@ static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double sc
}
// always load premultiplied images
_initPremultipliedATextureWithImage(CGImage, POTWide, POTHigh, pImageinfo);
return true;
// load and draw image
return _initPremultipliedATextureWithImage(CGImage, POTWide, POTHigh, pImageinfo);
}
static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
@ -277,17 +275,19 @@ static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
jpg = [[NSImage alloc] initWithContentsOfFile: fullPath];
//png = [[NSImage alloc] initWithData:UIImagePNGRepresentation(jpg)];
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)[jpg TIFFRepresentation], NULL);
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
ret = _initWithImage(CGImage, pImageinfo, 1.0, 1.0);
//[png release];
[jpg release];
if (CGImage) CFRelease(CGImage);
if (source) CFRelease(source);
return ret;
}
// TODO: rename _initWithData, it also makes a draw call.
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, double scaleX, double scaleY)
{
bool ret = false;
@ -302,8 +302,9 @@ static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, do
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
ret = _initWithImage(CGImage, pImageinfo, scaleX, scaleY);
if (CGImage) CFRelease(CGImage);
if (source) CFRelease(source);
}
return ret;
}
@ -462,21 +463,19 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
NSUInteger textureSize = POTWide*POTHigh*4;
unsigned char* dataNew = new unsigned char[textureSize];
CC_BREAK_IF(!dataNew);
memcpy(dataNew, data, textureSize);
if (dataNew) {
memcpy(dataNew, data, textureSize);
// output params
pInfo->width = POTWide;
pInfo->height = POTHigh;
pInfo->data = dataNew;
pInfo->hasAlpha = true;
pInfo->isPremultipliedAlpha = true;
pInfo->bitsPerComponent = 8;
bRet = true;
}
[bitmap release];
[image release];
// output params
pInfo->width = POTWide;
pInfo->height = POTHigh;
pInfo->data = dataNew;
pInfo->hasAlpha = true;
pInfo->isPremultipliedAlpha = true;
pInfo->bitsPerComponent = 8;
bRet = true;
[image release];
} while (0);
return bRet;
}

View File

@ -196,10 +196,10 @@ int CCBReader::readInt(bool pSigned) {
long long current = 0;
for(int a = numBits - 1; a >= 0; a--) {
if(this->getBit()) {
current |= 1 << a;
current |= 1LL << a;
}
}
current |= 1 << numBits;
current |= 1LL << numBits;
int num;
if(pSigned) {

View File

@ -876,7 +876,7 @@ std::string ActionCallFuncND::subtitle()
void ActionCallFuncND::removeFromParentAndCleanup(CCNode* pSender, void* data)
{
bool bCleanUp = (bool)data;
bool bCleanUp = data != NULL;
m_grossini->removeFromParentAndCleanup(bCleanUp);
}

View File

@ -168,7 +168,7 @@ void HttpClientTest::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
// dump data
std::vector<char> *buffer = response->getResponseData();
printf("Http Test, dump data: ");
for (int i = 0; i < buffer->size(); i++)
for (unsigned int i = 0; i < buffer->size(); i++)
{
printf("%c", (*buffer)[i]);
}

View File

@ -230,7 +230,7 @@ bool ScriptingCore::evalString(const char *string, jsval *outVal)
CCLog("error evaluating script:\n%s", string);
}
str = JS_ValueToString(cx, rval);
return ok;
return ok!=0;
}
void ScriptingCore::runScript(const char *path)

View File

@ -1 +1 @@
c3a4fa7cf2bdc8ce0bd3cbd98b7829bcdd253a2e
092a4fc2dae615c23d2a1b327c514193718f8a93

View File

@ -75,7 +75,7 @@ JSBool S_CCSequence::jsactions(JSContext *cx, uint32_t argc, jsval *vp) {
// get first element
S_CCSequence* prev;
JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0]));
for (int i=1; i < argc; i++) {
for (unsigned int i=1; i < argc; i++) {
CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i]));
prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next);
}

View File

@ -160,7 +160,7 @@ JSBool S_SimpleAudioEngine::jsplayBackgroundMusic(JSContext *cx, uint32_t argc,
JSBool arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "Sb", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
self->playBackgroundMusic(narg0, arg1);
self->playBackgroundMusic(narg0, arg1!=0);
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
@ -175,7 +175,7 @@ JSBool S_SimpleAudioEngine::jsstopBackgroundMusic(JSContext *cx, uint32_t argc,
if (argc == 1) {
JSBool arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "b", &arg0);
self->stopBackgroundMusic(arg0);
self->stopBackgroundMusic(arg0!=0);
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
@ -262,7 +262,7 @@ JSBool S_SimpleAudioEngine::jsplayEffect(JSContext *cx, uint32_t argc, jsval *vp
JSBool arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "Sb", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
unsigned int ret = self->playEffect(narg0, arg1);
unsigned int ret = self->playEffect(narg0, arg1!=0);
do { jsval tmp; JS_NewNumberValue(cx, ret, &tmp); JS_SET_RVAL(cx, vp, tmp); } while (0);
return JS_TRUE;

View File

@ -116,7 +116,7 @@ TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err)
}
/* the equivalent of lua_is* for usertable */
static int lua_isusertable (lua_State* L, int lo, const const char* type)
static int lua_isusertable (lua_State* L, int lo, const char* type)
{
int r = 0;
if (lo < 0) lo = lua_gettop(L)+lo+1;