Added window position callback.

This commit is contained in:
Camilla Berglund
2012-11-30 13:56:42 +01:00
parent fc69721807
commit 1a3d47d06d
5 changed files with 55 additions and 1 deletions

View File

@@ -199,6 +199,7 @@ struct _GLFWwindow
int glRobustness;
PFNGLGETSTRINGIPROC GetStringi;
GLFWwindowposfun windowPosCallback;
GLFWwindowsizefun windowSizeCallback;
GLFWwindowclosefun windowCloseCallback;
GLFWwindowrefreshfun windowRefreshCallback;

View File

@@ -119,8 +119,14 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
{
if (window->positionX == x && window->positionY == y)
return;
window->positionX = x;
window->positionY = y;
if (window->windowPosCallback)
window->windowPosCallback(window, x, y);
}
@@ -764,6 +770,24 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle)
}
//========================================================================
// Set callback function for window position changes
//========================================================================
GLFWAPI void glfwSetWindowPosCallback(GLFWwindow handle, GLFWwindowposfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
window->windowPosCallback = cbfun;
}
//========================================================================
// Set callback function for window size changes
//========================================================================