fixed #22 use user defined message to call CCDirector::preMainLoop, Use PowerVR Win32 GLES Lib to emulate TOPS GLES.

This commit is contained in:
yangws 2010-08-03 03:23:12 +00:00
parent 80c347932e
commit 27eda1194a
12 changed files with 428 additions and 109 deletions

View File

@ -64,7 +64,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libEGL.lib libgles_cl.lib libgles_cm.lib libxml2.lib ImageToolKit_d.lib" AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libEGL.lib libgles_cm.lib libxml2.lib ImageToolKit_d.lib"
OutputFile="$(OutDir)/libcocos2d.dll" OutputFile="$(OutDir)/libcocos2d.dll"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="../../PRJ_TG3/Common/ICU/lib;../../PRJ_TG3/Mtapi/Win32/lib;../../PRJ_TG3/LIB/Win32Lib;../../PRJ_TG3/Common/SoftSupport" AdditionalLibraryDirectories="../../PRJ_TG3/Common/ICU/lib;../../PRJ_TG3/Mtapi/Win32/lib;../../PRJ_TG3/LIB/Win32Lib;../../PRJ_TG3/Common/SoftSupport"
@ -292,6 +292,10 @@
RelativePath=".\include\ccTypes.h" RelativePath=".\include\ccTypes.h"
> >
</File> </File>
<File
RelativePath=".\include\CCXApplication.h"
>
</File>
<File <File
RelativePath=".\include\ccxCommon.h" RelativePath=".\include\ccxCommon.h"
> >
@ -578,7 +582,7 @@
Name="platform" Name="platform"
> >
<File <File
RelativePath=".\platform\CCTouch_Platform.h" RelativePath=".\platform\CCXApplication_platform.h"
> >
</File> </File>
<File <File
@ -612,6 +616,14 @@
RelativePath=".\platform\uphone\CCTime.h" RelativePath=".\platform\uphone\CCTime.h"
> >
</File> </File>
<File
RelativePath=".\platform\uphone\CCXApplication_uphone.cpp"
>
</File>
<File
RelativePath=".\platform\uphone\CCXApplication_uphone.h"
>
</File>
<File <File
RelativePath=".\platform\uphone\CCXEGLView_uphone.cpp" RelativePath=".\platform\uphone\CCXEGLView_uphone.cpp"
> >

View File

@ -0,0 +1,30 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCX_APPLICATION_H__
#define __CCX_APPLICATION_H__
#include "platform/CCXApplication_platform.h"
#endif // end of __CCX_APPLICATION_H__

View File

@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCX_APPLICATION_PLATFORM_H__
#define __CCX_APPLICATION_PLATFORM_H__
#include "config_platform.h"
#ifdef CCX_PLATFORM_UPHONE
#include "uphone/CCXApplication_uphone.h"
#else
#error
#endif
#endif // end of __CCX_APPLICATION_PLATFORM_H__

View File

@ -0,0 +1,55 @@
#include "CCXApplication_uphone.h"
#include "CCDirector.h"
namespace cocos2d {
static const Int32 CCX_ON_APPLICATION_IDLE = (EVENT_FirstUser + EVENT_LastUser) / 2;
static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData)
{
CCDirector::getSharedDirector()->preMainLoop();
int nRtn = Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, (MESSAGE_t *)uData);
return 1;
}
CCXApplication::CCXApplication()
{
memset(&m_tMsg, 0, sizeof(m_tMsg));
SS_GetCurrentGTID(&m_tMsg.gtid);
m_tMsg.type = CCX_ON_APPLICATION_IDLE;
Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, _OnAppIdle, (UInt32)&m_tMsg);
}
CCXApplication::~CCXApplication()
{
Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, NULL, NULL);
}
Boolean CCXApplication::EventHandler(EventType * pEvent)
{
Boolean bHandled = FALSE;
switch (pEvent->eType)
{
case EVENT_AppLoad:
if (! initCocos2d())
{
SendStopEvent();
}
bHandled = Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &m_tMsg);
bHandled = TRUE;
break;
case EVENT_AppStopNotify:
break;
}
if (! bHandled)
{
bHandled = TApplication::EventHandler(pEvent);
}
return bHandled;
}
}

View File

@ -0,0 +1,55 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCX_APPLICATION_UPHONE_H__
#define __CCX_APPLICATION_UPHONE_H__
#include "ccxCommon.h"
#include "TG3.h"
namespace cocos2d {
class CCX_DLL CCXApplication : public TApplication
{
public:
CCXApplication();
virtual ~CCXApplication();
virtual Boolean EventHandler(EventType * pEvent);
/**
@brief Implement CCDirector and sense init code here.
@return TRUE Initialize success, app continue.
@return FALSE Initialize failed, app terminate.
*/
virtual Boolean initCocos2d() = 0;
private:
MESSAGE_t m_tMsg;
};
} // end of namespace cocos2d
#endif // end of __CCX_APPLICATION_UPHONE_H__

View File

@ -22,10 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include <windows.h>
#include "CCXEGLView_uphone.h" #include "CCXEGLView_uphone.h"
#include "TG3.h"
#include "EGL/egl.h" #include "EGL/egl.h"
#include "Cocos2dDefine.h" #include "Cocos2dDefine.h"
@ -33,23 +32,119 @@ THE SOFTWARE.
#include "touch_dispatcher/CCTouch.h" #include "touch_dispatcher/CCTouch.h"
#include "touch_dispatcher/CCTouchDispatcher.h" #include "touch_dispatcher/CCTouchDispatcher.h"
#define WIN_CLASS_NAME "OpenGL"
static bool g_keys[256]; // Array Used For The Keyboard Routine
static bool g_active=TRUE; // Window Active Flag Set To TRUE By Default
EGLNativeWindowType _CreateWnd(int width, int height);
LRESULT CALLBACK _WndProc(HWND, UINT, WPARAM, LPARAM);
namespace cocos2d { namespace cocos2d {
class CCXEGL class CCXEGL
{ {
public: public:
~CCXEGL()
{
if (EGL_NO_DISPLAY != m_eglDisplay)
{
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(m_eglDisplay);
}
if (m_eglDC)
{
ReleaseDC(m_eglWnd, m_eglDC);
}
if (m_eglWnd)
{
DestroyWindow(m_eglWnd);
}
UnregisterClass(WIN_CLASS_NAME, GetModuleHandle(NULL));
}
static CCXEGL * Create(TWindow * pWindow)
{
CCXEGL * pEGL = new CCXEGL;
Boolean bSuccess = FALSE;
do
{
CCX_BREAK_IF(! pEGL);
TRectangle rc;
pWindow->GetClientBounds(&rc);
CCX_BREAK_IF(! (pEGL->m_eglWnd = _CreateWnd(rc.Width(), rc.Height())));
pEGL->m_eglDC = GetDC(pEGL->m_eglWnd);
CCX_BREAK_IF(! pEGL->m_eglDC);
EGLDisplay eglDisplay;
CCX_BREAK_IF(EGL_NO_DISPLAY == (eglDisplay = eglGetDisplay(pEGL->m_eglDC)));
EGLint nMajor, nMinor;
CCX_BREAK_IF(EGL_FALSE == eglInitialize(eglDisplay, &nMajor, &nMinor) || 1 != nMajor);
const EGLint aConfigAttribs[] =
{
EGL_LEVEL, 0,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NATIVE_RENDERABLE, EGL_FALSE,
EGL_DEPTH_SIZE, EGL_DONT_CARE,
EGL_NONE,
};
EGLint iConfigs;
EGLConfig eglConfig;
CCX_BREAK_IF(EGL_FALSE == eglChooseConfig(eglDisplay, aConfigAttribs, &eglConfig, 1, &iConfigs)
|| (iConfigs != 1));
EGLSurface eglSurface;
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, pEGL->m_eglWnd, NULL);
CCX_BREAK_IF(EGL_NO_SURFACE == eglSurface);
EGLContext eglContext;
eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
CCX_BREAK_IF(EGL_NO_CONTEXT == eglContext);
CCX_BREAK_IF(EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext));
pEGL->m_eglDisplay = eglDisplay;
pEGL->m_eglSurface = eglSurface;
pEGL->m_eglContext = eglContext;
bSuccess = TRUE;
} while (0);
if (! bSuccess)
{
CCX_SAFE_DELETE(pEGL);
}
return pEGL;
}
void SwapBuffers()
{
if (EGL_NO_DISPLAY != m_eglDisplay)
{
eglSwapBuffers(m_eglDisplay, m_eglSurface);
}
}
private:
CCXEGL() CCXEGL()
: m_pDC(NULL) : m_eglWnd(NULL)
, m_eglDisplay(EGL_NO_DISPLAY) , m_eglDC(NULL)
, m_eglSurface(EGL_NO_SURFACE) , m_eglDisplay(EGL_NO_DISPLAY)
, m_eglContext(EGL_NO_CONTEXT) {} , m_eglSurface(EGL_NO_SURFACE)
, m_eglContext(EGL_NO_CONTEXT) {}
~CCXEGL() { CCX_SAFE_DELETE(m_pDC); }
TDC * m_pDC; EGLNativeWindowType m_eglWnd;
EGLDisplay m_eglDisplay; EGLNativeDisplayType m_eglDC;
EGLSurface m_eglSurface; EGLDisplay m_eglDisplay;
EGLContext m_eglContext; EGLSurface m_eglSurface;
EGLContext m_eglContext;
}; };
CCXEGLView::CCXEGLView(TApplication * pApp) CCXEGLView::CCXEGLView(TApplication * pApp)
: TWindow(pApp) : TWindow(pApp)
@ -63,28 +158,22 @@ CCXEGLView::CCXEGLView(TApplication * pApp)
CCXEGLView::~CCXEGLView() CCXEGLView::~CCXEGLView()
{ {
_releaseEGL(); delete m_pEGL;
delete m_pSet; delete m_pSet;
delete m_pTouch; delete m_pTouch;
} }
Boolean CCXEGLView::AfterCreate(void)
{
return (m_pEGL = CCXEGL::Create(this)) ? TRUE : FALSE;
}
Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent) Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent)
{ {
Boolean bHandled = FALSE; Boolean bHandled = FALSE;
switch(pEvent->eType) switch(pEvent->eType)
{ {
case EVENT_WinInit:
{
_initEGL();
if (! m_pEGL)
{
break;
}
bHandled = TRUE;
}
break;
case EVENT_WinPaint: case EVENT_WinPaint:
{ {
swapBuffers(); swapBuffers();
@ -129,23 +218,13 @@ Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent)
bHandled = TRUE; bHandled = TRUE;
} }
break; break;
case EVENT_WinClose:
{
// Stop the application since the main form has been closed
_releaseEGL();
}
break;
} }
if (bHandled) if (! bHandled)
{
return bHandled;
}
else
{ {
return TWindow::EventHandler(pApp, pEvent); return TWindow::EventHandler(pApp, pEvent);
} }
return bHandled;
} }
CGSize CCXEGLView::getSize() CGSize CCXEGLView::getSize()
@ -162,7 +241,7 @@ bool CCXEGLView::isOpenGLReady()
void CCXEGLView::release() void CCXEGLView::release()
{ {
_releaseEGL(); CCX_SAFE_DELETE(m_pEGL);
CloseWindow(); CloseWindow();
} }
@ -176,79 +255,108 @@ void CCXEGLView::swapBuffers()
// DrawWindow(); // DrawWindow();
if (m_pEGL) if (m_pEGL)
{ {
eglSwapBuffers(m_pEGL->m_eglDisplay, m_pEGL->m_eglSurface); m_pEGL->SwapBuffers();
} }
} }
} // end of namespace cocos2d
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// private member for initialize EGL // static function
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void CCXEGLView::_initEGL() static EGLNativeWindowType _CreateWnd(int width, int height)
{ {
TDC * pDC = NULL; WNDCLASS wc; // Windows Class Structure
CCXEGL * pEGL = new CCXEGL; HINSTANCE hInstance;
EGLNativeWindowType hWnd = NULL;
do hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window
wc.style = CS_NOCLOSE | CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = WNDPROC( _WndProc ); // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = hInstance; // Set The Instance
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer
wc.hbrBackground = NULL; // No Background Required For GL
wc.lpszMenuName = NULL; // We Don't Want A Menu
wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name
RegisterClass(&wc); // Attempt To Register The Window Class
RECT rect = {0, 0, width, height};
AdjustWindowRectEx(&rect, WS_POPUPWINDOW, false, WS_EX_TOPMOST | WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
hWnd = CreateWindowEx(
WS_EX_TOPMOST | WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
"OpenGL", // Class Name
"Effect Test App", // Window Title
WS_POPUPWINDOW/*WS_OVERLAPPEDWINDOW*/ | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
rect.right - rect.left, // Window Width
rect.bottom - rect.top, // Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL );
return hWnd;
}
static LRESULT CALLBACK _WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch ( uMsg ) // Check For Windows Messages
{ {
CCX_BREAK_IF(m_pEGL || ! pEGL); case WM_ACTIVATE:
pDC = new TDC(this);
CCX_BREAK_IF(! pDC);
EGLNativeDisplayType displayId = (EGLNativeDisplayType) pDC;
EGLDisplay eglDisplay;
CCX_BREAK_IF(EGL_NO_DISPLAY == (eglDisplay = eglGetDisplay(displayId)));
EGLint nMajor, nMinor;
CCX_BREAK_IF(EGL_FALSE == eglInitialize(eglDisplay, &nMajor, &nMinor) || 1 != nMajor);
const EGLint aConfigAttribs[] =
{ {
EGL_LEVEL, 0, if ( ! HIWORD( wParam ) ) // Check Minimization State
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, g_active = TRUE;
EGL_NATIVE_RENDERABLE, EGL_FALSE, }
EGL_DEPTH_SIZE, EGL_DONT_CARE, else
EGL_NONE, {
}; g_active = FALSE;
EGLint iConfigs; }
EGLConfig eglConfig; return 0;
CCX_BREAK_IF(EGL_FALSE == eglChooseConfig(eglDisplay, aConfigAttribs, &eglConfig, 1, &iConfigs) }
|| (iConfigs != 1));
EGLSurface eglSurface; case WM_SYSCOMMAND:
EGLNativeWindowType eglWnd = (EGLNativeWindowType) this; {
CCX_BREAK_IF(EGL_NO_SURFACE == (eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, eglWnd, NULL))); if ( ( wParam == SC_SCREENSAVE ) ||
( wParam == SC_MONITORPOWER ) )
{
return 0;
}
break;
}
EGLContext eglContext; case WM_CLOSE:
CCX_BREAK_IF(EGL_NO_CONTEXT == (eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL))); {
PostQuitMessage( 0 );
return 0;
}
CCX_BREAK_IF(EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)); case WM_KEYDOWN:
{
g_keys[wParam] = TRUE;
return 0;
}
m_pEGL = pEGL; case WM_KEYUP:
pEGL->m_eglDisplay = eglDisplay; {
pEGL->m_eglSurface = eglSurface; g_keys[wParam] = FALSE;
pEGL->m_eglContext = eglContext; return 0;
pEGL->m_pDC = pDC; }
pDC = NULL;
pEGL = NULL;
} while (0);
CCX_SAFE_DELETE(pDC); case WM_SIZE:
CCX_SAFE_DELETE(pEGL); {
} //ResizeScene( LOWORD( lParam ), HIWORD( lParam ) ); // LoWord=Width, HiWord=Height
return 0;
void CCXEGLView::_releaseEGL() }
{
if (! m_pEGL)
{
return;
} }
eglMakeCurrent(m_pEGL->m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); // Pass All Unhandled Messages To DefWindowProc
eglTerminate(m_pEGL->m_eglDisplay); return DefWindowProc( hWnd, uMsg, wParam, lParam );
CCX_SAFE_DELETE(m_pEGL);
}
} }

View File

@ -44,8 +44,9 @@ class CCX_DLL CCXEGLView : public TWindow
public: public:
CCXEGLView(TApplication * pApp); CCXEGLView(TApplication * pApp);
~CCXEGLView(); virtual ~CCXEGLView();
virtual Boolean AfterCreate(void);
virtual Boolean EventHandler(TApplication * pApp, EventType * pEvent); virtual Boolean EventHandler(TApplication * pApp, EventType * pEvent);
CGSize getSize(); CGSize getSize();
@ -55,8 +56,6 @@ public:
void swapBuffers(); void swapBuffers();
private: private:
void _initEGL();
void _releaseEGL();
bool m_bCaptured; bool m_bCaptured;
NSSet * m_pSet; NSSet * m_pSet;

View File

@ -41,7 +41,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\Res;..\..\PRJ_TG3\Include;..\..\PRJ_TG3\Include\MTAPI;..\..\PRJ_TG3\Include\ThirdParty;..\..\PRJ_TG3\Include\TCOM;..\..\PRJ_TG3\TG3\Include;..\..\PRJ_TG3\TG3\TG3_Implement;..\..\PRJ_TG3\EOS_SYS;..\..\PRJ_TG3\Common\SoftSupport;..\..\PRJ_TG3\Common\ICU\Include;..\cocos2dx\include;..\cocos2dx" AdditionalIncludeDirectories=".\Res;..\..\PRJ_TG3\Include;..\..\PRJ_TG3\Include\MTAPI;..\..\PRJ_TG3\Include\ThirdParty\gles;..\..\PRJ_TG3\Include\TCOM;..\..\PRJ_TG3\TG3\Include;..\..\PRJ_TG3\TG3\TG3_Implement;..\..\PRJ_TG3\EOS_SYS;..\..\PRJ_TG3\Common\SoftSupport;..\..\PRJ_TG3\Common\ICU\Include;..\cocos2dx\include;..\cocos2dx"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"

View File

@ -6,7 +6,11 @@
#include "test_uphoneApp.h" #include "test_uphoneApp.h"
#include "test_uphoneMainForm.h" #include "test_uphoneMainForm.h"
#include "CCDirector.h"
Ttest_uphoneApp::Ttest_uphoneApp() Ttest_uphoneApp::Ttest_uphoneApp()
: m_pMainWnd(NULL)
{ {
} }
@ -16,6 +20,12 @@ Ttest_uphoneApp::~Ttest_uphoneApp()
} }
Boolean Ttest_uphoneApp::initCocos2d()
{
CCDirector::getSharedDirector()->setOpenGLView(m_pMainWnd);
return TRUE;
}
Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent) Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent)
{ {
Boolean bHandled = FALSE; Boolean bHandled = FALSE;
@ -24,17 +34,16 @@ Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent)
{ {
case EVENT_AppLoad: case EVENT_AppLoad:
{ {
TMainForm *pWin = new TMainForm(this); m_pMainWnd = new TMainForm(this);
if (pWin) if (m_pMainWnd)
{ {
SetActiveWindow(pWin); SetActiveWindow(m_pMainWnd);
} }
else else
{ // 窗口创建失败,退出应用。 { // 窗口创建失败,退出应用。
SendStopEvent(); SendStopEvent();
} }
} }
bHandled = TRUE;
break; break;
case EVENT_AppStopNotify: case EVENT_AppStopNotify:
@ -46,7 +55,7 @@ Boolean Ttest_uphoneApp::EventHandler(EventType* pEvent)
} }
if (FALSE == bHandled) if (FALSE == bHandled)
{ {
return TApplication::EventHandler(pEvent); return CCXApplication::EventHandler(pEvent);
} }
return bHandled; return bHandled;

View File

@ -6,17 +6,22 @@
#ifndef __test_uphone_App_H__ #ifndef __test_uphone_App_H__
#define __test_uphone_App_H__ #define __test_uphone_App_H__
#include "TG3.h" #include "CCXApplication.h"
#include "CCXEGLView.h"
class Ttest_uphoneApp : public TApplication class Ttest_uphoneApp : public cocos2d::CCXApplication
{ {
public: public:
Ttest_uphoneApp(); Ttest_uphoneApp();
~Ttest_uphoneApp(); ~Ttest_uphoneApp();
virtual Boolean initCocos2d();
public: public:
virtual Boolean EventHandler(EventType * pEvent); virtual Boolean EventHandler(EventType * pEvent);
protected: protected:
private: cocos2d::CCXEGLView * m_pMainWnd;
}; };

View File

@ -9,7 +9,7 @@
#include "test_uphone_res_def.h" #include "test_uphone_res_def.h"
#include "TG3.h" #include "TG3.h"
#include "ssMsgQueue.h"
#include "touch_dispatcher/CCTouchDelegateProtocol.h" #include "touch_dispatcher/CCTouchDelegateProtocol.h"
using namespace cocos2d; using namespace cocos2d;
@ -31,6 +31,13 @@ Boolean TMainForm::EventHandler(TApplication * pApp, EventType * pEvent)
switch(pEvent->eType) switch(pEvent->eType)
{ {
case EVENT_WinInit:
{
// do some thing
bHandled = TRUE;
}
break;
case EVENT_CtrlSelect: case EVENT_CtrlSelect:
{ {
//switch(pEvent->sParam1) //switch(pEvent->sParam1)
@ -41,10 +48,12 @@ Boolean TMainForm::EventHandler(TApplication * pApp, EventType * pEvent)
//} //}
} }
break; break;
case EVENT_WinClose: case EVENT_WinClose:
{ {
// Stop the application since the main form has been closed // Stop the application since the main form has been closed
pApp->SendStopEvent(); pApp->SendStopEvent();
bHandled = TRUE;
} }
break; break;
} }

View File

@ -19,6 +19,7 @@ public:
public: public:
virtual Boolean EventHandler(TApplication * pApp, EventType * pEvent); virtual Boolean EventHandler(TApplication * pApp, EventType * pEvent);
protected: protected:
}; };