From b8e6d9c589bf1dd6df14be612441d2194aa9285f Mon Sep 17 00:00:00 2001 From: Phenix Yu Date: Wed, 11 Apr 2012 11:15:53 +0800 Subject: [PATCH] fixed memory leak from CCGLProgram.cpp enable retina for win32 --- HelloLua/win32/HelloLua.win32.vcproj | 2 +- HelloWorld/Classes/AppDelegate.cpp | 2 +- cocos2dx/platform/win32/CCEGLView_win32.h | 2 +- cocos2dx/shaders/CCGLProgram.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/HelloLua/win32/HelloLua.win32.vcproj b/HelloLua/win32/HelloLua.win32.vcproj index bd50da0702..739943ab50 100644 --- a/HelloLua/win32/HelloLua.win32.vcproj +++ b/HelloLua/win32/HelloLua.win32.vcproj @@ -49,7 +49,7 @@ setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); + pDirector->enableRetinaDisplay(true); // turn on display FPS pDirector->setDisplayFPS(true); diff --git a/cocos2dx/platform/win32/CCEGLView_win32.h b/cocos2dx/platform/win32/CCEGLView_win32.h index 9186e08adf..0601eab7e0 100644 --- a/cocos2dx/platform/win32/CCEGLView_win32.h +++ b/cocos2dx/platform/win32/CCEGLView_win32.h @@ -53,7 +53,7 @@ public: bool canSetContentScaleFactor(); void setContentScaleFactor(float contentScaleFactor); - float getMainScreenScale() { return 1.0f; } + float getMainScreenScale() { return -1.0f; } virtual bool Create(LPCTSTR pTitle, int w, int h); virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index d2d95591d9..0d4addbd19 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -114,8 +114,10 @@ bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, cons { const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(vShaderFilename)); const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(fShaderFilename)); - - return initWithVertexShaderByteArray(vertexSource, fragmentSource); + bool ret = initWithVertexShaderByteArray(vertexSource, fragmentSource); + CC_SAFE_DELETE_ARRAY(vertexSource); + CC_SAFE_DELETE_ARRAY(fragmentSource); + return ret; } const char* CCGLProgram::description()