2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCEGLView.h"
|
2012-06-19 17:22:55 +08:00
|
|
|
#include "cocoa/CCSet.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "ccMacros.h"
|
|
|
|
#include "CCDirector.h"
|
2012-06-19 17:22:55 +08:00
|
|
|
#include "touch_dispatcher/CCTouch.h"
|
|
|
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
|
|
|
#include "text_input_node/CCIMEDispatcher.h"
|
|
|
|
#include "keypad_dispatcher/CCKeypadDispatcher.h"
|
2012-08-20 16:32:22 +08:00
|
|
|
#include "support/CCPointExtension.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCApplication.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-10-15 16:39:42 +08:00
|
|
|
// Windows Touch define
|
|
|
|
#define MOUSEEVENTF_FROMTOUCH 0xFF515700
|
|
|
|
|
|
|
|
// Windows Touch functions
|
|
|
|
// Workaround to be able tu run app on Windows XP
|
|
|
|
typedef WINUSERAPI BOOL (WINAPI *RegisterTouchWindowFn)(_In_ HWND hwnd, _In_ ULONG ulFlags);
|
|
|
|
typedef WINUSERAPI BOOL (WINAPI *UnregisterTouchWindowFn)(_In_ HWND hwnd);
|
|
|
|
typedef WINUSERAPI LPARAM (WINAPI *GetMessageExtraInfoFn)(VOID);
|
|
|
|
typedef WINUSERAPI BOOL (WINAPI *GetTouchInputInfoFn)(_In_ HTOUCHINPUT hTouchInput, _In_ UINT cInputs, __out_ecount(cInputs) PTOUCHINPUT pInputs, _In_ int cbSize);
|
|
|
|
typedef WINUSERAPI BOOL (WINAPI *CloseTouchInputHandleFn)(_In_ HTOUCHINPUT hTouchInput);
|
|
|
|
|
|
|
|
RegisterTouchWindowFn RegisterTouchWindowFunction = NULL;
|
|
|
|
UnregisterTouchWindowFn UnregisterTouchWindowFunction = NULL;
|
|
|
|
GetMessageExtraInfoFn GetMessageExtraInfoFunction = NULL;
|
|
|
|
GetTouchInputInfoFn GetTouchInputInfoFunction = NULL;
|
|
|
|
CloseTouchInputHandleFn CloseTouchInputHandleFunction = NULL;
|
|
|
|
|
|
|
|
bool CheckTouchSupport()
|
|
|
|
{
|
|
|
|
RegisterTouchWindowFunction = (RegisterTouchWindowFn)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "RegisterTouchWindow");
|
|
|
|
UnregisterTouchWindowFunction = (UnregisterTouchWindowFn)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "UnregisterTouchWindow");
|
|
|
|
GetMessageExtraInfoFunction = (GetMessageExtraInfoFn)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "GetMessageExtraInfo");
|
|
|
|
GetTouchInputInfoFunction = (GetTouchInputInfoFn)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "GetTouchInputInfo");
|
|
|
|
CloseTouchInputHandleFunction = (CloseTouchInputHandleFn)GetProcAddress(GetModuleHandle(TEXT("user32.dll")), "CloseTouchInputHandle");
|
|
|
|
|
|
|
|
return (RegisterTouchWindowFunction && UnregisterTouchWindowFunction && GetMessageExtraInfoFunction && GetTouchInputInfoFunction && CloseTouchInputHandleFunction);
|
|
|
|
}
|
|
|
|
|
2012-06-01 13:44:28 +08:00
|
|
|
static void SetupPixelFormat(HDC hDC)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
int pixelFormat;
|
|
|
|
|
|
|
|
PIXELFORMATDESCRIPTOR pfd =
|
2012-09-14 01:22:03 +08:00
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
sizeof(PIXELFORMATDESCRIPTOR), // size
|
|
|
|
1, // version
|
|
|
|
PFD_SUPPORT_OPENGL | // OpenGL window
|
|
|
|
PFD_DRAW_TO_WINDOW | // render to window
|
|
|
|
PFD_DOUBLEBUFFER, // support double-buffering
|
|
|
|
PFD_TYPE_RGBA, // color type
|
|
|
|
32, // prefered color depth
|
|
|
|
0, 0, 0, 0, 0, 0, // color bits (ignored)
|
|
|
|
0, // no alpha buffer
|
|
|
|
0, // alpha bits (ignored)
|
|
|
|
0, // no accumulation buffer
|
|
|
|
0, 0, 0, 0, // accum bits (ignored)
|
|
|
|
16, // depth buffer
|
|
|
|
0, // no stencil buffer
|
|
|
|
0, // no auxiliary buffers
|
|
|
|
PFD_MAIN_PLANE, // main layer
|
|
|
|
0, // reserved
|
|
|
|
0, 0, 0, // no layer, visible, damage masks
|
|
|
|
};
|
|
|
|
|
|
|
|
pixelFormat = ChoosePixelFormat(hDC, &pfd);
|
|
|
|
SetPixelFormat(hDC, pixelFormat, &pfd);
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-20 01:36:09 +08:00
|
|
|
bool glew_dynamic_binding()
|
2012-09-14 01:22:03 +08:00
|
|
|
{
|
|
|
|
const char *gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
|
|
|
|
|
2012-10-09 00:38:04 +08:00
|
|
|
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
|
2012-09-14 01:22:03 +08:00
|
|
|
if (glGenFramebuffers == NULL)
|
|
|
|
{
|
|
|
|
CCLog("OpenGL: glGenFramebuffers is NULL, try to detect an extension\n");
|
|
|
|
if (strstr(gl_extensions, "ARB_framebuffer_object"))
|
|
|
|
{
|
|
|
|
CCLog("OpenGL: ARB_framebuffer_object is supported\n");
|
|
|
|
|
|
|
|
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"))
|
|
|
|
{
|
2012-09-20 01:36:09 +08:00
|
|
|
CCLog("OpenGL: EXT_framebuffer_object is supported\n");
|
2012-09-14 01:22:03 +08:00
|
|
|
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
|
|
|
|
{
|
|
|
|
CCLog("OpenGL: No framebuffers extension is supported\n");
|
|
|
|
CCLog("OpenGL: Any call to Fbo will crash!\n");
|
2012-09-20 01:36:09 +08:00
|
|
|
return false;
|
2012-09-14 01:22:03 +08:00
|
|
|
}
|
|
|
|
}
|
2012-09-20 01:36:09 +08:00
|
|
|
return true;
|
2012-09-14 01:22:03 +08:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// impliment CCEGLView
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2012-05-02 17:50:26 +08:00
|
|
|
static CCEGLView* s_pMainWindow = NULL;
|
2012-06-01 13:44:28 +08:00
|
|
|
static const WCHAR* kWindowClassName = L"Cocos2dxWin32";
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (s_pMainWindow && s_pMainWindow->getHWnd() == hWnd)
|
|
|
|
{
|
|
|
|
return s_pMainWindow->WindowProc(uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCEGLView::CCEGLView()
|
|
|
|
: m_bCaptured(false)
|
|
|
|
, m_hWnd(NULL)
|
2012-06-01 13:44:28 +08:00
|
|
|
, m_hDC(NULL)
|
|
|
|
, m_hRC(NULL)
|
2012-04-19 14:35:52 +08:00
|
|
|
, m_lpfnAccelerometerKeyHook(NULL)
|
2012-09-02 04:38:52 +08:00
|
|
|
, m_menu(NULL)
|
|
|
|
, m_wndproc(NULL)
|
2012-09-03 00:58:42 +08:00
|
|
|
, m_windowWidth(0)
|
|
|
|
, m_windowHeight(0)
|
|
|
|
, m_windowTouchScaleX(1.0f)
|
|
|
|
, m_windowTouchScaleY(1.0f)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-08-09 12:49:33 +08:00
|
|
|
strcpy(m_szViewName, "Cocos2dxWin32");
|
2012-10-15 16:39:42 +08:00
|
|
|
m_Touch = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCEGLView::~CCEGLView()
|
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCEGLView::initGL()
|
|
|
|
{
|
|
|
|
m_hDC = GetDC(m_hWnd);
|
|
|
|
SetupPixelFormat(m_hDC);
|
|
|
|
//SetupPalette();
|
|
|
|
m_hRC = wglCreateContext(m_hDC);
|
|
|
|
wglMakeCurrent(m_hDC, m_hRC);
|
|
|
|
|
2012-09-13 15:52:46 +08:00
|
|
|
// check OpenGL version at first
|
2012-09-13 15:53:57 +08:00
|
|
|
const GLubyte* glVersion = glGetString(GL_VERSION);
|
|
|
|
CCLOG("OpenGL version = %s", glVersion);
|
|
|
|
|
|
|
|
if ( atof((const char*)glVersion) < 1.5 )
|
|
|
|
{
|
|
|
|
char strComplain[256] = {0};
|
2012-09-14 01:22:03 +08:00
|
|
|
sprintf(strComplain,
|
2012-09-20 01:36:09 +08:00
|
|
|
"OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.",
|
2012-09-13 15:53:57 +08:00
|
|
|
glVersion);
|
2012-09-20 01:36:09 +08:00
|
|
|
CCMessageBox(strComplain, "OpenGL version too old");
|
|
|
|
return false;
|
2012-09-13 15:53:57 +08:00
|
|
|
}
|
2012-09-13 15:52:46 +08:00
|
|
|
|
2012-06-01 13:44:28 +08:00
|
|
|
GLenum GlewInitResult = glewInit();
|
2012-09-14 01:22:03 +08:00
|
|
|
if (GLEW_OK != GlewInitResult)
|
2012-06-01 13:44:28 +08:00
|
|
|
{
|
2012-09-20 01:36:09 +08:00
|
|
|
CCMessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error");
|
2012-06-01 13:44:28 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
|
|
|
|
{
|
2012-09-13 02:17:56 +08:00
|
|
|
CCLog("Ready for GLSL");
|
2012-06-01 13:44:28 +08:00
|
|
|
}
|
2012-09-14 01:22:03 +08:00
|
|
|
else
|
2012-06-01 13:44:28 +08:00
|
|
|
{
|
2012-09-13 02:17:56 +08:00
|
|
|
CCLog("Not totally ready :(");
|
2012-06-01 13:44:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (glewIsSupported("GL_VERSION_2_0"))
|
|
|
|
{
|
2012-09-13 02:17:56 +08:00
|
|
|
CCLog("Ready for OpenGL 2.0");
|
2012-06-01 13:44:28 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-13 02:17:56 +08:00
|
|
|
CCLog("OpenGL 2.0 not supported");
|
2012-06-01 13:44:28 +08:00
|
|
|
}
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-09-20 01:36:09 +08:00
|
|
|
if(glew_dynamic_binding() == false)
|
|
|
|
{
|
|
|
|
CCMessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-06-01 13:44:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::destroyGL()
|
|
|
|
{
|
|
|
|
if (m_hDC != NULL && m_hRC != NULL)
|
|
|
|
{
|
|
|
|
// deselect rendering context and delete it
|
|
|
|
wglMakeCurrent(m_hDC, NULL);
|
|
|
|
wglDeleteContext(m_hRC);
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-10-09 00:38:04 +08:00
|
|
|
bool CCEGLView::Create()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
bool bRet = false;
|
2012-09-14 01:22:03 +08:00
|
|
|
do
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CC_BREAK_IF(m_hWnd);
|
|
|
|
|
|
|
|
HINSTANCE hInstance = GetModuleHandle( NULL );
|
|
|
|
WNDCLASS wc; // Windows Class Structure
|
|
|
|
|
|
|
|
// Redraw On Size, And Own DC For Window.
|
2012-09-14 01:22:03 +08:00
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
2012-04-19 14:35:52 +08:00
|
|
|
wc.lpfnWndProc = _WindowProc; // WndProc Handles Messages
|
|
|
|
wc.cbClsExtra = 0; // No Extra Window Data
|
|
|
|
wc.cbWndExtra = 0; // No Extra Window Data
|
|
|
|
wc.hInstance = hInstance; // Set The Instance
|
|
|
|
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon
|
|
|
|
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer
|
|
|
|
wc.hbrBackground = NULL; // No Background Required For GL
|
2012-09-14 01:22:03 +08:00
|
|
|
wc.lpszMenuName = m_menu; //
|
2012-04-19 14:35:52 +08:00
|
|
|
wc.lpszClassName = kWindowClassName; // Set The Class Name
|
|
|
|
|
2012-09-14 01:22:03 +08:00
|
|
|
CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// center window position
|
|
|
|
RECT rcDesktop;
|
|
|
|
GetWindowRect(GetDesktopWindow(), &rcDesktop);
|
|
|
|
|
2012-06-01 13:44:28 +08:00
|
|
|
WCHAR wszBuf[50] = {0};
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf));
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// create window
|
|
|
|
m_hWnd = CreateWindowEx(
|
|
|
|
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
|
|
|
|
kWindowClassName, // Class Name
|
2012-06-01 13:44:28 +08:00
|
|
|
wszBuf, // Window Title
|
2012-04-19 14:35:52 +08:00
|
|
|
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style
|
|
|
|
0, 0, // Window Position
|
|
|
|
0, // Window Width
|
|
|
|
0, // Window Height
|
|
|
|
NULL, // No Parent Window
|
|
|
|
NULL, // No Menu
|
|
|
|
hInstance, // Instance
|
|
|
|
NULL );
|
|
|
|
|
|
|
|
CC_BREAK_IF(! m_hWnd);
|
|
|
|
|
2012-06-01 13:44:28 +08:00
|
|
|
bRet = initGL();
|
2012-09-20 01:36:09 +08:00
|
|
|
if(!bRet) destroyGL();
|
2012-06-01 13:44:28 +08:00
|
|
|
CC_BREAK_IF(!bRet);
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
s_pMainWindow = this;
|
|
|
|
bRet = true;
|
|
|
|
} while (0);
|
|
|
|
|
2012-10-15 16:39:42 +08:00
|
|
|
m_Touch = CheckTouchSupport();
|
|
|
|
if(m_Touch) m_Touch = (RegisterTouchWindowFunction(m_hWnd, 0) != 0);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2012-09-02 04:38:52 +08:00
|
|
|
BOOL bProcessed = FALSE;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
2012-10-15 16:39:42 +08:00
|
|
|
// Don't process message generated by Windows Touch
|
|
|
|
if (m_Touch && (GetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
|
|
|
|
|
2012-04-20 15:23:00 +08:00
|
|
|
if (m_pDelegate && MK_LBUTTON == wParam)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-04-23 14:30:38 +08:00
|
|
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
2012-08-30 10:43:54 +08:00
|
|
|
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
2012-08-20 16:32:22 +08:00
|
|
|
CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
|
2012-08-20 17:08:29 +08:00
|
|
|
if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
m_bCaptured = true;
|
|
|
|
SetCapture(m_hWnd);
|
2012-04-20 15:23:00 +08:00
|
|
|
int id = 0;
|
2012-09-03 00:58:42 +08:00
|
|
|
pt.x *= m_windowTouchScaleX;
|
|
|
|
pt.y *= m_windowTouchScaleY;
|
2012-04-20 15:23:00 +08:00
|
|
|
handleTouchesBegin(1, &id, &pt.x, &pt.y);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
2012-10-15 16:39:42 +08:00
|
|
|
// Don't process message generated by Windows Touch
|
|
|
|
if (m_Touch && (GetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (MK_LBUTTON == wParam && m_bCaptured)
|
|
|
|
{
|
2012-04-23 14:30:38 +08:00
|
|
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
2012-08-30 10:43:54 +08:00
|
|
|
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
2012-04-20 15:23:00 +08:00
|
|
|
int id = 0;
|
2012-09-03 00:58:42 +08:00
|
|
|
pt.x *= m_windowTouchScaleX;
|
|
|
|
pt.y *= m_windowTouchScaleY;
|
2012-04-20 15:23:00 +08:00
|
|
|
handleTouchesMove(1, &id, &pt.x, &pt.y);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
2012-10-15 16:39:42 +08:00
|
|
|
// Don't process message generated by Windows Touch
|
|
|
|
if (m_Touch && (GetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (m_bCaptured)
|
|
|
|
{
|
2012-04-23 14:30:38 +08:00
|
|
|
POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
|
2012-08-30 10:43:54 +08:00
|
|
|
CCPoint pt(point.x/CC_CONTENT_SCALE_FACTOR(), point.y/CC_CONTENT_SCALE_FACTOR());
|
2012-04-20 15:23:00 +08:00
|
|
|
int id = 0;
|
2012-09-03 00:58:42 +08:00
|
|
|
pt.x *= m_windowTouchScaleX;
|
|
|
|
pt.y *= m_windowTouchScaleY;
|
2012-04-20 15:23:00 +08:00
|
|
|
handleTouchesEnd(1, &id, &pt.x, &pt.y);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
ReleaseCapture();
|
|
|
|
m_bCaptured = false;
|
|
|
|
}
|
|
|
|
break;
|
2012-10-15 16:39:42 +08:00
|
|
|
|
|
|
|
case WM_TOUCH:
|
|
|
|
{
|
|
|
|
BOOL bHandled = FALSE;
|
|
|
|
UINT cInputs = LOWORD(wParam);
|
|
|
|
PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
|
|
|
|
if (pInputs)
|
|
|
|
{
|
|
|
|
if (GetTouchInputInfoFunction((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT)))
|
|
|
|
{
|
|
|
|
for (UINT i=0; i < cInputs; i++)
|
|
|
|
{
|
|
|
|
TOUCHINPUT ti = pInputs[i];
|
|
|
|
CCPoint pt(TOUCH_COORD_TO_PIXEL(ti.x)/CC_CONTENT_SCALE_FACTOR(), TOUCH_COORD_TO_PIXEL(ti.y)/CC_CONTENT_SCALE_FACTOR());
|
|
|
|
CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
|
|
|
|
if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp))
|
|
|
|
{
|
|
|
|
pt.x *= m_windowTouchScaleX;
|
|
|
|
pt.y *= m_windowTouchScaleY;
|
|
|
|
|
|
|
|
if((ti.dwFlags & TOUCHEVENTF_DOWN)!=0)
|
|
|
|
handleTouchesBegin(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y);
|
|
|
|
else if((ti.dwFlags & TOUCHEVENTF_MOVE)!=0)
|
|
|
|
handleTouchesMove(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y);
|
|
|
|
else if((ti.dwFlags & TOUCHEVENTF_UP)!=0)
|
|
|
|
handleTouchesEnd(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bHandled = TRUE;
|
|
|
|
}
|
|
|
|
delete [] pInputs;
|
|
|
|
}
|
|
|
|
if (bHandled) CloseTouchInputHandleFunction((HTOUCHINPUT)lParam);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
case WM_SIZE:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case SIZE_RESTORED:
|
2012-08-21 17:25:03 +08:00
|
|
|
CCApplication::sharedApplication()->applicationWillEnterForeground();
|
2012-04-19 14:35:52 +08:00
|
|
|
break;
|
|
|
|
case SIZE_MINIMIZED:
|
2012-08-21 17:25:03 +08:00
|
|
|
CCApplication::sharedApplication()->applicationDidEnterBackground();
|
2012-04-19 14:35:52 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
if (wParam == VK_F1 || wParam == VK_F2)
|
|
|
|
{
|
|
|
|
CCDirector* pDirector = CCDirector::sharedDirector();
|
|
|
|
if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
|
|
|
|
pDirector->getKeypadDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked);
|
|
|
|
}
|
2012-10-09 00:46:19 +08:00
|
|
|
else if (wParam == VK_ESCAPE)
|
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
|
|
|
{
|
|
|
|
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KEYUP:
|
|
|
|
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
|
|
|
{
|
|
|
|
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CHAR:
|
|
|
|
{
|
|
|
|
if (wParam < 0x20)
|
|
|
|
{
|
|
|
|
if (VK_BACK == wParam)
|
|
|
|
{
|
|
|
|
CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
|
|
|
|
}
|
|
|
|
else if (VK_RETURN == wParam)
|
|
|
|
{
|
|
|
|
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
|
|
|
|
}
|
|
|
|
else if (VK_TAB == wParam)
|
|
|
|
{
|
|
|
|
// tab input
|
|
|
|
}
|
|
|
|
else if (VK_ESCAPE == wParam)
|
|
|
|
{
|
|
|
|
// ESC input
|
2012-09-02 04:38:52 +08:00
|
|
|
//CCDirector::sharedDirector()->end();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (wParam < 128)
|
|
|
|
{
|
|
|
|
// ascii char
|
|
|
|
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&wParam, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char szUtf8[8] = {0};
|
|
|
|
int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL);
|
|
|
|
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
|
|
|
|
}
|
|
|
|
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
|
|
|
{
|
|
|
|
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
2012-06-01 13:44:28 +08:00
|
|
|
PAINTSTRUCT ps;
|
2012-04-19 14:35:52 +08:00
|
|
|
BeginPaint(m_hWnd, &ps);
|
|
|
|
EndPaint(m_hWnd, &ps);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
CCDirector::sharedDirector()->end();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2012-06-01 13:44:28 +08:00
|
|
|
destroyGL();
|
2012-04-19 14:35:52 +08:00
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-09-02 04:38:52 +08:00
|
|
|
if (m_wndproc)
|
|
|
|
{
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-09-02 04:38:52 +08:00
|
|
|
m_wndproc(message, wParam, lParam, &bProcessed);
|
|
|
|
if (bProcessed) break;
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
return DefWindowProc(m_hWnd, message, wParam, lParam);
|
|
|
|
}
|
2012-09-02 04:38:52 +08:00
|
|
|
|
|
|
|
if (m_wndproc && !bProcessed)
|
|
|
|
{
|
|
|
|
m_wndproc(message, wParam, lParam, &bProcessed);
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelerometerKeyHook )
|
|
|
|
{
|
|
|
|
m_lpfnAccelerometerKeyHook=lpfnAccelerometerKeyHook;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCEGLView::isOpenGLReady()
|
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
return (m_hDC != NULL && m_hRC != NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-04-20 15:23:00 +08:00
|
|
|
void CCEGLView::end()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
if (m_hWnd)
|
|
|
|
{
|
2012-10-15 16:39:42 +08:00
|
|
|
if(m_Touch) UnregisterTouchWindowFunction(m_hWnd);
|
2012-04-19 14:35:52 +08:00
|
|
|
DestroyWindow(m_hWnd);
|
|
|
|
m_hWnd = NULL;
|
|
|
|
}
|
|
|
|
s_pMainWindow = NULL;
|
|
|
|
UnregisterClass(kWindowClassName, GetModuleHandle(NULL));
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::swapBuffers()
|
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
if (m_hDC != NULL)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-01 13:44:28 +08:00
|
|
|
::SwapBuffers(m_hDC);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCEGLView::setIMEKeyboardState(bool /*bOpen*/)
|
|
|
|
{
|
2012-04-20 15:23:00 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-08-24 18:01:16 +08:00
|
|
|
bool CCEGLView::enableRetina()
|
|
|
|
{
|
2012-08-30 10:43:54 +08:00
|
|
|
m_bIsRetinaEnabled = true;
|
2012-08-24 18:01:16 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-02 04:38:52 +08:00
|
|
|
void CCEGLView::setMenuResource(LPCWSTR menu)
|
|
|
|
{
|
|
|
|
m_menu = menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::setWndProc(CUSTOM_WND_PROC proc)
|
|
|
|
{
|
|
|
|
m_wndproc = proc;
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
HWND CCEGLView::getHWnd()
|
|
|
|
{
|
|
|
|
return m_hWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::resize(int width, int height)
|
|
|
|
{
|
|
|
|
if (! m_hWnd)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-03 00:58:42 +08:00
|
|
|
RECT rcWindow;
|
|
|
|
GetWindowRect(m_hWnd, &rcWindow);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
RECT rcClient;
|
|
|
|
GetClientRect(m_hWnd, &rcClient);
|
2012-09-03 00:58:42 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// calculate new window width and height
|
2012-09-03 00:58:42 +08:00
|
|
|
POINT ptDiff;
|
|
|
|
ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
|
|
|
|
ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
|
2012-04-19 14:35:52 +08:00
|
|
|
rcClient.right = rcClient.left + width;
|
|
|
|
rcClient.bottom = rcClient.top + height;
|
2012-09-03 00:58:42 +08:00
|
|
|
|
|
|
|
m_windowWidth = width;
|
|
|
|
m_windowHeight = height;
|
|
|
|
const CCSize& frameSize = getFrameSize();
|
|
|
|
if (frameSize.width > 0)
|
|
|
|
{
|
|
|
|
m_windowTouchScaleX = frameSize.width / width;
|
|
|
|
m_windowTouchScaleY = frameSize.height / height;
|
|
|
|
|
2012-10-09 16:58:56 +08:00
|
|
|
#ifdef _DEBUG
|
2012-09-03 00:58:42 +08:00
|
|
|
TCHAR buff[MAX_PATH + 1];
|
|
|
|
memset(buff, 0, sizeof(buff));
|
2012-10-09 16:58:56 +08:00
|
|
|
swprintf_s(buff, MAX_PATH, L"%S - %0.0fx%0.0f - %0.2f",
|
|
|
|
m_szViewName, frameSize.width, frameSize.height, 1.0f / m_windowTouchScaleX);
|
|
|
|
|
2012-09-03 00:58:42 +08:00
|
|
|
SetWindowText(m_hWnd, buff);
|
2012-10-09 16:58:56 +08:00
|
|
|
#endif
|
2012-09-03 00:58:42 +08:00
|
|
|
}
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
AdjustWindowRectEx(&rcClient, GetWindowLong(m_hWnd, GWL_STYLE), false, GetWindowLong(m_hWnd, GWL_EXSTYLE));
|
|
|
|
|
|
|
|
// change width and height
|
2012-09-03 00:58:42 +08:00
|
|
|
SetWindowPos(m_hWnd, 0, 0, 0, width + ptDiff.x, height + ptDiff.y,
|
|
|
|
SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
2012-05-02 17:50:26 +08:00
|
|
|
}
|
|
|
|
|
2012-10-09 00:38:04 +08:00
|
|
|
void CCEGLView::setFrameSize(float width, float height)
|
2012-05-02 17:50:26 +08:00
|
|
|
{
|
2012-08-15 14:33:56 +08:00
|
|
|
CCEGLViewProtocol::setFrameSize(width, height);
|
2012-09-03 00:58:42 +08:00
|
|
|
|
|
|
|
resize(width, height); // adjust window size for menubar
|
|
|
|
centerWindow();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEGLView::centerWindow()
|
|
|
|
{
|
|
|
|
if (! m_hWnd)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RECT rcDesktop, rcWindow;
|
|
|
|
GetWindowRect(GetDesktopWindow(), &rcDesktop);
|
|
|
|
|
|
|
|
// substract the task bar
|
|
|
|
HWND hTaskBar = FindWindow(TEXT("Shell_TrayWnd"), NULL);
|
|
|
|
if (hTaskBar != NULL)
|
|
|
|
{
|
|
|
|
APPBARDATA abd;
|
|
|
|
|
|
|
|
abd.cbSize = sizeof(APPBARDATA);
|
|
|
|
abd.hWnd = hTaskBar;
|
|
|
|
|
|
|
|
SHAppBarMessage(ABM_GETTASKBARPOS, &abd);
|
|
|
|
SubtractRect(&rcDesktop, &rcDesktop, &abd.rc);
|
|
|
|
}
|
|
|
|
GetWindowRect(m_hWnd, &rcWindow);
|
|
|
|
|
|
|
|
int offsetX = (rcDesktop.right - rcDesktop.left - (rcWindow.right - rcWindow.left)) / 2;
|
|
|
|
offsetX = (offsetX > 0) ? offsetX : rcDesktop.left;
|
|
|
|
int offsetY = (rcDesktop.bottom - rcDesktop.top - (rcWindow.bottom - rcWindow.top)) / 2;
|
|
|
|
offsetY = (offsetY > 0) ? offsetY : rcDesktop.top;
|
|
|
|
|
|
|
|
SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
|
2012-08-08 18:39:33 +08:00
|
|
|
bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-04-20 15:23:00 +08:00
|
|
|
CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor);
|
2012-08-09 12:49:33 +08:00
|
|
|
resize((int)(m_obScreenSize.width * contentScaleFactor), (int)(m_obScreenSize.height * contentScaleFactor));
|
2012-04-19 14:35:52 +08:00
|
|
|
centerWindow();
|
2012-09-14 01:22:03 +08:00
|
|
|
|
2012-08-09 12:49:33 +08:00
|
|
|
return true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-10-09 00:38:04 +08:00
|
|
|
CCEGLView* CCEGLView::sharedOpenGLView(const char* pTitle)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-05-02 17:50:26 +08:00
|
|
|
static CCEGLView* s_pEglView = NULL;
|
|
|
|
if (s_pEglView == NULL)
|
|
|
|
{
|
|
|
|
s_pEglView = new CCEGLView();
|
2012-10-09 00:38:04 +08:00
|
|
|
|
|
|
|
s_pEglView->setViewName(pTitle);
|
|
|
|
|
|
|
|
if(!s_pEglView->Create())
|
|
|
|
{
|
|
|
|
delete s_pEglView;
|
|
|
|
s_pEglView = NULL;
|
|
|
|
}
|
2012-05-02 17:50:26 +08:00
|
|
|
}
|
2012-10-09 00:38:04 +08:00
|
|
|
|
2012-08-21 14:58:31 +08:00
|
|
|
return s_pEglView;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|