diff --git a/.ocamlformat b/.ocamlformat index 8b13789..0b457a3 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1 +1,2 @@ - +profile = default +version = 0.26.2 diff --git a/examples/audio/audio_module_playing.ml b/examples/audio/audio_module_playing.ml index 6b8465f..51078e3 100644 --- a/examples/audio/audio_module_playing.ml +++ b/examples/audio/audio_module_playing.ml @@ -98,7 +98,7 @@ let rec loop circles music pause = circles.(i) <- (if alpha <= 0.0 then random_circle () - else { circle with alpha; speed; radius }))) + else { circle with alpha; speed; radius }))) circles; begin_drawing (); diff --git a/examples/core/core_2d_camera.ml b/examples/core/core_2d_camera.ml index 92e8fea..dcee8de 100644 --- a/examples/core/core_2d_camera.ml +++ b/examples/core/core_2d_camera.ml @@ -41,8 +41,8 @@ let rec loop (player, buildings, colors, camera) = | false -> let open Raylib in (if is_key_down Key.Right then Rectangle.(set_x player (x player +. 2.0)) - else if is_key_down Key.Left then - Rectangle.(set_x player (x player -. 2.0))); + else if is_key_down Key.Left then + Rectangle.(set_x player (x player -. 2.0))); Camera2D.set_target camera (Vector2.create @@ -50,16 +50,17 @@ let rec loop (player, buildings, colors, camera) = (Rectangle.y player +. 20.0)); (if is_key_down Key.A then - Camera2D.( - set_rotation camera (Float.max (-40.0) (rotation camera -. 1.0))) - else if is_key_down Key.S then - Camera2D.(set_rotation camera (Float.min 40.0 (rotation camera +. 1.0)))); + Camera2D.( + set_rotation camera (Float.max (-40.0) (rotation camera -. 1.0))) + else if is_key_down Key.S then + Camera2D.( + set_rotation camera (Float.min 40.0 (rotation camera +. 1.0)))); Camera2D.( set_zoom camera (zoom camera +. (get_mouse_wheel_move () *. 0.05))); (if Camera2D.zoom camera > 3.0 then Camera2D.(set_zoom camera 3.0) - else if Camera2D.zoom camera < 0.1 then Camera2D.(set_zoom camera 0.1)); + else if Camera2D.zoom camera < 0.1 then Camera2D.(set_zoom camera 0.1)); if is_key_pressed Key.R then ( Camera2D.( diff --git a/examples/shapes/shapes_collision_area.ml b/examples/shapes/shapes_collision_area.ml index eb0757c..3776e82 100644 --- a/examples/shapes/shapes_collision_area.ml +++ b/examples/shapes/shapes_collision_area.ml @@ -47,19 +47,20 @@ let rec loop (pause, box_a, box_a_speed_x, box_b, box_collision) = (* Make sure Box B does not go out of move area limits *) (if - Rectangle.(x box_b +. width box_b >= Float.of_int (get_screen_width ())) - then - Rectangle.( - set_x box_b (Float.of_int (get_screen_width ()) -. width box_b)) - else if Rectangle.(x box_b <= 0.0) then Rectangle.(set_x box_b 0.0)); + Rectangle.( + x box_b +. width box_b >= Float.of_int (get_screen_width ())) + then + Rectangle.( + set_x box_b (Float.of_int (get_screen_width ()) -. width box_b)) + else if Rectangle.(x box_b <= 0.0) then Rectangle.(set_x box_b 0.0)); (if - Rectangle.( - y box_b +. height box_b >= Float.of_int (get_screen_height ())) - then - Rectangle.( - set_y box_b (Float.of_int (get_screen_height ()) -. height box_b)) - else if Rectangle.(y box_b <= screen_upper_limit) then - Rectangle.(set_y box_b screen_upper_limit)); + Rectangle.( + y box_b +. height box_b >= Float.of_int (get_screen_height ())) + then + Rectangle.( + set_y box_b (Float.of_int (get_screen_height ()) -. height box_b)) + else if Rectangle.(y box_b <= screen_upper_limit) then + Rectangle.(set_y box_b screen_upper_limit)); (* Check boxes collision *) let collision = check_collision_recs box_a box_b in diff --git a/examples/text/text_font_filters.ml b/examples/text/text_font_filters.ml index 5b1c8d9..07a5c17 100644 --- a/examples/text/text_font_filters.ml +++ b/examples/text/text_font_filters.ml @@ -41,9 +41,9 @@ let rec loop font font_size font_position filter = let text_size = measure_text_ex font msg (Float.of_int font_size) 0.0 in (if is_key_down Key.Left then - Vector2.(set_x font_position (x font_position -. 10.0)) - else if is_key_down Key.Right then - Vector2.(set_x font_position (x font_position +. 10.0))); + Vector2.(set_x font_position (x font_position -. 10.0)) + else if is_key_down Key.Right then + Vector2.(set_x font_position (x font_position +. 10.0))); let font = if is_file_dropped () then ( diff --git a/examples/textures/textures_bunnymark.ml b/examples/textures/textures_bunnymark.ml index a5d40ca..0294029 100644 --- a/examples/textures/textures_bunnymark.ml +++ b/examples/textures/textures_bunnymark.ml @@ -55,11 +55,11 @@ let rec loop bunnies bunnies_count tex_bunny = V.(set_x b.position (x b.position +. x b.speed)); V.(set_y b.position (y b.position +. y b.speed)); (if - V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0) - > Float.of_int (get_screen_width ()) - || V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0) - < 0.0 - then V.(set_x b.speed (x b.speed *. -1.0))); + V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0) + > Float.of_int (get_screen_width ()) + || V.x b.position +. (Float.of_int (Texture.width tex_bunny) /. 2.0) + < 0.0 + then V.(set_x b.speed (x b.speed *. -1.0))); if V.y b.position +. (Float.of_int (Texture.height tex_bunny) /. 2.0) > Float.of_int (get_screen_height ()) diff --git a/src/c/functions/raylib_functions.ml b/src/c/functions/raylib_functions.ml index 71b4a01..8d961ab 100644 --- a/src/c/functions/raylib_functions.ml +++ b/src/c/functions/raylib_functions.ml @@ -218,10 +218,16 @@ module Description (F : Ctypes.FOREIGN) = struct foreign "UnloadRandomSequence" (ptr int @-> returning void) let take_screenshot = foreign "TakeScreenshot" (string @-> returning void) - let set_config_flags = foreign "SetConfigFlags" (ConfigFlags.t_bitmask @-> returning void) + + let set_config_flags = + foreign "SetConfigFlags" (ConfigFlags.t_bitmask @-> returning void) + let open_url = foreign "OpenURL" (string @-> returning void) let trace_log = foreign "TraceLog" (int @-> string @-> returning void) - let set_trace_log_level = foreign "SetTraceLogLevel" (TraceLogLevel.t @-> returning void) + + let set_trace_log_level = + foreign "SetTraceLogLevel" (TraceLogLevel.t @-> returning void) + let mem_alloc = foreign "MemAlloc" (int @-> returning (ptr void)) let mem_realloc = diff --git a/src/util/raylib_gen.ml b/src/util/raylib_gen.ml index c811f1a..4ec7989 100644 --- a/src/util/raylib_gen.ml +++ b/src/util/raylib_gen.ml @@ -88,11 +88,11 @@ module Enum = struct let nm = enum.name.name in Printf.sprintf "module %s = struct\n include %s\n\n" nm nm ^ (if enum.bitmask then - Printf.sprintf - " let t_bitmask = build_enum_bitmask \"%s\" Ctypes.int64_t \ - ~typedef:true vals\n\n" - nm - else "") + Printf.sprintf + " let t_bitmask = build_enum_bitmask \"%s\" Ctypes.int64_t \ + ~typedef:true vals\n\n" + nm + else "") ^ " let to_int x = Unsigned.UInt32.to_int Ctypes.(coerce t uint32_t x)\n" ^ " let of_int i = Ctypes.(coerce uint32_t t (Unsigned.UInt32.of_int i))\n\ end\n\n"