1
+ #pragma once
2
+ #include < vector>
3
+ #include " shape.h"
4
+
5
+ class Transition
6
+ {
7
+ public:
8
+ Transition (unsigned int flags);
9
+
10
+ enum TRANSITION_FLAGS
11
+ {
12
+ OUTGOING_ONLY = 1 << 0 , // Transition can be used only for outgoing image
13
+ INCOMING_ONLY = 1 << 1 , // Transition can only be used for incoming image
14
+ BIDIRECTIONAL_ONLY = 1 << 2 , // Transition must handle both directions
15
+ OUTGOING = 1 << 3 , // Transition can handle outgoing image
16
+ INCOMING = 1 << 4 , // Transition can handle incoming image
17
+ BIDIRECTIONAL = 1 << 5 , // Transition can handle both directions
18
+ FILLS_SCREEN = 1 << 6 // Transition blocks view behind at some point
19
+ };
20
+
21
+ typedef struct MaterialSpecificationBlob
22
+ {
23
+ glm::vec3 diffuse_albedo;
24
+ glm::vec3 specular_albedo;
25
+ glm::vec3 ambient_color;
26
+ float specular_power;
27
+ } MaterialSpecification;
28
+
29
+ // Identify is called after the effect is loaded. It returns flags to the caller indicating various attributes
30
+ // about this effect. For example, if this transitional effect were a zoom fade, this function would return:
31
+ // BIDIRECTIONAL_ONLY | FILLS_SCREEN
32
+ // Parameters
33
+ // float * minimum_time If not null, return the minimum time (in seconds) that this transition likes to run for.
34
+ // float * maximum_time If not null, return the maximum time (in seconds) that this transition likes to run for.
35
+ // If these are set, the caller will never go outside these bounds for 'time' in Render().
36
+
37
+ virtual TRANSITION_FLAGS Identify (float * minimum_time, float * maximum_time) = 0;
38
+
39
+ // Prepare is called when a transitional effect is selected for the outgoing or incoming or both effects.
40
+ // Parameters:
41
+ // unsigned int flags Chosen from TRANSITION_FLAGS
42
+ // Shape * s nullptr or a pointer to the shape that should be animated.
43
+ // vector<GLuint> texture_handles If empty, no texturing is to be used.
44
+ // If size is 1 or more, use [0] as the effect's incoming texture
45
+ // If size is 2 or more, use [1] as the effect's outgoing texture
46
+ // void fptr Update If not nullptr, this function should be called at the end of every Render.
47
+ // It will rearrange the geometry of the shape and recalculate lighting.
48
+
49
+ virtual bool Prepare (unsigned int flags, Shape * s, std::vector<GLuint> & texture_handles, void (*Update)(struct Data & data, float current_time, void * blob), float current_time, void * blob) = 0;
50
+
51
+ virtual bool Render (unsigned int flags, float time, MaterialSpecification & materials) = 0;
52
+ virtual bool Finish (unsigned int flags) = 0;
53
+
54
+ protected:
55
+ unsigned int flags;
56
+ };
0 commit comments