|
@@ -28,6 +28,7 @@
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
+#include <assert.h>
|
|
|
#include <string.h>
|
|
|
#include <stdlib.h>
|
|
|
|
|
@@ -124,6 +125,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|
|
_GLFWwindow* window;
|
|
|
_GLFWwindow* previous;
|
|
|
|
|
|
+ assert(title);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
if (width <= 0 || height <= 0)
|
|
@@ -415,6 +418,8 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
|
|
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
|
|
return window->closed;
|
|
|
}
|
|
@@ -422,6 +427,8 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
|
|
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
window->closed = value;
|
|
|
}
|
|
@@ -429,6 +436,10 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
|
|
|
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
+ assert(title);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
_glfwPlatformSetWindowTitle(window, title);
|
|
|
}
|
|
@@ -436,6 +447,7 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
|
|
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
if (xpos)
|
|
|
*xpos = 0;
|
|
@@ -449,6 +461,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
|
|
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -465,6 +478,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|
|
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
if (width)
|
|
|
*width = 0;
|
|
@@ -478,6 +492,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
|
|
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -495,6 +510,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
|
|
int maxwidth, int maxheight)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -509,6 +525,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
|
|
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -527,6 +544,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
|
|
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
if (width)
|
|
|
*width = 0;
|
|
@@ -542,6 +560,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
|
|
int* right, int* bottom)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
if (left)
|
|
|
*left = 0;
|
|
@@ -559,6 +578,8 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
|
|
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
_glfwPlatformIconifyWindow(window);
|
|
|
}
|
|
@@ -566,6 +587,8 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
|
|
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
_glfwPlatformRestoreWindow(window);
|
|
|
}
|
|
@@ -573,6 +596,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
|
|
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -585,6 +609,7 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
|
|
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
@@ -597,6 +622,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
|
|
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
|
|
|
|
@@ -643,6 +669,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|
|
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
return (GLFWmonitor*) window->monitor;
|
|
|
}
|
|
@@ -650,6 +678,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
|
|
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
window->userPointer = pointer;
|
|
|
}
|
|
@@ -657,6 +687,8 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
|
|
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
return window->userPointer;
|
|
|
}
|
|
@@ -665,6 +697,8 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
|
|
GLFWwindowposfun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
|
|
|
return cbfun;
|
|
@@ -674,6 +708,8 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
|
|
GLFWwindowsizefun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
|
|
|
return cbfun;
|
|
@@ -683,6 +719,8 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
|
|
GLFWwindowclosefun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
|
|
|
return cbfun;
|
|
@@ -692,6 +730,8 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
|
|
GLFWwindowrefreshfun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
|
|
|
return cbfun;
|
|
@@ -701,6 +741,8 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
|
|
GLFWwindowfocusfun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
|
|
|
return cbfun;
|
|
@@ -710,6 +752,8 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
|
|
GLFWwindowiconifyfun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
|
|
|
return cbfun;
|
|
@@ -719,6 +763,8 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
|
|
|
GLFWframebuffersizefun cbfun)
|
|
|
{
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
+ assert(window);
|
|
|
+
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
|
|
|
return cbfun;
|