//======================================================================== // GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy <[email protected]> // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would // be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not // be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source // distribution. // //======================================================================== #include "internal.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <assert.h> // NOTE: The global variables below comprise all mutable global data in GLFW // Any other mutable global variable is a bug // This contains all mutable state shared between compilation units of GLFW // _GLFWlibrary _glfw = …; // These are outside of _glfw so they can be used before initialization and // after termination without special handling when _glfw is cleared to zero // static _GLFWerror _glfwMainThreadError; static GLFWerrorfun _glfwErrorCallback; static GLFWallocator _glfwInitAllocator; static _GLFWinitconfig _glfwInitHints = …; // The allocation function used when no custom allocator is set // static void* defaultAllocate(size_t size, void* user) { … } // The deallocation function used when no custom allocator is set // static void defaultDeallocate(void* block, void* user) { … } // The reallocation function used when no custom allocator is set // static void* defaultReallocate(void* block, size_t size, void* user) { … } // Terminate the library // static void terminate(void) { … } ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// // Encode a Unicode code point to a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // size_t _glfwEncodeUTF8(char* s, uint32_t codepoint) { … } // Splits and translates a text/uri-list into separate file paths // NOTE: This function destroys the provided string // char** _glfwParseUriList(char* text, int* count) { … } char* _glfw_strdup(const char* source) { … } int _glfw_min(int a, int b) { … } int _glfw_max(int a, int b) { … } void* _glfw_calloc(size_t count, size_t size) { … } void* _glfw_realloc(void* block, size_t size) { … } void _glfw_free(void* block) { … } ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// ////////////////////////////////////////////////////////////////////////// // Notifies shared code of an error // void _glfwInputError(int code, const char* format, ...) { … } ////////////////////////////////////////////////////////////////////////// ////// GLFW public API ////// ////////////////////////////////////////////////////////////////////////// GLFWAPI int glfwInit(void) { … } GLFWAPI void glfwTerminate(void) { … } GLFWAPI void glfwInitHint(int hint, int value) { … } GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator) { … } GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader) { … } GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) { … } GLFWAPI int glfwGetError(const char** description) { … } GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun) { … }