mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Page:
raylib GLFW dependency
Pages
CMake Build Options
Community Resources
Compile for OSX
Create Visual Studio 2019 Project
Create Visual Studio Project
Creating Discord Activities with raylib
Frequently Asked Questions
Home
Install and configure Touchscreen Drivers (RPi)
Quick Setup for Windows with Visual Studio 2022, GCC, or MinGW
Redirect raylib output to Framebuffer 1
Screen Recording
Use multiple windows
Use raylib with Code Blocks
Use raylib with Eclipse
Use raylib with Sublime Text
Using BMFonts
Using SPI Displays with raylib
Using raylib in VSCode
Using raylib with Cpp
Visual Studio C# Setup
Working for Android (on Linux)
Working for Android (on macOS)
Working for Android
Working for Web (HTML5)
Working on Chrome OS
Working on FreeBSD
Working on GNU Linux
Working on Raspberry Pi
Working on Windows
Working on exaequOS
Working on macOS
Working with CMake
raylib GLFW dependency
raylib architecture
raylib coding conventions
raylib data structures
raylib default shader
raylib dependencies
raylib enumerated types
raylib generic uber shader and custom shaders
raylib input system
raylib integration with other libraries
raylib libc dependency
raylib platforms and graphics
raylib syntax analysis
raylib templates
Clone
5
raylib GLFW dependency
Frank Kartheuser edited this page 2024-07-07 16:20:59 +02:00
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_glueAndroid NDK module.PLATFORM_RPI: (native, no desktop) UsesEGL,evdevand 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);
Frequently Asked Questions
Library Design
- 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
Development Platforms
- 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
IDE Configurations
- 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
Misc Help
www.raylib.com | itch.io | GitHub | Discord | YouTube