add more texture & shader examples
This commit is contained in:
parent
0dda56d08d
commit
f121c0e386
7 changed files with 415 additions and 0 deletions
49
examples/shaders/texture_drawing/main.go
Normal file
49
examples/shaders/texture_drawing/main.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing")
|
||||
|
||||
imBlank := rl.GenImageColor(1024, 1024, rl.Blank)
|
||||
texture := rl.LoadTextureFromImage(imBlank)
|
||||
rl.UnloadImage(imBlank)
|
||||
|
||||
shader := rl.LoadShader("", "cubes_panning.fs")
|
||||
|
||||
time := []float32{0}
|
||||
|
||||
timeLoc := rl.GetShaderLocation(shader, "uTime")
|
||||
|
||||
rl.SetShaderValue(shader, timeLoc, time, rl.ShaderUniformFloat)
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
|
||||
time = nil
|
||||
time = []float32{float32(rl.GetTime())}
|
||||
rl.SetShaderValue(shader, timeLoc, time, rl.ShaderUniformFloat)
|
||||
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginShaderMode(shader)
|
||||
rl.DrawTexture(texture, 0, 0, rl.White)
|
||||
rl.EndShaderMode()
|
||||
|
||||
rl.DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, rl.Maroon)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.UnloadShader(shader) // Unload shader
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue