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.

9 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
23 changed files with 454 additions and 29 deletions

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/victorfisac/Physac
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

@ -35,3 +35,4 @@ print("""from enum import IntEnum
process("raylib.json")
process("raygui.json")
process("glfw3.json")
process("physac.json")

View file

@ -83,6 +83,7 @@ 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

View file

@ -74,6 +74,7 @@ import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...

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 )

View file

@ -4,6 +4,7 @@ import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...

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

@ -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

View file

@ -908,6 +908,7 @@ from warnings import deprecated
import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
PhysicsShapeType = int
def attach_audio_mixed_processor(processor: Any,) -> None:
"""Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'."""

@ -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__)

View file

@ -4,6 +4,7 @@ import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...

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"
@ -237,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

@ -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)