]> git.xolatile.top Git - xolatile-raylib-ada.git/commitdiff
Explaining examples and utter install script cancer...
authorxolatile <xolatile@proton.me>
Tue, 23 Apr 2024 14:00:40 +0000 (10:00 -0400)
committerxolatile <xolatile@proton.me>
Tue, 23 Apr 2024 14:00:40 +0000 (10:00 -0400)
example/window.adb
install.sh
raylib.ads

index 52f6c17ac30c262b5e751468e8c20513e6ae69d4..2c0abdf2437cafe73ba2b53d9a323b2c59c87691 100644 (file)
@@ -1,19 +1,63 @@
-with Raylib;
-use  Raylib;
+with Raylib; -- File path specified in 'install.sh' script.
+use  Raylib; -- I agree with raysan5 on namespaces being boring.
 
 procedure Window is
+
+   -- This is not Ada tutorial, but brief explanation of my bindings.
+   -- This is not my usual style of programming, following conventions.
+   --
+   -- C uses null terminated strings, while Ada does not, hence:
+   -- - "Foo" & Character'Val (0)
+   -- - "Bar" & ASCII.NUL
+   -- - To_C_String ("Baz")
+   --
+   -- This decision was made intentionally to avoid package body.
+   -- If your project uses 10-40 functions and 5-10 structures:
+   -- - Write your own bindings, it's simple and bloat-free.
+   -- - Use someone elses Ada bindings, or run command:
+   -- - $ gcc -c -fdump-ada-spec -C /usr/include/raylib.h
+   --
+   -- I don't like to use Interfaces.C package unless I have to...
+
+   function To_C_String ( -- I find this better than Interfaces.C.To_C.
+      Data : String := "" -- Concatenate this however you like...
+   ) return String is     -- Or simply use GCC generated bindings.
+   begin
+      return (Data & Character'Val (0)); -- This null terminates string.
+   end To_C_String;
+
 begin
-       Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0));
-       --
-       Main_Loop: loop
-               exit when Window_Should_Close;
-               --
-               Begin_Drawing;
-               Clear_Background (Ray_White);
-               Draw_Text ("Heyo Raylib, greetings from Ada!"  & Character'Val (0), 4,  4, 32, Black);
-               Draw_Text ("Press Escape key to exit program." & Character'Val (0), 4, 36, 32, Black);
-               End_Drawing;
-       end loop Main_Loop;
-       --
-       Close_Window;
+   Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0));
+   --
+   -- You can have main loop in several ways, choose what you like:
+   -- - Foo: loop ... exit when ... end loop Foo;
+   -- - loop ... exit when ... end loop;
+   -- - while (not) ... loop (exit when ...) ... end loop;
+   --
+   Main_Loop: loop
+      exit when Window_Should_Close;
+      --
+      Begin_Drawing;
+      Clear_Background (Ray_White);
+      -- You can specify all arguments, or use defaults after one point.
+      Draw_Text ("Heyo from Ada." & ASCII.NUL, 4,  4, 32, Black);
+      -- You can explicitly state all arguments and their values.
+      Draw_Text (
+         Text => To_C_String ("Press Escape key to exit program."),
+         X    => 4,
+         Y    => 36,
+         Size => 32,
+         Tint => Black
+      );
+      -- Or at last, you can specify which arguments won't be defaults.
+      Draw_Text (
+         Text => To_C_String ("You can ignore some arguments."),
+         X    => 4,
+         Y    => 68
+      );
+      -- And naturally, you can align them however you like...
+      End_Drawing;
+   end loop Main_Loop;
+   --
+   Close_Window;
 end Window;
index 077435861c9d8ad27f74de524a5f7077e3bb0319..355b710f262bddc90e658284e2a67df76faa050b 100644 (file)
@@ -2,6 +2,13 @@
 
 set -xe
 
+# Find your own file path for this, I rely on GCC and GNAT:
+# $ gcc -print-libgcc-file-name
+# Run the command above to get the following output:
+# /usr/lib/gcc/x86_64-linux-gnu/8/libgcc.a
+# Then, add 'adainclude' and file name to the file path.
+# Sorry, I don't know a better way to do this...
+
 cp raylib.ads /usr/lib/gcc/x86_64-linux-gnu/8/adainclude/raylib.ads
 
 exit
index f034a284e02af87f5e0e20e15203b152c38e2503..54bbbbc12046f82cc61f957542fdd0fe00018918 100644 (file)
@@ -3884,7 +3884,7 @@ package Raylib is
       X    : Integer := 0;
       Y    : Integer := 0;
       Size : Integer := 32;
-      Tint : Color   := White
+      Tint : Color   := Black
    ) with
       Import        => True,
       Convention    => C,
@@ -3896,7 +3896,7 @@ package Raylib is
       Position  : Vector_2D := (others => 0.0);
       Font_Size : Float     := 0.0;
       Spacing   : Float     := 0.0;
-      Tint      : Color     := White
+      Tint      : Color     := Black
    ) with
       Import        => True,
       Convention    => C,
@@ -3910,7 +3910,7 @@ package Raylib is
       Rotation  : Float     := 0.0;
       Font_Size : Float     := 0.0;
       Spacing   : Float     := 0.0;
-      Tint      : Color     := White
+      Tint      : Color     := Black
    ) with
       Import        => True,
       Convention    => C,