Added per-window user pointers.

This commit is contained in:
Camilla Berglund 2010-09-09 22:44:38 +02:00
parent 37c71c1ed1
commit 48f5a7e763
4 changed files with 36 additions and 0 deletions

View File

@ -421,6 +421,8 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow, int x, int y);
GLFWAPI void glfwIconifyWindow(GLFWwindow window);
GLFWAPI void glfwRestoreWindow(GLFWwindow window);
GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param);
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer);
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window);
GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun);
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun);
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun);

View File

@ -265,6 +265,7 @@ version of GLFW.</p>
<li>Added <code>glfwIsWindow</code> function for verifying that a given window handle is (still) valid</li>
<li>Added <code>glfwMakeWindowCurrent</code> function for making the context of the specified window current</li>
<li>Added <code>glfwGetError</code> and <code>glfwErrorString</code> error reporting functions and a number of error tokens</li>
<li>Added <code>glfwSetWindowUserPointer</code> and <code>glfwGetWindowUserPointer</code> functions for per-window user pointers</li>
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
<li>Renamed <code>lib</code> source code directory to <code>src</code></li>
<li>Replaced ad hoc build system with CMake</li>

View File

@ -158,6 +158,7 @@ typedef struct _GLFWwindow
GLboolean sysKeysDisabled; // system keys disabled flag
GLboolean windowNoResize; // resize- and maximize gadgets disabled flag
int refreshRate; // monitor refresh rate
void* userPointer;
// Window input state
GLboolean stickyKeys;

View File

@ -944,6 +944,38 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param)
}
//========================================================================
// Set the user pointer for the specified window
//========================================================================
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED);
return;
}
window->userPointer = pointer;
}
//========================================================================
// Get the user pointer for the specified window
//========================================================================
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED);
return;
}
return window->userPointer;
}
//========================================================================
// Set callback function for window size changes
//========================================================================