{"id":50816063,"url":"https://github.com/ydah/glfw-ruby","last_synced_at":"2026-06-13T09:33:44.588Z","repository":{"id":342778246,"uuid":"1174471708","full_name":"ydah/glfw-ruby","owner":"ydah","description":"Pure Ruby FFI bindings for GLFW 3.3/3.4.","archived":false,"fork":false,"pushed_at":"2026-03-07T12:00:08.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-07T17:09:00.799Z","etag":null,"topics":["2d-graphics","3d-graphics","bindings","ffi","glfw","glfw3","graphics","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ydah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-06T13:35:11.000Z","updated_at":"2026-03-07T11:59:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ydah/glfw-ruby","commit_stats":null,"previous_names":["ydah/glfw-ruby"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ydah/glfw-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fglfw-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fglfw-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fglfw-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fglfw-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ydah","download_url":"https://codeload.github.com/ydah/glfw-ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydah%2Fglfw-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34279898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-graphics","3d-graphics","bindings","ffi","glfw","glfw3","graphics","ruby"],"created_at":"2026-06-13T09:33:43.840Z","updated_at":"2026-06-13T09:33:44.579Z","avatar_url":"https://github.com/ydah.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# glfw-ruby\n\nPure Ruby FFI bindings for GLFW 3.3/3.4.\n\nThis gem exposes:\n\n- `GLFW::API` for low-level access that stays close to the C API\n- Ruby-friendly wrappers such as `GLFW::Window`, `GLFW::Monitor`, `GLFW::Cursor`, `GLFW::Joystick`, and `GLFW::Gamepad`\n- GLFW 3.4 additions including platform queries, allocator support, and Vulkan loader hooks\n\nThe gem does not bundle GLFW itself. You need a native GLFW shared library installed on the machine.\n\n## Requirements\n\n- Ruby `\u003e= 3.1`\n- A native GLFW 3.3 or 3.4 shared library available to the dynamic linker\n\nIf the loader cannot find the library automatically, set `GLFW_LIB_PATH` to the full path of the shared library.\n\n## Installation\n\nAdd the gem:\n\n```bash\nbundle add glfw\n```\n\nOr install it directly:\n\n```bash\ngem install glfw\n```\n\nInstall the native GLFW library separately:\n\n### macOS\n\n```bash\nbrew install glfw\n```\n\n### Ubuntu / Debian\n\n```bash\nsudo apt-get install libglfw3\n```\n\n### Windows\n\nInstall a GLFW DLL and make sure it is on `PATH`, or point `GLFW_LIB_PATH` at the DLL file.\n\n## Quick Start\n\n```ruby\nrequire \"glfw\"\n\nGLFW.on_error do |code, description|\n  warn \"[GLFW #{code}] #{description}\"\nend\n\nGLFW.init\n\nbegin\n  window = GLFW::Window.new(\n    800,\n    600,\n    \"Hello GLFW\",\n    visible: false,\n    context_version_major: 3,\n    context_version_minor: 3\n  )\n\n  window.make_context_current\n  window.show\n\n  until window.should_close?\n    # draw here\n    window.swap_buffers\n    GLFW.poll_events\n  end\nensure\n  window\u0026.destroy\n  GLFW.terminate\nend\n```\n\n## Examples\n\nExample scripts live in `examples/` and can be run from a source checkout.\n\n```bash\nbundle exec ruby examples/01_minimal_window.rb\n```\n\nAvailable examples:\n\n- `examples/01_minimal_window.rb` - smallest window + event loop example\n- `examples/02_input_callbacks.rb` - keyboard, mouse, cursor, scroll, and drop callbacks\n- `examples/03_window_attributes.rb` - window title, size, position, opacity, and attribute changes\n- `examples/04_monitor_info.rb` - monitor enumeration and video mode inspection\n- `examples/05_custom_cursor_and_icon.rb` - generated cursor and window icon data\n- `examples/06_gamepad_inspector.rb` - joystick and gamepad state inspector\n- `examples/07_glfw_34_features.rb` - platform queries and other GLFW 3.4 runtime-only features\n\nOn headless Linux, run windowed examples under Xvfb.\n\n## High-Level API\n\nThe high-level layer wraps common GLFW concepts in plain Ruby objects.\n\n### `GLFW`\n\n- `GLFW.init` / `GLFW.terminate`\n- `GLFW.version`\n- `GLFW.version_at_least?(major, minor)`\n- `GLFW.poll_events`\n- `GLFW.wait_events(timeout: nil)`\n- `GLFW.post_empty_event`\n- `GLFW.time` / `GLFW.time=`\n- `GLFW.clipboard` / `GLFW.clipboard=`\n- `GLFW.platform` (`GLFW 3.4+` runtime only)\n- `GLFW.platform_supported?(platform_constant)` (`GLFW 3.4+` runtime only)\n- `GLFW.on_error { |code, description| ... }`\n\n### `GLFW::Window`\n\nSupports window creation, context management, input polling, attributes, and callbacks.\n\nExamples of supported operations:\n\n- title, size, position, framebuffer size, frame size, content scale, opacity\n- show / hide / focus / maximize / restore / iconify\n- fullscreen and windowed transitions\n- icon updates via `set_icon` / `clear_icon`\n- cursor assignment and cursor position access\n- keyboard and mouse input queries\n- callbacks such as `on_key`, `on_char`, `on_mouse_button`, `on_cursor_pos`, `on_scroll`, `on_drop`, `on_resize`, `on_close`, and more\n\nWindow hints are passed as keyword arguments:\n\n```ruby\nwindow = GLFW::Window.new(\n  1280,\n  720,\n  \"Example\",\n  visible: false,\n  resizable: true,\n  opengl_profile: :core,\n  context_version_major: 4,\n  context_version_minor: 1\n)\n```\n\n### `GLFW::Monitor`\n\n- `GLFW::Monitor.all`\n- `GLFW::Monitor.primary`\n- monitor name, position, workarea, physical size, content scale\n- video modes and current video mode\n- gamma and gamma ramps\n- hotplug callback via `GLFW::Monitor.on_connect`\n\n### `GLFW::Cursor` and `GLFW::Image`\n\n- create standard cursors with `GLFW::Cursor.standard`\n- create custom cursors from RGBA image data with `GLFW::Cursor.create`\n- build image payloads with `GLFW::Image.from_rgba`\n\n### `GLFW::Joystick` and `GLFW::Gamepad`\n\n- joystick presence, name, GUID, axes, buttons, hats\n- gamepad detection and state access\n- gamepad mapping updates\n- joystick connection callback via `GLFW::Joystick.on_connect`\n\n## Low-Level API\n\n`GLFW::API` mirrors the native C API through FFI `attach_function` declarations. Use it when you want direct access to GLFW without the object wrappers.\n\n```ruby\nrequire \"glfw\"\n\nputs GLFW::API.glfwGetVersionString\nputs GLFW::API.glfwPlatformSupported(GLFW::GLFW_PLATFORM_X11)\n```\n\nLow-level types live under `GLFW::API`, including:\n\n- `GLFWvidmode`\n- `GLFWgammaramp`\n- `GLFWimage`\n- `GLFWgamepadstate`\n- `GLFWallocator`\n\nThe binding also exposes the usual GLFW constants, error codes, window hints, platform constants, input constants, and cursor shapes.\n\n## Errors\n\nBase error classes:\n\n- `GLFW::Error`\n- `GLFW::LibraryNotFoundError`\n- `GLFW::InitError`\n- `GLFW::NotSupportedError`\n- `GLFW::APIError`\n\nIf no custom error callback is registered, `GLFW.init` installs a default callback that prints GLFW error messages to stderr.\n\n## Development\n\nInstall dependencies:\n\n```bash\nbundle install\n```\n\nRun the test suite:\n\n```bash\nbundle exec rspec\n```\n\nOr run the default task:\n\n```bash\nbundle exec rake\n```\n\nOn headless Linux, run specs under Xvfb:\n\n```bash\nxvfb-run -a bundle exec rspec\n```\n\n## Contributing\n\nIssues and pull requests are welcome at:\n\n- https://github.com/ydah/glfw-ruby\n\n## License\n\nReleased under the [MIT License](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydah%2Fglfw-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fydah%2Fglfw-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydah%2Fglfw-ruby/lists"}