This commit is contained in:
richard 2022-02-02 18:21:34 +00:00
parent ff84bdf2dd
commit 218d9a18f7
7 changed files with 84 additions and 145 deletions

View file

@ -1,12 +1,6 @@
#!/usr/bin/env python3
import raylib as rl
from raylib.dynamic import raylib as rl, ffi
from raylib.colors import *
# a few functions ported from raymath
from rlmath import *
#// Initialization
@ -17,7 +11,7 @@ screenHeight = 450;
rl.SetConfigFlags(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 = ffi.new('struct Camera3D *', [
camera = rl.ffi.new('struct Camera3D *', [
[2, 12, 6],
[0, .5, 0],
[0, 1, 0],
@ -25,16 +19,16 @@ camera = ffi.new('struct Camera3D *', [
rl.CAMERA_PERSPECTIVE
])
imBlank = rl.GenImageColor(1024, 1024, BLANK)
imBlank = rl.GenImageColor(1024, 1024, rl.BLANK)
texture = rl.LoadTextureFromImage(imBlank) #// Load blank texture to fill on shader
rl.UnloadImage(imBlank);
#// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
shader = rl.LoadShader(b"", b"resources/shaders/glsl330/cubes_panning.fs");
time = ffi.new("float *", 0.0)
time = rl.ffi.new("float *", 0.0)
timeLoc = rl.GetShaderLocation(shader, b"uTime");
rl.SetShaderValue(shader, timeLoc, time, rl.UNIFORM_FLOAT);
rl.SetShaderValue(shader, timeLoc, time, rl.SHADER_UNIFORM_FLOAT);
rl.SetTargetFPS(60) # // Set our game to run at 60 frames-per-second
@ -45,7 +39,7 @@ while not rl.WindowShouldClose(): #// Detect window close button or E
#// Update
#//----------------------------------------------------------------------------------
time[0] = rl.GetTime();
rl.SetShaderValue(shader, timeLoc, time, rl.UNIFORM_FLOAT);
rl.SetShaderValue(shader, timeLoc, time, rl.SHADER_UNIFORM_FLOAT);
#//----------------------------------------------------------------------------------
@ -53,13 +47,13 @@ while not rl.WindowShouldClose(): #// Detect window close button or E
#//----------------------------------------------------------------------------------
rl.BeginDrawing()
rl.ClearBackground(RAYWHITE)
rl.ClearBackground(rl.RAYWHITE)
rl.BeginShaderMode(shader) #// Enable our custom shader for next shapes/textures drawings
rl.DrawTexture(texture, 0, 0, WHITE) #// Drawing BLANK texture, all magic happens on shader
rl.DrawTexture(texture, 0, 0, rl.WHITE) #// Drawing BLANK texture, all magic happens on shader
rl.EndShaderMode() #// Disable our custom shader, return to default shader
rl.DrawText(b"BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, MAROON);
rl.DrawText(b"BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, rl.MAROON);
rl.EndDrawing()