mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3606 from dabingnn/issue_2808_glfw_bug_enhancement
Issue 2808 glfw bug enhancement
This commit is contained in:
commit
e4f8929898
|
@ -161,6 +161,7 @@ public:
|
||||||
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
||||||
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
||||||
|
static void OnGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EGLViewEventHandler::s_captured = false;
|
bool EGLViewEventHandler::s_captured = false;
|
||||||
|
@ -232,6 +233,13 @@ void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int ch
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EGLViewEventHandler::OnGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
|
||||||
|
{
|
||||||
|
if(Director::getInstance())
|
||||||
|
{
|
||||||
|
Director::getInstance()->setViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
//end EGLViewEventHandler
|
//end EGLViewEventHandler
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,21 +268,26 @@ EGLView::~EGLView()
|
||||||
s_pEglView = nullptr;
|
s_pEglView = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::init(const char* viewName, float width, float height)
|
bool EGLView::init(const char* viewName, float width, float height, float frameZoomFactor)
|
||||||
{
|
{
|
||||||
if(nullptr != _mainWindow) return true;
|
if(nullptr != _mainWindow) return true;
|
||||||
|
|
||||||
setViewName(viewName);
|
setViewName(viewName);
|
||||||
setFrameSize(width, height);
|
setFrameSize(width, height);
|
||||||
|
setFrameZoomFactor(frameZoomFactor);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||||
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
|
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr);
|
||||||
glfwMakeContextCurrent(_mainWindow);
|
glfwMakeContextCurrent(_mainWindow);
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
|
||||||
|
|
||||||
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
||||||
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
||||||
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
||||||
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
|
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
|
||||||
|
glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::OnGLFWWindowPosCallback);
|
||||||
|
|
||||||
// check OpenGL version at first
|
// check OpenGL version at first
|
||||||
const GLubyte* glVersion = glGetString(GL_VERSION);
|
const GLubyte* glVersion = glGetString(GL_VERSION);
|
||||||
CCLOG("OpenGL version = %s", glVersion);
|
CCLOG("OpenGL version = %s", glVersion);
|
||||||
|
@ -379,18 +392,22 @@ void EGLView::setFrameSize(float width, float height)
|
||||||
|
|
||||||
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glViewport((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glScissor((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView* EGLView::getInstance()
|
EGLView* EGLView::getInstance()
|
||||||
|
|
|
@ -38,15 +38,13 @@ public:
|
||||||
virtual void swapBuffers();
|
virtual void swapBuffers();
|
||||||
virtual void setFrameSize(float width, float height);
|
virtual void setFrameSize(float width, float height);
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
/*
|
||||||
bool init(const char* viewName, float width, float height);
|
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
bool init(const char* viewName, float width, float height, float frameZoomFactor = 1.0f);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//void resize(int width, int height);
|
//void resize(int width, int height);
|
||||||
/*
|
|
||||||
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
||||||
*/
|
|
||||||
void setFrameZoomFactor(float fZoomFactor);
|
|
||||||
float getFrameZoomFactor();
|
float getFrameZoomFactor();
|
||||||
//void centerWindow();
|
//void centerWindow();
|
||||||
|
|
||||||
|
@ -63,11 +61,15 @@ public:
|
||||||
/** @deprecated Use getInstance() instead */
|
/** @deprecated Use getInstance() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
void setFrameZoomFactor(float fZoomFactor);
|
||||||
private:
|
private:
|
||||||
bool _captured;
|
bool _captured;
|
||||||
bool _supportTouch;
|
bool _supportTouch;
|
||||||
|
|
||||||
|
int _frameBufferSize[2];
|
||||||
float _frameZoomFactor;
|
float _frameZoomFactor;
|
||||||
static EGLView* s_pEglView;
|
static EGLView* s_pEglView;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -50,15 +50,14 @@ public:
|
||||||
virtual void swapBuffers();
|
virtual void swapBuffers();
|
||||||
virtual void setFrameSize(float width, float height);
|
virtual void setFrameSize(float width, float height);
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
/*
|
||||||
bool init(const char* viewName, float width, float height);
|
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
bool init(const char* viewName, float width, float height, float frameZoomFactor = 1.0f);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//void resize(int width, int height);
|
//void resize(int width, int height);
|
||||||
/*
|
|
||||||
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
||||||
*/
|
|
||||||
void setFrameZoomFactor(float fZoomFactor);
|
|
||||||
float getFrameZoomFactor();
|
float getFrameZoomFactor();
|
||||||
//void centerWindow();
|
//void centerWindow();
|
||||||
|
|
||||||
|
@ -75,11 +74,15 @@ public:
|
||||||
/** @deprecated Use getInstance() instead */
|
/** @deprecated Use getInstance() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
void setFrameZoomFactor(float fZoomFactor);
|
||||||
private:
|
private:
|
||||||
bool _captured;
|
bool _captured;
|
||||||
bool _supportTouch;
|
bool _supportTouch;
|
||||||
|
|
||||||
|
int _frameBufferSize[2];
|
||||||
float _frameZoomFactor;
|
float _frameZoomFactor;
|
||||||
static EGLView* s_pEglView;
|
static EGLView* s_pEglView;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -177,6 +177,7 @@ public:
|
||||||
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
||||||
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
||||||
|
static void OnGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EGLViewEventHandler::s_captured = false;
|
bool EGLViewEventHandler::s_captured = false;
|
||||||
|
@ -248,6 +249,14 @@ void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int ch
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EGLViewEventHandler::OnGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
|
||||||
|
{
|
||||||
|
if(Director::getInstance())
|
||||||
|
{
|
||||||
|
Director::getInstance()->setViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//end EGLViewEventHandler
|
//end EGLViewEventHandler
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,20 +286,25 @@ EGLView::~EGLView()
|
||||||
s_pEglView = nullptr;
|
s_pEglView = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::init(const char *viewName, float width, float height)
|
bool EGLView::init(const char *viewName, float width, float height, float frameZoomFactor)
|
||||||
{
|
{
|
||||||
if(nullptr != _mainWindow) return true;
|
if(nullptr != _mainWindow) return true;
|
||||||
|
|
||||||
setViewName(viewName);
|
setViewName(viewName);
|
||||||
setFrameSize(width, height);
|
setFrameSize(width, height);
|
||||||
|
setFrameZoomFactor(frameZoomFactor);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||||
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
|
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr);
|
||||||
glfwMakeContextCurrent(_mainWindow);
|
glfwMakeContextCurrent(_mainWindow);
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
|
||||||
|
|
||||||
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
||||||
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
||||||
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
||||||
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
|
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
|
||||||
|
glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::OnGLFWWindowPosCallback);
|
||||||
|
|
||||||
// check OpenGL version at first
|
// check OpenGL version at first
|
||||||
const GLubyte* glVersion = glGetString(GL_VERSION);
|
const GLubyte* glVersion = glGetString(GL_VERSION);
|
||||||
|
@ -396,18 +410,22 @@ void EGLView::setFrameSize(float width, float height)
|
||||||
|
|
||||||
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glViewport((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glScissor((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView* EGLView::getInstance()
|
EGLView* EGLView::getInstance()
|
||||||
|
|
|
@ -271,6 +271,7 @@ public:
|
||||||
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
|
||||||
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
||||||
|
static void OnGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EGLViewEventHandler::s_captured = false;
|
bool EGLViewEventHandler::s_captured = false;
|
||||||
|
@ -320,8 +321,8 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
||||||
EGLView* eglView = EGLView::getInstance();
|
EGLView* eglView = EGLView::getInstance();
|
||||||
if(nullptr == eglView) return;
|
if(nullptr == eglView) return;
|
||||||
|
|
||||||
s_mouseX *= eglView->getFrameZoomFactor();
|
s_mouseX /= eglView->getFrameZoomFactor();
|
||||||
s_mouseY *= eglView->getFrameZoomFactor();
|
s_mouseY /= eglView->getFrameZoomFactor();
|
||||||
|
|
||||||
if(s_captured)
|
if(s_captured)
|
||||||
{
|
{
|
||||||
|
@ -346,6 +347,14 @@ void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int ch
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EGLViewEventHandler::OnGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
|
||||||
|
{
|
||||||
|
if(Director::getInstance())
|
||||||
|
{
|
||||||
|
Director::getInstance()->setViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//end EGLViewEventHandler
|
//end EGLViewEventHandler
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -374,16 +383,19 @@ EGLView::~EGLView()
|
||||||
s_pEglView = nullptr;
|
s_pEglView = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::init(const char* viewName, float width, float height)
|
bool EGLView::init(const char* viewName, float width, float height, float frameZoomFactor)
|
||||||
{
|
{
|
||||||
if(nullptr != _mainWindow) return true;
|
if(nullptr != _mainWindow) return true;
|
||||||
|
|
||||||
setViewName(viewName);
|
setViewName(viewName);
|
||||||
setFrameSize(width, height);
|
setFrameSize(width, height);
|
||||||
|
setFrameZoomFactor(frameZoomFactor);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||||
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
|
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr);
|
||||||
glfwMakeContextCurrent(_mainWindow);
|
glfwMakeContextCurrent(_mainWindow);
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
|
||||||
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
|
||||||
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
|
||||||
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
|
||||||
|
@ -499,18 +511,22 @@ void EGLView::setFrameSize(float width, float height)
|
||||||
|
|
||||||
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glViewport((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
|
float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width;
|
||||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height;
|
||||||
(GLsizei)(w * _scaleX * _frameZoomFactor),
|
glScissor((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX),
|
||||||
(GLsizei)(h * _scaleY * _frameZoomFactor));
|
(GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY),
|
||||||
|
(GLsizei)(w * _scaleX * frameZoomFactorX),
|
||||||
|
(GLsizei)(h * _scaleY * frameZoomFactorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView* EGLView::getInstance()
|
EGLView* EGLView::getInstance()
|
||||||
|
|
|
@ -55,15 +55,13 @@ public:
|
||||||
virtual void swapBuffers();
|
virtual void swapBuffers();
|
||||||
virtual void setFrameSize(float width, float height);
|
virtual void setFrameSize(float width, float height);
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
/*
|
||||||
bool init(const char* viewName, float width, float height);
|
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
bool init(const char* viewName, float width, float height, float frameZoomFactor = 1.0f);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//void resize(int width, int height);
|
//void resize(int width, int height);
|
||||||
/*
|
|
||||||
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
||||||
*/
|
|
||||||
void setFrameZoomFactor(float fZoomFactor);
|
|
||||||
float getFrameZoomFactor();
|
float getFrameZoomFactor();
|
||||||
//void centerWindow();
|
//void centerWindow();
|
||||||
|
|
||||||
|
@ -82,12 +80,16 @@ public:
|
||||||
/** @deprecated Use getInstance() instead */
|
/** @deprecated Use getInstance() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
|
*/
|
||||||
|
void setFrameZoomFactor(float fZoomFactor);
|
||||||
private:
|
private:
|
||||||
bool _captured;
|
bool _captured;
|
||||||
LPFN_ACCELEROMETER_KEYHOOK _lpfnAccelerometerKeyHook;
|
LPFN_ACCELEROMETER_KEYHOOK _lpfnAccelerometerKeyHook;
|
||||||
bool _supportTouch;
|
bool _supportTouch;
|
||||||
|
|
||||||
|
int _frameBufferSize[2];
|
||||||
float _frameZoomFactor;
|
float _frameZoomFactor;
|
||||||
static EGLView* s_pEglView;
|
static EGLView* s_pEglView;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -15,6 +15,7 @@ cd $(dirname ${BASH_SOURCE[0]})
|
||||||
|
|
||||||
if $COCOS2DX_USEAPT; then
|
if $COCOS2DX_USEAPT; then
|
||||||
./install-deps-linux.sh
|
./install-deps-linux.sh
|
||||||
|
tools/travis-scripts/install_glfw.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export MAKEFLAGS=-j10
|
export MAKEFLAGS=-j10
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
GLFW_VERSION="3.0.1"
|
GLFW_VERSION="3.0.2"
|
||||||
GLFW_SOURCE="https://codeload.github.com/glfw/glfw/tar.gz/${GLFW_VERSION}"
|
GLFW_SOURCE="https://codeload.github.com/glfw/glfw/tar.gz/${GLFW_VERSION}"
|
||||||
GLFW_ZIP="glfw${GLFW_VERSION}.tar.gz"
|
GLFW_ZIP="glfw${GLFW_VERSION}.tar.gz"
|
||||||
GLFW_INSTALL="glfw_install"
|
GLFW_INSTALL="glfw_install"
|
||||||
|
@ -12,6 +12,7 @@ install_glfw_dep()
|
||||||
sudo apt-get install xorg-dev
|
sudo apt-get install xorg-dev
|
||||||
sudo apt-get install libglu1-mesa-dev
|
sudo apt-get install libglu1-mesa-dev
|
||||||
sudo apt-get install cmake
|
sudo apt-get install cmake
|
||||||
|
sudo apt-get install curl
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_tmp_file()
|
clean_tmp_file()
|
||||||
|
@ -26,6 +27,7 @@ make_and_install()
|
||||||
cmake "../${GLFW_SRCDIR}" -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON
|
cmake "../${GLFW_SRCDIR}" -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
|
sudo ldconfig
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue