diff --git a/HelloWorld/HelloWorld_Arm.TMK3 b/HelloWorld/HelloWorld_Arm.TMK3 index 9e95aa4a3d..9cdd721b37 100644 --- a/HelloWorld/HelloWorld_Arm.TMK3 +++ b/HelloWorld/HelloWorld_Arm.TMK3 @@ -29,15 +29,16 @@ INCLUDE_TMK3=$(TO_PROJECT_ROOT)/MakeInclude/TG3_APP_Arm.TMK3 ;TOPS ;PRE_DEFINE=USE_MTAPI=1 ;使用 MTAPI 库,此时生成的 Makefile 会自动连接有关的LIB ;C、C++预定义宏,可以使用多个DEFINES串,也可以使用DEFINES1、DEFINES2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -DEFINES=-D_MY_MARCO_ ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可 +DEFINES=-DCCX_UNDER_UPHONE ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可 ;DEFINES=-D__TG3_PURE_DLL__ ;生成的是纯动态库(意思是:不是TOPS应用,但可以是TCOM组件) ;DEFINES=-D__TCOM_SUPPORT__ ;生成的是TCOM组件(注意:TOPS应用也可以同时是TCOM组件) ;包含路径,可以使用多个INCLUDE_PATH串,也可以使用INCLUDE_PATH1、INCLUDE_PATH2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -INCLUDE_PATH= ;应用额外的包含路径。注意:ITOPS自己的所有路径都会自动包含,故此这里仅仅包含应用自己特有的路径即可 +INCLUDE_PATH=-I../cocos2dx +INCLUDE_PATH=-I../cocos2dx/include ;连接的库文件,可以使用多个LIBS串,也可以使用LIBS1、LIBS2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -LIBS=-lMyLib ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可 +LIBS=-lcocos2d ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可 ;强制包含文件的名字,不能使用通配符,一定要使用相对或者绝对路径 ;极力要求使用相对路径,多个文件之间使用“|”分隔 diff --git a/HelloWorld/Makefile.ARM b/HelloWorld/Makefile.ARM index 4f7d0320b9..3c169ece24 100644 --- a/HelloWorld/Makefile.ARM +++ b/HelloWorld/Makefile.ARM @@ -1 +1,56 @@ -this file need to run .tmk3 file to rebuild. + +############################################################################ +# +# Makefile for building : HelloWorld_Arm.TMK3 +# Created by TMK3_V2.3, please do not modify. +# +############################################################################# + +TO_PROJECT_ROOT = ../../PRJ_TG3 +OUTPUT_FILENAME = libHelloWorld.so + +include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_Base_DynamicLib.ARM +include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_TOPS_Def.ARM + +DEFINES += -DCCX_UNDER_UPHONE +INCLUDE_PATH += -I. -I./Res \ + -I../cocos2dx \ + -I../cocos2dx/include +LIBS += -lcocos2d + +OBJECTS_DIR = ./Debug-ARM +DESTDIR = $(TO_PROJECT_ROOT)/$(BIN_OUTPUT_DIR) +TARGET = $(DESTDIR)/$(OUTPUT_FILENAME) + +DEL_FILE = rm -f +MKDIR = mkdir -p + +first: all + +OBJECTS = \ + $(OBJECTS_DIR)/HelloWorldApp.o \ + $(OBJECTS_DIR)/TG3AppDllEntry.o + +ADD_OBJECTS += + +$(OBJECTS_DIR) : + $(MKDIR) $(OBJECTS_DIR) + +$(DESTDIR) : + $(MKDIR) $(DESTDIR) + +all : $(OBJECTS_DIR) $(DESTDIR) $(TARGET) + +$(TARGET) : $(OBJECTS) + $(LINK) $(LINK_FLAGS) -o $(TARGET) $(SYS_OBJECTS) $(OBJECTS) $(ADD_OBJECTS) $(LIBS) $(SYS_LIBS) + +clean : + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) $(TARGET) + +$(OBJECTS_DIR)/HelloWorldApp.o : ./HelloWorldApp.cpp + $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/HelloWorldApp.o ./HelloWorldApp.cpp + +$(OBJECTS_DIR)/TG3AppDllEntry.o : ./TG3AppDllEntry.cpp + $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/TG3AppDllEntry.o ./TG3AppDllEntry.cpp + diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5e4f7d9d72..7e9dc70bf4 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -233,7 +233,10 @@ void CCDirector::mainLoop(void) glPopMatrix(); // swap buffers - m_pobOpenGLView->swapBuffers(); + if (m_pobOpenGLView) + { + m_pobOpenGLView->swapBuffers(); + } } void CCDirector::calculateDeltaTime(void) diff --git a/cocos2dx/Lib_Cocos2d_Arm_Uphone.TMK3 b/cocos2dx/Lib_Cocos2d_Arm_Uphone.TMK3 index 7d65d78b7c..64b844008e 100644 --- a/cocos2dx/Lib_Cocos2d_Arm_Uphone.TMK3 +++ b/cocos2dx/Lib_Cocos2d_Arm_Uphone.TMK3 @@ -29,8 +29,8 @@ INCLUDE_TMK3=$(TO_PROJECT_ROOT)/MakeInclude/TG3_APP_Arm.TMK3 ;PRE_DEFINE=USE_MTAPI=1 ;使用 MTAPI 库,此时生成的 Makefile 会自动连接有关的LIB ;C、C++预定义宏,可以使用多个DEFINES串,也可以使用DEFINES1、DEFINES2等方式,MakeFile中依据出现顺序(不是数字大小)排列 -DEFINES=-D_MY_MARCO_ ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可 -;DEFINES=-D__TG3_PURE_DLL__ ;生成的是纯动态库(意思是:不是TOPS应用,但可以是TCOM组件) +DEFINES=-DCCX_UNDER_UPHONE ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可 +DEFINES=-D__TG3_PURE_DLL__ ;生成的是纯动态库(意思是:不是TOPS应用,但可以是TCOM组件) ;DEFINES=-D__TCOM_SUPPORT__ ;生成的是TCOM组件(注意:TOPS应用也可以同时是TCOM组件) ;包含路径,可以使用多个INCLUDE_PATH串,也可以使用INCLUDE_PATH1、INCLUDE_PATH2等方式,MakeFile中依据出现顺序(不是数字大小)排列 @@ -42,7 +42,7 @@ INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng ;连接的库文件,可以使用多个LIBS串,也可以使用LIBS1、LIBS2等方式,MakeFile中依据出现顺序(不是数字大小)排列 ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可 -LIBS= +LIBS= -lTG3_EGL -lTG3_GLESv1_CM -lTG3_GLESv2 -lz -lxml2 -lpng14 -lImageToolKit ;强制包含文件的名字,不能使用通配符,一定要使用相对或者绝对路径 ;极力要求使用相对路径,多个文件之间使用“|”分隔 diff --git a/cocos2dx/Makefile.ARM b/cocos2dx/Makefile.ARM index 189a391e6b..9c6b276a0a 100644 --- a/cocos2dx/Makefile.ARM +++ b/cocos2dx/Makefile.ARM @@ -12,11 +12,13 @@ OUTPUT_FILENAME = libcocos2d.so include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_Base_DynamicLib.ARM include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_TOPS_Def.ARM -DEFINES += -D_MY_MARCO_ +DEFINES += -DCCX_UNDER_UPHONE \ + -D__TG3_PURE_DLL__ -D_ENABLE_CHECK_POINT_ INCLUDE_PATH += -I. -I./Res \ -I./ -I./Res -I./include -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2 \ -I$(TO_PROJECT_ROOT)/Include/ThirdParty/iconv \ -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng +LIBS += -lTG3_EGL -lTG3_GLESv1_CM -lTG3_GLESv2 -lz -lxml2 -lpng14 -lImageToolKit OBJECTS_DIR = ./Debug-ARM DESTDIR = $(TO_PROJECT_ROOT)/$(BIN_OUTPUT_DIR) @@ -34,6 +36,7 @@ OBJECTS = \ $(OBJECTS_DIR)/CCDrawingPrimitives.o \ $(OBJECTS_DIR)/CCScheduler.o \ $(OBJECTS_DIR)/cocos2d.o \ + $(OBJECTS_DIR)/profile.o \ $(OBJECTS_DIR)/CCAction.o \ $(OBJECTS_DIR)/CCActionManager.o \ $(OBJECTS_DIR)/CCCameraAction.o \ @@ -140,6 +143,9 @@ $(OBJECTS_DIR)/CCScheduler.o : ./CCScheduler.cpp $(OBJECTS_DIR)/cocos2d.o : ./cocos2d.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/cocos2d.o ./cocos2d.cpp +$(OBJECTS_DIR)/profile.o : ./profile.cpp + $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/profile.o ./profile.cpp + $(OBJECTS_DIR)/CCAction.o : ./actions/CCAction.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCAction.o ./actions/CCAction.cpp diff --git a/cocos2dx/cocoa/CGAffineTransform.cpp b/cocos2dx/cocoa/CGAffineTransform.cpp index 760bc0d9c8..0cd31eb913 100644 --- a/cocos2dx/cocoa/CGAffineTransform.cpp +++ b/cocos2dx/cocoa/CGAffineTransform.cpp @@ -26,6 +26,8 @@ THE SOFTWARE. #include using namespace std; + + namespace cocos2d { CGAffineTransform __CGAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty) diff --git a/cocos2dx/cocos2dx-uphone.vcproj b/cocos2dx/cocos2dx-uphone.vcproj index c65a5960bc..9a75479e74 100644 --- a/cocos2dx/cocos2dx-uphone.vcproj +++ b/cocos2dx/cocos2dx-uphone.vcproj @@ -945,6 +945,18 @@ + + + + + + diff --git a/cocos2dx/include/CGAffineTransform.h b/cocos2dx/include/CGAffineTransform.h index 668726ca16..237bc0cc50 100644 --- a/cocos2dx/include/CGAffineTransform.h +++ b/cocos2dx/include/CGAffineTransform.h @@ -33,14 +33,13 @@ struct CGAffineTransform { CGFloat tx, ty; }; - -inline CGAffineTransform __CGAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty); +CGAffineTransform __CGAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty); #define CGAffineTransformMake __CGAffineTransformMake -inline CGPoint __CGPointApplyAffineTransform(CGPoint point, CGAffineTransform t); +CGPoint __CGPointApplyAffineTransform(CGPoint point, CGAffineTransform t); #define CGPointApplyAffineTransform __CGPointApplyAffineTransform -inline CGSize __CGSizeApplyAffineTransform(CGSize size, CGAffineTransform t); +CGSize __CGSizeApplyAffineTransform(CGSize size, CGAffineTransform t); #define CGSizeApplyAffineTransform __CGSizeApplyAffineTransform CGAffineTransform CGAffineTransformMakeIdentity(); diff --git a/cocos2dx/platform/config_platform.h b/cocos2dx/platform/config_platform.h index 3de603bdd9..5fafe11db5 100644 --- a/cocos2dx/platform/config_platform.h +++ b/cocos2dx/platform/config_platform.h @@ -22,8 +22,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +// pre configure #ifdef _TRANZDA_VM_ // under uphone emulator #define CCX_PLATFORM_UPHONE #else - #error "no platform flag defined!!" +// #error "no platform macro defined!" +#endif + +// user configure + +#if ! defined(CCX_PLATFORM_UPHONE) && defined(CCX_UNDER_UPHONE) + #define CCX_PLATFORM_UPHONE // under uphone +#endif + + +// post configure + +#if ! defined(CCX_PLATFORM_UPHONE) +#error "no platform macro defined!" #endif diff --git a/cocos2dx/platform/uphone/CCXEGLView_uphone.cpp b/cocos2dx/platform/uphone/CCXEGLView_uphone.cpp index 7237e13604..ed45b9ac42 100644 --- a/cocos2dx/platform/uphone/CCXEGLView_uphone.cpp +++ b/cocos2dx/platform/uphone/CCXEGLView_uphone.cpp @@ -22,9 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -// #define USE_EGL_UMU +#ifdef _TRANZDA_VM_ -#ifndef USE_EGL_UMU +// #define USE_EMU_TG3_EGL_LIB + +#ifndef USE_EMU_TG3_EGL_LIB // #define _EGL_SHOW_ #include #endif @@ -32,6 +34,13 @@ THE SOFTWARE. #include "TDC.h" #undef GetNextWindow // this micro defined in winuser.h + +#else // _TRANZDA_VM_ + +#include "TG3.h" + +#endif // _TRANZDA_VM_ + #include "TApplication.h" #include "EGL/egl.h" @@ -43,7 +52,7 @@ THE SOFTWARE. #include "CCTouch.h" #include "CCTouchDispatcher.h" -#ifndef USE_EGL_UMU +#if ! defined(USE_EMU_TG3_EGL_LIB) && defined(_TRANZDA_VM_) #define WIN_CLASS_NAME "OpenGL" static bool s_keys[256]; // Array Used For The Keyboard Routine @@ -51,11 +60,13 @@ static bool s_active=TRUE; // Window Active Flag Set To TRUE By Def EGLNativeWindowType _CreateWnd(int width, int height); LRESULT CALLBACK _WndProc(HWND, UINT, WPARAM, LPARAM); -#endif +#endif // USE_EMU_TG3_EGL_LIB namespace cocos2d { +#ifdef _TRANZDA_VM_ +// impliment for uPhone emulator class CCXEGL { public: @@ -66,7 +77,15 @@ public: eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglTerminate(m_eglDisplay); } -#ifndef USE_EGL_UMU + if (EGL_NO_CONTEXT != m_eglContext) + { + eglDestroyContext(m_eglDisplay, m_eglContext); + } + if (EGL_NO_SURFACE != m_eglSurface) + { + eglDestroySurface(m_eglDisplay, m_eglSurface); + } +#ifndef USE_EMU_TG3_EGL_LIB if (m_eglDC) { ReleaseDC( (HWND)m_eglWnd, (HDC)m_eglDC); @@ -94,7 +113,7 @@ public: TRectangle rc; pWindow->GetClientBounds(&rc); CCX_BREAK_IF(! (pEGL->m_pBmp = TBitmap::Create(rc.Width(), rc.Height(), 32))); -#ifdef USE_EGL_UMU +#ifdef USE_EMU_TG3_EGL_LIB pEGL->m_eglWnd = pWindow; TDC dc(pWindow); pEGL->m_eglDC = &dc; @@ -239,6 +258,119 @@ private: EGLSurface m_eglSurface; EGLContext m_eglContext; }; + +#else // _TRANZDA_VM_ + +// impliment for uPhone device +class CCXEGL +{ +public: + ~CCXEGL() + { + if (EGL_NO_DISPLAY != m_eglDisplay) + { + eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglTerminate(m_eglDisplay); + } + if (EGL_NO_CONTEXT != m_eglContext) + { + eglDestroyContext(m_eglDisplay, m_eglContext); + } + if (EGL_NO_SURFACE != m_eglSurface) + { + eglDestroySurface(m_eglDisplay, m_eglSurface); + } + } + + static CCXEGL * create(TWindow * pWindow) + { + CCXEGL * pEGL = new CCXEGL; + Boolean bSuccess = FALSE; + do + { + CCX_BREAK_IF(! pEGL); + + TRectangle rc; + pWindow->GetClientBounds(&rc); + pEGL->m_eglWnd = pWindow; + + 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_eglConfig = eglConfig; + pEGL->m_eglContext = eglContext; + bSuccess = TRUE; + } while (0); + + if (! bSuccess) + { + CCX_SAFE_DELETE(pEGL); + } + + return pEGL; + } + + void resizeSurface() + { + // do nothing on uPhone device, because of TWindow can't change size + } + + void swapBuffers() + { + if (EGL_NO_DISPLAY != m_eglDisplay) + { + eglSwapBuffers(m_eglDisplay, m_eglSurface); + } + } +private: + CCXEGL() + : m_eglWnd(NULL) + , m_eglDC(EGL_DEFAULT_DISPLAY) + , m_eglDisplay(EGL_NO_DISPLAY) + , m_eglConfig(0) + , m_eglSurface(EGL_NO_SURFACE) + , m_eglContext(EGL_NO_CONTEXT) + {} + + EGLNativeWindowType m_eglWnd; + EGLNativeDisplayType m_eglDC; + EGLDisplay m_eglDisplay; + EGLConfig m_eglConfig; + EGLSurface m_eglSurface; + EGLContext m_eglContext; +}; + +#endif // _TRANZDA_VM_ + CCXEGLView::CCXEGLView(TApplication * pApp) : TWindow(pApp) , m_bCaptured(false) @@ -385,7 +517,7 @@ void CCXEGLView::swapBuffers() ////////////////////////////////////////////////////////////////////////// // static function ////////////////////////////////////////////////////////////////////////// -#ifndef USE_EGL_UMU +#if defined(_TRANZDA_VM_) && ! defined(USE_EMU_TG3_EGL_LIB) static EGLNativeWindowType _CreateWnd(int width, int height) { WNDCLASS wc; // Windows Class Structure