-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello-3d.scm
87 lines (68 loc) · 3.07 KB
/
hello-3d.scm
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
;; int main(void)
;; {
;; // Initialization
;; //--------------------------------------------------------------------------------------
;; const int screenWidth = 800;
;; const int screenHeight = 450;
;; InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode");
;; // Define the camera to look into our 3d world
;; Camera3D camera = { 0 };
;; camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
;; camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
;; camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
;; camera.fovy = 45.0f; // Camera field-of-view Y
;; camera.type = CAMERA_PERSPECTIVE; // Camera mode type
;; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
;; SetTargetFPS(60); // Set our game to run at 60 frames-per-second
;; //--------------------------------------------------------------------------------------
;; // Main game loop
;; while (!WindowShouldClose()) // Detect window close button or ESC key
;; {
;; // Update
;; //----------------------------------------------------------------------------------
;; // TODO: Update your variables here
;; //----------------------------------------------------------------------------------
;; // Draw
;; //----------------------------------------------------------------------------------
;; BeginDrawing();
;; ClearBackground(RAYWHITE);
;; BeginMode3D(camera);
;; DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
;; DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
;; DrawGrid(10, 1.0f);
;; EndMode3D();
;; DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
;; DrawFPS(10, 10);
;; EndDrawing();
;; //----------------------------------------------------------------------------------
;; }
;; // De-Initialization
;; //--------------------------------------------------------------------------------------
;; CloseWindow(); // Close window and OpenGL context
;; //--------------------------------------------------------------------------------------
;; return 0;
;; }
(define camera #f)
(define cube-position #f)
(define (init)
(init-window 800 600 "Hello 3d")
(display-nl "About to init camera")
(set! camera (make-camera-3d
(make-vector-3 0.0 10.0 10.0)
(make-vector-3 0.0 0.0 0.0)
(make-vector-3 0.0 1.0 0.0)
45.0
0))
(display-nl "Did it")
(set! cube-position (make-vector-3 0.0 0.0 0.0))
(set-target-fps 60))
(define (draw)
(begin-drawing)
(clear-background (color 255 255 255 255))
(begin-mode-3d camera)
(draw-cube cube-position 2.0 2.0 2.0 (color 255 0 0 255))
(draw-grid 10 1.0)
(end-mode-3d)
(draw-text "Hello 3d" 190 200 20 (color 192 192 192 255))
(end-drawing)
)