Shared instance is now a pointer instead of a static instance. Also the CCEGLView::release notifies application about quit

This commit is contained in:
Giovanni Zito 2011-12-09 22:04:35 +01:00
parent 362a82f41c
commit af29be2d26
2 changed files with 406 additions and 392 deletions

View File

@ -25,6 +25,7 @@
#include "IwGL.h"
#include "CCApplication.h"
#include "CCDirector.h"
#include "CCSet.h"
#include "CCTouch.h"
@ -36,6 +37,9 @@
NS_CC_BEGIN;
CCEGLView* CCEGLView::m_pInstance = 0 ;
CCEGLView::CCEGLView()
: m_pDelegate(NULL)
, m_fScreenScaleFactor(1.0)
@ -182,9 +186,14 @@ void CCEGLView::release()
{
IW_CALLSTACK("CCEGLView::release");
s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler);
s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler);
s3eKeyboardUnRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler);
if (IwGLIsInitialised())
IwGLTerminate();
s3eDeviceRequestQuit() ;
}
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)
@ -253,8 +262,10 @@ void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
CCEGLView& CCEGLView::sharedOpenGLView()
{
static CCEGLView instance;
return instance;
if( !m_pInstance ) {
m_pInstance = new CCEGLView() ;
}
return *m_pInstance;
}
float CCEGLView::getScreenScaleFactor()
@ -275,4 +286,5 @@ CCRect CCEGLView::getViewPort()
}
}
NS_CC_END;

View File

@ -88,6 +88,8 @@ private:
CCSet * m_pSet;
CCTouch * m_pTouch;
static CCEGLView* m_pInstance ;
void setTouch(void* systemData);
void setMotionTouch(void* systemData);
void setKeyTouch(void* systemData);