mirror of https://github.com/axmolengine/axmol.git
Merge pull request #695 from GermanMtz/master
fixed #963: Member variable added to keep the current window active status
This commit is contained in:
commit
5c65af137b
|
@ -1,104 +1,104 @@
|
|||
/****************************************************************************
|
||||
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 "CCAccelerometer_qnx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <bps/accelerometer.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BUFFER_SIZE 30
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
CCAccelerometer* CCAccelerometer::m_spCCAccelerometer = NULL;
|
||||
int CCAccelerometer::m_initialOrientationAngle = 0;
|
||||
|
||||
CCAccelerometer::CCAccelerometer()
|
||||
{
|
||||
m_pAccelDelegate = NULL;
|
||||
m_initialOrientationAngle = atoi(getenv("ORIENTATION"));
|
||||
|
||||
accelerometer_set_update_frequency(FREQ_40_HZ);
|
||||
}
|
||||
|
||||
CCAccelerometer::~CCAccelerometer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
||||
{
|
||||
if (m_spCCAccelerometer == NULL)
|
||||
m_spCCAccelerometer = new CCAccelerometer();
|
||||
|
||||
return m_spCCAccelerometer;
|
||||
}
|
||||
|
||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||
{
|
||||
m_pAccelDelegate = pDelegate;
|
||||
}
|
||||
|
||||
void CCAccelerometer::update(long timeStamp)
|
||||
{
|
||||
if ( m_pAccelDelegate != NULL)
|
||||
{
|
||||
int angle = atoi(getenv("ORIENTATION"));
|
||||
|
||||
double x, y, z;
|
||||
|
||||
accelerometer_read_forces(&x, &y, &z);
|
||||
|
||||
if (m_initialOrientationAngle == 270)
|
||||
{
|
||||
m_accelerationValue.x = y;
|
||||
m_accelerationValue.y = -x;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 90)
|
||||
{
|
||||
m_accelerationValue.x = -y;
|
||||
m_accelerationValue.y = x;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 0)
|
||||
{
|
||||
m_accelerationValue.x = x;
|
||||
m_accelerationValue.y = y;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 180)
|
||||
{
|
||||
m_accelerationValue.x = -x;
|
||||
m_accelerationValue.y = -y;
|
||||
}
|
||||
|
||||
m_accelerationValue.z = z;
|
||||
m_accelerationValue.timestamp = (double)timeStamp;
|
||||
|
||||
m_pAccelDelegate->didAccelerate(&m_accelerationValue);
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace cococs2d
|
||||
|
||||
/****************************************************************************
|
||||
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 "CCAccelerometer_qnx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <bps/accelerometer.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BUFFER_SIZE 30
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
CCAccelerometer* CCAccelerometer::m_spCCAccelerometer = NULL;
|
||||
int CCAccelerometer::m_initialOrientationAngle = 0;
|
||||
|
||||
CCAccelerometer::CCAccelerometer()
|
||||
{
|
||||
m_pAccelDelegate = NULL;
|
||||
m_initialOrientationAngle = atoi(getenv("ORIENTATION"));
|
||||
|
||||
accelerometer_set_update_frequency(FREQ_40_HZ);
|
||||
}
|
||||
|
||||
CCAccelerometer::~CCAccelerometer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
||||
{
|
||||
if (m_spCCAccelerometer == NULL)
|
||||
m_spCCAccelerometer = new CCAccelerometer();
|
||||
|
||||
return m_spCCAccelerometer;
|
||||
}
|
||||
|
||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||
{
|
||||
m_pAccelDelegate = pDelegate;
|
||||
}
|
||||
|
||||
void CCAccelerometer::update(long timeStamp)
|
||||
{
|
||||
if ( m_pAccelDelegate != NULL)
|
||||
{
|
||||
int angle = atoi(getenv("ORIENTATION"));
|
||||
|
||||
double x, y, z;
|
||||
|
||||
accelerometer_read_forces(&x, &y, &z);
|
||||
|
||||
if (m_initialOrientationAngle == 270)
|
||||
{
|
||||
m_accelerationValue.x = y;
|
||||
m_accelerationValue.y = -x;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 90)
|
||||
{
|
||||
m_accelerationValue.x = -y;
|
||||
m_accelerationValue.y = x;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 0)
|
||||
{
|
||||
m_accelerationValue.x = x;
|
||||
m_accelerationValue.y = y;
|
||||
}
|
||||
else if (m_initialOrientationAngle == 180)
|
||||
{
|
||||
m_accelerationValue.x = -x;
|
||||
m_accelerationValue.y = -y;
|
||||
}
|
||||
|
||||
m_accelerationValue.z = z;
|
||||
m_accelerationValue.timestamp = (double)timeStamp;
|
||||
|
||||
m_pAccelDelegate->didAccelerate(&m_accelerationValue);
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace cococs2d
|
||||
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __PLATFORM_QNX_CCACCELEROMETER_H__
|
||||
#define __PLATFORM_QNX_CCACCELEROMETER_H__
|
||||
|
||||
#include "CCCommon.h"
|
||||
#include "CCAccelerometerDelegate.h"
|
||||
#include <list>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CC_DLL CCAccelerometer
|
||||
{
|
||||
public:
|
||||
CCAccelerometer();
|
||||
~CCAccelerometer();
|
||||
|
||||
static CCAccelerometer* sharedAccelerometer();
|
||||
|
||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
||||
void update(long sensorTimeStamp);
|
||||
|
||||
private:
|
||||
|
||||
static CCAccelerometer* m_spCCAccelerometer;
|
||||
CCAccelerometerDelegate* m_pAccelDelegate;
|
||||
CCAcceleration m_accelerationValue;
|
||||
static int m_initialOrientationAngle;
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif
|
||||
/****************************************************************************
|
||||
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_QNX_CCACCELEROMETER_H__
|
||||
#define __PLATFORM_QNX_CCACCELEROMETER_H__
|
||||
|
||||
#include "CCCommon.h"
|
||||
#include "CCAccelerometerDelegate.h"
|
||||
#include <list>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CC_DLL CCAccelerometer
|
||||
{
|
||||
public:
|
||||
CCAccelerometer();
|
||||
~CCAccelerometer();
|
||||
|
||||
static CCAccelerometer* sharedAccelerometer();
|
||||
|
||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
||||
void update(long sensorTimeStamp);
|
||||
|
||||
private:
|
||||
|
||||
static CCAccelerometer* m_spCCAccelerometer;
|
||||
CCAccelerometerDelegate* m_pAccelDelegate;
|
||||
CCAcceleration m_accelerationValue;
|
||||
static int m_initialOrientationAngle;
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,146 +1,146 @@
|
|||
#include "CCApplication.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCAccelerometer.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <bps/locale.h>
|
||||
|
||||
#define LOGD(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
// sharedApplication pointer
|
||||
CCApplication * CCApplication::sm_pSharedApplication = 0;
|
||||
long CCApplication::m_animationInterval = 1000;
|
||||
|
||||
// convert the timespec into milliseconds
|
||||
static long time2millis(struct timespec *times)
|
||||
{
|
||||
return times->tv_sec*1000 + times->tv_nsec/1000000;
|
||||
}
|
||||
|
||||
CCApplication::CCApplication()
|
||||
{
|
||||
CC_ASSERT(! sm_pSharedApplication);
|
||||
sm_pSharedApplication = this;
|
||||
}
|
||||
|
||||
CCApplication::~CCApplication()
|
||||
{
|
||||
CC_ASSERT(this == sm_pSharedApplication);
|
||||
sm_pSharedApplication = NULL;
|
||||
}
|
||||
|
||||
int CCApplication::run()
|
||||
{
|
||||
struct timespec time_struct;
|
||||
long current_time, update_time;
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (!initInstance() || !applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &time_struct);
|
||||
update_time = time2millis(&time_struct);
|
||||
|
||||
|
||||
while (1) // or device wants to quit
|
||||
{
|
||||
CCEGLView::sharedOpenGLView().HandleEvents();
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &time_struct);
|
||||
current_time = time2millis(&time_struct);
|
||||
|
||||
if ((current_time - update_time) > m_animationInterval)
|
||||
{
|
||||
update_time = current_time;
|
||||
|
||||
CCAccelerometer::sharedAccelerometer()->update(current_time);
|
||||
CCDirector::sharedDirector()->mainLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CCApplication::setAnimationInterval(double interval)
|
||||
{
|
||||
// interval in milliseconds
|
||||
m_animationInterval = (long)(interval * 1000);
|
||||
}
|
||||
|
||||
CCApplication::Orientation CCApplication::setOrientation(Orientation orientation)
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void CCApplication::statusBarFrame(CCRect * rect)
|
||||
{
|
||||
if (rect)
|
||||
{
|
||||
// qnx doesn't have a status bar
|
||||
*rect = CCRectMake(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// static member function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CCApplication& CCApplication::sharedApplication()
|
||||
{
|
||||
CC_ASSERT(sm_pSharedApplication);
|
||||
return *sm_pSharedApplication;
|
||||
}
|
||||
|
||||
ccLanguageType CCApplication::getCurrentLanguage()
|
||||
{
|
||||
ccLanguageType ret_language = kLanguageEnglish;
|
||||
char *language, *country;
|
||||
|
||||
locale_get(&language, &country);
|
||||
|
||||
if (strcmp(language, "en") == 0)
|
||||
{
|
||||
ret_language = kLanguageEnglish;
|
||||
}
|
||||
else if (strcmp(language, "fr") == 0)
|
||||
{
|
||||
ret_language = kLanguageFrench;
|
||||
}
|
||||
else if (strcmp(language, "de") == 0)
|
||||
{
|
||||
ret_language = kLanguageGerman;
|
||||
}
|
||||
else if (strcmp(language, "it") == 0)
|
||||
{
|
||||
ret_language = kLanguageItalian;
|
||||
}
|
||||
else if (strcmp(language, "es") == 0)
|
||||
{
|
||||
ret_language = kLanguageSpanish;
|
||||
}
|
||||
else if (strcmp(language, "ch") == 0)
|
||||
{
|
||||
ret_language = kLanguageChinese;
|
||||
}
|
||||
else if (strcmp(language, "ru") == 0)
|
||||
{
|
||||
ret_language = kLanguageRussian;
|
||||
}
|
||||
|
||||
free(language);
|
||||
free(country);
|
||||
|
||||
return ret_language;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
#include "CCApplication.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCAccelerometer.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <bps/locale.h>
|
||||
|
||||
#define LOGD(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
// sharedApplication pointer
|
||||
CCApplication * CCApplication::sm_pSharedApplication = 0;
|
||||
long CCApplication::m_animationInterval = 1000;
|
||||
|
||||
// convert the timespec into milliseconds
|
||||
static long time2millis(struct timespec *times)
|
||||
{
|
||||
return times->tv_sec*1000 + times->tv_nsec/1000000;
|
||||
}
|
||||
|
||||
CCApplication::CCApplication()
|
||||
{
|
||||
CC_ASSERT(! sm_pSharedApplication);
|
||||
sm_pSharedApplication = this;
|
||||
}
|
||||
|
||||
CCApplication::~CCApplication()
|
||||
{
|
||||
CC_ASSERT(this == sm_pSharedApplication);
|
||||
sm_pSharedApplication = NULL;
|
||||
}
|
||||
|
||||
int CCApplication::run()
|
||||
{
|
||||
struct timespec time_struct;
|
||||
long current_time, update_time;
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (!initInstance() || !applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &time_struct);
|
||||
update_time = time2millis(&time_struct);
|
||||
|
||||
|
||||
while (1) // or device wants to quit
|
||||
{
|
||||
CCEGLView::sharedOpenGLView().HandleEvents();
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &time_struct);
|
||||
current_time = time2millis(&time_struct);
|
||||
|
||||
if ((current_time - update_time) > m_animationInterval)
|
||||
{
|
||||
update_time = current_time;
|
||||
|
||||
CCAccelerometer::sharedAccelerometer()->update(current_time);
|
||||
CCDirector::sharedDirector()->mainLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// sleep(0);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CCApplication::setAnimationInterval(double interval)
|
||||
{
|
||||
// interval in milliseconds
|
||||
m_animationInterval = (long)(interval * 1000);
|
||||
}
|
||||
|
||||
CCApplication::Orientation CCApplication::setOrientation(Orientation orientation)
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void CCApplication::statusBarFrame(CCRect * rect)
|
||||
{
|
||||
if (rect)
|
||||
{
|
||||
// qnx doesn't have a status bar
|
||||
*rect = CCRectMake(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// static member function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CCApplication& CCApplication::sharedApplication()
|
||||
{
|
||||
CC_ASSERT(sm_pSharedApplication);
|
||||
return *sm_pSharedApplication;
|
||||
}
|
||||
|
||||
ccLanguageType CCApplication::getCurrentLanguage()
|
||||
{
|
||||
ccLanguageType ret_language = kLanguageEnglish;
|
||||
char *language, *country;
|
||||
|
||||
locale_get(&language, &country);
|
||||
|
||||
if (strcmp(language, "en") == 0)
|
||||
{
|
||||
ret_language = kLanguageEnglish;
|
||||
}
|
||||
else if (strcmp(language, "fr") == 0)
|
||||
{
|
||||
ret_language = kLanguageFrench;
|
||||
}
|
||||
else if (strcmp(language, "de") == 0)
|
||||
{
|
||||
ret_language = kLanguageGerman;
|
||||
}
|
||||
else if (strcmp(language, "it") == 0)
|
||||
{
|
||||
ret_language = kLanguageItalian;
|
||||
}
|
||||
else if (strcmp(language, "es") == 0)
|
||||
{
|
||||
ret_language = kLanguageSpanish;
|
||||
}
|
||||
else if (strcmp(language, "ch") == 0)
|
||||
{
|
||||
ret_language = kLanguageChinese;
|
||||
}
|
||||
else if (strcmp(language, "ru") == 0)
|
||||
{
|
||||
ret_language = kLanguageRussian;
|
||||
}
|
||||
|
||||
free(language);
|
||||
free(country);
|
||||
|
||||
return ret_language;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,121 +1,123 @@
|
|||
/****************************************************************************
|
||||
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 __CC_EGLVIEW_QNX_H__
|
||||
#define __CC_EGLVIEW_QNX_H__
|
||||
|
||||
#include "CCGeometry.h"
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <screen/screen.h>
|
||||
|
||||
namespace cocos2d {
|
||||
class CCSet;
|
||||
class CCTouch;
|
||||
class EGLTouchDelegate;
|
||||
|
||||
class CC_DLL CCEGLView
|
||||
{
|
||||
public:
|
||||
CCEGLView();
|
||||
virtual ~CCEGLView();
|
||||
|
||||
CCSize getSize();
|
||||
bool isOpenGLReady();
|
||||
/**
|
||||
* the width and height is the real size of phone
|
||||
*/
|
||||
void setFrameWidthAndHeight(int width, int height);
|
||||
/**
|
||||
* create a drawing rect,
|
||||
* the width and heiht is the resource size match best
|
||||
*/
|
||||
bool Create(int width, int height);
|
||||
EGLTouchDelegate* getDelegate(void);
|
||||
|
||||
// keep compatible
|
||||
void release();
|
||||
void setTouchDelegate(EGLTouchDelegate * pDelegate);
|
||||
void swapBuffers();
|
||||
bool canSetContentScaleFactor();
|
||||
void setContentScaleFactor(float contentScaleFactor);
|
||||
void setViewPortInPoints(float x, float y, float w, float h);
|
||||
void setScissorInPoints(float x, float y, float w, float h);
|
||||
CCRect getViewPort();
|
||||
float getScreenScaleFactor();
|
||||
void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
bool HandleEvents();
|
||||
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static CCEGLView& sharedOpenGLView();
|
||||
|
||||
// pointer to OES methods from EGL
|
||||
static PFNGLGENERATEMIPMAPOESPROC glGenerateMipmapOES;
|
||||
static PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOES;
|
||||
static PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOES;
|
||||
static PFNGLFRAMEBUFFERTEXTURE2DOESPROC glFramebufferTexture2DOES;
|
||||
static PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOES;
|
||||
static PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOES;
|
||||
|
||||
private:
|
||||
|
||||
bool initGL();
|
||||
void initEGLFunctions();
|
||||
bool isGLExtension(const char *searchName) const;
|
||||
bool initDriver();
|
||||
void printEGLInfo(const EGLConfig &config) const;
|
||||
EGLConfig chooseConfig(const EGLDisplay &eglDisplay, const char* str);
|
||||
int chooseFormat(const EGLDisplay &eglDisplay, const EGLConfig &config);
|
||||
bool createNativeWindow(const EGLConfig &config);
|
||||
void showKeyboard();
|
||||
void hideKeyboard();
|
||||
|
||||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
bool m_bNotHVGA;
|
||||
bool m_isGLInitialized;
|
||||
|
||||
EGLTouchDelegate *m_pDelegate;
|
||||
float m_fScreenScaleFactor;
|
||||
|
||||
static bool m_initializedFunctions;
|
||||
static const GLubyte *m_extensions;
|
||||
|
||||
EGLDisplay m_eglDisplay;
|
||||
EGLContext m_eglContext;
|
||||
EGLSurface m_eglSurface;
|
||||
screen_event_t m_screenEvent;
|
||||
screen_window_t m_screenWindow;
|
||||
screen_context_t m_screenContext;
|
||||
};
|
||||
|
||||
} // end of namespace cocos2d
|
||||
|
||||
#endif // end of __CC_EGLVIEW_QNX_H__
|
||||
/****************************************************************************
|
||||
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 __CC_EGLVIEW_QNX_H__
|
||||
#define __CC_EGLVIEW_QNX_H__
|
||||
|
||||
#include "CCGeometry.h"
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <screen/screen.h>
|
||||
|
||||
namespace cocos2d {
|
||||
class CCSet;
|
||||
class CCTouch;
|
||||
class EGLTouchDelegate;
|
||||
|
||||
class CC_DLL CCEGLView
|
||||
{
|
||||
public:
|
||||
CCEGLView();
|
||||
virtual ~CCEGLView();
|
||||
|
||||
CCSize getSize();
|
||||
bool isOpenGLReady();
|
||||
/**
|
||||
* the width and height is the real size of phone
|
||||
*/
|
||||
void setFrameWidthAndHeight(int width, int height);
|
||||
/**
|
||||
* create a drawing rect,
|
||||
* the width and heiht is the resource size match best
|
||||
*/
|
||||
bool Create(int width, int height);
|
||||
EGLTouchDelegate* getDelegate(void);
|
||||
|
||||
// keep compatible
|
||||
void release();
|
||||
void setTouchDelegate(EGLTouchDelegate * pDelegate);
|
||||
void swapBuffers();
|
||||
bool canSetContentScaleFactor();
|
||||
void setContentScaleFactor(float contentScaleFactor);
|
||||
void setViewPortInPoints(float x, float y, float w, float h);
|
||||
void setScissorInPoints(float x, float y, float w, float h);
|
||||
CCRect getViewPort();
|
||||
float getScreenScaleFactor();
|
||||
void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
bool HandleEvents();
|
||||
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static CCEGLView& sharedOpenGLView();
|
||||
|
||||
// pointer to OES methods from EGL
|
||||
static PFNGLGENERATEMIPMAPOESPROC glGenerateMipmapOES;
|
||||
static PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOES;
|
||||
static PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOES;
|
||||
static PFNGLFRAMEBUFFERTEXTURE2DOESPROC glFramebufferTexture2DOES;
|
||||
static PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOES;
|
||||
static PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOES;
|
||||
|
||||
private:
|
||||
|
||||
bool initGL();
|
||||
void initEGLFunctions();
|
||||
bool isGLExtension(const char *searchName) const;
|
||||
bool initDriver();
|
||||
void printEGLInfo(const EGLConfig &config) const;
|
||||
EGLConfig chooseConfig(const EGLDisplay &eglDisplay, const char* str);
|
||||
int chooseFormat(const EGLDisplay &eglDisplay, const EGLConfig &config);
|
||||
bool createNativeWindow(const EGLConfig &config);
|
||||
void showKeyboard();
|
||||
void hideKeyboard();
|
||||
|
||||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
bool m_bNotHVGA;
|
||||
bool m_isGLInitialized;
|
||||
|
||||
EGLTouchDelegate *m_pDelegate;
|
||||
float m_fScreenScaleFactor;
|
||||
|
||||
bool m_isWindowActive;
|
||||
|
||||
static bool m_initializedFunctions;
|
||||
static const GLubyte *m_extensions;
|
||||
|
||||
EGLDisplay m_eglDisplay;
|
||||
EGLContext m_eglContext;
|
||||
EGLSurface m_eglSurface;
|
||||
screen_event_t m_screenEvent;
|
||||
screen_window_t m_screenWindow;
|
||||
screen_context_t m_screenContext;
|
||||
};
|
||||
|
||||
} // end of namespace cocos2d
|
||||
|
||||
#endif // end of __CC_EGLVIEW_QNX_H__
|
||||
|
|
|
@ -1,161 +1,161 @@
|
|||
/****************************************************************************
|
||||
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 "CCFileUtils.h"
|
||||
#include "CCCommon.h"
|
||||
#include "CCString.h"
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
#define MAX_PATH 256
|
||||
|
||||
// record the resource path
|
||||
static std::string s_strResourcePath = "";
|
||||
static std::string s_pszZipFilePath = "";
|
||||
|
||||
void CCFileUtils::setResourcePath(const char *pszResourcePath)
|
||||
{
|
||||
CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path");
|
||||
CCAssert(strlen(pszResourcePath) <= MAX_PATH, "[FileUtils setResourcePath] -- resource path too long");
|
||||
|
||||
if (!pszResourcePath)
|
||||
return;
|
||||
|
||||
s_strResourcePath = pszResourcePath;
|
||||
|
||||
// if the path is not ended with '/', append it
|
||||
if (s_strResourcePath.find("/") != (strlen(s_strResourcePath.c_str()) - 1))
|
||||
{
|
||||
s_strResourcePath += "/";
|
||||
}
|
||||
}
|
||||
|
||||
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||
{
|
||||
// It works like this: if the relative path already includes the resource path
|
||||
// it will be returned as it is
|
||||
const std::string relPath = pszRelativePath;
|
||||
if (relPath.find(s_strResourcePath) == std::string::npos)
|
||||
{
|
||||
CCString *pRet = new CCString();
|
||||
pRet->autorelease();
|
||||
pRet->m_sString = s_strResourcePath + pszRelativePath;
|
||||
return pRet->m_sString.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return pszRelativePath;
|
||||
}
|
||||
}
|
||||
|
||||
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
|
||||
{
|
||||
std::string relativeFile = pszRelativeFile;
|
||||
CCString *pRet = new CCString();
|
||||
pRet->autorelease();
|
||||
pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
|
||||
pRet->m_sString += pszFilename;
|
||||
return pRet->m_sString.c_str();
|
||||
}
|
||||
|
||||
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
|
||||
std::string full_path = pszFileName;
|
||||
|
||||
// If it is not inside resource path
|
||||
if (full_path.find(s_strResourcePath) == std::string::npos)
|
||||
{
|
||||
full_path = s_strResourcePath + pszFileName;
|
||||
}
|
||||
|
||||
// if specify the zip file,load from it first
|
||||
if (s_pszZipFilePath[0] != 0)
|
||||
{
|
||||
buffer = getFileDataFromZip(s_pszZipFilePath.c_str(), full_path.c_str(), pSize);
|
||||
}
|
||||
|
||||
// if that failed then let's try and load the file ourselves
|
||||
if (!buffer)
|
||||
{
|
||||
// read the file from hardware
|
||||
FILE *fp = fopen(full_path.c_str(), pszMode);
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*pSize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
buffer = new unsigned char[*pSize];
|
||||
*pSize = fread(buffer, sizeof(unsigned char), *pSize, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
// we couldn't find the file
|
||||
if (!buffer && getIsPopupNotify())
|
||||
{
|
||||
std::string title = "Notification";
|
||||
std::string msg = "Get data from file(";
|
||||
msg.append(full_path);
|
||||
if (s_pszZipFilePath[0] != 0)
|
||||
{
|
||||
msg.append(") in zip archive(").append(s_pszZipFilePath);
|
||||
}
|
||||
msg.append(") failed!");
|
||||
|
||||
CCMessageBox(msg.c_str(), title.c_str());
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void CCFileUtils::setResource(const char* pszZipFileName)
|
||||
{
|
||||
s_pszZipFilePath = pszZipFileName;
|
||||
}
|
||||
|
||||
int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out)
|
||||
{
|
||||
CCAssert(0, "Have not implemented!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string CCFileUtils::getWriteablePath()
|
||||
{
|
||||
// Let's write it in the current working directory's data folder
|
||||
char cwd[FILENAME_MAX];
|
||||
|
||||
getcwd(cwd, FILENAME_MAX - 1);
|
||||
cwd[FILENAME_MAX] = '\0';
|
||||
|
||||
std::string path = cwd;
|
||||
path += "/data/";
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
/****************************************************************************
|
||||
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 "CCFileUtils.h"
|
||||
#include "CCCommon.h"
|
||||
#include "CCString.h"
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
#define MAX_PATH 256
|
||||
|
||||
// record the resource path
|
||||
static std::string s_strResourcePath = "";
|
||||
static std::string s_pszZipFilePath = "";
|
||||
|
||||
void CCFileUtils::setResourcePath(const char *pszResourcePath)
|
||||
{
|
||||
CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path");
|
||||
CCAssert(strlen(pszResourcePath) <= MAX_PATH, "[FileUtils setResourcePath] -- resource path too long");
|
||||
|
||||
if (!pszResourcePath)
|
||||
return;
|
||||
|
||||
s_strResourcePath = pszResourcePath;
|
||||
|
||||
// if the path is not ended with '/', append it
|
||||
if (s_strResourcePath.find("/") != (strlen(s_strResourcePath.c_str()) - 1))
|
||||
{
|
||||
s_strResourcePath += "/";
|
||||
}
|
||||
}
|
||||
|
||||
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||
{
|
||||
// It works like this: if the relative path already includes the resource path
|
||||
// it will be returned as it is
|
||||
const std::string relPath = pszRelativePath;
|
||||
if (relPath.find(s_strResourcePath) == std::string::npos)
|
||||
{
|
||||
CCString *pRet = new CCString();
|
||||
pRet->autorelease();
|
||||
pRet->m_sString = s_strResourcePath + pszRelativePath;
|
||||
return pRet->m_sString.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return pszRelativePath;
|
||||
}
|
||||
}
|
||||
|
||||
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
|
||||
{
|
||||
std::string relativeFile = pszRelativeFile;
|
||||
CCString *pRet = new CCString();
|
||||
pRet->autorelease();
|
||||
pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
|
||||
pRet->m_sString += pszFilename;
|
||||
return pRet->m_sString.c_str();
|
||||
}
|
||||
|
||||
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
|
||||
std::string full_path = pszFileName;
|
||||
|
||||
// If it is not inside resource path
|
||||
if (full_path.find(s_strResourcePath) == std::string::npos)
|
||||
{
|
||||
full_path = s_strResourcePath + pszFileName;
|
||||
}
|
||||
|
||||
// if specify the zip file,load from it first
|
||||
if (s_pszZipFilePath[0] != 0)
|
||||
{
|
||||
buffer = getFileDataFromZip(s_pszZipFilePath.c_str(), full_path.c_str(), pSize);
|
||||
}
|
||||
|
||||
// if that failed then let's try and load the file ourselves
|
||||
if (!buffer)
|
||||
{
|
||||
// read the file from hardware
|
||||
FILE *fp = fopen(full_path.c_str(), pszMode);
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*pSize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
buffer = new unsigned char[*pSize];
|
||||
*pSize = fread(buffer, sizeof(unsigned char), *pSize, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
// we couldn't find the file
|
||||
if (!buffer && getIsPopupNotify())
|
||||
{
|
||||
std::string title = "Notification";
|
||||
std::string msg = "Get data from file(";
|
||||
msg.append(full_path);
|
||||
if (s_pszZipFilePath[0] != 0)
|
||||
{
|
||||
msg.append(") in zip archive(").append(s_pszZipFilePath);
|
||||
}
|
||||
msg.append(") failed!");
|
||||
|
||||
CCMessageBox(msg.c_str(), title.c_str());
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void CCFileUtils::setResource(const char* pszZipFileName)
|
||||
{
|
||||
s_pszZipFilePath = pszZipFileName;
|
||||
}
|
||||
|
||||
int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out)
|
||||
{
|
||||
CCAssert(0, "Have not implemented!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string CCFileUtils::getWriteablePath()
|
||||
{
|
||||
// Let's write it in the current working directory's data folder
|
||||
char cwd[FILENAME_MAX];
|
||||
|
||||
getcwd(cwd, FILENAME_MAX - 1);
|
||||
cwd[FILENAME_MAX] = '\0';
|
||||
|
||||
std::string path = cwd;
|
||||
path += "/data/";
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
|
Loading…
Reference in New Issue