aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/window.adb74
-rw-r--r--install.sh7
-rw-r--r--raylib.ads6
3 files changed, 69 insertions, 18 deletions
diff --git a/example/window.adb b/example/window.adb
index 52f6c17..2c0abdf 100644
--- a/example/window.adb
+++ b/example/window.adb
@@ -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;
diff --git a/install.sh b/install.sh
index 0774358..355b710 100644
--- a/install.sh
+++ b/install.sh
@@ -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
diff --git a/raylib.ads b/raylib.ads
index f034a28..54bbbbc 100644
--- a/raylib.ads
+++ b/raylib.ads
@@ -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,