### Setup Python Virtual Environment and Install Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Steps to set up a Python virtual environment and install the raylib library on Linux. This includes creating the environment, activating it, upgrading pip, and installing setuptools and raylib. ```bash python3 -m venv venv\nsource venv/bin/activate\npython3 -m pip install --upgrade pip\npython3 -m pip install setuptools\npython3 -m pip install raylib==5.5.0.3 ``` -------------------------------- ### BeginDrawing Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Setup canvas (framebuffer) to start drawing. ```APIDOC ## BeginDrawing ### Description Setup canvas (framebuffer) to start drawing. ### Method `BeginDrawing` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```json null ``` ### Response #### Success Response (200) - None (This function returns None) #### Response Example ```json null ``` ``` -------------------------------- ### Web Browser Application Setup Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html This code demonstrates the basic setup for running a raylib application in a web browser using Pygbag. Ensure you have Pygbag and raylib installed. The main function must be asynchronous. ```python # /// script # dependencies = [ # "cffi", # "raylib" # ] # /// import asyncio import platform from pyray import * async def main(): # You MUST have an async main function init_window(500, 500, "Hello") ``` -------------------------------- ### Build a Binary Wheel Distribution (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst After building Raylib, create a binary wheel distribution for raylib-python-cffi. This involves cleaning the build directory, installing necessary tools, and running the setup script. ```bash rmdir /Q /S build pip3 install cffi pip3 install wheel python setup.py bdist_wheel ``` -------------------------------- ### Install Setuptools and Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/README.md Installs the setuptools package, which is often required for building Python packages, followed by the raylib Python package version 5.5.0.4. ```bash python3 -m pip install setuptools python3 -m pip install raylib==5.5.0.4 ``` -------------------------------- ### Install and Run Pygbag for Web Deployment Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/README.html Use these commands to install pygbag and create web-ready files for your project. Point your browser to http://localhost:8000 to view the application. ```bash python3.12 -m pip install --user --upgrade pygbag python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl --git my_project ``` -------------------------------- ### Basic Raylib Window Example Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt A simple "Hello, world!" example demonstrating how to initialize a window, clear the background, draw text, and close the window using the pyray module. ```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() ``` -------------------------------- ### Windows Manual Build: Create and Install Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html After building the Raylib C library, this process creates a binary wheel distribution for the Python bindings and then installs it. ```batch 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 Dynamic Raylib Binding Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Installs the dynamic version of the raylib Python binding. Uninstall the static version first if it is already installed. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_dynamic ``` -------------------------------- ### 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() ``` ``` -------------------------------- ### Linux Manual Build: Create and Install Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html Builds a binary wheel distribution for the Python bindings and then installs it. For PyPI compatibility on Linux, use the `build_multi_linux.sh` script. ```bash pip3 install wheel python3 setup.py bdist_wheel pip3 install dist/raylib*.whl ``` -------------------------------- ### 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 raylib Python library. ```python from pyray import *\ninit_window(800, 450, "Hello")\nwhile not window_should_close():\n begin_drawing()\n clear_background(WHITE)\n draw_text("Hello world", 190, 200, 20, VIOLET)\n end_drawing()\nclose_window() ``` -------------------------------- ### Compile Raylib from Source (X11 Mode) - Install Python Wheel Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Installs pip and then compiles and installs the raylib-python-cffi wheel, forcing a reinstall and upgrade. Use `--break-system-packages` if needed. ```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 ``` -------------------------------- ### Build and Install Raylib from Source (macOS) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Builds and installs Raylib from its source directory on macOS. This involves creating a build directory, configuring with CMake, compiling, and installing. ```bash cd raylib-python-cffi/raylib-c/ mkdir build cd build cmake -DWITH_PIC=on -DCMAKE_BUILD_TYPE=Release .. make sudo make install cd ../.. ``` -------------------------------- ### 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 SDL Backend for Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Installs the raylib Python binding with SDL backend support. Uninstall any existing raylib packages first. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_sdl ``` -------------------------------- ### Install Raylib (Linux/macOS) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs-src/README.md Commands to set up a virtual environment, upgrade pip, and install the raylib package on Linux or macOS. ```bash python3 -m venv venv source venv/bin/activate python3 -m pip install --upgrade pip python3 -m pip install setuptools python3 -m pip install raylib==5.5.0.4 ``` -------------------------------- ### Compile Raylib from Source (X11 Mode) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/RPI.rst Installs dependencies, clones the raylib repository, configures the build for X11, compiles, and installs Raylib. This is recommended if binary wheels do not work or for older/32-bit systems. ```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 5.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_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/ ``` ```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 Raylib Python CFFI (Linux/General) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Installs the raylib Python CFFI library and setuptools, typically after setting up a virtual environment. ```bash python3 -m pip install setuptools python3 -m pip install raylib==5.5.0.3 ``` -------------------------------- ### Install Raylib from Source on MacOS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/README.md Installs necessary development tools (pkg-config, raylib) using Homebrew and then installs the raylib Python package. This is for macOS users who need to build from source. ```bash brew install pkg-config brew install raylib python3 -m pip install raylib==5.5.0.4 ``` -------------------------------- ### Install DRM Binary Wheel for Raspberry Pi OS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Install the `raylib_drm` wheel for framebuffer access without X11. Only one wheel (X11 or DRM) can be installed at a time. ```bash python -m pip install --break-system-packages raylib_drm ``` -------------------------------- ### 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 ``` ``` -------------------------------- ### Create Binary Wheel Distribution Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Installs the wheel package and then builds a binary wheel distribution of the raylib Python CFFI library using `setup.py`. This is useful for easier installation. ```bash pip3 install wheel python3 setup.py bdist_wheel ``` -------------------------------- ### Build and Install Raylib from Source (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Compile and install the Raylib library from its source directory using CMake. This is part of the manual build process on Linux. You can use a pre-installed Raylib version if preferred. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -DSUPPORT_FILEFORMAT_JPG=ON -DSUPPORT_FILEFORMAT_FLAC=ON -DWITH_PIC=ON -DCMAKE_BUILD_TYPE=Release .. sudo make install ``` -------------------------------- ### Install Built Wheel Distribution Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Installs the previously built binary wheel distribution of the raylib Python CFFI library. This command should be run after `bdist_wheel`. ```bash pip3 install dist/raylib*.whl ``` -------------------------------- ### StartAutomationEventRecording() Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Starts recording automation events. ```APIDOC ## StartAutomationEventRecording() ### Description Begins the process of recording user input and other events for automation purposes. ### Method `raylib.StartAutomationEventRecording()` ### Parameters None ### Response None ``` -------------------------------- ### Install Raylib on MacOS Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Installs Raylib development libraries using Homebrew on MacOS, a prerequisite for building raylib-python-cffi from source if binary wheels are not available. ```bash brew install pkg-config brew install raylib python3 -m pip install raylib==5.5.0.3 ``` -------------------------------- ### Install Built Wheel (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Install the locally built wheel file for raylib-python-cffi. Note that the filename will vary based on your system's Python version and architecture. ```bash pip3 install dist\raylib-3.7.0-cp37-cp37m-win_amd64.whl ``` -------------------------------- ### 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 Begins the process of recording user input and other events for automation purposes. ### Method `pyray.start_automation_event_recording()` ### Parameters None ### Response None ``` -------------------------------- ### Install DRM Backend for Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Installs the raylib Python binding with DRM backend support, suitable for Linux systems without X11/Wayland. Uninstall any existing raylib packages first. ```bash python3 -m pip uninstall raylib python3 -m pip install raylib_drm ``` -------------------------------- ### 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 a pre-compiled 64-bit binary wheel for Raspberry Pi OS Bullseye in X11 mode. Ensure you use the `--break-system-packages` flag if necessary. ```bash python -m pip install --break-system-packages raylib ``` -------------------------------- ### Install Build Dependencies (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Install the necessary development packages and tools required for building Raylib and raylib-python-cffi on a Linux system. This includes CMake, graphics libraries, and pkg-config. ```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 Python CFFI Module (macOS) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Installs the raylib Python CFFI module on macOS after building Raylib. This includes installing cffi, building the bindings, and then installing the module using `setup.py`. ```bash pip3 install cffi rm -rf build raylib/_raylib_cffi.* python3 raylib/build.py pip3 install wheel python3 setup.py install ``` -------------------------------- ### GuiGetState Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the current state of the GUI. ```APIDOC ## GuiGetState() ### Description Retrieves the current state of the GUI (e.g., normal, disabled). ### Returns int - The current GUI state. ``` -------------------------------- ### Get File Length Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the size of a file in bytes. ```APIDOC ## get_file_length() ### Description Gets the size of a file in bytes. ### Method `pyray.get_file_length(file_path)` ### Parameters - **file_path** (str) - The path to the file. ### Response - **length** (int) - The size of the file in bytes. ``` -------------------------------- ### InitWindow Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initializes the window and OpenGL context. ```APIDOC ## raylib.InitWindow ### Description Initialize window and OpenGL context. ### Signature raylib.InitWindow(_width: int_, _height: int_, _title: bytes_) → None ``` -------------------------------- ### Get Line Width Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the current line width setting. ```APIDOC ## rlGetLineWidth ### Description Gets the current line width setting. ### Method `rlGetLineWidth()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python current_width = rlGetLineWidth() print(f"Current line width: {current_width}") ``` ### Response - **float**: The current line width. ``` -------------------------------- ### Get Framebuffer Width Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the width of the currently bound framebuffer. ```APIDOC ## rlGetFramebufferWidth ### Description Gets the width of the currently bound framebuffer. ### Method `rlGetFramebufferWidth()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python fb_width = rlGetFramebufferWidth() print(f"Framebuffer width: {fb_width}") ``` ### Response - **int**: The width of the framebuffer in pixels. ``` -------------------------------- ### InitAudioDevice Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Initializes the audio device and context. ```APIDOC ## raylib.InitAudioDevice ### Description Initialize audio device and context. ### Signature raylib.InitAudioDevice() → None ``` -------------------------------- ### Get Framebuffer Height Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the height of the currently bound framebuffer. ```APIDOC ## rlGetFramebufferHeight ### Description Gets the height of the currently bound framebuffer. ### Method `rlGetFramebufferHeight()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python fb_height = rlGetFramebufferHeight() print(f"Framebuffer height: {fb_height}") ``` ### Response - **int**: The height of the framebuffer in pixels. ``` -------------------------------- ### Get Active Framebuffer Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the ID of the currently active framebuffer. ```APIDOC ## rlGetActiveFramebuffer ### Description Gets the ID of the currently active framebuffer. ### Method `rlGetActiveFramebuffer()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python current_fbo = rlGetActiveFramebuffer() print(f"Current FBO ID: {current_fbo}") ``` ### Response - **int**: The ID of the currently active framebuffer. Returns 0 for the default framebuffer. ``` -------------------------------- ### Install Raylib with Break System Packages Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/README.md Installs the raylib Python package version 5.5.0.4, using the `--break-system-packages` flag. This is a common installation command for Python packages. ```bash pip3 install raylib==5.5.0.4 --break-system-packages ``` -------------------------------- ### Initialization and Configuration Functions Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Functions for initializing the library and configuring settings. ```APIDOC ## glfwInit ### Description Initializes the GLFW library. This function must be called before most other GLFW functions. ### Method `raylib.glfwInit()` ### Returns Returns `raylib.TRUE` if initialization was successful, or `raylib.FALSE` otherwise. ## glfwInitAllocator ### Description Initializes a custom memory allocator. ### Method `raylib.glfwInitAllocator(_allocator: Any | list | tuple_)` ### Parameters - `_allocator`: A pointer to the allocator object. ## glfwInitHint ### Description Sets an initialization hint for GLFW. ### Method `raylib.glfwInitHint(_hint: int_, _value: int_)` ### Parameters - `_hint`: The initialization hint to set (e.g., `raylib.CLIENT_API`). - `_value`: The desired value for the hint. ``` -------------------------------- ### Initialization Functions Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Functions to initialize audio device, physics, and the game window. ```APIDOC ## init_audio_device() ### Description Initializes the audio device and subsystems. ## init_physics() ### Description Initializes the physics system. ## init_window() ### Description Initializes the window and OpenGL context. ### Parameters * `width` (int) - The width of the window. * `height` (int) - The height of the window. * `title` (str) - The title of the window. ``` -------------------------------- ### 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` ``` -------------------------------- ### Get Glyph Index Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the index of a character in the font's glyphs. ```APIDOC ## get_glyph_index() ### Description Gets the index of a character in the font's glyphs. ### Method `pyray.get_glyph_index(font, character)` ### Parameters - **font** (Font) - The font to search within. - **character** (int) - The Unicode codepoint of the character. ### Response - **index** (int) - The index of the glyph. ``` -------------------------------- ### 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) ... ``` -------------------------------- ### Get Location Uniform Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the location of a uniform variable in a shader program. ```APIDOC ## rlGetLocationUniform ### Description Gets the location of a uniform variable in a shader program. ### Method `rlGetLocationUniform(shader, uniformName)` ### Endpoint N/A (Python function) ### Parameters #### Path Parameters - **shader** (int) - The shader program ID. - **uniformName** (str) - The name of the uniform variable. ### Request Example ```python # Assuming 'my_shader_id' is a valid shader ID # uniform_location = rlGetLocationUniform(my_shader_id, "u_Color") # print(f"Uniform location: {uniform_location}") ``` ### Response - **int**: The location index of the uniform variable. Returns -1 if not found. ``` -------------------------------- ### 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() ``` -------------------------------- ### Get Location Attribute Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the location of a vertex attribute in a shader program. ```APIDOC ## rlGetLocationAttrib ### Description Gets the location of a vertex attribute in a shader program. ### Method `rlGetLocationAttrib(shader, attribName)` ### Endpoint N/A (Python function) ### Parameters #### Path Parameters - **shader** (int) - The shader program ID. - **attribName** (str) - The name of the vertex attribute. ### Request Example ```python # Assuming 'my_shader_id' is a valid shader ID # attr_location = rlGetLocationAttrib(my_shader_id, "a_Position") # print(f"Attribute location: {attr_location}") ``` ### Response - **int**: The location index of the vertex attribute. Returns -1 if not found. ``` -------------------------------- ### glfwGetJoystickGUID Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Returns the GUID of the specified joystick. The GUID is a unique identifier for the joystick. ```APIDOC ## glfwGetJoystickGUID() ### Description Returns the GUID of the specified joystick. The GUID is a unique identifier for the joystick. ### Method `raylib.glfwGetJoystickGUID(joy)` ### Parameters #### Path Parameters - **joy** (int) - Required - The joystick to query. ### Response - **str** - The GUID of the joystick, or `None` if the joystick is not connected. ``` -------------------------------- ### pyray.glfw_init Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Initializes the GLFW library. ```APIDOC ## pyray.glfw_init ### Description Initializes the GLFW library. ### Signature pyray.glfw_init() -> int ``` -------------------------------- ### Get Shader Location Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the location (uniform index) of a uniform variable in a shader. ```APIDOC ## get_shader_location() ### Description Gets the location (uniform index) of a uniform variable in a shader. ### Method `pyray.get_shader_location(shader, uniform_name)` ### Parameters - **shader** (Shader) - The shader program. - **uniform_name** (str) - The name of the uniform variable. ### Response - **location** (int) - The location of the uniform, or -1 if not found. ``` -------------------------------- ### is_window_ready Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Check if the window has been successfully initialized. ```APIDOC ## is_window_ready ### Description Check if window has been initialized successfully. ### Signature pyray.is_window_ready() → bool ``` -------------------------------- ### Get Shader Location Attribute Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the location (attribute index) of an attribute variable in a shader. ```APIDOC ## get_shader_location_attrib() ### Description Gets the location (attribute index) of an attribute variable in a shader. ### Method `pyray.get_shader_location_attrib(shader, attrib_name)` ### Parameters - **shader** (Shader) - The shader program. - **attrib_name** (str) - The name of the attribute variable. ### Response - **location** (int) - The location of the attribute, or -1 if not found. ``` -------------------------------- ### 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() ``` -------------------------------- ### Create a Virtual Environment (Linux) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Steps to create and activate a Python virtual environment on Linux systems before installing raylib. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Get Cull Distance Near Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the near clipping plane distance used for culling. ```APIDOC ## rlGetCullDistanceNear ### Description Gets the near clipping plane distance used for culling. ### Method `rlGetCullDistanceNear()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python near_distance = rlGetCullDistanceNear() print(f"Near culling distance: {near_distance}") ``` ### Response - **float**: The near clipping plane distance. ``` -------------------------------- ### Get Cull Distance Far Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the far clipping plane distance used for culling. ```APIDOC ## rlGetCullDistanceFar ### Description Gets the far clipping plane distance used for culling. ### Method `rlGetCullDistanceFar()` ### Endpoint N/A (Python function) ### Parameters None ### Request Example ```python far_distance = rlGetCullDistanceFar() print(f"Far culling distance: {far_distance}") ``` ### Response - **float**: The far clipping plane distance. ``` -------------------------------- ### pyray.glfw_init_hint Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Sets a window hint for GLFW. ```APIDOC ## pyray.glfw_init_hint ### Description Sets a window hint for GLFW. ### Signature pyray.glfw_init_hint(_hint: int_, _value: int_) -> None ``` -------------------------------- ### Initialize Hint Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Sets a window creation attribute hint for GLFW. Hints affect the subsequent window and OpenGL/Vulkan context creation. ```APIDOC ## glfwInitHint() ### Description Sets a window creation attribute hint for GLFW. ### Method POST ### Endpoint /glfwInitHint ``` -------------------------------- ### glfw_default_window_hints Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Sets the default window creation parameters. ```APIDOC ## glfw_default_window_hints ### Description Sets the default window creation parameters. ### Method `pyray.glfw_default_window_hints()` ### Response #### Success Response (200) (No specific return value documented, operation is a side effect) ``` -------------------------------- ### pyray.glfw_default_window_hints() Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Sets the default window creation hints to those used for creating windows with glfwCreateWindow. ```APIDOC ## pyray.glfw_default_window_hints() ### Description Sets the default window creation hints. ### Returns - None ``` -------------------------------- ### glfw_init_hint Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Sets the specified initialization hint. ```APIDOC ## glfw_init_hint ### Description Sets the specified initialization hint. ### Method (Not specified, likely a function call in a Python SDK) ### Parameters (Parameters not specified in the source) ### Request Example (Not specified) ### Response (Not specified) ``` -------------------------------- ### Build and Install Raylib from Source (Windows) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Build the Raylib library from its source directory using CMake and MSBuild. This step is part of the manual build process on Windows. ```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 ..\.. ``` -------------------------------- ### BeginMode3D Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Begins 3D mode with a custom camera. This function sets up the camera for 3D rendering. ```APIDOC ## BeginMode3D ### Description Begins 3D mode with custom camera (3D). ### Parameters #### Path Parameters - **_camera** (Camera3D | list | tuple_) - Required - The camera to use for 3D mode. ### Returns None ``` -------------------------------- ### Install Raylib Python CFFI Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Install the raylib Python CFFI library using pip. Ensure you are using the correct version and consider using --break-system-packages if needed. ```bash pip3 install raylib==5.5.0.3 --break-system-packages ``` -------------------------------- ### GuiDefaultProperty Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Default properties that can be extended for GUI elements. ```APIDOC BACKGROUND_COLOR = 19 LINE_COLOR = 18 TEXT_ALIGNMENT_VERTICAL = 21 TEXT_LINE_SPACING = 20 TEXT_SIZE = 16 TEXT_SPACING = 17 TEXT_WRAP_MODE = 22 ``` -------------------------------- ### Get Key Pressed Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Retrieves the key code of the last key pressed. This function can be called multiple times to get keys from a queue, returning 0 when the queue is empty. ```APIDOC ## GET KEY PRESSED ### Description Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty. ### Method GET ### Endpoint /key/pressed ### Returns - **int**: The keycode of the last pressed key, or 0 if the queue is empty. ``` -------------------------------- ### rl_begin Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Begins a drawing mode or frame. ```APIDOC ## rl_begin() Begins a drawing mode or frame. ### Method `rl_begin()` ``` -------------------------------- ### Build Raylib Python CFFI Bindings Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst Installs the cffi package and then builds the raylib Python CFFI bindings by running the `build.py` script. This step is necessary before packaging. ```bash pip3 install cffi rm -rf build raylib/_raylib_cffi.* python3 raylib/build.py ``` -------------------------------- ### glfwCreateWindow Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Creates a window and its associated OpenGL or Vulkan context. The window will be hidden until `glfwShowWindow` is called. ```APIDOC ## glfwCreateWindow() ### Description Creates a window and its associated OpenGL or Vulkan context. The window will be hidden until `glfwShowWindow` is called. ### Method `raylib.glfwCreateWindow(width, height, title, monitor, share)` ### Parameters #### Path Parameters - **width** (int) - Required - The desired width, in screen coordinates, of the window. - **height** (int) - Required - The desired height, in screen coordinates, of the window. - **title** (str) - Required - The UTF-8 encoded title of the window. - **monitor** (Monitor) - Optional - The monitor to use for fullscreen mode, or `None` for windowed mode. - **share** (Window) - Optional - The window whose context will be shared with the new window, or `None` to not share context. ### Response - **Window** - The handle of the created window, or `None` if it failed. ``` -------------------------------- ### text_length Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the length of a string. ```APIDOC ## text_length ### Description Gets the length of a string. ### Signature `text_length(text)` ### Parameters - **text** (str) - The input string. ### Returns - (int) - The length of the string. ### Example ```python import pyray length = pyray.text_length("Hello") # length is 5 ``` ``` -------------------------------- ### GuiDefaultProperty Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Represents a default property for GUI elements. ```APIDOC ## GuiDefaultProperty (class) ### Description Represents a default property that can be applied to GUI elements. ### Attributes * **value** - The default value. ``` -------------------------------- ### Generate Project Documentation Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/AGENTS.md Command to generate project documentation using Sphinx. ```bash ./make_docs.sh ``` -------------------------------- ### 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 ### Description Gets the name of a gamepad. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### 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 Gets the default font. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### get_clipboard_text Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the text from the clipboard. ```APIDOC ## get_clipboard_text ### Description Gets the text from the clipboard. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### Packaging with Nuitka Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/README.md.txt Example command to package a Raylib Python CFFI application into a standalone binary using Nuitka. This command is run from the terminal. ```bash pip3 install nuitka cd examples/textures python3 -m nuitka --onefile --linux-onefile-icon resources/wabbit_alpha.png textures_bunnymark.py ``` -------------------------------- ### get_clipboard_image Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the image from the clipboard. ```APIDOC ## get_clipboard_image ### Description Gets the image from the clipboard. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### GuiDefaultProperty Constants Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Constants for default properties applied to GUI elements. ```APIDOC ## GuiDefaultProperty Constants ### Description Constants that define default visual properties for GUI elements. ### Constants - `GuiDefaultProperty.BACKGROUND_COLOR` - `GuiDefaultProperty.LINE_COLOR` - `GuiDefaultProperty.TEXT_ALIGNMENT_VERTICAL` - `GuiDefaultProperty.TEXT_LINE_SPACING` - `GuiDefaultProperty.TEXT_SIZE` - `GuiDefaultProperty.TEXT_SPACING` - `GuiDefaultProperty.TEXT_WRAP_MODE` ``` -------------------------------- ### get_char_pressed Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the character that was pressed. ```APIDOC ## get_char_pressed ### Description Gets the character that was pressed. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### get_camera_matrix Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Gets the camera matrix. ```APIDOC ## get_camera_matrix ### Description Gets the camera matrix. ### Parameters (No parameters specified in the source) ### Returns (No return value specified in the source) ``` -------------------------------- ### Linux Manual Build: Build Raylib C Library (Static) Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/BUILDING.html Builds the static Raylib C library using CMake and Make. The library is installed system-wide. ```bash cd raylib-python-cffi/raylib-c mkdir build cd build cmake -DCUSTOMIZE_BUILD=ON -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 cd ../.. ``` -------------------------------- ### Compile Raylib from Source (X11 Mode) - Build Raylib Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/_sources/RPI.rst.txt Clones the Raylib repository, configures the build for X11 mode with specific OpenGL and feature settings, and compiles the library. ```bash git clone https://github.com/raysan5/raylib.git --branch 5.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_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/ ``` -------------------------------- ### Initialization Functions Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Functions to initialize core raylib systems like audio device, physics, and the game window. ```APIDOC ## init_audio_device() (pyray) ### Description Initializes the audio device. ### Method `pyray.init_audio_device()` ## init_physics() (pyray) ### Description Initializes the physics system. ### Method `pyray.init_physics()` ## init_window() (pyray) ### Description Initializes the window and OpenGL context. ### Method `pyray.init_window(width, height, title)` ### Parameters - **width** (int) - The width of the window. - **height** (int) - The height of the window. - **title** (str) - The title of the window. ## InitAudioDevice() (raylib) ### Description Initializes the audio device. ### Method `raylib.InitAudioDevice()` ## InitPhysics() (raylib) ### Description Initializes the physics system. ### Method `raylib.InitPhysics()` ## InitWindow() (raylib) ### Description Initializes the window and OpenGL context. ### Method `raylib.InitWindow(width, height, title)` ### Parameters - **width** (int) - The width of the window. - **height** (int) - The height of the window. - **title** (str) - The title of the window. ``` -------------------------------- ### rl_get_framebuffer_width Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Get the width of the default framebuffer. ```APIDOC ## rl_get_framebuffer_width ### Description Get default framebuffer width. ### Signature `pyray.rl_get_framebuffer_width() → int` ``` -------------------------------- ### Automation and Input Configuration Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Functions for setting up automation events, clipboard text, configuration flags, exit keys, gamepad mappings, and gestures. ```APIDOC ## SetAutomationEventBaseFrame ### Description Set automation event internal base frame to start recording. ### Method `raylib.SetAutomationEventBaseFrame(_frame: int_)` ### Parameters - **_frame** (int) - The base frame number. ``` ```APIDOC ## SetAutomationEventList ### Description Set automation event list to record to. ### Method `raylib.SetAutomationEventList(_list_0: Any | list | tuple_)` ### Parameters - **_list_0** (Any | list | tuple_) - The list to record automation events to. ``` ```APIDOC ## SetClipboardText ### Description Set clipboard text content. ### Method `raylib.SetClipboardText(_text: bytes_)` ### Parameters - **_text** (bytes) - The text to set to the clipboard. ``` ```APIDOC ## SetConfigFlags ### Description Setup init configuration flags (view FLAGS). ### Method `raylib.SetConfigFlags(_flags: int_)` ### Parameters - **_flags** (int) - Configuration flags. ``` ```APIDOC ## SetExitKey ### Description Set a custom key to exit program (default is ESC). ### Method `raylib.SetExitKey(_key: int_)` ### Parameters - **_key** (int) - The key to use for exiting the program. ``` ```APIDOC ## SetGamepadMappings ### Description Set internal gamepad mappings (SDL_GameControllerDB). ### Method `raylib.SetGamepadMappings(_mappings: bytes_)` ### Parameters - **_mappings** (bytes) - The gamepad mappings data. ``` ```APIDOC ## SetGamepadVibration ### Description Set gamepad vibration for both motors (duration in seconds). ### Method `raylib.SetGamepadVibration(_gamepad: int_, _leftMotor: float_, _rightMotor: float_, _duration: float_)` ### Parameters - **_gamepad** (int) - The gamepad index. - **_leftMotor** (float) - The intensity of the left motor. - **_rightMotor** (float) - The intensity of the right motor. - **_duration** (float) - The duration of the vibration in seconds. ``` ```APIDOC ## SetGesturesEnabled ### Description Enable a set of gestures using flags. ### Method `raylib.SetGesturesEnabled(_flags: int_)` ### Parameters - **_flags** (int) - Flags representing the gestures to enable. ``` -------------------------------- ### rl_get_framebuffer_height Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Get the height of the default framebuffer. ```APIDOC ## rl_get_framebuffer_height ### Description Get default framebuffer height. ### Signature `pyray.rl_get_framebuffer_height() → int` ``` -------------------------------- ### pyray.gui_get_style Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Get one style property. ```APIDOC ## pyray.gui_get_style ### Description Get one style property. ### Signature pyray.gui_get_style(_control: int_, _property: int_) -> int ``` -------------------------------- ### GuiDefaultProperty Enum Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/genindex.html Enumeration for default GUI properties, including text spacing and wrap modes. ```APIDOC ## pyray.GuiDefaultProperty.TEXT_SPACING ### Description Default property for text spacing in GUI elements. ### Type Enum Member ### Usage ```python pyray.GuiDefaultProperty.TEXT_SPACING ``` ``` ```APIDOC ## pyray.GuiDefaultProperty.TEXT_WRAP_MODE ### Description Default property for text wrapping mode in GUI elements. ### Type Enum Member ### Usage ```python pyray.GuiDefaultProperty.TEXT_WRAP_MODE ``` ``` -------------------------------- ### pyray.get_file_length Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the size of a file in bytes. ```APIDOC ## pyray.get_file_length ### Description Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h). ### Parameters - **_fileName** (str) - The name of the file. ### Returns - int - The file size in bytes. ``` -------------------------------- ### raylib.GuiEnableTooltip Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/raylib.html Enables GUI tooltips globally. ```APIDOC ## raylib.GuiEnableTooltip ### Description Enable gui tooltips (global state). ### Method `raylib.GuiEnableTooltip() → None` ``` -------------------------------- ### pyray.glfw_create_window() Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Creates a new window and its associated OpenGL context. ```APIDOC ## pyray.glfw_create_window(width, height, title, monitor, share) ### Description Creates a window and its OpenGL context. ### Parameters #### Path Parameters - **width** (int_) - The desired width of the window in screen coordinates. - **height** (int_) - The desired height of the window in screen coordinates. - **title** (str_) - The UTF-8 encoded window title. - **monitor** (Any | list | tuple_) - The monitor to which the window will be attached, or null to create a windowed mode window. - **share** (Any | list | tuple_) - The window whose context will be shared, or null to not share context. ### Returns - Any: The handle of the created window, or null if it failed. ``` -------------------------------- ### rl_get_version Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the raylib version string. ```APIDOC ## rl_get_version ### Description Gets the raylib version string. ### Method APICALL const char * rl_get_version(void) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response (const char *) - **const char *** - The raylib version string. ``` -------------------------------- ### rl_get_texture_id_default Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Gets the default texture ID. ```APIDOC ## rl_get_texture_id_default ### Description Gets the default texture ID. ### Method APICALL int rl_get_texture_id_default(void) ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response (int) - **int** - The default texture ID. ``` -------------------------------- ### pyray.start_automation_event_recording Source: https://github.com/electronstudio/raylib-python-cffi/blob/master/docs/pyray.html Begins recording automation events. Requires an AutomationEventList to be set. ```APIDOC ## start_automation_event_recording ### Description Start recording automation events (AutomationEventList must be set). ```