diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index dab784cf..79dd1880 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -449,7 +449,7 @@ extern "C" { *************************************************************************/ /* Window handle type */ -typedef struct _GLFWwindow* GLFWwindow; +typedef void* GLFWwindow; /* The video mode structure used by glfwGetVideoModes */ typedef struct diff --git a/src/input.c b/src/input.c index f9f7c9e0..49177954 100644 --- a/src/input.c +++ b/src/input.c @@ -39,7 +39,7 @@ // Returns the state of the specified key for the specified window //======================================================================== -GLFWAPI int glfwGetKey(GLFWwindow window, int key) +GLFWAPI int glfwGetKey(GLFWwindow handle, int key) { if (!_glfwInitialized) { @@ -47,6 +47,8 @@ GLFWAPI int glfwGetKey(GLFWwindow window, int key) return GLFW_RELEASE; } + _GLFWwindow* window = (_GLFWwindow*) handle; + // Is it a valid key? if (key < 0 || key > GLFW_KEY_LAST) { @@ -70,7 +72,7 @@ GLFWAPI int glfwGetKey(GLFWwindow window, int key) // Returns the state of the specified mouse button for the specified window //======================================================================== -GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button) +GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button) { if (!_glfwInitialized) { @@ -78,6 +80,8 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button) return GLFW_RELEASE; } + _GLFWwindow* window = (_GLFWwindow*) handle; + // Is it a valid mouse button? if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) { @@ -100,7 +104,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button) // Returns the last reported cursor position for the specified window //======================================================================== -GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos) +GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos) { if (!_glfwInitialized) { @@ -108,6 +112,8 @@ GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + // Return mouse position if (xpos != NULL) *xpos = window->mousePosX; @@ -122,7 +128,7 @@ GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos) // the specified window //======================================================================== -GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos) +GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) { if (!_glfwInitialized) { @@ -130,6 +136,8 @@ GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + // Don't do anything if the mouse position did not change if (xpos == window->mousePosX && ypos == window->mousePosY) return; @@ -151,7 +159,7 @@ GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos) // Returns the scroll offset for the specified window //======================================================================== -GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y) +GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* x, int* y) { if (!_glfwInitialized) { @@ -159,6 +167,8 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (x) *x = window->scrollX; diff --git a/src/window.c b/src/window.c index f43d398e..693354ee 100644 --- a/src/window.c +++ b/src/window.c @@ -775,7 +775,7 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint) // Properly kill the window / video display //======================================================================== -GLFWAPI void glfwCloseWindow(GLFWwindow window) +GLFWAPI void glfwCloseWindow(GLFWwindow handle) { if (!_glfwInitialized) { @@ -783,6 +783,8 @@ GLFWAPI void glfwCloseWindow(GLFWwindow window) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + // Show mouse pointer again (if hidden) if (window == _glfwLibrary.cursorLockWindow) glfwEnable(window, GLFW_MOUSE_CURSOR); @@ -831,7 +833,7 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title) // Get the window size //======================================================================== -GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height) +GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height) { if (!_glfwInitialized) { @@ -839,6 +841,8 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (width != NULL) *width = window->width; @@ -851,7 +855,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height) // Set the window size //======================================================================== -GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height) +GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height) { if (!_glfwInitialized) { @@ -859,6 +863,8 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (window->iconified) { // TODO: Figure out if this is an error @@ -884,7 +890,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height) // Get the window position //======================================================================== -GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* x, int* y) +GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* x, int* y) { if (!_glfwInitialized) { @@ -892,6 +898,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* x, int* y) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (x != NULL) *x = window->positionX; @@ -904,7 +912,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow window, int* x, int* y) // Set the window position //======================================================================== -GLFWAPI void glfwSetWindowPos(GLFWwindow window, int x, int y) +GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int x, int y) { if (!_glfwInitialized) { @@ -912,6 +920,8 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow window, int x, int y) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (window->mode == GLFW_FULLSCREEN || window->iconified) { // TODO: Figure out if this is an error @@ -926,7 +936,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow window, int x, int y) // Window iconification //======================================================================== -GLFWAPI void glfwIconifyWindow(GLFWwindow window) +GLFWAPI void glfwIconifyWindow(GLFWwindow handle) { if (!_glfwInitialized) { @@ -934,6 +944,8 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow window) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (window->iconified) return; @@ -945,7 +957,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow window) // Window un-iconification //======================================================================== -GLFWAPI void glfwRestoreWindow(GLFWwindow window) +GLFWAPI void glfwRestoreWindow(GLFWwindow handle) { if (!_glfwInitialized) { @@ -953,6 +965,8 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow window) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + if (!window->iconified) return; @@ -1013,7 +1027,7 @@ GLFWAPI void glfwSwapInterval(int interval) // Get window parameter //======================================================================== -GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param) +GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) { if (!_glfwInitialized) { @@ -1021,6 +1035,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param) return 0; } + _GLFWwindow* window = (_GLFWwindow*) handle; + switch (param) { case GLFW_ACTIVE: @@ -1080,7 +1096,7 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param) // Set the user pointer for the specified window //======================================================================== -GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer) +GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer) { if (!_glfwInitialized) { @@ -1088,6 +1104,8 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer) return; } + _GLFWwindow* window = (_GLFWwindow*) handle; + window->userPointer = pointer; } @@ -1096,7 +1114,7 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer) // Get the user pointer for the specified window //======================================================================== -GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window) +GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle) { if (!_glfwInitialized) { @@ -1104,6 +1122,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window) return NULL; } + _GLFWwindow* window = (_GLFWwindow*) handle; + return window->userPointer; }