mirror of https://github.com/axmolengine/axmol.git
Shared instance is now a pointer instead of a static instance. Also the CCEGLView::release notifies application about quit
This commit is contained in:
parent
362a82f41c
commit
af29be2d26
|
@ -1,278 +1,290 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
|
||||
Copyright (c) 2011 Максим Аксенов
|
||||
|
||||
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 "CCEGLView.h"
|
||||
|
||||
#include "IwGL.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCSet.h"
|
||||
#include "CCTouch.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "CCKeypadDispatcher.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
CCEGLView::CCEGLView()
|
||||
: m_pDelegate(NULL)
|
||||
, m_fScreenScaleFactor(1.0)
|
||||
, m_bNotHVGA(false)
|
||||
|
||||
, m_bCaptured(false)
|
||||
, m_bAccelState(false)
|
||||
, m_Key(s3eKeyFirst)
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::CCEGLView");
|
||||
|
||||
|
||||
IwGLInit();
|
||||
|
||||
m_sSizeInPixel.width = IwGLGetInt(IW_GL_WIDTH);
|
||||
m_sSizeInPixel.height = IwGLGetInt(IW_GL_HEIGHT);
|
||||
|
||||
m_pSet = new CCSet;
|
||||
m_pTouch = new CCTouch;
|
||||
|
||||
// Register pointer touch button event handler
|
||||
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler, this);
|
||||
|
||||
// Register pointer motion button event handler
|
||||
s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, this);
|
||||
|
||||
// Register keyboard event handler
|
||||
s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler, this);
|
||||
}
|
||||
|
||||
void CCEGLView::setFrameWidthAndHeight(int width, int height)
|
||||
{
|
||||
m_sSizeInPixel.width = width;
|
||||
m_sSizeInPixel.height = height;
|
||||
}
|
||||
void CCEGLView::create(int width, int height)
|
||||
{
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_sSizeInPoint.width = width;
|
||||
m_sSizeInPoint.height = height;
|
||||
|
||||
// calculate the factor and the rect of viewport
|
||||
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
|
||||
(float)m_sSizeInPixel.height / m_sSizeInPoint.height);
|
||||
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
|
||||
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
|
||||
m_rcViewPort.origin.x = (m_sSizeInPixel.width - viewPortW) / 2;
|
||||
m_rcViewPort.origin.y = (m_sSizeInPixel.height - viewPortH) / 2;
|
||||
m_rcViewPort.size.width = viewPortW;
|
||||
m_rcViewPort.size.height = viewPortH;
|
||||
|
||||
m_bNotHVGA = true;
|
||||
|
||||
}
|
||||
CCEGLView::~CCEGLView()
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::~CCEGLView");
|
||||
|
||||
release();
|
||||
|
||||
CC_SAFE_DELETE(m_pDelegate);
|
||||
CC_SAFE_DELETE(m_pSet);
|
||||
CC_SAFE_DELETE(m_pTouch);
|
||||
|
||||
}
|
||||
|
||||
CCSize CCEGLView::getSize()
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
CCSize size(m_sSizeInPoint.width, m_sSizeInPoint.height);
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCSize size(m_sSizeInPixel.width, m_sSizeInPixel.height);
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
void CCEGLView::setTouch(void* systemData)
|
||||
{
|
||||
s3ePointerEvent* event =(s3ePointerEvent*)systemData;
|
||||
|
||||
switch (event->m_Pressed)
|
||||
{
|
||||
case S3E_POINTER_STATE_DOWN :
|
||||
m_bCaptured = true;
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pSet->addObject(m_pTouch);
|
||||
m_pDelegate->touchesBegan(m_pSet, NULL);
|
||||
break;
|
||||
|
||||
case S3E_POINTER_STATE_UP :
|
||||
if (m_bCaptured)
|
||||
{
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pDelegate->touchesEnded(m_pSet, NULL);
|
||||
m_pSet->removeObject(m_pTouch);
|
||||
m_bCaptured = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
void CCEGLView::setMotionTouch(void* systemData)
|
||||
{
|
||||
s3ePointerMotionEvent* event =(s3ePointerMotionEvent*)systemData;
|
||||
if (m_bCaptured)
|
||||
{
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pDelegate->touchesMoved(m_pSet, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
void CCEGLView::setKeyTouch(void* systemData)
|
||||
{
|
||||
s3eKeyboardEvent* event = (s3eKeyboardEvent*)systemData;
|
||||
if (event->m_Pressed)
|
||||
{
|
||||
if (event->m_Key!=m_Key)
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
||||
|
||||
}
|
||||
m_Key =event->m_Key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CCEGLView::isOpenGLReady()
|
||||
{
|
||||
return (IwGLIsInitialised() && m_sSizeInPixel.width != 0 && m_sSizeInPixel.height !=0);
|
||||
}
|
||||
|
||||
void CCEGLView::release()
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::release");
|
||||
|
||||
|
||||
if (IwGLIsInitialised())
|
||||
IwGLTerminate();
|
||||
}
|
||||
|
||||
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)
|
||||
{
|
||||
m_pDelegate = pDelegate;
|
||||
}
|
||||
|
||||
EGLTouchDelegate* CCEGLView::getDelegate(void)
|
||||
{
|
||||
return m_pDelegate;
|
||||
}
|
||||
|
||||
void CCEGLView::swapBuffers()
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::swapBuffers(");
|
||||
IwGLSwapBuffers();
|
||||
}
|
||||
|
||||
bool CCEGLView::canSetContentScaleFactor()
|
||||
{
|
||||
// can scale content?
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
||||
{
|
||||
m_fScreenScaleFactor = contentScaleFactor;
|
||||
}
|
||||
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||
glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||
(GLint)(y * factor) + m_rcViewPort.origin.y,
|
||||
(GLint)(w * factor),
|
||||
(GLint)(h * factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
glViewport((GLint)x,
|
||||
(GLint)y,
|
||||
(GLint)w,
|
||||
(GLint)h);
|
||||
}
|
||||
}
|
||||
|
||||
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||
(GLint)(y * factor) + m_rcViewPort.origin.y,
|
||||
(GLint)(w * factor),
|
||||
(GLint)(h * factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
glScissor((GLint)x,
|
||||
(GLint)y,
|
||||
(GLint)w,
|
||||
(GLint)h);
|
||||
}
|
||||
}
|
||||
|
||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
||||
{
|
||||
static CCEGLView instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
float CCEGLView::getScreenScaleFactor()
|
||||
{
|
||||
return m_fScreenScaleFactor;
|
||||
}
|
||||
|
||||
CCRect CCEGLView::getViewPort()
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
return m_rcViewPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCRect rect(0, 0, 0, 0);
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
/****************************************************************************
|
||||
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
|
||||
Copyright (c) 2011 Максим Аксенов
|
||||
|
||||
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 "CCEGLView.h"
|
||||
|
||||
#include "IwGL.h"
|
||||
|
||||
#include "CCApplication.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCSet.h"
|
||||
#include "CCTouch.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "CCKeypadDispatcher.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
CCEGLView* CCEGLView::m_pInstance = 0 ;
|
||||
|
||||
|
||||
CCEGLView::CCEGLView()
|
||||
: m_pDelegate(NULL)
|
||||
, m_fScreenScaleFactor(1.0)
|
||||
, m_bNotHVGA(false)
|
||||
|
||||
, m_bCaptured(false)
|
||||
, m_bAccelState(false)
|
||||
, m_Key(s3eKeyFirst)
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::CCEGLView");
|
||||
|
||||
|
||||
IwGLInit();
|
||||
|
||||
m_sSizeInPixel.width = IwGLGetInt(IW_GL_WIDTH);
|
||||
m_sSizeInPixel.height = IwGLGetInt(IW_GL_HEIGHT);
|
||||
|
||||
m_pSet = new CCSet;
|
||||
m_pTouch = new CCTouch;
|
||||
|
||||
// Register pointer touch button event handler
|
||||
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler, this);
|
||||
|
||||
// Register pointer motion button event handler
|
||||
s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, this);
|
||||
|
||||
// Register keyboard event handler
|
||||
s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler, this);
|
||||
}
|
||||
|
||||
void CCEGLView::setFrameWidthAndHeight(int width, int height)
|
||||
{
|
||||
m_sSizeInPixel.width = width;
|
||||
m_sSizeInPixel.height = height;
|
||||
}
|
||||
void CCEGLView::create(int width, int height)
|
||||
{
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_sSizeInPoint.width = width;
|
||||
m_sSizeInPoint.height = height;
|
||||
|
||||
// calculate the factor and the rect of viewport
|
||||
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
|
||||
(float)m_sSizeInPixel.height / m_sSizeInPoint.height);
|
||||
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
|
||||
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
|
||||
m_rcViewPort.origin.x = (m_sSizeInPixel.width - viewPortW) / 2;
|
||||
m_rcViewPort.origin.y = (m_sSizeInPixel.height - viewPortH) / 2;
|
||||
m_rcViewPort.size.width = viewPortW;
|
||||
m_rcViewPort.size.height = viewPortH;
|
||||
|
||||
m_bNotHVGA = true;
|
||||
|
||||
}
|
||||
CCEGLView::~CCEGLView()
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::~CCEGLView");
|
||||
|
||||
release();
|
||||
|
||||
CC_SAFE_DELETE(m_pDelegate);
|
||||
CC_SAFE_DELETE(m_pSet);
|
||||
CC_SAFE_DELETE(m_pTouch);
|
||||
|
||||
}
|
||||
|
||||
CCSize CCEGLView::getSize()
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
CCSize size(m_sSizeInPoint.width, m_sSizeInPoint.height);
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCSize size(m_sSizeInPixel.width, m_sSizeInPixel.height);
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
void CCEGLView::setTouch(void* systemData)
|
||||
{
|
||||
s3ePointerEvent* event =(s3ePointerEvent*)systemData;
|
||||
|
||||
switch (event->m_Pressed)
|
||||
{
|
||||
case S3E_POINTER_STATE_DOWN :
|
||||
m_bCaptured = true;
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pSet->addObject(m_pTouch);
|
||||
m_pDelegate->touchesBegan(m_pSet, NULL);
|
||||
break;
|
||||
|
||||
case S3E_POINTER_STATE_UP :
|
||||
if (m_bCaptured)
|
||||
{
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pDelegate->touchesEnded(m_pSet, NULL);
|
||||
m_pSet->removeObject(m_pTouch);
|
||||
m_bCaptured = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
void CCEGLView::setMotionTouch(void* systemData)
|
||||
{
|
||||
s3ePointerMotionEvent* event =(s3ePointerMotionEvent*)systemData;
|
||||
if (m_bCaptured)
|
||||
{
|
||||
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
|
||||
m_pDelegate->touchesMoved(m_pSet, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
void CCEGLView::setKeyTouch(void* systemData)
|
||||
{
|
||||
s3eKeyboardEvent* event = (s3eKeyboardEvent*)systemData;
|
||||
if (event->m_Pressed)
|
||||
{
|
||||
if (event->m_Key!=m_Key)
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
||||
|
||||
}
|
||||
m_Key =event->m_Key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CCEGLView::isOpenGLReady()
|
||||
{
|
||||
return (IwGLIsInitialised() && m_sSizeInPixel.width != 0 && m_sSizeInPixel.height !=0);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_pDelegate = pDelegate;
|
||||
}
|
||||
|
||||
EGLTouchDelegate* CCEGLView::getDelegate(void)
|
||||
{
|
||||
return m_pDelegate;
|
||||
}
|
||||
|
||||
void CCEGLView::swapBuffers()
|
||||
{
|
||||
IW_CALLSTACK("CCEGLView::swapBuffers(");
|
||||
IwGLSwapBuffers();
|
||||
}
|
||||
|
||||
bool CCEGLView::canSetContentScaleFactor()
|
||||
{
|
||||
// can scale content?
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
||||
{
|
||||
m_fScreenScaleFactor = contentScaleFactor;
|
||||
}
|
||||
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||
glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||
(GLint)(y * factor) + m_rcViewPort.origin.y,
|
||||
(GLint)(w * factor),
|
||||
(GLint)(h * factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
glViewport((GLint)x,
|
||||
(GLint)y,
|
||||
(GLint)w,
|
||||
(GLint)h);
|
||||
}
|
||||
}
|
||||
|
||||
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||
(GLint)(y * factor) + m_rcViewPort.origin.y,
|
||||
(GLint)(w * factor),
|
||||
(GLint)(h * factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
glScissor((GLint)x,
|
||||
(GLint)y,
|
||||
(GLint)w,
|
||||
(GLint)h);
|
||||
}
|
||||
}
|
||||
|
||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
||||
{
|
||||
if( !m_pInstance ) {
|
||||
m_pInstance = new CCEGLView() ;
|
||||
}
|
||||
return *m_pInstance;
|
||||
}
|
||||
|
||||
float CCEGLView::getScreenScaleFactor()
|
||||
{
|
||||
return m_fScreenScaleFactor;
|
||||
}
|
||||
|
||||
CCRect CCEGLView::getViewPort()
|
||||
{
|
||||
if (m_bNotHVGA)
|
||||
{
|
||||
return m_rcViewPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCRect rect(0, 0, 0, 0);
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_CC_END;
|
||||
|
|
|
@ -1,114 +1,116 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
|
||||
Copyright (c) 2011 Максим Аксенов
|
||||
|
||||
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_MARMALADE_H__
|
||||
#define __CC_EGLVIEW_MARMALADE_H__
|
||||
|
||||
#include "CCGeometry.h"
|
||||
#include "s3eKeyboard.h"
|
||||
#include "IwUtil.h"
|
||||
#include "IwUtilInitTerm.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
class CCSet;
|
||||
class CCTouch;
|
||||
class EGLTouchDelegate;
|
||||
class CCKeypadDelegate;
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
void 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();
|
||||
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static CCEGLView& sharedOpenGLView();
|
||||
|
||||
private:
|
||||
|
||||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
bool m_bNotHVGA;
|
||||
|
||||
EGLTouchDelegate *m_pDelegate;
|
||||
float m_fScreenScaleFactor;
|
||||
|
||||
bool m_bAccelState;
|
||||
bool m_bCaptured;
|
||||
s3eKey m_Key;
|
||||
CCSet * m_pSet;
|
||||
CCTouch * m_pTouch;
|
||||
|
||||
void setTouch(void* systemData);
|
||||
void setMotionTouch(void* systemData);
|
||||
void setKeyTouch(void* systemData);
|
||||
|
||||
static int32 TouchEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
static int32 MotionEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setMotionTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
static int32 KeyEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setKeyTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
#endif // end of __CC_EGLVIEW_MARMALADE_H__
|
||||
/****************************************************************************
|
||||
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
|
||||
Copyright (c) 2011 Максим Аксенов
|
||||
|
||||
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_MARMALADE_H__
|
||||
#define __CC_EGLVIEW_MARMALADE_H__
|
||||
|
||||
#include "CCGeometry.h"
|
||||
#include "s3eKeyboard.h"
|
||||
#include "IwUtil.h"
|
||||
#include "IwUtilInitTerm.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
class CCSet;
|
||||
class CCTouch;
|
||||
class EGLTouchDelegate;
|
||||
class CCKeypadDelegate;
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
void 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();
|
||||
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static CCEGLView& sharedOpenGLView();
|
||||
|
||||
private:
|
||||
|
||||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
bool m_bNotHVGA;
|
||||
|
||||
EGLTouchDelegate *m_pDelegate;
|
||||
float m_fScreenScaleFactor;
|
||||
|
||||
bool m_bAccelState;
|
||||
bool m_bCaptured;
|
||||
s3eKey m_Key;
|
||||
CCSet * m_pSet;
|
||||
CCTouch * m_pTouch;
|
||||
|
||||
static CCEGLView* m_pInstance ;
|
||||
|
||||
void setTouch(void* systemData);
|
||||
void setMotionTouch(void* systemData);
|
||||
void setKeyTouch(void* systemData);
|
||||
|
||||
static int32 TouchEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
static int32 MotionEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setMotionTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
static int32 KeyEventHandler(void* systemData, void* userData)
|
||||
{
|
||||
((CCEGLView*)userData)->setKeyTouch(systemData);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
#endif // end of __CC_EGLVIEW_MARMALADE_H__
|
||||
|
|
Loading…
Reference in New Issue