From 2777b89e4504524692bf2ac3fb84a9a86f18879b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 1 Feb 2018 13:03:26 +0530 Subject: [PATCH] Update bundled glfw --- glfw/context.c | 17 +++++++++++------ glfw/glfw3.h | 7 ++++++- glfw/input.c | 2 +- glfw/vulkan.c | 7 +++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/glfw/context.c b/glfw/context.c index 1ef1104a7..4c866fa96 100644 --- a/glfw/context.c +++ b/glfw/context.c @@ -607,7 +607,8 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) if (window && window->context.client == GLFW_NO_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, + "Cannot make current with a window that has no OpenGL or OpenGL ES context"); return; } @@ -636,7 +637,8 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* handle) if (window->context.client == GLFW_NO_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, + "Cannot swap buffers of a window that has no OpenGL or OpenGL ES context"); return; } @@ -652,7 +654,8 @@ GLFWAPI void glfwSwapInterval(int interval) window = _glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { - _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL); + _glfwInputError(GLFW_NO_CURRENT_CONTEXT, + "Cannot set swap interval without a current OpenGL or OpenGL ES context"); return; } @@ -669,13 +672,14 @@ GLFWAPI int glfwExtensionSupported(const char* extension) window = _glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { - _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL); + _glfwInputError(GLFW_NO_CURRENT_CONTEXT, + "Cannot query extension without a current OpenGL or OpenGL ES context"); return GLFW_FALSE; } if (*extension == '\0') { - _glfwInputError(GLFW_INVALID_VALUE, "Extension name is empty string"); + _glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string"); return GLFW_FALSE; } @@ -734,7 +738,8 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname) window = _glfwPlatformGetTls(&_glfw.contextSlot); if (!window) { - _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL); + _glfwInputError(GLFW_NO_CURRENT_CONTEXT, + "Cannot query entry point without a current OpenGL or OpenGL ES context"); return NULL; } diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 1913502dc..f53b40d13 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -5468,6 +5468,11 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys * glfwGetRequiredInstanceExtensions to check what instance extensions are * required. * + * The window surface cannot be shared with another API so the window must + * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib) + * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error + * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`. + * * The window surface must be destroyed before the specified Vulkan instance. * It is the responsibility of the caller to destroy the window surface. GLFW * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the @@ -5483,7 +5488,7 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys * [error](@ref error_handling) occurred. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. + * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE * * @remark If an error occurs before the creation call is made, GLFW returns * the Vulkan error code most appropriate for the error. Appropriate use of diff --git a/glfw/input.c b/glfw/input.c index d70b4a603..f6fb38fd0 100644 --- a/glfw/input.c +++ b/glfw/input.c @@ -1190,7 +1190,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) { if (js->mapping->buttons[i].type == _GLFW_JOYSTICK_AXIS) { - if (fabs(js->axes[js->mapping->buttons[i].value]) > 0.5) + if (fabsf(js->axes[js->mapping->buttons[i].value]) > 0.5f) state->buttons[i] = GLFW_PRESS; } else if (js->mapping->buttons[i].type == _GLFW_JOYSTICK_HATBIT) diff --git a/glfw/vulkan.c b/glfw/vulkan.c index 1fd15fad2..ab45c9b3e 100644 --- a/glfw/vulkan.c +++ b/glfw/vulkan.c @@ -317,6 +317,13 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; } + if (window->context.client != GLFW_NO_API) + { + _glfwInputError(GLFW_INVALID_VALUE, + "Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API"); + return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR; + } + return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface); }