Add initial prototype.

This commit is contained in:
Rod Kay
2022-07-31 17:34:54 +10:00
commit 54a53b2ac0
1421 changed files with 358874 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
with
ada.Text_IO;
package body openGL.Dolly
is
procedure Speed_is (Self : in out Item; Now : in Real)
is
begin
Self.Speed := Now;
end Speed_is;
procedure evolve (Self : in out Item)
is
use linear_Algebra_3d,
ada.Text_IO;
Command : Character;
Avail : Boolean;
begin
get_Immediate (Command, Avail);
if Avail
then
case Command
is
when 'q' => Self.quit_Requested := True;
-- Linear Motion.
--
when 'a' => Self.Camera.Site_is (Self.Camera.Site - right_Direction (Self.Camera.Spin) * Self.Speed);
when 's' => Self.Camera.Site_is (Self.Camera.Site + right_Direction (Self.Camera.Spin) * Self.Speed);
when 'w' => Self.Camera.Site_is (Self.Camera.Site - forward_Direction (Self.Camera.Spin) * Self.Speed);
when 'z' => Self.Camera.Site_is (Self.Camera.Site + forward_Direction (Self.Camera.Spin) * Self.Speed);
when 'e' => Self.Camera.Site_is (Self.Camera.Site + up_Direction (Self.Camera.Spin) * Self.Speed);
when 'd' => Self.Camera.Site_is (Self.Camera.Site - up_Direction (Self.Camera.Spin) * Self.Speed);
-- Orbital motion.
--
when 'A' => Self.Camera.Site_is (Self.Camera.Site * y_Rotation_from (to_Radians (-5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * y_Rotation_from (to_Radians (-5.0)));
when 'S' => Self.Camera.Site_is (Self.Camera.Site * y_Rotation_from (to_Radians ( 5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * y_Rotation_from (to_Radians ( 5.0)));
when 'E' => Self.Camera.Site_is (Self.Camera.Site * x_Rotation_from (to_Radians (-5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * x_Rotation_from (to_Radians (-5.0)));
when 'D' => Self.Camera.Site_is (Self.Camera.Site * x_Rotation_from (to_Radians ( 5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * x_Rotation_from (to_Radians ( 5.0)));
when 'W' => Self.Camera.Site_is (Self.Camera.Site * z_Rotation_from (to_Radians (-5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * z_Rotation_from (to_Radians (-5.0)));
when 'Z' => Self.Camera.Site_is (Self.Camera.Site * z_Rotation_from (to_Radians ( 5.0)));
Self.Camera.Spin_is (Self.Camera.Spin * z_Rotation_from (to_Radians ( 5.0)));
when others => null;
end case;
Self.last_Character := Command;
end if;
end evolve;
function quit_Requested (Self : in Item) return Boolean
is
begin
return Self.quit_Requested;
end quit_Requested;
procedure get_last_Character (Self : in out Item; the_Character : out Character;
Available : out Boolean)
is
use ada.Characters;
begin
if Self.last_Character = latin_1.NUL
then
Available := False;
else
Available := True;
the_Character := Self.last_Character;
Self.last_Character := latin_1.NUL;
end if;
end get_last_Character;
end openGL.Dolly;

View File

@@ -0,0 +1,31 @@
with
openGL.Camera,
ada.Characters.latin_1;
package openGL.Dolly
--
-- A utility which moves a camera via the keyboard.
--
is
type Item (Camera : openGL.Camera.view) is tagged private;
procedure Speed_is (Self : in out Item; Now : in Real);
procedure evolve (Self : in out Item);
function quit_Requested (Self : in Item) return Boolean;
procedure get_last_Character (Self : in out Item; the_Character : out Character;
Available : out Boolean);
private
type Item (Camera : openGL.Camera.view) is tagged
record
quit_Requested : Boolean := False;
last_Character : Character := ada.Characters.Latin_1.NUL;
Speed : Real := 1.0;
end record;
end openGL.Dolly;

View File

@@ -0,0 +1,25 @@
with
ada.Text_IO;
package body openGL.frame_Counter
is
procedure increment (Self : in out Item)
is
use ada.Text_IO;
use type ada.Calendar.Time;
begin
if ada.Calendar.Clock >= Self.next_FPS_Time
then
put_Line ("FPS:" & Integer'Image (Self.frame_Count));
Self.next_FPS_Time := Self.next_FPS_Time + 1.0;
Self.frame_Count := 0;
else
Self.frame_Count := Self.frame_Count + 1;
end if;
end increment;
end openGL.frame_Counter;

View File

@@ -0,0 +1,24 @@
private
with
ada.Calendar;
package openGL.frame_Counter
--
-- A utility which reports frames per second.
--
is
type Item is tagged private;
procedure increment (Self : in out Item);
private
type Item is tagged
record
frame_Count : Natural := 0;
next_FPS_Time : ada.Calendar.Time := ada.Calendar.Clock;
end record;
end openGL.frame_Counter;