]>
Dogcows Code - chaz/yoink/blob - src/Moof/Transition.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #define _MOOF_TRANSITION_HH_
13 #ifndef _MOOF_TRANSITION_HH_
14 #define _MOOF_TRANSITION_HH_
16 #include <boost/shared_ptr.hpp>
18 #include <Moof/Core.hh>
19 #include <Moof/Interpolator.hh>
20 #include <Moof/Layer.hh>
21 #include <Moof/Log.hh>
22 #include <Moof/Math.hh>
23 #include <Moof/OpenGL.hh>
24 #include <Moof/Texture.hh>
31 class Transition
: public Layer
40 Transition(LayerP t
, LayerP f
, const T
& interp
) :
45 typedef boost::shared_ptr
<Transition
> Ptr
;
47 static Ptr
alloc(LayerP t
, LayerP f
, const T
& interp
)
49 return Ptr(new Transition(t
, f
, interp
));
53 void removedFromCore(Core
& core
)
55 if (mTo
) core
.push(mTo
);
58 void update(Core
& core
, Scalar t
, Scalar dt
)
60 mInterp
.update(t
, dt
);
62 if (mFrom
) mFrom
->update(core
, t
, dt
);
63 if (mTo
) mTo
->update(core
, t
, dt
);
67 // to should /replace/ this
72 void drawFade(Scalar alpha
) const
75 glDisable(GL_DEPTH_TEST
);
76 glDisable(GL_ALPHA_TEST
);
78 glMatrixMode(GL_PROJECTION
);
81 glMatrixMode(GL_MODELVIEW
);
84 glColor(1.0, 1.0, 1.0, alpha
);
85 Mf::Texture::resetBind();
87 //glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
89 glVertex(-1.0, -1.0, -0.1);
90 glVertex(1.0, -1.0, -0.1);
91 glVertex(1.0, 1.0, -0.1);
92 glVertex(-1.0, 1.0, -0.1);
96 glEnable(GL_DEPTH_TEST
);
97 glEnable(GL_ALPHA_TEST
);
99 glMatrixMode(GL_PROJECTION
);
101 glMatrixMode(GL_MODELVIEW
);
105 void draw(Core
& core
, Scalar alpha
) const
107 Scalar a
= mInterp
.getState(alpha
);
108 logInfo
<< "transition state: " << a
<< std::endl
;
110 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
116 glRotate(180.0 * a
, 0.0, 1.0, 0.0);
117 mFrom
->draw(core
, alpha
);
126 glRotate(180.0 * (1.0 - a
), 0.0, 1.0, 0.0);
127 mTo
->draw(core
, alpha
);
133 bool handleEvent(Core
& core
, const Event
& event
)
137 return mTo
->handleEvent(core
, event
);
141 return mFrom
->handleEvent(core
, event
);
150 #endif // _MOOF_TRANSITION_HH_
This page took 0.038824 seconds and 4 git commands to generate.