Skip to content

Commit 1799c58

Browse files
update examples
1 parent ea29d96 commit 1799c58

9 files changed

+52
-45
lines changed

examples/core/core_smooth_pixel_perfect_camera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
draw_texture_pro(target.texture, sourceRec, destRec, origin, 0.0, WHITE)
7878
end_mode_2d()
7979

80-
draw_text(text_format("Screen resolution: %ix%i", screenWidth, screenHeight), 10, 10, 20, DARKBLUE)
81-
draw_text(text_format("World resolution: %ix%i", virtualScreenWidth, virtualScreenHeight), 10, 40, 20, DARKGREEN)
80+
draw_text(f"Screen resolution: {screenWidth}, {screenHeight}", 10, 10, 20, DARKBLUE)
81+
draw_text(f"World resolution: {virtualScreenWidth}, {virtualScreenHeight}", 10, 40, 20, DARKGREEN)
8282
draw_fps(get_screen_width() - 95, 10)
8383
end_drawing()
8484

examples/core/core_vr_simulator.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import pyray
2+
import raylib
3+
24
GLSL_VERSION = 330
35

46
# Initialization
@@ -30,18 +32,18 @@
3032
config = pyray.load_vr_stereo_config(device)
3133

3234
# Distortion shader (uses device lens distortion and chroma)
33-
distortion = pyray.load_shader(0, f"resources/distortion{GLSL_VERSION}.fs")
35+
distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs")
3436

3537
# Update distortion shader with lens and distortion-scale parameters
36-
pyray.set_shader_value(distortion, 2,"leftLensCenter", pyray.SHADER_UNIFORM_VEC2)
37-
pyray.set_shader_value(distortion, 2,"rightLensCenter", pyray.SHADER_UNIFORM_VEC2)
38-
pyray.set_shader_value(distortion, 2,"leftScreenCenter", pyray.SHADER_UNIFORM_VEC2)
39-
pyray.set_shader_value(distortion, 2,"rightScreenCenter", pyray.SHADER_UNIFORM_VEC2)
40-
41-
pyray.set_shader_value(distortion, 2,"scale", pyray.SHADER_UNIFORM_VEC2)
42-
pyray.set_shader_value(distortion, 2,"scaleIn", pyray.SHADER_UNIFORM_VEC2)
43-
pyray.set_shader_value(distortion, 4,"deviceWarpParam", pyray.SHADER_UNIFORM_VEC4)
44-
pyray.set_shader_value(distortion, 4,"chromaAbParam", pyray.SHADER_UNIFORM_VEC4)
38+
pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.SHADER_UNIFORM_VEC2)
39+
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.SHADER_UNIFORM_VEC2)
40+
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
41+
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
42+
43+
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.SHADER_UNIFORM_VEC2)
44+
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.SHADER_UNIFORM_VEC2)
45+
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.SHADER_UNIFORM_VEC4)
46+
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.SHADER_UNIFORM_VEC4)
4547

4648
# Initialize framebuffer for stereo rendering
4749
# NOTE: Screen size should match HMD aspect ratio

examples/models/models_animation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
position = ( 0., 0., 0. ) # Set model position
2323

2424
# Load animation data
25-
count = ray.ffi.new("unsigned int *", 1)
25+
count = ray.ffi.new("int *", 1)
2626
anims = ray.load_model_animations("resources/models/iqm/guyanim.iqm", count)
2727
anim_frame_counter = 0
2828

@@ -55,7 +55,7 @@
5555
ray.draw_model_ex(model, position, ray.Vector3( 1.0, 0.0, 0.0 ), -90.0, ray.Vector3( 1.0, 1.0, 1.0 ), ray.WHITE)
5656

5757
for i in range(model.boneCount):
58-
ray.draw_cube(anims[0].framePoses[anim_frame_counter][i].translation, 0.2, 0.2, 0.2, ray.RED)
58+
ray.draw_cube(anims.framePoses[anim_frame_counter][i].translation, 0.2, 0.2, 0.2, ray.RED)
5959

6060
ray.draw_grid(10, 1.0) # Draw a grid
6161

@@ -75,8 +75,8 @@
7575
ray.unload_texture(texture) # Unload texture
7676

7777
# Unload model animations data
78-
for anim in anims:
79-
ray.unload_model_animation(anim)
78+
for i in range(count[0]):
79+
ray.unload_model_animation(anims[i])
8080

8181
ray.unload_model(model) # Unload model
8282

examples/models/models_skybox.py renamed to examples/models/models_skybox_outdated_needs_update.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from raylib.dynamic import raylib as rl, ffi
1+
import raylib as rl
22
from raylib.colors import *
33

44
screenWidth = 1260
55
screenHeight = 768
66

77
rl.InitWindow(screenWidth, screenHeight, b'Skymap Demo')
88

9-
camera = ffi.new('struct Camera3D *', [[1, 1, 1], [4, 1, 4], [0, 1, 0], 70, 0])
9+
camera = rl.ffi.new('struct Camera3D *', [[1, 1, 1], [4, 1, 4], [0, 1, 0], 70, 0])
1010

1111
cube = rl.GenMeshCube(100, 100, 100)
1212
skybox = rl.LoadModelFromMesh(cube)
@@ -19,8 +19,8 @@
1919
rl.SetShaderValue(
2020
skybox.materials[0].shader,
2121
rl.GetShaderLocation(skybox.materials[0].shader, b"environmentMap"),
22-
ffi.new('int[]', [rl.MAP_CUBEMAP]),
23-
rl.UNIFORM_INT
22+
rl.ffi.new('int[]', [rl.MATERIAL_MAP_CUBEMAP]),
23+
rl.RL_SHADER_UNIFORM_INT
2424
)
2525

2626
shdrCubemap = rl.LoadShader(
@@ -31,13 +31,15 @@
3131
rl.SetShaderValue(
3232
shdrCubemap,
3333
rl.GetShaderLocation(shdrCubemap, b'equirectangularMap'),
34-
ffi.new('int[]', [0]),
35-
rl.UNIFORM_INT
34+
rl.ffi.new('int[]', [0]),
35+
rl.SHADER_UNIFORM_INT
3636
)
3737

3838
texHDR = rl.LoadTexture(b'resources/dresden_square.hdr')
3939

40-
skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap(shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32);
40+
# THIS FUNCTION NO LONGER EXISTS, will require porting a lot of C code from the C example to replace it
41+
skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap(shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32)
42+
4143

4244
rl.UnloadTexture(texHDR)
4345
rl.UnloadShader(shdrCubemap)

examples/shapes/shapes_draw_rounded_rectangle.py renamed to examples/shapes/shapes_draw_rounded_rectangle_incomplete.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,31 @@
2020
MAROON,
2121
)
2222

23-
#// Initialization
24-
#//--------------------------------------------------------------------------------------
23+
2524
SCREEN_WIDTH = 800
2625
SCREEN_HEIGHT = 450
2726

2827
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [shapes] example - draw rectangle rounded")
2928

30-
roundness = 0.2
31-
width = 200
32-
height = 100
33-
segments = 0
34-
lineThick = 1
29+
3530

3631
drawRect = False
3732
drawRoundedRect = True
3833
drawRoundedLines = False
3934

40-
pyray.set_target_fps(60) #// Set our game to run at 60 frames-per-second
41-
#//--------------------------------------------------------------------------------------
42-
35+
pyray.set_target_fps(60)
36+
width = pyray.ffi.new('float *', 200)
37+
# these need to be changed to pointers for new raygui format
38+
roundness = 0.2
39+
height = 100
40+
segments = 0
41+
lineThick = 1
4342
#// Main game loop
4443
while not pyray.window_should_close(): #// Detect window close button or ESC key
4544

4645
#// Update
4746
#//----------------------------------------------------------------------------------
48-
rec = pyray.Rectangle( (pyray.get_screen_width()-width-250)/2, (pyray.get_screen_height()-height)/2, width, height )
47+
rec = pyray.Rectangle( (pyray.get_screen_width()-width[0]-250)/2, (pyray.get_screen_height()-height)/2, width[0], height )
4948
#//----------------------------------------------------------------------------------
5049

5150
#// Draw
@@ -65,18 +64,22 @@
6564

6665
#// Draw GUI controls
6766
#//------------------------------------------------------------------------------
68-
width = int( pyray.gui_slider_bar(pyray.Rectangle(640,40,105,20),"Width",0,width,0,pyray.get_screen_width()-300) )
69-
height = int( pyray.gui_slider_bar(pyray.Rectangle(640,70,105,20),"Height",0,height,0,pyray.get_screen_height()-50) )
70-
roundness = pyray.gui_slider_bar(pyray.Rectangle(640,140,105,20),"Roundness",0,roundness,0,1)
71-
lineThick = int( pyray.gui_slider_bar(pyray.Rectangle(640,170,105,20),"Thickness",0,lineThick,0,20) )
72-
segments = int( pyray.gui_slider_bar(pyray.Rectangle(640,240,105,20),"Segments",0,segments,0,60) )
73-
74-
drawRoundedRect = pyray.gui_check_box(pyray.Rectangle(640,320,20,20),"DrawRoundedRect",drawRoundedRect)
75-
drawRoundedLines = pyray.gui_check_box(pyray.Rectangle(640,350,20,20),"DrawRoundedLines",drawRoundedLines)
76-
drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
67+
68+
pyray.gui_slider_bar(pyray.Rectangle(640,40,105,20),"Width","",width,0,pyray.get_screen_width()-300)
69+
70+
# these need to be updated to new raygui format like above like
71+
72+
# height = int( pyray.gui_slider_bar(pyray.Rectangle(640,70,105,20),"Height",0,height,0,pyray.get_screen_height()-50) )
73+
# roundness = pyray.gui_slider_bar(pyray.Rectangle(640,140,105,20),"Roundness",0,roundness,0,1)
74+
# lineThick = int( pyray.gui_slider_bar(pyray.Rectangle(640,170,105,20),"Thickness",0,lineThick,0,20) )
75+
# segments = int( pyray.gui_slider_bar(pyray.Rectangle(640,240,105,20),"Segments",0,segments,0,60) )
76+
#
77+
# drawRoundedRect = pyray.gui_check_box(pyray.Rectangle(640,320,20,20),"DrawRoundedRect",drawRoundedRect)
78+
# drawRoundedLines = pyray.gui_check_box(pyray.Rectangle(640,350,20,20),"DrawRoundedLines",drawRoundedLines)
79+
# drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
7780
#//------------------------------------------------------------------------------
7881

79-
pyray.draw_text(pyray.text_format( "MODE: %s" % "MANUAL" if segments >= 4 else "AUTO" ), 640, 280, 10, MAROON if segments >= 4 else DARKGRAY )
82+
pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, MAROON if segments >= 4 else DARKGRAY)
8083
pyray.draw_fps(10,10)
8184
pyray.end_drawing()
8285
#//------------------------------------------------------------------------------

tests/test_hello_world.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
while not window_should_close():
44
begin_drawing()
55
clear_background(WHITE)
6-
font = load_font_ex("/home/richard/pycharm-2022.1.4/jbr/lib/fonts/DroidSans.ttf", 30, None, 0)
6+
font = load_font_ex("/usr/share/fonts/TTF/FiraSans-Ultra.ttf", 30, None, 0)
77
draw_text_ex(font, "hellow font", (300, 300), 30, 0, BLACK)
88
draw_text("Hello world", 190, 200, 20, VIOLET)
99
end_drawing()

0 commit comments

Comments
 (0)