update examples

This commit is contained in:
Richard Smith 2024-11-16 20:11:08 +00:00 committed by Richard Smith
parent 4071263a59
commit a33f4fcc9a
40 changed files with 232 additions and 321 deletions

View file

@ -4,20 +4,20 @@ import raylib as rl
class LightSystem:
MAX_LIGHTS = 4 #// Max dynamic lights supported by shader
lightsCount = 0
lights = []
lights: list['Light'] = []
def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls):
self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs",
b"resources/shaders/fogLight.fs");
#// Get some shader loactions
self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel");
self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos");
self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel")
self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos")
#// ambient light level
self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient");
self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient")
v = rl.ffi.new("struct Vector4 *", ambient)
rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4);
rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4)
for light in ls:
self.add(light)

View file

@ -48,7 +48,7 @@ screenWidth = 1200
screenHeight = 720
rl.SetConfigFlags(
rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE); # Enable Multi Sampling Anti Aliasing 4x (if available)
rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE) # Enable Multi Sampling Anti Aliasing 4x (if available)
rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting")
camera = rl.ffi.new('struct Camera3D *', [

View file

@ -9,7 +9,7 @@ def LoadRenderTextureDepthTex(width, height):
target = RenderTexture()
target.id = rl_load_framebuffer(width, height) # Load an empty framebuffer
target.id = rl_load_framebuffer() # Load an empty framebuffer
if target.id > 0:
@ -72,12 +72,7 @@ shader = load_shader("","resources/shaders/glsl330/write_depth.fs")
target = LoadRenderTextureDepthTex(screenWidth, screenHeight)
# Define the camera to look into our 3d world
camera = Camera3D()
camera.position = (2.0, 2.0, 3.0) # Camera position
camera.target = (0.0, 0.5, 0.0) # Camera looking at point
camera.up = (0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
camera.fovy = 45.0 # Camera field-of-view Y
camera.projection = CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
camera = Camera3D((2.0, 2.0, 3.0),(0.0, 0.5, 0.0),(0.0, 1.0, 0.0),45.0, CameraProjection.CAMERA_PERSPECTIVE)
set_target_fps(60) # Set our game to run at 60 frames-per-second