test, review and fix the shader examples. https://github.com/electronstudio/raylib-python-cffi/issues/47
This commit is contained in:
parent
ff84bdf2dd
commit
218d9a18f7
7 changed files with 84 additions and 145 deletions
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from raylib import rl, ffi
|
||||
import raylib as rl
|
||||
from raylib.colors import *
|
||||
import math
|
||||
|
||||
|
@ -17,7 +15,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]")
|
||||
|
||||
camera = ffi.new('struct Camera3D *', [
|
||||
camera = rl.ffi.new('struct Camera3D *', [
|
||||
[2, 12, 6],
|
||||
[0, .5, 0],
|
||||
[0, 1, 0],
|
||||
|
@ -36,24 +34,24 @@ ampYLoc = rl.GetShaderLocation(shader, b"ampY")
|
|||
speedXLoc = rl.GetShaderLocation(shader, b"speedX")
|
||||
speedYLoc = rl.GetShaderLocation(shader, b"speedY")
|
||||
|
||||
freqX = ffi.new("float *", 25.0)
|
||||
freqY = ffi.new("float *", 25.0)
|
||||
ampX = ffi.new("float *", 5.0)
|
||||
ampY = ffi.new("float *", 5.0)
|
||||
speedX = ffi.new("float *", 8.0)
|
||||
speedY = ffi.new("float *", 8.0)
|
||||
freqX = rl.ffi.new("float *", 25.0)
|
||||
freqY = rl.ffi.new("float *", 25.0)
|
||||
ampX = rl.ffi.new("float *", 5.0)
|
||||
ampY = rl.ffi.new("float *", 5.0)
|
||||
speedX = rl.ffi.new("float *", 8.0)
|
||||
speedY = rl.ffi.new("float *", 8.0)
|
||||
|
||||
screenSize = ffi.new("struct Vector2 *",[ rl.GetScreenWidth(), rl.GetScreenHeight() ])
|
||||
rl.SetShaderValue(shader, rl.GetShaderLocation(shader, b"size"), screenSize, rl.UNIFORM_VEC2)
|
||||
screenSize = rl.ffi.new("struct Vector2 *",[ rl.GetScreenWidth(), rl.GetScreenHeight() ])
|
||||
rl.SetShaderValue(shader, rl.GetShaderLocation(shader, b"size"), screenSize, rl.SHADER_UNIFORM_VEC2)
|
||||
|
||||
rl.SetShaderValue(shader, freqXLoc, freqX, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, freqYLoc, freqY, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, ampXLoc, ampX, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, ampYLoc, ampY, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, speedXLoc, speedX, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, speedYLoc, speedY, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, freqXLoc, freqX, rl.SHADER_UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, freqYLoc, freqY, rl.SHADER_UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, ampXLoc, ampX, rl.SHADER_UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, ampYLoc, ampY, rl.SHADER_UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, speedXLoc, speedX, rl.SHADER_UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, speedYLoc, speedY, rl.SHADER_UNIFORM_FLOAT)
|
||||
|
||||
seconds = ffi.new("float *", 0.0)
|
||||
seconds = rl.ffi.new("float *", 0.0)
|
||||
|
||||
rl.SetTargetFPS(60) # // Set our game to run at 60 frames-per-second
|
||||
#//--------------------------------------------------------------------------------------
|
||||
|
@ -63,7 +61,7 @@ while not rl.WindowShouldClose(): #// Detect window close button or E
|
|||
#// Update
|
||||
#//----------------------------------------------------------------------------------
|
||||
seconds[0] += rl.GetFrameTime()
|
||||
rl.SetShaderValue(shader, secondsLoc, seconds, rl.UNIFORM_FLOAT)
|
||||
rl.SetShaderValue(shader, secondsLoc, seconds, rl.SHADER_UNIFORM_FLOAT)
|
||||
#//----------------------------------------------------------------------------------
|
||||
|
||||
#// Draw
|
||||
|
|
Reference in a new issue