Compare commits

..

2 commits

Author SHA1 Message Date
Richard Smith
c1e3fa2eca add libffi include path for nixos 2025-05-05 17:54:45 +01:00
Richard Smith
f6b6942292 when environment variables are set will skip the use of pkg-config in the build 2025-05-05 17:39:10 +01:00
23 changed files with 96 additions and 478 deletions

4
.gitmodules vendored
View file

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

View file

@ -83,6 +83,11 @@ 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,4 +35,3 @@ print("""from enum import IntEnum
process("raylib.json")
process("raygui.json")
process("glfw3.json")
process("physac.json")

View file

@ -83,7 +83,6 @@ 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,7 +74,6 @@ import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...

View file

@ -22,10 +22,9 @@ 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():
@ -55,9 +54,9 @@ ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
try:
raylib_fname = raylib_library_path()
rl = ffi.dlopen(raylib_fname)
logger.warning('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
except Exception as e:
logger.exception(e)
print(e)
LIGHTGRAY =( 200, 200, 200, 255 )
GRAY =( 130, 130, 130, 255 )

View file

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

View file

@ -1,101 +0,0 @@
"""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

@ -1,67 +0,0 @@
"""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

@ -1,86 +0,0 @@
"""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

@ -1,112 +0,0 @@
"""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} *", modified_args)[0]
s = ffi.new(f"struct {struct} *", modified_args)[0]
global_weakkeydict[s] = modified_args
return s

View file

@ -908,7 +908,6 @@ 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 15afe89aff2fc7da96ab5de80bde7f6186971cde
Subproject commit 26548c10620c4ae6937cf8b506c777a006b33c16

View file

@ -13,22 +13,18 @@
# 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:
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))
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)
raise
from raylib._raylib_cffi.lib import *
from raylib.colors import *
from raylib.defines import *
import cffi
from .version import __version__
logger.warning("RAYLIB STATIC %s LOADED", __version__)
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)

View file

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

View file

@ -15,53 +15,50 @@
# Assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them.
# Raylib must be installed and compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON ..
# We use /usr/local/lib/libraylib.a to ensure we link to static version
import re
import re
from cffi import FFI
import os
import platform
import sys
import subprocess
import time
from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
REPO_ROOT = THIS_DIR.parent
# Environment variables you can set before build
#
# RAYLIB_PLATFORM: Any one of: Desktop, SDL, DRM, PLATFORM_COMMA
# RAYLIB_LINK_ARGS: Arguments to pass to the linker rather than getting them from pkg-config.
# e.g.: -L/usr/local/lib -lraylib
# RAYLIB_INCLUDE_PATH: Directory to find raylib.h rather than getting from pkg-config.
# e.g.: /usr/local/include
# RAYGUI_INCLUDE_PATH: Directory to find raygui.h
# e.g.: /usr/local/include
# GLFW_INCLUDE_PATH: Directory to find glfw3.h
# e.g.: /usr/local/include/GLFW
# PHYSAC_INCLUDE_PATH: Directory to find physac.h
# e.g.: /usr/local/include
# LIBFFI_INCLUDE_PATH:
# e.g.: /usr/local/include
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
ENABLE_WAYLAND_DRM_LEASING = os.getenv("ENABLE_WAYLAND_DRM_LEASING")
def check_raylib_installed():
def check_raylib_pkgconfig_installed():
return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
def check_SDL_installed():
def check_sdl_pkgconfig_installed():
return subprocess.run(['pkg-config', '--exists', 'sdl2'], text=True, stdout=subprocess.PIPE).returncode == 0
def get_the_include_path():
def get_the_include_path_from_pkgconfig():
return subprocess.run(['pkg-config', '--variable=includedir', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip()
def get_the_lib_path():
def get_the_lib_path_from_pkgconfig():
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():
def get_lib_flags_from_pkgconfig():
return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip().split()
stdout=subprocess.PIPE).stdout.strip()
def pre_process_header(filename, remove_function_bodies=False):
print("Pre-processing " + filename)
@ -121,24 +118,29 @@ def check_header_exists(file):
def build_unix():
if not check_raylib_installed():
raise Exception("ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib.")
if os.getenv("RAYLIB_LINK_ARGS") is None and not check_raylib_pkgconfig_installed():
raise Exception("ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib"
"or else set RAYLIB_LINK_ARGS env variable.")
if RAYLIB_PLATFORM=="SDL" and not check_SDL_installed():
raise Exception("ERROR: SDL2 not found by pkg-config. Please install pkg-config and SDL2.")
if RAYLIB_PLATFORM=="SDL" and os.getenv("RAYLIB_LINK_ARGS") is None and not check_sdl_pkgconfig_installed():
raise Exception("ERROR: SDL2 not found by pkg-config. Please install pkg-config and SDL2."
"or else set RAYLIB_LINK_ARGS env variable.")
raylib_h = get_the_include_path() + "/raylib.h"
rlgl_h = get_the_include_path() + "/rlgl.h"
raymath_h = get_the_include_path() + "/raymath.h"
raylib_include_path = os.getenv("RAYLIB_INCLUDE_PATH")
if raylib_include_path is None:
raylib_include_path = get_the_include_path_from_pkgconfig()
raylib_h = raylib_include_path + "/raylib.h"
rlgl_h = raylib_include_path + "/rlgl.h"
raymath_h = raylib_include_path + "/raymath.h"
if not os.path.isfile(raylib_h):
raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib.")
raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
if not os.path.isfile(rlgl_h):
raise Exception("ERROR: " + rlgl_h + " not found. Please install Raylib.")
raise Exception("ERROR: " + rlgl_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
if not os.path.isfile(raymath_h):
raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib.")
raise Exception("ERROR: " + raylib_h + " not found. Please install Raylib or set RAYLIB_INCLUDE_PATH.")
ffi_includes = """
#include "raylib.h"
@ -146,13 +148,19 @@ def build_unix():
#include "raymath.h"
"""
glfw3_h = get_the_include_path() + "/GLFW/glfw3.h"
glfw_include_path = os.getenv("GLFW_INCLUDE_PATH")
if glfw_include_path is None:
glfw_include_path = get_the_include_path_from_pkgconfig()
glfw3_h = glfw_include_path + "/GLFW/glfw3.h"
if RAYLIB_PLATFORM=="Desktop" and check_header_exists(glfw3_h):
ffi_includes += """
#include "GLFW/glfw3.h"
"""
raygui_h = get_the_include_path() + "/raygui.h"
raygui_include_path = os.getenv("RAYGUI_INCLUDE_PATH")
if raygui_include_path is None:
raygui_include_path = get_the_include_path_from_pkgconfig()
raygui_h = raygui_include_path + "/raygui.h"
if check_header_exists(raygui_h):
ffi_includes += """
#define RAYGUI_IMPLEMENTATION
@ -160,13 +168,20 @@ def build_unix():
#include "raygui.h"
"""
physac_h = get_the_include_path() + "/physac.h"
physac_include_path = os.getenv("PHYSAC_INCLUDE_PATH")
if physac_include_path is None:
physac_include_path = get_the_include_path_from_pkgconfig()
physac_h = physac_include_path + "/physac.h"
if check_header_exists(physac_h):
ffi_includes += """
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
"""
libffi_include_path = os.getenv("LIBFFI_INCLUDE_PATH")
if libffi_include_path is None:
libffi_include_path = get_the_include_path_from_pkgconfig()
ffibuilder.cdef(pre_process_header(raylib_h))
ffibuilder.cdef(pre_process_header(rlgl_h))
ffibuilder.cdef(pre_process_header(raymath_h, True))
@ -181,7 +196,11 @@ def build_unix():
if platform.system() == "Darwin":
print("BUILDING FOR MAC")
extra_link_args = [get_the_lib_path() + '/libraylib.a', '-framework', 'OpenGL', '-framework', 'Cocoa',
flags = os.getenv("RAYLIB_LINK_ARGS")
if flags is None:
flags = get_the_lib_path_from_pkgconfig() + '/libraylib.a'
# We use /usr/local/lib/libraylib.a to ensure we link to static version
extra_link_args = flags.split() + ['-framework', 'OpenGL', '-framework', 'Cocoa',
'-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework',
'CoreVideo']
if RAYLIB_PLATFORM=="SDL":
@ -191,16 +210,18 @@ def build_unix():
extra_compile_args = ["-Wno-error=incompatible-function-pointer-types", "-D_CFFI_NO_LIMITED_API"]
else: #platform.system() == "Linux":
print("BUILDING FOR LINUX")
extra_link_args = get_lib_flags() + [ '-lm', '-lpthread', '-lGL',
flags = os.getenv("RAYLIB_LINK_ARGS")
if flags is None:
flags = get_lib_flags_from_pkgconfig()
extra_link_args = flags.split() + [ '-lm', '-lpthread', '-lGL',
'-lrt', '-lm', '-ldl', '-lpthread', '-latomic']
if RAYLIB_PLATFORM=="SDL":
extra_link_args += ['-lX11','-lSDL2']
elif RAYLIB_PLATFORM=="DRM":
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")
extra_link_args += ['-lEGL', '-lgbm']
elif RAYLIB_PLATFORM=="PLATFORM_COMMA":
extra_link_args.remove('-lGL')
extra_link_args += ['-lGLESv2', '-lEGL', '-lwayland-client', '-lwayland-egl']
else:
extra_link_args += ['-lX11']
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
@ -213,7 +234,8 @@ def build_unix():
ffibuilder.set_source("raylib._raylib_cffi",
ffi_includes,
py_limited_api=False,
include_dirs=[get_the_include_path()],
include_dirs=[raylib_include_path, raygui_include_path, physac_include_path, glfw_include_path,
libffi_include_path],
extra_link_args=extra_link_args,
extra_compile_args=extra_compile_args,
libraries=libraries)
@ -221,13 +243,13 @@ def build_unix():
def build_windows():
print("BUILDING FOR WINDOWS")
ffibuilder.cdef((THIS_DIR / "raylib.h.modified").read_text())
ffibuilder.cdef(open("raylib/raylib.h.modified").read())
if RAYLIB_PLATFORM=="Desktop":
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())
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())
ffi_includes = """
#include "raylib.h"
@ -258,10 +280,10 @@ def build_windows():
extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
py_limited_api=False,
libraries=libraries,
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')],
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'],
)

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)
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
*
* ADDITIONAL NOTES:

View file

@ -1,30 +0,0 @@
{
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,8 +7,6 @@ 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)