### Initialize and run a basic Raylib window Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs-src/raylib.rst A standard example showing window initialization, camera setup, and the main drawing loop. ```python from raylib import * InitWindow(800, 450, b"Hello Raylib") SetTargetFPS(60) camera = ffi.new("struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0]) while not WindowShouldClose(): UpdateCamera(camera, CAMERA_ORBITAL) BeginDrawing() ClearBackground(RAYWHITE) BeginMode3D(camera[0]) DrawGrid(20, 1.0) EndMode3D() DrawText(b"Hellow World", 190, 200, 20, VIOLET) EndDrawing() CloseWindow() ``` -------------------------------- ### Initialize and run a basic Pyray window Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs-src/pyray.rst A complete example demonstrating window initialization, camera setup, and the main drawing loop. ```python import pyray as pr pr.init_window(800, 450, "Hello Pyray") pr.set_target_fps(60) camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0) while not pr.window_should_close(): pr.update_camera(camera, pr.CAMERA_ORBITAL) pr.begin_drawing() pr.clear_background(pr.RAYWHITE) pr.begin_mode_3d(camera) pr.draw_grid(20, 1.0) pr.end_mode_3d() pr.draw_text("Hello world", 190, 200, 20, pr.VIOLET) pr.end_drawing() pr.close_window() ``` -------------------------------- ### Install from Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt Installs the previously built wheel distribution. This is the recommended way to install the library after building. ```bash pip3 install dist/raylib*.whl ``` -------------------------------- ### Install Setuptools Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/RPI.html Installs the setuptools package using pip. This is a prerequisite for building Python packages. ```bash python3 -m pip install --break-system-packages setuptools ``` -------------------------------- ### Windows: Build and Install Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html After building the Raylib C library, build a binary wheel distribution for the Python package and then install it. Ensure pip and wheel are installed. ```bash rmdir /Q /S build pip3 install cffi pip3 install wheel python setup.py bdist_wheel pip3 install dist\raylib-3.7.0-cp37-cp37m-win_amd64.whl ``` -------------------------------- ### Install Raylib SDL Backend Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Install the raylib package with an SDL backend. This option offers better controller support but is less tested. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_sdl ``` -------------------------------- ### Basic Usage Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/raylib.rst.txt A simple example demonstrating how to initialize a window, set the frame rate, and draw basic elements using the raylib-python-cffi library. ```APIDOC ## Basic Usage Example ### Description This example shows the fundamental steps to get started with raylib in Python, including window creation, game loop, and basic drawing operations. ### Code ```python from raylib import * InitWindow(800, 450, b"Hello Raylib") SetTargetFPS(60) camera = ffi.new("struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0]) while not WindowShouldClose(): UpdateCamera(camera, CAMERA_ORBITAL) BeginDrawing() ClearBackground(RAYWHITE) BeginMode3D(camera[0]) DrawGrid(20, 1.0) EndMode3D() DrawText(b"Hellow World", 190, 200, 20, VIOLET) EndDrawing() CloseWindow() ``` ``` -------------------------------- ### Build Binary Wheel Distribution (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt After building Raylib, create a binary wheel distribution for raylib-python-cffi using Python's setup tools. This prepares the package for installation. ```bash rmdir /Q /S build pip3 install cffi pip3 install wheel python setup.py bdist_wheel ``` -------------------------------- ### Basic Raylib Python Window Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html A simple "Hello world" example demonstrating how to initialize a window, clear the background, draw text, and close the window using the pyray library. ```python from pyray import * init_window(800, 450, "Hello") while not window_should_close(): begin_drawing() clear_background(WHITE) draw_text("Hello world", 190, 200, 20, VIOLET) end_drawing() close_window() ``` -------------------------------- ### Install Nuitka Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs-src/README.md Install the Nuitka compiler using pip. This is a prerequisite for packaging your application. ```bash pip3 install nuitka ``` -------------------------------- ### Build and Install Raylib from Source (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Builds and installs the Raylib C library from the cloned repository on a Linux system. This assumes Raylib has been cloned as a submodule. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. make sudo make install ``` -------------------------------- ### Linux: Install Dependencies and Build Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html Install necessary development packages for Raylib on Linux, then build and install the Raylib C library using CMake and Make. This includes setting the PKG_CONFIG_PATH. ```bash sudo apt install cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev pkg-config cmake cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_FILEFORMAT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. sudo make install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ``` -------------------------------- ### Install raylib-dynamic Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/dynamic.rst.txt Install the dynamic bindings for raylib-python-cffi using pip. This command installs the package and its dependencies. ```bash python3 -m pip install raylib_dynamic ``` -------------------------------- ### Install Raylib Python CFFI (Static) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Install the static version of the raylib-python-cffi package. This is the primary installation method. ```bash python3 -m pip install setuptools python3 -m pip install raylib==6.0.1.0 ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Installs necessary development libraries for building raylib on Debian-based systems. ```bash sudo apt install cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev pkg-config cmake ``` -------------------------------- ### Install Raylib from Source using CMake (Linux/Mac) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt This process ensures Raylib is installed with necessary pkg-config files, which is crucial for the pip build. It involves downloading, extracting, configuring with CMake, compiling, and installing Raylib. ```bash wget https://github.com/raysan5/raylib/archive/refs/tags/6.0.zip unzip 6.0.zip cd raylib-6.0 mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_FILEFORMAT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. make sudo make install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ``` -------------------------------- ### Install Raylib DRM Backend Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Install the raylib package with a DRM backend for devices that do not run X11/Wayland, utilizing the Linux framebuffer. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_drm ``` -------------------------------- ### Compile Raylib from Source (X11 Mode) - Build and Install Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Builds the Raylib library using 'make' and installs it system-wide. It also copies the GLFW header files to the system include directory. ```bash make sudo make install sudo cp -r ../src/external/glfw/include/GLFW /usr/local/include/ ``` -------------------------------- ### Install Raylib Dynamic Binding Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Install the dynamic version of the raylib binding. This may work on systems where the static version has issues. Read the caveats before use. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_dynamic ``` -------------------------------- ### Build and Install Static Raylib Library (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Compiles and installs the static raylib C library with custom build options. Ensure you are in the 'raylib-c' directory. ```bash cd raylib-python-cffi/raylib-c/ mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. sudo make install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ``` -------------------------------- ### Linux: Build and Install Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html Build a binary wheel distribution for the Python package on Linux and then install it. Use the appropriate build script for manylinux compatibility. ```bash pip3 install wheel python3 setup.py bdist_wheel pip3 install dist/raylib*.whl ``` -------------------------------- ### Build and Install Static Raylib Library (macOS) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Compiles and installs the static raylib C library on macOS. Ensure you are in the 'raylib-c' directory. ```bash cd raylib-python-cffi/raylib-c/ mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. make sudo make install ``` -------------------------------- ### Build and Install Raylib from Source (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt Compile and install the Raylib library from its source directory using CMake and MSBuild. This step is part of the manual Windows build process. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. msbuild raylib.sln /target:raylib /property:Configuration=Release copy raylib\Release\raylib.lib ..\..\.. cd ..\..\.. ``` -------------------------------- ### Portable Usage Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/raylib.rst.txt An example demonstrating a more portable way to use raylib functions by prefixing them with 'rl' for potential dynamic binding compatibility. ```APIDOC ## Portable Usage Example ### Description This example illustrates how to use raylib functions with an `rl` prefix, which can be beneficial for code that needs to work with both static and dynamic bindings. ### Code ```python from raylib import ffi, rl, colors rl.InitWindow(800, 450, b"Hello Raylib") rl.SetTargetFPS(60) # ... rest of the code ``` ``` -------------------------------- ### Install Binary Wheel for Raspberry Pi OS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Use this command to install the pre-compiled binary wheel for 64-bit Raspberry Pi OS (Bookworm/Trixie). Ensure you use '--break-system-packages' if needed. ```bash python -m pip install --break-system-packages raylib ``` -------------------------------- ### Package Bunnymark with Nuitka Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Use the Nuitka compiler to create a standalone binary for your Python application. This example shows how to package the Bunnymark example. ```bash pip3 install nuitka cd examples/textures python3 -m nuitka --onefile --linux-onefile-icon resources/wabbit_alpha.png textures_bunnymark.py ``` -------------------------------- ### Install raylib-python-cffi Wheel (X11 Mode) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Installs the raylib-python-cffi wheel after compiling Raylib from source for X11. This command forces pip to compile the wheel locally and ensures the correct version is installed. ```bash python3 -m pip install --break-system-packages setuptools python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0 ``` -------------------------------- ### Install Built Wheel (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt Install the generated wheel file for raylib-python-cffi. The filename will vary based on your system and Python version. ```bash pip3 install dist\raylib-3.7.0-cp37-cp37m-win_amd64.whl ``` -------------------------------- ### Install Raylib from Source using CMake (Linux/Mac) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst This snippet shows how to download, compile, and install Raylib using CMake on Linux or macOS. Ensure pkg-config files are included for proper integration. ```bash wget https://github.com/raysan5/raylib/archive/refs/tags/6.0.zip unzip 6.0.zip cd raylib-6.0 mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. make sudo make install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ``` -------------------------------- ### StartAutomationEventRecording() Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Starts recording automation events. ```APIDOC ## StartAutomationEventRecording() ### Description Starts recording automation events for testing or playback purposes. ### Method StartAutomationEventRecording() ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python import raylib raylib.StartAutomationEventRecording() ``` ### Response None ``` -------------------------------- ### Build and Install Raylib from Source (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/BUILDING.rst.txt Compile and install the Raylib library from its source directory. This is part of the manual Linux build process for raylib-python-cffi. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. make sudo make install ``` -------------------------------- ### Basic Raylib Window and Drawing Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html This example demonstrates the fundamental structure of a Raylib application in Python using the CFFI bindings. It initializes a window, sets the frame rate, configures a 3D camera, and enters a main loop for drawing. ```python from raylib import * InitWindow(800, 450, b"Hello Raylib") SetTargetFPS(60) camera = ffi.new("struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0]) while not WindowShouldClose(): UpdateCamera(camera, CAMERA_ORBITAL) BeginDrawing() ClearBackground(RAYWHITE) BeginMode3D(camera[0]) DrawGrid(20, 1.0) EndMode3D() DrawText(b"Hellow World", 190, 200, 20, VIOLET) EndDrawing() CloseWindow() ``` -------------------------------- ### Install Raylib Python Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Install the raylib Python package using pip. The --break-system-packages flag may be required on some systems. ```bash pip3 install raylib==6.0.1.0 --break-system-packages ``` -------------------------------- ### Compile Raylib from Source for X11 Mode Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/RPI.rst Installs dependencies, clones the raylib repository, configures the build with CMake for X11 desktop mode, and installs the library. This method is recommended for broader compatibility. ```bash sudo apt update sudo apt install python3-pip cmake libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libdrm-dev libglfw3-dev git clone https://github.com/raysan5/raylib.git --branch 6.0 --single-branch cd raylib mkdir build rm -rf build/* cd build cmake -DPLATFORM="Desktop" -DOPENGL_VERSION=2.1 -DBUILD_EXAMPLES=OFF -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. make sudo make install sudo cp -r ../src/external/glfw/include/GLFW /usr/local/include/ ``` -------------------------------- ### Install Raylib and Pkg-config on MacOS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html For older MacOS versions or when building from source, install Raylib development libraries and pkg-config using Homebrew. ```bash brew install pkg-config brew install raylib python3 -m pip install raylib==6.0.1.0 ``` -------------------------------- ### start_automation_event_recording() Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Starts recording automation events. ```APIDOC ## start_automation_event_recording() ### Description Starts recording automation events for testing or playback purposes. ### Method start_automation_event_recording() ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python import pyray pyray.start_automation_event_recording() ``` ### Response None ``` -------------------------------- ### Compile Raylib from Source (DRM Mode) - Build and Install Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Builds the Raylib library using 'make' and installs it system-wide to the '/usr' prefix. This step is for the DRM mode compilation. ```bash make sudo make install ``` -------------------------------- ### macOS: Build and Install Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html On macOS, build and install the Raylib C library using CMake and Make after cloning the repository. This is a prerequisite for building the Python bindings. ```bash cd raylib-python-cffi/ cd raylib-c/ mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. make sudo make install ``` -------------------------------- ### Initialize Window Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initializes the application window with specified dimensions and title, and sets up the OpenGL context. ```APIDOC ## InitWindow ### Description Initialize window and OpenGL context. ### Method Not applicable (Python function call) ### Function Signature `raylib.InitWindow(_width: int_, _height: int_, _title: bytes_) -> None` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # raylib.InitWindow(800, 600, b"My Game Window") ``` ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### rlglInit Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initialize rlgl, setting up buffers, shaders, textures, and states. ```APIDOC ## rlglInit ### Description Initialize rlgl (buffers, shaders, textures, states). ### Signature `raylib.rlglInit(_width: int_, _height: int_) -> None` ``` -------------------------------- ### Install DRM Binary Wheel for Raspberry Pi OS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Use this command to install the DRM binary wheel for framebuffer mode. Note that you cannot have both the standard and DRM wheels installed simultaneously. ```bash python -m pip install --break-system-packages raylib_drm ``` -------------------------------- ### Initialize Audio Device Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initializes the audio device and its associated context, preparing it for audio playback. ```APIDOC ## InitAudioDevice ### Description Initialize audio device and context. ### Method Not applicable (Python function call) ### Function Signature `raylib.InitAudioDevice() -> None` ### Parameters None ### Request Example ```python # raylib.InitAudioDevice() ``` ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### pyray.init_audio_device Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Initializes the audio device and context, preparing it for audio playback. ```APIDOC ## pyray.init_audio_device ### Description Initializes the audio device and context. ### Method `pyray.init_audio_device()` ### Returns None ``` -------------------------------- ### Remove Existing Raylib and GLFW Installations Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Removes any previously installed Raylib and GLFW packages and files to ensure a clean installation for DRM mode. This includes system packages, pkgconfig files, and library files. ```bash sudo apt remove raylib raylib-dev libraylib libraylib-dev sudo rm /usr/local/lib/pkgconfig/raylib.pc sudo rm -rf /usr/local/lib/libraylib.* /usr/lib/libraylib.* sudo apt remove libglfw3-dev libglfw3 sudo rm -rf /usr/local/include/GLFW ``` -------------------------------- ### Initialization and Window Management Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/pyray.rst.txt Functions for initializing the window, setting the target FPS, and closing the window. ```APIDOC ## init_window ### Description Initializes the window and OpenGL context, sets the window title and dimensions, and configures the frame rate. ### Signature `init_window(width: int, height: int, title: str) -> None` ## set_target_fps ### Description Sets the target frames per second for the application. ### Signature `set_target_fps(fps: int) -> None` ## close_window ### Description Closes the window and releases resources. ### Signature `close_window() -> None` ``` -------------------------------- ### Portable Raylib Initialization with Prefixed Functions Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/raylib.rst.txt This example shows how to initialize raylib in a way that supports dynamic bindings for increased portability. It uses prefixed functions from the 'rl' module and imports specific modules like 'ffi' and 'colors'. ```python from raylib import ffi, rl, colors rl.InitWindow(800, 450, b"Hello Raylib") rl.SetTargetFPS(60) ... ``` -------------------------------- ### glfwGetJoystickGUID Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Returns the GUID (Globally Unique Identifier) of the specified joystick. The GUID is a unique identifier for the joystick device. ```APIDOC ## glfwGetJoystickGUID ### Description Returns the GUID of the specified joystick. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in the source. ### Response Returns the GUID of the joystick as a string. ``` -------------------------------- ### Basic Raylib Window Initialization and Drawing Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/raylib.rst.txt This snippet demonstrates the fundamental setup for a raylib application using the C API, including window initialization, setting the frame rate, and basic drawing operations within the main game loop. It requires importing all functions from the raylib library. ```python from raylib import * InitWindow(800, 450, b"Hello Raylib") SetTargetFPS(60) camera = ffi.new("struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0]) while not WindowShouldClose(): UpdateCamera(camera, CAMERA_ORBITAL) BeginDrawing() ClearBackground(RAYWHITE) BeginMode3D(camera[0]) DrawGrid(20, 1.0) EndMode3D() DrawText(b"Hellow World", 190, 200, 20, VIOLET) EndDrawing() CloseWindow() ``` -------------------------------- ### Conditional Feature Initialization in Web Environment Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html This example shows how to conditionally initialize features like audio, which might not be fully supported in all web browser environments (like Emscripten). It checks the platform system before initializing audio. ```python if platform.system() != "Emscripten": # audio may not work on current version of emscripten init_audio_device() ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html On modern Linux systems, it's recommended to create and activate a virtual environment before installing packages. This helps manage dependencies. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Build and Install Raylib from Source (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Builds the Raylib C library using CMake and MSBuild within a Visual C++ command shell. It then copies the compiled library to the project root. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. msbuild raylib.sln /target:raylib /property:Configuration=Release copy raylib\Release\raylib.lib ..\..\.. cd ..\..\ ``` -------------------------------- ### Initialize Physics Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initializes the physics system, including setting up physics values, pointers, and starting the physics loop thread. ```APIDOC ## InitPhysics ### Description Initializes physics values, pointers and creates physics loop thread. ### Method Not applicable (Python function call) ### Function Signature `raylib.InitPhysics() -> None` ### Parameters None ### Request Example ```python # raylib.InitPhysics() ``` ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Basic Pyray Window and 3D Scene Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/pyray.rst.txt This snippet demonstrates the fundamental structure of a pyray application, including window initialization, setting the frame rate, defining a 3D camera, and the main game loop for drawing and updating the scene. It shows how to use pyray functions for basic 3D graphics. ```python import pyray as pr pr.init_window(800, 450, "Hello Pyray") pr.set_target_fps(60) camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0) while not pr.window_should_close(): pr.update_camera(camera, pr.CAMERA_ORBITAL) pr.begin_drawing() pr.clear_background(pr.RAYWHITE) pr.begin_mode_3d(camera) pr.draw_grid(20, 1.0) pr.end_mode_3d() pr.draw_text("Hello world", 190, 200, 20, pr.VIOLET) pr.end_drawing() pr.close_window() ``` -------------------------------- ### glfwInit Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Initializes the GLFW library. This function must be called before any other GLFW function. It sets up the necessary windowing system resources. ```APIDOC ## glfwInit ### Description Initializes the GLFW library. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in the source. ### Response Returns `True` if initialization was successful, `False` otherwise. ``` -------------------------------- ### Draw Line V Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Draws a line using Vector2 for start and end points. It takes start and end points and color as input. ```APIDOC ## Draw Line V ### Description Draws a line using Vector2 for start and end points (using gl lines). ### Parameters - **_startPos** (Vector2 | list | tuple) - The starting point of the line. - **_endPos** (Vector2 | list | tuple) - The ending point of the line. - **_color** (Color | list | tuple) - The color of the line. ``` -------------------------------- ### Check if Audio Device is Ready Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Checks if the audio device has been successfully initialized and is ready for use. ```APIDOC ## IsAudioDeviceReady ### Description Check if audio device has been initialized successfully. ### Method Not applicable (Python function call) ### Function Signature `raylib.IsAudioDeviceReady() -> bool` ### Parameters None ### Request Example ```python # is_ready = raylib.IsAudioDeviceReady() ``` ### Response #### Success Response (200) - **is_ready** (bool) - True if the audio device is ready, False otherwise. #### Response Example ```json { "is_ready": true } ``` ``` -------------------------------- ### pyray.is_audio_device_ready Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Checks if the audio device has been successfully initialized and is ready for use. ```APIDOC ## pyray.is_audio_device_ready ### Description Checks if the audio device has been initialized successfully. ### Method `pyray.is_audio_device_ready()` ### Returns bool - True if the audio device is ready, False otherwise. ``` -------------------------------- ### rlgl_init Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Initializes the rlgl library, setting up buffers, shaders, textures, and states. ```APIDOC ## rlgl_init ### Description Initializes rlgl (buffers, shaders, textures, states). ### Method `pyray.rlgl_init(_width: int_, _height: int_) ### Parameters * **_width** (int) - The initial width of the rendering context. * **_height** (int) - The initial height of the rendering context. ``` -------------------------------- ### Install Raylib-Python-CFFI Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/RPI.html Installs or upgrades the raylib-python-cffi library to a specific version (5.5.0.0). It bypasses the cache, forces a reinstall, and avoids using pre-compiled binary wheels. ```bash python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0 ``` -------------------------------- ### GuiDefaultProperty Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html A class representing default properties for GUI elements. ```APIDOC ## GuiDefaultProperty (class) ### Description A class representing default properties for GUI elements. ### Module pyray, raylib ### Usage `GuiDefaultProperty()` ``` -------------------------------- ### get_screen_width Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the screen width. ```APIDOC ## get_screen_width ### Description Gets the screen width. ### Method Not specified (likely a function call) ### Endpoint Not applicable (SDK function) ### Parameters None explicitly documented. ``` -------------------------------- ### pyray.init_physics Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Initializes the physics system, including setting up physics values, pointers, and starting the physics loop thread. ```APIDOC ## pyray.init_physics ### Description Initializes the physics system. ### Method `pyray.init_physics()` ### Returns None ``` -------------------------------- ### get_screen_height Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the screen height. ```APIDOC ## get_screen_height ### Description Gets the screen height. ### Method Not specified (likely a function call) ### Endpoint Not applicable (SDK function) ### Parameters None explicitly documented. ``` -------------------------------- ### get_monitor_name Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the name of a monitor. ```APIDOC ## get_monitor_name(monitor) ### Description Returns the name of a specified monitor. ### Parameters #### Path Parameters - **monitor** (int) - The monitor index. ### Returns (str) Monitor name. ``` -------------------------------- ### Package Bunnymark with Nuitka Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs-src/README.md Package the Bunnymark example using Nuitka to create a standalone Linux executable. Ensure you are in the correct directory and specify the icon for the executable. ```bash cd examples/textures python3 -m nuitka --onefile --linux-onefile-icon resources/wabbit_alpha.png textures_bunnymark.py ``` -------------------------------- ### Input and Callback Functions Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Functions for setting up callbacks for various input events like keyboard, mouse, and joystick events. ```APIDOC ## glfwSetCharCallback(window, callback) ### Description Sets the character callback for the specified window. This callback is invoked when a character is input. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetCharModsCallback(window, callback) ### Description Sets the character with modifiers callback for the specified window. This callback is invoked when a character is input with modifier keys pressed. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetClipboardString(window, string) ### Description Sets the content of the clipboard to the specified string. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window that owns the clipboard. * **string** (str) - The string to set as the clipboard content. ### Response None ## glfwSetCursorEnterCallback(window, callback) ### Description Sets the cursor enter/exit callback for the specified window. This callback is invoked when the cursor enters or leaves the window's content area. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetCursorPosCallback(window, callback) ### Description Sets the cursor position callback for the specified window. This callback is invoked when the cursor is moved. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetDropCallback(window, callback) ### Description Sets the file drop callback for the specified window. This callback is invoked when files are dropped onto the window. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetErrorCallback(callback) ### Description Sets the error callback. This callback is invoked when a GLFW error occurs. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **callback** (function) - The callback function to set. ### Response None ## glfwSetFramebufferSizeCallback(window, callback) ### Description Sets the framebuffer size callback for the specified window. This callback is invoked when the framebuffer of the window is resized. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetInputMode(window, mode, value) ### Description Sets the input mode of the specified window. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose input mode to set. * **mode** (int) - The input mode to set (e.g., `GLFW_CURSOR`, `GLFW_STICKY_KEYS`). * **value** (int) - The value for the input mode. ### Response None ## glfwSetJoystickCallback(callback) ### Description Sets the joystick configuration callback. This callback is invoked when a joystick is connected or disconnected. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **callback** (function) - The callback function to set. ### Response None ## glfwSetKeyCallback(window, callback) ### Description Sets the key callback for the specified window. This callback is invoked when a key is pressed or released. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetMouseButtonCallback(window, callback) ### Description Sets the mouse button callback for the specified window. This callback is invoked when a mouse button is pressed or released. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetScrollCallback(window, callback) ### Description Sets the scroll callback for the specified window. This callback is invoked when the user scrolls the mouse wheel. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowCloseCallback(window, callback) ### Description Sets the window close callback for the specified window. This callback is invoked when the user attempts to close the window. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowContentScaleCallback(window, callback) ### Description Sets the window content scale callback for the specified window. This callback is invoked when the content scale of the window changes. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowFocusCallback(window, callback) ### Description Sets the window focus callback for the specified window. This callback is invoked when the window gains or loses focus. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowIconifyCallback(window, callback) ### Description Sets the window iconify callback for the specified window. This callback is invoked when the window is iconified or restored. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowMaximizeCallback(window, callback) ### Description Sets the window maximize callback for the specified window. This callback is invoked when the window is maximized or restored. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowPosCallback(window, callback) ### Description Sets the window position callback for the specified window. This callback is invoked when the window is moved. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowRefreshCallback(window, callback) ### Description Sets the window refresh callback for the specified window. This callback is invoked when the window's content needs to be refreshed. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowShouldClose(window, value) ### Description Sets whether the window should be closed. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window to set the close flag for. * **value** (bool) - True to set the window to close, false otherwise. ### Response None ## glfwSetWindowSizeCallback(window, callback) ### Description Sets the window size callback for the specified window. This callback is invoked when the size of the window is changed. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose callback to set. * **callback** (function) - The callback function to set. ### Response None ## glfwSetWindowUserPointer(window, pointer) ### Description Sets the user pointer of the specified window. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable) ### Parameters * **window** (GLFWwindow) - The window whose user pointer to set. * **pointer** (any) - The user pointer to attach to the window. ### Response None ``` -------------------------------- ### get_key_name Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the name of a key. ```APIDOC ## get_key_name(key) ### Description Returns the human-readable name of a key (e.g., 'A', 'Space', 'Left Control'). ### Parameters #### Path Parameters - **key** (int) - The key code (e.g., `KEY_A`, `KEY_SPACE`). ### Returns (str) The name of the key. ``` -------------------------------- ### get_glyph_info Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets information about a glyph. ```APIDOC ## get_glyph_info(font, codepoint) ### Description Retrieves detailed information about a specific glyph in a font, including its metrics. ### Parameters #### Path Parameters - **font** (Font) - The font to get information from. - **codepoint** (int) - The Unicode codepoint of the character. ### Returns (GlyphInfo) A structure containing glyph information. ``` -------------------------------- ### get_gamepad_name Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the name of a gamepad. ```APIDOC ## get_gamepad_name(gamepad) ### Description Returns the name of the specified gamepad. ### Parameters #### Path Parameters - **gamepad** (int) - Gamepad index (0-15). ### Returns (str) Gamepad name. ``` -------------------------------- ### get_font_default Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the default font. ```APIDOC ## get_font_default() ### Description Returns the default font used by raylib. ### Method `pyray.get_font_default()` ### Returns (Font) The default Font object. ``` -------------------------------- ### pyray.is_window_ready Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Check if window has been initialized successfully. ```APIDOC ## pyray.is_window_ready ### Description Check if the application window has been successfully initialized. ### Method N/A (Function Call) ### Returns * **bool** - True if the window is ready, False otherwise. ``` -------------------------------- ### get_file_extension Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the extension of a file. ```APIDOC ## get_file_extension(fileName) ### Description Retrieves the file extension from a given file name. ### Parameters #### Path Parameters - **fileName** (str) - The name of the file. ### Returns (str) The file extension (e.g., ".png", ".txt"). ``` -------------------------------- ### Compile Raylib from Source for DRM Mode Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/RPI.rst Installs dependencies, clones the raylib repository, configures the build with CMake for DRM mode (framebuffer), and installs it as a shared library. Ensure X11 is not running when executing your programs. ```bash sudo apt update sudo apt install python3-pip cmake libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libdrm-dev git clone https://github.com/raysan5/raylib.git --branch 5.0 --single-branch cd raylib mkdir build rm rf build/* cd build cmake -DPLATFORM="DRM" -DBUILD_EXAMPLES=OFF -DCUSTOMIZE_BUILD=ON -DSUPPORT_BUSY_WAIT_LOOP=OFF -DSUPPORT_CUSTOM_FRAME_CONTROL=OFF -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr .. make sudo make install ``` -------------------------------- ### glfw_get_joystick_guid Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Returns the GUID of the specified joystick. ```APIDOC ## glfw_get_joystick_guid ### Description Returns the GUID of the specified joystick. ### Method Not specified (likely a function call) ### Endpoint Not applicable (SDK function) ### Parameters None explicitly documented. ``` -------------------------------- ### pyray.init_window Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Initializes the game window and the OpenGL context. This must be called before any rendering or window-related operations. ```APIDOC ## pyray.init_window ### Description Initializes the window and OpenGL context. ### Method `pyray.init_window(_width: int_, _height: int_, _title: str_)` ### Parameters * **_width** (int) - The width of the window. * **_height** (int) - The height of the window. * **_title** (str) - The title of the window. ### Returns None ```