Skip to content

Commit 50c2fb1

Browse files
QOL docs, colors, version number, example imports
1 parent 9e17046 commit 50c2fb1

File tree

13 files changed

+104
-68
lines changed

13 files changed

+104
-68
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ statically link and use in non-free / proprietary / commercial projects!
1212

1313
# Installation
1414

15-
We distribute a statically linked binary Raylib wheel:
16-
1715
python3 -m pip install raylib
1816

19-
Problems may be caused by out of date pip:
17+
If it doesn't work, first make sure you have latest pip installed:
2018

2119
python3 -m pip install --upgrade pip
2220

23-
Some platforms that _should_ be available: Windows 10 x64, MacOS 10.15 x64, Linux Ubuntu1804 x64.
21+
On most platforms it should install a binary wheel (Windows 10 x64, MacOS 10.15 x64, Linux Ubuntu1804 x64).
2422

2523
If yours isn't available then pip will attempt to build from source, in which case you will need to have Raylib development libs installed, e.g.
2624
using homebrew, apt, etc.
2725

28-
[If it doesn't work, build from source](BUILDING.md)
26+
[If it doesn't work, you can build manually.](BUILDING.md)
27+
28+
## Dynamic binding version
2929

3030
There is now a separate dynamic version of this binding:
3131

@@ -36,8 +36,7 @@ There is now a separate dynamic version of this binding:
3636

3737
# How to use
3838

39-
There are two different ways of using this binding. You only need to pick one method, but you
40-
can combine two methods in one program if you want to.
39+
There are two APIs, you can use either or both:
4140

4241
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
4342

@@ -63,7 +62,7 @@ Work in progress:
6362

6463
# Performance
6564

66-
For fastest permformance use Pypy rather than standard python.
65+
For fastest performance use Pypy rather than standard python.
6766

6867
Every call to C is costly, so it's slightly faster if you use Python data structures and functions when calculating
6968
in your update loop

docs-src/pyray.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,28 @@ The API is *still the same as Raylib*, so you should still reply on `the officia
2222

2323
Example program:
2424

25-
.. code-block::
25+
.. code-block::
2626
27-
from raylib.pyray import PyRay
28-
from raylib.colors import *
27+
import raylib
2928
30-
pyray = PyRay()
29+
pr = raylib.PyRay()
3130
32-
pyray.init_window(800, 450, "Hello Pyray")
33-
pyray.set_target_fps(60)
31+
pr.init_window(800, 450, "Hello Pyray")
32+
pr.set_target_fps(60)
3433
35-
camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
36-
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)
34+
camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
35+
pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)
3736
38-
while not pyray.window_should_close():
39-
pyray.update_camera(camera)
40-
pyray.begin_drawing()
41-
pyray.clear_background(RAYWHITE)
42-
pyray.begin_mode_3d(camera)
43-
pyray.draw_grid(20, 1.0)
44-
pyray.end_mode_3d()
45-
pyray.draw_text("Hello world", 190, 200, 20, VIOLET)
46-
pyray.end_drawing()
47-
pyray.close_window()
37+
while not pr.window_should_close():
38+
pr.update_camera(camera)
39+
pr.begin_drawing()
40+
pr.clear_background(pr.RAYWHITE)
41+
pr.begin_mode_3d(camera)
42+
pr.draw_grid(20, 1.0)
43+
pr.end_mode_3d()
44+
pr.draw_text("Hello world", 190, 200, 20, pr.VIOLET)
45+
pr.end_drawing()
46+
pr.close_window()
4847
4948
5049
See also https://github.com/electronstudio/raylib-python-cffi/blob/master/test_pyray.py

dynamic/raylib/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import pathlib
2424
import platform
25+
from .version import __version__
2526

2627
MODULE = pathlib.Path(__file__).parent
2728

@@ -52,6 +53,6 @@ def so_name():
5253
try:
5354
raylib_fname = raylib_library_path()
5455
rl = ffi.dlopen(raylib_fname)
55-
print('LOADED DYNAMICALLY SHARED LIB "{}"'.format(raylib_fname))
56+
print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
5657
except Exception as e:
5758
print(e)

dynamic/raylib/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../version.py

dynamic/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pathlib
22
from setuptools import setup
33
from setuptools.dist import Distribution
4+
from version import __version__
45

56
# The directory containing this file
67
HERE = pathlib.Path(__file__).parent
@@ -12,7 +13,7 @@
1213
# This call to setup() does all the work
1314
setup(
1415
name="raylib_dynamic",
15-
version="3.7.0.post6",
16+
version=__version__,
1617
description="Python CFFI bindings for Raylib DLL version",
1718
long_description=README,
1819
long_description_content_type="text/x-rst",

dynamic/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../version.py

raylib/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@
1818
import cffi
1919
import sys
2020
from raylib.pyray import PyRay
21+
from .version import __version__
22+
23+
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)
2124

22-
print("RAYLIB STATIC LOADED", file=sys.stderr)

raylib/build.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Assumes raylib, GL, etc are all already installed as system libraries. We dont distribute them.
1616
# Raylib must be installed and compiled with: cmake -DWITH_PIC=ON -DSHARED=ON -DSTATIC=ON ..
1717

18+
# We use /usr/local/lib/libraylib.a to ensure we link to static version
19+
1820
from cffi import FFI
1921
import os
2022
import platform
@@ -27,7 +29,7 @@ def build_linux():
2729
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
2830
ffibuilder.set_source("raylib._raylib_cffi",
2931
"""
30-
#include "../../raylib/raylib.h"
32+
#include "raylib.h"
3133
""",
3234
extra_link_args=['/usr/local/lib/libraylib.a','-lm', '-lpthread', '-lGLU', '-lGL', '-lrt', '-lm', '-ldl', '-lX11', '-lpthread'],
3335
libraries=['GL','m','pthread', 'dl', 'rt', 'X11']
@@ -55,7 +57,7 @@ def build_mac():
5557
"""
5658
#include "../../raylib/raylib.h" // the C header of the library, supplied by us here
5759
""",
58-
extra_link_args=['-lraylib', '-framework', 'OpenGL', '-framework', 'Cocoa', '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework', 'CoreVideo'],
60+
extra_link_args=['/usr/local/lib/libraylib.a', '-framework', 'OpenGL', '-framework', 'Cocoa', '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework', 'CoreVideo'],
5961
)
6062

6163
if __name__ == "__main__":

raylib/pyray.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,33 @@ class PyRay:
2121
def pointer(self, struct):
2222
return ffi.addressof(struct)
2323

24+
LIGHTGRAY =( 200, 200, 200, 255 )
25+
GRAY =( 130, 130, 130, 255 )
26+
DARKGRAY =( 80, 80, 80, 255 )
27+
YELLOW =( 253, 249, 0, 255 )
28+
GOLD =( 255, 203, 0, 255 )
29+
ORANGE =( 255, 161, 0, 255 )
30+
PINK =( 255, 109, 194, 255 )
31+
RED =( 230, 41, 55, 255 )
32+
MAROON =( 190, 33, 55, 255 )
33+
GREEN =( 0, 228, 48, 255 )
34+
LIME =( 0, 158, 47, 255 )
35+
DARKGREEN =( 0, 117, 44, 255 )
36+
SKYBLUE =( 102, 191, 255, 255 )
37+
BLUE =( 0, 121, 241, 255 )
38+
DARKBLUE =( 0, 82, 172, 255 )
39+
PURPLE =( 200, 122, 255, 255 )
40+
VIOLET =( 135, 60, 190, 255 )
41+
DARKPURPLE =( 112, 31, 126, 255 )
42+
BEIGE =( 211, 176, 131, 255 )
43+
BROWN =( 127, 106, 79, 255 )
44+
DARKBROWN =( 76, 63, 47, 255 )
45+
WHITE =( 255, 255, 255, 255 )
46+
BLACK =( 0, 0, 0, 255 )
47+
BLANK =( 0, 0, 0, 0 )
48+
MAGENTA =( 255, 0, 255, 255 )
49+
RAYWHITE =( 245, 245, 245, 255 )
50+
2451

2552
def makefunc(a):
2653
#print("makefunc ",a, ffi.typeof(a).args)

raylib/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../version.py

0 commit comments

Comments
 (0)