-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
raylib GLFW dependency
Ray edited this page Apr 30, 2020
·
5 revisions
raylib uses GLFW library for several platforms Window/Input events management:
-
PLATFORM_DESKTOP
(Windows, Linux, macOS) -
PLATFORM_WEB
(Html5) (Emscripten JS implementation (limited))
GLFW is used only on core module.
In case someone could be interested in replacing GLFW for a custom platform-specific implementation, here it is a list with the functions currently used (raylib 3.0):
// 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);
glfwShowWindow(CORE.Window.handle);
glfwHideWindow(CORE.Window.handle);
glfwGetWin32Window(CORE.Window.handle);
glfwGetX11Window(window);
glfwGetCocoaWindow(window);
// GLFW: Misc functionality
glfwGetProcAddress();
glfwGetClipboardString(CORE.Window.handle);
glfwSetClipboardString(CORE.Window.handle, text);
glfwGetTime();
// 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);
// 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);
GLFW is NOT used on the following platforms, where custom implementations are used to manage Window/Inputs:
-
PLATFORM_ANDROID
-> Usesnative_app_glue
Android NDK module -
PLATFORM_RPI
(native, no desktop) -> UsesEGL
,evdev
and standard system libraries directly -
PLATFORM_UWP
-> Uses UWP provided libraries
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks