Compare commits

...
This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.

17 commits

Author SHA1 Message Date
249b5b7c35
chore: Switch git submodule path
Some checks failed
Build / build-linux (3.13, SDL) (push) Has been cancelled
Build / build-linux (3.9, DRM) (push) Has been cancelled
Build / build-linux (3.9, Desktop) (push) Has been cancelled
Build / build-linux (3.9, SDL) (push) Has been cancelled
Build / build-linux (pypy-3.10, DRM) (push) Has been cancelled
Build / build-linux (pypy-3.10, Desktop) (push) Has been cancelled
Build / build-linux (pypy-3.10, SDL) (push) Has been cancelled
Build / build-linux (pypy-3.11, DRM) (push) Has been cancelled
Build / build-linux (pypy-3.11, Desktop) (push) Has been cancelled
Build / build-linux (pypy-3.11, SDL) (push) Has been cancelled
Build / build-linux (pypy-3.9, DRM) (push) Has been cancelled
Build / build-linux (pypy-3.9, Desktop) (push) Has been cancelled
Build / build-linux (pypy-3.9, SDL) (push) Has been cancelled
Build / build-windows (3.10, Desktop) (push) Has been cancelled
Build / build-windows (3.10, SDL) (push) Has been cancelled
Build / build-windows (3.11, Desktop) (push) Has been cancelled
Build / build-windows (3.11, SDL) (push) Has been cancelled
Build / build-windows (3.12, Desktop) (push) Has been cancelled
Build / build-windows (3.12, SDL) (push) Has been cancelled
Build / build-windows (3.13, Desktop) (push) Has been cancelled
Build / build-windows (3.13, SDL) (push) Has been cancelled
Build / build-windows (3.9, Desktop) (push) Has been cancelled
Build / build-windows (3.9, SDL) (push) Has been cancelled
Build / build-windows (pypy-3.10, Desktop) (push) Has been cancelled
Build / build-windows (pypy-3.10, SDL) (push) Has been cancelled
Build / build-windows (pypy-3.11, Desktop) (push) Has been cancelled
Build / build-windows (pypy-3.11, SDL) (push) Has been cancelled
Build / build-windows (pypy-3.9, Desktop) (push) Has been cancelled
Build / build-windows (pypy-3.9, SDL) (push) Has been cancelled
Build / merge (push) Has been cancelled
2025-06-08 11:39:27 -04:00
1e195e4ac9
fix: Fix DRM leasing support
Some checks failed
Build / build-windows (pypy-3.10, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.10, SDL) (push) Waiting to run
Build / build-windows (pypy-3.11, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.11, SDL) (push) Waiting to run
Build / build-windows (pypy-3.9, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.9, SDL) (push) Waiting to run
Build / source-distro (push) Waiting to run
Build / dynamic-distro (push) Waiting to run
Build / merge (push) Blocked by required conditions
Build / build-mac-intel (3.10, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.10, SDL) (push) Has been cancelled
Build / build-mac-intel (3.11, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.11, SDL) (push) Has been cancelled
Build / build-mac-intel (3.12, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.12, SDL) (push) Has been cancelled
Build / build-mac-intel (3.13, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.13, SDL) (push) Has been cancelled
Build / build-mac-intel (3.9, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.9, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.10, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.10, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.11, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.11, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.9, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.9, SDL) (push) Has been cancelled
Build / build-linux (3.10, DRM) (push) Has been cancelled
Build / build-linux (3.10, Desktop) (push) Has been cancelled
Build / build-linux (3.10, SDL) (push) Has been cancelled
Build / build-linux (3.11, DRM) (push) Has been cancelled
Build / build-linux (3.11, Desktop) (push) Has been cancelled
2025-06-08 08:31:27 -04:00
51e50d4cb9
chore: Switch out submodules and add a nix shell
Some checks failed
Build / build-windows (pypy-3.10, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.10, SDL) (push) Waiting to run
Build / build-windows (pypy-3.11, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.11, SDL) (push) Waiting to run
Build / build-windows (pypy-3.9, Desktop) (push) Waiting to run
Build / build-windows (pypy-3.9, SDL) (push) Waiting to run
Build / source-distro (push) Waiting to run
Build / dynamic-distro (push) Waiting to run
Build / build-mac-intel (3.10, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.10, SDL) (push) Has been cancelled
Build / build-mac-intel (3.11, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.11, SDL) (push) Has been cancelled
Build / build-mac-intel (3.12, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.12, SDL) (push) Has been cancelled
Build / build-mac-intel (3.13, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.13, SDL) (push) Has been cancelled
Build / build-mac-intel (3.9, Desktop) (push) Has been cancelled
Build / build-mac-intel (3.9, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.10, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.10, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.11, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.11, SDL) (push) Has been cancelled
Build / build-mac-intel (pypy-3.9, Desktop) (push) Has been cancelled
Build / build-mac-intel (pypy-3.9, SDL) (push) Has been cancelled
Build / build-linux (3.10, DRM) (push) Has been cancelled
Build / build-linux (3.10, Desktop) (push) Has been cancelled
Build / build-linux (3.10, SDL) (push) Has been cancelled
Build / build-linux (3.11, DRM) (push) Has been cancelled
Build / build-linux (3.11, Desktop) (push) Has been cancelled
Build / build-linux (3.11, SDL) (push) Has been cancelled
2025-06-07 20:19:23 -04:00
Richard Smith
8e85d28ca8 add audio examples 2025-06-04 17:00:08 +01:00
Cameron Clough
8d5d810925
Switch to logging in __init__.py, set load message to debug (#171)
* Switch to logging in `__init__.py`, set load message to debug

- Replace print statements with logger.error() and logger.warning() calls.
- Follow best practices by using a module-specific logger via
  getLogger(__name__).
- Use parameterized log messages to avoid unnecessary string formatting.
- Change the "RAYLIB STATIC x.x.x LOADED" message from direct stderr
  output to logger warning level.

Motivation:
In [commaai/openpilot#35076][openpilot-issue], we experienced noisy test
outputs because the RAYLIB STATIC message is printed unnecessarily,
cluttering stderr. This change allows library consumers to control the
visibility of this message.

[openpilot-issue]: https://github.com/commaai/openpilot/issues/35076

* use warning rather than debug logging

---------

Co-authored-by: Richard Smith <github@electronstudio.co.uk>
2025-06-04 15:55:41 +01:00
Richard Smith
c58d89fd86 add example 2025-05-27 19:57:35 +01:00
Richard Smith
f551fca1f3 hack stub files because enum from Physac isn't recognised by raylib header parser 2025-05-27 19:54:53 +01:00
Richard Smith
11c5b1a728 use typedefs when constructing structs 2025-05-27 14:53:20 +01:00
Baptiste Lepilleur
d3fcb40408
* fix hard-coded path in Windows build. (#174) 2025-05-21 12:30:20 +01:00
Richard Smith
d8e4385990 try to fix cirrus build by using system pip 2025-05-03 20:38:31 +01:00
Richard Smith
7971275111 try to fix windows build by disabling threads in Physac 2025-05-03 19:53:01 +01:00
Max Golubev
2df1ac470b
Update physac example (#168) 2025-05-03 19:41:59 +01:00
Richard Smith
67e6bf2405 add @victorfisac version of Physac 2025-05-03 19:40:15 +01:00
Richard Smith
5575f6b7b0 remove raylib Physac repo 2025-05-03 19:33:23 +01:00
Richard Smith
171177618b deprecate Physac, see #165 2025-05-03 19:03:36 +01:00
Richard Smith
5593f2e392 add docstrings for structs and enums, fixes issue #159 2025-05-03 18:06:27 +01:00
Richard Smith
002e4ca4d9 update github actions to oldest supported ubuntu version 2025-05-03 17:12:42 +01:00
48 changed files with 10495 additions and 9903 deletions

View file

@ -137,7 +137,6 @@ mac_task:
- sudo cp -r raylib-c/src/external/glfw/include/GLFW /usr/local/include/
- sudo cp physac/src/physac.h /usr/local/include/
- sudo cp raygui/src/raygui.h /usr/local/include/
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages --upgrade pip
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages cffi
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages setuptools
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages wheel

View file

@ -182,7 +182,7 @@ jobs:
build-linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
# You can use PyPy versions in python-version.
# For example, pypy2 and pypy3

4
.gitmodules vendored
View file

@ -1,9 +1,9 @@
[submodule "raylib-c"]
path = raylib-c
url = https://github.com/raysan5/raylib.git
url = https://git.terah.dev/UnrealXR/raylib.git
[submodule "raygui"]
path = raygui
url = https://github.com/raysan5/raygui.git
[submodule "physac"]
path = physac
url = https://github.com/raysan5/physac.git
url = https://github.com/victorfisac/Physac.git

View file

@ -83,11 +83,6 @@ To build a binary wheel distribution:
pip3 install wheel
python setup.py bdist_wheel
.. TODO::
There's a hardcoded path (to the raylib header files) in `raylib/build.py` you will probably need to edit.
Would be useful if some Windows user could figure out how to auto detect this.
Then install it:
::

View file

@ -24,6 +24,7 @@ def process(filename):
for e in js['enums']:
if e['name'] and e['values']:
print ("class "+e['name']+"("+"IntEnum):")
print(f' """{e['description']}."""')
for value in e['values']:
print(" "+value['name']+" = "+str(value['value']))
print("")
@ -34,3 +35,4 @@ print("""from enum import IntEnum
process("raylib.json")
process("raygui.json")
process("glfw3.json")
process("physac.json")

View file

@ -32,7 +32,8 @@ for filename in (Path("raylib.json"), Path("raymath.json"), Path("rlgl.json"), P
known_structs[st["name"]] = st
for e in js['enums']:
if e['name'] and e['values']:
print ("class "+e['name']+"(int):")
print("class "+e['name']+"(int):")
print(f' """{e['description']}."""')
for value in e['values']:
print(" "+value['name']+" = "+str(value['value']))
print("")
@ -78,10 +79,11 @@ def ctype_to_python_type(t):
print("""from typing import Any
from warnings import deprecated
import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
PhysicsShapeType = int
""")
# These words can be used for c arg names, but not in python
@ -118,8 +120,11 @@ for name, attr in getmembers(rl):
if 'description' in json_object:
description = json_object['description']
print(
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
if 'physics' in uname:
print('@deprecated("Raylib no longer recommends the use of Physac library")')
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
print(f' """{description}."""')
print(f' ...')
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
return_type = ffi.typeof(attr).result.cname
@ -144,7 +149,7 @@ for struct in ffi.list_types()[0]:
print("weird empty struct, skipping " + struct, file=sys.stderr)
continue
print(f"class {struct}:")
print(f' """ struct """')
print(f' """{known_structs[struct]['description']}."""')
sig = ""
for arg in ffi.typeof(struct).fields:
ptype = ctype_to_python_type(arg[1].type.cname)

View file

@ -69,11 +69,12 @@ def ctype_to_python_type(t):
print("""from typing import Any
from warnings import deprecated
import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...
@ -114,8 +115,12 @@ for name, attr in getmembers(rl):
if 'description' in json_object:
description = json_object['description']
print(
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
if 'Physics' in uname:
print('@deprecated("Raylib no longer recommends the use of Physac library")')
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
print(f' """{description}."""')
print(f' ...')
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
return_type = ffi.typeof(attr).result.cname

View file

@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 6b88b88b20947586d6498748ffd23a92
config: f2032a6434b52f7c68551d0ad70d555b
tags: 645f666f9bcd5a90fca523b33c5a78b7

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Building from source &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Bindings for Raylib 5.5 &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -142,7 +142,7 @@ original Raylib.</p></li>
<section id="quickstart">
<h1>Quickstart<a class="headerlink" href="#quickstart" title="Link to this heading"></a></h1>
<p><code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span> <span class="pre">raylib==5.5.0.2</span> <span class="pre">--break-system-packages</span></code></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyray</span> <span class="kn">import</span> <span class="o">*</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<span class="n">init_window</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">450</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>
<span class="n">begin_drawing</span><span class="p">()</span>
@ -202,7 +202,7 @@ so may not work on other boards.</p>
</section>
<section id="raspberry-pi">
<h2>Raspberry Pi<a class="headerlink" href="#raspberry-pi" title="Link to this heading"></a></h2>
<p><a class="reference internal" href="RPI.html"><span class="std std-doc">Using on Rasperry Pi</span></a></p>
<p><span class="xref myst">Using on Rasperry Pi</span></p>
</section>
</section>
<section id="backends">
@ -237,7 +237,7 @@ python3 -m pip install raylib_drm
</section>
<section id="problems">
<h2>Problems?<a class="headerlink" href="#problems" title="Link to this heading"></a></h2>
<p>If it doesnt work, <a class="reference internal" href="BUILDING.html"><span class="std std-doc">try to build manually.</span></a>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
<p>If it doesnt work, <span class="xref myst">try to build manually.</span>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
to let us know what you did.</p>
<p>If you need help you can try asking on <a class="reference external" href="https://discord.gg/fKDwt85aX6">our discord</a>. There is also a large <a class="reference external" href="https://discord.gg/raylib">Raylib discord</a>
for issues that are not Python-specific.</p>
@ -268,11 +268,11 @@ is recommended.</p>
<span class="c1"># &quot;raylib&quot;</span>
<span class="c1"># ]</span>
<span class="c1"># ///</span>
<span class="kn">import</span> <span class="nn">asyncio</span>
<span class="kn">import</span> <span class="nn">platform</span>
<span class="kn">from</span> <span class="nn">pyray</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">platform</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">main</span><span class="p">():</span> <span class="c1"># You MUST have an async main function</span>
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span> <span class="c1"># You MUST have an async main function</span>
<span class="n">init_window</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="mi">500</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
<span class="n">platform</span><span class="o">.</span><span class="n">window</span><span class="o">.</span><span class="n">window_resize</span><span class="p">()</span> <span class="c1"># You MAY want to add this line</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raspberry Pi &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

View file

@ -741,14 +741,6 @@ abbr, acronym {
cursor: help;
}
.translated {
background-color: rgba(207, 255, 207, 0.2)
}
.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}
/* -- code displays --------------------------------------------------------- */
pre {

View file

@ -1,6 +1,6 @@
const themeFlyoutDisplay = "hidden";
const themeVersionSelector = "True";
const themeLanguageSelector = "True";
const themeVersionSelector = true;
const themeLanguageSelector = true;
if (themeFlyoutDisplay === "attached") {
function renderLanguages(config) {
@ -8,10 +8,14 @@ if (themeFlyoutDisplay === "attached") {
return "";
}
// Insert the current language to the options on the selector
let languages = config.projects.translations.concat(config.projects.current);
languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));
const languagesHTML = `
<dl>
<dt>Languages</dt>
${config.projects.translations
${languages
.map(
(translation) => `
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>

View file

@ -6,26 +6,26 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .err { border: 1px solid #F00 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .o { color: #666 } /* Operator */
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .cs { color: #408090; background-color: #FFF0F0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gr { color: #F00 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .go { color: #333 } /* Generic.Output */
.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .gt { color: #04D } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
@ -33,43 +33,43 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .s { color: #4070A0 } /* Literal.String */
.highlight .na { color: #4070A0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60ADD5 } /* Name.Constant */
.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nf { color: #06287E } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nn { color: #0E84B5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .nv { color: #BB60D5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .w { color: #BBB } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sa { color: #4070A0 } /* Literal.String.Affix */
.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070A0 } /* Literal.String.Char */
.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070A0 } /* Literal.String.Double */
.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */
.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #C65D09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .s1 { color: #4070A0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #06287e } /* Name.Function.Magic */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
.highlight .fm { color: #06287E } /* Name.Function.Magic */
.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */
.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */
.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */
.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */

View file

@ -513,9 +513,11 @@ const Search = {
// perform the search on the required terms
searchTerms.forEach((word) => {
const files = [];
// find documents, if any, containing the query word in their text/title term indices
// use Object.hasOwnProperty to avoid mismatching against prototype properties
const arr = [
{ files: terms[word], score: Scorer.term },
{ files: titleTerms[word], score: Scorer.title },
{ files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term },
{ files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title },
];
// add support for partial matches
if (word.length > 2) {
@ -547,8 +549,9 @@ const Search = {
// set score for the word in each file
recordFiles.forEach((file) => {
if (!scoreMap.has(file)) scoreMap.set(file, {});
scoreMap.get(file)[word] = record.score;
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
const fileScores = scoreMap.get(file);
fileScores.set(word, record.score);
});
});
@ -587,7 +590,7 @@ const Search = {
break;
// select one (max) score for the file.
const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w)));
// add result to the result list
results.push([
docNames[file],

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamic Bindings &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -104,11 +104,11 @@ Therefore I personally recommend the static ones.
But the dynamic bindings have the advantage that you dont need to compile anything to install. You just need a Raylib DLL.</p>
</div>
<p>The API is exactly the same as the static one documented here. (Therefore you cant have both modules installed at once.) The only difference is you cant do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="o">*</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">raylib</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
</pre></div>
</div>
<p>Instead you have to do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="n">rl</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">raylib</span><span class="w"> </span><span class="kn">import</span> <span class="n">rl</span>
</pre></div>
</div>
<p>Then you access the functions with <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix.</p>

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raylib Python &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />

File diff suppressed because one or more lines are too long

View file

@ -22,9 +22,10 @@ import itertools
import os
import pathlib
import platform
import logging
from .version import __version__
logger = logging.getLogger(__name__)
MODULE = pathlib.Path(__file__).parent
def raylib_library_path():
@ -54,9 +55,9 @@ ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
try:
raylib_fname = raylib_library_path()
rl = ffi.dlopen(raylib_fname)
print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
logger.warning('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
except Exception as e:
print(e)
logger.exception(e)
LIGHTGRAY =( 200, 200, 200, 255 )
GRAY =( 130, 130, 130, 255 )

File diff suppressed because it is too large Load diff

View file

@ -186,12 +186,10 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
PHYSAC_MAX_BODIES: int = 64
PHYSAC_MAX_MANIFOLDS: int = 4096
PHYSAC_MAX_VERTICES: int = 24
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 100
PHYSAC_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 20
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
PHYSAC_PENETRATION_CORRECTION: float = 0.4
PHYSAC_PI: float = 3.141592653589793
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
PHYSAC_FLT_MAX: float = 3.402823466e+38
PHYSAC_EPSILON: float = 1e-06
GLFW_VERSION_MAJOR: int = 3

View file

@ -1,6 +1,7 @@
from enum import IntEnum
class ConfigFlags(IntEnum):
"""System/Window config flags."""
FLAG_VSYNC_HINT = 64
FLAG_FULLSCREEN_MODE = 2
FLAG_WINDOW_RESIZABLE = 4
@ -19,6 +20,7 @@ class ConfigFlags(IntEnum):
FLAG_INTERLACED_HINT = 65536
class TraceLogLevel(IntEnum):
"""Trace log level."""
LOG_ALL = 0
LOG_TRACE = 1
LOG_DEBUG = 2
@ -29,6 +31,7 @@ class TraceLogLevel(IntEnum):
LOG_NONE = 7
class KeyboardKey(IntEnum):
"""Keyboard keys (US keyboard layout)."""
KEY_NULL = 0
KEY_APOSTROPHE = 39
KEY_COMMA = 44
@ -141,6 +144,7 @@ class KeyboardKey(IntEnum):
KEY_VOLUME_DOWN = 25
class MouseButton(IntEnum):
"""Mouse buttons."""
MOUSE_BUTTON_LEFT = 0
MOUSE_BUTTON_RIGHT = 1
MOUSE_BUTTON_MIDDLE = 2
@ -150,6 +154,7 @@ class MouseButton(IntEnum):
MOUSE_BUTTON_BACK = 6
class MouseCursor(IntEnum):
"""Mouse cursor."""
MOUSE_CURSOR_DEFAULT = 0
MOUSE_CURSOR_ARROW = 1
MOUSE_CURSOR_IBEAM = 2
@ -163,6 +168,7 @@ class MouseCursor(IntEnum):
MOUSE_CURSOR_NOT_ALLOWED = 10
class GamepadButton(IntEnum):
"""Gamepad buttons."""
GAMEPAD_BUTTON_UNKNOWN = 0
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
@ -183,6 +189,7 @@ class GamepadButton(IntEnum):
GAMEPAD_BUTTON_RIGHT_THUMB = 17
class GamepadAxis(IntEnum):
"""Gamepad axis."""
GAMEPAD_AXIS_LEFT_X = 0
GAMEPAD_AXIS_LEFT_Y = 1
GAMEPAD_AXIS_RIGHT_X = 2
@ -191,6 +198,7 @@ class GamepadAxis(IntEnum):
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
class MaterialMapIndex(IntEnum):
"""Material map index."""
MATERIAL_MAP_ALBEDO = 0
MATERIAL_MAP_METALNESS = 1
MATERIAL_MAP_NORMAL = 2
@ -204,6 +212,7 @@ class MaterialMapIndex(IntEnum):
MATERIAL_MAP_BRDF = 10
class ShaderLocationIndex(IntEnum):
"""Shader location index."""
SHADER_LOC_VERTEX_POSITION = 0
SHADER_LOC_VERTEX_TEXCOORD01 = 1
SHADER_LOC_VERTEX_TEXCOORD02 = 2
@ -235,6 +244,7 @@ class ShaderLocationIndex(IntEnum):
SHADER_LOC_BONE_MATRICES = 28
class ShaderUniformDataType(IntEnum):
"""Shader uniform data type."""
SHADER_UNIFORM_FLOAT = 0
SHADER_UNIFORM_VEC2 = 1
SHADER_UNIFORM_VEC3 = 2
@ -246,12 +256,14 @@ class ShaderUniformDataType(IntEnum):
SHADER_UNIFORM_SAMPLER2D = 8
class ShaderAttributeDataType(IntEnum):
"""Shader attribute data types."""
SHADER_ATTRIB_FLOAT = 0
SHADER_ATTRIB_VEC2 = 1
SHADER_ATTRIB_VEC3 = 2
SHADER_ATTRIB_VEC4 = 3
class PixelFormat(IntEnum):
"""Pixel formats."""
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
@ -278,6 +290,7 @@ class PixelFormat(IntEnum):
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
class TextureFilter(IntEnum):
"""Texture parameters: filter mode."""
TEXTURE_FILTER_POINT = 0
TEXTURE_FILTER_BILINEAR = 1
TEXTURE_FILTER_TRILINEAR = 2
@ -286,12 +299,14 @@ class TextureFilter(IntEnum):
TEXTURE_FILTER_ANISOTROPIC_16X = 5
class TextureWrap(IntEnum):
"""Texture parameters: wrap mode."""
TEXTURE_WRAP_REPEAT = 0
TEXTURE_WRAP_CLAMP = 1
TEXTURE_WRAP_MIRROR_REPEAT = 2
TEXTURE_WRAP_MIRROR_CLAMP = 3
class CubemapLayout(IntEnum):
"""Cubemap layouts."""
CUBEMAP_LAYOUT_AUTO_DETECT = 0
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
@ -299,11 +314,13 @@ class CubemapLayout(IntEnum):
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
class FontType(IntEnum):
"""Font type, defines generation method."""
FONT_DEFAULT = 0
FONT_BITMAP = 1
FONT_SDF = 2
class BlendMode(IntEnum):
"""Color blending modes (pre-defined)."""
BLEND_ALPHA = 0
BLEND_ADDITIVE = 1
BLEND_MULTIPLIED = 2
@ -314,6 +331,7 @@ class BlendMode(IntEnum):
BLEND_CUSTOM_SEPARATE = 7
class Gesture(IntEnum):
"""Gesture."""
GESTURE_NONE = 0
GESTURE_TAP = 1
GESTURE_DOUBLETAP = 2
@ -327,6 +345,7 @@ class Gesture(IntEnum):
GESTURE_PINCH_OUT = 512
class CameraMode(IntEnum):
"""Camera system modes."""
CAMERA_CUSTOM = 0
CAMERA_FREE = 1
CAMERA_ORBITAL = 2
@ -334,36 +353,43 @@ class CameraMode(IntEnum):
CAMERA_THIRD_PERSON = 4
class CameraProjection(IntEnum):
"""Camera projection."""
CAMERA_PERSPECTIVE = 0
CAMERA_ORTHOGRAPHIC = 1
class NPatchLayout(IntEnum):
"""N-patch layout."""
NPATCH_NINE_PATCH = 0
NPATCH_THREE_PATCH_VERTICAL = 1
NPATCH_THREE_PATCH_HORIZONTAL = 2
class GuiState(IntEnum):
"""Gui control state."""
STATE_NORMAL = 0
STATE_FOCUSED = 1
STATE_PRESSED = 2
STATE_DISABLED = 3
class GuiTextAlignment(IntEnum):
"""Gui control text alignment."""
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_CENTER = 1
TEXT_ALIGN_RIGHT = 2
class GuiTextAlignmentVertical(IntEnum):
"""Gui control text alignment vertical."""
TEXT_ALIGN_TOP = 0
TEXT_ALIGN_MIDDLE = 1
TEXT_ALIGN_BOTTOM = 2
class GuiTextWrapMode(IntEnum):
"""Gui control text wrap mode."""
TEXT_WRAP_NONE = 0
TEXT_WRAP_CHAR = 1
TEXT_WRAP_WORD = 2
class GuiControl(IntEnum):
"""Gui controls."""
DEFAULT = 0
LABEL = 1
BUTTON = 2
@ -382,6 +408,7 @@ class GuiControl(IntEnum):
STATUSBAR = 15
class GuiControlProperty(IntEnum):
"""Gui base properties for every control."""
BORDER_COLOR_NORMAL = 0
BASE_COLOR_NORMAL = 1
TEXT_COLOR_NORMAL = 2
@ -399,6 +426,7 @@ class GuiControlProperty(IntEnum):
TEXT_ALIGNMENT = 14
class GuiDefaultProperty(IntEnum):
"""DEFAULT extended properties."""
TEXT_SIZE = 16
TEXT_SPACING = 17
LINE_COLOR = 18
@ -408,16 +436,20 @@ class GuiDefaultProperty(IntEnum):
TEXT_WRAP_MODE = 22
class GuiToggleProperty(IntEnum):
"""Toggle/ToggleGroup."""
GROUP_PADDING = 16
class GuiSliderProperty(IntEnum):
"""Slider/SliderBar."""
SLIDER_WIDTH = 16
SLIDER_PADDING = 17
class GuiProgressBarProperty(IntEnum):
"""ProgressBar."""
PROGRESS_PADDING = 16
class GuiScrollBarProperty(IntEnum):
"""ScrollBar."""
ARROWS_SIZE = 16
ARROWS_VISIBLE = 17
SCROLL_SLIDER_PADDING = 18
@ -426,26 +458,32 @@ class GuiScrollBarProperty(IntEnum):
SCROLL_SPEED = 21
class GuiCheckBoxProperty(IntEnum):
"""CheckBox."""
CHECK_PADDING = 16
class GuiComboBoxProperty(IntEnum):
"""ComboBox."""
COMBO_BUTTON_WIDTH = 16
COMBO_BUTTON_SPACING = 17
class GuiDropdownBoxProperty(IntEnum):
"""DropdownBox."""
ARROW_PADDING = 16
DROPDOWN_ITEMS_SPACING = 17
DROPDOWN_ARROW_HIDDEN = 18
DROPDOWN_ROLL_UP = 19
class GuiTextBoxProperty(IntEnum):
"""TextBox/TextBoxMulti/ValueBox/Spinner."""
TEXT_READONLY = 16
class GuiSpinnerProperty(IntEnum):
"""Spinner."""
SPIN_BUTTON_WIDTH = 16
SPIN_BUTTON_SPACING = 17
class GuiListViewProperty(IntEnum):
"""ListView."""
LIST_ITEMS_HEIGHT = 16
LIST_ITEMS_SPACING = 17
SCROLLBAR_WIDTH = 18
@ -453,6 +491,7 @@ class GuiListViewProperty(IntEnum):
LIST_ITEMS_BORDER_WIDTH = 20
class GuiColorPickerProperty(IntEnum):
"""ColorPicker."""
COLOR_SELECTOR_SIZE = 16
HUEBAR_WIDTH = 17
HUEBAR_PADDING = 18
@ -460,6 +499,7 @@ class GuiColorPickerProperty(IntEnum):
HUEBAR_SELECTOR_OVERFLOW = 20
class GuiIconName(IntEnum):
"""."""
ICON_NONE = 0
ICON_FOLDER_FILE_OPEN = 1
ICON_FILE_SAVE_CLASSIC = 2

View file

@ -0,0 +1,101 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Music playing (streaming)
Example complexity rating: [] 1/4
Example originally created with raylib 1.3, last time updated with raylib 4.0
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
# ------------------------------------------------------------------------------------
# Program main entry point
# ------------------------------------------------------------------------------------
def main():
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width,
screen_height,
"raylib [audio] example - music playing (streaming)",
)
rl.init_audio_device() # Initialize audio device
music = rl.load_music_stream(str(THIS_DIR / "resources/country.mp3"))
rl.play_music_stream(music)
time_played = 0.0 # Time played normalized [0.0f..1.0f]
pause = False # Music playing paused
rl.set_target_fps(30) # Set our game to run at 30 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
rl.update_music_stream(music) # Update music buffer with new stream data
# Restart music playing (stop and play)
if rl.is_key_pressed(rl.KEY_SPACE):
rl.stop_music_stream(music)
rl.play_music_stream(music)
# Pause/Resume music playing
if rl.is_key_pressed(rl.KEY_P):
pause = not pause
if pause:
rl.pause_music_stream(music)
else:
rl.resume_music_stream(music)
# Get normalized time played for current music stream
time_played = rl.get_music_time_played(music) / rl.get_music_time_length(music)
if time_played > 1.0:
time_played = 1.0 # Make sure time played is no longer than music
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.LIGHTGRAY)
rl.draw_rectangle(200, 200, 400, 12, rl.LIGHTGRAY)
rl.draw_rectangle(200, 200, int(time_played * 400.0), 12, rl.MAROON)
rl.draw_rectangle_lines(200, 200, 400, 12, rl.GRAY)
rl.draw_text("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.LIGHTGRAY)
rl.draw_text("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_music_stream(music) # Unload music stream buffers from RAM
rl.close_audio_device() # Close audio device (music streaming is automatically stopped)
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------
if __name__ == "__main__":
main()

View file

@ -0,0 +1,67 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Sound loading and playing
Example complexity rating: [] 1/4
Example originally created with raylib 1.1, last time updated with raylib 3.5
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - sound loading and playing"
)
rl.init_audio_device() # Initialize audio device
# Load WAV audio file using proper path resolution
fx_wav = rl.load_sound(str(THIS_DIR / "resources/sound.wav"))
# Load OGG audio file using proper path resolution
fx_ogg = rl.load_sound(str(THIS_DIR / "resources/target.ogg"))
rl.set_target_fps(60) # Set our game to run at 60 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
if rl.is_key_pressed(rl.KeyboardKey.KEY_SPACE):
rl.play_sound(fx_wav) # Play WAV sound
if rl.is_key_pressed(rl.KeyboardKey.KEY_ENTER):
rl.play_sound(fx_ogg) # Play OGG sound
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.LIGHTGRAY)
rl.draw_text("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_sound(fx_wav) # Unload sound data
rl.unload_sound(fx_ogg) # Unload sound data
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

View file

@ -0,0 +1,86 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Playing sound multiple times
Example complexity rating: [] 2/4
Example originally created with raylib 4.6, last time updated with raylib 4.6
Example contributed by Jeffery Myers (@JeffM2501) and reviewed by Ramon Santamaria (@raysan5)
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2023-2025 Jeffery Myers (@JeffM2501)
This source has been converted from C raylib examples to Python.
"""
from typing import List
import pyray as rl
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
MAX_SOUNDS = 10
sound_array: List[rl.Sound] = []
current_sound = 0
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - playing sound multiple times"
)
rl.init_audio_device() # Initialize audio device
# Load the sound list
sound_array.append(
rl.load_sound(str(THIS_DIR / "resources/sound.wav"))
) # Load WAV audio file into the first slot as the 'source' sound
# this sound owns the sample data
for i in range(1, MAX_SOUNDS):
sound_array.append(
rl.load_sound_alias(sound_array[0])
) # Load an alias of the sound into slots 1-9
# These do not own the sound data, but can be played
current_sound = 0 # Set the sound list to the start
rl.set_target_fps(60) # Set our game to run at 60 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
if rl.is_key_pressed(rl.KeyboardKey.KEY_SPACE):
rl.play_sound(sound_array[current_sound]) # Play the next open sound slot
current_sound += 1 # Increment the sound slot
if (
current_sound >= MAX_SOUNDS
): # If the sound slot is out of bounds, go back to 0
current_sound = 0
# Note: a better way would be to look at the list for the first sound that is not playing and use that slot
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("Press SPACE to PLAY a WAV sound!", 200, 180, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
for i in range(1, MAX_SOUNDS):
rl.unload_sound_alias(sound_array[i]) # Unload sound aliases
rl.unload_sound(sound_array[0]) # Unload source sound data
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

View file

@ -0,0 +1,112 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Playing spatialized 3D sound
Example complexity rating: [] 2/4
Example originally created with raylib 5.5, last time updated with raylib 5.5
Example contributed by Le Juez Victor (@Bigfoot71) and reviewed by Ramon Santamaria (@raysan5)
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2025 Le Juez Victor (@Bigfoot71)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
import math
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
# Sound positioning function
def set_sound_position(listener, sound, position, max_dist):
# Calculate direction vector and distance between listener and sound source
direction = rl.vector3_subtract(position, listener.position)
distance = rl.vector3_length(direction)
# Apply logarithmic distance attenuation and clamp between 0-1
attenuation = 1.0 / (1.0 + (distance / max_dist))
attenuation = rl.clamp(attenuation, 0.0, 1.0)
# Calculate normalized vectors for spatial positioning
normalized_direction = rl.vector3_normalize(direction)
forward = rl.vector3_normalize(
rl.vector3_subtract(listener.target, listener.position)
)
right = rl.vector3_normalize(rl.vector3_cross_product(listener.up, forward))
# Reduce volume for sounds behind the listener
dot_product = rl.vector3_dot_product(forward, normalized_direction)
if dot_product < 0.0:
attenuation *= 1.0 + dot_product * 0.5
# Set stereo panning based on sound position relative to listener
pan = 0.5 + 0.5 * rl.vector3_dot_product(normalized_direction, right)
# Apply final sound properties
rl.set_sound_volume(sound, attenuation)
rl.set_sound_pan(sound, pan)
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - Playing spatialized 3D sound"
)
rl.init_audio_device()
sound = rl.load_sound(str(THIS_DIR / "resources/coin.wav"))
camera = rl.Camera3D(
(0, 5, 5),
(0, 0, 0),
(0, 1, 0),
60.0,
rl.CameraProjection.CAMERA_PERSPECTIVE,
)
rl.disable_cursor()
rl.set_target_fps(60)
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close():
# Update
# ----------------------------------------------------------------------------------
rl.update_camera(camera, rl.CameraMode.CAMERA_FREE)
th = rl.get_time()
sphere_pos = rl.Vector3(5.0 * math.cos(th), 0.0, 5.0 * math.sin(th))
set_sound_position(camera, sound, sphere_pos, 20.0)
if not rl.is_sound_playing(sound):
rl.play_sound(sound)
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.begin_mode_3d(camera)
rl.draw_grid(10, 2)
rl.draw_sphere(sphere_pos, 0.5, rl.RED)
rl.end_mode_3d()
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_sound(sound)
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -25,10 +25,10 @@ SetTargetFPS(60)
while not WindowShouldClose():
# Update
# ----------------------------------------------------------------------
UpdatePhysics() # Update physics system
if IsKeyPressed(KEY_R): # Reset physics system
ResetPhysics()
ClosePhysics()
InitPhysics()
floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
floor.enabled = False

2
physac

@ -1 +1 @@
Subproject commit 4a8e17f263fb8e1150b3fbafc96f880c7d7a4833
Subproject commit 587b63926010593eedf29ef74e3aa22c1a507925

View file

@ -126,7 +126,7 @@ def _make_struct_constructor_function(struct):
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
arg = ffi.from_buffer(field[1].type, arg)
modified_args.append(arg)
s = ffi.new(f"struct {struct} *", modified_args)[0]
s = ffi.new(f"{struct} *", modified_args)[0]
global_weakkeydict[s] = modified_args
return s

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 26548c10620c4ae6937cf8b506c777a006b33c16
Subproject commit 15afe89aff2fc7da96ab5de80bde7f6186971cde

View file

@ -13,18 +13,22 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
import sys
import logging
logger = logging.getLogger(__name__)
try:
from ._raylib_cffi import ffi, lib as rl
except ModuleNotFoundError:
print("\n*** ERROR LOADING NATIVE CODE ***\n")
print("See https://github.com/electronstudio/raylib-python-cffi/issues/142\n", file=sys.stderr)
print("Your Python is: "+str(sys.implementation)+"\n", file=sys.stderr)
logger.error("*** ERROR LOADING NATIVE CODE ***")
logger.error("See https://github.com/electronstudio/raylib-python-cffi/issues/142")
logger.error("Your Python is: %s", str(sys.implementation))
raise
from raylib._raylib_cffi.lib import *
from raylib.colors import *
from raylib.defines import *
import cffi
from .version import __version__
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)
logger.warning("RAYLIB STATIC %s LOADED", __version__)

File diff suppressed because it is too large Load diff

View file

@ -24,8 +24,14 @@ import platform
import sys
import subprocess
import time
from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
REPO_ROOT = THIS_DIR.parent
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
ENABLE_WAYLAND_DRM_LEASING = os.getenv("ENABLE_WAYLAND_DRM_LEASING")
def check_raylib_installed():
return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
@ -42,6 +48,17 @@ def get_the_lib_path():
return subprocess.run(['pkg-config', '--variable=libdir', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip()
def get_specified_libs(lib_target):
libs = subprocess.run(['pkg-config', '--libs', lib_target], text=True,
stdout=subprocess.PIPE).stdout.strip().split()
if libs == "":
raise ValueError(f"Failed to get specified libs ({lib_target})")
print(f"{lib_target}: {libs}")
return libs
def get_lib_flags():
return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip().split()
@ -179,7 +196,11 @@ def build_unix():
if RAYLIB_PLATFORM=="SDL":
extra_link_args += ['-lX11','-lSDL2']
elif RAYLIB_PLATFORM=="DRM":
extra_link_args += ['-lEGL', '-lgbm']
extra_link_args += get_specified_libs("egl")
extra_link_args += get_specified_libs("gbm")
if ENABLE_WAYLAND_DRM_LEASING != "":
extra_link_args += get_specified_libs("wayland-client")
else:
extra_link_args += ['-lX11']
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
@ -200,13 +221,13 @@ def build_unix():
def build_windows():
print("BUILDING FOR WINDOWS")
ffibuilder.cdef(open("raylib/raylib.h.modified").read())
ffibuilder.cdef((THIS_DIR / "raylib.h.modified").read_text())
if RAYLIB_PLATFORM=="Desktop":
ffibuilder.cdef(open("raylib/glfw3.h.modified").read())
ffibuilder.cdef(open("raylib/rlgl.h.modified").read())
ffibuilder.cdef(open("raylib/raygui.h.modified").read())
ffibuilder.cdef(open("raylib/physac.h.modified").read())
ffibuilder.cdef(open("raylib/raymath.h.modified").read())
ffibuilder.cdef((THIS_DIR / "glfw3.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "rlgl.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "raygui.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "physac.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "raymath.h.modified").read_text())
ffi_includes = """
#include "raylib.h"
@ -224,6 +245,7 @@ def build_windows():
#define RAYGUI_SUPPORT_RICONS
#include "raygui.h"
#define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h"
"""
libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
@ -236,10 +258,10 @@ def build_windows():
extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
py_limited_api=False,
libraries=libraries,
include_dirs=['D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src\\external\\glfw\\include',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raygui\\src',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\physac\\src'],
include_dirs=[str(REPO_ROOT / 'raylib-c/src'),
str(REPO_ROOT / 'raylib-c/src/external/glfw/include'),
str(REPO_ROOT / 'raygui/src'),
str(REPO_ROOT / 'physac/src')],
)

View file

@ -186,12 +186,10 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
PHYSAC_MAX_BODIES: int = 64
PHYSAC_MAX_MANIFOLDS: int = 4096
PHYSAC_MAX_VERTICES: int = 24
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 100
PHYSAC_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 20
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
PHYSAC_PENETRATION_CORRECTION: float = 0.4
PHYSAC_PI: float = 3.141592653589793
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
PHYSAC_FLT_MAX: float = 3.402823466e+38
PHYSAC_EPSILON: float = 1e-06
GLFW_VERSION_MAJOR: int = 3

View file

@ -1,6 +1,7 @@
from enum import IntEnum
class ConfigFlags(IntEnum):
"""System/Window config flags."""
FLAG_VSYNC_HINT = 64
FLAG_FULLSCREEN_MODE = 2
FLAG_WINDOW_RESIZABLE = 4
@ -19,6 +20,7 @@ class ConfigFlags(IntEnum):
FLAG_INTERLACED_HINT = 65536
class TraceLogLevel(IntEnum):
"""Trace log level."""
LOG_ALL = 0
LOG_TRACE = 1
LOG_DEBUG = 2
@ -29,6 +31,7 @@ class TraceLogLevel(IntEnum):
LOG_NONE = 7
class KeyboardKey(IntEnum):
"""Keyboard keys (US keyboard layout)."""
KEY_NULL = 0
KEY_APOSTROPHE = 39
KEY_COMMA = 44
@ -141,6 +144,7 @@ class KeyboardKey(IntEnum):
KEY_VOLUME_DOWN = 25
class MouseButton(IntEnum):
"""Mouse buttons."""
MOUSE_BUTTON_LEFT = 0
MOUSE_BUTTON_RIGHT = 1
MOUSE_BUTTON_MIDDLE = 2
@ -150,6 +154,7 @@ class MouseButton(IntEnum):
MOUSE_BUTTON_BACK = 6
class MouseCursor(IntEnum):
"""Mouse cursor."""
MOUSE_CURSOR_DEFAULT = 0
MOUSE_CURSOR_ARROW = 1
MOUSE_CURSOR_IBEAM = 2
@ -163,6 +168,7 @@ class MouseCursor(IntEnum):
MOUSE_CURSOR_NOT_ALLOWED = 10
class GamepadButton(IntEnum):
"""Gamepad buttons."""
GAMEPAD_BUTTON_UNKNOWN = 0
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
@ -183,6 +189,7 @@ class GamepadButton(IntEnum):
GAMEPAD_BUTTON_RIGHT_THUMB = 17
class GamepadAxis(IntEnum):
"""Gamepad axis."""
GAMEPAD_AXIS_LEFT_X = 0
GAMEPAD_AXIS_LEFT_Y = 1
GAMEPAD_AXIS_RIGHT_X = 2
@ -191,6 +198,7 @@ class GamepadAxis(IntEnum):
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
class MaterialMapIndex(IntEnum):
"""Material map index."""
MATERIAL_MAP_ALBEDO = 0
MATERIAL_MAP_METALNESS = 1
MATERIAL_MAP_NORMAL = 2
@ -204,6 +212,7 @@ class MaterialMapIndex(IntEnum):
MATERIAL_MAP_BRDF = 10
class ShaderLocationIndex(IntEnum):
"""Shader location index."""
SHADER_LOC_VERTEX_POSITION = 0
SHADER_LOC_VERTEX_TEXCOORD01 = 1
SHADER_LOC_VERTEX_TEXCOORD02 = 2
@ -235,6 +244,7 @@ class ShaderLocationIndex(IntEnum):
SHADER_LOC_BONE_MATRICES = 28
class ShaderUniformDataType(IntEnum):
"""Shader uniform data type."""
SHADER_UNIFORM_FLOAT = 0
SHADER_UNIFORM_VEC2 = 1
SHADER_UNIFORM_VEC3 = 2
@ -246,12 +256,14 @@ class ShaderUniformDataType(IntEnum):
SHADER_UNIFORM_SAMPLER2D = 8
class ShaderAttributeDataType(IntEnum):
"""Shader attribute data types."""
SHADER_ATTRIB_FLOAT = 0
SHADER_ATTRIB_VEC2 = 1
SHADER_ATTRIB_VEC3 = 2
SHADER_ATTRIB_VEC4 = 3
class PixelFormat(IntEnum):
"""Pixel formats."""
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
@ -278,6 +290,7 @@ class PixelFormat(IntEnum):
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
class TextureFilter(IntEnum):
"""Texture parameters: filter mode."""
TEXTURE_FILTER_POINT = 0
TEXTURE_FILTER_BILINEAR = 1
TEXTURE_FILTER_TRILINEAR = 2
@ -286,12 +299,14 @@ class TextureFilter(IntEnum):
TEXTURE_FILTER_ANISOTROPIC_16X = 5
class TextureWrap(IntEnum):
"""Texture parameters: wrap mode."""
TEXTURE_WRAP_REPEAT = 0
TEXTURE_WRAP_CLAMP = 1
TEXTURE_WRAP_MIRROR_REPEAT = 2
TEXTURE_WRAP_MIRROR_CLAMP = 3
class CubemapLayout(IntEnum):
"""Cubemap layouts."""
CUBEMAP_LAYOUT_AUTO_DETECT = 0
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
@ -299,11 +314,13 @@ class CubemapLayout(IntEnum):
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
class FontType(IntEnum):
"""Font type, defines generation method."""
FONT_DEFAULT = 0
FONT_BITMAP = 1
FONT_SDF = 2
class BlendMode(IntEnum):
"""Color blending modes (pre-defined)."""
BLEND_ALPHA = 0
BLEND_ADDITIVE = 1
BLEND_MULTIPLIED = 2
@ -314,6 +331,7 @@ class BlendMode(IntEnum):
BLEND_CUSTOM_SEPARATE = 7
class Gesture(IntEnum):
"""Gesture."""
GESTURE_NONE = 0
GESTURE_TAP = 1
GESTURE_DOUBLETAP = 2
@ -327,6 +345,7 @@ class Gesture(IntEnum):
GESTURE_PINCH_OUT = 512
class CameraMode(IntEnum):
"""Camera system modes."""
CAMERA_CUSTOM = 0
CAMERA_FREE = 1
CAMERA_ORBITAL = 2
@ -334,36 +353,43 @@ class CameraMode(IntEnum):
CAMERA_THIRD_PERSON = 4
class CameraProjection(IntEnum):
"""Camera projection."""
CAMERA_PERSPECTIVE = 0
CAMERA_ORTHOGRAPHIC = 1
class NPatchLayout(IntEnum):
"""N-patch layout."""
NPATCH_NINE_PATCH = 0
NPATCH_THREE_PATCH_VERTICAL = 1
NPATCH_THREE_PATCH_HORIZONTAL = 2
class GuiState(IntEnum):
"""Gui control state."""
STATE_NORMAL = 0
STATE_FOCUSED = 1
STATE_PRESSED = 2
STATE_DISABLED = 3
class GuiTextAlignment(IntEnum):
"""Gui control text alignment."""
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_CENTER = 1
TEXT_ALIGN_RIGHT = 2
class GuiTextAlignmentVertical(IntEnum):
"""Gui control text alignment vertical."""
TEXT_ALIGN_TOP = 0
TEXT_ALIGN_MIDDLE = 1
TEXT_ALIGN_BOTTOM = 2
class GuiTextWrapMode(IntEnum):
"""Gui control text wrap mode."""
TEXT_WRAP_NONE = 0
TEXT_WRAP_CHAR = 1
TEXT_WRAP_WORD = 2
class GuiControl(IntEnum):
"""Gui controls."""
DEFAULT = 0
LABEL = 1
BUTTON = 2
@ -382,6 +408,7 @@ class GuiControl(IntEnum):
STATUSBAR = 15
class GuiControlProperty(IntEnum):
"""Gui base properties for every control."""
BORDER_COLOR_NORMAL = 0
BASE_COLOR_NORMAL = 1
TEXT_COLOR_NORMAL = 2
@ -399,6 +426,7 @@ class GuiControlProperty(IntEnum):
TEXT_ALIGNMENT = 14
class GuiDefaultProperty(IntEnum):
"""DEFAULT extended properties."""
TEXT_SIZE = 16
TEXT_SPACING = 17
LINE_COLOR = 18
@ -408,16 +436,20 @@ class GuiDefaultProperty(IntEnum):
TEXT_WRAP_MODE = 22
class GuiToggleProperty(IntEnum):
"""Toggle/ToggleGroup."""
GROUP_PADDING = 16
class GuiSliderProperty(IntEnum):
"""Slider/SliderBar."""
SLIDER_WIDTH = 16
SLIDER_PADDING = 17
class GuiProgressBarProperty(IntEnum):
"""ProgressBar."""
PROGRESS_PADDING = 16
class GuiScrollBarProperty(IntEnum):
"""ScrollBar."""
ARROWS_SIZE = 16
ARROWS_VISIBLE = 17
SCROLL_SLIDER_PADDING = 18
@ -426,26 +458,32 @@ class GuiScrollBarProperty(IntEnum):
SCROLL_SPEED = 21
class GuiCheckBoxProperty(IntEnum):
"""CheckBox."""
CHECK_PADDING = 16
class GuiComboBoxProperty(IntEnum):
"""ComboBox."""
COMBO_BUTTON_WIDTH = 16
COMBO_BUTTON_SPACING = 17
class GuiDropdownBoxProperty(IntEnum):
"""DropdownBox."""
ARROW_PADDING = 16
DROPDOWN_ITEMS_SPACING = 17
DROPDOWN_ARROW_HIDDEN = 18
DROPDOWN_ROLL_UP = 19
class GuiTextBoxProperty(IntEnum):
"""TextBox/TextBoxMulti/ValueBox/Spinner."""
TEXT_READONLY = 16
class GuiSpinnerProperty(IntEnum):
"""Spinner."""
SPIN_BUTTON_WIDTH = 16
SPIN_BUTTON_SPACING = 17
class GuiListViewProperty(IntEnum):
"""ListView."""
LIST_ITEMS_HEIGHT = 16
LIST_ITEMS_SPACING = 17
SCROLLBAR_WIDTH = 18
@ -453,6 +491,7 @@ class GuiListViewProperty(IntEnum):
LIST_ITEMS_BORDER_WIDTH = 20
class GuiColorPickerProperty(IntEnum):
"""ColorPicker."""
COLOR_SELECTOR_SIZE = 16
HUEBAR_WIDTH = 17
HUEBAR_PADDING = 18
@ -460,6 +499,7 @@ class GuiColorPickerProperty(IntEnum):
HUEBAR_SELECTOR_OVERFLOW = 20
class GuiIconName(IntEnum):
"""."""
ICON_NONE = 0
ICON_FOLDER_FILE_OPEN = 1
ICON_FILE_SAVE_CLASSIC = 2

View file

@ -4,8 +4,8 @@
*
* DESCRIPTION:
*
* Physac is a small 2D physics engine written in pure C. The engine uses a fixed time-step thread loop
* to simulate physics. A physics step contains the following phases: get collision information,
* Physac is a small 2D physics library written in pure C. The engine uses a fixed time-step thread loop
* to simluate physics. A physics step contains the following phases: get collision information,
* apply dynamics, collision solving and position correction. It uses a very simple struct for physic
* bodies with a position vector to be used in any 3D rendering API.
*
@ -16,41 +16,49 @@
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define PHYSAC_DEBUG
* Show debug traces log messages about physic bodies creation/destruction, physic system errors,
* some calculations results and NULL reference exceptions.
* #define PHYSAC_STATIC (defined by default)
* The generated implementation will stay private inside implementation file and all
* internal symbols and functions will only be visible inside that file.
*
* #define PHYSAC_AVOID_TIMMING_SYSTEM
* Disables internal timming system, used by UpdatePhysics() to launch timmed physic steps,
* it allows just running UpdatePhysics() automatically on a separate thread at a desired time step.
* In case physics steps update needs to be controlled by user with a custom timming mechanism,
* just define this flag and the internal timming mechanism will be avoided, in that case,
* timming libraries are neither required by the module.
* #define PHYSAC_NO_THREADS
* The generated implementation won't include pthread library and user must create a secondary thread to call PhysicsThread().
* It is so important that the thread where PhysicsThread() is called must not have v-sync or any other CPU limitation.
*
* #define PHYSAC_STANDALONE
* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
* internally in the library and input management and drawing functions must be provided by
* the user (check library implementation for further details).
*
* #define PHYSAC_DEBUG
* Traces log messages when creating and destroying physics bodies and detects errors in physics
* calculations and reference exceptions; it is useful for debug purposes
*
* #define PHYSAC_MALLOC()
* #define PHYSAC_CALLOC()
* #define PHYSAC_FREE()
* You can define your own malloc/free implementation replacing stdlib.h malloc()/free() functions.
* Otherwise it will include stdlib.h and use the C standard library malloc()/free() function.
*
* COMPILATION:
*
* Use the following code to compile with GCC:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
*
* VERSIONS HISTORY:
* 1.1 (20-Jan-2021) @raysan5: Library general revision
* Removed threading system (up to the user)
* Support MSVC C++ compilation using CLITERAL()
* Review DEBUG mechanism for TRACELOG() and all TRACELOG() messages
* Review internal variables/functions naming for consistency
* Allow option to avoid internal timming system, to allow app manage the steps
* 1.0 (12-Jun-2017) First release of the library
* Use the following code to compile:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lpthread -lopengl32 -lgdi32 -lwinmm -std=c99
*
* VERY THANKS TO:
* - raysan5: helped with library design
* - ficoos: added support for Linux
* - R8D8: added support for Linux
* - jubalh: fixed implementation of time calculations
* - a3f: fixed implementation of time calculations
* - define-private-public: added support for OSX
* - pamarcos: fixed implementation of physics steps
* - noshbar: fixed some memory leaks
*
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2016-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5)
* Copyright (c) 2016-2025 Victor Fisac (github: @victorfisac)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@ -68,39 +76,41 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
// Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
// Allow custom memory allocators
// #define PHYSAC_STATIC
// #define PHYSAC_NO_THREADS
// #define PHYSAC_STANDALONE
// #define PHYSAC_DEBUG
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Data Types Structure Definition
// Types and Structures Definition
// NOTE: Below types are required for PHYSAC_STANDALONE usage
//----------------------------------------------------------------------------------
typedef enum PhysicsShapeType { PHYSICS_CIRCLE = 0, PHYSICS_POLYGON } PhysicsShapeType;
typedef enum PhysicsShapeType { PHYSICS_CIRCLE, PHYSICS_POLYGON } PhysicsShapeType;
// Previously defined to be used in PhysicsShape struct as circular dependencies
typedef struct PhysicsBodyData *PhysicsBody;
// Matrix2x2 type (used for polygon shape rotation matrix)
typedef struct Matrix2x2 {
// Mat2 type (used for polygon shape rotation matrix)
typedef struct Mat2 {
float m00;
float m01;
float m10;
float m11;
} Matrix2x2;
typedef struct PhysicsVertexData {
unsigned int vertexCount; // Vertex count (positions and normals)
Vector2 positions[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex positions vectors
Vector2 normals[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex normals vectors
} PhysicsVertexData;
} Mat2;
typedef struct PolygonData {
unsigned int vertexCount; // Current used vertex and normals count
Vector2 positions[24]; // Polygon vertex positions vectors
Vector2 normals[24]; // Polygon vertex normals vectors
} PolygonData;
typedef struct PhysicsShape {
PhysicsShapeType type; // Shape type (circle or polygon)
PhysicsBody body; // Shape physics body data pointer
PhysicsVertexData vertexData; // Shape vertices data (used for polygon shapes)
float radius; // Shape radius (used for circle shapes)
Matrix2x2 transform; // Vertices transform matrix 2x2
PhysicsShapeType type; // Physics shape type (circle or polygon)
PhysicsBody body; // Shape physics body reference
float radius; // Circle shape radius (used for circle shapes)
Mat2 transform; // Vertices transform matrix 2x2
PolygonData vertexData; // Polygon shape vertices position and normals data (just used for polygon shapes)
} PhysicsShape;
typedef struct PhysicsBodyData {
unsigned int id; // Unique identifier
unsigned int id; // Reference unique identifier
bool enabled; // Enabled dynamics state (collisions are calculated anyway)
Vector2 position; // Physics body shape pivot
Vector2 velocity; // Current linear velocity applied to position
@ -118,10 +128,10 @@ typedef struct PhysicsBodyData {
bool useGravity; // Apply gravity force to dynamics
bool isGrounded; // Physics grounded on other body state
bool freezeOrient; // Physics rotation constraint
PhysicsShape shape; // Physics body shape information (type, radius, vertices, transform)
PhysicsShape shape; // Physics body shape information (type, radius, vertices, normals)
} PhysicsBodyData;
typedef struct PhysicsManifoldData {
unsigned int id; // Unique identifier
unsigned int id; // Reference unique identifier
PhysicsBody bodyA; // Manifold first physics body reference
PhysicsBody bodyB; // Manifold second physics body reference
float penetration; // Depth of penetration from collision
@ -135,29 +145,25 @@ typedef struct PhysicsManifoldData {
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
// Physics system management
void InitPhysics(void); // Initializes physics system
void UpdatePhysics(void); // Update physics system
void ResetPhysics(void); // Reset physics system (global variables)
void ClosePhysics(void); // Close physics system and unload used memory
void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
// Physic body creation/destroy
PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
void DestroyPhysicsBody(PhysicsBody body); // Destroy a physics body
// Physic body forces
void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
// Query physics info
PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
extern /* Functions visible from other files*/ void InitPhysics(void); // Initializes physics values, pointers and creates physics loop thread
extern /* Functions visible from other files*/ void RunPhysicsStep(void); // Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop
extern /* Functions visible from other files*/ void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
extern /* Functions visible from other files*/ bool IsPhysicsEnabled(void); // Returns true if physics thread is currently enabled
extern /* Functions visible from other files*/ void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
extern /* Functions visible from other files*/ void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
extern /* Functions visible from other files*/ void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
extern /* Functions visible from other files*/ void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
extern /* Functions visible from other files*/ int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
extern /* Functions visible from other files*/ PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
extern /* Functions visible from other files*/ int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
extern /* Functions visible from other files*/ int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
extern /* Functions visible from other files*/ Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
extern /* Functions visible from other files*/ void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
extern /* Functions visible from other files*/ void DestroyPhysicsBody(PhysicsBody body); // Unitializes and destroy a physics body
extern /* Functions visible from other files*/ void ClosePhysics(void); // Unitializes physics pointers and closes physics loop thread
/***********************************************************************************
*
* PHYSAC IMPLEMENTATION

View file

@ -3,7 +3,7 @@
* rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
*
* DESCRIPTION:
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
*
* ADDITIONAL NOTES:

30
shell.nix Normal file
View file

@ -0,0 +1,30 @@
{
pkgs ? import <nixpkgs> { },
}: pkgs.mkShell {
buildInputs = with pkgs; [
python3
cmake
clang-tools
pkg-config
wayland-scanner
wayland
libGL
libgbm
libdrm
xorg.libXi
xorg.libXcursor
xorg.libXrandr
xorg.libXinerama
xorg.libX11
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ pkgs.xorg.libX11 pkgs.libGL ]}:$LD_LIBRARY_PATH"
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
'';
}

View file

@ -7,6 +7,8 @@ import pyray as pr
pr.init_window(800, 450, "Raylib texture test")
pr.set_target_fps(60)
test_typedef_init = pr.Texture2D() # Texture2D is typedef for Texture
image = pr.gen_image_color(800, 400, (0,0,0,255) )
texture = pr.load_texture_from_image(image)
pr.update_texture(texture, image.data)