reorg modules
This commit is contained in:
parent
7262e4fa2e
commit
1d5579db6d
9 changed files with 68 additions and 63 deletions
53
README.md
53
README.md
|
@ -47,6 +47,33 @@ CloseWindow()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## raylib.pyray
|
||||||
|
|
||||||
|
Wrapper around the static bindings. Makes the names snakecase and converts strings to bytes automatically. See test_pyray.py.
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
from raylib.pyray import PyRay
|
||||||
|
from raylib.colors import *
|
||||||
|
|
||||||
|
pyray = PyRay()
|
||||||
|
|
||||||
|
pyray.init_window(800, 450, "Hello Pyray")
|
||||||
|
pyray.set_target_fps(60)
|
||||||
|
|
||||||
|
camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
|
||||||
|
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)
|
||||||
|
|
||||||
|
while not pyray.window_should_close():
|
||||||
|
pyray.update_camera(pyray.pointer(camera))
|
||||||
|
pyray.begin_drawing()
|
||||||
|
pyray.clear_background(RAYWHITE)
|
||||||
|
pyray.draw_text("Hello world", 190, 200, 20, VIOLET)
|
||||||
|
pyray.end_drawing()
|
||||||
|
pyray.close_window()
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## raylib.dynamic
|
## raylib.dynamic
|
||||||
|
|
||||||
In addition to the API static bindings we have CFFI ABI dynamic bindings in order to avoid the need to compile a C extension module.
|
In addition to the API static bindings we have CFFI ABI dynamic bindings in order to avoid the need to compile a C extension module.
|
||||||
|
@ -58,31 +85,6 @@ which we supply for Windows/Mac/Linux.
|
||||||
|
|
||||||
See test_dynamic.py for how to use.
|
See test_dynamic.py for how to use.
|
||||||
|
|
||||||
## raylib.static.pyray
|
|
||||||
|
|
||||||
Wrapper around the static bindings. Makes the names snakecase and converts strings to bytes automatically. See test_pyray.py.
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
from raylib.static.pyray import pyray as prl
|
|
||||||
from raylib.colors import *
|
|
||||||
|
|
||||||
prl.init_window(800, 450, "Hello Pyray")
|
|
||||||
prl.set_target_fps(60)
|
|
||||||
|
|
||||||
camera = prl.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
|
|
||||||
prl.set_camera_mode(camera, prl.CAMERA_ORBITAL)
|
|
||||||
|
|
||||||
while not prl.window_should_close():
|
|
||||||
prl.update_camera(prl.pointer(camera))
|
|
||||||
prl.begin_drawing()
|
|
||||||
prl.clear_background(RAYWHITE)
|
|
||||||
prl.draw_text("Hello world", 190, 200, 20, VIOLET)
|
|
||||||
prl.end_drawing()
|
|
||||||
prl.close_window()
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## raylib.richlib
|
## raylib.richlib
|
||||||
|
|
||||||
A very easy to use library on top of static bindings, modelled after Pygame Zero.
|
A very easy to use library on top of static bindings, modelled after Pygame Zero.
|
||||||
|
@ -98,4 +100,5 @@ A very easy to use library on top of static bindings, modelled after Pygame Zero
|
||||||
* converting more examples from C to python
|
* converting more examples from C to python
|
||||||
* testing and building on more platforms
|
* testing and building on more platforms
|
||||||
* sorting out binary wheel distribution for Mac/Win and compile-from-source distributtion for Linux
|
* sorting out binary wheel distribution for Mac/Win and compile-from-source distributtion for Linux
|
||||||
|
* dealing with conversions to pointers in PyRay automatically
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from raylib.richlib import *
|
from raylib.richlib import *
|
||||||
from raylib.static.pyray import pyray
|
|
||||||
|
|
||||||
WIDTH=1200
|
WIDTH=1200
|
||||||
HEIGHT=800
|
HEIGHT=800
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from . import rl, ffi
|
from .static import rl, ffi
|
||||||
from ..colors import *
|
from .colors import *
|
||||||
from inspect import ismethod,getmembers,isbuiltin
|
from inspect import ismethod,getmembers,isbuiltin
|
||||||
import inflection
|
import inflection
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ class PyRay:
|
||||||
def pointer(self, struct):
|
def pointer(self, struct):
|
||||||
return ffi.addressof(struct)
|
return ffi.addressof(struct)
|
||||||
|
|
||||||
pyray = PyRay()
|
|
||||||
|
|
||||||
|
|
||||||
def makefunc(a):
|
def makefunc(a):
|
||||||
#print("makefunc ",a)
|
#print("makefunc ",a)
|
||||||
|
@ -31,10 +29,12 @@ def makeStructHelper(struct):
|
||||||
|
|
||||||
|
|
||||||
for name, attr in getmembers(rl):
|
for name, attr in getmembers(rl):
|
||||||
print(name, attr)
|
#print(name, attr)
|
||||||
uname = inflection.underscore(name).replace('3_d','_3d').replace('2_d','_2d')
|
uname = inflection.underscore(name).replace('3_d','_3d').replace('2_d','_2d')
|
||||||
if isbuiltin(attr):
|
if isbuiltin(attr):
|
||||||
#print(attr)
|
#print(attr.__call__)
|
||||||
|
#print(attr.__doc__)
|
||||||
|
#print(attr.__text_signature__)
|
||||||
#print(dir(attr))
|
#print(dir(attr))
|
||||||
#print(dir(attr.__repr__))
|
#print(dir(attr.__repr__))
|
||||||
f = makefunc(attr)
|
f = makefunc(attr)
|
||||||
|
@ -48,3 +48,4 @@ for name, attr in getmembers(rl):
|
||||||
for struct in ('Vector2','Vector3','Vector4','Camera2D', 'Camera3D', 'Quaternion', 'Color'):
|
for struct in ('Vector2','Vector3','Vector4','Camera2D', 'Camera3D', 'Quaternion', 'Color'):
|
||||||
f = makeStructHelper(struct)
|
f = makeStructHelper(struct)
|
||||||
setattr(PyRay, struct, f)
|
setattr(PyRay, struct, f)
|
||||||
|
|
|
@ -10,6 +10,10 @@ import sys
|
||||||
|
|
||||||
data_dir = ""
|
data_dir = ""
|
||||||
|
|
||||||
|
from ..pyray import PyRay
|
||||||
|
|
||||||
|
pyray = PyRay()
|
||||||
|
|
||||||
camera = ffi.new("struct Camera3D *")
|
camera = ffi.new("struct Camera3D *")
|
||||||
camera.position = (0.0, 100, 100)
|
camera.position = (0.0, 100, 100)
|
||||||
camera.target = (0.0, 0.0, 0.0)
|
camera.target = (0.0, 0.0, 0.0)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from ._raylib_cffi import ffi, lib as rl
|
from ._raylib_cffi import ffi, lib as rl
|
||||||
from _raylib_cffi.lib import *
|
from _raylib_cffi.lib import *
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
from .helpers import *
|
|
||||||
|
|
||||||
|
|
||||||
print("RAYLIB STATIC LOADED")
|
print("RAYLIB STATIC LOADED")
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
from ._raylib_cffi import ffi
|
|
||||||
|
|
||||||
def Vector3(x, y, z):
|
|
||||||
return ffi.new("struct Vector3 *", [x, y, z])[0]
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -10,7 +10,7 @@ README = (HERE / "README.md").read_text()
|
||||||
# This call to setup() does all the work
|
# This call to setup() does all the work
|
||||||
setup(
|
setup(
|
||||||
name="raylib",
|
name="raylib",
|
||||||
version="2.5.0.post2",
|
version="2.5.0.post3",
|
||||||
description="Python CFFI bindings for Raylib",
|
description="Python CFFI bindings for Raylib",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
"""
|
"""
|
||||||
This shows how to use the Pyray wrapper around the static binding.
|
This shows how to use the Pyray wrapper around the static binding.
|
||||||
"""
|
"""
|
||||||
from raylib.static.pyray import pyray as prl
|
|
||||||
|
from raylib.pyray import PyRay
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
|
|
||||||
prl.init_window(800, 450, "Raylib texture test")
|
pyray = PyRay()
|
||||||
prl.set_target_fps(60)
|
|
||||||
|
|
||||||
camera = prl.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
|
pyray.init_window(800, 450, "Raylib texture test")
|
||||||
image = prl.load_image("examples/models/resources/heightmap.png")
|
pyray.set_target_fps(60)
|
||||||
texture = prl.load_texture_from_image(image)
|
|
||||||
mesh = prl.gen_mesh_heightmap(image, (16, 8, 16))
|
|
||||||
model = prl.load_model_from_mesh(mesh)
|
|
||||||
model.materials.maps[prl.MAP_DIFFUSE].texture = texture
|
|
||||||
|
|
||||||
prl.unload_image(image)
|
camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
|
||||||
prl.set_camera_mode(camera, prl.CAMERA_ORBITAL)
|
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.MAP_DIFFUSE].texture = texture
|
||||||
|
|
||||||
while not prl.window_should_close():
|
pyray.unload_image(image)
|
||||||
prl.update_camera(prl.pointer(camera))
|
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)
|
||||||
prl.begin_drawing()
|
|
||||||
prl.clear_background(RAYWHITE)
|
while not pyray.window_should_close():
|
||||||
prl.begin_mode_3d(camera)
|
pyray.update_camera(pyray.pointer(camera))
|
||||||
prl.draw_model(model, (-8.0, 0.0, -8.0), 1.0, RED)
|
pyray.begin_drawing()
|
||||||
prl.draw_grid(20, 1.0)
|
pyray.clear_background(RAYWHITE)
|
||||||
prl.end_mode_3d()
|
pyray.begin_mode_3d(camera)
|
||||||
prl.draw_text("This mesh should be textured", 190, 200, 20, VIOLET)
|
pyray.draw_model(model, (-8.0, 0.0, -8.0), 1.0, RED)
|
||||||
prl.end_drawing()
|
pyray.draw_grid(20, 1.0)
|
||||||
prl.close_window()
|
pyray.end_mode_3d()
|
||||||
|
pyray.draw_text("This mesh should be textured", 190, 200, 20, VIOLET)
|
||||||
|
pyray.end_drawing()
|
||||||
|
pyray.close_window()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from raylib.richlib import *
|
from raylib.richlib import *
|
||||||
from raylib.static.pyray import pyray
|
|
||||||
|
|
||||||
WIDTH=800
|
WIDTH=800
|
||||||
HEIGHT=640
|
HEIGHT=640
|
||||||
|
|
Reference in a new issue