Merge branch 'newlines_in_cclog' of https://github.com/sbc100/cocos2d-x into sbc100-newlines_in_cclog

Conflicts:
	cocos2dx/proj.linux/cocos2dx.mk
This commit is contained in:
James Chen 2013-04-10 14:17:23 +08:00
commit 32406efec2
14 changed files with 131 additions and 103 deletions

View File

@ -33,17 +33,25 @@ void CCLog(const char * pszFormat, ...)
char buf[MAX_LEN];
va_list args;
va_start(args, pszFormat);
va_start(args, pszFormat);
vsnprintf(buf, MAX_LEN, pszFormat, args);
va_end(args);
fprintf(stderr, "cocos2d-x debug info %s\n", buf);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info %s\n", buf);
}
void CCMessageBox(const char * pszMsg, const char * pszTitle)
{
// MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
CCLog(pszMsg);
//MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
CCLog(pszMsg);
}
void CCLuaLog(const char * pszFormat)
@ -52,4 +60,3 @@ void CCLuaLog(const char * pszFormat)
}
NS_CC_END

View File

@ -259,12 +259,12 @@ public:
return false;
}
do {
//CCLog("\n\n ---- FT_New_Face with pFontName = %s\n", pFontName);
//CCLog(" ---- FT_New_Face with pFontName = %s", pFontName);
iError = FT_New_Face( library, pFontName, 0, &face );
if (iError) {
//no valid font found use default
//CCLog("\n\n ---- no valid font, use default %s\n", pFontName);
//CCLog(" ---- no valid font, use default %s", pFontName);
iError = FT_New_Face( library, "/usr/fonts/font_repository/monotype/arial.ttf", 0, &face );
}
CC_BREAK_IF(iError);
@ -418,7 +418,7 @@ bool CCImage::initWithString(
//CCLog("-----pText=%s and Font File is %s nWidth= %d,nHeight=%d",pText,fullFontName.c_str(),nWidth,nHeight);
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, fullFontName.c_str(), nSize));
//CCLog("---- dc.getBitmap is Succesfull... \n");
//CCLog("---- dc.getBitmap is Succesfull...");
// assign the dc.m_pData to m_pData in order to save time
m_pData = dc.m_pData;

View File

@ -34,15 +34,23 @@ void CCLog(const char * pszFormat, ...)
va_list ap;
va_start(ap, pszFormat);
vsnprintf( szBuf, MAX_LEN, pszFormat, ap);
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
}
void CCMessageBox(const char * pszMsg, const char * pszTitle)
{
CCLog("%s: %s", pszTitle, pszMsg);
CCLog("%s: %s", pszTitle, pszMsg);
}
void CCLuaLog(const char * pszFormat)
@ -51,4 +59,3 @@ void CCLuaLog(const char * pszFormat)
}
NS_CC_END

View File

@ -305,20 +305,20 @@ bool CCEGLView::initGL()
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
{
CCLog("Ready for GLSL\n");
CCLog("Ready for GLSL");
}
else
{
CCLog("Not totally ready :( \n");
CCLog("Not totally ready :(");
}
if (glewIsSupported("GL_VERSION_2_0"))
{
CCLog("Ready for OpenGL 2.0\n");
CCLog("Ready for OpenGL 2.0");
}
else
{
CCLog("OpenGL 2.0 not supported\n");
CCLog("OpenGL 2.0 not supported");
}
// Enable point size by default on linux.

View File

@ -61,7 +61,7 @@ void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
{
if (s3eAccelerometerStart() != S3E_RESULT_SUCCESS)
{
CCLog("s3eAccelerometerStart() - ERROR\n");
CCLog("s3eAccelerometerStart() - ERROR");
}
}
else

View File

@ -38,12 +38,20 @@ void CCLog(const char * pszFormat, ...)
vsnprintf( szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
}
void CCMessageBox(const char * pszMsg, const char * pszTitle)
{
CCLog("%s: %s", pszTitle, pszMsg);
CCLog("%s: %s", pszTitle, pszMsg);
}
void CCLuaLog(const char * pszFormat)
@ -52,4 +60,3 @@ void CCLuaLog(const char * pszFormat)
}
NS_CC_END

View File

@ -383,7 +383,7 @@ bool BitmapDC::getBitmap( const char *text, int nWidth, int nHeight, CCImage::ET
if (iError) { //no valid font found, try to use default
fName = "fonts/Marker Felt.ttf" ;
//CCLog("No valid font, use default %s\n", fName.c_str());
//CCLog("No valid font, use default %s", fName.c_str());
iError = openFont( fName, fontSize );
}
}

View File

@ -38,6 +38,14 @@ void CCLog(const char * pszFormat, ...)
vsnprintf( szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
}

View File

@ -103,10 +103,10 @@ static bool glew_dynamic_binding()
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
if (glGenFramebuffers == NULL)
{
CCLog("OpenGL: glGenFramebuffers is NULL, try to detect an extension\n");
CCLog("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
if (strstr(gl_extensions, "ARB_framebuffer_object"))
{
CCLog("OpenGL: ARB_framebuffer_object is supported\n");
CCLog("OpenGL: ARB_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
@ -129,7 +129,7 @@ static bool glew_dynamic_binding()
else
if (strstr(gl_extensions, "EXT_framebuffer_object"))
{
CCLog("OpenGL: EXT_framebuffer_object is supported\n");
CCLog("OpenGL: EXT_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
@ -150,8 +150,8 @@ static bool glew_dynamic_binding()
}
else
{
CCLog("OpenGL: No framebuffers extension is supported\n");
CCLog("OpenGL: Any call to Fbo will crash!\n");
CCLog("OpenGL: No framebuffers extension is supported");
CCLog("OpenGL: Any call to Fbo will crash!");
return false;
}
}

View File

@ -10,14 +10,12 @@ DEFINES += -DLINUX
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ifndef COCOS_ROOT
COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..)
else
RPATH_REL = ../..
COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..)
endif
COCOS_SRC = $(COCOS_ROOT)/cocos2dx
OBJ_DIR ?= obj
LIB_DIR = $(COCOS_SRC)/lib/linux
LIB_DIR = $(COCOS_ROOT)/lib/linux
BIN_DIR = bin
INCLUDES += \
@ -92,8 +90,9 @@ endif
endif
SHAREDLIBS += -lglfw -lGLEW -lfontconfig -lpthread -lGL
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(RPATH_REL)/$(FMOD_LIBDIR)
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
LIBS = -lrt -lz
clean:

View File

@ -99,7 +99,7 @@ static void* networkThread(void *data)
// Wait for http request tasks from main thread
int semWaitRet = sem_wait(s_pSem);
if (semWaitRet < 0) {
CCLog("HttpRequest async thread semaphore error: %s\n", strerror(errno));
CCLog("HttpRequest async thread semaphore error: %s", strerror(errno));
break;
}

View File

@ -226,7 +226,7 @@ void TestSearchPath::onEnter()
// Gets external.txt from writable path
string fullPath = sharedFileUtils->fullPathForFilename("external.txt");
CCLog("\nexternal file path = %s\n", fullPath.c_str());
CCLog("external file path = %s", fullPath.c_str());
if (fullPath.length() > 0)
{
fp = fopen(fullPath.c_str(), "rb");

View File

@ -91,9 +91,9 @@ void TextureTest::performTestsPNG(const char* filename)
gettimeofday(&now, NULL);
texture = cache->addImage(filename);
if( texture )
CCLog(" ms:%f\n", calculateDeltaTime(&now) );
CCLog(" ms:%f", calculateDeltaTime(&now) );
else
CCLog(" ERROR\n");
CCLog(" ERROR");
cache->removeTexture(texture);
CCLog("RGBA 4444");
@ -101,9 +101,9 @@ void TextureTest::performTestsPNG(const char* filename)
gettimeofday(&now, NULL);
texture = cache->addImage(filename);
if( texture )
CCLog(" ms:%f\n", calculateDeltaTime(&now) );
CCLog(" ms:%f", calculateDeltaTime(&now) );
else
CCLog(" ERROR\n");
CCLog(" ERROR");
cache->removeTexture(texture);
CCLog("RGBA 5551");
@ -111,9 +111,9 @@ void TextureTest::performTestsPNG(const char* filename)
gettimeofday(&now, NULL);
texture = cache->addImage(filename);
if( texture )
CCLog(" ms:%f\n", calculateDeltaTime(&now) );
CCLog(" ms:%f", calculateDeltaTime(&now) );
else
CCLog(" ERROR\n");
CCLog(" ERROR");
cache->removeTexture(texture);
CCLog("RGB 565");
@ -121,9 +121,9 @@ void TextureTest::performTestsPNG(const char* filename)
gettimeofday(&now, NULL);
texture = cache->addImage(filename);
if( texture )
CCLog(" ms:%f\n", calculateDeltaTime(&now) );
CCLog(" ms:%f", calculateDeltaTime(&now) );
else
CCLog(" ERROR\n");
CCLog(" ERROR");
cache->removeTexture(texture);
}
@ -133,60 +133,60 @@ void TextureTest::performTests()
// struct timeval now;
// CCTextureCache *cache = CCTextureCache::sharedTextureCache();
CCLog("\n\n--------\n\n");
CCLog("--------");
CCLog("--- PNG 128x128 ---\n");
CCLog("--- PNG 128x128 ---");
performTestsPNG("Images/test_image.png");
// CCLog("--- PVR 128x128 ---\n");
// CCLog("--- PVR 128x128 ---");
// CCLog("RGBA 8888");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/test_image_rgba8888.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("BGRA 8888");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/test_image_bgra8888.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/test_image_rgba4444.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("RGB 565");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/test_image_rgb565.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
CCLog("\n\n--- PNG 512x512 ---\n");
CCLog("--- PNG 512x512 ---");
performTestsPNG("Images/texture512x512.png");
// CCLog("--- PVR 512x512 ---\n");
// CCLog("--- PVR 512x512 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/texture512x512_rgba4444.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
@ -195,38 +195,38 @@ void TextureTest::performTests()
// Empty image
//
CCLog("\n\nEMPTY IMAGE\n\n");
CCLog("--- PNG 1024x1024 ---\n");
CCLog("EMPTY IMAGE");
CCLog("--- PNG 1024x1024 ---");
performTestsPNG("Images/texture1024x1024.png");
// CCLog("--- PVR 1024x1024 ---\n");
// CCLog("--- PVR 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.GZ 1024x1024 ---\n");
// CCLog("--- PVR.GZ 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr.gz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.CCZ 1024x1024 ---\n");
// CCLog("--- PVR.CCZ 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr.ccz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
@ -235,38 +235,38 @@ void TextureTest::performTests()
// SpriteSheet images
//
CCLog("\n\nSPRITESHEET IMAGE\n\n");
CCLog("--- PNG 1024x1024 ---\n");
CCLog("SPRITESHEET IMAGE");
CCLog("--- PNG 1024x1024 ---");
performTestsPNG("Images/PlanetCute-1024x1024.png");
// CCLog("--- PVR 1024x1024 ---\n");
// CCLog("--- PVR 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.GZ 1024x1024 ---\n");
// CCLog("--- PVR.GZ 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr.gz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.CCZ 1024x1024 ---\n");
// CCLog("--- PVR.CCZ 1024x1024 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr.ccz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
@ -276,39 +276,39 @@ void TextureTest::performTests()
// Landscape Image
//
CCLog("\n\nLANDSCAPE IMAGE\n\n");
CCLog("LANDSCAPE IMAGE");
CCLog("--- PNG 1024x1024 ---\n");
CCLog("--- PNG 1024x1024 ---");
performTestsPNG("Images/landscape-1024x1024.png");
// CCLog("--- PVR 1024x1024 ---\n");
// CCLog("--- PVR 1024x1024 ---");
// CCLog("RGBA 8888");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.GZ 1024x1024 ---\n");
// CCLog("--- PVR.GZ 1024x1024 ---");
// CCLog("RGBA 8888");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr.gz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
//
// CCLog("--- PVR.CCZ 1024x1024 ---\n");
// CCLog("--- PVR.CCZ 1024x1024 ---");
// CCLog("RGBA 8888");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr.ccz");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
@ -318,17 +318,17 @@ void TextureTest::performTests()
//
// most platform don't support texture with width/height is 2048
// CCLog("\n\n--- PNG 2048x2048 ---\n");
// CCLog("--- PNG 2048x2048 ---");
// performTestsPNG("Images/texture2048x2048.png");
// CCLog("--- PVR 2048x2048 ---\n");
// CCLog("--- PVR 2048x2048 ---");
// CCLog("RGBA 4444");
// gettimeofday(&now, NULL);
// texture = cache->addImage("Images/texture2048x2048_rgba4444.pvr");
// if( texture )
// CCLog(" ms:%f\n", calculateDeltaTime(&now) );
// CCLog(" ms:%f", calculateDeltaTime(&now) );
// else
// CCLog("ERROR\n");
// CCLog("ERROR");
// cache->removeTexture(texture);
}

View File

@ -1701,30 +1701,30 @@ void TextureSizeTest::onEnter()
CCLog("Loading 512x512 image...");
sprite = CCSprite::create("Images/texture512x512.png");
if( sprite )
CCLog("OK\n");
CCLog("OK");
else
CCLog("Error\n");
CCLog("Error");
CCLog("Loading 1024x1024 image...");
sprite = CCSprite::create("Images/texture1024x1024.png");
if( sprite )
CCLog("OK\n");
CCLog("OK");
else
CCLog("Error\n");
CCLog("Error");
// @todo
// CCLog("Loading 2048x2048 image...");
// sprite = CCSprite::create("Images/texture2048x2048.png");
// if( sprite )
// CCLog("OK\n");
// CCLog("OK");
// else
// CCLog("Error\n");
// CCLog("Error");
//
// CCLog("Loading 4096x4096 image...");
// sprite = CCSprite::create("Images/texture4096x4096.png");
// if( sprite )
// CCLog("OK\n");
// CCLog("OK");
// else
// CCLog("Error\n");
// CCLog("Error");
}
std::string TextureSizeTest::title()