Merge branch 'develop' into develop_nutty_modify_framework_for315

This commit is contained in:
CaiWenzhi 2014-03-07 14:41:32 +08:00
commit 5ee35be0ad
10 changed files with 524 additions and 376 deletions

View File

@ -33,17 +33,18 @@ NS_CC_BEGIN
const int FontAtlas::CacheTextureWidth = 1024;
const int FontAtlas::CacheTextureHeight = 1024;
FontAtlas::FontAtlas(Font &theFont) :
_font(&theFont),
_currentPageData(nullptr)
FontAtlas::FontAtlas(Font &theFont)
: _font(&theFont)
, _currentPageData(nullptr)
, _fontAscender(0)
{
_font->retain();
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf)
{
_currentPageLineHeight = _font->getFontMaxHeight();
_commonLineHeight = _currentPageLineHeight * 0.8f;
_commonLineHeight = _font->getFontMaxHeight();
_fontAscender = fontTTf->getFontAscender();
auto texture = new Texture2D;
_currentPage = 0;
_currentPageOrigX = 0;
@ -139,13 +140,13 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.width = tempRect.size.width + _letterPadding;
tempDef.height = tempRect.size.height + _letterPadding;
tempDef.offsetX = tempRect.origin.x + offsetAdjust;
tempDef.offsetY = _commonLineHeight + tempRect.origin.y - offsetAdjust;
tempDef.offsetY = _fontAscender + tempRect.origin.y - offsetAdjust;
if (_currentPageOrigX + tempDef.width > CacheTextureWidth)
{
_currentPageOrigY += _currentPageLineHeight;
_currentPageOrigY += _commonLineHeight;
_currentPageOrigX = 0;
if(_currentPageOrigY + _currentPageLineHeight >= CacheTextureHeight)
if(_currentPageOrigY + _commonLineHeight >= CacheTextureHeight)
{
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
_currentPageOrigY = 0;

View File

@ -91,9 +91,10 @@ private:
int _currentPageDataSize;
float _currentPageOrigX;
float _currentPageOrigY;
float _currentPageLineHeight;
float _letterPadding;
bool _makeDistanceMap;
int _fontAscender;
};

View File

@ -162,24 +162,26 @@ FontAtlas * FontFreeType::createFontAtlas()
int * FontFreeType::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const
{
if (!text)
return 0;
if (!text || !_fontRef)
return nullptr;
outNumLetters = cc_wcslen(text);
if (!outNumLetters)
return 0;
return nullptr;
int *sizes = new int[outNumLetters];
if (!sizes)
return 0;
for (int c = 0; c < outNumLetters; ++c)
return nullptr;
memset(sizes,0,outNumLetters * sizeof(int));
bool hasKerning = FT_HAS_KERNING( _fontRef ) != 0;
if (hasKerning)
{
if (c < (outNumLetters-1))
sizes[c] = getHorizontalKerningForChars(text[c], text[c+1]);
else
sizes[c] = 0;
for (int c = 1; c < outNumLetters; ++c)
{
sizes[c] = getHorizontalKerningForChars(text[c-1], text[c]);
}
}
return sizes;
@ -187,14 +189,6 @@ int * FontFreeType::getHorizontalKerningForTextUTF16(unsigned short *text, int &
int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const
{
if (!_fontRef)
return 0;
bool hasKerning = FT_HAS_KERNING( _fontRef ) != 0;
if (!hasKerning)
return 0;
// get the ID to the char we need
int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar);
@ -220,6 +214,11 @@ int FontFreeType::getFontMaxHeight() const
return (static_cast<int>(_fontRef->size->metrics.height >> 6));
}
int FontFreeType::getFontAscender() const
{
return (static_cast<int>(_fontRef->size->metrics.ascender >> 6));
}
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight, Rect &outRect,int &xAdvance)
{
bool invalidChar = true;

View File

@ -56,6 +56,7 @@ public:
unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight, Rect &outRect,int &xAdvance);
virtual int getFontMaxHeight() const override;
virtual int getFontAscender() const;
protected:

View File

@ -87,6 +87,49 @@ void GLViewProtocol::pollInputEvents()
{
}
void GLViewProtocol::updateDesignResolutionSize()
{
if (_screenSize.width > 0 && _screenSize.height > 0
&& _designResolutionSize.width > 0 && _designResolutionSize.height > 0)
{
_scaleX = (float)_screenSize.width / _designResolutionSize.width;
_scaleY = (float)_screenSize.height / _designResolutionSize.height;
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
{
_scaleX = _scaleY = MAX(_scaleX, _scaleY);
}
else if (_resolutionPolicy == ResolutionPolicy::SHOW_ALL)
{
_scaleX = _scaleY = MIN(_scaleX, _scaleY);
}
else if ( _resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
_scaleX = _scaleY;
_designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
}
else if ( _resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
_scaleY = _scaleX;
_designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
}
// calculate the rect of viewport
float viewPortW = _designResolutionSize.width * _scaleX;
float viewPortH = _designResolutionSize.height * _scaleY;
_viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH);
// reset director's member variables to fit visible rect
auto director = Director::getInstance();
director->_winSizeInPoints = getDesignResolutionSize();
director->createStatsLabel();
director->setGLDefaultValues();
}
}
void GLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
{
CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");
@ -97,44 +140,10 @@ void GLViewProtocol::setDesignResolutionSize(float width, float height, Resoluti
}
_designResolutionSize.setSize(width, height);
_scaleX = (float)_screenSize.width / _designResolutionSize.width;
_scaleY = (float)_screenSize.height / _designResolutionSize.height;
if (resolutionPolicy == ResolutionPolicy::NO_BORDER)
{
_scaleX = _scaleY = MAX(_scaleX, _scaleY);
}
else if (resolutionPolicy == ResolutionPolicy::SHOW_ALL)
{
_scaleX = _scaleY = MIN(_scaleX, _scaleY);
}
else if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
_scaleX = _scaleY;
_designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
}
else if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
_scaleY = _scaleX;
_designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
}
// calculate the rect of viewport
float viewPortW = _designResolutionSize.width * _scaleX;
float viewPortH = _designResolutionSize.height * _scaleY;
_viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH);
_resolutionPolicy = resolutionPolicy;
// reset director's member variables to fit visible rect
auto director = Director::getInstance();
director->_winSizeInPoints = getDesignResolutionSize();
director->createStatsLabel();
director->setGLDefaultValues();
}
updateDesignResolutionSize();
}
const Size& GLViewProtocol::getDesignResolutionSize() const
{

View File

@ -186,6 +186,8 @@ public:
ResolutionPolicy getResolutionPolicy() const { return _resolutionPolicy; }
protected:
void updateDesignResolutionSize();
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
// real screen size

View File

@ -37,6 +37,78 @@ THE SOFTWARE.
NS_CC_BEGIN
// GLFWEventHandler
class GLFWEventHandler
{
public:
static void onGLFWError(int errorID, const char* errorDesc)
{
if (_view)
_view->onGLFWError(errorID, errorDesc);
}
static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{
if (_view)
_view->onGLFWMouseCallBack(window, button, action, modify);
}
static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
if (_view)
_view->onGLFWMouseMoveCallBack(window, x, y);
}
static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
{
if (_view)
_view->onGLFWMouseScrollCallback(window, x, y);
}
static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (_view)
_view->onGLFWKeyCallback(window, key, scancode, action, mods);
}
static void onGLFWCharCallback(GLFWwindow* window, unsigned int character)
{
if (_view)
_view->onGLFWCharCallback(window, character);
}
static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y)
{
if (_view)
_view->onGLFWWindowPosCallback(windows, x, y);
}
static void onGLFWframebuffersize(GLFWwindow* window, int w, int h)
{
if (_view)
_view->onGLFWframebuffersize(window, w, h);
}
static void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height)
{
if (_view)
_view->onGLFWWindowSizeFunCallback(window, width, height);
}
static void setGLView(GLView* view)
{
_view = view;
}
private:
static GLView* _view;
};
GLView* GLFWEventHandler::_view = nullptr;
////////////////////////////////////////////////////
struct keyCodeItem
{
int glfwKeyCode;
@ -48,7 +120,7 @@ static std::unordered_map<int, EventKeyboard::KeyCode> g_keyCodeMap;
static keyCodeItem g_keyCodeStructArray[] = {
/* The unknown key */
{ GLFW_KEY_UNKNOWN , EventKeyboard::KeyCode::KEY_NONE },
/* Printable keys */
{ GLFW_KEY_SPACE , EventKeyboard::KeyCode::KEY_SPACE },
{ GLFW_KEY_APOSTROPHE , EventKeyboard::KeyCode::KEY_APOSTROPHE },
@ -100,7 +172,7 @@ static keyCodeItem g_keyCodeStructArray[] = {
{ GLFW_KEY_GRAVE_ACCENT , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_1 , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_2 , EventKeyboard::KeyCode::KEY_NONE },
/* Function keys */
{ GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE },
{ GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
@ -175,186 +247,43 @@ static keyCodeItem g_keyCodeStructArray[] = {
{ GLFW_KEY_LAST , EventKeyboard::KeyCode::KEY_NONE }
};
//begin GLViewEventHandler
class GLViewEventHandler
{
public:
static bool s_captured;
static float s_mouseX;
static float s_mouseY;
static void onGLFWError(int errorID, const char* errorDesc);
static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify);
static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y);
static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void onGLFWCharCallback(GLFWwindow* window, unsigned int character);
static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
static void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
static void OnGLFWWindowSizeFunCallback(GLFWwindow *windows, int width, int height);
};
bool GLViewEventHandler::s_captured = false;
float GLViewEventHandler::s_mouseX = 0;
float GLViewEventHandler::s_mouseY = 0;
void GLViewEventHandler::onGLFWError(int errorID, const char* errorDesc)
{
CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc);
}
void GLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{
GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return;
if(GLFW_MOUSE_BUTTON_LEFT == button)
{
if(GLFW_PRESS == action)
{
s_captured = true;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{
int id = 0;
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
}
}
else if(GLFW_RELEASE == action)
{
s_captured = false;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{
int id = 0;
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
}
}
}
if(GLFW_PRESS == action)
{
EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
event.setMouseButton(button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
else if(GLFW_RELEASE == action)
{
EventMouse event(EventMouse::MouseEventType::MOUSE_UP);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
event.setMouseButton(button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
}
void GLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return;
if (eglView->isRetina()) {
x *= 2;
y *= 2;
}
s_mouseX = (float)x;
s_mouseY = (float)y;
s_mouseX /= eglView->getFrameZoomFactor();
s_mouseY /= eglView->getFrameZoomFactor();
if(s_captured)
{
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{
int id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
}
}
EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
void GLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
{
GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return;
EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setScrollData((float)x, -(float)y);
event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
void GLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{
if (GLFW_REPEAT != action)
{
EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->dispatchEvent(&event);
}
}
void GLViewEventHandler::onGLFWCharCallback(GLFWwindow *window, unsigned int character)
{
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
}
void GLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
{
Director::getInstance()->setViewport();
}
void GLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
{
auto view = Director::getInstance()->getOpenGLView();
float frameSizeW = view->getFrameSize().width;
float frameSizeH = view->getFrameSize().height;
float factorX = frameSizeW / w * view->getFrameZoomFactor();
float factorY = frameSizeH / h * view->getFrameZoomFactor();;
if (fabs(factorX - 0.5f) < FLT_EPSILON && fabs(factorY - 0.5f) < FLT_EPSILON )
{
view->_isRetina = true;
view->setFrameZoomFactor(2.0f * view->getFrameZoomFactor());
glfwSetWindowSize(window, static_cast<int>(frameSizeW * 0.5f * view->getFrameZoomFactor()) , static_cast<int>(frameSizeH * 0.5f * view->getFrameZoomFactor()));
}
else if(fabs(factorX - 2.0f) < FLT_EPSILON && fabs(factorY - 2.0f) < FLT_EPSILON)
{
view->_isRetina = false;
view->setFrameZoomFactor(0.5f * view->getFrameZoomFactor());
glfwSetWindowSize(window, static_cast<int>(frameSizeW * view->getFrameZoomFactor()), static_cast<int>(frameSizeH * view->getFrameZoomFactor()));
}
}
void GLViewEventHandler::OnGLFWWindowSizeFunCallback(GLFWwindow *windows, int width, int height)
{
auto view = Director::getInstance()->getOpenGLView();
if(view && view->getResolutionPolicy() != ResolutionPolicy::UNKNOWN)
{
Size resSize=view->getDesignResolutionSize();
ResolutionPolicy resPolicy=view->getResolutionPolicy();
view->setFrameSize(width, height);
view->setDesignResolutionSize(resSize.width, resSize.height, resPolicy);
Director::getInstance()->setViewport();
}
}
//end GLViewEventHandler
//////////////////////////////////////////////////////////////////////////
// implement GLView
//////////////////////////////////////////////////////////////////////////
GLView::GLView()
: _captured(false)
, _supportTouch(false)
, _isInRetinaMonitor(false)
, _isRetinaEnabled(false)
, _retinaFactor(1)
, _frameZoomFactor(1.0f)
, _mainWindow(nullptr)
, _primaryMonitor(nullptr)
, _mouseX(0.0f)
, _mouseY(0.0f)
{
_viewName = "cocos2dx";
g_keyCodeMap.clear();
for (auto& item : g_keyCodeStructArray)
{
g_keyCodeMap[item.glfwKeyCode] = item.keyCode;
}
GLFWEventHandler::setGLView(this);
glfwSetErrorCallback(GLFWEventHandler::onGLFWError);
glfwInit();
}
GLView::~GLView()
{
CCLOGINFO("deallocing GLView: %p", this);
GLFWEventHandler::setGLView(nullptr);
glfwTerminate();
}
GLView* GLView::create(const std::string& viewName)
{
auto ret = new GLView;
@ -388,68 +317,35 @@ GLView* GLView::createWithFullScreen(const std::string& viewName)
return nullptr;
}
GLView::GLView()
: _captured(false)
, _frameZoomFactor(1.0f)
, _supportTouch(false)
, _isRetina(false)
, _mainWindow(nullptr)
, _primaryMonitor(nullptr)
{
_viewName = "cocos2dx";
g_keyCodeMap.clear();
for (auto& item : g_keyCodeStructArray)
{
g_keyCodeMap[item.glfwKeyCode] = item.keyCode;
}
glfwSetErrorCallback(GLViewEventHandler::onGLFWError);
glfwInit();
}
GLView::~GLView()
{
CCLOGINFO("deallocing GLView: %p", this);
glfwTerminate();
}
bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
setViewName(viewName);
setFrameSize(rect.size.width, rect.size.height);
setFrameZoomFactor(frameZoomFactor);
_frameZoomFactor = frameZoomFactor;
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor,
_screenSize.height * _frameZoomFactor,
_mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor,
rect.size.height * _frameZoomFactor,
_viewName.c_str(),
_primaryMonitor,
NULL);
nullptr);
glfwMakeContextCurrent(_mainWindow);
int w, h;
glfwGetWindowSize(_mainWindow, &w, &h);
int frameBufferW, frameBufferH;
glfwGetFramebufferSize(_mainWindow, &frameBufferW, &frameBufferH);
if (frameBufferW == 2 * w && frameBufferH == 2 * h)
{
_isRetina = true;
setFrameZoomFactor(frameZoomFactor * 2);
glfwSetWindowSize(_mainWindow, rect.size.width/2 * _frameZoomFactor, rect.size.height/2 * _frameZoomFactor);
}
glfwSetMouseButtonCallback(_mainWindow, GLViewEventHandler::onGLFWMouseCallBack);
glfwSetCursorPosCallback(_mainWindow, GLViewEventHandler::onGLFWMouseMoveCallBack);
glfwSetScrollCallback(_mainWindow, GLViewEventHandler::onGLFWMouseScrollCallback);
glfwSetCharCallback(_mainWindow, GLViewEventHandler::onGLFWCharCallback);
glfwSetKeyCallback(_mainWindow, GLViewEventHandler::onGLFWKeyCallback);
glfwSetWindowPosCallback(_mainWindow, GLViewEventHandler::onGLFWWindowPosCallback);
glfwSetFramebufferSizeCallback(_mainWindow, GLViewEventHandler::onGLFWframebuffersize);
glfwSetWindowSizeCallback(_mainWindow, GLViewEventHandler::OnGLFWWindowSizeFunCallback);
glfwSetMouseButtonCallback(_mainWindow, GLFWEventHandler::onGLFWMouseCallBack);
glfwSetCursorPosCallback(_mainWindow, GLFWEventHandler::onGLFWMouseMoveCallBack);
glfwSetScrollCallback(_mainWindow, GLFWEventHandler::onGLFWMouseScrollCallback);
glfwSetCharCallback(_mainWindow, GLFWEventHandler::onGLFWCharCallback);
glfwSetKeyCallback(_mainWindow, GLFWEventHandler::onGLFWKeyCallback);
glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback);
glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize);
glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback);
setFrameSize(rect.size.width, rect.size.height);
// check OpenGL version at first
const GLubyte* glVersion = glGetString(GL_VERSION);
if ( atof((const char*)glVersion) < 1.5 )
{
char strComplain[256] = {0};
@ -459,12 +355,12 @@ bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoo
MessageBox(strComplain, "OpenGL version too old");
return false;
}
initGlew();
// Enable point size by default.
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
return true;
}
@ -473,7 +369,7 @@ bool GLView::initWithFullScreen(const std::string& viewName)
_primaryMonitor = glfwGetPrimaryMonitor();
if (nullptr == _primaryMonitor)
return false;
const GLFWvidmode* videoMode = glfwGetVideoMode(_primaryMonitor);
return initWithRect(viewName, Rect(0, 0, videoMode->width, videoMode->height), 1.0f);
}
@ -490,7 +386,7 @@ void GLView::end()
glfwSetWindowShouldClose(_mainWindow,1);
_mainWindow = nullptr;
}
}
void GLView::swapBuffers()
@ -512,15 +408,40 @@ void GLView::pollEvents()
glfwPollEvents();
}
void GLView::enableRetina(bool enabled)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
_isRetinaEnabled = enabled;
if (_isRetinaEnabled)
{
_retinaFactor = 1;
}
else
{
_retinaFactor = 2;
}
updateFrameSize();
#endif
}
void GLView::setIMEKeyboardState(bool /*bOpen*/)
{
}
void GLView::setFrameZoomFactor(float zoomFactor)
{
CCASSERT(zoomFactor > 0.0f, "zoomFactor must be larger than 0");
if (fabs(_frameZoomFactor - zoomFactor) < FLT_EPSILON)
{
return;
}
_frameZoomFactor = zoomFactor;
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
updateFrameSize();
}
float GLView::getFrameZoomFactor()
@ -528,88 +449,272 @@ float GLView::getFrameZoomFactor()
return _frameZoomFactor;
}
void GLView::updateFrameSize()
{
if (_screenSize.width > 0 && _screenSize.height > 0)
{
int w = 0, h = 0;
glfwGetWindowSize(_mainWindow, &w, &h);
int frameBufferW = 0, frameBufferH = 0;
glfwGetFramebufferSize(_mainWindow, &frameBufferW, &frameBufferH);
if (frameBufferW == 2 * w && frameBufferH == 2 * h)
{
if (_isRetinaEnabled)
{
_retinaFactor = 1;
}
else
{
_retinaFactor = 2;
}
glfwSetWindowSize(_mainWindow, _screenSize.width/2 * _retinaFactor * _frameZoomFactor, _screenSize.height/2 * _retinaFactor * _frameZoomFactor);
_isInRetinaMonitor = true;
}
else
{
if (_isInRetinaMonitor)
{
_retinaFactor = 1;
}
glfwSetWindowSize(_mainWindow, _screenSize.width * _retinaFactor * _frameZoomFactor, _screenSize.height *_retinaFactor * _frameZoomFactor);
_isInRetinaMonitor = false;
}
}
}
void GLView::setFrameSize(float width, float height)
{
GLViewProtocol::setFrameSize(width, height);
updateFrameSize();
}
void GLView::setViewPortInPoints(float x , float y , float w , float h)
{
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
glViewport((GLint)(x * _scaleX * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.x * _retinaFactor * _frameZoomFactor),
(GLint)(y * _scaleY * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.y * _retinaFactor * _frameZoomFactor),
(GLsizei)(w * _scaleX * _retinaFactor * _frameZoomFactor),
(GLsizei)(h * _scaleY * _retinaFactor * _frameZoomFactor));
}
void GLView::setScissorInPoints(float x , float y , float w , float h)
{
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
glScissor((GLint)(x * _scaleX * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.x * _retinaFactor * _frameZoomFactor),
(GLint)(y * _scaleY * _retinaFactor * _frameZoomFactor + _viewPortRect.origin.y * _retinaFactor * _frameZoomFactor),
(GLsizei)(w * _scaleX * _retinaFactor * _frameZoomFactor),
(GLsizei)(h * _scaleY * _retinaFactor * _frameZoomFactor));
}
void GLView::onGLFWError(int errorID, const char* errorDesc)
{
CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc);
}
void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{
if(GLFW_MOUSE_BUTTON_LEFT == button)
{
if(GLFW_PRESS == action)
{
_captured = true;
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX,_mouseY)))
{
int id = 0;
this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);
}
}
else if(GLFW_RELEASE == action)
{
_captured = false;
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX,_mouseY)))
{
int id = 0;
this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY);
}
}
}
if(GLFW_PRESS == action)
{
EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(_mouseX, this->getViewPortRect().size.height - _mouseY);
event.setMouseButton(button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
else if(GLFW_RELEASE == action)
{
EventMouse event(EventMouse::MouseEventType::MOUSE_UP);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(_mouseX, this->getViewPortRect().size.height - _mouseY);
event.setMouseButton(button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
}
void GLView::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
_mouseX = (float)x;
_mouseY = (float)y;
_mouseX /= this->getFrameZoomFactor();
_mouseY /= this->getFrameZoomFactor();
if (_isInRetinaMonitor)
{
if (_retinaFactor == 1)
{
_mouseX *= 2;
_mouseY *= 2;
}
}
if (_captured)
{
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX, _mouseY)))
{
int id = 0;
this->handleTouchesMove(1, &id, &_mouseX, &_mouseY);
}
}
EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setCursorPosition(_mouseX, this->getViewPortRect().size.height - _mouseY);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
void GLView::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
{
EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
event.setScrollData((float)x, -(float)y);
event.setCursorPosition(_mouseX, this->getViewPortRect().size.height - _mouseY);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
void GLView::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{
if (GLFW_REPEAT != action)
{
EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->dispatchEvent(&event);
}
}
void GLView::onGLFWCharCallback(GLFWwindow *window, unsigned int character)
{
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
}
void GLView::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
{
Director::getInstance()->setViewport();
}
void GLView::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
{
float frameSizeW = _screenSize.width;
float frameSizeH = _screenSize.height;
float factorX = frameSizeW / w * _retinaFactor * _frameZoomFactor;
float factorY = frameSizeH / h * _retinaFactor * _frameZoomFactor;
if (fabs(factorX - 0.5f) < FLT_EPSILON && fabs(factorY - 0.5f) < FLT_EPSILON )
{
_isInRetinaMonitor = true;
if (_isRetinaEnabled)
{
_retinaFactor = 1;
}
else
{
_retinaFactor = 2;
}
glfwSetWindowSize(window, static_cast<int>(frameSizeW * 0.5f * _retinaFactor * _frameZoomFactor) , static_cast<int>(frameSizeH * 0.5f * _retinaFactor * _frameZoomFactor));
}
else if(fabs(factorX - 2.0f) < FLT_EPSILON && fabs(factorY - 2.0f) < FLT_EPSILON)
{
_isInRetinaMonitor = false;
_retinaFactor = 1;
glfwSetWindowSize(window, static_cast<int>(frameSizeW * _retinaFactor * _frameZoomFactor), static_cast<int>(frameSizeH * _retinaFactor * _frameZoomFactor));
}
}
void GLView::onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height)
{
if (_resolutionPolicy != ResolutionPolicy::UNKNOWN)
{
updateDesignResolutionSize();
Director::getInstance()->setViewport();
}
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
static bool glew_dynamic_binding()
{
const char *gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
const char *gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
if (glGenFramebuffers == NULL)
{
log("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
if (strstr(gl_extensions, "ARB_framebuffer_object"))
{
log("OpenGL: ARB_framebuffer_object is supported");
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
if (glGenFramebuffers == NULL)
{
log("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
if (strstr(gl_extensions, "ARB_framebuffer_object"))
{
log("OpenGL: ARB_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffers");
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffers");
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorage");
glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameteriv");
glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebuffer");
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebuffer");
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffers");
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffers");
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatus");
glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1D");
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2D");
glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3D");
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbuffer");
glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameteriv");
glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmap");
}
else
if (strstr(gl_extensions, "EXT_framebuffer_object"))
{
log("OpenGL: EXT_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffersEXT");
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorageEXT");
glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameterivEXT");
glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebufferEXT");
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebufferEXT");
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffersEXT");
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffersEXT");
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1DEXT");
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3DEXT");
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmapEXT");
}
else
{
log("OpenGL: No framebuffers extension is supported");
log("OpenGL: Any call to Fbo will crash!");
return false;
}
}
return true;
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffers");
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffers");
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorage");
glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameteriv");
glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebuffer");
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebuffer");
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffers");
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffers");
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatus");
glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1D");
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2D");
glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3D");
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbuffer");
glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameteriv");
glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmap");
}
else
if (strstr(gl_extensions, "EXT_framebuffer_object"))
{
log("OpenGL: EXT_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffersEXT");
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorageEXT");
glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameterivEXT");
glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebufferEXT");
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebufferEXT");
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffersEXT");
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffersEXT");
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1DEXT");
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3DEXT");
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmapEXT");
}
else
{
log("OpenGL: No framebuffers extension is supported");
log("OpenGL: Any call to Fbo will crash!");
return false;
}
}
return true;
}
#endif
@ -647,7 +752,7 @@ bool GLView::initGlew()
{
MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
return false;
}
}
#endif
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)

View File

@ -45,7 +45,7 @@ public:
*/
//void resize(int width, int height);
float getFrameZoomFactor();
//void centerWindow();
@ -64,6 +64,18 @@ public:
virtual void setFrameSize(float width, float height) override;
virtual void setIMEKeyboardState(bool bOpen) override;
/*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/
void setFrameZoomFactor(float zoomFactor);
/** Retina support is disabled by default
* @note This method is only available on Mac.
*/
void enableRetina(bool enabled);
/** Check whether retina display is enabled. */
bool isRetinaEnabled() { return _isRetinaEnabled; };
protected:
GLView();
virtual ~GLView();
@ -71,22 +83,36 @@ protected:
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
bool initWithFullScreen(const std::string& viewName);
/*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/
void setFrameZoomFactor(float zoomFactor);
bool initGlew();
inline bool isRetina() { return _isRetina; };
void updateFrameSize();
// GLFW callbacks
void onGLFWError(int errorID, const char* errorDesc);
void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify);
void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y);
void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
void onGLFWCharCallback(GLFWwindow* window, unsigned int character);
void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height);
bool _captured;
bool _supportTouch;
bool _isRetina;
bool _isInRetinaMonitor;
bool _isRetinaEnabled;
int _retinaFactor; // Should be 1 or 2
float _frameZoomFactor;
GLFWwindow* _mainWindow;
GLFWmonitor* _primaryMonitor;
friend class GLViewEventHandler;
float _mouseX;
float _mouseY;
friend class GLFWEventHandler;
private:
CC_DISALLOW_COPY_AND_ASSIGN(GLView);
@ -94,4 +120,4 @@ private:
NS_CC_END // end of namespace cocos2d
#endif // end of __CC_EGLVIEW_DESKTOP_H__
#endif // end of __CC_EGLVIEW_DESKTOP_H__

View File

@ -27,8 +27,10 @@ THE SOFTWARE.
#include "cocos2d.h"
#include "CocoStudio.h"
class cocos2d::EventDispatcher;
class cocos2d::EventListener;
namespace cocos2d {
class EventDispatcher;
class EventListener;
}
namespace cocostudio {

View File

@ -29,7 +29,9 @@ THE SOFTWARE.
#include "CocoStudio.h"
#include <vector>
class cocos2d::EventListenerCustom;
namespace cocos2d {
class EventListenerCustom;
}
namespace cocostudio {