8000 100+ official raylib C examples converted to Python / pyray · Issue #173 · electronstudio/raylib-python-cffi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
100+ official raylib C examples converted to Python / pyray #173
Open
@blep

Description

@blep

I’ve converted over 100+ official raylib C examples into Python using pyray, via tool-assisted conversion.
I want to hand them over to the pyray community (due to my limited availability).

The repo containing the examples and a description of the process/tool used for the conversion is available here:
https://github.com/blep/pyray_examples. I made the repo because I wanted to share the conversion process, as I think it
would be valuable for other languages (and Copilot is still free for a few weeks).

124/174 (~71%) examples work without known issues.

I don't have the time to manage such a high visibility project nowadays, and want to hand it over to the community.
I already spent way more time than I initially planned on this. I started this initially just to have a few examples
for my personal project. But with the success, I decided to take the time to convert all the examples as I think it
will be a great boon for the Python/pyray communities, and get the tedious part of migrating the examples out of the
way.

Note that I'm a total newbie when it comes to raylib and pyray (though I've used similar libraries in the past).

  • Some examples have errors, some are clearly me not knowing how to use the pyray/CFFI bindings, but some seem to be
    binding issues. I've listed all the identified issues in the project. For example:

    • raylib_official_examples/shaders/shaders_deferred_render.py: Press key 1 (switch G buffer)
      texture = rl.Texture2D() 
      ffi.error: undefined struct/union name : struct Texture2D *
  • There is also some API that (IMHO) should be improved:

    • pyray.YELLOW is a tuple. Should be a namedtuple for convenience, so we could use .r, .g...
      There are also places where a rl.Color type is expected, and pyray.YELLOW is not a rl.Color instance.
      I don't know enough to say what should be done, but from a user P.O.V. it is confusing.
    • GUI style can return negative int32 value for get_color(), but color only accepts uint32, forcing a dirty work-around:
      # PORT: "0xffff_ffff &" is a work-around for converting the negative int32 to uint32
      rl.clear_background(rl.get_color(0xffff_ffff & rl.gui_get_style(rl.DEFAULT, rl.BACKGROUND_COLOR)))
    • rl.set_shader_value() only accepts a pointer for the value which makes it very painful/verbose to use

Please note that, due to my full-time job and other commitments, my response time may be delayed (two days or more).

Feel free to use or copy anything from the repository without waiting for my feedback, or I can transfer ownership...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0