kojix2 / LibUI

A portable GUI library for Ruby
MIT License
208 stars 10 forks source link

Two duplicate lines, I think, at: https://github.com/kojix2/LibUI/blob/main/examples/draw_text.rb#L92 #74

Closed rubyFeedback closed 1 year ago

rubyFeedback commented 1 year ago

I recently went through the examples, trying to polish them, and I think there is a duplicate line or actually two here:

https://github.com/kojix2/LibUI/blob/main/examples/draw_text.rb#L92

kojix2 commented 1 year ago

You finally committed code to the repository using git. Glad to see your great step!

rubyFeedback commented 1 year ago

\o/

Now if only I would understand C ... :)

(It's on my perpetual todo list ... but first I have to improve Java - there are many opportunities via Java too; Andy showed that via glimmer-SWT, and there is truffleruby in graalvm, as well as jruby. C and C++ are kind of the "real deal" though, even ruby is written in C.)

kojix2 commented 1 year ago

If you are interested in using C from Ruby, it is not difficult.

  1. Prepare the shared library.
  2. Check the library's header file and remember the signature of the function you want to call.
  3. Use gems like FFI or Fiddle to define the FFI module.
    1. Specify the path to the shared library.
    2. Define the method in the module using attach_function or extern.

With these steps, the module will be able to call C functions.