raylib 5.0.0.1__tar.gz → 5.0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of raylib might be problematic. Click here for more details.
- {raylib-5.0.0.1/raylib.egg-info → raylib-5.0.0.3}/PKG-INFO +72 -12
- {raylib-5.0.0.1 → raylib-5.0.0.3}/README.md +69 -12
- raylib-5.0.0.3/pyray/__init__.py +160 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/pyray/__init__.pyi +38 -51
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/__init__.pyi +36 -49
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/build.py +6 -1
- raylib-5.0.0.3/raylib/version.py +1 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3/raylib.egg-info}/PKG-INFO +72 -12
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib.egg-info/SOURCES.txt +8 -1
- raylib-5.0.0.3/raylib.egg-info/requires.txt +1 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/setup.py +3 -1
- raylib-5.0.0.3/tests/test_color.py +22 -0
- raylib-5.0.0.3/tests/test_float_pointers.py +11 -0
- raylib-5.0.0.3/tests/test_gamepad.py +17 -0
- raylib-5.0.0.3/tests/test_hello_world.py +10 -0
- raylib-5.0.0.3/tests/test_pyray.py +44 -0
- raylib-5.0.0.3/tests/test_pyray_no_prefix.py +44 -0
- raylib-5.0.0.3/tests/test_static_with_only_api_from_dynamic.py +36 -0
- raylib-5.0.0.3/version.py +1 -0
- raylib-5.0.0.1/pyray/__init__.py +0 -108
- raylib-5.0.0.1/raylib/version.py +0 -1
- raylib-5.0.0.1/raylib.egg-info/requires.txt +0 -2
- raylib-5.0.0.1/version.py +0 -1
- {raylib-5.0.0.1 → raylib-5.0.0.3}/LICENSE +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/MANIFEST.in +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/__init__.py +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/colors.py +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/defines.py +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib/enums.py +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib.egg-info/dependency_links.txt +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/raylib.egg-info/top_level.txt +0 -0
- {raylib-5.0.0.1 → raylib-5.0.0.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: raylib
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.3
|
|
4
4
|
Summary: Python CFFI bindings for Raylib
|
|
5
5
|
Home-page: https://github.com/electronstudio/raylib-python-cffi
|
|
6
6
|
Author: Electron Studio
|
|
@@ -8,6 +8,8 @@ Author-email: github@electronstudio.co.uk
|
|
|
8
8
|
License: EPL-2.0
|
|
9
9
|
Classifier: License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
15
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -15,16 +17,19 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
15
17
|
Classifier: Programming Language :: Python :: 3.7
|
|
16
18
|
Description-Content-Type: text/markdown
|
|
17
19
|
License-File: LICENSE
|
|
20
|
+
Requires-Dist: cffi>=1.17.0rc1
|
|
18
21
|
|
|
19
22
|
# Python Bindings for Raylib 5.0
|
|
20
23
|
|
|
24
|
+
Chatroom: [Discord](https://discord.gg/fKDwt85aX6) or [Matrix](https://matrix.to/#/#raylib-python-cffi:matrix.org)
|
|
25
|
+
|
|
21
26
|
New CFFI API static bindings.
|
|
22
27
|
* Automatically generated to be as close as possible to
|
|
23
28
|
original Raylib.
|
|
24
29
|
* Faster, fewer bugs and easier to maintain than ctypes.
|
|
25
30
|
* Commercial-friendly license.
|
|
26
31
|
* Docstrings and auto-completion.
|
|
27
|
-
* **Now includes extra libraries: raymath, raygui, rlgl and
|
|
32
|
+
* **Now includes extra libraries: raymath, raygui, rlgl, physac and GLFW**
|
|
28
33
|
|
|
29
34
|
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
|
30
35
|
|
|
@@ -53,7 +58,7 @@ Then install
|
|
|
53
58
|
python3 -m pip install setuptools
|
|
54
59
|
python3 -m pip install raylib
|
|
55
60
|
|
|
56
|
-
On most platforms it should install a binary wheel (Windows 10 x64, MacOS
|
|
61
|
+
On most platforms it should install a binary wheel (Windows 10 x64, MacOS 12 x64/arm64, Linux Ubuntu2004 x64/arm64).
|
|
57
62
|
|
|
58
63
|
If yours isn't available then pip will attempt to build from source, in which case you will need to have Raylib development libs installed, e.g.
|
|
59
64
|
using homebrew, apt, etc.
|
|
@@ -99,6 +104,47 @@ Use [the C API](https://electronstudio.github.io/raylib-python-cffi/raylib.html)
|
|
|
99
104
|
|
|
100
105
|
Use [the Python API](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
|
|
101
106
|
|
|
107
|
+
# Running in a web browser
|
|
108
|
+
|
|
109
|
+
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
|
|
110
|
+
|
|
111
|
+
Make a folder `my_project` with a file `main.py`:
|
|
112
|
+
|
|
113
|
+
# /// script
|
|
114
|
+
# dependencies = [
|
|
115
|
+
# "cffi",
|
|
116
|
+
# "raylib"
|
|
117
|
+
# ]
|
|
118
|
+
# ///
|
|
119
|
+
import asyncio
|
|
120
|
+
import platform
|
|
121
|
+
from pyray import *
|
|
122
|
+
|
|
123
|
+
async def main(): # You must have an async main function
|
|
124
|
+
init_window(500, 500, "Hello")
|
|
125
|
+
platform.window.window_resize() # You must add this line
|
|
126
|
+
while not window_should_close():
|
|
127
|
+
begin_drawing()
|
|
128
|
+
clear_background(WHITE)
|
|
129
|
+
draw_text("Hello world", 190, 200, 20, VIOLET)
|
|
130
|
+
end_drawing()
|
|
131
|
+
await asyncio.sleep(0) # You must call this in your main loop
|
|
132
|
+
close_window()
|
|
133
|
+
|
|
134
|
+
asyncio.run(main())
|
|
135
|
+
|
|
136
|
+
Then to create the web files and launch a web server:
|
|
137
|
+
|
|
138
|
+
python3.12 -m pip install --user --upgrade pygbag
|
|
139
|
+
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
|
|
140
|
+
|
|
141
|
+
Point your browser to http://localhost:8000
|
|
142
|
+
|
|
143
|
+
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
|
|
144
|
+
Carefully read all their [documentation](https://pygame-web.github.io/).
|
|
145
|
+
|
|
146
|
+
It does work for most of [these examples](https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/)
|
|
147
|
+
|
|
102
148
|
# App showcase
|
|
103
149
|
|
|
104
150
|
[Tanki](https://github.com/pkulev/tanki)
|
|
@@ -125,22 +171,36 @@ statically link and use in non-free / proprietary / commercial projects!
|
|
|
125
171
|
|
|
126
172
|
# Performance
|
|
127
173
|
|
|
128
|
-
|
|
174
|
+
If you need more performance, do in this order:
|
|
129
175
|
|
|
130
|
-
|
|
176
|
+
1. Use Pypy rather than standard CPython. It is much, much faster and will make more difference than any other optimisations you might do.
|
|
177
|
+
|
|
178
|
+
2. Every call to C is costly, so it's slightly faster if you use Python data structures and functions when calculating
|
|
131
179
|
in your update loop
|
|
132
180
|
and then only convert them to C data structures when you have to call the C functions for drawing.
|
|
133
181
|
|
|
182
|
+
3. The raylib.* functions are potentially *slightly* faster than the pyray.* equivalents, so if you need a tiny bit more performance
|
|
183
|
+
you can switch your inner loop functions to these.
|
|
184
|
+
|
|
185
|
+
4. There is a version of Python that is faster than Pypy: GraalPy. However it's not fully compatible with all Python
|
|
186
|
+
packages. It doesn't work with CFFI and so doesn't work with this binding. But it *is* compatible with the
|
|
187
|
+
*Java* binding, Jaylib! There is an example of this here: https://github.com/electronstudio/megabunny/tree/master/raylib-python-jaylib
|
|
188
|
+
|
|
134
189
|
## Bunnymark
|
|
135
190
|
|
|
136
191
|
|
|
137
|
-
| Library
|
|
138
|
-
|
|
139
|
-
| Raylib
|
|
140
|
-
| Raylib Python CFFI
|
|
141
|
-
| Raylib Python CFFI
|
|
142
|
-
| Raylib
|
|
143
|
-
| Raylib Python CFFI 3.7
|
|
192
|
+
| Library | Implementation | Bunnies (60 FPS) | Percentage |
|
|
193
|
+
|--------------------------------|-------------------|------------------|------------|
|
|
194
|
+
| Raylib 5.0 | C | 180000 | 100% |
|
|
195
|
+
| Raylib Python CFFI 5.0.0.2 | Python 3.12 | 10500 | 5.8% |
|
|
196
|
+
| Raylib Python CFFI 5.0.0.2 | Pypy 3.10 | 95000 | 53% |
|
|
197
|
+
| Raylib 3.7 | C | 168100 | 100% |
|
|
198
|
+
| Raylib Python CFFI 3.7 | Pypy 3.7 | 33800 | 20% |
|
|
199
|
+
| Raylib Python CFFI 3.7 | Python 3.9 | 7700 | 4.5% |
|
|
200
|
+
| Raylib Python CFFI 3.7 | Python 3.9 Nuitka | 8600 | 5.1% |
|
|
201
|
+
| Raylib Python CFFI 3.7 Dynamic | Python 3.9 | 6300 | 3.7% |
|
|
202
|
+
|
|
203
|
+
See also https://github.com/electronstudio/megabunny/
|
|
144
204
|
|
|
145
205
|
# Packaging your app
|
|
146
206
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Python Bindings for Raylib 5.0
|
|
2
2
|
|
|
3
|
+
Chatroom: [Discord](https://discord.gg/fKDwt85aX6) or [Matrix](https://matrix.to/#/#raylib-python-cffi:matrix.org)
|
|
4
|
+
|
|
3
5
|
New CFFI API static bindings.
|
|
4
6
|
* Automatically generated to be as close as possible to
|
|
5
7
|
original Raylib.
|
|
6
8
|
* Faster, fewer bugs and easier to maintain than ctypes.
|
|
7
9
|
* Commercial-friendly license.
|
|
8
10
|
* Docstrings and auto-completion.
|
|
9
|
-
* **Now includes extra libraries: raymath, raygui, rlgl and
|
|
11
|
+
* **Now includes extra libraries: raymath, raygui, rlgl, physac and GLFW**
|
|
10
12
|
|
|
11
13
|
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
|
12
14
|
|
|
@@ -35,7 +37,7 @@ Then install
|
|
|
35
37
|
python3 -m pip install setuptools
|
|
36
38
|
python3 -m pip install raylib
|
|
37
39
|
|
|
38
|
-
On most platforms it should install a binary wheel (Windows 10 x64, MacOS
|
|
40
|
+
On most platforms it should install a binary wheel (Windows 10 x64, MacOS 12 x64/arm64, Linux Ubuntu2004 x64/arm64).
|
|
39
41
|
|
|
40
42
|
If yours isn't available then pip will attempt to build from source, in which case you will need to have Raylib development libs installed, e.g.
|
|
41
43
|
using homebrew, apt, etc.
|
|
@@ -81,6 +83,47 @@ Use [the C API](https://electronstudio.github.io/raylib-python-cffi/raylib.html)
|
|
|
81
83
|
|
|
82
84
|
Use [the Python API](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
|
|
83
85
|
|
|
86
|
+
# Running in a web browser
|
|
87
|
+
|
|
88
|
+
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
|
|
89
|
+
|
|
90
|
+
Make a folder `my_project` with a file `main.py`:
|
|
91
|
+
|
|
92
|
+
# /// script
|
|
93
|
+
# dependencies = [
|
|
94
|
+
# "cffi",
|
|
95
|
+
# "raylib"
|
|
96
|
+
# ]
|
|
97
|
+
# ///
|
|
98
|
+
import asyncio
|
|
99
|
+
import platform
|
|
100
|
+
from pyray import *
|
|
101
|
+
|
|
102
|
+
async def main(): # You must have an async main function
|
|
103
|
+
init_window(500, 500, "Hello")
|
|
104
|
+
platform.window.window_resize() # You must add this line
|
|
105
|
+
while not window_should_close():
|
|
106
|
+
begin_drawing()
|
|
107
|
+
clear_background(WHITE)
|
|
108
|
+
draw_text("Hello world", 190, 200, 20, VIOLET)
|
|
109
|
+
end_drawing()
|
|
110
|
+
await asyncio.sleep(0) # You must call this in your main loop
|
|
111
|
+
close_window()
|
|
112
|
+
|
|
113
|
+
asyncio.run(main())
|
|
114
|
+
|
|
115
|
+
Then to create the web files and launch a web server:
|
|
116
|
+
|
|
117
|
+
python3.12 -m pip install --user --upgrade pygbag
|
|
118
|
+
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
|
|
119
|
+
|
|
120
|
+
Point your browser to http://localhost:8000
|
|
121
|
+
|
|
122
|
+
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
|
|
123
|
+
Carefully read all their [documentation](https://pygame-web.github.io/).
|
|
124
|
+
|
|
125
|
+
It does work for most of [these examples](https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/)
|
|
126
|
+
|
|
84
127
|
# App showcase
|
|
85
128
|
|
|
86
129
|
[Tanki](https://github.com/pkulev/tanki)
|
|
@@ -107,22 +150,36 @@ statically link and use in non-free / proprietary / commercial projects!
|
|
|
107
150
|
|
|
108
151
|
# Performance
|
|
109
152
|
|
|
110
|
-
|
|
153
|
+
If you need more performance, do in this order:
|
|
111
154
|
|
|
112
|
-
|
|
155
|
+
1. Use Pypy rather than standard CPython. It is much, much faster and will make more difference than any other optimisations you might do.
|
|
156
|
+
|
|
157
|
+
2. Every call to C is costly, so it's slightly faster if you use Python data structures and functions when calculating
|
|
113
158
|
in your update loop
|
|
114
159
|
and then only convert them to C data structures when you have to call the C functions for drawing.
|
|
115
160
|
|
|
161
|
+
3. The raylib.* functions are potentially *slightly* faster than the pyray.* equivalents, so if you need a tiny bit more performance
|
|
162
|
+
you can switch your inner loop functions to these.
|
|
163
|
+
|
|
164
|
+
4. There is a version of Python that is faster than Pypy: GraalPy. However it's not fully compatible with all Python
|
|
165
|
+
packages. It doesn't work with CFFI and so doesn't work with this binding. But it *is* compatible with the
|
|
166
|
+
*Java* binding, Jaylib! There is an example of this here: https://github.com/electronstudio/megabunny/tree/master/raylib-python-jaylib
|
|
167
|
+
|
|
116
168
|
## Bunnymark
|
|
117
169
|
|
|
118
170
|
|
|
119
|
-
| Library
|
|
120
|
-
|
|
121
|
-
| Raylib
|
|
122
|
-
| Raylib Python CFFI
|
|
123
|
-
| Raylib Python CFFI
|
|
124
|
-
| Raylib
|
|
125
|
-
| Raylib Python CFFI 3.7
|
|
171
|
+
| Library | Implementation | Bunnies (60 FPS) | Percentage |
|
|
172
|
+
|--------------------------------|-------------------|------------------|------------|
|
|
173
|
+
| Raylib 5.0 | C | 180000 | 100% |
|
|
174
|
+
| Raylib Python CFFI 5.0.0.2 | Python 3.12 | 10500 | 5.8% |
|
|
175
|
+
| Raylib Python CFFI 5.0.0.2 | Pypy 3.10 | 95000 | 53% |
|
|
176
|
+
| Raylib 3.7 | C | 168100 | 100% |
|
|
177
|
+
| Raylib Python CFFI 3.7 | Pypy 3.7 | 33800 | 20% |
|
|
178
|
+
| Raylib Python CFFI 3.7 | Python 3.9 | 7700 | 4.5% |
|
|
179
|
+
| Raylib Python CFFI 3.7 | Python 3.9 Nuitka | 8600 | 5.1% |
|
|
180
|
+
| Raylib Python CFFI 3.7 Dynamic | Python 3.9 | 6300 | 3.7% |
|
|
181
|
+
|
|
182
|
+
See also https://github.com/electronstudio/megabunny/
|
|
126
183
|
|
|
127
184
|
# Packaging your app
|
|
128
185
|
|
|
@@ -137,4 +194,4 @@ You can create a standalone binary using the Nuitka compiler. For example, here
|
|
|
137
194
|
[RetroWar: 8-bit Party Battle](https://store.steampowered.com/app/664240/RetroWar_8bit_Party_Battle/?git) is out now. Defeat up to 15 of your friends in a tournament of 80s-inspired retro mini games.
|
|
138
195
|
|
|
139
196
|
[Coding Games With Pygame Zero & Python](https://github.com/electronstudio/pygame-zero-book) is
|
|
140
|
-
a book for Python beginners.
|
|
197
|
+
a book for Python beginners.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Copyright (c) 2021 Richard Smith and others
|
|
2
|
+
#
|
|
3
|
+
# This program and the accompanying materials are made available under the
|
|
4
|
+
# terms of the Eclipse Public License 2.0 which is available at
|
|
5
|
+
# http://www.eclipse.org/legal/epl-2.0.
|
|
6
|
+
#
|
|
7
|
+
# This Source Code may also be made available under the following Secondary
|
|
8
|
+
# licenses when the conditions for such availability set forth in the Eclipse
|
|
9
|
+
# Public License, v. 2.0 are satisfied: GNU General Public License, version 2
|
|
10
|
+
# with the GNU Classpath Exception which is
|
|
11
|
+
# available at https://www.gnu.org/software/classpath/license.html.
|
|
12
|
+
#
|
|
13
|
+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
import re
|
|
15
|
+
import weakref
|
|
16
|
+
from array import array
|
|
17
|
+
|
|
18
|
+
from raylib import rl, ffi
|
|
19
|
+
from raylib.colors import *
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
from raylib.defines import *
|
|
23
|
+
except AttributeError:
|
|
24
|
+
print("sorry deprecated enums dont work on dynamic version")
|
|
25
|
+
|
|
26
|
+
from inspect import getmembers, isbuiltin
|
|
27
|
+
|
|
28
|
+
current_module = __import__(__name__)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _underscore(word: str) -> str:
|
|
32
|
+
"""
|
|
33
|
+
from inflection
|
|
34
|
+
"""
|
|
35
|
+
word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
|
|
36
|
+
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
|
|
37
|
+
word = word.replace("-", "_")
|
|
38
|
+
return word.lower()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _wrap_function(original_func):
|
|
42
|
+
c_args = [str(x) for x in ffi.typeof(original_func).args]
|
|
43
|
+
number_of_args = len(c_args)
|
|
44
|
+
c_arg_is_pointer = [x.kind == 'pointer' for x in ffi.typeof(original_func).args]
|
|
45
|
+
c_arg_is_string = [str(x) == "<ctype 'char *'>" for x in ffi.typeof(original_func).args]
|
|
46
|
+
# c_arg_is_void_pointer = [str(x) == "<ctype 'void *'>" for x in ffi.typeof(original_func).args]
|
|
47
|
+
|
|
48
|
+
def wrapped_func(*args):
|
|
49
|
+
args = list(args) # tuple is immutable, converting it to mutable list is faster than constructing new list!
|
|
50
|
+
for i in range(number_of_args):
|
|
51
|
+
try:
|
|
52
|
+
arg = args[i]
|
|
53
|
+
except IndexError:
|
|
54
|
+
raise RuntimeError(f"function requires {number_of_args} arguments but you supplied {len(args)}")
|
|
55
|
+
if c_arg_is_pointer[i]:
|
|
56
|
+
if c_arg_is_string[i]: # we assume c_arg is 'const char *'
|
|
57
|
+
try: # if it's a non-const 'char *' then user should be supplying a ctype pointer, not a Python
|
|
58
|
+
# string
|
|
59
|
+
args[i] = arg.encode('utf-8') # in that case this conversion will fail
|
|
60
|
+
except AttributeError: # but those functions are uncommon, so quicker on average to try the
|
|
61
|
+
# conversion
|
|
62
|
+
pass # and ignore the exception
|
|
63
|
+
# if user supplied a Python string but c_arg is a 'char *' not a 'const char *' then we ought to raise
|
|
64
|
+
# exception because its an out
|
|
65
|
+
# parameter and user should supply a ctype pointer, but we cant because cffi cant detect 'const'
|
|
66
|
+
# so we would have to get the info from raylib.json
|
|
67
|
+
elif c_args[i] == "<ctype 'char * *'>" and type(arg) is list:
|
|
68
|
+
args[i] = [ffi.new("char[]", x.encode('utf-8')) for x in arg]
|
|
69
|
+
elif is_cdata(arg) and "*" not in str(arg):
|
|
70
|
+
args[i] = ffi.addressof(arg)
|
|
71
|
+
elif arg is None:
|
|
72
|
+
args[i] = ffi.NULL
|
|
73
|
+
elif not is_cdata(arg):
|
|
74
|
+
if c_args[i] == "<ctype '_Bool *'>":
|
|
75
|
+
raise TypeError(
|
|
76
|
+
f"Argument {i} ({arg}) must be a ctype bool, please create one with: pyray.ffi.new('bool "
|
|
77
|
+
f"*', True)")
|
|
78
|
+
elif c_args[i] == "<ctype 'int *'>":
|
|
79
|
+
raise TypeError(
|
|
80
|
+
f"Argument {i} ({arg}) must be a ctype int, please create one with: pyray.ffi.new('int "
|
|
81
|
+
f"*', 1)")
|
|
82
|
+
elif c_args[i] == "<ctype 'float *'>":
|
|
83
|
+
raise TypeError(
|
|
84
|
+
f"Argument {i} ({arg}) must be a ctype float, please create one with: pyray.ffi.new("
|
|
85
|
+
f"'float *', 1.0)")
|
|
86
|
+
elif c_args[i] == "<ctype 'void *'>":
|
|
87
|
+
# we could assume it's a string and try to convert it but we would have to be sure it's
|
|
88
|
+
# const. that seems reasonable assumption for char* but i'm not confident it is for void*
|
|
89
|
+
raise TypeError(
|
|
90
|
+
f"Argument {i} ({arg}) must be a cdata pointer. Type is void so I don't know what type it "
|
|
91
|
+
f"should be."
|
|
92
|
+
"If it's a const string you can create it with pyray.ffi.new('char []', b\"whatever\") . "
|
|
93
|
+
"If it's a float you can create it with pyray.ffi.new('float *', 1.0)")
|
|
94
|
+
|
|
95
|
+
result = original_func(*args)
|
|
96
|
+
if result is None:
|
|
97
|
+
return
|
|
98
|
+
elif is_cdata(result) and str(result).startswith("<cdata 'char *'"):
|
|
99
|
+
if str(result) == "<cdata 'char *' NULL>":
|
|
100
|
+
return ""
|
|
101
|
+
else:
|
|
102
|
+
return ffi.string(result).decode('utf-8')
|
|
103
|
+
else:
|
|
104
|
+
return result
|
|
105
|
+
|
|
106
|
+
# apparently pypy and cpython produce different types so check for both
|
|
107
|
+
def is_cdata(arg):
|
|
108
|
+
return str(type(arg)) == "<class '_cffi_backend.__CDataOwn'>" or str(
|
|
109
|
+
type(arg)) == "<class '_cffi_backend._CDataBase'>"
|
|
110
|
+
|
|
111
|
+
return wrapped_func
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
global_weakkeydict = weakref.WeakKeyDictionary()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _make_struct_constructor_function(struct):
|
|
118
|
+
def func(*args):
|
|
119
|
+
# print(struct, args)
|
|
120
|
+
modified_args = []
|
|
121
|
+
for (field, arg) in zip(ffi.typeof(struct).fields, args):
|
|
122
|
+
# print("arg:", str(arg), "field:", field[1], "field type:", field[1].type, "type(arg):", str(type(arg)))
|
|
123
|
+
if arg is None:
|
|
124
|
+
arg = ffi.NULL
|
|
125
|
+
elif (field[1].type.kind == 'pointer'
|
|
126
|
+
and (str(type(arg)) == "<class 'numpy.ndarray'>"
|
|
127
|
+
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
|
|
128
|
+
arg = ffi.from_buffer(field[1].type, arg)
|
|
129
|
+
modified_args.append(arg)
|
|
130
|
+
s = ffi.new(f"struct {struct} *", modified_args)[0]
|
|
131
|
+
global_weakkeydict[s] = modified_args
|
|
132
|
+
return s
|
|
133
|
+
|
|
134
|
+
return func
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
for name, attr in getmembers(rl):
|
|
138
|
+
# print(name, attr)
|
|
139
|
+
uname = _underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
|
|
140
|
+
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
|
|
141
|
+
type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
|
142
|
+
# print(attr.__call__)
|
|
143
|
+
# print(attr.__doc__)
|
|
144
|
+
# print(dir(attr))
|
|
145
|
+
# print(dir(attr.__repr__))
|
|
146
|
+
f = _wrap_function(attr)
|
|
147
|
+
setattr(current_module, uname, f)
|
|
148
|
+
else:
|
|
149
|
+
setattr(current_module, name, attr)
|
|
150
|
+
|
|
151
|
+
for struct in ffi.list_types()[0]:
|
|
152
|
+
f = _make_struct_constructor_function(struct)
|
|
153
|
+
setattr(current_module, struct, f)
|
|
154
|
+
|
|
155
|
+
# overwrite ffi enums with our own
|
|
156
|
+
from raylib.enums import *
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def text_format(*args):
|
|
160
|
+
raise RuntimeError("Use Python f-strings etc rather than calling text_format().")
|
|
@@ -937,10 +937,10 @@ def gui_line(bounds: Rectangle,text: str,) -> int:
|
|
|
937
937
|
def gui_list_view(bounds: Rectangle,text: str,scrollIndex: Any,active: Any,) -> int:
|
|
938
938
|
"""List View control, returns selected list item index"""
|
|
939
939
|
...
|
|
940
|
-
def gui_list_view_ex(bounds: Rectangle,text: str,count: int,scrollIndex: Any,active: Any,focus: Any,) -> int:
|
|
940
|
+
def gui_list_view_ex(bounds: Rectangle,text: list[str],count: int,scrollIndex: Any,active: Any,focus: Any,) -> int:
|
|
941
941
|
"""List View with extended parameters"""
|
|
942
942
|
...
|
|
943
|
-
def gui_load_icons(fileName: str,loadIconsName: bool,) -> str:
|
|
943
|
+
def gui_load_icons(fileName: str,loadIconsName: bool,) -> list[str]:
|
|
944
944
|
"""Load raygui icons file (.rgi) into internal icons data"""
|
|
945
945
|
...
|
|
946
946
|
def gui_load_style(fileName: str,) -> None:
|
|
@@ -994,7 +994,7 @@ def gui_spinner(bounds: Rectangle,text: str,value: Any,minValue: int,maxValue: i
|
|
|
994
994
|
def gui_status_bar(bounds: Rectangle,text: str,) -> int:
|
|
995
995
|
"""Status Bar control, shows info text"""
|
|
996
996
|
...
|
|
997
|
-
def gui_tab_bar(bounds: Rectangle,text: str,count: int,active: Any,) -> int:
|
|
997
|
+
def gui_tab_bar(bounds: Rectangle,text: list[str],count: int,active: Any,) -> int:
|
|
998
998
|
"""Tab Bar control, returns TAB to be closed or -1"""
|
|
999
999
|
...
|
|
1000
1000
|
def gui_text_box(bounds: Rectangle,text: str,textSize: int,editMode: bool,) -> int:
|
|
@@ -1864,7 +1864,7 @@ def text_insert(text: str,insert: str,position: int,) -> str:
|
|
|
1864
1864
|
def text_is_equal(text1: str,text2: str,) -> bool:
|
|
1865
1865
|
"""Check if two text string are equal"""
|
|
1866
1866
|
...
|
|
1867
|
-
def text_join(textList: str,count: int,delimiter: str,) -> str:
|
|
1867
|
+
def text_join(textList: list[str],count: int,delimiter: str,) -> str:
|
|
1868
1868
|
"""Join text strings with delimiter"""
|
|
1869
1869
|
...
|
|
1870
1870
|
def text_length(text: str,) -> int:
|
|
@@ -1873,7 +1873,7 @@ def text_length(text: str,) -> int:
|
|
|
1873
1873
|
def text_replace(text: str,replace: str,by: str,) -> str:
|
|
1874
1874
|
"""Replace text string (WARNING: memory must be freed!)"""
|
|
1875
1875
|
...
|
|
1876
|
-
def text_split(text: str,delimiter: str,count: Any,) -> str:
|
|
1876
|
+
def text_split(text: str,delimiter: str,count: Any,) -> list[str]:
|
|
1877
1877
|
"""Split text into multiple strings"""
|
|
1878
1878
|
...
|
|
1879
1879
|
def text_subtext(text: str,position: int,length: int,) -> str:
|
|
@@ -2260,7 +2260,7 @@ def glfw_get_current_context() -> Any:
|
|
|
2260
2260
|
def glfw_get_cursor_pos(window: Any,xpos: Any,ypos: Any,) -> None:
|
|
2261
2261
|
""""""
|
|
2262
2262
|
...
|
|
2263
|
-
def glfw_get_error(description: str,) -> int:
|
|
2263
|
+
def glfw_get_error(description: list[str],) -> int:
|
|
2264
2264
|
""""""
|
|
2265
2265
|
...
|
|
2266
2266
|
def glfw_get_framebuffer_size(window: Any,width: Any,height: Any,) -> None:
|
|
@@ -2338,16 +2338,16 @@ def glfw_get_primary_monitor() -> Any:
|
|
|
2338
2338
|
def glfw_get_proc_address(procname: str,) -> Any:
|
|
2339
2339
|
""""""
|
|
2340
2340
|
...
|
|
2341
|
-
def glfw_get_required_instance_extensions(count: Any,) -> str:
|
|
2341
|
+
def glfw_get_required_instance_extensions(count: Any,) -> list[str]:
|
|
2342
2342
|
""""""
|
|
2343
2343
|
...
|
|
2344
2344
|
def glfw_get_time() -> float:
|
|
2345
2345
|
""""""
|
|
2346
2346
|
...
|
|
2347
|
-
def glfw_get_timer_frequency() ->
|
|
2347
|
+
def glfw_get_timer_frequency() -> int:
|
|
2348
2348
|
""""""
|
|
2349
2349
|
...
|
|
2350
|
-
def glfw_get_timer_value() ->
|
|
2350
|
+
def glfw_get_timer_value() -> int:
|
|
2351
2351
|
""""""
|
|
2352
2352
|
...
|
|
2353
2353
|
def glfw_get_version(major: Any,minor: Any,rev: Any,) -> None:
|
|
@@ -2452,7 +2452,7 @@ def glfw_set_cursor_pos(window: Any,xpos: float,ypos: float,) -> None:
|
|
|
2452
2452
|
def glfw_set_cursor_pos_callback(window: Any,callback: Any,) -> Any:
|
|
2453
2453
|
""""""
|
|
2454
2454
|
...
|
|
2455
|
-
def glfw_set_drop_callback(window: Any,callback: str,) -> str:
|
|
2455
|
+
def glfw_set_drop_callback(window: Any,callback: list[str],) -> list[str]:
|
|
2456
2456
|
""""""
|
|
2457
2457
|
...
|
|
2458
2458
|
def glfw_set_error_callback(callback: str,) -> str:
|
|
@@ -3397,6 +3397,34 @@ class rlVertexBuffer:
|
|
|
3397
3397
|
self.indices=indices
|
|
3398
3398
|
self.vaoId=vaoId
|
|
3399
3399
|
self.vboId=vboId
|
|
3400
|
+
|
|
3401
|
+
LIGHTGRAY : Color
|
|
3402
|
+
GRAY : Color
|
|
3403
|
+
DARKGRAY : Color
|
|
3404
|
+
YELLOW : Color
|
|
3405
|
+
GOLD : Color
|
|
3406
|
+
ORANGE : Color
|
|
3407
|
+
PINK : Color
|
|
3408
|
+
RED : Color
|
|
3409
|
+
MAROON : Color
|
|
3410
|
+
GREEN : Color
|
|
3411
|
+
LIME : Color
|
|
3412
|
+
DARKGREEN : Color
|
|
3413
|
+
SKYBLUE : Color
|
|
3414
|
+
BLUE : Color
|
|
3415
|
+
DARKBLUE : Color
|
|
3416
|
+
PURPLE : Color
|
|
3417
|
+
VIOLET : Color
|
|
3418
|
+
DARKPURPLE : Color
|
|
3419
|
+
BEIGE : Color
|
|
3420
|
+
BROWN : Color
|
|
3421
|
+
DARKBROWN : Color
|
|
3422
|
+
WHITE : Color
|
|
3423
|
+
BLACK : Color
|
|
3424
|
+
BLANK : Color
|
|
3425
|
+
MAGENTA : Color
|
|
3426
|
+
RAYWHITE : Color
|
|
3427
|
+
|
|
3400
3428
|
from enum import IntEnum
|
|
3401
3429
|
|
|
3402
3430
|
class ConfigFlags(IntEnum):
|
|
@@ -4111,44 +4139,3 @@ class GuiIconName(IntEnum):
|
|
|
4111
4139
|
ICON_254 = 254
|
|
4112
4140
|
ICON_255 = 255
|
|
4113
4141
|
|
|
4114
|
-
# Copyright (c) 2021 Richard Smith and others
|
|
4115
|
-
#
|
|
4116
|
-
# This program and the accompanying materials are made available under the
|
|
4117
|
-
# terms of the Eclipse Public License 2.0 which is available at
|
|
4118
|
-
# http://www.eclipse.org/legal/epl-2.0.
|
|
4119
|
-
#
|
|
4120
|
-
# This Source Code may also be made available under the following Secondary
|
|
4121
|
-
# licenses when the conditions for such availability set forth in the Eclipse
|
|
4122
|
-
# Public License, v. 2.0 are satisfied: GNU General Public License, version 2
|
|
4123
|
-
# with the GNU Classpath Exception which is
|
|
4124
|
-
# available at https://www.gnu.org/software/classpath/license.html.
|
|
4125
|
-
#
|
|
4126
|
-
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
4127
|
-
|
|
4128
|
-
LIGHTGRAY =( 200, 200, 200, 255 )
|
|
4129
|
-
GRAY =( 130, 130, 130, 255 )
|
|
4130
|
-
DARKGRAY =( 80, 80, 80, 255 )
|
|
4131
|
-
YELLOW =( 253, 249, 0, 255 )
|
|
4132
|
-
GOLD =( 255, 203, 0, 255 )
|
|
4133
|
-
ORANGE =( 255, 161, 0, 255 )
|
|
4134
|
-
PINK =( 255, 109, 194, 255 )
|
|
4135
|
-
RED =( 230, 41, 55, 255 )
|
|
4136
|
-
MAROON =( 190, 33, 55, 255 )
|
|
4137
|
-
GREEN =( 0, 228, 48, 255 )
|
|
4138
|
-
LIME =( 0, 158, 47, 255 )
|
|
4139
|
-
DARKGREEN =( 0, 117, 44, 255 )
|
|
4140
|
-
SKYBLUE =( 102, 191, 255, 255 )
|
|
4141
|
-
BLUE =( 0, 121, 241, 255 )
|
|
4142
|
-
DARKBLUE =( 0, 82, 172, 255 )
|
|
4143
|
-
PURPLE =( 200, 122, 255, 255 )
|
|
4144
|
-
VIOLET =( 135, 60, 190, 255 )
|
|
4145
|
-
DARKPURPLE =( 112, 31, 126, 255 )
|
|
4146
|
-
BEIGE =( 211, 176, 131, 255 )
|
|
4147
|
-
BROWN =( 127, 106, 79, 255 )
|
|
4148
|
-
DARKBROWN =( 76, 63, 47, 255 )
|
|
4149
|
-
WHITE =( 255, 255, 255, 255 )
|
|
4150
|
-
BLACK =( 0, 0, 0, 255 )
|
|
4151
|
-
BLANK =( 0, 0, 0, 0 )
|
|
4152
|
-
MAGENTA =( 255, 0, 255, 255 )
|
|
4153
|
-
RAYWHITE =( 245, 245, 245, 255 )
|
|
4154
|
-
|