mirror of https://github.com/axmolengine/axmol.git
issue #2462:use cocos2d-x c++ style
This commit is contained in:
parent
a8ac892c0b
commit
bf79a0560b
|
@ -65,7 +65,7 @@ void Camera::restore(void)
|
|||
_upY = 1.0f;
|
||||
_upZ = 0.0f;
|
||||
|
||||
kmMat4Identity( &_lookupMatrix );
|
||||
kmMat4Identity(&_lookupMatrix);
|
||||
|
||||
_dirty = false;
|
||||
}
|
||||
|
@ -76,15 +76,15 @@ void Camera::locate(void)
|
|||
{
|
||||
kmVec3 eye, center, up;
|
||||
|
||||
kmVec3Fill( &eye, _eyeX, _eyeY , _eyeZ );
|
||||
kmVec3Fill( ¢er, _centerX, _centerY, _centerZ );
|
||||
kmVec3Fill(&eye, _eyeX, _eyeY , _eyeZ);
|
||||
kmVec3Fill(¢er, _centerX, _centerY, _centerZ);
|
||||
|
||||
kmVec3Fill( &up, _upX, _upY, _upZ);
|
||||
kmMat4LookAt( &_lookupMatrix, &eye, ¢er, &up);
|
||||
kmVec3Fill(&up, _upX, _upY, _upZ);
|
||||
kmMat4LookAt(&_lookupMatrix, &eye, ¢er, &up);
|
||||
|
||||
_dirty = false;
|
||||
}
|
||||
kmGLMultMatrix( &_lookupMatrix );
|
||||
kmGLMultMatrix(&_lookupMatrix);
|
||||
}
|
||||
|
||||
float Camera::getZEye(void)
|
||||
|
|
|
@ -24,13 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCCAMERA_H__
|
||||
#define __CCCAMERA_H__
|
||||
#ifndef __COCOS2DX_CAMERA_H__
|
||||
#define __COCOS2DX_CAMERA_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cocoa/CCObject.h"
|
||||
#include "ccMacros.h"
|
||||
#include "kazmath/mat4.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -122,4 +124,4 @@ private:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCCAMERA_H__
|
||||
#endif // __COCOS2DX_CAMERA_H__
|
||||
|
|
|
@ -24,9 +24,9 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCConfiguration.h"
|
||||
#include <string.h>
|
||||
#include "ccMacros.h"
|
||||
#include "ccConfig.h"
|
||||
#include <string.h>
|
||||
#include "cocoa/CCDictionary.h"
|
||||
#include "cocoa/CCInteger.h"
|
||||
#include "cocoa/CCBool.h"
|
||||
|
@ -38,9 +38,9 @@ using namespace std;
|
|||
NS_CC_BEGIN
|
||||
|
||||
|
||||
Configuration* Configuration::s_gSharedConfiguration = NULL;
|
||||
Configuration* Configuration::s_sharedConfiguration = nullptr;
|
||||
|
||||
Configuration::Configuration(void)
|
||||
Configuration::Configuration()
|
||||
: _maxTextureSize(0)
|
||||
, _maxModelviewStackDepth(0)
|
||||
, _supportsPVRTC(false)
|
||||
|
@ -51,40 +51,40 @@ Configuration::Configuration(void)
|
|||
, _supportsShareableVAO(false)
|
||||
, _maxSamplesAllowed(0)
|
||||
, _maxTextureUnits(0)
|
||||
, _glExtensions(NULL)
|
||||
, _valueDict(NULL)
|
||||
, _glExtensions(nullptr)
|
||||
, _valueDict(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool Configuration::init(void)
|
||||
bool Configuration::init()
|
||||
{
|
||||
_valueDict = Dictionary::create();
|
||||
_valueDict->retain();
|
||||
|
||||
_valueDict->setObject( String::create( cocos2dVersion() ), "cocos2d.x.version");
|
||||
_valueDict->setObject(String::create( cocos2dVersion() ), "cocos2d.x.version");
|
||||
|
||||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
_valueDict->setObject( Bool::create(true), "cocos2d.x.compiled_with_profiler");
|
||||
_valueDict->setObject(Bool::create(true), "cocos2d.x.compiled_with_profiler");
|
||||
#else
|
||||
_valueDict->setObject( Bool::create(false), "cocos2d.x.compiled_with_profiler");
|
||||
_valueDict->setObject(Bool::create(false), "cocos2d.x.compiled_with_profiler");
|
||||
#endif
|
||||
|
||||
#if CC_ENABLE_GL_STATE_CACHE == 0
|
||||
_valueDict->setObject( Bool::create(false), "cocos2d.x.compiled_with_gl_state_cache");
|
||||
_valueDict->setObject(Bool::create(false), "cocos2d.x.compiled_with_gl_state_cache");
|
||||
#else
|
||||
_valueDict->setObject( Bool::create(true), "cocos2d.x.compiled_with_gl_state_cache");
|
||||
_valueDict->setObject(Bool::create(true), "cocos2d.x.compiled_with_gl_state_cache");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Configuration::~Configuration(void)
|
||||
Configuration::~Configuration()
|
||||
{
|
||||
_valueDict->release();
|
||||
}
|
||||
|
||||
void Configuration::dumpInfo(void) const
|
||||
void Configuration::dumpInfo() const
|
||||
{
|
||||
// Dump
|
||||
PrettyPrinter visitor(0);
|
||||
|
@ -109,68 +109,68 @@ void Configuration::dumpInfo(void) const
|
|||
|
||||
void Configuration::gatherGPUInfo()
|
||||
{
|
||||
_valueDict->setObject( String::create( (const char*)glGetString(GL_VENDOR)), "gl.vendor");
|
||||
_valueDict->setObject( String::create( (const char*)glGetString(GL_RENDERER)), "gl.renderer");
|
||||
_valueDict->setObject( String::create( (const char*)glGetString(GL_VERSION)), "gl.version");
|
||||
_valueDict->setObject(String::create((const char*)glGetString(GL_VENDOR)), "gl.vendor");
|
||||
_valueDict->setObject(String::create((const char*)glGetString(GL_RENDERER)), "gl.renderer");
|
||||
_valueDict->setObject(String::create((const char*)glGetString(GL_VERSION)), "gl.version");
|
||||
|
||||
_glExtensions = (char *)glGetString(GL_EXTENSIONS);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize);
|
||||
_valueDict->setObject( Integer::create((int)_maxTextureSize), "gl.max_texture_size");
|
||||
_valueDict->setObject(Integer::create((int)_maxTextureSize), "gl.max_texture_size");
|
||||
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits);
|
||||
_valueDict->setObject( Integer::create((int)_maxTextureUnits), "gl.max_texture_units");
|
||||
_valueDict->setObject(Integer::create((int)_maxTextureUnits), "gl.max_texture_units");
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
glGetIntegerv(GL_MAX_SAMPLES_APPLE, &_maxSamplesAllowed);
|
||||
_valueDict->setObject( Integer::create((int)_maxSamplesAllowed), "gl.max_samples_allowed");
|
||||
_valueDict->setObject(Integer::create((int)_maxSamplesAllowed), "gl.max_samples_allowed");
|
||||
#endif
|
||||
|
||||
_supportsETC = checkForGLExtension("GL_OES_compressed_ETC1_RGB8_texture");
|
||||
_valueDict->setObject( Bool::create(_supportsETC), "gl.supports_ETC");
|
||||
_valueDict->setObject(Bool::create(_supportsETC), "gl.supports_ETC");
|
||||
|
||||
_supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
||||
_valueDict->setObject( Bool::create(_supportsPVRTC), "gl.supports_PVRTC");
|
||||
_valueDict->setObject(Bool::create(_supportsPVRTC), "gl.supports_PVRTC");
|
||||
|
||||
_supportsNPOT = true;
|
||||
_valueDict->setObject( Bool::create(_supportsNPOT), "gl.supports_NPOT");
|
||||
_valueDict->setObject(Bool::create(_supportsNPOT), "gl.supports_NPOT");
|
||||
|
||||
_supportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888");
|
||||
_valueDict->setObject( Bool::create(_supportsBGRA8888), "gl.supports_BGRA8888");
|
||||
_valueDict->setObject(Bool::create(_supportsBGRA8888), "gl.supports_BGRA8888");
|
||||
|
||||
_supportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer");
|
||||
_valueDict->setObject( Bool::create(_supportsDiscardFramebuffer), "gl.supports_discard_framebuffer");
|
||||
_valueDict->setObject(Bool::create(_supportsDiscardFramebuffer), "gl.supports_discard_framebuffer");
|
||||
|
||||
_supportsShareableVAO = checkForGLExtension("vertex_array_object");
|
||||
_valueDict->setObject( Bool::create(_supportsShareableVAO), "gl.supports_vertex_array_object");
|
||||
_valueDict->setObject(Bool::create(_supportsShareableVAO), "gl.supports_vertex_array_object");
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
Configuration* Configuration::getInstance()
|
||||
{
|
||||
if (! s_gSharedConfiguration)
|
||||
if (! s_sharedConfiguration)
|
||||
{
|
||||
s_gSharedConfiguration = new Configuration();
|
||||
s_gSharedConfiguration->init();
|
||||
s_sharedConfiguration = new Configuration();
|
||||
s_sharedConfiguration->init();
|
||||
}
|
||||
|
||||
return s_gSharedConfiguration;
|
||||
return s_sharedConfiguration;
|
||||
}
|
||||
|
||||
void Configuration::destroyInstance()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(s_gSharedConfiguration);
|
||||
CC_SAFE_RELEASE_NULL(s_sharedConfiguration);
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
Configuration* Configuration::sharedConfiguration(void)
|
||||
Configuration* Configuration::sharedConfiguration()
|
||||
{
|
||||
return Configuration::getInstance();
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
void Configuration::purgeConfiguration(void)
|
||||
void Configuration::purgeConfiguration()
|
||||
{
|
||||
Configuration::destroyInstance();
|
||||
}
|
||||
|
@ -178,43 +178,43 @@ void Configuration::purgeConfiguration(void)
|
|||
|
||||
bool Configuration::checkForGLExtension(const string &searchName) const
|
||||
{
|
||||
bool bRet = false;
|
||||
bool ret = false;
|
||||
const char *kSearchName = searchName.c_str();
|
||||
|
||||
if (_glExtensions &&
|
||||
strstr(_glExtensions, kSearchName))
|
||||
{
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// getters for specific variables.
|
||||
// Mantained for backward compatiblity reasons only.
|
||||
//
|
||||
int Configuration::getMaxTextureSize(void) const
|
||||
int Configuration::getMaxTextureSize() const
|
||||
{
|
||||
return _maxTextureSize;
|
||||
}
|
||||
|
||||
int Configuration::getMaxModelviewStackDepth(void) const
|
||||
int Configuration::getMaxModelviewStackDepth() const
|
||||
{
|
||||
return _maxModelviewStackDepth;
|
||||
}
|
||||
|
||||
int Configuration::getMaxTextureUnits(void) const
|
||||
int Configuration::getMaxTextureUnits() const
|
||||
{
|
||||
return _maxTextureUnits;
|
||||
}
|
||||
|
||||
bool Configuration::supportsNPOT(void) const
|
||||
bool Configuration::supportsNPOT() const
|
||||
{
|
||||
return _supportsNPOT;
|
||||
}
|
||||
|
||||
bool Configuration::supportsPVRTC(void) const
|
||||
bool Configuration::supportsPVRTC() const
|
||||
{
|
||||
return _supportsPVRTC;
|
||||
}
|
||||
|
@ -229,17 +229,17 @@ bool Configuration::supportsETC() const
|
|||
#endif
|
||||
}
|
||||
|
||||
bool Configuration::supportsBGRA8888(void) const
|
||||
bool Configuration::supportsBGRA8888() const
|
||||
{
|
||||
return _supportsBGRA8888;
|
||||
}
|
||||
|
||||
bool Configuration::supportsDiscardFramebuffer(void) const
|
||||
bool Configuration::supportsDiscardFramebuffer() const
|
||||
{
|
||||
return _supportsDiscardFramebuffer;
|
||||
}
|
||||
|
||||
bool Configuration::supportsShareableVAO(void) const
|
||||
bool Configuration::supportsShareableVAO() const
|
||||
{
|
||||
return _supportsShareableVAO;
|
||||
}
|
||||
|
@ -247,63 +247,66 @@ bool Configuration::supportsShareableVAO(void) const
|
|||
//
|
||||
// generic getters for properties
|
||||
//
|
||||
const char *Configuration::getCString( const char *key, const char *default_value ) const
|
||||
const char *Configuration::getCString(const char *key, const char *defaultValue) const
|
||||
{
|
||||
Object *ret = _valueDict->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( String *str=dynamic_cast<String*>(ret) )
|
||||
if (ret)
|
||||
{
|
||||
if (String *str=dynamic_cast<String*>(ret))
|
||||
return str->getCString();
|
||||
|
||||
CCASSERT(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
return default_value;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/** returns the value of a given key as a boolean */
|
||||
bool Configuration::getBool( const char *key, bool default_value ) const
|
||||
bool Configuration::getBool(const char *key, bool defaultValue) const
|
||||
{
|
||||
Object *ret = _valueDict->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( Bool *boolobj=dynamic_cast<Bool*>(ret) )
|
||||
if (ret)
|
||||
{
|
||||
if (Bool *boolobj=dynamic_cast<Bool*>(ret))
|
||||
return boolobj->getValue();
|
||||
if( String *strobj=dynamic_cast<String*>(ret) )
|
||||
if (String *strobj=dynamic_cast<String*>(ret))
|
||||
return strobj->boolValue();
|
||||
CCASSERT(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
return default_value;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/** returns the value of a given key as a double */
|
||||
double Configuration::getNumber( const char *key, double default_value ) const
|
||||
double Configuration::getNumber( const char *key, double defaultValue ) const
|
||||
{
|
||||
Object *ret = _valueDict->objectForKey(key);
|
||||
if( ret ) {
|
||||
if( Double *obj=dynamic_cast<Double*>(ret) )
|
||||
if( ret )
|
||||
{
|
||||
if (Double *obj=dynamic_cast<Double*>(ret))
|
||||
return obj->getValue();
|
||||
|
||||
if( Integer *obj=dynamic_cast<Integer*>(ret) )
|
||||
if (Integer *obj=dynamic_cast<Integer*>(ret))
|
||||
return obj->getValue();
|
||||
|
||||
if( String *strobj=dynamic_cast<String*>(ret) )
|
||||
if (String *strobj=dynamic_cast<String*>(ret))
|
||||
return strobj->doubleValue();
|
||||
|
||||
CCASSERT(false, "Key found, but from different type");
|
||||
}
|
||||
|
||||
// XXX: Should it throw an exception ?
|
||||
return default_value;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Object * Configuration::getObject( const char *key ) const
|
||||
Object * Configuration::getObject(const char *key) const
|
||||
{
|
||||
return _valueDict->objectForKey(key);
|
||||
}
|
||||
|
||||
void Configuration::setObject( const char *key, Object *value )
|
||||
void Configuration::setObject(const char *key, Object *value)
|
||||
{
|
||||
_valueDict->setObject(value, key);
|
||||
}
|
||||
|
@ -312,35 +315,40 @@ void Configuration::setObject( const char *key, Object *value )
|
|||
//
|
||||
// load file
|
||||
//
|
||||
void Configuration::loadConfigFile( const char *filename )
|
||||
void Configuration::loadConfigFile(const char *filename)
|
||||
{
|
||||
Dictionary *dict = Dictionary::createWithContentsOfFile(filename);
|
||||
CCASSERT(dict, "cannot create dictionary");
|
||||
|
||||
// search for metadata
|
||||
bool metadata_ok = false;
|
||||
bool validMetadata = false;
|
||||
Object *metadata = dict->objectForKey("metadata");
|
||||
if( metadata && dynamic_cast<Dictionary*>(metadata) ) {
|
||||
if (metadata && dynamic_cast<Dictionary*>(metadata))
|
||||
{
|
||||
Object *format_o = static_cast<Dictionary*>(metadata)->objectForKey("format");
|
||||
|
||||
// XXX: cocos2d-x returns Strings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
|
||||
if( format_o && dynamic_cast<String*>(format_o) ) {
|
||||
if (format_o && dynamic_cast<String*>(format_o))
|
||||
{
|
||||
int format = static_cast<String*>(format_o)->intValue();
|
||||
|
||||
// Support format: 1
|
||||
if( format == 1 ) {
|
||||
metadata_ok = true;
|
||||
if (format == 1)
|
||||
{
|
||||
validMetadata = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ! metadata_ok ) {
|
||||
if (! validMetadata)
|
||||
{
|
||||
CCLOG("Invalid config format for file: %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
Object *data = dict->objectForKey("data");
|
||||
if( !data || !dynamic_cast<Dictionary*>(data) ) {
|
||||
if (!data || !dynamic_cast<Dictionary*>(data))
|
||||
{
|
||||
CCLOG("Expected 'data' dict, but not found. Config file: %s", filename);
|
||||
return;
|
||||
}
|
||||
|
@ -350,10 +358,10 @@ void Configuration::loadConfigFile( const char *filename )
|
|||
DictElement* element;
|
||||
CCDICT_FOREACH(data_dict, element)
|
||||
{
|
||||
if( ! _valueDict->objectForKey( element->getStrKey() ) )
|
||||
_valueDict->setObject(element->getObject(), element->getStrKey() );
|
||||
if(! _valueDict->objectForKey( element->getStrKey() ))
|
||||
_valueDict->setObject(element->getObject(), element->getStrKey());
|
||||
else
|
||||
CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
|
||||
CCLOG("Key already present. Ignoring '%s'", element->getStrKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,90 +54,90 @@ public:
|
|||
static void destroyInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration(void);
|
||||
CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration();
|
||||
|
||||
/** @deprecated Use destroyInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration(void);
|
||||
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Configuration(void);
|
||||
virtual ~Configuration();
|
||||
|
||||
/** OpenGL Max texture size. */
|
||||
int getMaxTextureSize(void) const;
|
||||
int getMaxTextureSize() const;
|
||||
|
||||
/** OpenGL Max Modelview Stack Depth. */
|
||||
int getMaxModelviewStackDepth(void) const;
|
||||
int getMaxModelviewStackDepth() const;
|
||||
|
||||
/** returns the maximum texture units
|
||||
@since v2.0.0
|
||||
*/
|
||||
int getMaxTextureUnits(void) const;
|
||||
int getMaxTextureUnits() const;
|
||||
|
||||
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
|
||||
OpenGL ES 2.0 already supports NPOT (iOS).
|
||||
|
||||
@since v0.99.2
|
||||
*/
|
||||
bool supportsNPOT(void) const;
|
||||
bool supportsNPOT() const;
|
||||
|
||||
/** Whether or not PVR Texture Compressed is supported */
|
||||
bool supportsPVRTC(void) const;
|
||||
bool supportsPVRTC() const;
|
||||
|
||||
/** Whether or not ETC Texture Compressed is supported */
|
||||
bool supportsETC(void) const;
|
||||
bool supportsETC() const;
|
||||
|
||||
/** Whether or not BGRA8888 textures are supported.
|
||||
@since v0.99.2
|
||||
*/
|
||||
bool supportsBGRA8888(void) const;
|
||||
bool supportsBGRA8888() const;
|
||||
|
||||
/** Whether or not glDiscardFramebufferEXT is supported
|
||||
@since v0.99.2
|
||||
*/
|
||||
bool supportsDiscardFramebuffer(void) const;
|
||||
bool supportsDiscardFramebuffer() const;
|
||||
|
||||
/** Whether or not shareable VAOs are supported.
|
||||
@since v2.0.0
|
||||
*/
|
||||
bool supportsShareableVAO(void) const;
|
||||
bool supportsShareableVAO() const;
|
||||
|
||||
/** returns whether or not an OpenGL is supported */
|
||||
bool checkForGLExtension(const std::string &searchName) const;
|
||||
|
||||
bool init(void);
|
||||
bool init();
|
||||
|
||||
/** returns the value of a given key as a string.
|
||||
If the key is not found, it will return the default value */
|
||||
const char* getCString( const char *key, const char *default_value=NULL ) const;
|
||||
const char* getCString(const char *key, const char *defaultValue = nullptr) const;
|
||||
|
||||
/** returns the value of a given key as a boolean.
|
||||
If the key is not found, it will return the default value */
|
||||
bool getBool( const char *key, bool default_value=false ) const;
|
||||
bool getBool(const char *key, bool defaultValue = false) const;
|
||||
|
||||
/** returns the value of a given key as a double.
|
||||
If the key is not found, it will return the default value */
|
||||
double getNumber( const char *key, double default_value=0.0 ) const;
|
||||
double getNumber(const char *key, double defaultValue = 0.0) const;
|
||||
|
||||
/** returns the value of a given key as a double */
|
||||
Object * getObject( const char *key ) const;
|
||||
Object * getObject(const char *key) const;
|
||||
|
||||
/** sets a new key/value pair in the configuration dictionary */
|
||||
void setObject( const char *key, Object *value );
|
||||
void setObject(const char *key, Object *value);
|
||||
|
||||
/** dumps the current configuration on the console */
|
||||
void dumpInfo(void) const;
|
||||
void dumpInfo() const;
|
||||
|
||||
/** gathers OpenGL / GPU information */
|
||||
void gatherGPUInfo( void );
|
||||
void gatherGPUInfo();
|
||||
|
||||
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */
|
||||
void loadConfigFile( const char *filename );
|
||||
void loadConfigFile(const char *filename);
|
||||
|
||||
private:
|
||||
Configuration(void);
|
||||
static Configuration *s_gSharedConfiguration;
|
||||
static std::string s_sConfigfile;
|
||||
static Configuration *s_sharedConfiguration;
|
||||
static std::string s_configfile;
|
||||
|
||||
protected:
|
||||
GLint _maxTextureSize;
|
||||
|
|
|
@ -83,7 +83,7 @@ NS_CC_BEGIN
|
|||
// XXX it should be a Director ivar. Move it there once support for multiple directors is added
|
||||
|
||||
// singleton stuff
|
||||
static DisplayLinkDirector *s_SharedDirector = NULL;
|
||||
static DisplayLinkDirector *s_SharedDirector = nullptr;
|
||||
|
||||
#define kDefaultFPS 60 // 60 frames per second
|
||||
extern const char* cocos2dVersion(void);
|
||||
|
@ -109,23 +109,23 @@ bool Director::init(void)
|
|||
setDefaultValues();
|
||||
|
||||
// scenes
|
||||
_runningScene = NULL;
|
||||
_nextScene = NULL;
|
||||
_runningScene = nullptr;
|
||||
_nextScene = nullptr;
|
||||
|
||||
_notificationNode = NULL;
|
||||
_notificationNode = nullptr;
|
||||
|
||||
_scenesStack = new Array();
|
||||
_scenesStack->init();
|
||||
|
||||
// projection delegate if "Custom" projection is used
|
||||
_projectionDelegate = NULL;
|
||||
_projectionDelegate = nullptr;
|
||||
|
||||
// FPS
|
||||
_accumDt = 0.0f;
|
||||
_frameRate = 0.0f;
|
||||
_FPSLabel = NULL;
|
||||
_SPFLabel = NULL;
|
||||
_drawsLabel = NULL;
|
||||
_FPSLabel = nullptr;
|
||||
_SPFLabel = nullptr;
|
||||
_drawsLabel = nullptr;
|
||||
_totalFrames = _frames = 0;
|
||||
_FPS = new char[10];
|
||||
_lastUpdate = new struct timeval;
|
||||
|
@ -138,7 +138,7 @@ bool Director::init(void)
|
|||
|
||||
_winSizeInPoints = Size::ZERO;
|
||||
|
||||
_openGLView = NULL;
|
||||
_openGLView = nullptr;
|
||||
|
||||
_contentScaleFactor = 1.0f;
|
||||
|
||||
|
@ -193,7 +193,7 @@ Director::~Director(void)
|
|||
// delete fps string
|
||||
delete []_FPS;
|
||||
|
||||
s_SharedDirector = NULL;
|
||||
s_SharedDirector = nullptr;
|
||||
}
|
||||
|
||||
void Director::setDefaultValues(void)
|
||||
|
@ -209,7 +209,7 @@ void Director::setDefaultValues(void)
|
|||
|
||||
// GL projection
|
||||
const char *projection = conf->getCString("cocos2d.x.gl.projection", "2d");
|
||||
if( strcmp(projection, "3d") == 0 )
|
||||
if (strcmp(projection, "3d") == 0)
|
||||
_projection = Projection::_3D;
|
||||
else if (strcmp(projection, "2d") == 0)
|
||||
_projection = Projection::_2D;
|
||||
|
@ -220,11 +220,11 @@ void Director::setDefaultValues(void)
|
|||
|
||||
// Default pixel format for PNG images with alpha
|
||||
const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888");
|
||||
if( strcmp(pixel_format, "rgba8888") == 0 )
|
||||
if (strcmp(pixel_format, "rgba8888") == 0)
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
else if( strcmp(pixel_format, "rgba4444") == 0 )
|
||||
else if(strcmp(pixel_format, "rgba4444") == 0)
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
else if( strcmp(pixel_format, "rgba5551") == 0 )
|
||||
else if(strcmp(pixel_format, "rgba5551") == 0)
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
|
||||
|
||||
// PVR v2 has alpha premultiplied ?
|
||||
|
@ -232,7 +232,7 @@ void Director::setDefaultValues(void)
|
|||
Texture2D::PVRImagesHavePremultipliedAlpha(pvr_alpha_premultipled);
|
||||
}
|
||||
|
||||
void Director::setGLDefaultValues(void)
|
||||
void Director::setGLDefaultValues()
|
||||
{
|
||||
// This method SHOULD be called only after openGLView_ was initialized
|
||||
CCASSERT(_openGLView, "opengl view should not be null");
|
||||
|
@ -248,7 +248,7 @@ void Director::setGLDefaultValues(void)
|
|||
}
|
||||
|
||||
// Draw the Scene
|
||||
void Director::drawScene(void)
|
||||
void Director::drawScene()
|
||||
{
|
||||
// calculate "global" dt
|
||||
calculateDeltaTime();
|
||||
|
@ -308,11 +308,11 @@ void Director::drawScene(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Director::calculateDeltaTime(void)
|
||||
void Director::calculateDeltaTime()
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
if (gettimeofday(&now, NULL) != 0)
|
||||
if (gettimeofday(&now, nullptr) != 0)
|
||||
{
|
||||
CCLOG("error in gettimeofday");
|
||||
_deltaTime = 0;
|
||||
|
@ -333,7 +333,7 @@ void Director::calculateDeltaTime(void)
|
|||
|
||||
#ifdef DEBUG
|
||||
// If we are debugging our code, prevent big delta time
|
||||
if(_deltaTime > 0.2f)
|
||||
if (_deltaTime > 0.2f)
|
||||
{
|
||||
_deltaTime = 1 / 60.0f;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ void Director::setProjection(Projection projection)
|
|||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadIdentity();
|
||||
kmMat4 orthoMatrix;
|
||||
kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024 );
|
||||
kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024);
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadIdentity();
|
||||
|
@ -418,7 +418,7 @@ void Director::setProjection(Projection projection)
|
|||
kmGLLoadIdentity();
|
||||
|
||||
// issue #1334
|
||||
kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
|
||||
kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
|
||||
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
|
||||
|
||||
kmGLMultMatrix(&matrixPerspective);
|
||||
|
@ -426,9 +426,9 @@ void Director::setProjection(Projection projection)
|
|||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadIdentity();
|
||||
kmVec3 eye, center, up;
|
||||
kmVec3Fill( &eye, size.width/2, size.height/2, zeye );
|
||||
kmVec3Fill( ¢er, size.width/2, size.height/2, 0.0f );
|
||||
kmVec3Fill( &up, 0.0f, 1.0f, 0.0f);
|
||||
kmVec3Fill(&eye, size.width/2, size.height/2, zeye);
|
||||
kmVec3Fill(¢er, size.width/2, size.height/2, 0.0f);
|
||||
kmVec3Fill(&up, 0.0f, 1.0f, 0.0f);
|
||||
kmMat4LookAt(&matrixLookup, &eye, ¢er, &up);
|
||||
kmGLMultMatrix(&matrixLookup);
|
||||
break;
|
||||
|
@ -437,6 +437,7 @@ void Director::setProjection(Projection projection)
|
|||
case Projection::CUSTOM:
|
||||
if (_projectionDelegate)
|
||||
_projectionDelegate->updateProjection();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -464,9 +465,9 @@ float Director::getZEye(void) const
|
|||
return (_winSizeInPoints.height / 1.1566f);
|
||||
}
|
||||
|
||||
void Director::setAlphaBlending(bool bOn)
|
||||
void Director::setAlphaBlending(bool on)
|
||||
{
|
||||
if (bOn)
|
||||
if (on)
|
||||
{
|
||||
GL::blendFunc(CC_BLEND_SRC, CC_BLEND_DST);
|
||||
}
|
||||
|
@ -478,9 +479,9 @@ void Director::setAlphaBlending(bool bOn)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
void Director::setDepthTest(bool bOn)
|
||||
void Director::setDepthTest(bool on)
|
||||
{
|
||||
if (bOn)
|
||||
if (on)
|
||||
{
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -494,8 +495,7 @@ void Director::setDepthTest(bool bOn)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
static void
|
||||
GLToClipTransform(kmMat4 *transformOut)
|
||||
static void GLToClipTransform(kmMat4 *transformOut)
|
||||
{
|
||||
kmMat4 projection;
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &projection);
|
||||
|
@ -576,41 +576,41 @@ Point Director::getVisibleOrigin() const
|
|||
|
||||
// scene management
|
||||
|
||||
void Director::runWithScene(Scene *pScene)
|
||||
void Director::runWithScene(Scene *scene)
|
||||
{
|
||||
CCASSERT(pScene != NULL, "This command can only be used to start the Director. There is already a scene present.");
|
||||
CCASSERT(_runningScene == NULL, "_runningScene should be null");
|
||||
CCASSERT(scene != nullptr, "This command can only be used to start the Director. There is already a scene present.");
|
||||
CCASSERT(_runningScene == nullptr, "_runningScene should be null");
|
||||
|
||||
pushScene(pScene);
|
||||
pushScene(scene);
|
||||
startAnimation();
|
||||
}
|
||||
|
||||
void Director::replaceScene(Scene *pScene)
|
||||
void Director::replaceScene(Scene *scene)
|
||||
{
|
||||
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
||||
CCASSERT(pScene != NULL, "the scene should not be null");
|
||||
CCASSERT(scene != nullptr, "the scene should not be null");
|
||||
|
||||
unsigned int index = _scenesStack->count();
|
||||
|
||||
_sendCleanupToScene = true;
|
||||
_scenesStack->replaceObjectAtIndex(index - 1, pScene);
|
||||
_scenesStack->replaceObjectAtIndex(index - 1, scene);
|
||||
|
||||
_nextScene = pScene;
|
||||
_nextScene = scene;
|
||||
}
|
||||
|
||||
void Director::pushScene(Scene *pScene)
|
||||
void Director::pushScene(Scene *scene)
|
||||
{
|
||||
CCASSERT(pScene, "the scene should not null");
|
||||
CCASSERT(scene, "the scene should not null");
|
||||
|
||||
_sendCleanupToScene = false;
|
||||
|
||||
_scenesStack->addObject(pScene);
|
||||
_nextScene = pScene;
|
||||
_scenesStack->addObject(scene);
|
||||
_nextScene = scene;
|
||||
}
|
||||
|
||||
void Director::popScene(void)
|
||||
{
|
||||
CCASSERT(_runningScene != NULL, "running scene should not null");
|
||||
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
||||
|
||||
_scenesStack->removeLastObject();
|
||||
unsigned int c = _scenesStack->count();
|
||||
|
@ -633,8 +633,8 @@ void Director::popToRootScene(void)
|
|||
|
||||
void Director::popToSceneStackLevel(int level)
|
||||
{
|
||||
CCASSERT(_runningScene != NULL, "A running Scene is needed");
|
||||
int c = (int)_scenesStack->count();
|
||||
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
||||
int c = static_cast<int>(_scenesStack->count());
|
||||
|
||||
// level 0? -> end
|
||||
if (level == 0)
|
||||
|
@ -660,7 +660,7 @@ void Director::popToSceneStackLevel(int level)
|
|||
|
||||
current->cleanup();
|
||||
_scenesStack->removeLastObject();
|
||||
c--;
|
||||
--c;
|
||||
}
|
||||
|
||||
_nextScene = (Scene*)_scenesStack->lastObject();
|
||||
|
@ -689,8 +689,8 @@ void Director::purgeDirector()
|
|||
_runningScene->release();
|
||||
}
|
||||
|
||||
_runningScene = NULL;
|
||||
_nextScene = NULL;
|
||||
_runningScene = nullptr;
|
||||
_nextScene = nullptr;
|
||||
|
||||
// remove all objects, but don't release it.
|
||||
// runWithScene might be executed after 'end'.
|
||||
|
@ -724,16 +724,16 @@ void Director::purgeDirector()
|
|||
|
||||
// OpenGL view
|
||||
_openGLView->end();
|
||||
_openGLView = NULL;
|
||||
_openGLView = nullptr;
|
||||
|
||||
// delete Director
|
||||
release();
|
||||
}
|
||||
|
||||
void Director::setNextScene(void)
|
||||
void Director::setNextScene()
|
||||
{
|
||||
bool runningIsTransition = dynamic_cast<TransitionScene*>(_runningScene) != NULL;
|
||||
bool newIsTransition = dynamic_cast<TransitionScene*>(_nextScene) != NULL;
|
||||
bool runningIsTransition = dynamic_cast<TransitionScene*>(_runningScene) != nullptr;
|
||||
bool newIsTransition = dynamic_cast<TransitionScene*>(_nextScene) != nullptr;
|
||||
|
||||
// If it is not a transition, call onExit/cleanup
|
||||
if (! newIsTransition)
|
||||
|
@ -758,7 +758,7 @@ void Director::setNextScene(void)
|
|||
}
|
||||
_runningScene = _nextScene;
|
||||
_nextScene->retain();
|
||||
_nextScene = NULL;
|
||||
_nextScene = nullptr;
|
||||
|
||||
if ((! runningIsTransition) && _runningScene)
|
||||
{
|
||||
|
@ -767,7 +767,7 @@ void Director::setNextScene(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Director::pause(void)
|
||||
void Director::pause()
|
||||
{
|
||||
if (_paused)
|
||||
{
|
||||
|
@ -781,7 +781,7 @@ void Director::pause(void)
|
|||
_paused = true;
|
||||
}
|
||||
|
||||
void Director::resume(void)
|
||||
void Director::resume()
|
||||
{
|
||||
if (! _paused)
|
||||
{
|
||||
|
@ -790,7 +790,7 @@ void Director::resume(void)
|
|||
|
||||
setAnimationInterval(_oldAnimationInterval);
|
||||
|
||||
if (gettimeofday(_lastUpdate, NULL) != 0)
|
||||
if (gettimeofday(_lastUpdate, nullptr) != 0)
|
||||
{
|
||||
CCLOG("cocos2d: Director: Error in gettimeofday");
|
||||
}
|
||||
|
@ -801,9 +801,9 @@ void Director::resume(void)
|
|||
|
||||
// display the FPS using a LabelAtlas
|
||||
// updates the FPS every frame
|
||||
void Director::showStats(void)
|
||||
void Director::showStats()
|
||||
{
|
||||
_frames++;
|
||||
++_frames;
|
||||
_accumDt += _deltaTime;
|
||||
|
||||
if (_displayStats)
|
||||
|
@ -838,7 +838,7 @@ void Director::showStats(void)
|
|||
void Director::calculateMPF()
|
||||
{
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
gettimeofday(&now, nullptr);
|
||||
|
||||
_secondsPerFrame = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f;
|
||||
}
|
||||
|
@ -853,10 +853,10 @@ void Director::getFPSImageData(unsigned char** datapointer, unsigned int* length
|
|||
|
||||
void Director::createStatsLabel()
|
||||
{
|
||||
Texture2D *texture = NULL;
|
||||
Texture2D *texture = nullptr;
|
||||
TextureCache *textureCache = TextureCache::getInstance();
|
||||
|
||||
if( _FPSLabel && _SPFLabel )
|
||||
if (_FPSLabel && _SPFLabel)
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(_FPSLabel);
|
||||
CC_SAFE_RELEASE_NULL(_SPFLabel);
|
||||
|
@ -867,13 +867,13 @@ void Director::createStatsLabel()
|
|||
|
||||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
unsigned char *data = NULL;
|
||||
unsigned int data_len = 0;
|
||||
getFPSImageData(&data, &data_len);
|
||||
unsigned char *data = nullptr;
|
||||
unsigned int dataLength = 0;
|
||||
getFPSImageData(&data, &dataLength);
|
||||
|
||||
Image* image = new Image();
|
||||
bool isOK = image->initWithImageData(data, data_len);
|
||||
if (!isOK) {
|
||||
bool isOK = image->initWithImageData(data, dataLength);
|
||||
if (! isOK) {
|
||||
CCLOGERROR("%s", "Fails: init fps_images");
|
||||
return;
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ void Director::createStatsLabel()
|
|||
_FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
|
||||
}
|
||||
|
||||
float Director::getContentScaleFactor(void) const
|
||||
float Director::getContentScaleFactor() const
|
||||
{
|
||||
return _contentScaleFactor;
|
||||
}
|
||||
|
@ -949,18 +949,18 @@ DirectorDelegate* Director::getDelegate() const
|
|||
return _projectionDelegate;
|
||||
}
|
||||
|
||||
void Director::setDelegate(DirectorDelegate* pDelegate)
|
||||
void Director::setDelegate(DirectorDelegate* delegate)
|
||||
{
|
||||
_projectionDelegate = pDelegate;
|
||||
_projectionDelegate = delegate;
|
||||
}
|
||||
|
||||
void Director::setScheduler(Scheduler* pScheduler)
|
||||
void Director::setScheduler(Scheduler* scheduler)
|
||||
{
|
||||
if (_scheduler != pScheduler)
|
||||
if (_scheduler != scheduler)
|
||||
{
|
||||
CC_SAFE_RETAIN(pScheduler);
|
||||
CC_SAFE_RETAIN(scheduler);
|
||||
CC_SAFE_RELEASE(_scheduler);
|
||||
_scheduler = pScheduler;
|
||||
_scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -969,13 +969,13 @@ Scheduler* Director::getScheduler() const
|
|||
return _scheduler;
|
||||
}
|
||||
|
||||
void Director::setActionManager(ActionManager* pActionManager)
|
||||
void Director::setActionManager(ActionManager* actionManager)
|
||||
{
|
||||
if (_actionManager != pActionManager)
|
||||
if (_actionManager != actionManager)
|
||||
{
|
||||
CC_SAFE_RETAIN(pActionManager);
|
||||
CC_SAFE_RETAIN(actionManager);
|
||||
CC_SAFE_RELEASE(_actionManager);
|
||||
_actionManager = pActionManager;
|
||||
_actionManager = actionManager;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,13 +984,13 @@ ActionManager* Director::getActionManager() const
|
|||
return _actionManager;
|
||||
}
|
||||
|
||||
void Director::setTouchDispatcher(TouchDispatcher* pTouchDispatcher)
|
||||
void Director::setTouchDispatcher(TouchDispatcher* touchDispatcher)
|
||||
{
|
||||
if (_touchDispatcher != pTouchDispatcher)
|
||||
if (_touchDispatcher != touchDispatcher)
|
||||
{
|
||||
CC_SAFE_RETAIN(pTouchDispatcher);
|
||||
CC_SAFE_RETAIN(touchDispatcher);
|
||||
CC_SAFE_RELEASE(_touchDispatcher);
|
||||
_touchDispatcher = pTouchDispatcher;
|
||||
_touchDispatcher = touchDispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -999,11 +999,11 @@ TouchDispatcher* Director::getTouchDispatcher() const
|
|||
return _touchDispatcher;
|
||||
}
|
||||
|
||||
void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher)
|
||||
void Director::setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher)
|
||||
{
|
||||
CC_SAFE_RETAIN(pKeyboardDispatcher);
|
||||
CC_SAFE_RETAIN(keyboardDispatcher);
|
||||
CC_SAFE_RELEASE(_keyboardDispatcher);
|
||||
_keyboardDispatcher = pKeyboardDispatcher;
|
||||
_keyboardDispatcher = keyboardDispatcher;
|
||||
}
|
||||
|
||||
KeyboardDispatcher* Director::getKeyboardDispatcher() const
|
||||
|
@ -1011,11 +1011,11 @@ KeyboardDispatcher* Director::getKeyboardDispatcher() const
|
|||
return _keyboardDispatcher;
|
||||
}
|
||||
|
||||
void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher)
|
||||
void Director::setKeypadDispatcher(KeypadDispatcher* keyboardDispatcher)
|
||||
{
|
||||
CC_SAFE_RETAIN(pKeypadDispatcher);
|
||||
CC_SAFE_RETAIN(keyboardDispatcher);
|
||||
CC_SAFE_RELEASE(_keypadDispatcher);
|
||||
_keypadDispatcher = pKeypadDispatcher;
|
||||
_keypadDispatcher = keyboardDispatcher;
|
||||
}
|
||||
|
||||
KeypadDispatcher* Director::getKeypadDispatcher() const
|
||||
|
@ -1023,12 +1023,12 @@ KeypadDispatcher* Director::getKeypadDispatcher() const
|
|||
return _keypadDispatcher;
|
||||
}
|
||||
|
||||
void Director::setAccelerometer(Accelerometer* pAccelerometer)
|
||||
void Director::setAccelerometer(Accelerometer* accelerometer)
|
||||
{
|
||||
if (_accelerometer != pAccelerometer)
|
||||
if (_accelerometer != accelerometer)
|
||||
{
|
||||
CC_SAFE_DELETE(_accelerometer);
|
||||
_accelerometer = pAccelerometer;
|
||||
_accelerometer = accelerometer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1044,9 +1044,9 @@ Accelerometer* Director::getAccelerometer() const
|
|||
// should we implement 4 types of director ??
|
||||
// I think DisplayLinkDirector is enough
|
||||
// so we now only support DisplayLinkDirector
|
||||
void DisplayLinkDirector::startAnimation(void)
|
||||
void DisplayLinkDirector::startAnimation()
|
||||
{
|
||||
if (gettimeofday(_lastUpdate, NULL) != 0)
|
||||
if (gettimeofday(_lastUpdate, nullptr) != 0)
|
||||
{
|
||||
CCLOG("cocos2d: DisplayLinkDirector: Error on gettimeofday");
|
||||
}
|
||||
|
@ -1057,7 +1057,7 @@ void DisplayLinkDirector::startAnimation(void)
|
|||
#endif // EMSCRIPTEN
|
||||
}
|
||||
|
||||
void DisplayLinkDirector::mainLoop(void)
|
||||
void DisplayLinkDirector::mainLoop()
|
||||
{
|
||||
if (_purgeDirecotorInNextLoop)
|
||||
{
|
||||
|
@ -1065,22 +1065,22 @@ void DisplayLinkDirector::mainLoop(void)
|
|||
purgeDirector();
|
||||
}
|
||||
else if (! _invalid)
|
||||
{
|
||||
drawScene();
|
||||
{
|
||||
drawScene();
|
||||
|
||||
// release the objects
|
||||
PoolManager::sharedPoolManager()->pop();
|
||||
}
|
||||
// release the objects
|
||||
PoolManager::sharedPoolManager()->pop();
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayLinkDirector::stopAnimation(void)
|
||||
void DisplayLinkDirector::stopAnimation()
|
||||
{
|
||||
_invalid = true;
|
||||
}
|
||||
|
||||
void DisplayLinkDirector::setAnimationInterval(double dValue)
|
||||
void DisplayLinkDirector::setAnimationInterval(double value)
|
||||
{
|
||||
_animationInterval = dValue;
|
||||
_animationInterval = value;
|
||||
if (! _invalid)
|
||||
{
|
||||
stopAnimation();
|
||||
|
|
|
@ -117,15 +117,15 @@ public:
|
|||
// attribute
|
||||
|
||||
/** Get current running Scene. Director can only run one Scene at the time */
|
||||
inline Scene* getRunningScene(void) { return _runningScene; }
|
||||
inline Scene* getRunningScene() { return _runningScene; }
|
||||
|
||||
/** Get the FPS value */
|
||||
inline double getAnimationInterval(void) { return _animationInterval; }
|
||||
inline double getAnimationInterval() { return _animationInterval; }
|
||||
/** Set the FPS value. */
|
||||
virtual void setAnimationInterval(double dValue) = 0;
|
||||
|
||||
/** Whether or not to display the FPS on the bottom-left corner */
|
||||
inline bool isDisplayStats(void) { return _displayStats; }
|
||||
inline bool isDisplayStats() { return _displayStats; }
|
||||
/** Display the FPS on the bottom-left corner */
|
||||
inline void setDisplayStats(bool displayStats) { _displayStats = displayStats; }
|
||||
|
||||
|
@ -133,22 +133,22 @@ public:
|
|||
inline float getSecondsPerFrame() { return _secondsPerFrame; }
|
||||
|
||||
/** Get the EGLView, where everything is rendered */
|
||||
inline EGLView* getOpenGLView(void) { return _openGLView; }
|
||||
inline EGLView* getOpenGLView() { return _openGLView; }
|
||||
void setOpenGLView(EGLView *pobOpenGLView);
|
||||
|
||||
inline bool isNextDeltaTimeZero(void) { return _nextDeltaTimeZero; }
|
||||
inline bool isNextDeltaTimeZero() { return _nextDeltaTimeZero; }
|
||||
void setNextDeltaTimeZero(bool nextDeltaTimeZero);
|
||||
|
||||
/** Whether or not the Director is paused */
|
||||
inline bool isPaused(void) { return _paused; }
|
||||
inline bool isPaused() { return _paused; }
|
||||
|
||||
/** How many frames were called since the director started */
|
||||
inline unsigned int getTotalFrames(void) { return _totalFrames; }
|
||||
inline unsigned int getTotalFrames() { return _totalFrames; }
|
||||
|
||||
/** Sets an OpenGL projection
|
||||
@since v0.8.2
|
||||
*/
|
||||
inline Projection getProjection(void) { return _projection; }
|
||||
inline Projection getProjection() { return _projection; }
|
||||
void setProjection(Projection projection);
|
||||
|
||||
/** Sets the glViewport*/
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
If the new scene replaces the old one, the it will receive the "cleanup" message.
|
||||
@since v0.99.0
|
||||
*/
|
||||
inline bool isSendCleanupToScene(void) { return _sendCleanupToScene; }
|
||||
inline bool isSendCleanupToScene() { return _sendCleanupToScene; }
|
||||
|
||||
/** This object will be visited after the main scene is visited.
|
||||
This object MUST implement the "visit" selector.
|
||||
|
@ -176,17 +176,17 @@ public:
|
|||
@since v0.99.5
|
||||
*/
|
||||
DirectorDelegate* getDelegate() const;
|
||||
void setDelegate(DirectorDelegate* pDelegate);
|
||||
void setDelegate(DirectorDelegate* delegate);
|
||||
|
||||
// window size
|
||||
|
||||
/** returns the size of the OpenGL view in points.
|
||||
*/
|
||||
const Size& getWinSize(void) const;
|
||||
const Size& getWinSize() const;
|
||||
|
||||
/** returns the size of the OpenGL view in pixels.
|
||||
*/
|
||||
Size getWinSizeInPixels(void) const;
|
||||
Size getWinSizeInPixels() const;
|
||||
|
||||
/** returns visible size of the OpenGL view in points.
|
||||
* the value is equal to getWinSize if don't invoke
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
Point convertToUI(const Point& point);
|
||||
|
||||
/// XXX: missing description
|
||||
float getZEye(void) const;
|
||||
float getZEye() const;
|
||||
|
||||
// Scene Management
|
||||
|
||||
|
@ -233,13 +233,13 @@ public:
|
|||
* The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
|
||||
* ONLY call it if there is a running scene.
|
||||
*/
|
||||
void popScene(void);
|
||||
void popScene();
|
||||
|
||||
/** Pops out all scenes from the queue until the root scene in the queue.
|
||||
* This scene will replace the running one.
|
||||
* Internally it will call `popToSceneStackLevel(1)`
|
||||
*/
|
||||
void popToRootScene(void);
|
||||
void popToRootScene();
|
||||
|
||||
/** Pops out all scenes from the queue until it reaches `level`.
|
||||
If level is 0, it will end the director.
|
||||
|
@ -256,35 +256,35 @@ public:
|
|||
/** Ends the execution, releases the running scene.
|
||||
It doesn't remove the OpenGL view from its parent. You have to do it manually.
|
||||
*/
|
||||
void end(void);
|
||||
void end();
|
||||
|
||||
/** Pauses the running scene.
|
||||
The running scene will be _drawed_ but all scheduled timers will be paused
|
||||
While paused, the draw rate will be 4 FPS to reduce CPU consumption
|
||||
*/
|
||||
void pause(void);
|
||||
void pause();
|
||||
|
||||
/** Resumes the paused scene
|
||||
The scheduled timers will be activated again.
|
||||
The "delta time" will be 0 (as if the game wasn't paused)
|
||||
*/
|
||||
void resume(void);
|
||||
void resume();
|
||||
|
||||
/** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore.
|
||||
If you don't want to pause your animation call [pause] instead.
|
||||
*/
|
||||
virtual void stopAnimation(void) = 0;
|
||||
virtual void stopAnimation() = 0;
|
||||
|
||||
/** The main loop is triggered again.
|
||||
Call this function only if [stopAnimation] was called earlier
|
||||
@warning Don't call this function to start the main loop. To run the main loop call runWithScene
|
||||
*/
|
||||
virtual void startAnimation(void) = 0;
|
||||
virtual void startAnimation() = 0;
|
||||
|
||||
/** Draw the scene.
|
||||
This method is called every frame. Don't call it manually.
|
||||
*/
|
||||
void drawScene(void);
|
||||
void drawScene();
|
||||
|
||||
// Memory Helper
|
||||
|
||||
|
@ -292,23 +292,23 @@ public:
|
|||
It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache
|
||||
@since v0.99.3
|
||||
*/
|
||||
void purgeCachedData(void);
|
||||
void purgeCachedData();
|
||||
|
||||
/** sets the default values based on the Configuration info */
|
||||
void setDefaultValues(void);
|
||||
void setDefaultValues();
|
||||
|
||||
// OpenGL Helper
|
||||
|
||||
/** sets the OpenGL default values */
|
||||
void setGLDefaultValues(void);
|
||||
void setGLDefaultValues();
|
||||
|
||||
/** enables/disables OpenGL alpha blending */
|
||||
void setAlphaBlending(bool bOn);
|
||||
void setAlphaBlending(bool on);
|
||||
|
||||
/** enables/disables OpenGL depth test */
|
||||
void setDepthTest(bool bOn);
|
||||
void setDepthTest(bool on);
|
||||
|
||||
virtual void mainLoop(void) = 0;
|
||||
virtual void mainLoop() = 0;
|
||||
|
||||
/** The size in pixels of the surface. It could be different than the screen size.
|
||||
High-res devices might have a higher surface size than the screen size.
|
||||
|
@ -316,7 +316,7 @@ public:
|
|||
@since v0.99.4
|
||||
*/
|
||||
void setContentScaleFactor(float scaleFactor);
|
||||
float getContentScaleFactor(void) const;
|
||||
float getContentScaleFactor() const;
|
||||
|
||||
public:
|
||||
/** Gets the Scheduler associated with this director
|
||||
|
@ -388,7 +388,7 @@ protected:
|
|||
void purgeDirector();
|
||||
bool _purgeDirecotorInNextLoop; // this flag will be set to true in end()
|
||||
|
||||
void setNextScene(void);
|
||||
void setNextScene();
|
||||
|
||||
void showStats();
|
||||
void createStatsLabel();
|
||||
|
@ -511,16 +511,16 @@ protected:
|
|||
class DisplayLinkDirector : public Director
|
||||
{
|
||||
public:
|
||||
DisplayLinkDirector(void)
|
||||
DisplayLinkDirector()
|
||||
: _invalid(false)
|
||||
{}
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void mainLoop(void) override;
|
||||
virtual void setAnimationInterval(double dValue) override;
|
||||
virtual void startAnimation(void) override;
|
||||
virtual void mainLoop() override;
|
||||
virtual void setAnimationInterval(double value) override;
|
||||
virtual void startAnimation() override;
|
||||
virtual void stopAnimation() override;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue