Skip to content

Ruby bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

License

Notifications You must be signed in to change notification settings

wilsonsilva/raylib-ruby

Repository files navigation

Raylib for Ruby

raylib-ruby logo

Ruby bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

Features

  • Feature parity with raylib 4.5
  • NO external dependencies besides raylib, all required libraries are bundled into raylib
  • Multiple platforms supported: Windows, Linux, MacOS, RPI... and more!
  • Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES 2.0)
  • Unique OpenGL abstraction layer (usable as standalone module): rlgl
  • Multiple Fonts formats supported (TTF, Image fonts, AngelCode fonts)
  • Multiple texture formats supported, including compressed formats (DXT, ETC, ASTC)
  • Full 3D support, including 3D Shapes, Models, Billboards, Heightmaps and more!
  • Flexible Materials system, supporting classic maps and PBR maps
  • Animated 3D models supported (skeletal bones animation) (IQM)
  • Shaders support, including model and postprocessing shaders.
  • Powerful math module for Vector, Matrix and Quaternion operations: raymath
  • Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
  • VR stereo rendering support with configurable HMD device parameters
  • Huge examples collection with +65 code examples!
  • Free and open source.
  • Linter for best practices: rubocop-raylib

Installation

  1. Follow the instructions on the native raylib wiki to install the native raylib library on your operating system.

  2. Install the gem by executing: bundle add raylib or gem install raylib --pre

Usage

Raylib can be used in two ways: namespaced or global.

Namespaced

The namespaced usage is recommended as it avoids global namespace pollution:

require 'raylib'

Raylib.init_window(800, 450, 'My window')

until Raylib.window_should_close
  Raylib.begin_drawing
  Raylib.clear_background(Raylib::WHITE)
  Raylib.draw_text('Congrats! You created your first window!', 190, 200, 20, Raylib::BLACK)
  Raylib.end_drawing
end

Raylib.close_window

Global

If you prefer to use Raylib globally, you can require the raylib/dsl:

require 'raylib/dsl'

init_window(800, 450, 'My window')

until window_should_close
  begin_drawing
  clear_background(WHITE)
  draw_text('Congrats! You created your first window!', 190, 200, 20, BLACK)
  end_drawing
end

close_window

In the code above, require 'raylib/dsl is a shorthand for require 'raylib' + include Raylib.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/raylib-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the zlib/libpng License.

Code of Conduct

Everyone interacting in the Raylib project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.