opengl: Add texture animation.
This commit is contained in:
@@ -1,23 +1,36 @@
|
||||
with
|
||||
openGL.Program,
|
||||
openGL.Texture,
|
||||
openGL.Variable.uniform;
|
||||
ada.Calendar;
|
||||
|
||||
private
|
||||
with
|
||||
ada.Streams;
|
||||
|
||||
|
||||
package openGL.texture_Set
|
||||
--
|
||||
-- Facilitates texturing of geometries.
|
||||
-- Facilitates multi-texturing of geometries.
|
||||
--
|
||||
-- Note that Mesa currently only supports 16 texture units.
|
||||
--
|
||||
is
|
||||
--- Note that Mesa currently only supports 16 texture units.
|
||||
|
||||
---------------
|
||||
--- Texture Ids
|
||||
--
|
||||
-- max_Textures : constant := 32;
|
||||
max_Textures : constant := 16;
|
||||
|
||||
type texture_Id is range 1 .. max_Textures;
|
||||
max_Textures : constant := 16; -- 32;
|
||||
|
||||
type texture_Id is range 1 .. max_Textures;
|
||||
type texture_Ids is array (Positive range <>) of texture_Id;
|
||||
|
||||
|
||||
|
||||
--------
|
||||
--- Fade
|
||||
--
|
||||
|
||||
type fade_Level is delta 0.001 range 0.0 .. 1.0 -- '0.0' is no fading, '1.0' is fully faded (ie invisible).
|
||||
with Atomic;
|
||||
|
||||
@@ -31,7 +44,7 @@ is
|
||||
record
|
||||
Fade : fade_Level := 0.0;
|
||||
Object : openGL.Texture.Object := openGL.Texture.null_Object;
|
||||
Applied : Boolean := True; -- Whether this texture is painted on.
|
||||
Applied : Boolean := True; -- Whether this texture is painted on or not.
|
||||
-- texture_Uniform : openGL.Variable.uniform.sampler2D;
|
||||
-- fade_Uniform : openGL.Variable.uniform.float;
|
||||
end record;
|
||||
@@ -39,6 +52,45 @@ is
|
||||
type fadeable_Textures is array (texture_Id range 1 .. max_Textures) of fadeable_Texture;
|
||||
|
||||
|
||||
|
||||
-------------
|
||||
--- Animation
|
||||
--
|
||||
|
||||
subtype frame_Id is Positive;
|
||||
|
||||
type Frame is
|
||||
record
|
||||
texture_Id : texture_Set.texture_Id;
|
||||
end record;
|
||||
|
||||
type Frames is array (frame_Id range <>) of Frame;
|
||||
|
||||
function to_Frames (From : in texture_Ids) return Frames;
|
||||
|
||||
|
||||
|
||||
type Animation (frame_Count : Positive) is
|
||||
record
|
||||
frame_Duration : Duration := 0.1;
|
||||
next_frame_Time : ada.Calendar.Time := ada.Calendar.Clock;
|
||||
|
||||
Current : frame_Id := 1;
|
||||
Frames : texture_Set.Frames (1 .. frame_Count);
|
||||
end record;
|
||||
|
||||
type Animation_view is access all Animation;
|
||||
|
||||
|
||||
procedure animate (the_Animation : in out Animation;
|
||||
texture_Applies : in out texture_Apply_array);
|
||||
|
||||
|
||||
|
||||
--------
|
||||
--- Item
|
||||
--
|
||||
|
||||
type Item is
|
||||
record
|
||||
Textures : fadeable_Textures;
|
||||
@@ -59,4 +111,21 @@ is
|
||||
function Texture (in_Set : in Item) return openGL.Texture.Object;
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
-----------
|
||||
--- Streams
|
||||
--
|
||||
|
||||
procedure write (Stream : not null access ada.Streams.Root_Stream_type'Class;
|
||||
Item : in texture_Set.Animation_view);
|
||||
|
||||
procedure read (Stream : not null access ada.Streams.Root_Stream_type'Class;
|
||||
Item : out texture_Set.Animation_view);
|
||||
|
||||
for Animation_view'write use write;
|
||||
for Animation_view'read use read;
|
||||
|
||||
|
||||
end openGL.texture_Set;
|
||||
|
||||
Reference in New Issue
Block a user