GLFWAPI void glfwTerminate(void) { int i; if (!_glfwInitialized) return; memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks)); while (_glfw.windowListHead) glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead); while (_glfw.cursorListHead) glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead); for (i = 0; i < _glfw.monitorCount; i++) { _GLFWmonitor* monitor = _glfw.monitors[i]; if (monitor->originalRamp.size) _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp); } _glfwFreeMonitors(_glfw.monitors, _glfw.monitorCount); _glfw.monitors = NULL; _glfw.monitorCount = 0; _glfwPlatformTerminate(); memset(&_glfw, 0, sizeof(_glfw)); _glfwInitialized = GL_FALSE; }
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); assert(ramp != NULL); assert(ramp->size > 0); assert(ramp->red != NULL); assert(ramp->green != NULL); assert(ramp->blue != NULL); if (ramp->size <= 0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma ramp size %i", ramp->size); return; } _GLFW_REQUIRE_INIT(); if (!monitor->originalRamp.size) _glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp); _glfwPlatformSetGammaRamp(monitor, ramp); }
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT(); if (!monitor->originalRamp.size) _glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp); _glfwPlatformSetGammaRamp(monitor, ramp); }
GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp) { if (!_glfwInitialized) { _glfwInputError(GLFW_NOT_INITIALIZED, NULL); return; } _glfwPlatformSetGammaRamp(ramp); _glfw.currentRamp = *ramp; _glfw.rampChanged = GL_TRUE; }
void _glfwPlatformTerminate(void) { // Restore the original gamma ramp if (_glfw.rampChanged) _glfwPlatformSetGammaRamp(&_glfw.originalRamp); if (_glfw.win32.classAtom) { UnregisterClass(_GLFW_WNDCLASSNAME, _glfw.win32.instance); _glfw.win32.classAtom = 0; } _glfwTerminateOpenGL(); _glfwTerminateJoysticks(); freeLibraries(); // Restore previous FOREGROUNDLOCKTIMEOUT system setting SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(_glfw.win32.foregroundLockTimeout), SPIF_SENDCHANGE); }
GLFWAPI void glfwTerminate(void) { int i; if (!_glfwInitialized) return; // Close all remaining windows while (_glfw.windowListHead) glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead); for (i = 0; i < _glfw.monitorCount; i++) { _GLFWmonitor* monitor = _glfw.monitors[i]; if (monitor->rampChanged) _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp); } _glfwDestroyMonitors(); _glfwPlatformTerminate(); _glfwInitialized = GL_FALSE; }