diff --git a/examples/textures/textures_bunnymark_dynamic.py b/examples/textures/textures_bunnymark_dynamic.py index aa78fcd..9c461f6 100644 --- a/examples/textures/textures_bunnymark_dynamic.py +++ b/examples/textures/textures_bunnymark_dynamic.py @@ -9,7 +9,9 @@ # * # ********************************************************************************************/ -from raylib.static import * +from raylib.dynamic import ffi, raylib as rl +from raylib.colors import * + MAX_BUNNIES = 500000 # This is the maximum amount of elements (quads) per batch @@ -29,10 +31,10 @@ class Bunny: screenWidth = 1920; screenHeight = 1080; -InitWindow(screenWidth, screenHeight, b"raylib [textures] example - bunnymark") +rl.InitWindow(screenWidth, screenHeight, b"raylib [textures] example - bunnymark") # // Load bunny texture -texBunny = LoadTexture(b"resources/wabbit_alpha.png") +texBunny = rl.LoadTexture(b"resources/wabbit_alpha.png") bunnies = [] for i in range(0, MAX_BUNNIES): @@ -40,23 +42,23 @@ for i in range(0, MAX_BUNNIES): bunniesCount = 0; # Bunnies counter -SetTargetFPS(60); # Set our game to run at 60 frames-per-second +rl.SetTargetFPS(60); # Set our game to run at 60 frames-per-second #//-------------------------------------------------------------------------------------- #// Main game loop -while not WindowShouldClose(): #// Detect window close button or ESC key +while not rl.WindowShouldClose(): #// Detect window close button or ESC key #// Update #//---------------------------------------------------------------------------------- - if IsMouseButtonDown(MOUSE_LEFT_BUTTON): + if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON): #// Create more bunnies for i in range(0, 100): if bunniesCount < MAX_BUNNIES: - bunnies[bunniesCount].position = GetMousePosition() - bunnies[bunniesCount].speed.x = GetRandomValue(-250, 250)/60.0 - bunnies[bunniesCount].speed.y = GetRandomValue(-250, 250)/60.0 - bunnies[bunniesCount].color = (GetRandomValue(50, 240), - GetRandomValue(80, 240), - GetRandomValue(100, 240), 255 ) + bunnies[bunniesCount].position = rl.GetMousePosition() + bunnies[bunniesCount].speed.x = rl.GetRandomValue(-250, 250)/60.0 + bunnies[bunniesCount].speed.y = rl.GetRandomValue(-250, 250)/60.0 + bunnies[bunniesCount].color = (rl.GetRandomValue(50, 240), + rl.GetRandomValue(80, 240), + rl.GetRandomValue(100, 240), 255 ) bunniesCount+=1 @@ -66,18 +68,18 @@ while not WindowShouldClose(): #// Detect window close button or ESC key bunnies[i].position.x += bunnies[i].speed.x; bunnies[i].position.y += bunnies[i].speed.y; - if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0): + if ((bunnies[i].position.x + texBunny.width/2) > rl.GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0): bunnies[i].speed.x *= -1 - if ((bunnies[i].position.y + texBunny.height/2) > GetScreenHeight()) or ((bunnies[i].position.y + texBunny.height/2 - 40) < 0): + if ((bunnies[i].position.y + texBunny.height/2) > rl.GetScreenHeight()) or ((bunnies[i].position.y + texBunny.height/2 - 40) < 0): bunnies[i].speed.y *= -1 # //---------------------------------------------------------------------------------- # # // Draw # //---------------------------------------------------------------------------------- - BeginDrawing() + rl.BeginDrawing() - ClearBackground(RAYWHITE) + rl.ClearBackground(RAYWHITE) for i in range(0, bunniesCount): # // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), @@ -86,17 +88,17 @@ while not WindowShouldClose(): #// Detect window close button or ESC key # // Process of sending data is costly and it could happen that GPU data has not been completely # // processed for drawing while new data is tried to be sent (updating current in-use buffers) # // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - DrawTexture(texBunny, int(bunnies[i].position.x), int(bunnies[i].position.y), bunnies[i].color) + rl.DrawTexture(texBunny, int(bunnies[i].position.x), int(bunnies[i].position.y), bunnies[i].color) - DrawRectangle(0, 0, screenWidth, 40, BLACK) + rl.DrawRectangle(0, 0, screenWidth, 40, BLACK) text = f"bunnies {bunniesCount}" - DrawText(text.encode('utf-8'), 120, 10, 20, GREEN) + rl.DrawText(text.encode('utf-8'), 120, 10, 20, GREEN) text = f"batched draw calls: { 1 + int(bunniesCount/MAX_BATCH_ELEMENTS)}" - DrawText(text.encode('utf-8'), 320, 10, 20, MAROON) + rl.DrawText(text.encode('utf-8'), 320, 10, 20, MAROON) - DrawFPS(10, 10) + rl.DrawFPS(10, 10) - EndDrawing() + rl.EndDrawing() #//---------------------------------------------------------------------------------- @@ -104,8 +106,8 @@ while not WindowShouldClose(): #// Detect window close button or ESC key #//-------------------------------------------------------------------------------------- -UnloadTexture(texBunny); #Unload bunny texture +rl.UnloadTexture(texBunny); #Unload bunny texture -CloseWindow() # Close window and OpenGL context +rl.CloseWindow() # Close window and OpenGL context #//-------------------------------------------------------------------------------------- diff --git a/raylib/dynamic/32bit/raylib.dll b/raylib/dynamic/32bit/raylib.dll old mode 100755 new mode 100644 index 30331b0..3aca75b Binary files a/raylib/dynamic/32bit/raylib.dll and b/raylib/dynamic/32bit/raylib.dll differ diff --git a/raylib/dynamic/libraylib.dylib b/raylib/dynamic/libraylib.dylib index a723dcf..69329ee 100755 Binary files a/raylib/dynamic/libraylib.dylib and b/raylib/dynamic/libraylib.dylib differ diff --git a/raylib/dynamic/libraylib.so b/raylib/dynamic/libraylib.so deleted file mode 120000 index 551ad26..0000000 --- a/raylib/dynamic/libraylib.so +++ /dev/null @@ -1 +0,0 @@ -libraylib.so.351 \ No newline at end of file diff --git a/raylib/dynamic/libraylib.so b/raylib/dynamic/libraylib.so new file mode 100644 index 0000000..9335726 Binary files /dev/null and b/raylib/dynamic/libraylib.so differ diff --git a/raylib/dynamic/raylib.dll b/raylib/dynamic/raylib.dll old mode 100755 new mode 100644 diff --git a/setup.py b/setup.py index 1609074..5be97c4 100644 --- a/setup.py +++ b/setup.py @@ -36,5 +36,5 @@ setup( include_package_data=True, install_requires=["cffi>=1.14.5","inflection"], distclass=BinaryDistribution, - cffi_modules=["raylib/static/build.py:ffibuilder"], # this would build libs whenever the module is installed, but we are distributing static libs instead + cffi_modules=["raylib/static/build.py:ffibuilder"] ) diff --git a/setup_dynamic.py b/setup_dynamic.py new file mode 100644 index 0000000..20e1f79 --- /dev/null +++ b/setup_dynamic.py @@ -0,0 +1,34 @@ +import pathlib +from setuptools import setup +from setuptools.dist import Distribution + +# The directory containing this file +HERE = pathlib.Path(__file__).parent + +# The text of the README file +README = (HERE / "README.md").read_text() + + +# This call to setup() does all the work +setup( + name="raylib-dynamic", + version="3.7.0.post1", + description="Python CFFI bindings for Raylib", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/electronstudio/raylib-python-cffi", + author="Electron Studio", + author_email="github@electronstudio.co.uk", + license="LGPLv3+", + classifiers=[ + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + ], + packages=["raylib", "raylib.dynamic"], + include_package_data=True, + install_requires=["cffi>=1.14.5","inflection"], +)