lace_gel_0.1.0_2c333035/applet/demo/distributed/gel_demo_client.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
with
     gel_demo_Services,
     gel_demo_Server,

     gel.Applet.client_World,

     gel.Forge,
     gel.Camera,

     ada.Calendar,
     ada.Text_IO,
     ada.Exceptions;


package body gel_demo_Client
is
   use ada.Text_IO;


   task body Item
   is
      use type ada.Calendar.Time;

      the_Applet       : gel.Applet.client_World.view;
      next_render_Time : ada.calendar.Time;

   begin
      accept start;

      the_Applet := gel.Forge.new_client_Applet ("distributed Demo ~ Client", 1920, 1200);

      -- Register the client world as a mirror of the server world.
      --
      the_Applet.client_World.is_a_Mirror (of_World           => gel_demo_Services.World);
      gel_demo_Services.World.register    (the_Mirror         => the_Applet.client_World.all'Access,
                                           Mirror_as_observer => the_Applet.client_World.all'Access);

      --  Setup.
      --
      the_Applet.client_Camera.Site_is ((0.0, 0.0, 20.0));
      the_Applet.enable_simple_Dolly (1);

      next_render_Time := ada.Calendar.clock;

      --  Begin processing.
      --
      while the_Applet.is_open
      loop
         the_Applet.freshen;

         next_render_Time := next_render_Time + 1.0/60.0;
         delay until next_render_Time;
      end loop;

      --  Close.
      --
      gel_demo_services.World.deregister (the_mirror => the_Applet.client_World.all'access);
      the_Applet.destroy;
      gel_demo_Server.item.stop;

      put_Line ("Client done.");


   exception
      when E : others =>
         put_Line ("Client unhandled exception ...");
         put_Line (ada.exceptions.Exception_Information (E));
         put_Line ("Client has terminated !");
   end Item;


end gel_demo_Client;