Added macros for library initialization check.

This commit is contained in:
Camilla Berglund 2013-02-20 00:28:08 +01:00
parent ca0617be2c
commit 719b60dd2b
16 changed files with 88 additions and 434 deletions

View File

@ -40,26 +40,14 @@
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformSetClipboardString(window, string);
}
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetClipboardString(window);
}

View File

@ -930,13 +930,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
return window->ns.object;
}

View File

@ -364,11 +364,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (_glfwPlatformGetCurrentContext() == window)
return;
@ -378,35 +374,20 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return (GLFWwindow*) _glfwPlatformGetCurrentContext();
}
GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformSwapBuffers(window);
}
GLFWAPI void glfwSwapInterval(int interval)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (!_glfwPlatformGetCurrentContext())
{
@ -422,11 +403,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
const GLubyte* extensions;
_GLFWwindow* window;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return GL_FALSE;
}
_GLFW_REQUIRE_INIT_OR_RETURN(GL_FALSE);
window = _glfwPlatformGetCurrentContext();
if (!window)
@ -479,11 +456,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfwPlatformGetCurrentContext())
{

View File

@ -461,38 +461,21 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfw.egl.display;
}
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->egl.context;
}
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return window->egl.surface;
}

View File

@ -42,11 +42,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
int i, size = GLFW_GAMMA_RAMP_SIZE;
GLFWgammaramp ramp;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (gamma <= 0.f)
{
@ -81,13 +77,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
GLFWAPI void glfwGetGammaRamp(GLFWmonitor* handle, GLFWgammaramp* ramp)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformGetGammaRamp(monitor, ramp);
}
@ -95,11 +85,7 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (!monitor->rampChanged)
{

View File

@ -594,13 +594,7 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->glx.context;
}

View File

@ -208,11 +208,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
switch (mode)
{
@ -232,11 +228,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
switch (mode)
{
@ -259,11 +251,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE;
}
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
if (key < 0 || key > GLFW_KEY_LAST)
{
@ -285,11 +273,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE;
}
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{
@ -312,16 +296,12 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, int* xpos, int* ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (xpos != NULL)
if (xpos)
*xpos = window->cursorPosX;
if (ypos != NULL)
if (ypos)
*ypos = window->cursorPosY;
}
@ -329,11 +309,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, int xpos, int ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (_glfw.focusedWindow != window)
return;
@ -357,78 +333,42 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, int xpos, int ypos)
GLFWAPI void glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.key = cbfun;
}
GLFWAPI void glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.character = cbfun;
}
GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow* handle, GLFWmousebuttonfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.mouseButton = cbfun;
}
GLFWAPI void glfwSetCursorPosCallback(GLFWwindow* handle, GLFWcursorposfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.cursorPos = cbfun;
}
GLFWAPI void glfwSetCursorEnterCallback(GLFWwindow* handle, GLFWcursorenterfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.cursorEnter = cbfun;
}
GLFWAPI void glfwSetScrollCallback(GLFWwindow* handle, GLFWscrollfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.scroll = cbfun;
}

View File

@ -109,6 +109,20 @@ typedef struct _GLFWmonitor _GLFWmonitor;
// Internal key state used for sticky keys
#define _GLFW_STICK 3
// Checks for whether the library has been intitalized
#define _GLFW_REQUIRE_INIT() \
if (!_glfwInitialized) \
{ \
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
return; \
}
#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \
if (!_glfwInitialized) \
{ \
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
return x; \
}
//========================================================================
// Internal types

View File

@ -37,11 +37,7 @@
GLFWAPI int glfwGetJoystickParam(int joy, int param)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
@ -56,11 +52,7 @@ GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes)
{
int i;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
@ -87,11 +79,7 @@ GLFWAPI int glfwGetJoystickButtons(int joy,
{
int i;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
@ -114,11 +102,7 @@ GLFWAPI int glfwGetJoystickButtons(int joy,
GLFWAPI const char* glfwGetJoystickName(int joy)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{

View File

@ -266,24 +266,14 @@ void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
*count = _glfw.monitorCount;
return (GLFWmonitor**) _glfw.monitors;
}
GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return (GLFWmonitor*) _glfw.monitors[0];
}
@ -291,11 +281,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (xpos)
*xpos = monitor->positionX;
@ -307,11 +293,7 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* he
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (width)
*width = monitor->widthMM;
@ -322,24 +304,13 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* he
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->name;
}
GLFWAPI void glfwSetMonitorCallback(GLFWmonitorfun cbfun)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfw.monitorCallback = cbfun;
}
@ -347,11 +318,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!refreshVideoModes(monitor))
return GL_FALSE;
@ -365,11 +332,7 @@ GLFWAPI GLFWvidmode glfwGetVideoMode(GLFWmonitor* handle)
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
GLFWvidmode mode = { 0, 0, 0, 0, 0 };
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return mode;
}
_GLFW_REQUIRE_INIT_OR_RETURN(mode);
_glfwPlatformGetVideoMode(monitor, &mode);
return mode;

View File

@ -292,13 +292,7 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
return window->nsgl.context;
}

View File

@ -37,23 +37,13 @@
GLFWAPI double glfwGetTime(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0.0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
return _glfwPlatformGetTime();
}
GLFWAPI void glfwSetTime(double time)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformSetTime(time);
}

View File

@ -579,13 +579,7 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->wgl.context;
}

View File

@ -1090,13 +1090,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->win32.handle;
}

View File

@ -147,11 +147,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
_GLFWwindow* window;
_GLFWwindow* previous;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (width <= 0 || height <= 0)
{
@ -271,11 +267,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
void glfwDefaultWindowHints(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
@ -298,11 +290,7 @@ void glfwDefaultWindowHints(void)
GLFWAPI void glfwWindowHint(int target, int hint)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
switch (target)
{
@ -385,11 +373,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
// Allow closing of NULL (to match the behavior of free)
if (window == NULL)
@ -425,26 +409,14 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformSetWindowTitle(window, title);
}
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformGetWindowPos(window, xpos, ypos);
}
@ -452,11 +424,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (window->monitor)
{
@ -471,13 +439,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformGetWindowSize(window, width, height);
}
@ -485,11 +447,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (window->iconified)
{
@ -510,11 +468,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (window->iconified)
return;
@ -526,11 +480,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (!window->iconified)
return;
@ -542,11 +492,7 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (window->monitor)
return;
@ -558,11 +504,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
if (window->monitor)
return;
@ -574,11 +516,7 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow* handle, int param)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(0);
switch (param)
{
@ -617,139 +555,75 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow* handle, int param)
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return (GLFWmonitor*) window->monitor;
}
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->userPointer = pointer;
}
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->userPointer;
}
GLFWAPI void glfwSetWindowPosCallback(GLFWwindow* handle, GLFWwindowposfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.pos = cbfun;
}
GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow* handle, GLFWwindowsizefun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.size = cbfun;
}
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow* handle, GLFWwindowclosefun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.close = cbfun;
}
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow* handle, GLFWwindowrefreshfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.refresh = cbfun;
}
GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow* handle, GLFWwindowfocusfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.focus = cbfun;
}
GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow* handle, GLFWwindowiconifyfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
window->callbacks.iconify = cbfun;
}
GLFWAPI void glfwPollEvents(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformPollEvents();
}
GLFWAPI void glfwWaitEvents(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFW_REQUIRE_INIT();
_glfwPlatformWaitEvents();
}

View File

@ -1037,25 +1037,14 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
GLFWAPI Display* glfwGetX11Display(void)
{
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfw.x11.display;
}
GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFW_REQUIRE_INIT_OR_RETURN(None);
return window->x11.handle;
}