-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.odin
45 lines (37 loc) · 1.23 KB
/
main.odin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import "core:fmt"
import "core:math"
import la "core:math/linalg"
import rl "vendor:raylib"
main :: proc() {
rl.SetTraceLogLevel(rl.TraceLogLevel.WARNING)
rl.InitWindow(400, 400, "glsl light shader")
shader := rl.LoadShader("assets/vs.glsl", "assets/fs.glsl")
camera: rl.Camera3D
{
using rl.CameraProjection
camera = rl.Camera3D{{0.0, 1.0, 4.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, 45.0, PERSPECTIVE}
}
model := rl.LoadModelFromMesh(rl.GenMeshTorus(0.4, 1, 16, 32))
model.materials[0].shader = shader // if you miss this, then the shader would not be applied to this object
ambientColor_loc := rl.GetShaderLocation(shader, "ambientColor")
ambientColor := la.Vector3f32{1.0, 1.0, 1.0}
{
using rl.ShaderUniformDataType
rl.SetShaderValue(shader, rl.ShaderLocationIndex(ambientColor_loc), &ambientColor, VEC3)
}
rl.SetTargetFPS(60)
for (!rl.WindowShouldClose()) {
rl.UpdateCamera(&camera, rl.CameraMode.ORBITAL)
rl.BeginDrawing()
rl.ClearBackground(rl.BLACK)
rl.BeginMode3D(camera)
rl.DrawModel(model, la.Vector3f32{0, 0, 0}, 1.0, rl.WHITE)
rl.EndMode3D()
rl.DrawFPS(10, 10)
rl.EndDrawing()
}
rl.UnloadModel(model)
rl.UnloadShader(shader)
rl.CloseWindow()
}