diff --git a/dune-project b/dune-project index 90df2fd..1dd95b3 100644 --- a/dune-project +++ b/dune-project @@ -1,12 +1,18 @@ (lang dune 2.8) + (name raylib) ; cannot specify conditional deps otherwise + (generate_opam_files false) -(source (github tjammer/raylib-ocaml)) +(source + (github tjammer/raylib-ocaml)) + (license MIT) + (authors "Tobias Mock") + (maintainers "tobiasjammer@gmail.com") (package @@ -17,9 +23,34 @@ (depends dune dune-configurator - (ctypes (>= 0.14)) - (integers (>= 0.5)) - (patch (>= 2.0)))) + (ctypes + (>= 0.14)) + (integers + (>= 0.5)) + (patch + (>= 2.0)))) + +(package + (name raylib-rlgl) + (version 1.3.1) + (description "OCaml bindings for raylib") + (synopsis "OCaml bindings for raylib") + (depends + dune + dune-configurator + (raylib + (= :version)))) + +(package + (name raylib-raudio) + (version 1.3.1) + (description "OCaml bindings for raylib") + (synopsis "OCaml bindings for raylib") + (depends + dune + dune-configurator + (raylib + (= :version)))) (package (name raygui) @@ -29,16 +60,16 @@ (depends dune dune-configurator - (ctypes (>= 0.14)) - (raylib (>= 0.6)) - (patch (>= 2.0)))) + (ctypes + (>= 0.14)) + (raylib + (>= 0.6)) + (patch + (>= 2.0)))) (package (name raylib-gen) (version 0.1.0) (description "Binding generation for raylib") (synopsis "Binding generation for raylib") - (depends - dune - yojson - re)) + (depends dune yojson re)) diff --git a/examples/audio/audio_module_playing.ml b/examples/audio/audio_module_playing.ml index 51078e3..35867b4 100644 --- a/examples/audio/audio_module_playing.ml +++ b/examples/audio/audio_module_playing.ml @@ -46,6 +46,7 @@ let random_circle () = let setup () = let open Raylib in + let open Raudio in set_config_flags [ ConfigFlags.Msaa_4x_hint ]; init_window width height "raylib [audio] example - module playing (streaming)"; init_audio_device (); @@ -59,6 +60,7 @@ let setup () = (circles, music) let rec loop circles music pause = + let open Raudio in match Raylib.window_should_close () with | true -> let open Raylib in diff --git a/examples/audio/audio_music_stream.ml b/examples/audio/audio_music_stream.ml index 3224e1d..3e786ae 100644 --- a/examples/audio/audio_music_stream.ml +++ b/examples/audio/audio_music_stream.ml @@ -3,6 +3,7 @@ let height = 450 let setup () = let open Raylib in + let open Raudio in init_window width height "raylib [audio] example - music playing (streaming)"; init_audio_device (); @@ -15,6 +16,7 @@ let setup () = let rec loop music pause = let open Raylib in + let open Raudio in match window_should_close () with | true -> unload_music_stream music; diff --git a/examples/audio/dune b/examples/audio/dune index 97c78d5..283dd4c 100644 --- a/examples/audio/dune +++ b/examples/audio/dune @@ -1,9 +1,9 @@ (executable (name audio_module_playing) (modules Audio_module_playing) - (libraries raylib)) + (libraries raylib-raudio)) (executable (name audio_music_stream) (modules Audio_music_stream) - (libraries raylib)) + (libraries raylib-raudio)) diff --git a/examples/core/core_2d_camera_mouse_zoom.ml b/examples/core/core_2d_camera_mouse_zoom.ml index 1cf4553..006ead8 100644 --- a/examples/core/core_2d_camera_mouse_zoom.ml +++ b/examples/core/core_2d_camera_mouse_zoom.ml @@ -70,11 +70,11 @@ let rec loop { zoom_mode; camera } = Raylib.begin_mode_2d camera; (* Draw the 3d grid, rotated 90 degrees and centered around 0,0 just so we have something in the XY plane *) - Raylib.Rlgl.push_matrix (); - Raylib.Rlgl.translatef 0. (25. *. 50.) 0.; - Raylib.Rlgl.rotatef 90. 1. 0. 0.; + Rlgl.push_matrix (); + Rlgl.translatef 0. (25. *. 50.) 0.; + Rlgl.rotatef 90. 1. 0. 0.; Raylib.draw_grid 100 50.; - Raylib.Rlgl.pop_matrix (); + Rlgl.pop_matrix (); (* Draw a reference circle *) Raylib.draw_circle diff --git a/examples/core/dune b/examples/core/dune index e9ac912..9fcc570 100644 --- a/examples/core/dune +++ b/examples/core/dune @@ -6,7 +6,7 @@ (executable (name core_2d_camera_mouse_zoom) (modules Core_2d_camera_mouse_zoom) - (libraries raylib)) + (libraries raylib-rlgl)) (executable (name core_2d_camera_platformer) diff --git a/raylib-raudio.opam b/raylib-raudio.opam new file mode 100644 index 0000000..c438f95 --- /dev/null +++ b/raylib-raudio.opam @@ -0,0 +1,35 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +version: "1.3.1" +synopsis: "OCaml bindings for raylib" +description: "OCaml bindings for raylib" +maintainer: ["tobiasjammer@gmail.com"] +authors: ["Tobias Mock"] +license: "MIT" +homepage: "https://github.com/tjammer/raylib-ocaml" +bug-reports: "https://github.com/tjammer/raylib-ocaml/issues" +depends: [ + "dune" {>= "2.8"} + "raylib" {= version} + "odoc" {with-doc} +] +build: [ + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "build" "@doc" "-p" name ] {with-doc} +] +dev-repo: "git+https://github.com/tjammer/raylib-ocaml.git" +available: [arch != "arm32" & arch != "ppc64"] +x-ci-accept-failures: [ + "centos-7" # C compiler is too old + "oraclelinux-7" # C compiler is too old +] diff --git a/raylib-rlgl.opam b/raylib-rlgl.opam new file mode 100644 index 0000000..c438f95 --- /dev/null +++ b/raylib-rlgl.opam @@ -0,0 +1,35 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +version: "1.3.1" +synopsis: "OCaml bindings for raylib" +description: "OCaml bindings for raylib" +maintainer: ["tobiasjammer@gmail.com"] +authors: ["Tobias Mock"] +license: "MIT" +homepage: "https://github.com/tjammer/raylib-ocaml" +bug-reports: "https://github.com/tjammer/raylib-ocaml/issues" +depends: [ + "dune" {>= "2.8"} + "raylib" {= version} + "odoc" {with-doc} +] +build: [ + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "build" "@doc" "-p" name ] {with-doc} +] +dev-repo: "git+https://github.com/tjammer/raylib-ocaml.git" +available: [arch != "arm32" & arch != "ppc64"] +x-ci-accept-failures: [ + "centos-7" # C compiler is too old + "oraclelinux-7" # C compiler is too old +] diff --git a/src/c/dune b/src/c/dune index f1c7ca3..8883a58 100644 --- a/src/c/dune +++ b/src/c/dune @@ -6,16 +6,37 @@ (library (name raylib_c) (package raylib) - (modules - Raylib_c_generated_functions - Raylib_c_generated_math - Raylib_c_generated_rlgl) + (modules Raylib_c_generated_functions Raylib_c_generated_math) (foreign_archives raylib) (foreign_stubs (language c) - (names c_generated_functions c_generated_math c_generated_rlgl) + (names c_generated_functions c_generated_math) (include_dirs %{project_root}/src/c/vendor/raylib/src)) - (libraries ctypes.stubs raylib_functions raylib_math raylib_rlgl) + (libraries ctypes.stubs raylib_functions raylib_math) + (library_flags + (:include library_flags.sexp))) + +(library + (name raylib_rlgl_c) + (package raylib-rlgl) + (modules Raylib_c_generated_rlgl) + (foreign_stubs + (language c) + (names c_generated_rlgl) + (include_dirs %{project_root}/src/c/vendor/raylib/src)) + (libraries ctypes.stubs raylib_rlgl) + (library_flags + (:include library_flags.sexp))) + +(library + (name raylib_raudio_c) + (package raylib-raudio) + (modules Raylib_c_generated_raudio) + (foreign_stubs + (language c) + (names c_generated_raudio) + (include_dirs %{project_root}/src/c/vendor/raylib/src)) + (libraries ctypes.stubs raylib_raudio) (library_flags (:include library_flags.sexp))) @@ -64,11 +85,21 @@ c_generated_rlgl.c (run stubgen/generate_c_rlgl.exe raylib_stub))) +(rule + (with-stdout-to + c_generated_raudio.c + (run stubgen/generate_c_raudio.exe raylib_stub))) + (rule (with-stdout-to raylib_c_generated_rlgl.ml (run stubgen/generate_ml_rlgl.exe raylib_stub))) +(rule + (with-stdout-to + raylib_c_generated_raudio.ml + (run stubgen/generate_ml_raudio.exe raylib_stub))) + (data_only_dirs vendor) (rule @@ -212,7 +243,20 @@ (bash "%{cc} %{c} -I '%{lib:ctypes:.}' -I %{ocaml_where} -I vendor/raylib/src -o %{targets}"))) +(rule + (targets generate_raudio_types_step_2.exe) + (deps + (:c raudio_c_generated_types.c)) + (action + (bash + "%{cc} %{c} -I '%{lib:ctypes:.}' -I %{ocaml_where} -I vendor/raylib/src -o %{targets}"))) + (rule (with-stdout-to rlgl_c_generated_types.c (run stubgen/generate_c_rlgl_types.exe raylib_stub))) + +(rule + (with-stdout-to + raudio_c_generated_types.c + (run stubgen/generate_c_raudio_types.exe raylib_stub))) diff --git a/src/c/functions/dune b/src/c/functions/dune index 6f78ba6..5acd1a8 100644 --- a/src/c/functions/dune +++ b/src/c/functions/dune @@ -6,6 +6,14 @@ (:standard -w -9-27)) (libraries ctypes.stubs raylib_fixed_types)) +(library + (name raylib_raudio) + (package raylib) + (modules Raylib_raudio) + (flags + (:standard -w -9-27)) + (libraries ctypes.stubs raudio_fixed_types)) + (library (name raylib_math) (package raylib) @@ -24,7 +32,7 @@ (library (name raylib_rlgl) - (package raylib) + (package raylib-rlgl) (modules Raylib_rlgl) (flags (:standard -w -9-27)) diff --git a/src/c/functions/raylib_functions.ml b/src/c/functions/raylib_functions.ml index 8d961ab..426df7a 100644 --- a/src/c/functions/raylib_functions.ml +++ b/src/c/functions/raylib_functions.ml @@ -1475,173 +1475,4 @@ module Description (F : Ctypes.FOREIGN) = struct foreign "GetRayCollisionQuad" (Ray.t @-> Vector3.t @-> Vector3.t @-> Vector3.t @-> Vector3.t @-> returning RayCollision.t) - - let init_audio_device = foreign "InitAudioDevice" (void @-> returning void) - let close_audio_device = foreign "CloseAudioDevice" (void @-> returning void) - - let is_audio_device_ready = - foreign "IsAudioDeviceReady" (void @-> returning bool) - - let set_master_volume = foreign "SetMasterVolume" (float @-> returning void) - let get_master_volume = foreign "GetMasterVolume" (void @-> returning float) - let load_wave = foreign "LoadWave" (string @-> returning Wave.t) - - let load_wave_from_memory = - foreign "LoadWaveFromMemory" (string @-> string @-> int @-> returning Wave.t) - - let is_wave_ready = foreign "IsWaveReady" (Wave.t @-> returning bool) - let load_sound = foreign "LoadSound" (string @-> returning Sound.t) - - let load_sound_from_wave = - foreign "LoadSoundFromWave" (Wave.t @-> returning Sound.t) - - let load_sound_alias = foreign "LoadSoundAlias" (Sound.t @-> returning Sound.t) - let is_sound_ready = foreign "IsSoundReady" (Sound.t @-> returning bool) - - let update_sound = - foreign "UpdateSound" (Sound.t @-> ptr void @-> int @-> returning void) - - let unload_wave = foreign "UnloadWave" (Wave.t @-> returning void) - let unload_sound = foreign "UnloadSound" (Sound.t @-> returning void) - - let unload_sound_alias = - foreign "UnloadSoundAlias" (Sound.t @-> returning void) - - let export_wave = foreign "ExportWave" (Wave.t @-> string @-> returning bool) - - let export_wave_as_code = - foreign "ExportWaveAsCode" (Wave.t @-> string @-> returning bool) - - let play_sound = foreign "PlaySound" (Sound.t @-> returning void) - let stop_sound = foreign "StopSound" (Sound.t @-> returning void) - let pause_sound = foreign "PauseSound" (Sound.t @-> returning void) - let resume_sound = foreign "ResumeSound" (Sound.t @-> returning void) - let is_sound_playing = foreign "IsSoundPlaying" (Sound.t @-> returning bool) - - let set_sound_volume = - foreign "SetSoundVolume" (Sound.t @-> float @-> returning void) - - let set_sound_pitch = - foreign "SetSoundPitch" (Sound.t @-> float @-> returning void) - - let set_sound_pan = - foreign "SetSoundPan" (Sound.t @-> float @-> returning void) - - let wave_copy = foreign "WaveCopy" (Wave.t @-> returning Wave.t) - - let wave_crop = - foreign "WaveCrop" (ptr Wave.t @-> int @-> int @-> returning void) - - let wave_format = - foreign "WaveFormat" (ptr Wave.t @-> int @-> int @-> int @-> returning void) - - let load_wave_samples = - foreign "LoadWaveSamples" (Wave.t @-> returning (ptr float)) - - let unload_wave_samples = - foreign "UnloadWaveSamples" (ptr float @-> returning void) - - let load_music_stream = - foreign "LoadMusicStream" (string @-> returning Music.t) - - let load_music_stream_from_memory = - foreign "LoadMusicStreamFromMemory" - (string @-> string @-> int @-> returning Music.t) - - let is_music_ready = foreign "IsMusicReady" (Music.t @-> returning bool) - - let unload_music_stream = - foreign "UnloadMusicStream" (Music.t @-> returning void) - - let play_music_stream = foreign "PlayMusicStream" (Music.t @-> returning void) - - let is_music_stream_playing = - foreign "IsMusicStreamPlaying" (Music.t @-> returning bool) - - let update_music_stream = - foreign "UpdateMusicStream" (Music.t @-> returning void) - - let stop_music_stream = foreign "StopMusicStream" (Music.t @-> returning void) - - let pause_music_stream = - foreign "PauseMusicStream" (Music.t @-> returning void) - - let resume_music_stream = - foreign "ResumeMusicStream" (Music.t @-> returning void) - - let seek_music_stream = - foreign "SeekMusicStream" (Music.t @-> float @-> returning void) - - let set_music_volume = - foreign "SetMusicVolume" (Music.t @-> float @-> returning void) - - let set_music_pitch = - foreign "SetMusicPitch" (Music.t @-> float @-> returning void) - - let set_music_pan = - foreign "SetMusicPan" (Music.t @-> float @-> returning void) - - let get_music_time_length = - foreign "GetMusicTimeLength" (Music.t @-> returning float) - - let get_music_time_played = - foreign "GetMusicTimePlayed" (Music.t @-> returning float) - - let load_audio_stream = - foreign "LoadAudioStream" (int @-> int @-> int @-> returning AudioStream.t) - - let is_audio_stream_ready = - foreign "IsAudioStreamReady" (AudioStream.t @-> returning bool) - - let unload_audio_stream = - foreign "UnloadAudioStream" (AudioStream.t @-> returning void) - - let update_audio_stream = - foreign "UpdateAudioStream" - (AudioStream.t @-> ptr void @-> int @-> returning void) - - let is_audio_stream_processed = - foreign "IsAudioStreamProcessed" (AudioStream.t @-> returning bool) - - let play_audio_stream = - foreign "PlayAudioStream" (AudioStream.t @-> returning void) - - let pause_audio_stream = - foreign "PauseAudioStream" (AudioStream.t @-> returning void) - - let resume_audio_stream = - foreign "ResumeAudioStream" (AudioStream.t @-> returning void) - - let is_audio_stream_playing = - foreign "IsAudioStreamPlaying" (AudioStream.t @-> returning bool) - - let stop_audio_stream = - foreign "StopAudioStream" (AudioStream.t @-> returning void) - - let set_audio_stream_volume = - foreign "SetAudioStreamVolume" (AudioStream.t @-> float @-> returning void) - - let set_audio_stream_pitch = - foreign "SetAudioStreamPitch" (AudioStream.t @-> float @-> returning void) - - let set_audio_stream_pan = - foreign "SetAudioStreamPan" (AudioStream.t @-> float @-> returning void) - - let set_audio_stream_buffer_size_default = - foreign "SetAudioStreamBufferSizeDefault" (int @-> returning void) - - (* let set_audio_stream_callback = *) - (* foreign "SetAudioStreamCallback" (AudioStream.t @-> audio_callback @-> returning void) *) - - (* let attach_audio_stream_processor = *) - (* foreign "AttachAudioStreamProcessor" (AudioStream.t @-> audio_callback @-> returning void) *) - - (* let detach_audio_stream_processor = *) - (* foreign "DetachAudioStreamProcessor" (AudioStream.t @-> audio_callback @-> returning void) *) - - (* let attach_audio_mixed_processor = *) - (* foreign "AttachAudioMixedProcessor" (audio_callback @-> returning void) *) - - (* let detach_audio_mixed_processor = *) - (* foreign "DetachAudioMixedProcessor" (audio_callback @-> returning void) *) end diff --git a/src/c/functions/raylib_raudio.ml b/src/c/functions/raylib_raudio.ml new file mode 100644 index 0000000..c39437b --- /dev/null +++ b/src/c/functions/raylib_raudio.ml @@ -0,0 +1,174 @@ +module Description (F : Ctypes.FOREIGN) = struct + open Ctypes + open F + open Raudio_fixed_types + + let init_audio_device = foreign "InitAudioDevice" (void @-> returning void) + let close_audio_device = foreign "CloseAudioDevice" (void @-> returning void) + + let is_audio_device_ready = + foreign "IsAudioDeviceReady" (void @-> returning bool) + + let set_master_volume = foreign "SetMasterVolume" (float @-> returning void) + let get_master_volume = foreign "GetMasterVolume" (void @-> returning float) + let load_wave = foreign "LoadWave" (string @-> returning Wave.t) + + let load_wave_from_memory = + foreign "LoadWaveFromMemory" (string @-> string @-> int @-> returning Wave.t) + + let is_wave_ready = foreign "IsWaveReady" (Wave.t @-> returning bool) + let load_sound = foreign "LoadSound" (string @-> returning Sound.t) + + let load_sound_from_wave = + foreign "LoadSoundFromWave" (Wave.t @-> returning Sound.t) + + let load_sound_alias = foreign "LoadSoundAlias" (Sound.t @-> returning Sound.t) + let is_sound_ready = foreign "IsSoundReady" (Sound.t @-> returning bool) + + let update_sound = + foreign "UpdateSound" (Sound.t @-> ptr void @-> int @-> returning void) + + let unload_wave = foreign "UnloadWave" (Wave.t @-> returning void) + let unload_sound = foreign "UnloadSound" (Sound.t @-> returning void) + + let unload_sound_alias = + foreign "UnloadSoundAlias" (Sound.t @-> returning void) + + let export_wave = foreign "ExportWave" (Wave.t @-> string @-> returning bool) + + let export_wave_as_code = + foreign "ExportWaveAsCode" (Wave.t @-> string @-> returning bool) + + let play_sound = foreign "PlaySound" (Sound.t @-> returning void) + let stop_sound = foreign "StopSound" (Sound.t @-> returning void) + let pause_sound = foreign "PauseSound" (Sound.t @-> returning void) + let resume_sound = foreign "ResumeSound" (Sound.t @-> returning void) + let is_sound_playing = foreign "IsSoundPlaying" (Sound.t @-> returning bool) + + let set_sound_volume = + foreign "SetSoundVolume" (Sound.t @-> float @-> returning void) + + let set_sound_pitch = + foreign "SetSoundPitch" (Sound.t @-> float @-> returning void) + + let set_sound_pan = + foreign "SetSoundPan" (Sound.t @-> float @-> returning void) + + let wave_copy = foreign "WaveCopy" (Wave.t @-> returning Wave.t) + + let wave_crop = + foreign "WaveCrop" (ptr Wave.t @-> int @-> int @-> returning void) + + let wave_format = + foreign "WaveFormat" (ptr Wave.t @-> int @-> int @-> int @-> returning void) + + let load_wave_samples = + foreign "LoadWaveSamples" (Wave.t @-> returning (ptr float)) + + let unload_wave_samples = + foreign "UnloadWaveSamples" (ptr float @-> returning void) + + let load_music_stream = + foreign "LoadMusicStream" (string @-> returning Music.t) + + let load_music_stream_from_memory = + foreign "LoadMusicStreamFromMemory" + (string @-> string @-> int @-> returning Music.t) + + let is_music_ready = foreign "IsMusicReady" (Music.t @-> returning bool) + + let unload_music_stream = + foreign "UnloadMusicStream" (Music.t @-> returning void) + + let play_music_stream = foreign "PlayMusicStream" (Music.t @-> returning void) + + let is_music_stream_playing = + foreign "IsMusicStreamPlaying" (Music.t @-> returning bool) + + let update_music_stream = + foreign "UpdateMusicStream" (Music.t @-> returning void) + + let stop_music_stream = foreign "StopMusicStream" (Music.t @-> returning void) + + let pause_music_stream = + foreign "PauseMusicStream" (Music.t @-> returning void) + + let resume_music_stream = + foreign "ResumeMusicStream" (Music.t @-> returning void) + + let seek_music_stream = + foreign "SeekMusicStream" (Music.t @-> float @-> returning void) + + let set_music_volume = + foreign "SetMusicVolume" (Music.t @-> float @-> returning void) + + let set_music_pitch = + foreign "SetMusicPitch" (Music.t @-> float @-> returning void) + + let set_music_pan = + foreign "SetMusicPan" (Music.t @-> float @-> returning void) + + let get_music_time_length = + foreign "GetMusicTimeLength" (Music.t @-> returning float) + + let get_music_time_played = + foreign "GetMusicTimePlayed" (Music.t @-> returning float) + + let load_audio_stream = + foreign "LoadAudioStream" (int @-> int @-> int @-> returning AudioStream.t) + + let is_audio_stream_ready = + foreign "IsAudioStreamReady" (AudioStream.t @-> returning bool) + + let unload_audio_stream = + foreign "UnloadAudioStream" (AudioStream.t @-> returning void) + + let update_audio_stream = + foreign "UpdateAudioStream" + (AudioStream.t @-> ptr void @-> int @-> returning void) + + let is_audio_stream_processed = + foreign "IsAudioStreamProcessed" (AudioStream.t @-> returning bool) + + let play_audio_stream = + foreign "PlayAudioStream" (AudioStream.t @-> returning void) + + let pause_audio_stream = + foreign "PauseAudioStream" (AudioStream.t @-> returning void) + + let resume_audio_stream = + foreign "ResumeAudioStream" (AudioStream.t @-> returning void) + + let is_audio_stream_playing = + foreign "IsAudioStreamPlaying" (AudioStream.t @-> returning bool) + + let stop_audio_stream = + foreign "StopAudioStream" (AudioStream.t @-> returning void) + + let set_audio_stream_volume = + foreign "SetAudioStreamVolume" (AudioStream.t @-> float @-> returning void) + + let set_audio_stream_pitch = + foreign "SetAudioStreamPitch" (AudioStream.t @-> float @-> returning void) + + let set_audio_stream_pan = + foreign "SetAudioStreamPan" (AudioStream.t @-> float @-> returning void) + + let set_audio_stream_buffer_size_default = + foreign "SetAudioStreamBufferSizeDefault" (int @-> returning void) + + (* let set_audio_stream_callback = *) + (* foreign "SetAudioStreamCallback" (AudioStream.t @-> audio_callback @-> returning void) *) + + (* let attach_audio_stream_processor = *) + (* foreign "AttachAudioStreamProcessor" (AudioStream.t @-> audio_callback @-> returning void) *) + + (* let detach_audio_stream_processor = *) + (* foreign "DetachAudioStreamProcessor" (AudioStream.t @-> audio_callback @-> returning void) *) + + (* let attach_audio_mixed_processor = *) + (* foreign "AttachAudioMixedProcessor" (audio_callback @-> returning void) *) + + (* let detach_audio_mixed_processor = *) + (* foreign "DetachAudioMixedProcessor" (audio_callback @-> returning void) *) +end diff --git a/src/c/stubgen/dune b/src/c/stubgen/dune index 693acd4..2b7635a 100644 --- a/src/c/stubgen/dune +++ b/src/c/stubgen/dune @@ -36,11 +36,21 @@ (modules Generate_c_rlgl) (libraries ctypes.stubs raylib_rlgl)) +(executable + (name generate_c_raudio) + (modules Generate_c_raudio) + (libraries ctypes.stubs raylib_raudio)) + (executable (name generate_ml_rlgl) (modules Generate_ml_rlgl) (libraries ctypes.stubs raylib_rlgl)) +(executable + (name generate_ml_raudio) + (modules Generate_ml_raudio) + (libraries ctypes.stubs raylib_raudio)) + (executable (name generate_c_raylib_types) (modules Generate_c_raylib_types) @@ -55,3 +65,8 @@ (name generate_c_rlgl_types) (modules Generate_c_rlgl_types) (libraries ctypes.stubs rlgl_types)) + +(executable + (name generate_c_raudio_types) + (modules Generate_c_raudio_types) + (libraries ctypes.stubs raudio_types)) diff --git a/src/c/stubgen/generate_c_raudio.ml b/src/c/stubgen/generate_c_raudio.ml new file mode 100644 index 0000000..20ba9d2 --- /dev/null +++ b/src/c/stubgen/generate_c_raudio.ml @@ -0,0 +1,5 @@ +let () = + print_endline "#include "; + + Cstubs.write_c Format.std_formatter ~prefix:Sys.argv.(1) + (module Raylib_raudio.Description) diff --git a/src/c/stubgen/generate_c_raudio_types.ml b/src/c/stubgen/generate_c_raudio_types.ml new file mode 100644 index 0000000..9cd02b5 --- /dev/null +++ b/src/c/stubgen/generate_c_raudio_types.ml @@ -0,0 +1,4 @@ +let () = + print_endline "#include \n#include "; + + Cstubs_structs.write_c Format.std_formatter (module Raudio_types.Types) diff --git a/src/c/stubgen/generate_ml_raudio.ml b/src/c/stubgen/generate_ml_raudio.ml new file mode 100644 index 0000000..64f6b8f --- /dev/null +++ b/src/c/stubgen/generate_ml_raudio.ml @@ -0,0 +1,3 @@ +let () = + Cstubs.write_ml Format.std_formatter ~prefix:Sys.argv.(1) + (module Raylib_raudio.Description) diff --git a/src/c/types/dune b/src/c/types/dune index b98020b..e649e7d 100644 --- a/src/c/types/dune +++ b/src/c/types/dune @@ -1,3 +1,5 @@ +; RAYLIB + (library (name raylib_types) (package raylib) @@ -17,6 +19,29 @@ raylib_c_generated_types.ml (run ../generate_types_step_2.exe))) +; RAUDIO + +(library + (name raudio_types) + (package raylib-raudio) + (modules Raudio_types) + (flags + (:standard -w -9-27)) + (libraries ctypes.stubs)) + +(library + (name raudio_fixed_types) + (package raylib-raudio) + (modules Raudio_fixed_types Raudio_c_generated_types) + (libraries ctypes raudio_types)) + +(rule + (with-stdout-to + raudio_c_generated_types.ml + (run ../generate_raudio_types_step_2.exe))) + +; RAYGUI + (library (name raygui_types) (package raygui) @@ -36,9 +61,11 @@ raygui_c_generated_types.ml (run ../generate_raygui_types_step_2.exe))) +; RLGL + (library (name rlgl_types) - (package raylib) + (package raylib-rlgl) (modules Rlgl_types) (flags (:standard -w -9-27)) @@ -51,7 +78,7 @@ (library (name rlgl_generated_types) - (package raylib) + (package raylib-rlgl) (modules Rlgl_generated_types Rlgl_c_generated_types) (flags (:standard -w -9-27)) diff --git a/src/c/types/raudio_fixed_types.ml b/src/c/types/raudio_fixed_types.ml new file mode 100644 index 0000000..1ba2cce --- /dev/null +++ b/src/c/types/raudio_fixed_types.ml @@ -0,0 +1,6 @@ +module Types = Raudio_types.Types (Raudio_c_generated_types) +open Types +module Wave = Wave +module AudioStream = AudioStream +module Sound = Sound +module Music = Music diff --git a/src/c/types/raudio_types.ml b/src/c/types/raudio_types.ml new file mode 100644 index 0000000..8f212bc --- /dev/null +++ b/src/c/types/raudio_types.ml @@ -0,0 +1,54 @@ +module Types (F : Ctypes.TYPE) = struct + open F + + module Wave = struct + type t + + let t : t Ctypes.structure typ = structure "Wave" + let frame_count = field t "frameCount" uint + let sample_rate = field t "sampleRate" uint + let sample_size = field t "sampleSize" uint + let channels = field t "channels" uint + let data = field t "data" (ptr void) + let () = seal t + end + + module AudioStream = struct + let r_audio_buffer : [ `R_audio_buffer ] Ctypes.structure typ = + structure "rAudioBuffer" + + let r_audio_processor : [ `R_audio_processor ] Ctypes.structure typ = + structure "rAudioProcessor" + + type t + + let t : t Ctypes.structure typ = structure "AudioStream" + let buffer = field t "buffer" (ptr r_audio_buffer) + let processor = field t "processor" (ptr r_audio_processor) + let sample_rate = field t "sampleRate" uint + let sample_size = field t "sampleSize" uint + let channels = field t "channels" uint + let () = seal t + end + + module Sound = struct + type t + + let t : t Ctypes.structure typ = structure "Sound" + let stream = field t "stream" AudioStream.t + let frame_count = field t "frameCount" uint + let () = seal t + end + + module Music = struct + type t + + let t : t Ctypes.structure typ = structure "Music" + let stream = field t "stream" AudioStream.t + let frame_count = field t "frameCount" uint + let looping = field t "looping" bool + let ctx_type = field t "ctxType" int + let ctx_data = field t "ctxData" (ptr void) + let () = seal t + end +end diff --git a/src/c/types/raylib_fixed_types.ml b/src/c/types/raylib_fixed_types.ml index 539e8e3..0f58cd6 100644 --- a/src/c/types/raylib_fixed_types.ml +++ b/src/c/types/raylib_fixed_types.ml @@ -198,10 +198,6 @@ module ModelAnimation = ModelAnimation module Ray = Ray module RayCollision = RayCollision module BoundingBox = BoundingBox -module Wave = Wave -module AudioStream = AudioStream -module Sound = Sound -module Music = Music module VrDeviceInfo = VrDeviceInfo module VrStereoConfig = VrStereoConfig module FilePathList = FilePathList diff --git a/src/c/types/raylib_types.ml b/src/c/types/raylib_types.ml index e3bd675..5b78676 100644 --- a/src/c/types/raylib_types.ml +++ b/src/c/types/raylib_types.ml @@ -1098,57 +1098,6 @@ module Types (F : Ctypes.TYPE) = struct let () = seal t end - module Wave = struct - type t - - let t : t Ctypes.structure typ = structure "Wave" - let frame_count = field t "frameCount" uint - let sample_rate = field t "sampleRate" uint - let sample_size = field t "sampleSize" uint - let channels = field t "channels" uint - let data = field t "data" (ptr void) - let () = seal t - end - - module AudioStream = struct - let r_audio_buffer : [ `R_audio_buffer ] Ctypes.structure typ = - structure "rAudioBuffer" - - let r_audio_processor : [ `R_audio_processor ] Ctypes.structure typ = - structure "rAudioProcessor" - - type t - - let t : t Ctypes.structure typ = structure "AudioStream" - let buffer = field t "buffer" (ptr r_audio_buffer) - let processor = field t "processor" (ptr r_audio_processor) - let sample_rate = field t "sampleRate" uint - let sample_size = field t "sampleSize" uint - let channels = field t "channels" uint - let () = seal t - end - - module Sound = struct - type t - - let t : t Ctypes.structure typ = structure "Sound" - let stream = field t "stream" AudioStream.t - let frame_count = field t "frameCount" uint - let () = seal t - end - - module Music = struct - type t - - let t : t Ctypes.structure typ = structure "Music" - let stream = field t "stream" AudioStream.t - let frame_count = field t "frameCount" uint - let looping = field t "looping" bool - let ctx_type = field t "ctxType" int - let ctx_data = field t "ctxData" (ptr void) - let () = seal t - end - module VrDeviceInfo = struct let float_array_4 = array 4 float diff --git a/src/raylib/raudio/dune b/src/raylib/raudio/dune new file mode 100644 index 0000000..0f236bf --- /dev/null +++ b/src/raylib/raudio/dune @@ -0,0 +1,4 @@ +(library + (name raudio) + (public_name raylib-raudio) + (libraries raylib raylib_raudio_c raudio_fixed_types raudio_types)) diff --git a/src/raylib/raudio/raudio.ml b/src/raylib/raudio/raudio.ml new file mode 100644 index 0000000..1f71d7d --- /dev/null +++ b/src/raylib/raudio/raudio.ml @@ -0,0 +1,57 @@ +open Raudio_fixed_types +include Raylib_raudio.Description (Raylib_raudio_c.Raylib_c_generated_raudio) +open Ctypes + +module Wave = struct + type t' = Wave.t + type t = t' Raylib.ctyp + + let t = Wave.t + let sample_rate wave = getf wave Wave.sample_rate + let sample_size wave = getf wave Wave.sample_size + let channels wave = getf wave Wave.channels + let set_sample_rate wave sample_rate = setf wave Wave.sample_rate sample_rate + let set_sample_size wave sample_size = setf wave Wave.sample_size sample_size + let set_channels wave channels = setf wave Wave.channels channels +end + +module AudioStream = struct + type t' = AudioStream.t + type t = t' Raylib.ctyp + + let t = AudioStream.t + let sample_rate audiostream = getf audiostream AudioStream.sample_rate + let sample_size audiostream = getf audiostream AudioStream.sample_size + let channels audiostream = getf audiostream AudioStream.channels + + let set_sample_rate audiostream sample_rate = + setf audiostream AudioStream.sample_rate sample_rate + + let set_sample_size audiostream sample_size = + setf audiostream AudioStream.sample_size sample_size + + let set_channels audiostream channels = + setf audiostream AudioStream.channels channels +end + +module Sound = struct + type t' = Sound.t + type t = t' Raylib.ctyp + + let t = Sound.t + let stream sound = getf sound Sound.stream + let set_stream sound stream = setf sound Sound.stream stream +end + +module Music = struct + type t' = Music.t + type t = t' Raylib.ctyp + + let t = Music.t + let stream music = getf music Music.stream + let looping music = getf music Music.looping + let ctx_type music = getf music Music.ctx_type + let set_stream music stream = setf music Music.stream stream + let set_looping music looping = setf music Music.looping looping + let set_ctx_type music ctx_type = setf music Music.ctx_type ctx_type +end diff --git a/src/raylib/raudio/raudio.mli b/src/raylib/raudio/raudio.mli new file mode 100644 index 0000000..e3e6cc6 --- /dev/null +++ b/src/raylib/raudio/raudio.mli @@ -0,0 +1,267 @@ +open Raylib + +(** {1 Types} *) + +module Wave : sig + type t' + type t = t' ctyp + + val t : t Ctypes.typ + + val sample_rate : t -> Unsigned.uint + (** Frequency (samples per second) *) + + val sample_size : t -> Unsigned.uint + (** Bit depth (bits per sample): 8, 16, 32 (24 not supported) *) + + val channels : t -> Unsigned.uint + (** Number of channels (1-mono, 2-stereo, ...) *) + + val set_sample_rate : t -> Unsigned.uint -> unit + val set_sample_size : t -> Unsigned.uint -> unit + val set_channels : t -> Unsigned.uint -> unit +end + +module AudioStream : sig + type t' + type t = t' ctyp + + val t : t Ctypes.typ + + val sample_rate : t -> Unsigned.uint + (** Frequency (samples per second) *) + + val sample_size : t -> Unsigned.uint + (** Bit depth (bits per sample): 8, 16, 32 (24 not supported) *) + + val channels : t -> Unsigned.uint + (** Number of channels (1-mono, 2-stereo, ...) *) + + val set_sample_rate : t -> Unsigned.uint -> unit + val set_sample_size : t -> Unsigned.uint -> unit + val set_channels : t -> Unsigned.uint -> unit +end + +module Sound : sig + type t' + type t = t' ctyp + + val t : t Ctypes.typ + + val stream : t -> AudioStream.t + (** Audio stream *) + + val set_stream : t -> AudioStream.t -> unit +end + +module Music : sig + type t' + type t = t' ctyp + + val t : t Ctypes.typ + + val stream : t -> AudioStream.t + (** Audio stream *) + + val looping : t -> bool + (** Music looping enable *) + + val ctx_type : t -> int + (** Type of music context (audio filetype) *) + + val set_stream : t -> AudioStream.t -> unit + val set_looping : t -> bool -> unit + val set_ctx_type : t -> int -> unit +end + +(** {1 Functions}*) + +(** {2 Audio Loading and Playing Functions (Module: audio)} *) + +(** {3 Audio device management functions} *) +val init_audio_device : unit -> unit +(** [init_audio_device ()] Initialize audio device and context*) + +val close_audio_device : unit -> unit +(** [close_audio_device ()] Close the audio device and context*) + +val is_audio_device_ready : unit -> bool +(** [is_audio_device_ready ()] Check if audio device has been initialized successfully*) + +val set_master_volume : float -> unit +(** [set_master_volume volume] Set master volume (listener)*) + +val get_master_volume : unit -> float +(** [get_master_volume ()] Get master volume (listener)*) + +val load_wave : string -> Wave.t +(** [load_wave file_name] Load wave data from file*) + +val load_wave_from_memory : string -> string -> int -> Wave.t +(** [load_wave_from_memory file_type file_data data_size] Load wave from memory buffer, fileType refers to extension: i.e. '.wav'*) + +val is_wave_ready : Wave.t -> bool +(** [is_wave_ready wave] Checks if wave data is ready*) + +val load_sound : string -> Sound.t +(** [load_sound file_name] Load sound from file*) + +val load_sound_from_wave : Wave.t -> Sound.t +(** [load_sound_from_wave wave] Load sound from wave data*) + +val load_sound_alias : Sound.t -> Sound.t +(** [load_sound_alias source] Create a new sound that shares the same sample data as the source sound, does not own the sound data*) + +val is_sound_ready : Sound.t -> bool +(** [is_sound_ready sound] Checks if a sound is ready*) + +val update_sound : Sound.t -> unit ptr -> int -> unit +(** [update_sound sound data sample_count] Update sound buffer with new data*) + +val unload_wave : Wave.t -> unit +(** [unload_wave wave] Unload wave data*) + +val unload_sound : Sound.t -> unit +(** [unload_sound sound] Unload sound*) + +val unload_sound_alias : Sound.t -> unit +(** [unload_sound_alias alias] Unload a sound alias (does not deallocate sample data)*) + +val export_wave : Wave.t -> string -> bool +(** [export_wave wave file_name] Export wave data to file, returns true on success*) + +val export_wave_as_code : Wave.t -> string -> bool +(** [export_wave_as_code wave file_name] Export wave sample data to code (.h), returns true on success*) + +(** {3 Wave/Sound management functions} *) + +val play_sound : Sound.t -> unit +(** [play_sound sound] Play a sound*) + +val stop_sound : Sound.t -> unit +(** [stop_sound sound] Stop playing a sound*) + +val pause_sound : Sound.t -> unit +(** [pause_sound sound] Pause a sound*) + +val resume_sound : Sound.t -> unit +(** [resume_sound sound] Resume a paused sound*) + +val is_sound_playing : Sound.t -> bool +(** [is_sound_playing sound] Check if a sound is currently playing*) + +val set_sound_volume : Sound.t -> float -> unit +(** [set_sound_volume sound volume] Set volume for a sound (1.0 is max level)*) + +val set_sound_pitch : Sound.t -> float -> unit +(** [set_sound_pitch sound pitch] Set pitch for a sound (1.0 is base level)*) + +val set_sound_pan : Sound.t -> float -> unit +(** [set_sound_pan sound pan] Set pan for a sound (0.5 is center)*) + +val wave_copy : Wave.t -> Wave.t +(** [wave_copy wave] Copy a wave to a new wave*) + +val wave_crop : Wave.t ptr -> int -> int -> unit +(** [wave_crop wave init_sample final_sample] Crop a wave to defined samples range*) + +val wave_format : Wave.t ptr -> int -> int -> int -> unit +(** [wave_format wave sample_rate sample_size channels] Convert wave data to desired format*) + +val load_wave_samples : Wave.t -> float ptr +(** [load_wave_samples wave] Load samples data from wave as a 32bit float data array*) + +val unload_wave_samples : float ptr -> unit +(** [unload_wave_samples samples] Unload samples data loaded with LoadWaveSamples()*) + +val load_music_stream : string -> Music.t +(** [load_music_stream file_name] Load music stream from file*) + +val load_music_stream_from_memory : string -> string -> int -> Music.t +(** [load_music_stream_from_memory file_type data data_size] Load music stream from data*) + +val is_music_ready : Music.t -> bool +(** [is_music_ready music] Checks if a music stream is ready*) + +val unload_music_stream : Music.t -> unit +(** [unload_music_stream music] Unload music stream*) + +val play_music_stream : Music.t -> unit +(** [play_music_stream music] Start music playing*) + +val is_music_stream_playing : Music.t -> bool +(** [is_music_stream_playing music] Check if music is playing*) + +val update_music_stream : Music.t -> unit +(** [update_music_stream music] Updates buffers for music streaming*) + +val stop_music_stream : Music.t -> unit +(** [stop_music_stream music] Stop music playing*) + +val pause_music_stream : Music.t -> unit +(** [pause_music_stream music] Pause music playing*) + +val resume_music_stream : Music.t -> unit +(** [resume_music_stream music] Resume playing paused music*) + +val seek_music_stream : Music.t -> float -> unit +(** [seek_music_stream music position] Seek music to a position (in seconds)*) + +val set_music_volume : Music.t -> float -> unit +(** [set_music_volume music volume] Set volume for music (1.0 is max level)*) + +val set_music_pitch : Music.t -> float -> unit +(** [set_music_pitch music pitch] Set pitch for a music (1.0 is base level)*) + +val set_music_pan : Music.t -> float -> unit +(** [set_music_pan music pan] Set pan for a music (0.5 is center)*) + +val get_music_time_length : Music.t -> float +(** [get_music_time_length music] Get music time length (in seconds)*) + +val get_music_time_played : Music.t -> float +(** [get_music_time_played music] Get current music time played (in seconds)*) + +val load_audio_stream : int -> int -> int -> AudioStream.t +(** [load_audio_stream sample_rate sample_size channels] Load audio stream (to stream raw audio pcm data)*) + +(** {3 AudioStream management functions} *) + +val is_audio_stream_ready : AudioStream.t -> bool +(** [is_audio_stream_ready stream] Checks if an audio stream is ready*) + +val unload_audio_stream : AudioStream.t -> unit +(** [unload_audio_stream stream] Unload audio stream and free memory*) + +val update_audio_stream : AudioStream.t -> unit ptr -> int -> unit +(** [update_audio_stream stream data frame_count] Update audio stream buffers with data*) + +val is_audio_stream_processed : AudioStream.t -> bool +(** [is_audio_stream_processed stream] Check if any audio stream buffers requires refill*) + +val play_audio_stream : AudioStream.t -> unit +(** [play_audio_stream stream] Play audio stream*) + +val pause_audio_stream : AudioStream.t -> unit +(** [pause_audio_stream stream] Pause audio stream*) + +val resume_audio_stream : AudioStream.t -> unit +(** [resume_audio_stream stream] Resume audio stream*) + +val is_audio_stream_playing : AudioStream.t -> bool +(** [is_audio_stream_playing stream] Check if audio stream is playing*) + +val stop_audio_stream : AudioStream.t -> unit +(** [stop_audio_stream stream] Stop audio stream*) + +val set_audio_stream_volume : AudioStream.t -> float -> unit +(** [set_audio_stream_volume stream volume] Set volume for audio stream (1.0 is max level)*) + +val set_audio_stream_pitch : AudioStream.t -> float -> unit +(** [set_audio_stream_pitch stream pitch] Set pitch for audio stream (1.0 is base level)*) + +val set_audio_stream_pan : AudioStream.t -> float -> unit +(** [set_audio_stream_pan stream pan] Set pan for audio stream (0.5 is centered)*) + +val set_audio_stream_buffer_size_default : int -> unit +(** [set_audio_stream_buffer_size_default size] Default size for new audio streams*) diff --git a/src/raylib/ctypes_reexports.ml b/src/raylib/rcore/ctypes_reexports.ml similarity index 100% rename from src/raylib/ctypes_reexports.ml rename to src/raylib/rcore/ctypes_reexports.ml diff --git a/src/raylib/dune b/src/raylib/rcore/dune similarity index 100% rename from src/raylib/dune rename to src/raylib/rcore/dune diff --git a/src/raylib/functions.ml b/src/raylib/rcore/functions.ml similarity index 100% rename from src/raylib/functions.ml rename to src/raylib/rcore/functions.ml diff --git a/src/raylib/raylib.ml b/src/raylib/rcore/raylib.ml similarity index 77% rename from src/raylib/raylib.ml rename to src/raylib/rcore/raylib.ml index 520fb0c..d9d58d2 100644 --- a/src/raylib/raylib.ml +++ b/src/raylib/rcore/raylib.ml @@ -1,4 +1,3 @@ include Ctypes_reexports include Raylib_types include Functions -module Rlgl = Rlgl diff --git a/src/raylib/raylib.mli b/src/raylib/rcore/raylib.mli similarity index 91% rename from src/raylib/raylib.mli rename to src/raylib/rcore/raylib.mli index d552252..fb68064 100644 --- a/src/raylib/raylib.mli +++ b/src/raylib/rcore/raylib.mli @@ -1202,78 +1202,6 @@ module BoundingBox : sig val set_max : t -> Vector3.t -> unit end -module Wave : sig - type t' - type t = t' ctyp - - val t : t Ctypes.typ - - val sample_rate : t -> Unsigned.uint - (** Frequency (samples per second) *) - - val sample_size : t -> Unsigned.uint - (** Bit depth (bits per sample): 8, 16, 32 (24 not supported) *) - - val channels : t -> Unsigned.uint - (** Number of channels (1-mono, 2-stereo, ...) *) - - val set_sample_rate : t -> Unsigned.uint -> unit - val set_sample_size : t -> Unsigned.uint -> unit - val set_channels : t -> Unsigned.uint -> unit -end - -module AudioStream : sig - type t' - type t = t' ctyp - - val t : t Ctypes.typ - - val sample_rate : t -> Unsigned.uint - (** Frequency (samples per second) *) - - val sample_size : t -> Unsigned.uint - (** Bit depth (bits per sample): 8, 16, 32 (24 not supported) *) - - val channels : t -> Unsigned.uint - (** Number of channels (1-mono, 2-stereo, ...) *) - - val set_sample_rate : t -> Unsigned.uint -> unit - val set_sample_size : t -> Unsigned.uint -> unit - val set_channels : t -> Unsigned.uint -> unit -end - -module Sound : sig - type t' - type t = t' ctyp - - val t : t Ctypes.typ - - val stream : t -> AudioStream.t - (** Audio stream *) - - val set_stream : t -> AudioStream.t -> unit -end - -module Music : sig - type t' - type t = t' ctyp - - val t : t Ctypes.typ - - val stream : t -> AudioStream.t - (** Audio stream *) - - val looping : t -> bool - (** Music looping enable *) - - val ctx_type : t -> int - (** Type of music context (audio filetype) *) - - val set_stream : t -> AudioStream.t -> unit - val set_looping : t -> bool -> unit - val set_ctx_type : t -> int -> unit -end - module VrDeviceInfo : sig type t' type t = t' ctyp @@ -2937,195 +2865,3 @@ val get_ray_collision_triangle : val get_ray_collision_quad : Ray.t -> Vector3.t -> Vector3.t -> Vector3.t -> Vector3.t -> RayCollision.t (** [get_ray_collision_quad ray p1 p2 p3 p4] Get collision info between ray and quad*) - -(** {2 Audio Loading and Playing Functions (Module: audio)} *) - -(** {3 Audio device management functions} *) -val init_audio_device : unit -> unit -(** [init_audio_device ()] Initialize audio device and context*) - -val close_audio_device : unit -> unit -(** [close_audio_device ()] Close the audio device and context*) - -val is_audio_device_ready : unit -> bool -(** [is_audio_device_ready ()] Check if audio device has been initialized successfully*) - -val set_master_volume : float -> unit -(** [set_master_volume volume] Set master volume (listener)*) - -val get_master_volume : unit -> float -(** [get_master_volume ()] Get master volume (listener)*) - -val load_wave : string -> Wave.t -(** [load_wave file_name] Load wave data from file*) - -val load_wave_from_memory : string -> string -> int -> Wave.t -(** [load_wave_from_memory file_type file_data data_size] Load wave from memory buffer, fileType refers to extension: i.e. '.wav'*) - -val is_wave_ready : Wave.t -> bool -(** [is_wave_ready wave] Checks if wave data is ready*) - -val load_sound : string -> Sound.t -(** [load_sound file_name] Load sound from file*) - -val load_sound_from_wave : Wave.t -> Sound.t -(** [load_sound_from_wave wave] Load sound from wave data*) - -val load_sound_alias : Sound.t -> Sound.t -(** [load_sound_alias source] Create a new sound that shares the same sample data as the source sound, does not own the sound data*) - -val is_sound_ready : Sound.t -> bool -(** [is_sound_ready sound] Checks if a sound is ready*) - -val update_sound : Sound.t -> unit ptr -> int -> unit -(** [update_sound sound data sample_count] Update sound buffer with new data*) - -val unload_wave : Wave.t -> unit -(** [unload_wave wave] Unload wave data*) - -val unload_sound : Sound.t -> unit -(** [unload_sound sound] Unload sound*) - -val unload_sound_alias : Sound.t -> unit -(** [unload_sound_alias alias] Unload a sound alias (does not deallocate sample data)*) - -val export_wave : Wave.t -> string -> bool -(** [export_wave wave file_name] Export wave data to file, returns true on success*) - -val export_wave_as_code : Wave.t -> string -> bool -(** [export_wave_as_code wave file_name] Export wave sample data to code (.h), returns true on success*) - -(** {3 Wave/Sound management functions} *) - -val play_sound : Sound.t -> unit -(** [play_sound sound] Play a sound*) - -val stop_sound : Sound.t -> unit -(** [stop_sound sound] Stop playing a sound*) - -val pause_sound : Sound.t -> unit -(** [pause_sound sound] Pause a sound*) - -val resume_sound : Sound.t -> unit -(** [resume_sound sound] Resume a paused sound*) - -val is_sound_playing : Sound.t -> bool -(** [is_sound_playing sound] Check if a sound is currently playing*) - -val set_sound_volume : Sound.t -> float -> unit -(** [set_sound_volume sound volume] Set volume for a sound (1.0 is max level)*) - -val set_sound_pitch : Sound.t -> float -> unit -(** [set_sound_pitch sound pitch] Set pitch for a sound (1.0 is base level)*) - -val set_sound_pan : Sound.t -> float -> unit -(** [set_sound_pan sound pan] Set pan for a sound (0.5 is center)*) - -val wave_copy : Wave.t -> Wave.t -(** [wave_copy wave] Copy a wave to a new wave*) - -val wave_crop : Wave.t ptr -> int -> int -> unit -(** [wave_crop wave init_sample final_sample] Crop a wave to defined samples range*) - -val wave_format : Wave.t ptr -> int -> int -> int -> unit -(** [wave_format wave sample_rate sample_size channels] Convert wave data to desired format*) - -val load_wave_samples : Wave.t -> float ptr -(** [load_wave_samples wave] Load samples data from wave as a 32bit float data array*) - -val unload_wave_samples : float ptr -> unit -(** [unload_wave_samples samples] Unload samples data loaded with LoadWaveSamples()*) - -val load_music_stream : string -> Music.t -(** [load_music_stream file_name] Load music stream from file*) - -val load_music_stream_from_memory : string -> string -> int -> Music.t -(** [load_music_stream_from_memory file_type data data_size] Load music stream from data*) - -val is_music_ready : Music.t -> bool -(** [is_music_ready music] Checks if a music stream is ready*) - -val unload_music_stream : Music.t -> unit -(** [unload_music_stream music] Unload music stream*) - -val play_music_stream : Music.t -> unit -(** [play_music_stream music] Start music playing*) - -val is_music_stream_playing : Music.t -> bool -(** [is_music_stream_playing music] Check if music is playing*) - -val update_music_stream : Music.t -> unit -(** [update_music_stream music] Updates buffers for music streaming*) - -val stop_music_stream : Music.t -> unit -(** [stop_music_stream music] Stop music playing*) - -val pause_music_stream : Music.t -> unit -(** [pause_music_stream music] Pause music playing*) - -val resume_music_stream : Music.t -> unit -(** [resume_music_stream music] Resume playing paused music*) - -val seek_music_stream : Music.t -> float -> unit -(** [seek_music_stream music position] Seek music to a position (in seconds)*) - -val set_music_volume : Music.t -> float -> unit -(** [set_music_volume music volume] Set volume for music (1.0 is max level)*) - -val set_music_pitch : Music.t -> float -> unit -(** [set_music_pitch music pitch] Set pitch for a music (1.0 is base level)*) - -val set_music_pan : Music.t -> float -> unit -(** [set_music_pan music pan] Set pan for a music (0.5 is center)*) - -val get_music_time_length : Music.t -> float -(** [get_music_time_length music] Get music time length (in seconds)*) - -val get_music_time_played : Music.t -> float -(** [get_music_time_played music] Get current music time played (in seconds)*) - -val load_audio_stream : int -> int -> int -> AudioStream.t -(** [load_audio_stream sample_rate sample_size channels] Load audio stream (to stream raw audio pcm data)*) - -(** {3 AudioStream management functions} *) - -val is_audio_stream_ready : AudioStream.t -> bool -(** [is_audio_stream_ready stream] Checks if an audio stream is ready*) - -val unload_audio_stream : AudioStream.t -> unit -(** [unload_audio_stream stream] Unload audio stream and free memory*) - -val update_audio_stream : AudioStream.t -> unit ptr -> int -> unit -(** [update_audio_stream stream data frame_count] Update audio stream buffers with data*) - -val is_audio_stream_processed : AudioStream.t -> bool -(** [is_audio_stream_processed stream] Check if any audio stream buffers requires refill*) - -val play_audio_stream : AudioStream.t -> unit -(** [play_audio_stream stream] Play audio stream*) - -val pause_audio_stream : AudioStream.t -> unit -(** [pause_audio_stream stream] Pause audio stream*) - -val resume_audio_stream : AudioStream.t -> unit -(** [resume_audio_stream stream] Resume audio stream*) - -val is_audio_stream_playing : AudioStream.t -> bool -(** [is_audio_stream_playing stream] Check if audio stream is playing*) - -val stop_audio_stream : AudioStream.t -> unit -(** [stop_audio_stream stream] Stop audio stream*) - -val set_audio_stream_volume : AudioStream.t -> float -> unit -(** [set_audio_stream_volume stream volume] Set volume for audio stream (1.0 is max level)*) - -val set_audio_stream_pitch : AudioStream.t -> float -> unit -(** [set_audio_stream_pitch stream pitch] Set pitch for audio stream (1.0 is base level)*) - -val set_audio_stream_pan : AudioStream.t -> float -> unit -(** [set_audio_stream_pan stream pan] Set pan for audio stream (0.5 is centered)*) - -val set_audio_stream_buffer_size_default : int -> unit -(** [set_audio_stream_buffer_size_default size] Default size for new audio streams*) - -module Rlgl = Rlgl diff --git a/src/raylib/raylib_types.ml b/src/raylib/rcore/raylib_types.ml similarity index 94% rename from src/raylib/raylib_types.ml rename to src/raylib/rcore/raylib_types.ml index 4f68039..c2ec789 100644 --- a/src/raylib/raylib_types.ml +++ b/src/raylib/rcore/raylib_types.ml @@ -737,60 +737,6 @@ module BoundingBox = struct let set_max boundingbox max = setf boundingbox BoundingBox.max max end -module Wave = struct - type t' = Wave.t - type t = t' ctyp - - let t = Wave.t - let sample_rate wave = getf wave Wave.sample_rate - let sample_size wave = getf wave Wave.sample_size - let channels wave = getf wave Wave.channels - let set_sample_rate wave sample_rate = setf wave Wave.sample_rate sample_rate - let set_sample_size wave sample_size = setf wave Wave.sample_size sample_size - let set_channels wave channels = setf wave Wave.channels channels -end - -module AudioStream = struct - type t' = AudioStream.t - type t = t' ctyp - - let t = AudioStream.t - let sample_rate audiostream = getf audiostream AudioStream.sample_rate - let sample_size audiostream = getf audiostream AudioStream.sample_size - let channels audiostream = getf audiostream AudioStream.channels - - let set_sample_rate audiostream sample_rate = - setf audiostream AudioStream.sample_rate sample_rate - - let set_sample_size audiostream sample_size = - setf audiostream AudioStream.sample_size sample_size - - let set_channels audiostream channels = - setf audiostream AudioStream.channels channels -end - -module Sound = struct - type t' = Sound.t - type t = t' ctyp - - let t = Sound.t - let stream sound = getf sound Sound.stream - let set_stream sound stream = setf sound Sound.stream stream -end - -module Music = struct - type t' = Music.t - type t = t' ctyp - - let t = Music.t - let stream music = getf music Music.stream - let looping music = getf music Music.looping - let ctx_type music = getf music Music.ctx_type - let set_stream music stream = setf music Music.stream stream - let set_looping music looping = setf music Music.looping looping - let set_ctx_type music ctx_type = setf music Music.ctx_type ctx_type -end - module VrDeviceInfo = struct type t' = VrDeviceInfo.t type t = t' ctyp diff --git a/src/raylib/rlgl.ml b/src/raylib/rlgl.ml deleted file mode 100644 index dbd6a32..0000000 --- a/src/raylib/rlgl.ml +++ /dev/null @@ -1,2 +0,0 @@ -include Raylib_rlgl.Description (Raylib_c.Raylib_c_generated_rlgl) -include Rlgl_types diff --git a/src/raylib/rlgl/dune b/src/raylib/rlgl/dune new file mode 100644 index 0000000..2604342 --- /dev/null +++ b/src/raylib/rlgl/dune @@ -0,0 +1,4 @@ +(library + (name rlgl) + (public_name raylib-rlgl) + (libraries raylib raylib_rlgl_c)) diff --git a/src/raylib/rlgl/rlgl.ml b/src/raylib/rlgl/rlgl.ml new file mode 100644 index 0000000..69f0f15 --- /dev/null +++ b/src/raylib/rlgl/rlgl.ml @@ -0,0 +1,2 @@ +include Raylib_rlgl.Description (Raylib_rlgl_c.Raylib_c_generated_rlgl) +include Rlgl_types diff --git a/src/raylib/rlgl.mli b/src/raylib/rlgl/rlgl.mli similarity index 89% rename from src/raylib/rlgl.mli rename to src/raylib/rlgl/rlgl.mli index 9c5c134..611b3a2 100644 --- a/src/raylib/rlgl.mli +++ b/src/raylib/rlgl/rlgl.mli @@ -136,22 +136,17 @@ val unload_shader_program : Unsigned.uint -> unit val get_location_uniform : Unsigned.uint -> string -> int val get_location_attrib : Unsigned.uint -> string -> int val set_uniform : int -> unit Ctypes.ptr -> int -> int -> unit -val set_uniform_matrix : int -> Raylib_types.Matrix.t -> unit +val set_uniform_matrix : int -> Raylib.Matrix.t -> unit val set_uniform_sampler : int -> Unsigned.uint -> unit val set_shader : Unsigned.uint -> int Ctypes.ptr -> unit -val get_matrix_modelview : unit -> Raylib_types.Matrix.t -val get_matrix_projection : unit -> Raylib_types.Matrix.t -val get_matrix_transform : unit -> Raylib_types.Matrix.t -val get_matrix_projection_stereo : int -> Raylib_types.Matrix.t -val get_matrix_view_offset_stereo : int -> Raylib_types.Matrix.t -val set_matrix_projection : Raylib_types.Matrix.t -> unit -val set_matrix_modelview : Raylib_types.Matrix.t -> unit - -val set_matrix_projection_stereo : - Raylib_types.Matrix.t -> Raylib_types.Matrix.t -> unit - -val set_matrix_view_offset_stereo : - Raylib_types.Matrix.t -> Raylib_types.Matrix.t -> unit - +val get_matrix_modelview : unit -> Raylib.Matrix.t +val get_matrix_projection : unit -> Raylib.Matrix.t +val get_matrix_transform : unit -> Raylib.Matrix.t +val get_matrix_projection_stereo : int -> Raylib.Matrix.t +val get_matrix_view_offset_stereo : int -> Raylib.Matrix.t +val set_matrix_projection : Raylib.Matrix.t -> unit +val set_matrix_modelview : Raylib.Matrix.t -> unit +val set_matrix_projection_stereo : Raylib.Matrix.t -> Raylib.Matrix.t -> unit +val set_matrix_view_offset_stereo : Raylib.Matrix.t -> Raylib.Matrix.t -> unit val load_draw_cube : unit -> unit val load_draw_quad : unit -> unit diff --git a/src/raylib/rlgl_types.ml b/src/raylib/rlgl/rlgl_types.ml similarity index 75% rename from src/raylib/rlgl_types.ml rename to src/raylib/rlgl/rlgl_types.ml index 07a63a4..18a1793 100644 --- a/src/raylib/rlgl_types.ml +++ b/src/raylib/rlgl/rlgl_types.ml @@ -1,17 +1,16 @@ module Types = Rlgl_generated_types -open Ctypes_reexports module RlVertexBuffer = struct type t' = Types.RlVertexBuffer.t - type t = t' ctyp + type t = t' Raylib.ctyp end module RlDrawCall = struct type t' = Types.RlDrawCall.t - type t = t' ctyp + type t = t' Raylib.ctyp end module RlRenderBatch = struct type t' = Types.RlRenderBatch.t - type t = t' ctyp + type t = t' Raylib.ctyp end