diff --git a/docs-src/RPI.rst b/docs-src/RPI.rst new file mode 120000 index 0000000..60349ff --- /dev/null +++ b/docs-src/RPI.rst @@ -0,0 +1 @@ +../RPI.rst \ No newline at end of file diff --git a/docs-src/pyray.rst b/docs-src/pyray.rst index a7129f7..c93773c 100644 --- a/docs-src/pyray.rst +++ b/docs-src/pyray.rst @@ -3,7 +3,16 @@ Python API This is a wrapper around the C API with some syntactic sugar. -The API is *still the same as Raylib*, so you should still reply on `the official Raylib docs `_, except: +The API is *still the same as Raylib*, so you should still reply on: + +* `the C Raylib docs `_ + +* `the C Raylib examples `_ + +* `the C Raylib header file `_ + + +The *differences* are: * the function names are in **snake_case**. @@ -11,6 +20,9 @@ The API is *still the same as Raylib*, so you should still reply on `the officia * There are some helper functions to create structures. +Examples +-------- + Example program: .. code-block:: @@ -45,9 +57,10 @@ Example program: init_window(800, 450, "Raylib texture test") ... - You don't need to use the PyRay() class anymore. + (You don't need to use the PyRay() class anymore.) + +`See all examples here `_ -See also https://github.com/electronstudio/raylib-python-cffi/blob/master/tests/test_pyray.py API reference ------------- diff --git a/docs-src/raylib.rst b/docs-src/raylib.rst index 51d5f73..76b4005 100644 --- a/docs-src/raylib.rst +++ b/docs-src/raylib.rst @@ -1,7 +1,8 @@ C API ============= -The goal of the C API is make usage as similar to the original C as CFFI will allow. The `example programs `_ +The goal of the C API is make usage as similar to the original C as CFFI will allow. +So the `example programs `_ are very, very similar to the C originals. Example program: @@ -39,11 +40,16 @@ If you want to be more portable (i.e. same code will work with dynamic bindings) ... -See also https://github.com/electronstudio/raylib-python-cffi/blob/master/tests/test_static.py .. note:: Whenever you need to convert stuff between C and Python see https://cffi.readthedocs.io -.. important:: Your **primary reference** should always be `the official Raylib docs `_ +.. important:: Your **primary reference** should always be + + * `the C Raylib docs `_ + + * `the C Raylib examples `_ + + * `the C Raylib header file `_ However, here is a list of available functions: diff --git a/dynamic/raylib/defines.py b/dynamic/raylib/defines.py new file mode 100644 index 0000000..9b988bf --- /dev/null +++ b/dynamic/raylib/defines.py @@ -0,0 +1,9 @@ +import raylib + +MOUSE_LEFT_BUTTON = raylib.MOUSE_BUTTON_LEFT +MOUSE_RIGHT_BUTTON = raylib.MOUSE_BUTTON_RIGHT +MOUSE_MIDDLE_BUTTON = raylib.MOUSE_BUTTON_MIDDLE +MATERIAL_MAP_DIFFUSE = raylib.MATERIAL_MAP_ALBEDO +MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS +SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO +SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS \ No newline at end of file diff --git a/dynamic/raylib/libraylib.dylib b/dynamic/raylib/libraylib.dylib index 42da768..83e4eb7 100755 Binary files a/dynamic/raylib/libraylib.dylib and b/dynamic/raylib/libraylib.dylib differ diff --git a/dynamic/raylib/libraylib.so b/dynamic/raylib/libraylib.so index 134f573..6caf3a8 100755 Binary files a/dynamic/raylib/libraylib.so and b/dynamic/raylib/libraylib.so differ diff --git a/dynamic/raylib/raylib.dll b/dynamic/raylib/raylib.dll index 398f83e..c220506 100644 Binary files a/dynamic/raylib/raylib.dll and b/dynamic/raylib/raylib.dll differ diff --git a/pyray/__init__.py b/pyray/__init__.py index 69177cc..abe44ca 100644 --- a/pyray/__init__.py +++ b/pyray/__init__.py @@ -14,7 +14,10 @@ from raylib import rl, ffi from raylib.colors import * -from raylib.defines import * +try: + from raylib.defines import * +except AttributeError: + print("sorry deprecated enums dont work on dynamic version") from inspect import ismethod,getmembers,isbuiltin diff --git a/pyray/__init__.pyi b/pyray/__init__.pyi index 07eef4f..9602313 100644 --- a/pyray/__init__.pyi +++ b/pyray/__init__.pyi @@ -5,7 +5,7 @@ def pointer(struct): ... def attach_audio_stream_processor(stream: AudioStream,processor: Any,) -> None: - """""" + """Attach audio stream processor to stream""" ... def begin_blend_mode(mode: int,) -> None: """Begin blending mode (alpha, additive, multiplied, subtract, custom)""" @@ -143,7 +143,7 @@ def destroy_physics_body(PhysicsBodyData_pointer_0: Any,) -> None: CFFI C function from raylib._raylib_cffi.lib""" ... def detach_audio_stream_processor(stream: AudioStream,processor: Any,) -> None: - """""" + """Detach audio stream processor from stream""" ... def directory_exists(dirPath: str,) -> bool: """Check if a directory path exists""" @@ -492,9 +492,6 @@ def gen_image_gradient_v(width: int,height: int,top: Color,bottom: Color,) -> Im def gen_image_white_noise(width: int,height: int,factor: float,) -> Image: """Generate image: white noise""" ... -def gen_mesh_binormals(mesh: Any,) -> None: - """Compute mesh binormals""" - ... def gen_mesh_cone(radius: float,height: float,slices: int,) -> Mesh: """Generate cone/pyramid mesh""" ... @@ -1415,9 +1412,6 @@ def load_sound(fileName: str,) -> Sound: def load_sound_from_wave(wave: Wave,) -> Sound: """Load sound from wave data""" ... -def load_storage_value(position: int,) -> int: - """Load integer value from storage file (from defined position)""" - ... def load_texture(fileName: str,) -> Texture: """Load texture from file into GPU memory (VRAM)""" ... @@ -1755,9 +1749,6 @@ def save_file_data(fileName: str,data: Any,bytesToWrite: int,) -> bool: def save_file_text(fileName: str,text: str,) -> bool: """Save text data to file (write), string must be '\0' terminated, returns true on success""" ... -def save_storage_value(position: int,value: int,) -> bool: - """Save integer value to storage file (to defined position), returns true on success""" - ... def seek_music_stream(music: Music,position: float,) -> None: """Seek music to a position (in seconds)""" ... @@ -2372,6 +2363,11 @@ CFFI C function from raylib._raylib_cffi.lib""" def vector3_refract(Vector3_0: Vector3,Vector3_1: Vector3,float_2: float,) -> Vector3: """struct Vector3 Vector3Refract(struct Vector3, struct Vector3, float); +CFFI C function from raylib._raylib_cffi.lib""" + ... +def vector3_rotate_by_axis_angle(Vector3_0: Vector3,Vector3_1: Vector3,float_2: float,) -> Vector3: + """struct Vector3 Vector3RotateByAxisAngle(struct Vector3, struct Vector3, float); + CFFI C function from raylib._raylib_cffi.lib""" ... def vector3_rotate_by_quaternion(Vector3_0: Vector3,Vector4_1: Vector4,) -> Vector3: diff --git a/raygui b/raygui index 38236a5..4e2a878 160000 --- a/raygui +++ b/raygui @@ -1 +1 @@ -Subproject commit 38236a5513c8ceb112b6d2e944c6993d37eb5cae +Subproject commit 4e2a878e715c4aafa6ad7bd58d851221503c6e60 diff --git a/raylib-c b/raylib-c index 61e691d..d658e67 160000 --- a/raylib-c +++ b/raylib-c @@ -1 +1 @@ -Subproject commit 61e691d94fee0d2700ac3e8ed8783cf9c7516ab0 +Subproject commit d658e6772d75bce52fbe46cc9789f0b33500bc0f diff --git a/raylib/__init__.pyi b/raylib/__init__.pyi index 04a237b..6a56acf 100644 --- a/raylib/__init__.pyi +++ b/raylib/__init__.pyi @@ -7,7 +7,7 @@ ARROWS_SIZE: int ARROWS_VISIBLE: int ARROW_PADDING: int def AttachAudioStreamProcessor(stream: AudioStream,processor: Any,) -> None: - """""" + """Attach audio stream processor to stream""" ... BACKGROUND_COLOR: int BASE_COLOR_DISABLED: int @@ -186,7 +186,7 @@ def DestroyPhysicsBody(PhysicsBodyData_pointer_0: Any,) -> None: CFFI C function from raylib._raylib_cffi.lib""" ... def DetachAudioStreamProcessor(stream: AudioStream,processor: Any,) -> None: - """""" + """Detach audio stream processor from stream""" ... def DirectoryExists(dirPath: str,) -> bool: """Check if a directory path exists""" @@ -589,9 +589,6 @@ def GenImageGradientV(width: int,height: int,top: Color,bottom: Color,) -> Image def GenImageWhiteNoise(width: int,height: int,factor: float,) -> Image: """Generate image: white noise""" ... -def GenMeshBinormals(mesh: Any,) -> None: - """Compute mesh binormals""" - ... def GenMeshCone(radius: float,height: float,slices: int,) -> Mesh: """Generate cone/pyramid mesh""" ... @@ -1895,9 +1892,6 @@ def LoadSound(fileName: str,) -> Sound: def LoadSoundFromWave(wave: Wave,) -> Sound: """Load sound from wave data""" ... -def LoadStorageValue(position: int,) -> int: - """Load integer value from storage file (from defined position)""" - ... def LoadTexture(fileName: str,) -> Texture: """Load texture from file into GPU memory (VRAM)""" ... @@ -2454,9 +2448,6 @@ def SaveFileData(fileName: str,data: Any,bytesToWrite: int,) -> bool: def SaveFileText(fileName: str,text: str,) -> bool: """Save text data to file (write), string must be '\0' terminated, returns true on success""" ... -def SaveStorageValue(position: int,value: int,) -> bool: - """Save integer value to storage file (to defined position), returns true on success""" - ... def SeekMusicStream(music: Music,position: float,) -> None: """Seek music to a position (in seconds)""" ... @@ -3097,6 +3088,11 @@ CFFI C function from raylib._raylib_cffi.lib""" def Vector3Refract(Vector3_0: Vector3,Vector3_1: Vector3,float_2: float,) -> Vector3: """struct Vector3 Vector3Refract(struct Vector3, struct Vector3, float); +CFFI C function from raylib._raylib_cffi.lib""" + ... +def Vector3RotateByAxisAngle(Vector3_0: Vector3,Vector3_1: Vector3,float_2: float,) -> Vector3: + """struct Vector3 Vector3RotateByAxisAngle(struct Vector3, struct Vector3, float); + CFFI C function from raylib._raylib_cffi.lib""" ... def Vector3RotateByQuaternion(Vector3_0: Vector3,Vector4_1: Vector4,) -> Vector3: diff --git a/raylib/raylib.h.modified b/raylib/raylib.h.modified index 2ed048a..12d1818 100644 --- a/raylib/raylib.h.modified +++ b/raylib/raylib.h.modified @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib v4.2-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) +* raylib v4.2 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) * * FEATURES: * - NO external dependencies, all required libraries included with raylib @@ -80,6 +80,7 @@ // Some basic Defines //---------------------------------------------------------------------------------- // Allow custom memory allocators +// NOTE: Require recompiling raylib sources // NOTE: MSVC C++ compiler does not support compound literals (C99 feature) // Plain structures in C++ (without constructors) can be initialized with { } // NOTE: We set some defines with some data types declared by raylib @@ -853,6 +854,7 @@ typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileI void *MemAlloc(int size); // Internal memory allocator void *MemRealloc(void *ptr, int size); // Internal memory reallocator void MemFree(void *ptr); // Internal memory free + void OpenURL(const char *url); // Open URL with default system browser (if available) // Set custom callbacks // WARNING: Callbacks setup is intended for advance users void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log @@ -893,10 +895,6 @@ typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree() char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree() unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree() -// Persistent storage management - bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success - int LoadStorageValue(unsigned int position); // Load integer value from storage file (from defined position) - void OpenURL(const char *url); // Open URL with default system browser (if available) //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) //------------------------------------------------------------------------------------ @@ -1226,7 +1224,6 @@ typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits void GenMeshTangents(Mesh *mesh); // Compute mesh tangents - void GenMeshBinormals(Mesh *mesh); // Compute mesh binormals // Mesh generation functions Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) @@ -1327,5 +1324,5 @@ typedef void (*AudioCallback)(void *bufferData, unsigned int frames); void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered) void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data - void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); - void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); \ No newline at end of file + void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream + void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream \ No newline at end of file diff --git a/raylib/raymath.h.modified b/raylib/raymath.h.modified index 05f494c..19707d6 100644 --- a/raylib/raymath.h.modified +++ b/raylib/raymath.h.modified @@ -124,7 +124,8 @@ inline /* Functions may be inlined or external definition used*/ Vector3 Vector3 // Gram-Schmidt function implementation inline /* Functions may be inlined or external definition used*/ void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2);// Transforms a Vector3 by a given Matrix inline /* Functions may be inlined or external definition used*/ Vector3 Vector3Transform(Vector3 v, Matrix mat);// Transform a vector by quaternion rotation -inline /* Functions may be inlined or external definition used*/ Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);// Calculate linear interpolation between two vectors +inline /* Functions may be inlined or external definition used*/ Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);// Rotates a vector around an axis +inline /* Functions may be inlined or external definition used*/ Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle);// Calculate linear interpolation between two vectors inline /* Functions may be inlined or external definition used*/ Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount);// Calculate reflected vector to normal inline /* Functions may be inlined or external definition used*/ Vector3 Vector3Reflect(Vector3 v, Vector3 normal);// Get min value for each pair of components inline /* Functions may be inlined or external definition used*/ Vector3 Vector3Min(Vector3 v1, Vector3 v2);// Get max value for each pair of components @@ -159,15 +160,20 @@ inline /* Functions may be inlined or external definition used*/ Matrix MatrixSu inline /* Functions may be inlined or external definition used*/ Matrix MatrixMultiply(Matrix left, Matrix right);// Get translation matrix inline /* Functions may be inlined or external definition used*/ Matrix MatrixTranslate(float x, float y, float z);// Create rotation matrix from axis and angle // NOTE: Angle should be provided in radians -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotate(Vector3 axis, float angle);// Get x-rotation matrix (angle in radians) -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateX(float angle);// Get y-rotation matrix (angle in radians) -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateY(float angle);// Get z-rotation matrix (angle in radians) -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateZ(float angle);// Get xyz-rotation matrix (angles in radians) -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateXYZ(Vector3 ang);// Get zyx-rotation matrix (angles in radians) -inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateZYX(Vector3 ang);// Get scaling matrix +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotate(Vector3 axis, float angle);// Get x-rotation matrix +// NOTE: Angle must be provided in radians +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateX(float angle);// Get y-rotation matrix +// NOTE: Angle must be provided in radians +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateY(float angle);// Get z-rotation matrix +// NOTE: Angle must be provided in radians +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateZ(float angle);// Get xyz-rotation matrix +// NOTE: Angle must be provided in radians +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateXYZ(Vector3 angle);// Get zyx-rotation matrix +// NOTE: Angle must be provided in radians +inline /* Functions may be inlined or external definition used*/ Matrix MatrixRotateZYX(Vector3 angle);// Get scaling matrix inline /* Functions may be inlined or external definition used*/ Matrix MatrixScale(float x, float y, float z);// Get perspective projection matrix inline /* Functions may be inlined or external definition used*/ Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far);// Get perspective projection matrix -// NOTE: Angle should be provided in radians +// NOTE: Fovy angle must be provided in radians inline /* Functions may be inlined or external definition used*/ Matrix MatrixPerspective(double fovy, double aspect, double near, double far);// Get orthographic projection matrix inline /* Functions may be inlined or external definition used*/ Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far);// Get camera look-at matrix (view matrix) inline /* Functions may be inlined or external definition used*/ Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up);// Get float array of matrix data @@ -192,7 +198,7 @@ inline /* Functions may be inlined or external definition used*/ Quaternion Quat inline /* Functions may be inlined or external definition used*/ Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to);// Get a quaternion for a given rotation matrix inline /* Functions may be inlined or external definition used*/ Quaternion QuaternionFromMatrix(Matrix mat);// Get a matrix for a given quaternion inline /* Functions may be inlined or external definition used*/ Matrix QuaternionToMatrix(Quaternion q);// Get rotation quaternion for an angle and axis -// NOTE: angle must be provided in radians +// NOTE: Angle must be provided in radians inline /* Functions may be inlined or external definition used*/ Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle);// Get the rotation angle and axis for a given quaternion inline /* Functions may be inlined or external definition used*/ void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle);// Get the quaternion equivalent to Euler angles // NOTE: Rotation order is ZYX diff --git a/tests/test_hello_world.py b/tests/test_hello_world.py index a0d9748..a76f275 100644 --- a/tests/test_hello_world.py +++ b/tests/test_hello_world.py @@ -3,6 +3,8 @@ init_window(800, 450, "Hello") while not window_should_close(): begin_drawing() clear_background(WHITE) + font = load_font_ex("/home/richard/pycharm-2022.1.4/jbr/lib/fonts/DroidSans.ttf", 30, None, 0) + draw_text_ex(font, "hellow font", (300, 300), 30, 0, BLACK) draw_text("Hello world", 190, 200, 20, VIOLET) end_drawing() close_window() diff --git a/tests/test_defines.py b/tests/xtest_defines.py similarity index 100% rename from tests/test_defines.py rename to tests/xtest_defines.py diff --git a/tests/test_music.py b/tests/xtest_music.py similarity index 100% rename from tests/test_music.py rename to tests/xtest_music.py diff --git a/tests/test_raymath.py b/tests/xtest_raymath.py similarity index 100% rename from tests/test_raymath.py rename to tests/xtest_raymath.py diff --git a/version.py b/version.py index 423d54c..0231c7e 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "4.2.0.0.dev4" \ No newline at end of file +__version__ = "4.2.0.0" \ No newline at end of file