C strictness fixes.

This commit is contained in:
Camilla Berglund 2011-04-06 20:38:55 +02:00
parent 1412732874
commit f0ef9277ea
2 changed files with 35 additions and 36 deletions

View File

@ -41,14 +41,14 @@
GLFWAPI int glfwGetKey(GLFWwindow handle, int key) GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE; return GLFW_RELEASE;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
// Is it a valid key? // Is it a valid key?
if (key < 0 || key > GLFW_KEY_LAST) 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) GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE; return GLFW_RELEASE;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
// Is it a valid mouse button? // Is it a valid mouse button?
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) 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) GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
// Return mouse position // Return mouse position
if (xpos != NULL) if (xpos != NULL)
*xpos = window->mousePosX; *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) GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
// Don't do anything if the mouse position did not change // Don't do anything if the mouse position did not change
if (xpos == window->mousePosX && ypos == window->mousePosY) if (xpos == window->mousePosX && ypos == window->mousePosY)
return; return;
@ -161,14 +161,14 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset) GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (xoffset) if (xoffset)
*xoffset = window->scrollX; *xoffset = window->scrollX;

View File

@ -365,14 +365,14 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle) GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (_glfwLibrary.currentWindow == window) if (_glfwLibrary.currentWindow == window)
return; return;
@ -388,6 +388,7 @@ GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
GLFWAPI int glfwIsWindow(GLFWwindow handle) GLFWAPI int glfwIsWindow(GLFWwindow handle)
{ {
_GLFWwindow* entry; _GLFWwindow* entry;
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -395,8 +396,6 @@ GLFWAPI int glfwIsWindow(GLFWwindow handle)
return GL_FALSE; return GL_FALSE;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window == NULL) if (window == NULL)
return GL_FALSE; return GL_FALSE;
@ -515,14 +514,14 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
GLFWAPI void glfwCloseWindow(GLFWwindow handle) GLFWAPI void glfwCloseWindow(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
// Allow closing of NULL (to match the behavior of free) // Allow closing of NULL (to match the behavior of free)
if (window == NULL) if (window == NULL)
return; return;
@ -561,14 +560,14 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title) GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
_glfwPlatformSetWindowTitle(window, title); _glfwPlatformSetWindowTitle(window, title);
} }
@ -579,14 +578,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height) GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (width != NULL) if (width != NULL)
*width = window->width; *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) GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->iconified) if (window->iconified)
{ {
// TODO: Figure out if this is an error // 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) GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (xpos != NULL) if (xpos != NULL)
*xpos = window->positionX; *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) GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->mode == GLFW_FULLSCREEN || window->iconified) if (window->mode == GLFW_FULLSCREEN || window->iconified)
{ {
// TODO: Figure out if this is an error // 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) GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->iconified) if (window->iconified)
return; return;
@ -703,14 +702,14 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
GLFWAPI void glfwRestoreWindow(GLFWwindow handle) GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!window->iconified) if (!window->iconified)
return; return;
@ -728,14 +727,14 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return 0; return 0;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
switch (param) switch (param)
{ {
case GLFW_ACTIVE: case GLFW_ACTIVE:
@ -799,14 +798,14 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer) GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
window->userPointer = pointer; window->userPointer = pointer;
} }
@ -817,14 +816,14 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle) GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return NULL; return NULL;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
return window->userPointer; return window->userPointer;
} }