]>
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 #ifndef _MOOF_TRANSITION_HH_
13 #define _MOOF_TRANSITION_HH_
15 #include <boost/shared_ptr.hpp>
17 #include <Moof/Core.hh>
18 #include <Moof/Interpolator.hh>
19 #include <Moof/Layer.hh>
20 #include <Moof/Log.hh>
21 #include <Moof/Math.hh>
22 #include <Moof/OpenGL.hh>
23 #include <Moof/Texture.hh>
30 class Transition
: public Layer
39 Transition(LayerP t
, LayerP f
, const T
& interp
) :
44 typedef boost::shared_ptr
<Transition
> Ptr
;
46 static Ptr
alloc(LayerP t
, LayerP f
, const T
& interp
)
48 return Ptr(new Transition(t
, f
, interp
));
52 void removedFromCore()
54 if (mTo
) core
.push(mTo
);
57 void update(Scalar t
, Scalar dt
)
59 mInterp
.update(t
, dt
);
61 if (mFrom
) mFrom
->update(t
, dt
);
62 if (mTo
) mTo
->update(t
, dt
);
66 // to should /replace/ this
71 void drawFade(Scalar alpha
) const
74 glDisable(GL_DEPTH_TEST
);
75 glDisable(GL_ALPHA_TEST
);
77 glMatrixMode(GL_PROJECTION
);
80 glMatrixMode(GL_MODELVIEW
);
83 glColor(1.0, 1.0, 1.0, alpha
);
84 Mf::Texture::resetBind();
86 //glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
88 glVertex(-1.0, -1.0, -0.1);
89 glVertex(1.0, -1.0, -0.1);
90 glVertex(1.0, 1.0, -0.1);
91 glVertex(-1.0, 1.0, -0.1);
95 glEnable(GL_DEPTH_TEST
);
96 glEnable(GL_ALPHA_TEST
);
98 glMatrixMode(GL_PROJECTION
);
100 glMatrixMode(GL_MODELVIEW
);
104 void draw(Scalar alpha
) const
106 Scalar a
= mInterp
.getState(alpha
);
107 logInfo
<< "transition state: " << a
<< std::endl
;
109 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
115 glRotate(180.0 * a
, 0.0, 1.0, 0.0);
125 glRotate(180.0 * (1.0 - a
), 0.0, 1.0, 0.0);
132 bool handleEvent(const Event
& event
)
136 return mTo
->handleEvent(event
);
140 return mFrom
->handleEvent(event
);
149 #endif // _MOOF_TRANSITION_HH_
This page took 0.041846 seconds and 4 git commands to generate.