issue #2460: optimize EGLView interface

This commit is contained in:
Huabing.Xu 2013-08-29 11:36:16 +08:00
parent d73b8e8b23
commit 99f88df8d2
9 changed files with 22 additions and 19 deletions

View File

@ -132,9 +132,13 @@ EGLView::~EGLView()
s_pEglView = nullptr; s_pEglView = nullptr;
} }
bool EGLView::create() bool EGLView::init(const char* viewName, float width, float height)
{ {
if(nullptr != _mainWindow) return true; if(nullptr != _mainWindow) return true;
setViewName(viewName);
setFrameSize(width, height);
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr); _mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
glfwMakeContextCurrent(_mainWindow); glfwMakeContextCurrent(_mainWindow);

View File

@ -32,8 +32,7 @@ public:
virtual void setFrameSize(float width, float height); virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
//void setWndProc(CUSTOM_WND_PROC proc); bool init(const char* viewName, float width, float height);
virtual bool create();
public: public:
//void resize(int width, int height); //void resize(int width, int height);

View File

@ -44,8 +44,7 @@ public:
virtual void setFrameSize(float width, float height); virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
//void setWndProc(CUSTOM_WND_PROC proc); bool init(const char* viewName, float width, float height);
virtual bool create();
public: public:
//void resize(int width, int height); //void resize(int width, int height);

View File

@ -149,9 +149,13 @@ EGLView::~EGLView()
s_pEglView = nullptr; s_pEglView = nullptr;
} }
bool EGLView::create() bool EGLView::init(const char *viewName, float width, float height)
{ {
if(nullptr != _mainWindow) return true; if(nullptr != _mainWindow) return true;
setViewName(viewName);
setFrameSize(width, height);
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr); _mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
glfwMakeContextCurrent(_mainWindow); glfwMakeContextCurrent(_mainWindow);

View File

@ -245,9 +245,13 @@ EGLView::~EGLView()
s_pEglView = nullptr; s_pEglView = nullptr;
} }
bool EGLView::create() bool EGLView::init(const char* viewName, float width, float height)
{ {
if(nullptr != _mainWindow) return true; if(nullptr != _mainWindow) return true;
setViewName(viewName);
setFrameSize(width, height);
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr); _mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
glfwMakeContextCurrent(_mainWindow); glfwMakeContextCurrent(_mainWindow);

View File

@ -49,8 +49,7 @@ public:
virtual void setFrameSize(float width, float height); virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
//void setWndProc(CUSTOM_WND_PROC proc); bool init(const char* viewName, float width, float height);
virtual bool create();
public: public:
//void resize(int width, int height); //void resize(int width, int height);

View File

@ -14,8 +14,6 @@ int main(int argc, char **argv)
// create the application instance // create the application instance
AppDelegate app; AppDelegate app;
EGLView* eglView = new EGLView(); EGLView* eglView = new EGLView();
eglView->setViewName("TestCpp"); eglView->init("TestCPP",900,640);
eglView->setFrameSize(900, 640);
eglView->create();
return Application::getInstance()->run(); return Application::getInstance()->run();
} }

View File

@ -31,8 +31,6 @@ int main(int argc, char *argv[])
{ {
AppDelegate app; AppDelegate app;
EGLView* eglView = new EGLView(); EGLView* eglView = new EGLView();
eglView->setViewName("TestCpp"); eglView->init("TestCPP",900,640);
eglView->setFrameSize(900, 640);
eglView->create();
return Application::getInstance()->run(); return Application::getInstance()->run();
} }

View File

@ -15,8 +15,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// create the application instance // create the application instance
AppDelegate app; AppDelegate app;
EGLView* eglView = new EGLView(); EGLView* eglView = new EGLView();
eglView->setViewName("TestCpp"); eglView->init("TestCPP",900,640);
eglView->setFrameSize(480, 320);
eglView->create();
return Application::getInstance()->run(); return Application::getInstance()->run();
} }