|
4 | 4 | module Raylib = |
5 | 5 | struct |
6 | 6 | include Raylib |
7 | | - let log fmt = Printf.ksprintf (Printf.printf "[%s]\n%!") fmt |
| 7 | + let _log fmt = Printf.ksprintf (Printf.printf "[Raylib.%s]\n%!") fmt |
| 8 | + let _log1 fmt = Printf.ksprintf (Printf.printf "[Raylib.%s]") fmt |
| 9 | + let _log2 fmt = Printf.ksprintf (Printf.printf " => %s\n%!") fmt |
| 10 | +(* |
8 | 11 | let init_window w h s = |
9 | | - log "init_window %d %d \"%s\"" w h s; |
| 12 | + _log "init_window %d %d \"%s\"" w h s; |
10 | 13 | init_window w h s |
11 | 14 | let set_window_size w h = |
12 | | - log "set_window_size %d %d" w h; |
| 15 | + _log "set_window_size %d %d" w h; |
13 | 16 | set_window_size w h |
14 | 17 | let set_window_position x y = |
15 | | - log "set_window_position %d %d" x y; |
| 18 | + _log "set_window_position %d %d" x y; |
16 | 19 | set_window_position x y |
17 | 20 | let set_window_state flags = |
18 | | - log "set_window_state 0x%x" (Raylib.ConfigFlags.to_int flags); |
| 21 | + _log "set_window_state 0x%x" (Raylib.ConfigFlags.to_int flags); |
19 | 22 | set_window_state flags |
20 | 23 | let clear_window_state flags = |
21 | | - log "clear_window_state 0x%x" (Raylib.ConfigFlags.to_int flags); |
| 24 | + _log "clear_window_state 0x%x" (Raylib.ConfigFlags.to_int flags); |
22 | 25 | clear_window_state flags |
23 | 26 | let maximize_window () = |
24 | | - log "maximize_window ()"; |
| 27 | + _log1 "maximize_window ()"; |
25 | 28 | maximize_window (); |
26 | | - let point_of_vec2 v = |
27 | | - Raylib.Vector2.(int_of_float (x v), int_of_float (y v)) in |
28 | | - let x, y = point_of_vec2 (Raylib.get_window_position ()) in |
29 | | - let w, h = Raylib.(get_screen_width (), get_screen_height ()) in |
30 | | - log "=> x=%d y=%d w=%d h=%d" x y w h |
| 29 | + let point_of_vec2 v = Vector2.(int_of_float (x v), int_of_float (y v)) in |
| 30 | + let x, y = point_of_vec2 (get_window_position ()) in |
| 31 | + let w, h = get_screen_width (), get_screen_height () in |
| 32 | + _log2 "x=%d y=%d w=%d h=%d" x y w h |
31 | 33 | let minimize_window () = |
32 | | - log "minimize_window ()"; |
| 34 | + _log "minimize_window ()"; |
33 | 35 | minimize_window () |
34 | 36 | let restore_window () = |
35 | | - log "restore_window ()"; |
| 37 | + _log "restore_window ()"; |
36 | 38 | restore_window () |
37 | 39 | let close_window () = |
38 | | - log "close_window ()"; |
| 40 | + _log "close_window ()"; |
39 | 41 | close_window () |
| 42 | +*) |
| 43 | +(* |
| 44 | + let init_audio_device () = |
| 45 | + _log "init_audio_device ()"; |
| 46 | + init_audio_device () |
| 47 | + let set_audio_stream_buffer_size_default n = |
| 48 | + _log "set_audio_stream_buffer_size_default %d" n; |
| 49 | + set_audio_stream_buffer_size_default n |
| 50 | + let set_master_volume x = |
| 51 | + _log "set_master_volume %.2f" x; |
| 52 | + set_master_volume x |
| 53 | + let load_music_stream path = |
| 54 | + _log1 "load_music_stream \"%s\"" path; |
| 55 | + let music = load_music_stream path in |
| 56 | + _log2 "music(%d)" (Music.ctx_type music); |
| 57 | + music |
| 58 | +(* |
| 59 | + let update_music_stream music = |
| 60 | + _log "update_music_stream music(%d)" (Music.ctx_type music); |
| 61 | + update_music_stream music |
| 62 | +*) |
| 63 | + let play_music_stream music = |
| 64 | + _log "play_music_stream music(%d)" (Music.ctx_type music); |
| 65 | + play_music_stream music |
| 66 | + let pause_music_stream music = |
| 67 | + _log "pause_music_stream music(%d)" (Music.ctx_type music); |
| 68 | + pause_music_stream music |
| 69 | + let resume_music_stream music = |
| 70 | + _log "resume_music_stream music(%d)" (Music.ctx_type music); |
| 71 | + resume_music_stream music |
| 72 | + let stop_music_stream music = |
| 73 | + _log "stop_music_stream music(%d)" (Music.ctx_type music); |
| 74 | + stop_music_stream music |
| 75 | + let seek_music_stream music time = |
| 76 | + _log1 "seek_music_stream music(%d) %.2f" (Music.ctx_type music) time; |
| 77 | + seek_music_stream music time; |
| 78 | + let played = get_music_time_played music in |
| 79 | + let length = get_music_time_length music in |
| 80 | + _log2 "%.2f/%.2fs" played length |
| 81 | +(* |
| 82 | + let is_music_stream_playing music = |
| 83 | + _log1 "is_music_stream_playing music(%d)" (Music.ctx_type music); |
| 84 | + let b = is_music_stream_playing music in |
| 85 | + _log2 "%b" b; |
| 86 | + b |
| 87 | + let get_music_time_played music = |
| 88 | + _log1 "get_music_time_played music(%d)" (Music.ctx_type music); |
| 89 | + let played = get_music_time_played music in |
| 90 | + let length = get_music_time_length music in |
| 91 | + _log2 "%.2f/%.2fs" played length; |
| 92 | + played |
| 93 | + let get_music_time_length music = |
| 94 | + _log1 "get_music_time_length music(%d)" (Music.ctx_type music); |
| 95 | + let length = get_music_time_length music in |
| 96 | + _log2 "%.2fs" length; |
| 97 | + length |
| 98 | +*) |
| 99 | + let unload_music_stream music = |
| 100 | + _log "unload_music_stream music(%d)" (Music.ctx_type music); |
| 101 | + unload_music_stream music |
| 102 | +(* |
| 103 | + let attach_audio_mixed_processor f = |
| 104 | + _log "attach_audio_mixed_processor func"; |
| 105 | + attach_audio_mixed_processor f |
| 106 | + let detach_audio_mixed_processor f = |
| 107 | + _log "detach_audio_mixed_processor func"; |
| 108 | + detach_audio_mixed_processor f |
| 109 | +*) |
| 110 | +*) |
40 | 111 | end |
41 | 112 | *) |
42 | 113 |
|
@@ -1055,11 +1126,14 @@ struct |
1055 | 1126 |
|
1056 | 1127 | let seek a t = |
1057 | 1128 | Mutex.protect a.mutex (fun () -> |
1058 | | - let playing = Raylib.is_music_stream_playing a.sound.music in |
1059 | | - Raylib.stop_music_stream a.sound.music; |
| 1129 | + if Raylib.is_music_stream_playing a.sound.music then |
| 1130 | + ( |
| 1131 | + (* Clear buffer *) |
| 1132 | + Raylib.stop_music_stream a.sound.music; |
| 1133 | + Raylib.play_music_stream a.sound.music; |
| 1134 | + ); |
1060 | 1135 | Raylib.seek_music_stream a.sound.music t; |
1061 | 1136 | Raylib.update_music_stream a.sound.music; |
1062 | | - if playing then Raylib.play_music_stream a.sound.music; |
1063 | 1137 | ) |
1064 | 1138 |
|
1065 | 1139 | let volume a x = |
|
0 commit comments