mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-27 04:28:52 -05:00
C strictness fixes.
This commit is contained in:
parent
1412732874
commit
f0ef9277ea
20
src/input.c
20
src/input.c
|
@ -41,14 +41,14 @@
|
|||
|
||||
GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
// Is it a valid key?
|
||||
if (key < 0 || key > GLFW_KEY_LAST)
|
||||
{
|
||||
|
@ -74,14 +74,14 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
|
|||
|
||||
GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
// Is it a valid mouse button?
|
||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||
{
|
||||
|
@ -106,14 +106,14 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
|
|||
|
||||
GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
// Return mouse position
|
||||
if (xpos != NULL)
|
||||
*xpos = window->mousePosX;
|
||||
|
@ -130,14 +130,14 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
|
|||
|
||||
GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
// Don't do anything if the mouse position did not change
|
||||
if (xpos == window->mousePosX && ypos == window->mousePosY)
|
||||
return;
|
||||
|
@ -161,14 +161,14 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
|
|||
|
||||
GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (xoffset)
|
||||
*xoffset = window->scrollX;
|
||||
|
||||
|
|
51
src/window.c
51
src/window.c
|
@ -365,14 +365,14 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||
|
||||
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (_glfwLibrary.currentWindow == window)
|
||||
return;
|
||||
|
||||
|
@ -388,6 +388,7 @@ GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
|
|||
GLFWAPI int glfwIsWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* entry;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
|
@ -395,8 +396,6 @@ GLFWAPI int glfwIsWindow(GLFWwindow handle)
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (window == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
|
@ -515,14 +514,14 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
|
|||
|
||||
GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
// Allow closing of NULL (to match the behavior of free)
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
@ -561,14 +560,14 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
|||
|
||||
GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
_glfwPlatformSetWindowTitle(window, title);
|
||||
}
|
||||
|
||||
|
@ -579,14 +578,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
|
|||
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (width != NULL)
|
||||
*width = window->width;
|
||||
|
||||
|
@ -601,14 +600,14 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height)
|
|||
|
||||
GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (window->iconified)
|
||||
{
|
||||
// TODO: Figure out if this is an error
|
||||
|
@ -636,14 +635,14 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
|||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (xpos != NULL)
|
||||
*xpos = window->positionX;
|
||||
|
||||
|
@ -658,14 +657,14 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
|
|||
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN || window->iconified)
|
||||
{
|
||||
// TODO: Figure out if this is an error
|
||||
|
@ -682,14 +681,14 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
|
|||
|
||||
GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (window->iconified)
|
||||
return;
|
||||
|
||||
|
@ -703,14 +702,14 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
|
|||
|
||||
GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!window->iconified)
|
||||
return;
|
||||
|
||||
|
@ -728,14 +727,14 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
|||
|
||||
GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
switch (param)
|
||||
{
|
||||
case GLFW_ACTIVE:
|
||||
|
@ -799,14 +798,14 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||
|
||||
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
window->userPointer = pointer;
|
||||
}
|
||||
|
||||
|
@ -817,14 +816,14 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
|
|||
|
||||
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
return window->userPointer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user