lace_opengl_0.1.0_672a6415/source/lean/io/opengl-io.ads

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
with
     openGL.Texture,

     ada.Strings.unbounded,
     ada.Streams.Stream_IO,
     ada.unchecked_Deallocation;

package openGL.IO
--
--  Provides I/O functions for openGL.
--
is
   subtype Text is ada.Strings.unbounded.unbounded_String;


   ------------------
   --  General Vertex
   --

   null_Id : constant long_Index_t;

   type Vertex is
      record
         site_Id,
         coord_Id,
         normal_Id,
         weights_Id : long_Index_t;
   end record;

   type Vertices      is array (long_Index_t range <>) of aliased Vertex;
   type Vertices_view is access all Vertices;


   --------
   --  Face
   --

   type facet_Kind is (Triangle, Quad, Polygon);

   type Face (Kind : facet_Kind := Triangle) is
      record
         case Kind
         is
         when Triangle => Tri  : Vertices (1 .. 3);
         when Quad     => Quad : Vertices (1 .. 4);
         when Polygon  => Poly : Vertices_view;
         end case;
      end record;

   type Faces is array (long_Index_t range <>) of Face;


   procedure destroy       (Self : in out Face);
   function  Vertices_of   (Self : in     Face) return Vertices;

   procedure set_Vertex_in (Self : in out Face;   Which : in long_Index_t;
                                                  To    : in Vertex);

   --------------------
   --  Rigging/Skinning
   --

   type bone_Id is range 0 .. 200;

   type bone_Weight is
      record
         Bone   : bone_Id;
         Weight : Real;
      end record;

   type bone_Weights       is array (long_Index_t range <>) of bone_Weight;
   type bone_Weights_view  is access bone_Weights;
   type bone_Weights_array is array (long_Index_t range <>) of bone_Weights_view;


   ---------
   --  Views
   --

   type              Sites_view is access all openGL.many_Sites;
   type             Coords_view is access all openGL.many_Coordinates_2D;
   type            Normals_view is access all openGL.many_Normals;
   type bone_Weights_array_view is access all bone_Weights_array;
   type              Faces_view is access all IO.Faces;

   procedure free is new ada.unchecked_Deallocation (many_Sites,          IO.Sites_view);
   procedure free is new ada.unchecked_Deallocation (many_Coordinates_2D, IO.Coords_view);
   procedure free is new ada.unchecked_Deallocation (many_Normals,        IO.Normals_view);
   procedure free is new ada.unchecked_Deallocation (IO.Faces,            IO.Faces_view);


   -----------------
   --- General Model
   --

   type Model is
      record
         Sites   : Sites_view;
         Coords  : Coords_view;
         Normals : Normals_view;
         Weights : bone_Weights_array_view;
         Faces   : Faces_view;
      end record;

   procedure destroy (Self : in out Model);


   --------------
   --  Heightmaps
   --

   type height_Map_view is access all height_Map;

   function to_height_Map (image_Filename : in asset_Name;
                           Scale          : in Real := 1.0) return height_Map_view;

   ----------
   --  Images
   --

   function fetch_Image (Stream  : in ada.Streams.Stream_IO.Stream_access;
                         try_TGA : in Boolean) return openGL.Image;
   pragma Obsolescent   (fetch_Image, "use 'openGL.Images.fetch_Image' instead");

   function       to_Image (image_Filename : in     asset_Name)  return Image;
   function to_lucid_Image (image_Filename : in     asset_Name)  return lucid_Image;
   function to_lucid_Image (image_Filename : in     asset_Name;
                            is_Lucid       : access Boolean)     return lucid_Image;

   ------------
   --  Textures
   --

   function to_Texture (image_Filename : in asset_Name) return Texture.Object;


   ---------------
   --  Screenshots
   --

   function  current_Frame return Image;

   procedure Screenshot (Filename : in String;   with_Alpha : in Boolean := False);
   --
   --  Stores the image of the current, active viewport (in RGB or RGBA Bitmap format).


   -----------------
   --  Video Capture
   --

   procedure start_capture (AVI_Name   : in String;
                            frame_Rate : in Positive);
   --
   --  Prepare for video capture (RGB uncompressed, AVI format).

   procedure capture_Frame;
   --
   --  Captures the current active viewport.

   procedure stop_capture;



private
   null_Id : constant long_Index_t := 0;
end openGL.IO;