2024-04-23 10:00:40 -04:00
|
|
|
with Raylib; -- File path specified in 'install.sh' script.
|
|
|
|
use Raylib; -- I agree with raysan5 on namespaces being boring.
|
2024-04-23 08:59:03 -04:00
|
|
|
|
|
|
|
procedure Window is
|
2024-04-23 10:00:40 -04:00
|
|
|
|
|
|
|
-- 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;
|
|
|
|
|
2024-04-23 08:59:03 -04:00
|
|
|
begin
|
2024-04-23 10:00:40 -04:00
|
|
|
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;
|
2024-04-23 08:59:03 -04:00
|
|
|
end Window;
|