Explaining examples and utter install script cancer...
This commit is contained in:
parent
fba5a57989
commit
cffe810f43
@ -1,19 +1,63 @@
|
|||||||
with Raylib;
|
with Raylib; -- File path specified in 'install.sh' script.
|
||||||
use Raylib;
|
use Raylib; -- I agree with raysan5 on namespaces being boring.
|
||||||
|
|
||||||
procedure Window is
|
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
|
begin
|
||||||
Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0));
|
Open_Window (720, 360, "Heyo Raylib!" & Character'Val (0));
|
||||||
--
|
--
|
||||||
Main_Loop: loop
|
-- You can have main loop in several ways, choose what you like:
|
||||||
exit when Window_Should_Close;
|
-- - Foo: loop ... exit when ... end loop Foo;
|
||||||
--
|
-- - loop ... exit when ... end loop;
|
||||||
Begin_Drawing;
|
-- - while (not) ... loop (exit when ...) ... end loop;
|
||||||
Clear_Background (Ray_White);
|
--
|
||||||
Draw_Text ("Heyo Raylib, greetings from Ada!" & Character'Val (0), 4, 4, 32, Black);
|
Main_Loop: loop
|
||||||
Draw_Text ("Press Escape key to exit program." & Character'Val (0), 4, 36, 32, Black);
|
exit when Window_Should_Close;
|
||||||
End_Drawing;
|
--
|
||||||
end loop Main_Loop;
|
Begin_Drawing;
|
||||||
--
|
Clear_Background (Ray_White);
|
||||||
Close_Window;
|
-- 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;
|
end Window;
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
set -xe
|
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
|
cp raylib.ads /usr/lib/gcc/x86_64-linux-gnu/8/adainclude/raylib.ads
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
@ -3884,7 +3884,7 @@ package Raylib is
|
|||||||
X : Integer := 0;
|
X : Integer := 0;
|
||||||
Y : Integer := 0;
|
Y : Integer := 0;
|
||||||
Size : Integer := 32;
|
Size : Integer := 32;
|
||||||
Tint : Color := White
|
Tint : Color := Black
|
||||||
) with
|
) with
|
||||||
Import => True,
|
Import => True,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
@ -3896,7 +3896,7 @@ package Raylib is
|
|||||||
Position : Vector_2D := (others => 0.0);
|
Position : Vector_2D := (others => 0.0);
|
||||||
Font_Size : Float := 0.0;
|
Font_Size : Float := 0.0;
|
||||||
Spacing : Float := 0.0;
|
Spacing : Float := 0.0;
|
||||||
Tint : Color := White
|
Tint : Color := Black
|
||||||
) with
|
) with
|
||||||
Import => True,
|
Import => True,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
@ -3910,7 +3910,7 @@ package Raylib is
|
|||||||
Rotation : Float := 0.0;
|
Rotation : Float := 0.0;
|
||||||
Font_Size : Float := 0.0;
|
Font_Size : Float := 0.0;
|
||||||
Spacing : Float := 0.0;
|
Spacing : Float := 0.0;
|
||||||
Tint : Color := White
|
Tint : Color := Black
|
||||||
) with
|
) with
|
||||||
Import => True,
|
Import => True,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
|
Loading…
Reference in New Issue
Block a user