update examples
This commit is contained in:
parent
ea29d96ff9
commit
1799c58ca5
9 changed files with 51 additions and 44 deletions
|
@ -77,8 +77,8 @@ while not window_should_close(): # Detect window close button or ESC key
|
|||
draw_texture_pro(target.texture, sourceRec, destRec, origin, 0.0, WHITE)
|
||||
end_mode_2d()
|
||||
|
||||
draw_text(text_format("Screen resolution: %ix%i", screenWidth, screenHeight), 10, 10, 20, DARKBLUE)
|
||||
draw_text(text_format("World resolution: %ix%i", virtualScreenWidth, virtualScreenHeight), 10, 40, 20, DARKGREEN)
|
||||
draw_text(f"Screen resolution: {screenWidth}, {screenHeight}", 10, 10, 20, DARKBLUE)
|
||||
draw_text(f"World resolution: {virtualScreenWidth}, {virtualScreenHeight}", 10, 40, 20, DARKGREEN)
|
||||
draw_fps(get_screen_width() - 95, 10)
|
||||
end_drawing()
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import pyray
|
||||
import raylib
|
||||
|
||||
GLSL_VERSION = 330
|
||||
|
||||
# Initialization
|
||||
|
@ -30,18 +32,18 @@ device = pyray.VrDeviceInfo(
|
|||
config = pyray.load_vr_stereo_config(device)
|
||||
|
||||
# Distortion shader (uses device lens distortion and chroma)
|
||||
distortion = pyray.load_shader(0, f"resources/distortion{GLSL_VERSION}.fs")
|
||||
distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs")
|
||||
|
||||
# Update distortion shader with lens and distortion-scale parameters
|
||||
pyray.set_shader_value(distortion, 2,"leftLensCenter", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,"rightLensCenter", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,"leftScreenCenter", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,"rightScreenCenter", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||
|
||||
pyray.set_shader_value(distortion, 2,"scale", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,"scaleIn", pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 4,"deviceWarpParam", pyray.SHADER_UNIFORM_VEC4)
|
||||
pyray.set_shader_value(distortion, 4,"chromaAbParam", pyray.SHADER_UNIFORM_VEC4)
|
||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.SHADER_UNIFORM_VEC2)
|
||||
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.SHADER_UNIFORM_VEC4)
|
||||
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.SHADER_UNIFORM_VEC4)
|
||||
|
||||
# Initialize framebuffer for stereo rendering
|
||||
# NOTE: Screen size should match HMD aspect ratio
|
||||
|
|
|
@ -22,7 +22,7 @@ ray.set_material_texture(model.materials, ray.MATERIAL_MAP_ALBEDO, texture)
|
|||
position = ( 0., 0., 0. ) # Set model position
|
||||
|
||||
# Load animation data
|
||||
count = ray.ffi.new("unsigned int *", 1)
|
||||
count = ray.ffi.new("int *", 1)
|
||||
anims = ray.load_model_animations("resources/models/iqm/guyanim.iqm", count)
|
||||
anim_frame_counter = 0
|
||||
|
||||
|
@ -55,7 +55,7 @@ while not ray.window_should_close(): # Detect window close button or ESC
|
|||
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)
|
||||
|
||||
for i in range(model.boneCount):
|
||||
ray.draw_cube(anims[0].framePoses[anim_frame_counter][i].translation, 0.2, 0.2, 0.2, ray.RED)
|
||||
ray.draw_cube(anims.framePoses[anim_frame_counter][i].translation, 0.2, 0.2, 0.2, ray.RED)
|
||||
|
||||
ray.draw_grid(10, 1.0) # Draw a grid
|
||||
|
||||
|
@ -75,8 +75,8 @@ while not ray.window_should_close(): # Detect window close button or ESC
|
|||
ray.unload_texture(texture) # Unload texture
|
||||
|
||||
# Unload model animations data
|
||||
for anim in anims:
|
||||
ray.unload_model_animation(anim)
|
||||
for i in range(count[0]):
|
||||
ray.unload_model_animation(anims[i])
|
||||
|
||||
ray.unload_model(model) # Unload model
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from raylib.dynamic import raylib as rl, ffi
|
||||
import raylib as rl
|
||||
from raylib.colors import *
|
||||
|
||||
screenWidth = 1260
|
||||
|
@ -6,7 +6,7 @@ screenHeight = 768
|
|||
|
||||
rl.InitWindow(screenWidth, screenHeight, b'Skymap Demo')
|
||||
|
||||
camera = ffi.new('struct Camera3D *', [[1, 1, 1], [4, 1, 4], [0, 1, 0], 70, 0])
|
||||
camera = rl.ffi.new('struct Camera3D *', [[1, 1, 1], [4, 1, 4], [0, 1, 0], 70, 0])
|
||||
|
||||
cube = rl.GenMeshCube(100, 100, 100)
|
||||
skybox = rl.LoadModelFromMesh(cube)
|
||||
|
@ -19,8 +19,8 @@ skybox.materials[0].shader = rl.LoadShader(
|
|||
rl.SetShaderValue(
|
||||
skybox.materials[0].shader,
|
||||
rl.GetShaderLocation(skybox.materials[0].shader, b"environmentMap"),
|
||||
ffi.new('int[]', [rl.MAP_CUBEMAP]),
|
||||
rl.UNIFORM_INT
|
||||
rl.ffi.new('int[]', [rl.MATERIAL_MAP_CUBEMAP]),
|
||||
rl.RL_SHADER_UNIFORM_INT
|
||||
)
|
||||
|
||||
shdrCubemap = rl.LoadShader(
|
||||
|
@ -31,13 +31,15 @@ shdrCubemap = rl.LoadShader(
|
|||
rl.SetShaderValue(
|
||||
shdrCubemap,
|
||||
rl.GetShaderLocation(shdrCubemap, b'equirectangularMap'),
|
||||
ffi.new('int[]', [0]),
|
||||
rl.UNIFORM_INT
|
||||
rl.ffi.new('int[]', [0]),
|
||||
rl.SHADER_UNIFORM_INT
|
||||
)
|
||||
|
||||
texHDR = rl.LoadTexture(b'resources/dresden_square.hdr')
|
||||
|
||||
skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap(shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32);
|
||||
# THIS FUNCTION NO LONGER EXISTS, will require porting a lot of C code from the C example to replace it
|
||||
skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap(shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32)
|
||||
|
||||
|
||||
rl.UnloadTexture(texHDR)
|
||||
rl.UnloadShader(shdrCubemap)
|
|
@ -20,32 +20,31 @@ from raylib.colors import (
|
|||
MAROON,
|
||||
)
|
||||
|
||||
#// Initialization
|
||||
#//--------------------------------------------------------------------------------------
|
||||
|
||||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [shapes] example - draw rectangle rounded")
|
||||
|
||||
roundness = 0.2
|
||||
width = 200
|
||||
height = 100
|
||||
segments = 0
|
||||
lineThick = 1
|
||||
|
||||
|
||||
drawRect = False
|
||||
drawRoundedRect = True
|
||||
drawRoundedLines = False
|
||||
|
||||
pyray.set_target_fps(60) #// Set our game to run at 60 frames-per-second
|
||||
#//--------------------------------------------------------------------------------------
|
||||
|
||||
pyray.set_target_fps(60)
|
||||
width = pyray.ffi.new('float *', 200)
|
||||
# these need to be changed to pointers for new raygui format
|
||||
roundness = 0.2
|
||||
height = 100
|
||||
segments = 0
|
||||
lineThick = 1
|
||||
#// Main game loop
|
||||
while not pyray.window_should_close(): #// Detect window close button or ESC key
|
||||
|
||||
#// Update
|
||||
#//----------------------------------------------------------------------------------
|
||||
rec = pyray.Rectangle( (pyray.get_screen_width()-width-250)/2, (pyray.get_screen_height()-height)/2, width, height )
|
||||
rec = pyray.Rectangle( (pyray.get_screen_width()-width[0]-250)/2, (pyray.get_screen_height()-height)/2, width[0], height )
|
||||
#//----------------------------------------------------------------------------------
|
||||
|
||||
#// Draw
|
||||
|
@ -65,18 +64,22 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
|
|||
|
||||
#// Draw GUI controls
|
||||
#//------------------------------------------------------------------------------
|
||||
width = int( pyray.gui_slider_bar(pyray.Rectangle(640,40,105,20),"Width",0,width,0,pyray.get_screen_width()-300) )
|
||||
height = int( pyray.gui_slider_bar(pyray.Rectangle(640,70,105,20),"Height",0,height,0,pyray.get_screen_height()-50) )
|
||||
roundness = pyray.gui_slider_bar(pyray.Rectangle(640,140,105,20),"Roundness",0,roundness,0,1)
|
||||
lineThick = int( pyray.gui_slider_bar(pyray.Rectangle(640,170,105,20),"Thickness",0,lineThick,0,20) )
|
||||
segments = int( pyray.gui_slider_bar(pyray.Rectangle(640,240,105,20),"Segments",0,segments,0,60) )
|
||||
|
||||
drawRoundedRect = pyray.gui_check_box(pyray.Rectangle(640,320,20,20),"DrawRoundedRect",drawRoundedRect)
|
||||
drawRoundedLines = pyray.gui_check_box(pyray.Rectangle(640,350,20,20),"DrawRoundedLines",drawRoundedLines)
|
||||
drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
|
||||
pyray.gui_slider_bar(pyray.Rectangle(640,40,105,20),"Width","",width,0,pyray.get_screen_width()-300)
|
||||
|
||||
# these need to be updated to new raygui format like above like
|
||||
|
||||
# height = int( pyray.gui_slider_bar(pyray.Rectangle(640,70,105,20),"Height",0,height,0,pyray.get_screen_height()-50) )
|
||||
# roundness = pyray.gui_slider_bar(pyray.Rectangle(640,140,105,20),"Roundness",0,roundness,0,1)
|
||||
# lineThick = int( pyray.gui_slider_bar(pyray.Rectangle(640,170,105,20),"Thickness",0,lineThick,0,20) )
|
||||
# segments = int( pyray.gui_slider_bar(pyray.Rectangle(640,240,105,20),"Segments",0,segments,0,60) )
|
||||
#
|
||||
# drawRoundedRect = pyray.gui_check_box(pyray.Rectangle(640,320,20,20),"DrawRoundedRect",drawRoundedRect)
|
||||
# drawRoundedLines = pyray.gui_check_box(pyray.Rectangle(640,350,20,20),"DrawRoundedLines",drawRoundedLines)
|
||||
# drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
|
||||
#//------------------------------------------------------------------------------
|
||||
|
||||
pyray.draw_text(pyray.text_format( "MODE: %s" % "MANUAL" if segments >= 4 else "AUTO" ), 640, 280, 10, MAROON if segments >= 4 else DARKGRAY )
|
||||
pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, MAROON if segments >= 4 else DARKGRAY)
|
||||
pyray.draw_fps(10,10)
|
||||
pyray.end_drawing()
|
||||
#//------------------------------------------------------------------------------
|
|
@ -3,7 +3,7 @@ init_window(800, 450, "Hello")
|
|||
while not window_should_close():
|
||||
begin_drawing()
|
||||
clear_background(WHITE)
|
||||
font = load_font_ex("/home/richard/pycharm-2022.1.4/jbr/lib/fonts/DroidSans.ttf", 30, None, 0)
|
||||
font = load_font_ex("/usr/share/fonts/TTF/FiraSans-Ultra.ttf", 30, None, 0)
|
||||
draw_text_ex(font, "hellow font", (300, 300), 30, 0, BLACK)
|
||||
draw_text("Hello world", 190, 200, 20, VIOLET)
|
||||
end_drawing()
|
||||
|
|
Reference in a new issue