raylib GLFW dependency - raysan5/raylib GitHub Wiki
raylib uses the GLFW library for managing Window and Input events on the following platforms:
PLATFORM_DESKTOP
: Windows, Linux and macOS.PLATFORM_WEB
: HTML5 (Emscripten JS implementation (limited)).
Note that GLFW is used by the core module only.
GLFW is not used on the following platforms, where custom implementations are used to manage Window and Input events:
PLATFORM_ANDROID
: Uses thenative_app_glue
Android NDK module.PLATFORM_RPI
: (native, no desktop) UsesEGL
,evdev
and standard system libraries directly.PLATFORM_SDL
: Uses the native SDL functions.
If you are interested in replacing GLFW with a custom, platform-specific implementation, the functions currently used by raylib (as of raylib 4.0) are detailed below:
// GLFW: Device init/close
glfwInit();
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE);
glfwDefaultWindowHints();
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwCreateWindow(CORE.Window.display.width, CORE.Window.display.height, CORE.Window.title, glfwGetPrimaryMonitor(), NULL);
glfwDestroyWindow(CORE.Window.handle);
glfwWindowShouldClose(CORE.Window.handle);
glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE);
glfwMakeContextCurrent(CORE.Window.handle);
glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
glfwWaitEvents();
glfwPollEvents();
glfwSwapInterval(1);
glfwSwapBuffers(CORE.Window.handle);
glfwTerminate();
// GLFW: Window/Monitor management
glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y);
glfwGetWindowAttrib(CORE.Window.handle, GLFW_VISIBLE) == GL_FALSE);
glfwSetWindowTitle(CORE.Window.handle, title);
glfwSetWindowPos(CORE.Window.handle, x, y);
glfwGetPrimaryMonitor();
glfwGetMonitors(&monitorCount);
glfwGetMonitorName(monitors[monitor]));
glfwGetMonitorPhysicalSize(monitors[monitor], &physicalWidth, NULL);
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
glfwSetWindowSizeLimits(CORE.Window.handle, width, height, mode->width, mode->height);
glfwSetWindowSize(CORE.Window.handle, width, height);
glfwGetVideoMode(monitor);
glfwGetVideoModes(monitors[monitor], &count);
glfwShowWindow(CORE.Window.handle);
glfwHideWindow(CORE.Window.handle);
glfwGetWin32Window(CORE.Window.handle);
glfwMaximizeWindow(CORE.Window.handle);
glfwIconifyWindow(CORE.Window.handle);
glfwRestoreWindow(CORE.Window.handle);
glfwSetWindowIcon(CORE.Window.handle, 1, icon);
glfwGetWindowMonitor(CORE.Window.handle);
glfwGetMonitorWorkarea(monitor, &mx, &my, &width, &height);
glfwGetMonitorPos(monitors[monitor], &x, &y);
glfwGetMonitorContentScale(monitors[i], &xdpi, &ydpi);
glfwGetWindowContentScale(CORE.Window.handle, &xScale, &yScale);
// GLFW: Misc functionality
glfwGetProcAddress();
glfwGetClipboardString(CORE.Window.handle);
glfwSetClipboardString(CORE.Window.handle, text);
glfwGetTime();
glfwSetCursor(CORE.Window.handle, NULL);
glfwCreateStandardCursor(0x00036000 + cursor);
// GLFW: Callbacks (Window/Input events)
glfwSetErrorCallback(ErrorCallback);
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
glfwSetWindowIconifyCallback(CORE.Window.handle, WindowIconifyCallback);
glfwSetWindowFocusCallback(CORE.Window.handle, WindowFocusCallback);
glfwSetCursorEnterCallback(CORE.Window.handle, CursorEnterCallback);
glfwSetCursorPosCallback(CORE.Window.handle, MouseCursorPosCallback);
glfwSetMouseButtonCallback(CORE.Window.handle, MouseButtonCallback);
glfwSetScrollCallback(CORE.Window.handle, ScrollCallback);
glfwSetKeyCallback(CORE.Window.handle, KeyCallback);
glfwSetCharCallback(CORE.Window.handle, CharCallback);
glfwSetDropCallback(CORE.Window.handle, WindowDropCallback);
glfwSetJoystickCallback(NULL);
// GLFW: Input management
// NOTE: Most inputs (keyboard/mouse) are managed through callbacks
glfwJoystickPresent(i);
glfwGetJoystickName(gamepad);
glfwGetGamepadState(i, &state);
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.position.x, CORE.Input.Mouse.position.y);
glfwUpdateGamepadMappings(mappings);