mirror of https://github.com/axmolengine/axmol.git
[uphone]issue #340.Refactor platform_support on uphone,and run HelloWorld successful on both simulator and device.
This commit is contained in:
parent
0a2ceee2c5
commit
e4063fd190
|
@ -22,8 +22,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
{
|
||||
// init the window
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
if (!(m_pMainWnd = new CCXEGLView(this)) ||
|
||||
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
|
||||
TApplication* pApp = TApplication::GetCurrentApplication();
|
||||
if (!(m_pMainWnd = new CCXEGLView(pApp)) ||
|
||||
! m_pMainWnd->Create(&TRectangle(0,0,pApp->GetScreenWidth(),pApp->GetScreenHeight())))
|
||||
#elif (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
||||
if (!(m_pMainWnd = new CCXEGLView()) ||
|
||||
! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) )
|
||||
|
@ -40,8 +41,12 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
}
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
// set the resource path
|
||||
CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/APPS/cocos2d_helloworld/");
|
||||
|
||||
// on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
|
||||
// #ifndef _TRANZDA_VM_
|
||||
// cocos2d::CCFileUtils::setResource("HelloWorld.zip");
|
||||
// #endif
|
||||
|
||||
#endif
|
||||
|
||||
// init director
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
#include "CCXApplication_uphone.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "ssBackLightControl.h"
|
||||
#include "ssKeyLockControl.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCScheduler.h"
|
||||
|
||||
// #include "CCXGLExtFunc.h"
|
||||
#include <GLES/glext.h>
|
||||
|
||||
namespace cocos2d {
|
||||
using namespace cocos2d;
|
||||
|
||||
static const Int32 CCX_ON_APPLICATION_IDLE = (EVENT_FirstUser + EVENT_LastUser) / 2;
|
||||
|
||||
// #undef _TRANZDA_VM_
|
||||
#ifdef _TRANZDA_VM_
|
||||
static LARGE_INTEGER s_nAnimationInterval;
|
||||
static LARGE_INTEGER s_nFreq;
|
||||
|
@ -30,7 +22,7 @@ static long long getTimeOfDayMicroSecond()
|
|||
}
|
||||
#endif
|
||||
|
||||
CCXApplication::CCXApplication()
|
||||
Application::Application()
|
||||
: m_bRunning(FALSE)
|
||||
, m_bNeedStop(FALSE)
|
||||
, m_bInBackground(FALSE)
|
||||
|
@ -39,7 +31,7 @@ CCXApplication::CCXApplication()
|
|||
SS_GetCurrentGTID(&m_tMsg.gtid);
|
||||
m_tMsg.type = CCX_ON_APPLICATION_IDLE;
|
||||
|
||||
Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, CCXApplication::_OnAppIdle, (UInt32)this);
|
||||
Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, Application::_OnAppIdle, (UInt32)this);
|
||||
|
||||
memset(m_AppDataPath, 0, sizeof(char) * EOS_FILE_MAX_PATH);
|
||||
|
||||
|
@ -56,18 +48,20 @@ CCXApplication::CCXApplication()
|
|||
} while (0);
|
||||
}
|
||||
|
||||
CCXApplication::~CCXApplication()
|
||||
Application::~Application()
|
||||
{
|
||||
Sys_RegisterMessageCallBack(CCX_ON_APPLICATION_IDLE, NULL, NULL);
|
||||
}
|
||||
|
||||
Boolean CCXApplication::EventHandler(EventType * pEvent)
|
||||
Boolean Application::EventHandler(EventType* pEvent)
|
||||
{
|
||||
Boolean bHandled = FALSE;
|
||||
switch (pEvent->eType)
|
||||
Boolean bHandled = FALSE;
|
||||
|
||||
switch(pEvent->eType)
|
||||
{
|
||||
case EVENT_AppLoad:
|
||||
if (! applicationDidFinishLaunching())
|
||||
setSharedApplication(*this);
|
||||
if (! m_Delegate.applicationDidFinishLaunching())
|
||||
{
|
||||
CCScheduler::purgeSharedScheduler();
|
||||
SendStopEvent();
|
||||
|
@ -82,20 +76,20 @@ Boolean CCXApplication::EventHandler(EventType * pEvent)
|
|||
break;
|
||||
|
||||
case EVENT_AppStopNotify:
|
||||
|
||||
break;
|
||||
|
||||
case EVENT_AppActiveNotify:
|
||||
if (pEvent->sParam1 == 0)
|
||||
{
|
||||
if (!m_bInBackground)
|
||||
{
|
||||
applicationDidEnterBackground();
|
||||
m_Delegate.applicationDidEnterBackground();
|
||||
m_bInBackground = true;
|
||||
}
|
||||
|
||||
if (CCDirector::sharedDirector()->isPaused())
|
||||
{
|
||||
StopMainLoop();
|
||||
StopMainLoop();
|
||||
}
|
||||
CfgTurnOnBackLight();
|
||||
EnableKeyLock();
|
||||
|
@ -104,12 +98,12 @@ Boolean CCXApplication::EventHandler(EventType * pEvent)
|
|||
{
|
||||
if (m_bInBackground)
|
||||
{
|
||||
applicationWillEnterForeground();
|
||||
m_Delegate.applicationWillEnterForeground();
|
||||
m_bInBackground = false;
|
||||
}
|
||||
|
||||
StartMainLoop();
|
||||
|
||||
|
||||
CfgTurnOnBackLightDelay(0x7fffffff);
|
||||
// if KeyLock disactived, disable it.
|
||||
if (! CfgKeyLock_GetActive())
|
||||
|
@ -119,51 +113,15 @@ Boolean CCXApplication::EventHandler(EventType * pEvent)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (! bHandled)
|
||||
if (FALSE == bHandled)
|
||||
{
|
||||
bHandled = TApplication::EventHandler(pEvent);
|
||||
return TApplication::EventHandler(pEvent);
|
||||
}
|
||||
|
||||
return bHandled;
|
||||
}
|
||||
|
||||
ccDeviceOrientation CCXApplication::setDeviceOrientation(ccDeviceOrientation eOritation)
|
||||
{
|
||||
return eOritation;
|
||||
}
|
||||
|
||||
CGRect CCXApplication::statusBarFrame()
|
||||
{
|
||||
CGRect rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void CCXApplication::StartMainLoop()
|
||||
{
|
||||
if (m_bRunning)
|
||||
{
|
||||
m_bNeedStop = FALSE;
|
||||
return;
|
||||
}
|
||||
Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &m_tMsg);
|
||||
m_bRunning = TRUE;
|
||||
}
|
||||
|
||||
void CCXApplication::StopMainLoop()
|
||||
{
|
||||
m_bNeedStop = TRUE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Implement static class member
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCXApplication * CCXApplication::sharedApplication()
|
||||
{
|
||||
return (CCXApplication *)TApplication::GetCurrentApplication();
|
||||
}
|
||||
|
||||
void CCXApplication::setAnimationInterval(double interval)
|
||||
void Application::setAnimationInterval(double interval)
|
||||
{
|
||||
#ifdef _TRANZDA_VM_
|
||||
LARGE_INTEGER nFreq;
|
||||
|
@ -174,16 +132,75 @@ void CCXApplication::setAnimationInterval(double interval)
|
|||
#endif
|
||||
}
|
||||
|
||||
Int32 CCXApplication::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData)
|
||||
Application::Orientation Application::setOrientation(Application::Orientation orientation)
|
||||
{
|
||||
CCXApplication * pThis = CCXApplication::sharedApplication();
|
||||
CCXEGLView * pView = CCDirector::sharedDirector()->getOpenGLView();
|
||||
if (pThis && pView && pThis->m_bRunning)
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void Application::statusBarFrame(CGRect * rect)
|
||||
{
|
||||
}
|
||||
|
||||
const char* Application::getAppDataPath()
|
||||
{
|
||||
return m_AppDataPath;
|
||||
}
|
||||
|
||||
void Application::switchNotify(int nTurnOn)
|
||||
{
|
||||
bool bInBack = isInBackground();
|
||||
|
||||
do
|
||||
{
|
||||
if (pThis->m_bNeedStop)
|
||||
// if the app have be in background,don't handle this message
|
||||
CCX_BREAK_IF(bInBack);
|
||||
|
||||
if (! nTurnOn) // turn off screen
|
||||
{
|
||||
pThis->m_bNeedStop = FALSE;
|
||||
pThis->m_bRunning = FALSE;
|
||||
// CCDirector::sharedDirector()->pause();
|
||||
m_Delegate.applicationDidEnterBackground();
|
||||
StopMainLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// CCDirector::sharedDirector()->resume();
|
||||
m_Delegate.applicationWillEnterForeground();
|
||||
StartMainLoop();
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
bool Application::isInBackground()
|
||||
{
|
||||
return m_bInBackground;
|
||||
}
|
||||
|
||||
void Application::StartMainLoop()
|
||||
{
|
||||
if (m_bRunning)
|
||||
{
|
||||
m_bNeedStop = FALSE;
|
||||
return;
|
||||
}
|
||||
Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &m_tMsg);
|
||||
m_bRunning = TRUE;
|
||||
}
|
||||
|
||||
void Application::StopMainLoop()
|
||||
{
|
||||
m_bNeedStop = TRUE;
|
||||
}
|
||||
|
||||
Int32 Application::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData)
|
||||
{
|
||||
Application& rThis = (Application&) Application::sharedApplication();
|
||||
CCXEGLView * pView = CCDirector::sharedDirector()->getOpenGLView();
|
||||
if (pView && rThis.m_bRunning)
|
||||
{
|
||||
if (rThis.m_bNeedStop)
|
||||
{
|
||||
rThis.m_bNeedStop = FALSE;
|
||||
rThis.m_bRunning = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -207,20 +224,8 @@ Int32 CCXApplication::_OnAppIdle(MESSAGE_t * pMsg, UInt32 uData)
|
|||
{
|
||||
Sys_Sleep(0);
|
||||
}
|
||||
Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &pThis->m_tMsg);
|
||||
Sys_PostMessage2(MESSAGE_PRIOR_LOWEST, &rThis.m_tMsg);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* CCXApplication::getAppDataPath()
|
||||
{
|
||||
return m_AppDataPath;
|
||||
}
|
||||
|
||||
bool CCXApplication::isInBackground()
|
||||
{
|
||||
return m_bInBackground;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef __COCOS2D_HELLOWORLD_APP_H__
|
||||
#define __COCOS2D_HELLOWORLD_APP_H__
|
||||
#include "TG3.h"
|
||||
#include "cocos2d.h"
|
||||
#include "AppDelegate.h"
|
||||
|
||||
class Application : public TApplication, public cocos2d::ccxApplication
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
virtual ~Application();
|
||||
|
||||
virtual Boolean EventHandler(EventType * pEvent);
|
||||
|
||||
public:
|
||||
// implement the virtual interface of class ccxApplication
|
||||
virtual void setAnimationInterval(double interval);
|
||||
virtual Orientation setOrientation(Orientation orientation);
|
||||
virtual void statusBarFrame(cocos2d::CGRect * rect);
|
||||
virtual const char* getAppDataPath();
|
||||
virtual void switchNotify(int nTurnOn);
|
||||
|
||||
protected:
|
||||
bool isInBackground();
|
||||
void StartMainLoop();
|
||||
void StopMainLoop();
|
||||
|
||||
private:
|
||||
static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData);
|
||||
|
||||
MESSAGE_t m_tMsg;
|
||||
bool m_bRunning;
|
||||
bool m_bNeedStop;
|
||||
bool m_bInBackground;
|
||||
char m_AppDataPath[EOS_FILE_MAX_PATH];
|
||||
AppDelegate m_Delegate;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -40,7 +40,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\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;..\..\..\PRJ_TG3\Include\OpenGL;..\uphone;..\;.\Res"
|
||||
AdditionalIncludeDirectories="..\..\..\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;..\..\..\PRJ_TG3\Include\OpenGL;..\uphone;..\;.\Res;..\..\platform_support\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -63,7 +63,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libcocos2d.lib"
|
||||
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libcocos2d.lib libPlatformSupport.lib"
|
||||
OutputFile="$(OutDir)/HelloWorld.dll"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../../../PRJ_TG3/Common/ICU/lib;../../../PRJ_TG3/Mtapi/Win32/lib;../../../PRJ_TG3/LIB/Win32Lib;../../../PRJ_TG3/Common/SoftSupport"
|
||||
|
@ -252,6 +252,14 @@
|
|||
<Filter
|
||||
Name="Framework"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Application.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Application.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\HelloWorldUnicodeScript.h"
|
||||
>
|
||||
|
|
|
@ -1,26 +1,19 @@
|
|||
// Unicode string resource file
|
||||
|
||||
// Original file name: HelloWorldUnicodeScript_str.h
|
||||
// Generated by TOPS Builder:Project wizard,Date:2010-11-27
|
||||
|
||||
|
||||
#ifndef __HelloWorld_STR_STR_H__
|
||||
#define __HelloWorld_STR_STR_H__
|
||||
#ifndef __HELLOWORLDUNICODESCRIPT_STR_H__
|
||||
#define __HELLOWORLDUNICODESCRIPT_STR_H__
|
||||
|
||||
|
||||
#define AppName_HelloWorld__N \
|
||||
"A\x00p\x00p\x00_\x00T\x00\x65\x00s\x00t\x00"
|
||||
#define AppName_HelloWorld__C \
|
||||
#define AppName_HelloWorld__N \
|
||||
"H\x00\x65\x00l\x00l\x00o\x00W\x00o\x00r\x00l\x00\x64\x00"
|
||||
#define AppName_HelloWorld__C \
|
||||
AppName_HelloWorld__N"\x00\x00"
|
||||
#define AppName_HelloWorld \
|
||||
((const unsigned short *)(AppName_HelloWorld__C))
|
||||
#define AppName_HelloWorld__N16 \
|
||||
0x0041,0x0070,0x0070,0x005f,0x0054,0x0065,0x0073,0x0074
|
||||
#define AppName_HelloWorld_16 \
|
||||
#define AppName_HelloWorld \
|
||||
((const unsigned short *)(AppName_HelloWorld__C))
|
||||
#define AppName_HelloWorld__N16 \
|
||||
0x0048,0x0065,0x006c,0x006c,0x006f,0x0057,0x006f,0x0072,0x006c,0x0064
|
||||
#define AppName_HelloWorld_16 \
|
||||
{AppName_HelloWorld__N16,0x0000}
|
||||
// 原始串信息:
|
||||
// HelloWorld
|
||||
// HelloWorld
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif //__HELLOWORLDUNICODESCRIPT_STR_H__
|
||||
|
|
|
@ -17,8 +17,9 @@ INCLUDE_PATH += -I./Res \
|
|||
-I../ \
|
||||
-I../uphone \
|
||||
-I../../cocos2dx \
|
||||
-I../../cocos2dx/include
|
||||
LIBS += -lCocos2dStatic -lTG3_GLESv1_CM -lTG3_EGL -lz -lxml2 -lpng14 -lImageToolKit -ljpeg
|
||||
-I../../cocos2dx/include \
|
||||
-I../../platform_support/include
|
||||
LIBS += -lCocos2dStatic -lPlatformSupportStatic -lTG3_GLESv1_CM -lTG3_EGL -lz -lxml2 -lpng14 -lImageToolKit -ljpeg
|
||||
|
||||
OBJECTS_DIR = ./Debug-ARM
|
||||
DESTDIR = $(TO_PROJECT_ROOT)/$(BIN_OUTPUT_DIR)
|
||||
|
@ -31,6 +32,7 @@ first: all
|
|||
|
||||
OBJECTS = \
|
||||
$(OBJECTS_DIR)/AppDelegate.o \
|
||||
$(OBJECTS_DIR)/Application.o \
|
||||
$(OBJECTS_DIR)/HelloWorldScene.o \
|
||||
$(OBJECTS_DIR)/main.o \
|
||||
$(OBJECTS_DIR)/TG3AppDllEntry.o
|
||||
|
@ -55,6 +57,9 @@ clean :
|
|||
$(OBJECTS_DIR)/AppDelegate.o : ../AppDelegate.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/AppDelegate.o ../AppDelegate.cpp
|
||||
|
||||
$(OBJECTS_DIR)/Application.o : ./Application.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/Application.o ./Application.cpp
|
||||
|
||||
$(OBJECTS_DIR)/HelloWorldScene.o : ../HelloWorldScene.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/HelloWorldScene.o ../HelloWorldScene.cpp
|
||||
|
||||
|
|
|
@ -5,21 +5,14 @@
|
|||
|
||||
// uphone header
|
||||
#include "TG3.h"
|
||||
// cocos2d
|
||||
#include "cocos2d.h"
|
||||
|
||||
// game
|
||||
#include "AppDelegate.h"
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
|
||||
{
|
||||
AppDelegate app;
|
||||
|
||||
// on uphone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
|
||||
#ifndef _TRANZDA_VM_
|
||||
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
|
||||
#endif
|
||||
|
||||
Application app;
|
||||
app.Run();
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -11,6 +11,9 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chipmunk", "chipmunk\proj.uphone\chipmunk.uphone.vcproj", "{BA00DDF7-0F25-4C1E-B012-FA230C1F6463}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cocos2d-uphone", "cocos2dx\proj.uphone\cocos2d-uphone.vcproj", "{6AC43F51-A036-4653-B910-BDDC346D15E7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{560E20BA-9562-4AFC-A222-6B7B1956D607} = {560E20BA-9562-4AFC-A222-6B7B1956D607}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDenshion", "CocosDenshion\proj.uphone\CocosDenshion.uphone.vcproj", "{AB17438B-7848-4FD6-AF6E-A6A91F82C6F0}"
|
||||
EndProject
|
||||
|
@ -27,6 +30,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "tests\test.uphone\
|
|||
{BA00DDF7-0F25-4C1E-B012-FA230C1F6463} = {BA00DDF7-0F25-4C1E-B012-FA230C1F6463}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PlatformSupport", "platform_support\proj.uphone\PlatformSupport.uphone.vcproj", "{560E20BA-9562-4AFC-A222-6B7B1956D607}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -61,6 +66,10 @@ Global
|
|||
{33819ACD-9774-4E68-AFBE-7A88BBA7B19D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{33819ACD-9774-4E68-AFBE-7A88BBA7B19D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{33819ACD-9774-4E68-AFBE-7A88BBA7B19D}.Release|Win32.Build.0 = Release|Win32
|
||||
{560E20BA-9562-4AFC-A222-6B7B1956D607}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{560E20BA-9562-4AFC-A222-6B7B1956D607}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{560E20BA-9562-4AFC-A222-6B7B1956D607}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{560E20BA-9562-4AFC-A222-6B7B1956D607}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -33,8 +33,6 @@ THE SOFTWARE.
|
|||
#include "ccxStdC.h"
|
||||
|
||||
#define NSAssert(cond, msg) CCX_ASSERT(cond)
|
||||
#define MIN min
|
||||
#define MAX max
|
||||
|
||||
#include "ccConfig.h"
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxStdC.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
int CCTime::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxThread.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
struct cc_timeval
|
||||
{
|
||||
|
@ -47,9 +47,6 @@ class NSLock : public ccxLock{};
|
|||
NS_CC_END;
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
#include "uphone/CCTime.h"
|
||||
#include "uphone/NSLock.h"
|
||||
#include "uphone/CCXBitmapDC.h"
|
||||
#elif (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
||||
#elif (CCX_TARGET_PLATFORM == CCX_PLATFORM_ANDROID)
|
||||
#include "android/CCTime.h"
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCTime.h"
|
||||
#include <TG3.h>
|
||||
namespace cocos2d {
|
||||
|
||||
// although it is not the same as gettimeofday as unix
|
||||
// but we only use the diffrences of tow values
|
||||
int CCTime::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp)
|
||||
{
|
||||
unsigned int ms = TimGetTicks();
|
||||
tp->tv_sec = ms * 10 / 1000;
|
||||
tp->tv_usec = ms * 10 % 1000 * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCTime::timersubCocos2d(struct cc_timeval *out, struct cc_timeval *start, struct cc_timeval *end)
|
||||
{
|
||||
out->tv_sec = end->tv_sec - start->tv_sec;
|
||||
out->tv_usec = end->tv_usec - start->tv_usec;
|
||||
}
|
||||
}//namespace cocos2d
|
|
@ -1,43 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __PLATFORM_UPHONE_CCTIME_H__
|
||||
#define __PLATFORM_UPHONE_CCTIME_H__
|
||||
namespace cocos2d {
|
||||
|
||||
struct cc_timeval
|
||||
{
|
||||
long tv_sec; // seconds
|
||||
long tv_usec; // microSeconds
|
||||
};
|
||||
|
||||
class CCTime
|
||||
{
|
||||
public:
|
||||
static int gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp);
|
||||
static void timersubCocos2d(struct cc_timeval *out, struct cc_timeval *start, struct cc_timeval *end);
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __PLATFORM_UPHONE_NSTIME_H__
|
|
@ -1,106 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CGGeometry.h"
|
||||
|
||||
#include "TG3.h"
|
||||
|
||||
#include "CCDirector.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 bool applicationDidFinishLaunching() = 0;
|
||||
|
||||
/**
|
||||
@brief rotate main window by device orientation.
|
||||
@param nOritation device orientation enum value.
|
||||
@see ccDeviceOrientation
|
||||
*/
|
||||
ccDeviceOrientation setDeviceOrientation(ccDeviceOrientation eOritation);
|
||||
|
||||
/**
|
||||
@brief Get status bar rectangle in EGLView window.
|
||||
*/
|
||||
CGRect statusBarFrame();
|
||||
|
||||
/**
|
||||
@brief The function be called when the application enter background
|
||||
@param the pointer of the application
|
||||
*/
|
||||
virtual void applicationDidEnterBackground() {}
|
||||
|
||||
/**
|
||||
@brief The function be called when the application enter foreground
|
||||
@param the pointer of the application
|
||||
*/
|
||||
virtual void applicationWillEnterForeground() {}
|
||||
|
||||
/**
|
||||
@brief Get current applicaiton instance.
|
||||
@return Current application instance pointer.
|
||||
*/
|
||||
static CCXApplication * sharedApplication();
|
||||
|
||||
void StartMainLoop();
|
||||
void StopMainLoop();
|
||||
|
||||
/**
|
||||
@brief Get the data path of the Application.
|
||||
@return If the app is installed,the return value is the path of .so file.
|
||||
else the return value is "/NEWPLUS/TG3/APP/"
|
||||
*/
|
||||
const char* getAppDataPath();
|
||||
|
||||
void setAnimationInterval(double interval);
|
||||
bool isInBackground();
|
||||
|
||||
private:
|
||||
static Int32 _OnAppIdle(MESSAGE_t * pMsg, UInt32 uData);
|
||||
|
||||
MESSAGE_t m_tMsg;
|
||||
bool m_bRunning;
|
||||
bool m_bNeedStop;
|
||||
bool m_bInBackground;
|
||||
char m_AppDataPath[EOS_FILE_MAX_PATH];
|
||||
};
|
||||
|
||||
} // end of namespace cocos2d
|
||||
|
||||
#endif // end of __CCX_APPLICATION_UPHONE_H__
|
|
@ -1,162 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
#include <cstring>
|
||||
#include "CCXBitmapDC.h"
|
||||
#include "CCXApplication_uphone.h"
|
||||
#include "CCDirector.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
static TWindow * s_pMemWnd = NULL;
|
||||
|
||||
CCXBitmapDC::CCXBitmapDC(int width, int height)
|
||||
: m_pBitmap(NULL)
|
||||
{
|
||||
m_pBitmap = TBitmap::Create(width, height, 32);
|
||||
}
|
||||
|
||||
CCXBitmapDC::CCXBitmapDC(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
: m_pBitmap(NULL)
|
||||
{
|
||||
TUChar *pText = NULL;
|
||||
do
|
||||
{
|
||||
// create font
|
||||
TFont font;
|
||||
CCX_BREAK_IF(! font.Create(0, (Int32)fontSize));
|
||||
|
||||
// text
|
||||
Int32 len = strlen(text) + 1;
|
||||
CCX_BREAK_IF(! (pText = new TUChar[len]));
|
||||
TUString::StrGBToUnicode(pText, (Char*)text);
|
||||
|
||||
// calculate text size
|
||||
if (CGSize::CGSizeEqualToSize(dimensions, CGSizeZero))
|
||||
{
|
||||
m_tSize.width = font.CharsWidth(pText,len);
|
||||
m_tSize.height = font.LineHeight();
|
||||
}else
|
||||
{
|
||||
m_tSize = dimensions;
|
||||
}
|
||||
|
||||
Int16 width = (Int16)m_tSize.width;
|
||||
Int16 height = (Int16)m_tSize.height;
|
||||
|
||||
// create bitmap
|
||||
CCX_BREAK_IF(! (m_pBitmap = TBitmap::Create(width, height, 32)));
|
||||
|
||||
// create memory window
|
||||
if (s_pMemWnd)
|
||||
{
|
||||
TRectangle rcMemWnd(0, 0, 0, 0);
|
||||
s_pMemWnd->GetClientBounds(&rcMemWnd);
|
||||
if (rcMemWnd.Width() < width || rcMemWnd.Height() < height)
|
||||
{
|
||||
s_pMemWnd->CloseWindow();
|
||||
s_pMemWnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// if memery window is already break
|
||||
CCX_BREAK_IF(s_pMemWnd);
|
||||
|
||||
CCX_BREAK_IF(! (s_pMemWnd = new TWindow(CCXApplication::sharedApplication())));
|
||||
|
||||
Coord nCurrentWidth = CCXApplication::GetCurrentApplication()->GetScreenWidth();
|
||||
Coord nCurrentHeight = CCXApplication::GetCurrentApplication()->GetScreenHeight();
|
||||
|
||||
Coord nMemWndW = (width >= nCurrentWidth) ? width : nCurrentWidth;
|
||||
Coord nMemWndH = (height >= nCurrentHeight) ? height : nCurrentHeight;
|
||||
CCX_BREAK_IF(s_pMemWnd->CreateMemWindow(nMemWndW, nMemWndH,screenTransparentFormat));
|
||||
delete s_pMemWnd;
|
||||
s_pMemWnd = NULL;
|
||||
} while (0);
|
||||
|
||||
CCX_BREAK_IF(! s_pMemWnd);
|
||||
|
||||
// create DC
|
||||
TDC dc(s_pMemWnd);
|
||||
// set DC styles
|
||||
UInt32 styles = GUI_API_STYLE_SPECIFY_FORE_COLOR | GUI_API_STYLE_ROP_MODE_TRANSPARENT |
|
||||
GUI_API_STYLE_SPECIFY_BACK_COLOR | GUI_API_STYLE_ALIGNMENT_MIDDLE | GUI_API_STYLE_SPECIFY_FONT;
|
||||
|
||||
switch (alignment)
|
||||
{
|
||||
case UITextAlignmentLeft:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_LEFT;
|
||||
break;
|
||||
case UITextAlignmentCenter:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_CENTER;
|
||||
break;
|
||||
case UITextAlignmentRight:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_RIGHT;
|
||||
break;
|
||||
default:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_CENTER;
|
||||
break;
|
||||
}
|
||||
|
||||
s_pMemWnd->GetMemWindowTBitmapPtr()->Fill32(RGBA(0, 0, 0, 0), 0, 0, width, height);
|
||||
|
||||
TRectangle rect(0, 0, width, height);
|
||||
dc.DrawTextInRectangleEx(pText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), font, &rect, styles);
|
||||
|
||||
dc.ReadBitmap(m_pBitmap, 0, 0);
|
||||
|
||||
} while (0);
|
||||
if (pText)
|
||||
{
|
||||
delete[] pText;
|
||||
pText = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CCXBitmapDC::~CCXBitmapDC(void)
|
||||
{
|
||||
if (m_pBitmap)
|
||||
{
|
||||
m_pBitmap->Destroy();
|
||||
m_pBitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void *CCXBitmapDC::getBuffer()
|
||||
{
|
||||
return m_pBitmap->GetDataPtr();
|
||||
}
|
||||
|
||||
CGSize CCXBitmapDC::getSize()
|
||||
{
|
||||
return m_tSize;
|
||||
}
|
||||
|
||||
TBitmap* CCXBitmapDC::getBitmap()
|
||||
{
|
||||
return m_pBitmap;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CCXBITMAP_DC_H__
|
||||
#define __CCXBITMAP_DC_H__
|
||||
|
||||
#include "TG3.h"
|
||||
#include "ccTypes.h"
|
||||
#include "CCXCocos2dDefine.h"
|
||||
#include "CCXUIImage.h"
|
||||
|
||||
namespace cocos2d{
|
||||
class CCX_DLL CCXBitmapDC
|
||||
{
|
||||
public:
|
||||
CCXBitmapDC(int width, int height);
|
||||
CCXBitmapDC(const char *text,
|
||||
CGSize dimensions = CGSizeZero,
|
||||
UITextAlignment alignment = UITextAlignmentCenter,
|
||||
const char *fontName = NULL,
|
||||
float fontSize = 0);
|
||||
~CCXBitmapDC(void);
|
||||
|
||||
TBitmap* getBitmap(void);
|
||||
CGSize getSize(void);
|
||||
void* getBuffer(void);
|
||||
protected:
|
||||
TBitmap *m_pBitmap;
|
||||
CGSize m_tSize;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //__CCXBITMAP_DC_H__
|
|
@ -1,117 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __PLATFORM_UPHONE_CCXCOCOS2D_DEFINE_H__
|
||||
#define __PLATFORM_UPHONE_CCXCOCOS2D_DEFINE_H__
|
||||
|
||||
/** CCX_PROPERTY_READONLY is used to declare a protected variable.
|
||||
We can use getter to read the variable.
|
||||
@param varType : the type of variable.
|
||||
@param varName : variable name.
|
||||
@param funName : "get + funName" is the name of the getter.
|
||||
@warning : The getter is a public virtual function, you should rewrite it first.
|
||||
The variables and methods declared after CCX_PROPERTY_READONLY are all public.
|
||||
If you need protected or private, please declare.
|
||||
*/
|
||||
#define CCX_PROPERTY_READONLY(varType, varName, funName)\
|
||||
protected: varType varName;\
|
||||
public: virtual varType get##funName(void);
|
||||
|
||||
/** CCX_PROPERTY is used to declare a protected variable.
|
||||
We can use getter to read the variable, and use the setter to change the variable.
|
||||
@param varType : the type of variable.
|
||||
@param varName : variable name.
|
||||
@param funName : "get + funName" is the name of the getter.
|
||||
"set + funName" is the name of the setter.
|
||||
@warning : The getter and setter are public virtual functions, you should rewrite them first.
|
||||
The variables and methods declared after CCX_PROPERTY are all public.
|
||||
If you need protected or private, please declare.
|
||||
*/
|
||||
#define CCX_PROPERTY(varType, varName, funName)\
|
||||
protected: varType varName;\
|
||||
public: virtual varType get##funName(void);\
|
||||
public: virtual void set##funName(varType var);
|
||||
|
||||
/** CCX_SYNTHESIZE_READONLY is used to declare a protected variable.
|
||||
We can use getter to read the variable.
|
||||
@param varType : the type of variable.
|
||||
@param varName : variable name.
|
||||
@param funName : "get + funName" is the name of the getter.
|
||||
@warning : The getter is a public inline function.
|
||||
The variables and methods declared after CCX_SYNTHESIZE_READONLY are all public.
|
||||
If you need protected or private, please declare.
|
||||
*/
|
||||
#define CCX_SYNTHESIZE_READONLY(varType, varName, funName)\
|
||||
protected: varType varName;\
|
||||
public: inline varType get##funName(void){ return varName; }
|
||||
|
||||
/** CCX_SYNTHESIZE is used to declare a protected variable.
|
||||
We can use getter to read the variable, and use the setter to change the variable.
|
||||
@param varType : the type of variable.
|
||||
@param varName : variable name.
|
||||
@param funName : "get + funName" is the name of the getter.
|
||||
"set + funName" is the name of the setter.
|
||||
@warning : The getter and setter are public inline functions.
|
||||
The variables and methods declared after CCX_SYNTHESIZE are all public.
|
||||
If you need protected or private, please declare.
|
||||
*/
|
||||
#define CCX_SYNTHESIZE(varType, varName, funName)\
|
||||
protected: varType varName;\
|
||||
public: inline varType get##funName(void){ return varName; }\
|
||||
public: inline void set##funName(varType var){ varName = var; }
|
||||
|
||||
#define CCX_SAFE_DELETE(p) if(p) { delete p; p=NULL; }
|
||||
#define CCX_SAFE_DELETE_ARRAY(p) if(p) { delete[] p; p=NULL; }
|
||||
#define CCX_SAFE_FREE(p) if(p) { free(p); p=NULL; }
|
||||
#define CCX_SAFE_RELEASE(p) if(p) { p->release(); }
|
||||
#define CCX_SAFE_RELEASE_NULL(p) if(p) { p->release(); p = NULL; }
|
||||
#define CCX_SAFE_RETAIN(p) if(p) { p->retain(); }
|
||||
#define CCX_BREAK_IF(cond) if(cond) break;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#define NSAssert(_CONDITION, _TXT)\
|
||||
if(! (_CONDITION) ) \
|
||||
{ \
|
||||
assert( (_CONDITION) ); \
|
||||
}
|
||||
#else
|
||||
#define NSAssert(_CONDITION, _TXT)
|
||||
#endif // _DEBUG
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define self this
|
||||
#define YES true
|
||||
#define NO false
|
||||
#define nil NULL
|
||||
|
||||
#endif // __PLATFORM_UPHONE_CCXCOCOS2D_DEFINE_H__
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ccxCommon_uphone.h"
|
||||
|
||||
#include "TG3.h"
|
||||
|
||||
#define MAX_LEN 256
|
||||
#define LOG_FILE_PATH "/NEWPLUS/TDA_DATA/UserData/Cocos2dLog.txt"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
void CCXLog(const char * pszFormat, ...)
|
||||
{
|
||||
SS_printf("Cocos2d: ");
|
||||
char szBuf[MAX_LEN];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, pszFormat);
|
||||
#ifdef _TRANZDA_VM_
|
||||
vsprintf_s(szBuf, MAX_LEN, pszFormat, ap);
|
||||
#else
|
||||
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
|
||||
SS_printf("%s", szBuf);
|
||||
#ifdef _TRANZDA_VM_
|
||||
SS_printf("\n");
|
||||
#else
|
||||
SS_printf("\r\n");
|
||||
FILE * pf = fopen(LOG_FILE_PATH, "a+");
|
||||
if (! pf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(szBuf, 1, strlen(szBuf), pf);
|
||||
fwrite("\r\n", 1, strlen("\r\n"), pf);
|
||||
fflush(pf);
|
||||
fclose(pf);
|
||||
#endif
|
||||
}
|
||||
|
||||
}//namespace cocos2d
|
|
@ -28,7 +28,6 @@ THE SOFTWARE.
|
|||
#include "EGL/egl.h"
|
||||
#include "GLES/gl.h"
|
||||
|
||||
#include "CCXCocos2dDefine.h"
|
||||
#include "NSSet.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCTouch.h"
|
||||
|
@ -297,23 +296,7 @@ Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent)
|
|||
|
||||
case EVENT_ScreenSwitchNotify:
|
||||
{
|
||||
bool bInBack = CCXApplication::sharedApplication()->isInBackground();
|
||||
|
||||
// if the app have be in background,don't handle this message
|
||||
CCX_BREAK_IF(bInBack);
|
||||
|
||||
if (! pEvent->sParam1) // turn off screen
|
||||
{
|
||||
// CCDirector::sharedDirector()->pause();
|
||||
CCXApplication::sharedApplication()->applicationDidEnterBackground();
|
||||
CCXApplication::sharedApplication()->StopMainLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// CCDirector::sharedDirector()->resume();
|
||||
CCXApplication::sharedApplication()->applicationWillEnterForeground();
|
||||
CCXApplication::sharedApplication()->StartMainLoop();
|
||||
}
|
||||
ccxApplication::sharedApplication().switchNotify(pEvent->sParam1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ THE SOFTWARE.
|
|||
#include <TG3.h>
|
||||
#include "NSString.h"
|
||||
#include "CCXFileUtils_uphone.h"
|
||||
#include "CCXCocos2dDefine.h"
|
||||
#include "CCXApplication.h"
|
||||
|
||||
#include "support/file_support/FileData.h"
|
||||
|
@ -219,7 +218,7 @@ void updateZipFilePath(const char* pResPath)
|
|||
}
|
||||
else
|
||||
{
|
||||
ResPath = CCXApplication::sharedApplication()->getAppDataPath();
|
||||
ResPath = ccxApplication::sharedApplication().getAppDataPath();
|
||||
}
|
||||
|
||||
// replace the resource path in s_pszZipFilePath
|
||||
|
@ -245,7 +244,7 @@ void setZipFilePath(const char* pZipFileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* pAppDataPath = CCXApplication::sharedApplication()->getAppDataPath();
|
||||
const char* pAppDataPath = ccxApplication::sharedApplication().getAppDataPath();
|
||||
strcpy(fullPath, pAppDataPath);
|
||||
}
|
||||
strcat(fullPath, pZipFileName);
|
||||
|
@ -314,7 +313,7 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
|||
// get the user data path and append relative path to it
|
||||
if (strlen(s_pszResourcePath) == 0)
|
||||
{
|
||||
const char* pAppDataPath = CCXApplication::sharedApplication()->getAppDataPath();
|
||||
const char* pAppDataPath = ccxApplication::sharedApplication().getAppDataPath();
|
||||
strcpy(s_pszResourcePath, pAppDataPath);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCXUIAccelerometer_uphone.h"
|
||||
#include "CCXCocos2dDefine.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
#include "TCOM_Generic_Method_IIDs.h"
|
||||
|
|
|
@ -1,425 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCXUIImage_uphone.h"
|
||||
#include "CCXFileUtils.h"
|
||||
#include "TG3.h"
|
||||
#include "png.h"
|
||||
|
||||
#include "CCXBitmapDC.h"
|
||||
#include "support/file_support/FileData.h"
|
||||
|
||||
// in order to compile correct in andLinux, because ssTypes(uphone)
|
||||
// and jmorecfg.h all typedef xxx INT32
|
||||
#define QGLOBAL_H
|
||||
#include "jpeglib.h"
|
||||
#undef QGLOBAL_H
|
||||
|
||||
//using namespace ImageToolKit;
|
||||
using namespace std;
|
||||
namespace cocos2d {
|
||||
|
||||
#define CCX_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
|
||||
(ColorRefType)(((UInt32)((UInt8)(vr) * ((UInt8)(va) + 1)) >> 8) | \
|
||||
((UInt32)((UInt8)(vg) * ((UInt8)(va) + 1) >> 8) << 8) | \
|
||||
((UInt32)((UInt8)(vb) * ((UInt8)(va) + 1) >> 8) << 16) | \
|
||||
((UInt32)(UInt8)(va) << 24))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char* data;
|
||||
int size;
|
||||
int offset;
|
||||
}tImageSource;
|
||||
|
||||
bool UIImage::s_bPopupNotify = true;
|
||||
|
||||
// because we do not want to include "png.h" in CCXUIImage_uphone.h, so we implement
|
||||
// the function as a static function
|
||||
static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
tImageSource* isource = (tImageSource*)png_get_io_ptr(png_ptr);
|
||||
|
||||
if((int)(isource->offset + length) <= isource->size)
|
||||
{
|
||||
memcpy(data, isource->data+isource->offset, length);
|
||||
isource->offset += length;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_error(png_ptr, "pngReaderCallback failed");
|
||||
}
|
||||
}
|
||||
|
||||
UIImage::UIImage(void)
|
||||
{
|
||||
m_imageInfo.hasAlpha = false;
|
||||
m_imageInfo.isPremultipliedAlpha = false;
|
||||
m_imageInfo.height = 0;
|
||||
m_imageInfo.width = 0;
|
||||
m_imageInfo.data = NULL;
|
||||
m_imageInfo.bitsPerComponent = 0;
|
||||
}
|
||||
|
||||
UIImage::UIImage(CCXBitmapDC * pBmpDC)
|
||||
{
|
||||
m_imageInfo.hasAlpha = false;
|
||||
m_imageInfo.isPremultipliedAlpha = false;
|
||||
m_imageInfo.height = 0;
|
||||
m_imageInfo.width = 0;
|
||||
m_imageInfo.data = NULL;
|
||||
m_imageInfo.bitsPerComponent = 0;
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! pBmpDC);
|
||||
TBitmap * pBitmap = pBmpDC->getBitmap();
|
||||
CCX_BREAK_IF(! pBitmap);
|
||||
|
||||
// init imageinfo
|
||||
INT32 nWidth = pBitmap->GetWidth();
|
||||
INT32 nHeight = pBitmap->GetHeight();
|
||||
CCX_BREAK_IF(nWidth <= 0 || nHeight <= 0);
|
||||
|
||||
INT32 nLen = pBitmap->GetRowBytes() * nHeight;
|
||||
m_imageInfo.data = new unsigned char [nLen];
|
||||
CCX_BREAK_IF(! m_imageInfo.data);
|
||||
memcpy(m_imageInfo.data, pBitmap->GetDataPtr(), nLen);
|
||||
|
||||
m_imageInfo.height = nHeight;
|
||||
m_imageInfo.width = nWidth;
|
||||
m_imageInfo.hasAlpha = true;
|
||||
// uphone only support isPremultipliedAlpha
|
||||
m_imageInfo.isPremultipliedAlpha = true;
|
||||
m_imageInfo.bitsPerComponent = pBitmap->GetDepth() / 4;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
UIImage::~UIImage(void)
|
||||
{
|
||||
if (m_imageInfo.data)
|
||||
{
|
||||
delete []m_imageInfo.data;
|
||||
}
|
||||
}
|
||||
|
||||
bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageType)
|
||||
{
|
||||
bool bRet = false;
|
||||
|
||||
// attempt load image from file
|
||||
FileData data;
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = data.getFileData(strPath.c_str(), "rb", &nSize);
|
||||
if (pBuffer)
|
||||
{
|
||||
switch (imageType)
|
||||
{
|
||||
case kCCImageFormatPNG:
|
||||
// use libpng load image
|
||||
bRet = loadPngFromStream(pBuffer, nSize);
|
||||
break;
|
||||
case kCCImageFormatJPG:
|
||||
bRet = loadJpgFromStream(pBuffer, nSize);
|
||||
break;
|
||||
default:
|
||||
// unsupported image type
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bRet && s_bPopupNotify)
|
||||
{
|
||||
std::string strErr = "Load ";
|
||||
strErr += strPath;
|
||||
strErr += " failed!";
|
||||
TUChar szText[256] = { 0 };
|
||||
TUString::StrUtf8ToStrUnicode(szText,(Char*)strErr.c_str());
|
||||
TApplication::GetCurrentApplication()->MessageBox(szText,NULL,WMB_OK);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
unsigned int UIImage::width(void)
|
||||
{
|
||||
return m_imageInfo.width;
|
||||
}
|
||||
|
||||
unsigned int UIImage::height(void)
|
||||
{
|
||||
return m_imageInfo.height;
|
||||
}
|
||||
|
||||
bool UIImage::isAlphaPixelFormat(void)
|
||||
{
|
||||
return m_imageInfo.hasAlpha;
|
||||
}
|
||||
|
||||
// now, uphone only support premultiplied data
|
||||
// so, we only return true
|
||||
bool UIImage::isPremultipliedAlpha(void)
|
||||
{
|
||||
return m_imageInfo.isPremultipliedAlpha;
|
||||
}
|
||||
|
||||
// compute how many bits every color component
|
||||
int UIImage::CGImageGetBitsPerComponent(void)
|
||||
{
|
||||
return m_imageInfo.bitsPerComponent;
|
||||
}
|
||||
|
||||
// now we only support RGBA8888 or RGB888
|
||||
// so it has color space
|
||||
int UIImage::CGImageGetColorSpace(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned char* UIImage::getData(void)
|
||||
{
|
||||
return m_imageInfo.data;
|
||||
}
|
||||
|
||||
bool UIImage::loadPngFromStream(unsigned char *data, int nLength)
|
||||
{
|
||||
char header[8];
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_bytep * rowPointers;
|
||||
tImageSource imageSource;
|
||||
int color_type;
|
||||
|
||||
// read 8 bytes from the beginning of stream
|
||||
unsigned char *tmp = data;
|
||||
memcpy(header, tmp, 8);
|
||||
|
||||
// close the file if it's not a png
|
||||
if (png_sig_cmp((png_bytep)header, 0, 8))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// init png_struct
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// init png_info
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// if something wrong,close file and return
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// set the read call back function
|
||||
imageSource.data = data;
|
||||
imageSource.size = nLength;
|
||||
imageSource.offset = 0;
|
||||
png_set_read_fn(png_ptr, &imageSource, pngReadCallback);
|
||||
|
||||
// read png
|
||||
// PNG_TRANSFORM_EXPAND: perform set_expand()
|
||||
// PNG_TRANSFORM_PACKING: expand 1, 2 and 4-bit samples to bytes
|
||||
// PNG_TRANSFORM_STRIP_16: strip 16-bit samples to 8 bits
|
||||
// PNG_TRANSFORM_GRAY_TO_RGB: expand grayscale samples to RGB (or GA to RGBA)
|
||||
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_GRAY_TO_RGB, NULL);
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, &m_imageInfo.width, &m_imageInfo.height, &m_imageInfo.bitsPerComponent, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
// init image info
|
||||
m_imageInfo.isPremultipliedAlpha = true;
|
||||
m_imageInfo.hasAlpha = ( info_ptr->color_type & PNG_COLOR_MASK_ALPHA ) ? true : false;
|
||||
|
||||
// allocate memory and read data
|
||||
int bytesPerComponent = 3;
|
||||
if (m_imageInfo.hasAlpha)
|
||||
{
|
||||
bytesPerComponent = 4;
|
||||
}
|
||||
m_imageInfo.data = new unsigned char[m_imageInfo.height * m_imageInfo.width * bytesPerComponent];
|
||||
rowPointers = png_get_rows(png_ptr, info_ptr);
|
||||
|
||||
// copy data to image info
|
||||
int bytesPerRow = m_imageInfo.width * bytesPerComponent;
|
||||
if(m_imageInfo.hasAlpha)
{
|
||||
unsigned int *tmp = (unsigned int *)m_imageInfo.data;
|
||||
for(unsigned int i = 0; i < m_imageInfo.height; i++)
|
||||
{
|
||||
for(int j = 0; j < bytesPerRow; j += 4)
|
||||
{
|
||||
*tmp++ = CCX_RGB_PREMULTIPLY_APLHA( rowPointers[i][j], rowPointers[i][j + 1],
|
||||
rowPointers[i][j + 2], rowPointers[i][j + 3] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int j = 0; j < m_imageInfo.height; ++j)
|
||||
{
|
||||
memcpy(m_imageInfo.data + j * bytesPerRow, rowPointers[j], bytesPerRow);
|
||||
}
|
||||
}
|
||||
|
||||
// release
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UIImage::loadJpgFromStream(unsigned char *data, unsigned long nSize)
|
||||
{
|
||||
/* these are standard libjpeg structures for reading(decompression) */
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
/* libjpeg data structure for storing one row, that is, scanline of an image */
|
||||
JSAMPROW row_pointer[1];
|
||||
|
||||
unsigned long location = 0;
|
||||
unsigned int i = 0;
|
||||
|
||||
/* here we set up the standard libjpeg error handler */
|
||||
cinfo.err = jpeg_std_error( &jerr );
|
||||
|
||||
/* setup decompression process and source, then read JPEG header */
|
||||
jpeg_create_decompress( &cinfo );
|
||||
|
||||
/* this makes the library read from infile */
|
||||
jpeg_mem_src( &cinfo, data, nSize );
|
||||
|
||||
/* reading the image header which contains image information */
|
||||
jpeg_read_header( &cinfo, true );
|
||||
|
||||
// we only support RGB or grayscale
|
||||
if (cinfo.jpeg_color_space != JCS_RGB)
|
||||
{
|
||||
if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr)
|
||||
{
|
||||
cinfo.out_color_space = JCS_RGB;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Start decompression jpeg here */
|
||||
jpeg_start_decompress( &cinfo );
|
||||
|
||||
/* init image info */
|
||||
m_imageInfo.width = cinfo.image_width;
|
||||
m_imageInfo.height = cinfo.image_height;
|
||||
m_imageInfo.hasAlpha = false;
|
||||
m_imageInfo.isPremultipliedAlpha = false;
|
||||
m_imageInfo.bitsPerComponent = 8;
|
||||
m_imageInfo.data = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components];
|
||||
|
||||
/* now actually read the jpeg into the raw buffer */
|
||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
||||
|
||||
/* read one scan line at a time */
|
||||
while( cinfo.output_scanline < cinfo.image_height )
|
||||
{
|
||||
jpeg_read_scanlines( &cinfo, row_pointer, 1 );
|
||||
for( i=0; i<cinfo.image_width*cinfo.num_components;i++)
|
||||
m_imageInfo.data[location++] = row_pointer[0][i];
|
||||
}
|
||||
|
||||
/* wrap up decompression, destroy objects, free pointers and close open files */
|
||||
jpeg_finish_decompress( &cinfo );
|
||||
jpeg_destroy_decompress( &cinfo );
|
||||
delete row_pointer[0];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UIImage::save(const std::string &strFileName, int nFormat)
|
||||
{
|
||||
/// @todo uiimage::save
|
||||
return false;
|
||||
}
|
||||
bool UIImage::initWithData(unsigned char *pBuffer, int nLength)
|
||||
{
|
||||
return loadPngFromStream(pBuffer, nLength);
|
||||
}
|
||||
|
||||
bool UIImage::initWithBuffer(int tx, int ty, unsigned char *pBuffer)
|
||||
{
|
||||
/// @todo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIImage::initWithBitmap(const TBitmap* pBmp)
|
||||
{
|
||||
bool bRet = false;
|
||||
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! pBmp);
|
||||
|
||||
// init imageinfo
|
||||
INT32 nWidth = pBmp->GetWidth();
|
||||
INT32 nHeight = pBmp->GetHeight();
|
||||
CCX_BREAK_IF(nWidth <= 0 || nHeight <= 0);
|
||||
|
||||
INT32 nLen = pBmp->GetRowBytes() * nHeight;
|
||||
m_imageInfo.data = new unsigned char [nLen];
|
||||
CCX_BREAK_IF(! m_imageInfo.data);
|
||||
memcpy(m_imageInfo.data, pBmp->GetDataPtr(), nLen);
|
||||
|
||||
m_imageInfo.height = nHeight;
|
||||
m_imageInfo.width = nWidth;
|
||||
m_imageInfo.hasAlpha = true;
|
||||
// uphone only support isPremultipliedAlpha
|
||||
m_imageInfo.isPremultipliedAlpha = true;
|
||||
m_imageInfo.bitsPerComponent = pBmp->GetDepth() / 4;
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void UIImage::setIsPopupNotify(bool bNotify)
|
||||
{
|
||||
s_bPopupNotify = bNotify;
|
||||
}
|
||||
|
||||
bool UIImage::getIsPopupNotify()
|
||||
{
|
||||
return s_bPopupNotify;
|
||||
}
|
||||
|
||||
}//namespace cocos2d
|
|
@ -1,116 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __PLATFORM_UPHONE_UIIMAGE_H__
|
||||
#define __PLATFORM_UPHONE_UIIMAGE_H__
|
||||
|
||||
#include <string>
|
||||
#include "ccxCommon.h"
|
||||
#include "CCRenderTexture.h"
|
||||
|
||||
class TBitmap;
|
||||
namespace cocos2d {
|
||||
class CCXBitmapDC;
|
||||
|
||||
/// @cond
|
||||
typedef struct
|
||||
{
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
int bitsPerComponent;
|
||||
bool hasAlpha;
|
||||
bool isPremultipliedAlpha;
|
||||
unsigned char *data;
|
||||
} tImageInfo;
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
@brief image toolkits
|
||||
*/
|
||||
class CCX_DLL UIImage
|
||||
{
|
||||
public:
|
||||
UIImage(void);
|
||||
UIImage(CCXBitmapDC * pBmpDC);
|
||||
|
||||
~UIImage(void);
|
||||
|
||||
/**
|
||||
Load the image from the specified path.
|
||||
@param strPath the absolute file path
|
||||
@param imageType the type of image, now only support tow types:
|
||||
- kImageFormatPNG -> png
|
||||
- kImageFormatJPG -> jpeg
|
||||
@return true if load correctly
|
||||
*/
|
||||
bool initWithContentsOfFile(const std::string &strPath, eImageFormat imageType = kCCImageFormatPNG);
|
||||
/**
|
||||
Load image from stream buffer.
|
||||
@param pBuffer stream buffer that hold the image data
|
||||
@param nLength the length of data(managed in byte)
|
||||
@return true if load correctly
|
||||
*/
|
||||
bool initWithData(unsigned char *pBuffer, int nLength);
|
||||
|
||||
/// @cond
|
||||
bool initWithBitmap(const TBitmap* pBmp);
|
||||
bool initWithBuffer(int tx, int ty, unsigned char *pBuffer);
|
||||
bool save(const std::string &strFileName, int nFormat);
|
||||
/// @endcond
|
||||
|
||||
/** get the image width */
|
||||
unsigned int width(void);
|
||||
/** get the image height */
|
||||
unsigned int height(void);
|
||||
|
||||
/** whether or not the image has alpha channel */
|
||||
bool isAlphaPixelFormat(void);
|
||||
/** whether or not the r, g, b channels are premultiplied by alpha channel */
|
||||
bool isPremultipliedAlpha(void);
|
||||
|
||||
/** get the bit depth of each color channel */
|
||||
int CGImageGetBitsPerComponent(void);
|
||||
/** the source color space for the image, or 0 if the image is an image mask */
|
||||
int CGImageGetColorSpace(void);
|
||||
|
||||
/** get the image data */
|
||||
unsigned char* getData(void);
|
||||
|
||||
/**
|
||||
@brief Set/Get whether pop-up a message box when the image load failed
|
||||
*/
|
||||
static void setIsPopupNotify(bool bNotify);
|
||||
static bool getIsPopupNotify();
|
||||
|
||||
private:
|
||||
bool loadPngFromStream(unsigned char *data, int nLength);
|
||||
bool loadJpgFromStream(unsigned char *data, unsigned long nSize);
|
||||
|
||||
private:
|
||||
tImageInfo m_imageInfo;
|
||||
static bool s_bPopupNotify;
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __PLATFORM_UPHONE_UIIMAGE_H__
|
|
@ -1,39 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __SUPPORT_COCOS2D_TYPES_H__
|
||||
#define __SUPPORT_COCOS2D_TYPES_H__
|
||||
namespace cocos2d {
|
||||
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char UINT8;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned short UINT16;
|
||||
typedef signed int INT32;
|
||||
typedef unsigned int UINT32;
|
||||
typedef long long INT64;
|
||||
typedef unsigned long long UINT64;
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __SUPPORT_COCOS2D_TYPES_H__
|
|
@ -1,45 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __PLATFORM_UPHONE_PLATFORM_NSLOCK_H__
|
||||
#define __PLATFORM_UPHONE_PLATFORM_NSLOCK_H__
|
||||
|
||||
#include <TG3.h>
|
||||
namespace cocos2d {
|
||||
|
||||
class NSLock
|
||||
{
|
||||
public:
|
||||
NSLock(void);
|
||||
~NSLock(void);
|
||||
|
||||
void lock(void);
|
||||
void unlock(void);
|
||||
|
||||
private:
|
||||
SS_LOCK_t *m_pLock;
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // __PLATFORM_UPHONE_PLATFORM_NSLOCK_H__
|
|
@ -1,55 +0,0 @@
|
|||
/****************************************************************************
|
||||
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_COMMON_UPHONE__
|
||||
#define __CCX_COMMON_UPHONE__
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(SS_MAKEDLL)
|
||||
#define CCX_DLL __declspec(dllexport)
|
||||
#elif defined(SS_IGNORE_EXPORT)
|
||||
#define CCX_DLL
|
||||
#else /* use a DLL library */
|
||||
#define CCX_DLL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#if defined(SS_SHARED)
|
||||
#define CCX_DLL __attribute__((visibility("default")))
|
||||
#elif defined(SS_IGNORE_EXPORT)
|
||||
#define CCX_DLL
|
||||
#else
|
||||
#define CCX_DLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace cocos2d{
|
||||
|
||||
/**
|
||||
@brief Output Debug message to Application console.
|
||||
*/
|
||||
void CCX_DLL CCXLog(const char * pszFormat, ...);
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif // end of __CCX_COMMON_UPHONE__
|
|
@ -16,6 +16,7 @@ DEFINES += -DCCX_UNDER_UPHONE \
|
|||
-D__TG3_PURE_DLL__ \
|
||||
-DUSE_FILE32API
|
||||
INCLUDE_PATH += -I../ \
|
||||
-I../../platform_support/include \
|
||||
-I../include -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2 \
|
||||
-I$(TO_PROJECT_ROOT)/Include/ThirdParty/iconv \
|
||||
-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng \
|
||||
|
@ -53,7 +54,6 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/NSAutoreleasePool.o \
|
||||
$(OBJECTS_DIR)/NSData.o \
|
||||
$(OBJECTS_DIR)/NSObject.o \
|
||||
$(OBJECTS_DIR)/CCNS_uphone.o \
|
||||
$(OBJECTS_DIR)/NSSet.o \
|
||||
$(OBJECTS_DIR)/NSZone.o \
|
||||
$(OBJECTS_DIR)/CCGrabber.o \
|
||||
|
@ -83,15 +83,11 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/CCNode_mobile.o \
|
||||
$(OBJECTS_DIR)/CCParticleSystemPoint_mobile.o \
|
||||
$(OBJECTS_DIR)/CCTransition_mobile.o \
|
||||
$(OBJECTS_DIR)/CCTime.o \
|
||||
$(OBJECTS_DIR)/CCXApplication_uphone.o \
|
||||
$(OBJECTS_DIR)/CCXBitmapDC.o \
|
||||
$(OBJECTS_DIR)/CCXCommon_uphone.o \
|
||||
$(OBJECTS_DIR)/platform.o \
|
||||
$(OBJECTS_DIR)/CCNS_uphone.o \
|
||||
$(OBJECTS_DIR)/CCXEGLView_uphone.o \
|
||||
$(OBJECTS_DIR)/CCXFileUtils_uphone.o \
|
||||
$(OBJECTS_DIR)/CCXUIAccelerometer_uphone.o \
|
||||
$(OBJECTS_DIR)/CCXUIImage_uphone.o \
|
||||
$(OBJECTS_DIR)/NSLock.o \
|
||||
$(OBJECTS_DIR)/CCAnimation.o \
|
||||
$(OBJECTS_DIR)/CCAnimationCache.o \
|
||||
$(OBJECTS_DIR)/CCSprite.o \
|
||||
|
@ -106,7 +102,6 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/TransformUtils.o \
|
||||
$(OBJECTS_DIR)/FileUtils.o \
|
||||
$(OBJECTS_DIR)/TGAlib.o \
|
||||
$(OBJECTS_DIR)/glu.o \
|
||||
$(OBJECTS_DIR)/ioapi.o \
|
||||
$(OBJECTS_DIR)/unzip.o \
|
||||
$(OBJECTS_DIR)/ZipUtils.o \
|
||||
|
@ -292,17 +287,11 @@ $(OBJECTS_DIR)/CCParticleSystemPoint_mobile.o : ../platform/CCParticleSystemPoin
|
|||
$(OBJECTS_DIR)/CCTransition_mobile.o : ../platform/CCTransition_mobile.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCTransition_mobile.o ../platform/CCTransition_mobile.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCTime.o : ../platform/uphone/CCTime.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCTime.o ../platform/uphone/CCTime.cpp
|
||||
$(OBJECTS_DIR)/platform.o : ../platform/platform.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/platform.o ../platform/platform.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCXApplication_uphone.o : ../platform/uphone/CCXApplication_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXApplication_uphone.o ../platform/uphone/CCXApplication_uphone.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCXBitmapDC.o : ../platform/uphone/CCXBitmapDC.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXBitmapDC.o ../platform/uphone/CCXBitmapDC.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCXCommon_uphone.o : ../platform/uphone/CCXCommon_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXCommon_uphone.o ../platform/uphone/CCXCommon_uphone.cpp
|
||||
$(OBJECTS_DIR)/CCNS_uphone.o : ../platform/uphone/CCNS_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCNS_uphone.o ../platform/uphone/CCNS_uphone.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCXEGLView_uphone.o : ../platform/uphone/CCXEGLView_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXEGLView_uphone.o ../platform/uphone/CCXEGLView_uphone.cpp
|
||||
|
@ -313,15 +302,6 @@ $(OBJECTS_DIR)/CCXFileUtils_uphone.o : ../platform/uphone/CCXFileUtils_uphone.cp
|
|||
$(OBJECTS_DIR)/CCXUIAccelerometer_uphone.o : ../platform/uphone/CCXUIAccelerometer_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXUIAccelerometer_uphone.o ../platform/uphone/CCXUIAccelerometer_uphone.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCXUIImage_uphone.o : ../platform/uphone/CCXUIImage_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCXUIImage_uphone.o ../platform/uphone/CCXUIImage_uphone.cpp
|
||||
|
||||
$(OBJECTS_DIR)/NSLock.o : ../platform/uphone/NSLock.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/NSLock.o ../platform/uphone/NSLock.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCNS_uphone.o : ../platform/uphone/CCNS_uphone.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCNS_uphone.o ../platform/uphone/CCNS_uphone.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCAnimation.o : ../sprite_nodes/CCAnimation.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCAnimation.o ../sprite_nodes/CCAnimation.cpp
|
||||
|
||||
|
@ -364,9 +344,6 @@ $(OBJECTS_DIR)/FileUtils.o : ../support/file_support/FileUtils.cpp
|
|||
$(OBJECTS_DIR)/TGAlib.o : ../support/image_support/TGAlib.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/TGAlib.o ../support/image_support/TGAlib.cpp
|
||||
|
||||
$(OBJECTS_DIR)/glu.o : ../support/opengl_support/glu.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/glu.o ../support/opengl_support/glu.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ioapi.o : ../support/zip_support/ioapi.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ioapi.o ../support/zip_support/ioapi.cpp
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\PRJ_TG3\Include\ThirdParty\iconv;..\..\..\PRJ_TG3\Include\ThirdParty\zlib;..\..\..\PRJ_TG3\Include\ThirdParty\libpng;..\..\..\PRJ_TG3\Include\ThirdParty\libjpeg;..\..\..\PRJ_TG3\Include\ThirdParty\libxml2;..\include;..\..\..\PRJ_TG3\Include;..\..\..\PRJ_TG3\Include\MTAPI;..\..\..\PRJ_TG3\Include\OpenGL;..\..\..\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;..\"
|
||||
AdditionalIncludeDirectories="..\..\..\PRJ_TG3\Include\ThirdParty\iconv;..\..\..\PRJ_TG3\Include\ThirdParty\zlib;..\..\..\PRJ_TG3\Include\ThirdParty\libpng;..\..\..\PRJ_TG3\Include\ThirdParty\libjpeg;..\..\..\PRJ_TG3\Include\ThirdParty\libxml2;..\include;..\..\..\PRJ_TG3\Include;..\..\..\PRJ_TG3\Include\MTAPI;..\..\..\PRJ_TG3\Include\OpenGL;..\..\..\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;..\;..\..\platform_support\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL;__TG3_PURE_DLL__;_USE_MATH_DEFINES"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -64,7 +64,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libEGL.lib libTG3_EGL.lib libgles_cm.lib libxml2.lib zlib.lib libpng14-imp.lib ImageToolKit_d.lib libjpeg.lib"
|
||||
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libEGL.lib libTG3_EGL.lib libgles_cm.lib libxml2.lib zlib.lib libpng14-imp.lib ImageToolKit_d.lib libjpeg.lib libPlatformSupport.lib"
|
||||
OutputFile="$(OutDir)/libcocos2d.dll"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../../../PRJ_TG3/Common/ICU/lib;../../../PRJ_TG3/Mtapi/Win32/lib;../../../PRJ_TG3/LIB/Win32Lib;../../../PRJ_TG3/Common/SoftSupport"
|
||||
|
@ -520,14 +520,6 @@
|
|||
RelativePath="..\include\CCUIAccelerometerDelegate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCXApplication.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxCommon.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCXEGLView.h"
|
||||
>
|
||||
|
@ -540,10 +532,6 @@
|
|||
RelativePath="..\include\CCXUIAccelerometer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCXUIImage.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CGAffineTransform.h"
|
||||
>
|
||||
|
@ -780,22 +768,6 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="opengl_support"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\support\opengl_support\glu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\support\opengl_support\glu.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\support\opengl_support\OpenGL_Internal.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="zip_support"
|
||||
>
|
||||
|
@ -984,32 +956,16 @@
|
|||
RelativePath="..\platform\CCTransition_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCXApplication_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\ccxCommon_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCXEGLView_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCXMath.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCXUIAccelerometer_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCXUIImage_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\config_platform.h"
|
||||
RelativePath="..\platform\platform.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -1023,34 +979,6 @@
|
|||
RelativePath="..\platform\uphone\CCNS_uphone.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCTime.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCTime.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXApplication_uphone.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXApplication_uphone.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXBitmapDC.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXBitmapDC.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXCommon_uphone.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXEGLView_uphone.cpp"
|
||||
>
|
||||
|
@ -1075,30 +1003,10 @@
|
|||
RelativePath="..\platform\uphone\CCXUIAccelerometer_uphone.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXUIImage_uphone.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\CCXUIImage_uphone.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\Cocos2dTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\NewDeleteOp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\NSLock.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\uphone\NSLock.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
|
@ -558,7 +558,7 @@ bool CCTexture2D::initWithString(const char *text, CGSize dimensions, UITextAlig
|
|||
ccxImage::ETextAlign eAlign = (UITextAlignmentCenter == alignment) ? ccxImage::kAlignCenter
|
||||
: (UITextAlignmentLeft == alignment) ? ccxImage::kAlignLeft : ccxImage::kAlignRight;
|
||||
|
||||
if (! image.initWidthString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize))
|
||||
if (! image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxCommon.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CGRect;
|
||||
|
||||
|
@ -71,6 +71,17 @@ public:
|
|||
*/
|
||||
static ccxApplication& sharedApplication();
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
/**
|
||||
@brief Get the data path of the Application.
|
||||
@return If the app is installed,the return value is the path of .so file.
|
||||
else the return value is "/NEWPLUS/TG3/APP/"
|
||||
*/
|
||||
virtual const char* getAppDataPath() = 0;
|
||||
|
||||
virtual void switchNotify(int nTurnOn) = 0;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
ccxApplication() {}
|
||||
static void setSharedApplication(ccxApplication& app);
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxMacros.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
// [u]int[8|16|32|64]
|
||||
// char
|
||||
|
@ -48,8 +48,8 @@ static const int kMaxLogLen = 255;
|
|||
void CCX_DLL_PS CCXLog(const char * pszFormat, ...);
|
||||
|
||||
struct ccxNullDeleter { template< class TPTR > void operator()(TPTR ) {} };
|
||||
struct ccxNewDeleter { template< class TPTR > void operator()(TPTR p) { delete p; } };
|
||||
struct ccxNewArrayDeleter { template< class TPTR > void operator()(TPTR p) { delete[] p; } };
|
||||
struct ccxNewDeleter { template< class TPTR > void operator()(TPTR p) { if (p) delete p; } };
|
||||
struct ccxNewArrayDeleter { template< class TPTR > void operator()(TPTR p) { if (p) delete[] p; } };
|
||||
|
||||
/**
|
||||
@brief A simple scoped pointer.
|
||||
|
|
|
@ -67,7 +67,7 @@ There are config below:
|
|||
#endif
|
||||
|
||||
// uphone
|
||||
#if ! CCX_TARGET_PLATFORM && defined(_TRANZDA_VM_)
|
||||
#if ! CCX_TARGET_PLATFORM && (defined(_TRANZDA_VM_) || defined(CCX_UNDER_UPHONE))
|
||||
#undef CCX_TARGET_PLATFORM
|
||||
#define CCX_TARGET_PLATFORM CCX_PLATFORM_UPHONE
|
||||
#endif
|
||||
|
|
|
@ -52,7 +52,7 @@ THE SOFTWARE.
|
|||
|
||||
#if defined(CCX_PLATFORM_MOBILE)
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
/*
|
||||
OpenGL GLU implementation
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxCommon.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCX_DLL_PS ccxImage
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
@param pFontName the name of the font which use to draw the text. If nil, use the default system font.
|
||||
@param nSize the font size, if 0, use the system default size.
|
||||
*/
|
||||
bool initWidthString(
|
||||
bool initWithString(
|
||||
const char * pText,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
|
|
|
@ -140,6 +140,17 @@ public: inline void set##funName(varType var){ varName = var; }
|
|||
|
||||
#endif // CCX_PLATFORM_WIN32
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE && defined(_TRANZDA_VM_))
|
||||
|
||||
#undef CCX_DLL
|
||||
#if defined(SS_MAKEDLL)
|
||||
#define CCX_DLL __declspec(dllexport)
|
||||
#else /* use a DLL library */
|
||||
#define CCX_DLL __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif // uphone VM
|
||||
|
||||
// shared library declator for platform_support project
|
||||
#define CCX_DLL_PS CCX_DLL
|
||||
|
||||
|
|
|
@ -41,6 +41,19 @@ THE SOFTWARE.
|
|||
#endif
|
||||
|
||||
#endif // CCX_PLATFORM_WIN32
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE && defined(_TRANZDA_VM_))
|
||||
|
||||
#if ! defined(_USE_MATH_DEFINES)
|
||||
#define _USE_MATH_DEFINES // make M_PI can be use
|
||||
#endif
|
||||
|
||||
#if ! defined(isnan)
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -49,10 +62,13 @@ THE SOFTWARE.
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
// for sys/time.h on win32 platform
|
||||
// for MIN MAX and sys/time.h on win32 platform
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
||||
|
||||
// Struct timeval has define in winsock.h, include windows.h for it.
|
||||
#define MIN min
|
||||
#define MAX max
|
||||
|
||||
// Structure timeval has define in winsock.h, include windows.h for it.
|
||||
#include <Windows.h>
|
||||
|
||||
struct timezone
|
||||
|
@ -65,4 +81,10 @@ int CCX_DLL_PS gettimeofday(struct timeval *, struct timezone *);
|
|||
|
||||
#endif // CCX_PLATFORM_WIN32
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
|
||||
#include "TG3.h"
|
||||
|
||||
#endif // CCX_PLATFORM_UPHONE
|
||||
|
||||
#endif // __CCX_STD_C_H__
|
|
@ -43,9 +43,16 @@ There are some useful tool for ccxString:
|
|||
|
||||
#include <string>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
typedef std::string ccxAString;
|
||||
typedef ccxAString ccxString;
|
||||
|
||||
// ccxStringTrim
|
||||
/**
|
||||
@todo ccxStringTrim must re-implement.
|
||||
Because basic_string is not have the same implement on different platform.
|
||||
*/
|
||||
#if 0
|
||||
template <class _E, class Tr, class AllocT >
|
||||
std::basic_string<_E, Tr, AllocT >& ccxStringTrim(std::basic_string<_E, Tr, AllocT >& str,
|
||||
const _E* blanks)
|
||||
|
@ -314,6 +321,7 @@ inline void ccxStringTrim(std::basic_string<wchar_t, Tr, AllocT >& str)
|
|||
}
|
||||
|
||||
#endif // CCX_SUPPORT_UNICODE
|
||||
#endif
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxCommon.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
#if CCX_SUPPORT_MULTITHREAD
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
############################################################################
|
||||
#
|
||||
# Makefile for building : PlatformSupport_Arm.TMK3
|
||||
# Created by TMK3_V2.3, please do not modify.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
TO_PROJECT_ROOT = ../../../PRJ_TG3
|
||||
OUTPUT_FILENAME = libPlatformSupportStatic.a
|
||||
|
||||
include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_Base_StaticLib.ARM
|
||||
include $(TO_PROJECT_ROOT)/MakeInclude/Makefile_TOPS_Def.ARM
|
||||
|
||||
DEFINES += -DCCX_UNDER_UPHONE \
|
||||
-D__TG3_PURE_DLL__
|
||||
INCLUDE_PATH += -I../include -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2 \
|
||||
-I$(TO_PROJECT_ROOT)/Include/ThirdParty/iconv \
|
||||
-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng \
|
||||
-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libjpeg
|
||||
|
||||
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)/ccxApplication.o \
|
||||
$(OBJECTS_DIR)/ccxCommon.o \
|
||||
$(OBJECTS_DIR)/ccxGL.o \
|
||||
$(OBJECTS_DIR)/ccxImage.o \
|
||||
$(OBJECTS_DIR)/ccxStdC.o \
|
||||
$(OBJECTS_DIR)/ccxThread.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)/ccxApplication.o : ../src/ccxApplication.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxApplication.o ../src/ccxApplication.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ccxCommon.o : ../src/ccxCommon.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxCommon.o ../src/ccxCommon.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ccxGL.o : ../src/ccxGL.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxGL.o ../src/ccxGL.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ccxImage.o : ../src/ccxImage.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxImage.o ../src/ccxImage.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ccxStdC.o : ../src/ccxStdC.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxStdC.o ../src/ccxStdC.cpp
|
||||
|
||||
$(OBJECTS_DIR)/ccxThread.o : ../src/ccxThread.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ccxThread.o ../src/ccxThread.cpp
|
|
@ -0,0 +1,264 @@
|
|||
<?xml version="1.0" encoding="gb2312"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="PlatformSupport"
|
||||
ProjectGUID="{560E20BA-9562-4AFC-A222-6B7B1956D607}"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../../PRJ_TG3/LIB/Win32Lib"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include;..\..\..\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;..\..\..\PRJ_TG3\Include\ThirdParty\libjpeg;..\..\..\PRJ_TG3\Include\ThirdParty\zlib;..\..\..\PRJ_TG3\Include\ThirdParty\libpng;..\..\..\PRJ_TG3\Include\OpenGL"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL;__TG3_PURE_DLL__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
StructMemberAlignment="3"
|
||||
TreatWChar_tAsBuiltInType="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4996"
|
||||
ForcedIncludeFiles=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libEGL.lib libTG3_EGL.lib libgles_cm.lib zlib.lib libpng14-imp.lib libjpeg.lib"
|
||||
OutputFile="$(OutDir)/libPlatformSupport.dll"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../../../PRJ_TG3/Common/ICU/lib;../../../PRJ_TG3/Mtapi/Win32/lib;../../../PRJ_TG3/LIB/Win32Lib;../../../PRJ_TG3/Common/SoftSupport"
|
||||
GenerateDebugInformation="true"
|
||||
GenerateMapFile="true"
|
||||
MapExports="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/$(TargetName).lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../PRJ_TG3/LIB/Win32Lib"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\include;..\..\..\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;..\..\..\PRJ_TG3\Include\ThirdParty\libjpeg;..\..\..\PRJ_TG3\Include\ThirdParty\zlib;..\..\..\PRJ_TG3\Include\ThirdParty\libpng;..\..\..\PRJ_TG3\Include\OpenGL"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL;__TG3_PURE_DLL__"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/PlatformSupport.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="src"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\ccxApplication.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ccxCommon.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ccxGL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ccxImage.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ccxStdC.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ccxThread.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\uphone\NewDeleteOp.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="include"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\include\ccxApplication.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxCommon.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxConfig.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxGL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxImage.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxLibxml2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxMacros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxStdC.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxString.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\ccxThread.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,54 @@
|
|||
;
|
||||
; TG3 Makefile Auto Create Script
|
||||
;
|
||||
; 说明:
|
||||
; 1.在等号左边不要有空格
|
||||
; 2.所有的路径请使用"/"来分隔
|
||||
; 3.所有的文件名不可以有空格
|
||||
; 4.只能对当前目录及其子目录下的.c、.cpp生成Makefile
|
||||
|
||||
;本TMK3文件目录位置到项目根目录之间的转换,不支持多个串,如果有多个,以最后一个为准
|
||||
;即 ./$(TO_PROJECT_ROOT)/ 就是项目的根目录
|
||||
TO_PROJECT_ROOT=../../PRJ_TG3
|
||||
|
||||
;输出目标的名字,不支持多个串,如果有多个,以最后一个为准
|
||||
OUTPUT_FILENAME=libPlatformSupport.so
|
||||
|
||||
;包含的其他的TMK3文件,此文件和本文件一起构成MakeFile的内容
|
||||
;此项可以出现在TMK3文件内的任意地方,与已经存在的项依次组合
|
||||
;注意:此项不支持绝对路径,但是可以使用$(TO_PROJECT_ROOT)构成文件名
|
||||
INCLUDE_TMK3=$(TO_PROJECT_ROOT)/MakeInclude/TG3_APP_Arm.TMK3 ;TOPS标准应用,包括动态库等
|
||||
|
||||
;预定义串,生成MakeFile的时候直接放在MakeFile的前面
|
||||
;格式:PRE_DEFINE=STRING,生成MakeFile的时候,"PRE_DEFINE="后面的所有非注释非续行字符都会放在MakeFile前面
|
||||
;例如:PRE_DEFINE=AAA=BBB,会放入AAA=BBB到MakeFile中
|
||||
;可以使用多个PRE_DEFINE串,也可以使用PRE_DEFINE1、PRE_DEFINE2等方式,MakeFile中依据出现顺序(不是数字大小)排列
|
||||
|
||||
;C、C++预定义宏,可以使用多个DEFINES串,也可以使用DEFINES1、DEFINES2等方式,MakeFile中依据出现顺序(不是数字大小)排列
|
||||
DEFINES=-DCCX_UNDER_UPHONE ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可
|
||||
DEFINES=-D__TG3_PURE_DLL__ ;生成的是纯动态库(意思是:不是TOPS应用,但可以是TCOM组件)
|
||||
|
||||
;包含路径,支持换行,后面不要加续行符,请连续使用INCLUDE_PATH1、INCLUDE_PATH2等标明多行
|
||||
;行号需要连续,不可跳跃
|
||||
INCLUDE_PATH=-I./include -I$(TO_PROJECT_ROOT)/Include/ThirdParty/libxml2
|
||||
INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/iconv
|
||||
INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libpng
|
||||
INCLUDE_PATH=-I$(TO_PROJECT_ROOT)/Include/ThirdParty/libjpeg
|
||||
|
||||
;连接的库文件,可以使用多个LIBS串,也可以使用LIBS1、LIBS2等方式,MakeFile中依据出现顺序(不是数字大小)排列
|
||||
;LIBS=-lMyLib ;应用额外的连接库。注意:ITOPS自己的所需库自动包含,而且库包含路径也已经包含,故此这里仅仅包含应用自己特有的库的名字即可
|
||||
|
||||
LIBS=
|
||||
;强制包含文件的名字,不能使用通配符,一定要使用相对或者绝对路径
|
||||
;极力要求使用相对路径,多个文件之间使用“|”分隔
|
||||
;强制包含文件指的是不在本文件夹及其子文件夹下的.c、.cpp、.o文件
|
||||
;可以使用多个INCLUDEFILE串,也可以使用INCLUDEFILE1、INCLUDEFILE2等方式,MakeFile中依据出现顺序(不是数字大小)排列
|
||||
INCLUDEFILE=
|
||||
|
||||
;强制排除文件,不能使用通配符,一定要使用相对路径
|
||||
;多个文件之间使用“|”分隔,路径必须以"./","../"开始
|
||||
;只能对.c、.cpp文件进行排除
|
||||
;如果要排除本目录的文件也要加入"./"
|
||||
;可以使用多个EXCLUDEFILE串,也可以使用EXCLUDEFILE1、EXCLUDEFILE2等方式,MakeFile中依据出现顺序(不是数字大小)排列
|
||||
EXCLUDEFILE= ./src/uphone/
|
||||
EXCLUDEFILE= ./src/win32/
|
|
@ -26,9 +26,7 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
||||
|
||||
static ccxApplication* s_pSharedApplication;
|
||||
static ccxApplication* s_pSharedApplication = 0;
|
||||
|
||||
ccxApplication& ccxApplication::sharedApplication()
|
||||
{
|
||||
|
@ -41,6 +39,4 @@ void ccxApplication::setSharedApplication(ccxApplication& app)
|
|||
s_pSharedApplication = &app;
|
||||
}
|
||||
|
||||
#endif // CCX_PLATFORM_WIN32
|
||||
|
||||
NS_CC_END;
|
||||
|
|
|
@ -48,3 +48,47 @@ void CCXLog(const char * pszFormat, ...)
|
|||
NS_CC_END;
|
||||
|
||||
#endif // CCX_PLATFORM_WIN32
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
#include "TG3.h"
|
||||
|
||||
#define MAX_LEN 256
|
||||
#define LOG_FILE_PATH "/NEWPLUS/TDA_DATA/UserData/Cocos2dLog.txt"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
void CCXLog(const char * pszFormat, ...)
|
||||
{
|
||||
SS_printf("Cocos2d: ");
|
||||
char szBuf[MAX_LEN];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, pszFormat);
|
||||
#ifdef _TRANZDA_VM_
|
||||
vsprintf_s(szBuf, MAX_LEN, pszFormat, ap);
|
||||
#else
|
||||
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
|
||||
SS_printf("%s", szBuf);
|
||||
#ifdef _TRANZDA_VM_
|
||||
SS_printf("\n");
|
||||
#else
|
||||
SS_printf("\r\n");
|
||||
FILE * pf = fopen(LOG_FILE_PATH, "a+");
|
||||
if (! pf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(szBuf, 1, strlen(szBuf), pf);
|
||||
fwrite("\r\n", 1, strlen("\r\n"), pf);
|
||||
fflush(pf);
|
||||
fclose(pf);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
#endif // CCX_PLATFORM_UPHONE
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccxStdC.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,10 @@ THE SOFTWARE.
|
|||
#include "ccxString.h"
|
||||
#include "ccxStdC.h"
|
||||
#include "png.h"
|
||||
|
||||
#define QGLOBAL_H
|
||||
#include "jpeglib.h"
|
||||
#undef QGLOBAL_H
|
||||
|
||||
#define CCX_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
|
||||
(unsigned)(((unsigned)((ccxByte)(vr) * ((ccxByte)(va) + 1)) >> 8) | \
|
||||
|
@ -57,7 +60,7 @@ static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t leng
|
|||
}
|
||||
}
|
||||
|
||||
NS_CC_BEGIN;
|
||||
NS_CC_BEGIN
|
||||
|
||||
static void ccxMessageBox(const ccxString& msg, const ccxString& title);
|
||||
|
||||
|
@ -333,3 +336,7 @@ NS_CC_END;
|
|||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
||||
#include "win32/ccxImage_win32.cpp"
|
||||
#endif
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
#include "uphone/ccxImage_uphone.cpp"
|
||||
#endif
|
||||
|
|
|
@ -30,4 +30,8 @@ THE SOFTWARE.
|
|||
#include "win32/ccxThread_win32.cpp"
|
||||
#endif
|
||||
|
||||
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE)
|
||||
#include "uphone/ccxThread_uphone.cpp"
|
||||
#endif
|
||||
|
||||
#endif // CCX_SUPPORT_MULTITHREAD
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
/*!
|
||||
* @file NewDeleteOp.cpp
|
||||
* @author 全智达
|
||||
* @brief
|
||||
*
|
||||
* @section Copyright
|
||||
* =======================================================================<br>
|
||||
* <br>
|
||||
* Copyright (c) 2005-2010 Tranzda Technologies Co.,Ltd. <br>
|
||||
* 深圳市全智达科技有限公司 版权所有2005-2010<br>
|
||||
* <br>
|
||||
* PROPRIETARY RIGHTS of Tranzda Technologies Co.,Ltd. are involved in <br>
|
||||
* the subject matter of this material. All manufacturing, reproduction, <br>
|
||||
* use, and sales rights pertaining to this subject matter are governed <br>
|
||||
* by the license agreement. The recipient of this software implicitly <br>
|
||||
* accepts the terms of the license. <br>
|
||||
* 本软件文档资料是深圳市全智达科技有限公司的合法资产,任何人士阅读和使<br>
|
||||
* 用本资料必须获得相应的书面授权,承担保密责任和接受相应的法律约束。<br>
|
||||
* <br>
|
||||
* 公司网址:<a href="http://www.tranzda.com"> http://www.tranzda.com </a> <br>
|
||||
* 公司邮箱:<a mailto="support@tranzda.com">support@tranzda.com</a> <br>
|
||||
* =======================================================================<br>
|
||||
*/
|
||||
|
||||
#include "ssTypes.h"
|
||||
#include "TG3_Type.h"
|
||||
#include "TG3_Memory.h"
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#ifdef delete
|
||||
#undef delete
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#define __cdecl
|
||||
#endif
|
||||
|
||||
void * __cdecl operator new(unsigned int size)
|
||||
{
|
||||
return TMalloc(size);
|
||||
}
|
||||
|
||||
void * __cdecl operator new[](unsigned int size)
|
||||
{
|
||||
return TMalloc(size);
|
||||
}
|
||||
|
||||
void * __cdecl operator new(unsigned int size, const unsigned short * fileName, int lineNo)
|
||||
{
|
||||
return TMallocEx(size, fileName, lineNo);
|
||||
}
|
||||
|
||||
void * __cdecl operator new[](unsigned int size, const unsigned short * fileName, int lineNo)
|
||||
{
|
||||
return TMallocEx(size, fileName, lineNo);
|
||||
}
|
||||
|
||||
void __cdecl operator delete(void *p)
|
||||
{
|
||||
TFree(p);
|
||||
}
|
||||
|
||||
void __cdecl operator delete[](void *p)
|
||||
{
|
||||
TFree(p);
|
||||
}
|
||||
|
||||
void __cdecl operator delete(void *p, const unsigned short * fileName, int lineNo)
|
||||
{
|
||||
TFreeEx(p, fileName, lineNo);
|
||||
}
|
||||
|
||||
void __cdecl operator delete[](void *p, const unsigned short * fileName, int lineNo)
|
||||
{
|
||||
TFreeEx(p, fileName, lineNo);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "TG3.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
void ccxMessageBox(const ccxString& msg, const ccxString& title)
|
||||
{
|
||||
//MessageBoxA(NULL, msg.c_str(), title.c_str(), MB_OK);
|
||||
}
|
||||
|
||||
class BitmapDC
|
||||
{
|
||||
public:
|
||||
BitmapDC()
|
||||
: m_pBmp(NULL)
|
||||
, m_pMemWnd(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~BitmapDC(void)
|
||||
{
|
||||
prepareBitmap(0, 0);
|
||||
}
|
||||
|
||||
bool setFont(const char * pFontName = NULL, int nSize = 0)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! m_hFont.Create(0, (Int32)nSize));
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool getTextExtentPoint(TUChar* pszText, int nLen, TSize& tSize)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! pszText);
|
||||
tSize.SetWidth(m_hFont.CharsWidth(pszText,nLen));
|
||||
tSize.SetHeight(m_hFont.LineHeight());
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool prepareBitmap(int nWidth, int nHeight)
|
||||
{
|
||||
// release bitmap
|
||||
if (m_pBmp)
|
||||
{
|
||||
m_pBmp->Destroy();
|
||||
m_pBmp = NULL;
|
||||
}
|
||||
if (nWidth > 0 && nHeight > 0)
|
||||
{
|
||||
m_pBmp = TBitmap::Create(nWidth, nHeight, 32);
|
||||
if (! m_pBmp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int drawText(TUChar* pszText, int nLen, TSize& tSize, UInt32 style)
|
||||
{
|
||||
int nRet = 0;
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! pszText);
|
||||
|
||||
if (tSize.Width() <= 0 || tSize.Height() <= 0)
|
||||
{
|
||||
CCX_BREAK_IF(! getTextExtentPoint(pszText, nLen, tSize));
|
||||
}
|
||||
CCX_BREAK_IF(tSize.Width() <= 0 || tSize.Height() <= 0);
|
||||
|
||||
CCX_BREAK_IF(! prepareBitmap(tSize.Width(), tSize.Height()));
|
||||
|
||||
Int32 nWidth = tSize.Width();
|
||||
Int32 nHeight = tSize.Height();
|
||||
|
||||
// create memory window
|
||||
if (m_pMemWnd)
|
||||
{
|
||||
TRectangle rcMemWnd(0, 0, 0, 0);
|
||||
m_pMemWnd->GetClientBounds(&rcMemWnd);
|
||||
if (rcMemWnd.Width() < nWidth || rcMemWnd.Height() < nHeight)
|
||||
{
|
||||
m_pMemWnd->CloseWindow();
|
||||
m_pMemWnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// if memory window is already break
|
||||
CCX_BREAK_IF(m_pMemWnd);
|
||||
|
||||
TApplication* pApp = TApplication::GetCurrentApplication();
|
||||
CCX_BREAK_IF(! pApp || ! (m_pMemWnd = new TWindow(pApp)));
|
||||
|
||||
Coord nCurrentWidth = pApp->GetScreenWidth();
|
||||
Coord nCurrentHeight = pApp->GetScreenHeight();
|
||||
|
||||
Coord nMemWndW = (nWidth >= nCurrentWidth) ? nWidth : nCurrentWidth;
|
||||
Coord nMemWndH = (nHeight >= nCurrentHeight) ? nHeight : nCurrentHeight;
|
||||
CCX_BREAK_IF(m_pMemWnd->CreateMemWindow(nMemWndW, nMemWndH,screenAlphaFormat));
|
||||
delete m_pMemWnd;
|
||||
m_pMemWnd = NULL;
|
||||
} while (0);
|
||||
CCX_BREAK_IF(! m_pMemWnd);
|
||||
|
||||
// create DC
|
||||
TDC dc(m_pMemWnd);
|
||||
|
||||
// draw text
|
||||
m_pMemWnd->GetMemWindowTBitmapPtr()->Fill32(RGBA(0, 0, 0, 0), 0, 0, nWidth, nHeight);
|
||||
|
||||
TRectangle rect(0, 0, nWidth, nHeight);
|
||||
dc.DrawTextInRectangleEx(pszText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), m_hFont, &rect, style);
|
||||
|
||||
dc.ReadBitmap(m_pBmp, 0, 0);
|
||||
|
||||
nRet = true;
|
||||
} while (0);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
CCX_SYNTHESIZE_READONLY(TBitmap*, m_pBmp, Bitmap);
|
||||
|
||||
private:
|
||||
TFont m_hFont;
|
||||
TWindow * m_pMemWnd;
|
||||
};
|
||||
|
||||
static BitmapDC& sharedBitmapDC()
|
||||
{
|
||||
static BitmapDC s_BmpDC;
|
||||
return s_BmpDC;
|
||||
}
|
||||
|
||||
bool ccxImage::initWithString(
|
||||
const char * pText,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
||||
const char * pFontName/* = nil*/,
|
||||
int nSize/* = 0*/)
|
||||
{
|
||||
bool bRet = false;
|
||||
TUChar* pWText = NULL;
|
||||
do
|
||||
{
|
||||
CCX_BREAK_IF(! pText);
|
||||
int nLen = strlen(pText) + 1;
|
||||
CCX_BREAK_IF(! (pWText = new TUChar[nLen]));
|
||||
TUString::StrGBToUnicode(pWText, (Char*)pText);
|
||||
|
||||
BitmapDC& dc = sharedBitmapDC();
|
||||
|
||||
dc.setFont(pFontName, nSize);
|
||||
|
||||
TSize size(0, 0);
|
||||
if (nWidth > 0 && nHeight > 0)
|
||||
{
|
||||
size.SetSize(nWidth, nHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.getTextExtentPoint(pWText, nLen, size);
|
||||
}
|
||||
CCX_BREAK_IF(! size.Width() || ! size.Height());
|
||||
|
||||
// set style
|
||||
UInt32 styles = GUI_API_STYLE_SPECIFY_FORE_COLOR | GUI_API_STYLE_ROP_MODE_TRANSPARENT |
|
||||
GUI_API_STYLE_CLIP_WORDWRAP | GUI_API_STYLE_SPECIFY_BACK_COLOR | GUI_API_STYLE_SPECIFY_FONT;
|
||||
|
||||
switch (eAlignMask)
|
||||
{
|
||||
case kAlignCenter:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_MIDDLE;
|
||||
break;
|
||||
case kAlignTop:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_TOP;
|
||||
break;
|
||||
case kAlignTopRight:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_TOP;
|
||||
break;
|
||||
case kAlignRight:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_MIDDLE;
|
||||
break;
|
||||
case kAlignBottomRight:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_BOTTOM;
|
||||
break;
|
||||
case kAlignBottom:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_BOTTOM;
|
||||
break;
|
||||
case kAlignBottomLeft:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_BOTTOM;
|
||||
break;
|
||||
case kAlignLeft:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_MIDDLE;
|
||||
break;
|
||||
case kAlignTopLeft:
|
||||
styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_TOP;
|
||||
}
|
||||
|
||||
CCX_BREAK_IF(! dc.drawText(pWText, nLen, size, styles));
|
||||
|
||||
// init image information
|
||||
TBitmap * pBitmap = dc.getBitmap();
|
||||
CCX_BREAK_IF(! pBitmap);
|
||||
|
||||
INT32 nWidth = pBitmap->GetWidth();
|
||||
INT32 nHeight = pBitmap->GetHeight();
|
||||
CCX_BREAK_IF(nWidth <= 0 || nHeight <= 0);
|
||||
|
||||
INT32 nDataLen = pBitmap->GetRowBytes() * nHeight;
|
||||
m_pData.reset(new ccxByte[nDataLen]);
|
||||
CCX_BREAK_IF(! m_pData.get());
|
||||
memcpy((void*) m_pData.get(), pBitmap->GetDataPtr(), nDataLen);
|
||||
|
||||
m_nWidth = (ccxInt16)nWidth;
|
||||
m_nHeight = (ccxInt16)nHeight;
|
||||
m_bHasAlpha = true;
|
||||
m_bPreMulti = true;
|
||||
m_nBitsPerComponent = pBitmap->GetDepth() / 4;
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
if (pWText)
|
||||
{
|
||||
delete [] pWText;
|
||||
pWText = NULL;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
|
@ -21,33 +21,61 @@ 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.
|
||||
****************************************************************************/
|
||||
#include "NSLock.h"
|
||||
namespace cocos2d {
|
||||
|
||||
NSLock::NSLock(void)
|
||||
#if CCX_SUPPORT_MULTITHREAD
|
||||
|
||||
#include "TG3.h"
|
||||
#include "ccxThread.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
class CCXLock::Impl
|
||||
{
|
||||
public:
|
||||
Impl()
|
||||
{
|
||||
CriticalSectionInit(m_pLock);
|
||||
}
|
||||
|
||||
~Impl()
|
||||
{
|
||||
CriticalSectionDestroy(m_pLock);
|
||||
|
||||
if (m_pLock)
|
||||
{
|
||||
delete m_pLock;
|
||||
m_pLock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SS_LOCK_t *m_pLock;
|
||||
};
|
||||
|
||||
CCXLock::CCXLock()
|
||||
: m_pImp(new CCXLock::Impl)
|
||||
{
|
||||
m_pLock = new SS_LOCK_t();
|
||||
CriticalSectionInit(m_pLock);
|
||||
}
|
||||
|
||||
NSLock::~NSLock(void)
|
||||
CCXLock::~CCXLock()
|
||||
{
|
||||
CriticalSectionDestroy(m_pLock);
|
||||
}
|
||||
|
||||
if (m_pLock)
|
||||
void CCXLock::lock()
|
||||
{
|
||||
if (m_pImp)
|
||||
{
|
||||
delete m_pLock;
|
||||
m_pLock = NULL;
|
||||
CriticalSectionLock(m_pImp->m_pLock);
|
||||
}
|
||||
}
|
||||
|
||||
void NSLock::lock(void)
|
||||
void CCXLock::unlock()
|
||||
{
|
||||
CriticalSectionLock(m_pLock);
|
||||
if (m_pImp)
|
||||
{
|
||||
CriticalSectionUnLock(m_pImp->m_pLock);
|
||||
}
|
||||
}
|
||||
|
||||
void NSLock::unlock(void)
|
||||
{
|
||||
CriticalSectionUnLock(m_pLock);
|
||||
}
|
||||
}//namespace cocos2d
|
||||
NS_CC_END;
|
||||
|
||||
#endif // CCX_SUPPORT_MULTITHREAD
|
|
@ -177,7 +177,7 @@ static BitmapDC& sharedBitmapDC()
|
|||
return s_BmpDC;
|
||||
}
|
||||
|
||||
bool ccxImage::initWidthString(
|
||||
bool ccxImage::initWithString(
|
||||
const char * pText,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
|
|
Loading…
Reference in New Issue