Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing FFI functions #5

Open
julik opened this issue Jun 7, 2024 · 4 comments
Open

Missing FFI functions #5

julik opened this issue Jun 7, 2024 · 4 comments

Comments

@julik
Copy link

julik commented Jun 7, 2024

Hi! I've tried to play with the project a bit, but I don't manage to get the script to run. I get this error:

julik@jet <redacted> $ ruby window.rb 
/Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/library.rb:216:in `attach_function': Function 'DrawLineBezierQuad' not found in [libraylib.dylib] (FFI::NotFoundError)
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/raylib-4.5.0.alpha1/lib/raylib/core/functions.rb:582:in `<module:Raylib>'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/raylib-4.5.0.alpha1/lib/raylib/core/functions.rb:1:in `<top (required)>'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/raylib-4.5.0.alpha1/lib/raylib/core.rb:5:in `<top (required)>'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/raylib-4.5.0.alpha1/lib/raylib.rb:12:in `<top (required)>'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:141:in `require'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:141:in `rescue in require'
	from <internal:/Users/julik/.rbenv/versions/3.3.1/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:135:in `require'
	from window.rb:1:in `<main>

I've looked for the function in the raylib GH repo but it doesn't show anywhere. Could it be that the FFI bindings need to be regenerated from time to time?

Ruby is

julik@jet banksvc (main) $ ruby -v
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-darwin21]

and this is macOS Monterey (10.12) and raylib is installed using brew (brew install raylib)

@julik julik changed the title Missing FFI function Missing FFI functions Jun 7, 2024
@julik
Copy link
Author

julik commented Jun 7, 2024

After commenting a few function bindings (GenImageGradientV, GenImageGradientH, DrawLineBezierQuad and DrawLineBezierCubic) the script does start, but then quits with

julik@jet banksvc (main) $ ruby window.rb 
INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 2560 x 1440
INFO:     > Screen size:  640 x 480
INFO:     > Render size:  640 x 480
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 46
INFO: GL: OpenGL device information:
INFO:     > Vendor:   ATI Technologies Inc.
INFO:     > Renderer: AMD Radeon HD - FirePro D700 OpenGL Engine
INFO:     > Version:  4.1 ATI-4.8.101
INFO:     > GLSL:     4.10
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
[DEPRECATION] Struct layout is already defined for class Raylib::Vector2. Redefinition as in window.rb:9:in `initialize' will be disallowed in ffi-2.0.
/Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/types.rb:94:in `find_type': unable to resolve type '' (TypeError)

        raise TypeError, "unable to resolve type '#{name}'"
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/library.rb:415:in `find_type'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/struct.rb:278:in `find_type'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/struct.rb:272:in `find_field_type'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/struct.rb:312:in `array_layout'
	from /Users/julik/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi/struct.rb:218:in `layout'
	from window.rb:9:in `initialize'
	from window.rb:9:in `new'
	from window.rb:9:in `<main>'

That is on the initialization of the Vector2. What version of raylib is actually supported with these bindings?

@wilsonsilva
Copy link
Owner

Hello @julik these bindings are for Raylib 4.5. They released version 5.0 about 6 months ago. I haven't looked into this yet, but can you try to install an earlier version of the native homebrew raylib package?

@julik
Copy link
Author

julik commented Jun 7, 2024

It doesn't look like Homebrew has an older formula with a version, so I would have to install all the way from scratch (which is a bit terrifying) 😱 Is there a way to regen the bindings?

@wilsonsilva
Copy link
Owner

@julik, the link to the archive is still valid. Homebrew stores the formulas in a git repository, so there's surely a way to point your homebrew to an earlier version.

https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula

Alternatively, you'll need to compile raylib from the source. With their Makefiles, you should't run into any issues.

Upgrading the bindings from Raylib v4.5 to v5.0 is not an easy task. There are a lot of dependencies. I'll need to check the validity of every function and manually test all examples. I'll do it someday.

In any case, thanks for bringing this to my attention! This explains why the project stopped getting stars. I'll update the documentation at some point and even implement a version check with troubleshooting instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants