From 316f0bb1e4636be0b63898f63d8dc9476a863050 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 4 Oct 2021 16:20:18 +0100 Subject: [PATCH] fix dynamic to import exactly the same as static --- dynamic/raylib/__init__.py | 3 +++ dynamic/test_dynamic.py | 10 ++++---- dynamic/test_pyray.py | 49 +------------------------------------- version.py | 2 +- 4 files changed, 10 insertions(+), 54 deletions(-) mode change 100644 => 120000 dynamic/test_pyray.py diff --git a/dynamic/raylib/__init__.py b/dynamic/raylib/__init__.py index a858bea..93b979a 100644 --- a/dynamic/raylib/__init__.py +++ b/dynamic/raylib/__init__.py @@ -24,6 +24,7 @@ import pathlib import platform from .version import __version__ + MODULE = pathlib.Path(__file__).parent def raylib_library_path(): @@ -56,3 +57,5 @@ try: print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname)) except Exception as e: print(e) + +from .pyray import PyRay \ No newline at end of file diff --git a/dynamic/test_dynamic.py b/dynamic/test_dynamic.py index 61db1bc..ed783e3 100644 --- a/dynamic/test_dynamic.py +++ b/dynamic/test_dynamic.py @@ -2,8 +2,8 @@ This shows how to use the CFFI dynamic (ABI) binding. Note that is slower and more likely to run into silent errors and segfaults. But it doesnt require any C compiler to build. """ -from raylib import ffi, rl -from raylib.colors import * + +from raylib import ffi, rl, colors rl.InitWindow(800, 450, b"Raylib dynamic binding test") rl.SetTargetFPS(60) @@ -22,12 +22,12 @@ rl.SetCameraMode(camera[0], rl.CAMERA_ORBITAL) while not rl.WindowShouldClose(): rl.UpdateCamera(camera) rl.BeginDrawing() - rl.ClearBackground(RAYWHITE) + rl.ClearBackground(colors.RAYWHITE) rl.BeginMode3D(camera[0]) - rl.DrawModel(model, (-8.0, 0.0, -8.0), 1.0, RED) + rl.DrawModel(model, (-8.0, 0.0, -8.0), 1.0, colors.RED) rl.DrawGrid(20, 1.0) rl.EndMode3D() - rl.DrawText(b"This mesh should be textured", 190, 200, 20, VIOLET) + rl.DrawText(b"This mesh should be textured", 190, 200, 20, colors.VIOLET) rl.EndDrawing() rl.CloseWindow() diff --git a/dynamic/test_pyray.py b/dynamic/test_pyray.py deleted file mode 100644 index 253cb9a..0000000 --- a/dynamic/test_pyray.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -This shows how to use the Pyray wrapper around the static binding. -""" - -from raylib.pyray import PyRay -from raylib.colors import * - -pyray = PyRay() - -pyray.init_window(800, 450, "Raylib texture test") -pyray.set_target_fps(60) - -image = pyray.gen_image_color(800, 400, (0,0,0,255) ) -texture = pyray.load_texture_from_image(image) -pyray.update_texture(texture, image.data) - -camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0) -image = pyray.load_image("../examples/models/resources/heightmap.png") -texture = pyray.load_texture_from_image(image) -mesh = pyray.gen_mesh_heightmap(image, (16, 8, 16)) -model = pyray.load_model_from_mesh(mesh) -model.materials.maps[pyray.MATERIAL_MAP_DIFFUSE].texture = texture - -pyray.unload_image(image) -pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL) - -pos = pyray.get_mouse_position() -ray = pyray.get_mouse_ray(pos, camera) -rayhit = pyray.get_collision_ray_ground(ray, 0) -print(str(rayhit.position.x)) - -while not pyray.window_should_close(): - pyray.update_camera(camera) - pyray.begin_drawing() - pyray.clear_background(RAYWHITE) - pyray.begin_mode_3d(camera) - pyray.draw_model(model, (-8.0, 0.0, -8.0), 1.0, RED) - pyray.draw_grid(20, 1.0) - pyray.end_mode_3d() - pyray.draw_text("This mesh should be textured", 190, 200, 20, VIOLET) - pyray.end_drawing() - - pos = pyray.get_mouse_position() - ray = pyray.get_mouse_ray(pos, camera) - rayhit = pyray.get_collision_ray_ground(ray, 0) - #print(str(rayhit.position.x)) - -pyray.close_window() diff --git a/dynamic/test_pyray.py b/dynamic/test_pyray.py new file mode 120000 index 0000000..04108d7 --- /dev/null +++ b/dynamic/test_pyray.py @@ -0,0 +1 @@ +../test_pyray.py \ No newline at end of file diff --git a/version.py b/version.py index d37c29f..3affcf9 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "3.7.0.post7" \ No newline at end of file +__version__ = "3.7.0.post8" \ No newline at end of file