mirror of https://github.com/axmolengine/axmol.git
Merge pull request #881 from dumganhar/iss1204_initInstance
fixed #1204: Removed CCApplication::initInstance. If users want to custom some features of CCEGLView, e.g. set the design resolution, they should add the following code in "HelloWorld/proj.win32/main.cpp" (on win32) or "HelloWorld/proj.android/jni/helloworld/main.cpp" (on android). CCEGLView::sharedOpenGLView().setDesignResolutionSize(480, 320); You should look into main.cpp files for detail infomations. This commit also update something as follows: 1. Modified some project configuations for win32, we used MultiByte rather than Unicode as CharacterSet for all win32 projects, and removed some unused codes for win32 platform. 2. Made CCEGLView::Create(on win32) as a private function. 3. Updated ExtensionsTest. 4. Updated the format of source files(changed linebreak symbol to UNIX format ('\n'),replaced 'tab' with four spaces).
This commit is contained in:
commit
ec433b46cd
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -85,7 +85,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -34,44 +34,6 @@ AppDelegate::~AppDelegate()
|
|||
//CCScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), CC_WIDTH, CC_HEIGHT));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
// MaxAksenov said it's NOT a very elegant solution. I agree, haha
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -26,9 +26,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->create(480, 320);
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -107,7 +107,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
// uncomment below line, open debug console
|
||||
#define USE_WIN32_CONSOLE
|
||||
|
@ -22,8 +24,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello Lua");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
|
||||
int ret = cocos2d::CCApplication::sharedApplication().run();
|
||||
int ret = CCApplication::sharedApplication().run();
|
||||
|
||||
#ifdef USE_WIN32_CONSOLE
|
||||
FreeConsole();
|
||||
|
|
|
@ -11,73 +11,8 @@ AppDelegate::AppDelegate() {
|
|||
|
||||
}
|
||||
|
||||
AppDelegate::~AppDelegate() {
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance() {
|
||||
bool bRet = false;
|
||||
do {
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
//pMainWnd->setDesignResolutionSize(480, 320);
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
// if the resources under '/sdcard" or other writeable path, set it.
|
||||
// warning: the audio source should in assets/
|
||||
// cocos2d::CCFileUtils::setResourcePath("/sdcard");
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
// MaxAksenov said it's NOT a very elegant solution. I agree, haha
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create("cocos2d: Hello World", 480, 320 ,480, 320));
|
||||
|
||||
CCFileUtils::setResourcePath("../Resources/");
|
||||
|
||||
#endif // CC_PLATFORM_LINUX
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||
pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
|
||||
CCFileUtils::setResourcePath("/Res/");
|
||||
|
||||
#endif // CC_PLATFORM_BADA
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(1024, 600));
|
||||
CCFileUtils::setResourcePath("app/native/Resources");
|
||||
#endif // CC_PLATFORM_QNX
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -29,9 +29,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->setDesignResolutionSize(480, 320); Please change it to (320, 480) if you're in portrait mode.
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -97,7 +97,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "../Classes/AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
|
@ -12,6 +14,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
|
||||
return cocos2d::CCApplication::sharedApplication().run();
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello World");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
return CCApplication::sharedApplication().run();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -87,7 +87,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -35,7 +35,10 @@ public:
|
|||
return (loc - range.location <= range.length);
|
||||
}
|
||||
|
||||
static bool CCEqualRanges(CCRange range1, CCRange range2)
{
return (range1.location == range2.location && range1.length == range2.length);
}
|
||||
static bool CCEqualRanges(CCRange range1, CCRange range2)
|
||||
{
|
||||
return (range1.location == range2.location && range1.length == range2.length);
|
||||
}
|
||||
|
||||
unsigned int length;
|
||||
unsigned int location;
|
||||
|
|
|
@ -13,11 +13,6 @@ public:
|
|||
|
||||
virtual ~CCApplicationProtocol() {}
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance() = 0;
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -47,7 +47,7 @@ CCEGLViewProtocol::CCEGLViewProtocol()
|
|||
, m_pDelegate(NULL)
|
||||
, m_fScreenScaleFactor(1.0f)
|
||||
{
|
||||
|
||||
strncpy(m_szViewName, "Cocos2d-x Game", sizeof(m_szViewName));
|
||||
}
|
||||
|
||||
CCEGLViewProtocol::~CCEGLViewProtocol()
|
||||
|
@ -171,6 +171,19 @@ float CCEGLViewProtocol::getMainScreenScale()
|
|||
return -1.0f;
|
||||
}
|
||||
|
||||
void CCEGLViewProtocol::setViewName(const char* pszViewName)
|
||||
{
|
||||
if (pszViewName != NULL && strlen(pszViewName) > 0)
|
||||
{
|
||||
strncpy(m_szViewName, pszViewName, sizeof(m_szViewName));
|
||||
}
|
||||
}
|
||||
|
||||
const char* CCEGLViewProtocol::getViewName()
|
||||
{
|
||||
return m_szViewName;
|
||||
}
|
||||
|
||||
void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
CCSet set;
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
||||
virtual void setScissorInPoints(float x , float y , float w , float h);
|
||||
virtual float getMainScreenScale();
|
||||
virtual void setViewName(const char* pszViewName);
|
||||
const char* getViewName();
|
||||
|
||||
/** handle touch events by default, if you want to custom your handles, please override these functions */
|
||||
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
|
||||
|
@ -49,6 +51,7 @@ protected:
|
|||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
char m_szViewName[50];
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -31,7 +31,7 @@ CCApplication::~CCApplication()
|
|||
int CCApplication::run()
|
||||
{
|
||||
// Initialize instance and cocos2d.
|
||||
if (! initInstance() || ! applicationDidFinishLaunching())
|
||||
if (! applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ CCApplication::~CCApplication()
|
|||
|
||||
int CCApplication::run()
|
||||
{
|
||||
if (initInstance() && applicationDidFinishLaunching())
|
||||
if (applicationDidFinishLaunching())
|
||||
{
|
||||
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int CCApplication::run()
|
|||
QueryPerformanceCounter(&nLast);
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (! initInstance() || ! applicationDidFinishLaunching())
|
||||
if (!applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -160,17 +160,17 @@ static void PVRFrameEnableControlWindow(bool bEnable)
|
|||
return;
|
||||
}
|
||||
|
||||
const wchar_t * wszValue = L"hide_gui";
|
||||
const wchar_t * wszNewData = (bEnable) ? L"NO" : L"YES";
|
||||
wchar_t wszOldData[256] = {0};
|
||||
DWORD dwSize = sizeof(wszOldData);
|
||||
LSTATUS status = RegQueryValueExW(hKey, wszValue, 0, NULL, (LPBYTE)wszOldData, &dwSize);
|
||||
const char * szValue = "hide_gui";
|
||||
const char * szNewData = (bEnable) ? "NO" : "YES";
|
||||
char szOldData[256] = {0};
|
||||
DWORD dwSize = sizeof(szOldData);
|
||||
LSTATUS status = RegQueryValueEx(hKey, szValue, 0, NULL, (LPBYTE)szOldData, &dwSize);
|
||||
if (ERROR_FILE_NOT_FOUND == status // the key not exist
|
||||
|| (ERROR_SUCCESS == status // or the hide_gui value is exist
|
||||
&& 0 != wcscmp(wszNewData, wszOldData))) // but new data and old data not equal
|
||||
&& 0 != strcmp(szNewData, szOldData))) // but new data and old data not equal
|
||||
{
|
||||
dwSize = sizeof(wchar_t) * (wcslen(wszNewData) + 1);
|
||||
RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize);
|
||||
dwSize = sizeof(wchar_t) * (strlen(szNewData) + 1);
|
||||
RegSetValueEx(hKey, szValue, 0, REG_SZ, (const BYTE *)szNewData, dwSize);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
|
|
@ -165,8 +165,8 @@ private:
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// impliment CCEGLView
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static CCEGLView * s_pMainWindow;
|
||||
static const WCHAR * kWindowClassName = L"Cocos2dxWin32";
|
||||
static CCEGLView* s_pMainWindow = NULL;
|
||||
static const char* kWindowClassName = "Cocos2dxWin32";
|
||||
|
||||
static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
|
|||
m_hWnd = CreateWindowEx(
|
||||
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
|
||||
kWindowClassName, // Class Name
|
||||
pTitle, // Window Title
|
||||
m_szViewName, // Window Title
|
||||
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style
|
||||
0, 0, // Window Position
|
||||
0, // Window Width
|
||||
|
@ -408,7 +408,6 @@ void CCEGLView::end()
|
|||
}
|
||||
s_pMainWindow = NULL;
|
||||
UnregisterClass(kWindowClassName, GetModuleHandle(NULL));
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
@ -459,7 +458,12 @@ void CCEGLView::resize(int width, int height)
|
|||
m_pEGL->resizeSurface();
|
||||
}
|
||||
|
||||
setFrameSize(width, height);
|
||||
CCEGLViewProtocol::setFrameSize(width, height);
|
||||
}
|
||||
|
||||
void CCEGLView::setFrameSize(float width, float height)
|
||||
{
|
||||
Create((LPCTSTR)m_szViewName, width, height);
|
||||
}
|
||||
|
||||
void CCEGLView::centerWindow()
|
||||
|
@ -509,8 +513,12 @@ void CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
|||
|
||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
||||
{
|
||||
CC_ASSERT(s_pMainWindow);
|
||||
return *s_pMainWindow;
|
||||
static CCEGLView* s_pEglView = NULL;
|
||||
if (s_pEglView == NULL)
|
||||
{
|
||||
s_pEglView = new CCEGLView();
|
||||
}
|
||||
return *s_pEglView;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -37,25 +37,23 @@ class CCEGL;
|
|||
class CC_DLL CCEGLView : public CCEGLViewProtocol
|
||||
{
|
||||
public:
|
||||
|
||||
CCEGLView();
|
||||
virtual ~CCEGLView();
|
||||
|
||||
bool isOpenGLReady();
|
||||
void end();
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
bool canSetContentScaleFactor();
|
||||
void setContentScaleFactor(float contentScaleFactor);
|
||||
|
||||
/* override functions */
|
||||
virtual bool isOpenGLReady();
|
||||
virtual void end();
|
||||
virtual void swapBuffers();
|
||||
virtual bool canSetContentScaleFactor();
|
||||
virtual void setContentScaleFactor(float contentScaleFactor);
|
||||
virtual void setFrameSize(float width, float height);
|
||||
virtual void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
private:
|
||||
virtual bool Create(LPCTSTR pTitle, int w, int h);
|
||||
public:
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
// win32 platform function
|
||||
HWND getHWnd();
|
||||
void resize(int width, int height);
|
||||
|
@ -65,7 +63,6 @@ public:
|
|||
void setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelerometerKeyHook );
|
||||
|
||||
// static function
|
||||
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
|
|
|
@ -60,38 +60,10 @@ public:
|
|||
// release temp font resource
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
{
|
||||
RemoveFontResource(pwszBuffer);
|
||||
RemoveFontResource(m_curFontPath.c_str());
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t * utf8ToUtf16(std::string nString)
|
||||
{
|
||||
wchar_t * pwszBuffer = NULL;
|
||||
do
|
||||
{
|
||||
if (nString.size() < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// utf-8 to utf-16
|
||||
int nLen = nString.size();
|
||||
int nBufLen = nLen + 1;
|
||||
pwszBuffer = new wchar_t[nBufLen];
|
||||
CC_BREAK_IF(! pwszBuffer);
|
||||
memset(pwszBuffer,0,nBufLen);
|
||||
nLen = MultiByteToWideChar(CP_UTF8, 0, nString.c_str(), nLen, pwszBuffer, nBufLen);
|
||||
pwszBuffer[nLen] = '\0';
|
||||
} while (0);
|
||||
return pwszBuffer;
|
||||
|
||||
}
|
||||
|
||||
bool setFont(const char * pFontName = NULL, int nSize = 0)
|
||||
{
|
||||
|
@ -141,31 +113,20 @@ public:
|
|||
// release old font register
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
{
|
||||
if(RemoveFontResource(pwszBuffer))
|
||||
if(RemoveFontResource(m_curFontPath.c_str()))
|
||||
{
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear());
|
||||
// register temp font
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
{
|
||||
if(AddFontResource(pwszBuffer))
|
||||
if(AddFontResource(m_curFontPath.c_str()))
|
||||
{
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hFont = NULL;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -104,7 +104,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -1 +1 @@
|
|||
99a350af562498cb7fcbaec3063f86f9d05889fe
|
||||
215941887bb3ecde65ca64e6e1b5ddaacded6a7c
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -87,7 +87,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,11 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,10 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,11 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -35,40 +35,6 @@ AppDelegate::~AppDelegate()
|
|||
CCScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), CC_WIDTH, CC_HEIGHT));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -16,70 +16,6 @@ AppDelegate::~AppDelegate()
|
|||
// SimpleAudioEngine::end();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The tests is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: tests"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// Android doesn't need to do anything.
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create("cocos2d: tests", 480, 320, 480, 320));
|
||||
|
||||
//set the base resource folder pay attention to add "/"
|
||||
CCFileUtils::setResourcePath("../Resources/");
|
||||
|
||||
#endif // CC_PLATFORM_LINUX
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||
pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
|
||||
CCFileUtils::setResourcePath("/Res/");
|
||||
|
||||
#endif // CC_PLATFORM_BADA
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(1024, 600));
|
||||
CCFileUtils::setResourcePath("app/native/Resources");
|
||||
#endif // CC_PLATFORM_QNX
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -27,9 +27,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->setDesignResolutionSize(480, 320);
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
|
@ -12,6 +14,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello Tests");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
|
||||
return cocos2d::CCApplication::sharedApplication().run();
|
||||
return CCApplication::sharedApplication().run();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -98,7 +98,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -5,12 +5,19 @@
|
|||
|
||||
enum
|
||||
{
|
||||
MAX_COUNT = 3,
|
||||
LINE_SPACE = 40,
|
||||
kItemTagBasic = 1000,
|
||||
};
|
||||
|
||||
static const std::string testsName[MAX_COUNT] =
|
||||
enum
|
||||
{
|
||||
TEST_NOTIFICATIONCENTER = 0,
|
||||
TEST_CCCONTROLBUTTON,
|
||||
TEST_TEXTUREWATCHER,
|
||||
TEST_MAX_COUNT
|
||||
};
|
||||
|
||||
static const std::string testsName[TEST_MAX_COUNT] =
|
||||
{
|
||||
"NotificationCenterTest",
|
||||
"CCControlButtonTest",
|
||||
|
@ -32,7 +39,7 @@ void ExtensionsMainLayer::onEnter()
|
|||
pMenu->setPosition( CCPointZero );
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < MAX_COUNT; ++i)
|
||||
for (int i = 0; i < TEST_MAX_COUNT; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::itemWithString(testsName[i].c_str(), this,
|
||||
menu_selector(ExtensionsMainLayer::menuCallback));
|
||||
|
@ -50,17 +57,19 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender)
|
|||
|
||||
switch (nIndex)
|
||||
{
|
||||
case 0:
|
||||
case TEST_NOTIFICATIONCENTER:
|
||||
{
|
||||
runNotificationCenterTest();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case TEST_CCCONTROLBUTTON:
|
||||
{
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case TEST_TEXTUREWATCHER:
|
||||
{
|
||||
static bool s_bOpened = false;
|
||||
s_bOpened = !s_bOpened;
|
||||
|
|
|
@ -7,28 +7,32 @@
|
|||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace cocos2d::extension;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
|
||||
view->setFrameWidthAndHeight(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
view->create(480, 320);
|
||||
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
cocos2d::CCApplication::sharedApplication().run();
|
||||
CCApplication::sharedApplication().run();
|
||||
}
|
||||
else
|
||||
{
|
||||
cocos2d::CCTextureCache::reloadAllTextures();
|
||||
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue