fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / engine / OGLTrans / generic / OGLTrans_TransitionImpl.cxx
blob736c8c750c613e9ae4c27bf90d240eafece2d8b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <GL/glew.h>
30 #include <vcl/opengl/OpenGLHelper.hxx>
32 #include <utility>
34 #include <boost/make_shared.hpp>
35 #include <comphelper/random.hxx>
37 #include "OGLTrans_TransitionImpl.hxx"
38 #include <math.h>
40 using boost::make_shared;
41 using boost::shared_ptr;
43 using std::max;
44 using std::min;
45 using std::vector;
47 TransitionScene::TransitionScene(TransitionScene const& rOther)
48 : maLeavingSlidePrimitives(rOther.maLeavingSlidePrimitives)
49 , maEnteringSlidePrimitives(rOther.maEnteringSlidePrimitives)
50 , maOverallOperations(rOther.maOverallOperations)
51 , maSceneObjects(rOther.maSceneObjects)
55 TransitionScene& TransitionScene::operator=(const TransitionScene& rOther)
57 TransitionScene aTmp(rOther);
58 swap(aTmp);
59 return *this;
62 void TransitionScene::swap(TransitionScene& rOther)
64 using std::swap;
66 swap(maLeavingSlidePrimitives, rOther.maLeavingSlidePrimitives);
67 swap(maEnteringSlidePrimitives, rOther.maEnteringSlidePrimitives);
68 swap(maOverallOperations, rOther.maOverallOperations);
69 swap(maSceneObjects, rOther.maSceneObjects);
72 OGLTransitionImpl::~OGLTransitionImpl()
76 void OGLTransitionImpl::setScene(TransitionScene const& rScene)
78 maScene = rScene;
81 void OGLTransitionImpl::prepare( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex )
83 const SceneObjects_t& rSceneObjects(maScene.getSceneObjects());
84 for(size_t i(0); i != rSceneObjects.size(); ++i) {
85 rSceneObjects[i]->prepare();
88 prepareTransition( glLeavingSlideTex, glEnteringSlideTex );
91 void OGLTransitionImpl::finish()
93 const SceneObjects_t& rSceneObjects(maScene.getSceneObjects());
94 for(size_t i(0); i != rSceneObjects.size(); ++i) {
95 rSceneObjects[i]->finish();
98 finishTransition();
101 static void blendSlide( double depth )
103 CHECK_GL_ERROR();
104 double showHeight = -1 + depth*2;
105 GLfloat reflectionColor[] = {0, 0, 0, 0.25};
107 glDisable( GL_DEPTH_TEST );
108 glBegin( GL_QUADS );
109 glColor4fv( reflectionColor );
110 glVertex3f( -1, -1, 0 );
111 glColor4f( 0, 0, 0, 1 );
112 glVertex3f(-1, showHeight, 0 );
113 glVertex3f( 1, showHeight, 0 );
114 glColor4fv( reflectionColor );
115 glVertex3f( 1, -1, 0 );
116 glEnd();
118 glBegin( GL_QUADS );
119 glColor4f( 0, 0, 0, 1 );
120 glVertex3f( -1, showHeight, 0 );
121 glVertex3f( -1, 1, 0 );
122 glVertex3f( 1, 1, 0 );
123 glVertex3f( 1, showHeight, 0 );
124 glEnd();
125 glEnable( GL_DEPTH_TEST );
126 CHECK_GL_ERROR();
129 static void slideShadow( double nTime, const Primitive& primitive, double sw, double sh )
131 CHECK_GL_ERROR();
132 double reflectionDepth = 0.3;
134 glEnable(GL_BLEND);
135 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
136 glDisable(GL_LIGHTING);
138 glPushMatrix();
139 primitive.applyOperations( nTime, sw, sh );
140 blendSlide( reflectionDepth );
141 glPopMatrix();
143 glDisable(GL_BLEND);
144 glEnable(GL_LIGHTING);
145 CHECK_GL_ERROR();
148 void OGLTransitionImpl::prepare( double, double, double, double, double )
152 void OGLTransitionImpl::prepareTransition( ::sal_Int32, ::sal_Int32 )
156 void OGLTransitionImpl::finishTransition()
160 void OGLTransitionImpl::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
162 CHECK_GL_ERROR();
163 applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
165 glEnable(GL_TEXTURE_2D);
166 displaySlide( nTime, glLeavingSlideTex, maScene.getLeavingSlide(), SlideWidthScale, SlideHeightScale );
167 displaySlide( nTime, glEnteringSlideTex, maScene.getEnteringSlide(), SlideWidthScale, SlideHeightScale );
170 void OGLTransitionImpl::display( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
171 double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
173 const double SlideWidthScale = SlideWidth/DispWidth;
174 const double SlideHeightScale = SlideHeight/DispHeight;
176 CHECK_GL_ERROR();
177 prepare( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight );
179 CHECK_GL_ERROR();
180 glPushMatrix();
181 CHECK_GL_ERROR();
182 displaySlides_( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale );
183 CHECK_GL_ERROR();
184 displayScene( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight );
185 CHECK_GL_ERROR();
186 glPopMatrix();
187 CHECK_GL_ERROR();
190 void OGLTransitionImpl::applyOverallOperations( double nTime, double SlideWidthScale, double SlideHeightScale )
192 const Operations_t& rOverallOperations(maScene.getOperations());
193 for(size_t i(0); i != rOverallOperations.size(); ++i)
194 rOverallOperations[i]->interpolate(nTime,SlideWidthScale,SlideHeightScale);
197 void
198 OGLTransitionImpl::displaySlide(
199 const double nTime,
200 const ::sal_Int32 glSlideTex, const Primitives_t& primitives,
201 double SlideWidthScale, double SlideHeightScale )
203 CHECK_GL_ERROR();
204 //TODO change to foreach
205 glBindTexture(GL_TEXTURE_2D, glSlideTex);
206 CHECK_GL_ERROR();
208 // display slide reflection
209 // note that depth test is turned off while blending the shadow
210 // so the slides has to be rendered in right order, see rochade as example
211 if( maSettings.mbReflectSlides ) {
212 double surfaceLevel = -0.04;
214 /* reflected slides */
215 glPushMatrix();
217 glScaled( 1, -1, 1 );
218 glTranslated( 0, 2 - surfaceLevel, 0 );
220 glCullFace(GL_FRONT);
221 for(size_t i(0); i < primitives.size(); ++i)
222 primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
223 glCullFace(GL_BACK);
225 slideShadow( nTime, primitives[0], SlideWidthScale, SlideHeightScale );
227 glPopMatrix();
230 for(size_t i(0); i < primitives.size(); ++i)
231 primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
232 CHECK_GL_ERROR();
235 void OGLTransitionImpl::displayScene( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
237 CHECK_GL_ERROR();
238 const SceneObjects_t& rSceneObjects(maScene.getSceneObjects());
239 glEnable(GL_TEXTURE_2D);
240 for(size_t i(0); i != rSceneObjects.size(); ++i)
241 rSceneObjects[i]->display(nTime, SlideWidth, SlideHeight, DispWidth, DispHeight);
242 CHECK_GL_ERROR();
245 void Primitive::display(double nTime, double WidthScale, double HeightScale) const
247 CHECK_GL_ERROR();
248 glPushMatrix();
250 CHECK_GL_ERROR();
251 applyOperations( nTime, WidthScale, HeightScale );
253 CHECK_GL_ERROR();
254 glEnableClientState( GL_VERTEX_ARRAY );
255 CHECK_GL_ERROR();
256 if(!Normals.empty())
258 CHECK_GL_ERROR();
259 glNormalPointer( GL_FLOAT , 0 , &Normals[0] );
260 CHECK_GL_ERROR();
261 glEnableClientState( GL_NORMAL_ARRAY );
262 CHECK_GL_ERROR();
264 CHECK_GL_ERROR();
265 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
266 CHECK_GL_ERROR();
267 glTexCoordPointer( 2, GL_FLOAT, 0, &TexCoords[0] );
268 CHECK_GL_ERROR();
269 glVertexPointer( 3, GL_FLOAT, 0, &Vertices[0] );
270 CHECK_GL_ERROR();
271 glDrawArrays( GL_TRIANGLES, 0, Vertices.size() );
272 CHECK_GL_ERROR();
273 glPopMatrix();
274 CHECK_GL_ERROR();
277 void Primitive::applyOperations(double nTime, double WidthScale, double HeightScale) const
279 CHECK_GL_ERROR();
280 for(size_t i(0); i < Operations.size(); ++i)
281 Operations[i]->interpolate( nTime ,WidthScale,HeightScale);
282 glScaled(WidthScale,HeightScale,1);
283 CHECK_GL_ERROR();
286 void SceneObject::display(double nTime, double /* SlideWidth */, double /* SlideHeight */, double DispWidth, double DispHeight ) const
288 CHECK_GL_ERROR();
289 for(size_t i(0); i < maPrimitives.size(); ++i) {
290 // fixme: allow various model spaces, now we make it so that
291 // it is regular -1,-1 to 1,1, where the whole display fits in
292 CHECK_GL_ERROR();
293 glPushMatrix();
294 CHECK_GL_ERROR();
295 if (DispHeight > DispWidth)
296 glScaled(DispHeight/DispWidth, 1, 1);
297 else
298 glScaled(1, DispWidth/DispHeight, 1);
299 maPrimitives[i].display(nTime, 1, 1);
300 CHECK_GL_ERROR();
301 glPopMatrix();
302 CHECK_GL_ERROR();
304 CHECK_GL_ERROR();
307 void SceneObject::pushPrimitive(const Primitive &p)
309 maPrimitives.push_back(p);
312 SceneObject::SceneObject()
313 : maPrimitives()
317 SceneObject::~SceneObject()
321 Iris::Iris()
322 : SceneObject()
323 , maTexture(0)
327 void Iris::display(double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) const
329 glBindTexture(GL_TEXTURE_2D, maTexture);
330 CHECK_GL_ERROR();
331 SceneObject::display(nTime, SlideWidth, SlideHeight, DispWidth, DispHeight);
334 void Iris::prepare()
336 CHECK_GL_ERROR();
337 static const GLubyte img[3] = { 80, 80, 80 };
339 glGenTextures(1, &maTexture);
340 glBindTexture(GL_TEXTURE_2D, maTexture);
341 glTexImage2D(GL_TEXTURE_2D, 0, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, img);
342 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
343 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
344 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
345 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
346 CHECK_GL_ERROR();
349 void Iris::finish()
351 CHECK_GL_ERROR();
352 glDeleteTextures(1, &maTexture);
353 CHECK_GL_ERROR();
356 namespace
359 class SimpleTransition : public OGLTransitionImpl
361 public:
362 SimpleTransition()
363 : OGLTransitionImpl()
367 SimpleTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
368 : OGLTransitionImpl(rScene, rSettings)
373 shared_ptr<OGLTransitionImpl>
374 makeSimpleTransition()
376 return make_shared<SimpleTransition>();
379 shared_ptr<OGLTransitionImpl>
380 makeSimpleTransition(
381 const Primitives_t& rLeavingSlidePrimitives,
382 const Primitives_t& rEnteringSlidePrimitives,
383 const Operations_t& rOverallOperations,
384 const SceneObjects_t& rSceneObjects,
385 const TransitionSettings& rSettings = TransitionSettings())
387 return make_shared<SimpleTransition>(
388 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives, rOverallOperations, rSceneObjects),
389 rSettings)
393 shared_ptr<OGLTransitionImpl>
394 makeSimpleTransition(
395 const Primitives_t& rLeavingSlidePrimitives,
396 const Primitives_t& rEnteringSlidePrimitives,
397 const Operations_t& rOverallOperations,
398 const TransitionSettings& rSettings = TransitionSettings())
400 return makeSimpleTransition(rLeavingSlidePrimitives, rEnteringSlidePrimitives, rOverallOperations, SceneObjects_t(), rSettings);
403 shared_ptr<OGLTransitionImpl>
404 makeSimpleTransition(
405 const Primitives_t& rLeavingSlidePrimitives,
406 const Primitives_t& rEnteringSlidePrimitives,
407 const SceneObjects_t& rSceneObjects,
408 const TransitionSettings& rSettings = TransitionSettings())
410 return makeSimpleTransition(rLeavingSlidePrimitives, rEnteringSlidePrimitives, Operations_t(), rSceneObjects, rSettings);
413 shared_ptr<OGLTransitionImpl>
414 makeSimpleTransition(
415 const Primitives_t& rLeavingSlidePrimitives,
416 const Primitives_t& rEnteringSlidePrimitives,
417 const TransitionSettings& rSettings = TransitionSettings())
419 return makeSimpleTransition(rLeavingSlidePrimitives, rEnteringSlidePrimitives, Operations_t(), SceneObjects_t(), rSettings);
424 boost::shared_ptr<OGLTransitionImpl> makeOutsideCubeFaceToLeft()
426 Primitive Slide;
428 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
429 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
431 Primitives_t aLeavingPrimitives;
432 aLeavingPrimitives.push_back(Slide);
434 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),90,false,0.0,1.0));
436 Primitives_t aEnteringPrimitives;
437 aEnteringPrimitives.push_back(Slide);
439 Operations_t aOperations;
440 aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),-90,true,0.0,1.0));
442 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations);
445 boost::shared_ptr<OGLTransitionImpl> makeInsideCubeFaceToLeft()
447 Primitive Slide;
449 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
450 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
452 Primitives_t aLeavingPrimitives;
453 aLeavingPrimitives.push_back(Slide);
455 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),-90,false,0.0,1.0));
457 Primitives_t aEnteringPrimitives;
458 aEnteringPrimitives.push_back(Slide);
460 Operations_t aOperations;
461 aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),90,true,0.0,1.0));
463 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations);
466 boost::shared_ptr<OGLTransitionImpl> makeFallLeaving()
468 Primitive Slide;
470 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
471 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
473 Primitives_t aEnteringPrimitives;
474 aEnteringPrimitives.push_back(Slide);
476 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(1,0,0),glm::vec3(0,-1,0), 90,true,0.0,1.0));
477 Primitives_t aLeavingPrimitives;
478 aLeavingPrimitives.push_back(Slide);
480 TransitionSettings aSettings;
481 aSettings.mbUseMipMapEntering = false;
483 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aSettings);
486 boost::shared_ptr<OGLTransitionImpl> makeTurnAround()
488 Primitive Slide;
490 TransitionSettings aSettings;
491 aSettings.mbReflectSlides = true;
493 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
494 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
495 Primitives_t aLeavingPrimitives;
496 aLeavingPrimitives.push_back(Slide);
498 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0),-180,false,0.0,1.0));
499 Primitives_t aEnteringPrimitives;
500 aEnteringPrimitives.push_back(Slide);
502 Operations_t aOperations;
503 aOperations.push_back(makeSTranslate(glm::vec3(0, 0, -1.5),true, 0, 0.5));
504 aOperations.push_back(makeSTranslate(glm::vec3(0, 0, 1.5), true, 0.5, 1));
505 aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0),glm::vec3(0, 0, 0), -180, true, 0.0, 1.0));
507 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations, aSettings);
510 boost::shared_ptr<OGLTransitionImpl> makeTurnDown()
512 Primitive Slide;
514 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
515 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
516 Primitives_t aLeavingPrimitives;
517 aLeavingPrimitives.push_back(Slide);
519 Slide.Operations.push_back(makeSTranslate(glm::vec3(0, 0, 0.0001), false, -1.0, 0.0));
520 Slide.Operations.push_back(makeSRotate (glm::vec3(0, 0, 1), glm::vec3(-1, 1, 0), -90, true, 0.0, 1.0));
521 Slide.Operations.push_back(makeSRotate (glm::vec3(0, 0, 1), glm::vec3(-1, 1, 0), 90, false, -1.0, 0.0));
522 Primitives_t aEnteringPrimitives;
523 aEnteringPrimitives.push_back(Slide);
525 TransitionSettings aSettings;
526 aSettings.mbUseMipMapLeaving = false;
528 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aSettings);
531 boost::shared_ptr<OGLTransitionImpl> makeIris()
533 Primitive Slide;
535 Slide.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
536 Slide.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
537 Primitives_t aEnteringPrimitives;
538 aEnteringPrimitives.push_back (Slide);
540 Slide.Operations.push_back (makeSTranslate (glm::vec3 (0, 0, 0.000001), false, -1, 0));
541 Slide.Operations.push_back (makeSTranslate (glm::vec3 (0, 0, -0.000002), false, 0.5, 1));
542 Primitives_t aLeavingPrimitives;
543 aLeavingPrimitives.push_back (Slide);
546 Primitive irisPart, part;
547 int i, nSteps = 24, nParts = 7;
548 double t = 1.0/nSteps, cx, cy, lcx, lcy, lx = 1, ly = 0, x, y, cxo, cyo, lcxo, lcyo, of=2.2, f=1.42;
550 for (i=1; i<=nSteps; i++) {
551 x = cos ((3*2*M_PI*t)/nParts);
552 y = -sin ((3*2*M_PI*t)/nParts);
553 cx = (f*x + 1)/2;
554 cy = (f*y + 1)/2;
555 lcx = (f*lx + 1)/2;
556 lcy = (f*ly + 1)/2;
557 cxo = (of*x + 1)/2;
558 cyo = (of*y + 1)/2;
559 lcxo = (of*lx + 1)/2;
560 lcyo = (of*ly + 1)/2;
561 irisPart.pushTriangle (glm::vec2 (lcx, lcy),
562 glm::vec2 (lcxo, lcyo),
563 glm::vec2 (cx, cy));
564 irisPart.pushTriangle (glm::vec2 (cx, cy),
565 glm::vec2 (lcxo, lcyo),
566 glm::vec2 (cxo, cyo));
567 lx = x;
568 ly = y;
569 t += 1.0/nSteps;
572 shared_ptr<Iris> pIris = make_shared<Iris>();
573 double angle = 87;
575 for (i = 0; i < nParts; i++) {
576 irisPart.Operations.clear ();
577 double rx, ry;
579 rx = cos ((2*M_PI*i)/nParts);
580 ry = sin ((2*M_PI*i)/nParts);
581 irisPart.Operations.push_back (makeSRotate (glm::vec3(0, 0, 1), glm::vec3(rx, ry, 0), angle, true, 0.0, 0.5));
582 irisPart.Operations.push_back (makeSRotate (glm::vec3(0, 0, 1), glm::vec3(rx, ry, 0), -angle, true, 0.5, 1));
583 if (i > 0) {
584 irisPart.Operations.push_back (makeSTranslate (glm::vec3(rx, ry, 0), false, -1, 0));
585 irisPart.Operations.push_back (makeSRotate (glm::vec3(0, 0, 1), glm::vec3(0, 0, 0), i*360.0/nParts, false, -1, 0));
586 irisPart.Operations.push_back (makeSTranslate (glm::vec3(-1, 0, 0), false, -1, 0));
588 irisPart.Operations.push_back(makeSTranslate(glm::vec3(0, 0, 1), false, -2, 0.0));
589 irisPart.Operations.push_back (makeSRotate (glm::vec3(1, .5, 0), glm::vec3(1, 0, 0), -30, false, -1, 0));
590 pIris->pushPrimitive (irisPart);
593 SceneObjects_t aSceneObjects;
594 aSceneObjects.push_back (pIris);
596 TransitionSettings aSettings;
597 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
599 return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aSceneObjects, aSettings);
602 namespace
605 class RochadeTransition : public OGLTransitionImpl
607 public:
608 RochadeTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
609 : OGLTransitionImpl(rScene, rSettings)
612 private:
613 virtual void displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) SAL_OVERRIDE;
616 void RochadeTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
618 applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
620 glEnable(GL_TEXTURE_2D);
622 if( nTime > .5) {
623 displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
624 displaySlide( nTime, glEnteringSlideTex, getScene().getEnteringSlide(), SlideWidthScale, SlideHeightScale );
625 } else {
626 displaySlide( nTime, glEnteringSlideTex, getScene().getEnteringSlide(), SlideWidthScale, SlideHeightScale );
627 displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
631 shared_ptr<OGLTransitionImpl>
632 makeRochadeTransition(
633 const Primitives_t& rLeavingSlidePrimitives,
634 const Primitives_t& rEnteringSlidePrimitives,
635 const TransitionSettings& rSettings)
637 return make_shared<RochadeTransition>(
638 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
639 rSettings)
645 boost::shared_ptr<OGLTransitionImpl> makeRochade()
647 Primitive Slide;
649 TransitionSettings aSettings;
650 aSettings.mbReflectSlides = true;
652 double w, h;
654 w = 2.2;
655 h = 10;
657 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
658 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
660 Slide.Operations.push_back(makeSEllipseTranslate(w, h, 0.25, -0.25, true, 0, 1));
661 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, 0, 1));
662 Primitives_t aLeavingSlide;
663 aLeavingSlide.push_back(Slide);
665 Slide.Operations.clear();
666 Slide.Operations.push_back(makeSEllipseTranslate(w, h, 0.75, 0.25, true, 0, 1));
667 Slide.Operations.push_back(makeSTranslate(glm::vec3(0, 0, -h), false, -1, 0));
668 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, 0, 1));
669 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), 45, false, -1, 0));
670 Primitives_t aEnteringSlide;
671 aEnteringSlide.push_back(Slide);
673 return makeRochadeTransition(aLeavingSlide, aEnteringSlide, aSettings);
676 inline double randFromNeg1to1()
678 return comphelper::rng::uniform_real_distribution(-1.0, std::nextafter(1.0, DBL_MAX));
681 // TODO(Q3): extract to basegfx
682 inline glm::vec3 randNormVectorInXYPlane()
684 glm::vec3 toReturn(randFromNeg1to1(),randFromNeg1to1(),0.0);
685 return glm::normalize(toReturn);
688 template<typename T>
689 T clamp(const T& rIn)
691 return glm::clamp(rIn, T(-1.0), T(1.0));
694 boost::shared_ptr<OGLTransitionImpl> makeRevolvingCircles( ::sal_uInt16 nCircles , ::sal_uInt16 nPointsOnCircles )
696 double dAngle(2*3.1415926/static_cast<double>( nPointsOnCircles ));
697 if(nCircles < 2 || nPointsOnCircles < 4)
699 makeNByMTileFlip(1,1);
700 return makeSimpleTransition();
702 float Radius(1.0/static_cast<double>( nCircles ));
703 float dRadius(Radius);
704 float LastRadius(0.0);
705 float NextRadius(2*Radius);
707 /// now we know there is at least two circles
708 /// the first will always be a full circle
709 /// the last will always be the outer shell of the slide with a circle hole
711 //add the full circle
712 vector<glm::vec2> unScaledTexCoords;
713 float TempAngle(0.0);
714 for(unsigned int Point(0); Point < nPointsOnCircles; ++Point)
716 unScaledTexCoords.push_back( glm::vec2( cos(TempAngle - 3.1415926/2.0) , sin(TempAngle- 3.1415926/2.0) ) );
718 TempAngle += dAngle;
721 Primitives_t aLeavingSlide;
722 Primitives_t aEnteringSlide;
724 Primitive EnteringSlide;
725 Primitive LeavingSlide;
726 for(int Point(0); Point + 1 < nPointsOnCircles; ++Point)
728 EnteringSlide.pushTriangle( glm::vec2( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point + 1 ] / 2.0f + glm::vec2( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point ] / 2.0f + glm::vec2( 0.5 , 0.5 ) );
729 LeavingSlide.pushTriangle( glm::vec2( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point + 1 ] / 2.0f + glm::vec2( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point ] / 2.0f + glm::vec2( 0.5, 0.5) );
731 EnteringSlide.pushTriangle( glm::vec2(0.5,0.5) , Radius * unScaledTexCoords[ 0 ] / 2.0f + glm::vec2( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ nPointsOnCircles - 1 ] / 2.0f + glm::vec2( 0.5 , 0.5 ) );
732 LeavingSlide.pushTriangle( glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) );
734 glm::vec3 axis(randNormVectorInXYPlane());
735 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
736 LeavingSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
737 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , -180, false,0.0,1.0) );
739 aEnteringSlide.push_back(EnteringSlide);
740 aLeavingSlide.push_back(LeavingSlide);
741 LastRadius = Radius;
742 Radius = NextRadius;
743 NextRadius += dRadius;
746 for(int i(1); i < nCircles - 1; ++i)
748 Primitive LeavingSlide;
749 Primitive EnteringSlide;
750 for(int Side(0); Side < nPointsOnCircles - 1; ++Side)
752 EnteringSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
753 EnteringSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
755 LeavingSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
756 LeavingSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
759 EnteringSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
760 EnteringSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
762 LeavingSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
763 LeavingSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
765 glm::vec3 axis(randNormVectorInXYPlane());
766 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
767 LeavingSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
768 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , -180, false,0.0,1.0) );
770 aEnteringSlide.push_back(EnteringSlide);
771 aLeavingSlide.push_back(LeavingSlide);
773 LastRadius = Radius;
774 Radius = NextRadius;
775 NextRadius += dRadius;
778 Radius = sqrt(2.0);
779 Primitive LeavingSlide;
780 Primitive EnteringSlide;
781 for(int Side(0); Side < nPointsOnCircles - 1; ++Side)
784 EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
785 EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) , clamp(Radius*unScaledTexCoords[Side + 1])/2.0f + glm::vec2(0.5,0.5) );
787 LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) );
788 LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0f + glm::vec2(0.5,0.5) , clamp(Radius*unScaledTexCoords[Side + 1])/2.0f + glm::vec2(0.5,0.5) );
791 EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
792 EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) , clamp(Radius*unScaledTexCoords[0])/2.0f + glm::vec2(0.5,0.5) );
794 LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) );
795 LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0f + glm::vec2(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0f + glm::vec2(0.5,0.5) , clamp(Radius*unScaledTexCoords[0])/2.0f + glm::vec2(0.5,0.5) );
797 glm::vec3 axis(randNormVectorInXYPlane());
798 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, (LastRadius + dRadius)/2.0 , 1.0 ) );
799 LeavingSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , 180, true, (LastRadius + dRadius)/2.0 , 1.0 ) );
800 EnteringSlide.Operations.push_back( makeSRotate( axis , glm::vec3(0,0,0) , -180, false,0.0,1.0) );
802 aEnteringSlide.push_back(EnteringSlide);
803 aLeavingSlide.push_back(LeavingSlide);
806 return makeSimpleTransition(aLeavingSlide, aEnteringSlide);
809 boost::shared_ptr<OGLTransitionImpl> makeHelix( ::sal_uInt16 nRows )
811 double invN(1.0/static_cast<double>(nRows));
812 double iDn = 0.0;
813 double iPDn = invN;
814 Primitives_t aLeavingSlide;
815 Primitives_t aEnteringSlide;
816 for(unsigned int i(0); i < nRows; ++i)
818 Primitive Tile;
820 Tile.pushTriangle(glm::vec2( 1.0 , iDn ) , glm::vec2( 0.0 , iDn ) , glm::vec2( 0.0 , iPDn ));
822 Tile.pushTriangle(glm::vec2( 1.0 , iPDn ) , glm::vec2( 1.0 , iDn ) , glm::vec2( 0.0 , iPDn ));
824 Tile.Operations.push_back( makeSRotate( glm::vec3( 0 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0f , 180 ,
825 true,min(max(static_cast<double>(i - nRows/2.0)*invN/2.0,0.0),1.0),
826 min(max(static_cast<double>(i + nRows/2.0)*invN/2.0,0.0),1.0) ) );
828 aLeavingSlide.push_back(Tile);
830 Tile.Operations.push_back( makeSRotate( glm::vec3( 0 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0f , -180 , false,0.0,1.0) );
832 aEnteringSlide.push_back(Tile);
834 iDn += invN;
835 iPDn += invN;
838 return makeSimpleTransition(aLeavingSlide, aEnteringSlide);
841 boost::shared_ptr<OGLTransitionImpl> makeNByMTileFlip( ::sal_uInt16 n, ::sal_uInt16 m )
843 double invN(1.0/static_cast<double>(n));
844 double invM(1.0/static_cast<double>(m));
845 double iDn = 0.0;
846 double iPDn = invN;
847 Primitives_t aLeavingSlide;
848 Primitives_t aEnteringSlide;
849 for(unsigned int i(0); i < n; ++i)
851 double jDm = 0.0;
852 double jPDm = invM;
853 for(unsigned int j(0); j < m; ++j)
855 Primitive Tile;
857 Tile.pushTriangle(glm::vec2( iPDn , jDm ) , glm::vec2( iDn , jDm ) , glm::vec2( iDn , jPDm ));
859 Tile.pushTriangle(glm::vec2( iPDn , jPDm ) , glm::vec2( iPDn , jDm ) , glm::vec2( iDn , jPDm ));//bottom left corner of tile
861 Tile.Operations.push_back( makeSRotate( glm::vec3( 1 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0f , 180 , true, iDn*jDm/2.0 , ((iPDn*jPDm)+1.0)/2.0 ) );
862 aLeavingSlide.push_back(Tile);
863 Tile.Operations.push_back( makeSRotate( glm::vec3( 1 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0f , -180, false, iDn*jDm/2.0 , ((iPDn*jPDm)+1.0)/2.0 ) );
865 aEnteringSlide.push_back(Tile);
867 jDm += invM;
868 jPDm += invM;
870 iDn += invN;
871 iPDn += invN;
874 return makeSimpleTransition(aLeavingSlide, aEnteringSlide);
877 SRotate::SRotate(const glm::vec3& Axis, const glm::vec3& Origin,
878 double Angle, bool bInter, double T0, double T1):
879 Operation(bInter, T0, T1),
880 axis(Axis),
881 origin(Origin),
882 angle(Angle)
886 SScale::SScale(const glm::vec3& Scale, const glm::vec3& Origin,
887 bool bInter, double T0, double T1):
888 Operation(bInter, T0, T1),
889 scale(Scale),
890 origin(Origin)
894 RotateAndScaleDepthByWidth::RotateAndScaleDepthByWidth(const glm::vec3& Axis,
895 const glm::vec3& Origin, double Angle, bool bInter, double T0, double T1):
896 Operation(bInter, T0, T1),
897 axis(Axis),
898 origin(Origin),
899 angle(Angle)
903 RotateAndScaleDepthByHeight::RotateAndScaleDepthByHeight(const glm::vec3& Axis,
904 const glm::vec3& Origin, double Angle, bool bInter, double T0, double T1):
905 Operation(bInter, T0, T1),
906 axis(Axis),
907 origin(Origin),
908 angle(Angle)
913 STranslate::STranslate(const glm::vec3& Vector, bool bInter, double T0, double T1):
914 Operation(bInter, T0, T1),
915 vector(Vector)
919 boost::shared_ptr<SRotate>
920 makeSRotate(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1)
922 return make_shared<SRotate>(Axis, Origin, Angle, bInter, T0, T1);
925 boost::shared_ptr<SScale>
926 makeSScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1)
928 return make_shared<SScale>(Scale, Origin, bInter, T0, T1);
931 boost::shared_ptr<STranslate>
932 makeSTranslate(const glm::vec3& Vector,bool bInter, double T0, double T1)
934 return make_shared<STranslate>(Vector, bInter, T0, T1);
937 boost::shared_ptr<SEllipseTranslate>
938 makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1)
940 return make_shared<SEllipseTranslate>(dWidth, dHeight, dStartPosition, dEndPosition, bInter, T0, T1);
943 boost::shared_ptr<RotateAndScaleDepthByWidth>
944 makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1)
946 return make_shared<RotateAndScaleDepthByWidth>(Axis, Origin, Angle, bInter, T0, T1);
949 boost::shared_ptr<RotateAndScaleDepthByHeight>
950 makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1)
952 return make_shared<RotateAndScaleDepthByHeight>(Axis, Origin, Angle, bInter, T0, T1);
955 inline double intervalInter(double t, double T0, double T1)
957 return ( t - T0 ) / ( T1 - T0 );
960 void STranslate::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const
962 CHECK_GL_ERROR();
963 if(t <= mnT0)
964 return;
965 if(!mbInterpolate || t > mnT1)
966 t = mnT1;
967 t = intervalInter(t,mnT0,mnT1);
968 glTranslated(SlideWidthScale*t*vector.x,SlideHeightScale*t*vector.y,t*vector.z);
969 CHECK_GL_ERROR();
972 void SRotate::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const
974 CHECK_GL_ERROR();
975 if(t <= mnT0)
976 return;
977 if(!mbInterpolate || t > mnT1)
978 t = mnT1;
979 t = intervalInter(t,mnT0,mnT1);
980 glTranslated(SlideWidthScale*origin.x,SlideHeightScale*origin.y,origin.z);
981 glScaled(SlideWidthScale,SlideHeightScale,1);
982 glRotated(t*angle,axis.x,axis.y,axis.z);
983 glScaled(1/SlideWidthScale,1/SlideHeightScale,1);
984 glTranslated(-SlideWidthScale*origin.x,-SlideHeightScale*origin.y,-origin.z);
985 CHECK_GL_ERROR();
988 void SScale::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const
990 CHECK_GL_ERROR();
991 if(t <= mnT0)
992 return;
993 if(!mbInterpolate || t > mnT1)
994 t = mnT1;
995 t = intervalInter(t,mnT0,mnT1);
996 glTranslated(SlideWidthScale*origin.x,SlideHeightScale*origin.y,origin.z);
997 glScaled((1-t) + t*scale.x,(1-t) + t*scale.y,(1-t) + t*scale.z);
998 glTranslated(-SlideWidthScale*origin.x,-SlideHeightScale*origin.y,-origin.z);
999 CHECK_GL_ERROR();
1002 void RotateAndScaleDepthByWidth::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const
1004 CHECK_GL_ERROR();
1005 if(t <= mnT0)
1006 return;
1007 if(!mbInterpolate || t > mnT1)
1008 t = mnT1;
1009 t = intervalInter(t,mnT0,mnT1);
1010 glTranslated(SlideWidthScale*origin.x,SlideHeightScale*origin.y,SlideWidthScale*origin.z);
1011 glRotated(t*angle,axis.x,axis.y,axis.z);
1012 glTranslated(-SlideWidthScale*origin.x,-SlideHeightScale*origin.y,-SlideWidthScale*origin.z);
1013 CHECK_GL_ERROR();
1016 void RotateAndScaleDepthByHeight::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const
1018 CHECK_GL_ERROR();
1019 if(t <= mnT0)
1020 return;
1021 if(!mbInterpolate || t > mnT1)
1022 t = mnT1;
1023 t = intervalInter(t,mnT0,mnT1);
1024 glTranslated(SlideWidthScale*origin.x,SlideHeightScale*origin.y,SlideHeightScale*origin.z);
1025 glRotated(t*angle,axis.x,axis.y,axis.z);
1026 glTranslated(-SlideWidthScale*origin.x,-SlideHeightScale*origin.y,-SlideHeightScale*origin.z);
1027 CHECK_GL_ERROR();
1030 SEllipseTranslate::SEllipseTranslate(double dWidth, double dHeight, double dStartPosition,
1031 double dEndPosition, bool bInter, double T0, double T1):
1032 Operation(bInter, T0, T1)
1034 width = dWidth;
1035 height = dHeight;
1036 startPosition = dStartPosition;
1037 endPosition = dEndPosition;
1040 void SEllipseTranslate::interpolate(double t,double /* SlideWidthScale */,double /* SlideHeightScale */) const
1042 if(t <= mnT0)
1043 return;
1044 if(!mbInterpolate || t > mnT1)
1045 t = mnT1;
1046 t = intervalInter(t,mnT0,mnT1);
1048 double a1, a2, x, y;
1049 a1 = startPosition*2*M_PI;
1050 a2 = (startPosition + t*(endPosition - startPosition))*2*M_PI;
1051 x = width*(cos (a2) - cos (a1))/2;
1052 y = height*(sin (a2) - sin (a1))/2;
1054 glTranslated(x, 0, y);
1057 Primitive& Primitive::operator=(const Primitive& rvalue)
1059 Primitive aTmp(rvalue);
1060 swap(aTmp);
1061 return *this;
1064 Primitive::Primitive(const Primitive& rvalue)
1065 : Operations(rvalue.Operations)
1066 , Vertices(rvalue.Vertices)
1067 , Normals(rvalue.Normals)
1068 , TexCoords(rvalue.TexCoords)
1072 void Primitive::swap(Primitive& rOther)
1074 using std::swap;
1076 swap(Operations, rOther.Operations);
1077 swap(Vertices, rOther.Vertices);
1078 swap(Normals, rOther.Normals);
1079 swap(TexCoords, rOther.TexCoords);
1082 void Primitive::pushTriangle(const glm::vec2& SlideLocation0,const glm::vec2& SlideLocation1,const glm::vec2& SlideLocation2)
1084 vector<glm::vec3> Verts;
1085 vector<glm::vec2> Texs;
1086 Verts.reserve(3);
1087 Texs.reserve(3);
1089 Verts.push_back(glm::vec3( 2*SlideLocation0.x - 1, -2*SlideLocation0.y + 1 , 0.0 ));
1090 Verts.push_back(glm::vec3( 2*SlideLocation1.x - 1, -2*SlideLocation1.y + 1 , 0.0 ));
1091 Verts.push_back(glm::vec3( 2*SlideLocation2.x - 1, -2*SlideLocation2.y + 1 , 0.0 ));
1093 //figure out if they're facing the correct way, and make them face the correct way.
1094 glm::vec3 Normal( glm::cross( Verts[0] - Verts[1] , Verts[1] - Verts[2] ) );
1095 if(Normal.z >= 0.0)//if the normal is facing us
1097 Texs.push_back(SlideLocation0);
1098 Texs.push_back(SlideLocation1);
1099 Texs.push_back(SlideLocation2);
1101 else // if the normal is facing away from us, make it face us
1103 Texs.push_back(SlideLocation0);
1104 Texs.push_back(SlideLocation2);
1105 Texs.push_back(SlideLocation1);
1106 Verts.clear();
1107 Verts.push_back(glm::vec3( 2*SlideLocation0.x - 1, -2*SlideLocation0.y + 1 , 0.0 ));
1108 Verts.push_back(glm::vec3( 2*SlideLocation2.x - 1, -2*SlideLocation2.y + 1 , 0.0 ));
1109 Verts.push_back(glm::vec3( 2*SlideLocation1.x - 1, -2*SlideLocation1.y + 1 , 0.0 ));
1112 Vertices.push_back(Verts[0]);
1113 Vertices.push_back(Verts[1]);
1114 Vertices.push_back(Verts[2]);
1116 TexCoords.push_back(Texs[0]);
1117 TexCoords.push_back(Texs[1]);
1118 TexCoords.push_back(Texs[2]);
1120 Normals.push_back(glm::vec3(0,0,1));//all normals always face the screen when untransformed.
1121 Normals.push_back(glm::vec3(0,0,1));//all normals always face the screen when untransformed.
1122 Normals.push_back(glm::vec3(0,0,1));//all normals always face the screen when untransformed.
1125 namespace
1128 class DiamondTransition : public OGLTransitionImpl
1130 public:
1131 DiamondTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1132 : OGLTransitionImpl(rScene, rSettings)
1135 private:
1136 virtual void prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) SAL_OVERRIDE;
1137 // mmPrepare = &OGLTransitionImpl::prepareDiamond;
1140 void DiamondTransition::prepare( double nTime, double /* SlideWidth */, double /* SlideHeight */, double /* DispWidth */, double /* DispHeight */ )
1142 Primitive Slide1, Slide2;
1144 Slide1.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
1145 Slide1.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
1146 Primitives_t aEnteringSlidePrimitives;
1147 aEnteringSlidePrimitives.push_back (Slide1);
1149 if( nTime >= 0.5 ) {
1150 double m = 1 - nTime;
1152 Slide2.pushTriangle (glm::vec2 (0,0), glm::vec2 (m,0), glm::vec2 (0,m));
1153 Slide2.pushTriangle (glm::vec2 (nTime,0), glm::vec2 (1,0), glm::vec2 (1,m));
1154 Slide2.pushTriangle (glm::vec2 (1,nTime), glm::vec2 (1,1), glm::vec2 (nTime,1));
1155 Slide2.pushTriangle (glm::vec2 (0,nTime), glm::vec2 (m,1), glm::vec2 (0,1));
1156 } else {
1157 double l = 0.5 - nTime;
1158 double h = 0.5 + nTime;
1160 Slide2.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0.5,l));
1161 Slide2.pushTriangle (glm::vec2 (0.5,l), glm::vec2 (1,0), glm::vec2 (h,0.5));
1162 Slide2.pushTriangle (glm::vec2 (1,0), glm::vec2 (1,1), glm::vec2 (h,0.5));
1163 Slide2.pushTriangle (glm::vec2 (h,0.5), glm::vec2 (1,1), glm::vec2 (0.5,h));
1164 Slide2.pushTriangle (glm::vec2 (0.5,h), glm::vec2 (1,1), glm::vec2 (0,1));
1165 Slide2.pushTriangle (glm::vec2 (l,0.5), glm::vec2 (0.5,h), glm::vec2 (0,1));
1166 Slide2.pushTriangle (glm::vec2 (0,0), glm::vec2 (l,0.5), glm::vec2 (0,1));
1167 Slide2.pushTriangle (glm::vec2 (0,0), glm::vec2 (0.5,l), glm::vec2 (l,0.5));
1169 Slide2.Operations.push_back (makeSTranslate (glm::vec3 (0, 0, 0.00000001), false, -1, 0));
1170 Primitives_t aLeavingSlidePrimitives;
1171 aLeavingSlidePrimitives.push_back (Slide2);
1173 setScene(TransitionScene(aLeavingSlidePrimitives, aEnteringSlidePrimitives));
1176 shared_ptr<OGLTransitionImpl>
1177 makeDiamondTransition(const TransitionSettings& rSettings)
1179 return make_shared<DiamondTransition>(TransitionScene(), rSettings);
1184 boost::shared_ptr<OGLTransitionImpl> makeDiamond()
1186 TransitionSettings aSettings;
1187 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
1189 return makeDiamondTransition(aSettings);
1192 boost::shared_ptr<OGLTransitionImpl> makeVenetianBlinds( bool vertical, int parts )
1194 static double t30 = tan( M_PI/6.0 );
1195 double n, ln = 0;
1196 double p = 1.0/parts;
1198 Primitives_t aLeavingSlide;
1199 Primitives_t aEnteringSlide;
1200 for( int i=0; i<parts; i++ ) {
1201 Primitive Slide;
1202 n = (i + 1)/(double)parts;
1203 if( vertical ) {
1204 Slide.pushTriangle (glm::vec2 (ln,0), glm::vec2 (n,0), glm::vec2 (ln,1));
1205 Slide.pushTriangle (glm::vec2 (n,0), glm::vec2 (ln,1), glm::vec2 (n,1));
1206 Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0), glm::vec3(n + ln - 1, 0, -t30*p), -120, true, 0.0, 1.0));
1207 } else {
1208 Slide.pushTriangle (glm::vec2 (0,ln), glm::vec2 (1,ln), glm::vec2 (0,n));
1209 Slide.pushTriangle (glm::vec2 (1,ln), glm::vec2 (0,n), glm::vec2 (1,n));
1210 Slide.Operations.push_back(makeRotateAndScaleDepthByHeight(glm::vec3(1, 0, 0), glm::vec3(0, 1 - n - ln, -t30*p), -120, true, 0.0, 1.0));
1212 aLeavingSlide.push_back (Slide);
1214 if( vertical ) {
1215 Slide.Operations.push_back(makeSRotate(glm::vec3(0, 1, 0), glm::vec3(2*n - 1, 0, 0), -60, false, -1, 0));
1216 Slide.Operations.push_back(makeSRotate(glm::vec3(0, 1, 0), glm::vec3(n + ln - 1, 0, 0), 180, false, -1, 0));
1217 } else {
1218 Slide.Operations.push_back(makeSRotate(glm::vec3(1, 0, 0), glm::vec3(0, 1 - 2*n, 0), -60, false, -1, 0));
1219 Slide.Operations.push_back(makeSRotate(glm::vec3(1, 0, 0), glm::vec3(0, 1 - n - ln, 0), 180, false, -1, 0));
1221 aEnteringSlide.push_back (Slide);
1222 ln = n;
1225 return makeSimpleTransition(aLeavingSlide, aEnteringSlide);
1228 namespace
1231 class FadeSmoothlyTransition : public OGLTransitionImpl
1233 public:
1234 FadeSmoothlyTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1235 : OGLTransitionImpl(rScene, rSettings)
1238 private:
1239 virtual void displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) SAL_OVERRIDE;
1242 void FadeSmoothlyTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
1244 CHECK_GL_ERROR();
1245 applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
1247 CHECK_GL_ERROR();
1248 glDisable(GL_DEPTH_TEST);
1250 CHECK_GL_ERROR();
1251 displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
1252 CHECK_GL_ERROR();
1254 CHECK_GL_ERROR();
1255 glDisable(GL_LIGHTING);
1256 CHECK_GL_ERROR();
1257 glEnable(GL_BLEND);
1258 CHECK_GL_ERROR();
1259 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1260 CHECK_GL_ERROR();
1261 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1262 CHECK_GL_ERROR();
1263 glColor4f( 1, 1, 1, nTime );
1264 CHECK_GL_ERROR();
1265 displaySlide( nTime, glEnteringSlideTex, getScene().getEnteringSlide(), SlideWidthScale, SlideHeightScale );
1266 CHECK_GL_ERROR();
1267 glDisable(GL_BLEND);
1268 CHECK_GL_ERROR();
1269 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1270 CHECK_GL_ERROR();
1271 glEnable(GL_LIGHTING);
1272 CHECK_GL_ERROR();
1274 glEnable(GL_DEPTH_TEST);
1275 CHECK_GL_ERROR();
1278 shared_ptr<OGLTransitionImpl>
1279 makeFadeSmoothlyTransition(
1280 const Primitives_t& rLeavingSlidePrimitives,
1281 const Primitives_t& rEnteringSlidePrimitives,
1282 const TransitionSettings& rSettings)
1284 return make_shared<FadeSmoothlyTransition>(
1285 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
1286 rSettings)
1292 boost::shared_ptr<OGLTransitionImpl> makeFadeSmoothly()
1294 Primitive Slide;
1296 Slide.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
1297 Slide.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
1298 Primitives_t aLeavingSlide;
1299 aLeavingSlide.push_back (Slide);
1300 Primitives_t aEnteringSlide;
1301 aEnteringSlide.push_back (Slide);
1303 TransitionSettings aSettings;
1304 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
1306 return makeFadeSmoothlyTransition(aLeavingSlide, aEnteringSlide, aSettings);
1309 namespace
1312 class FadeThroughBlackTransition : public OGLTransitionImpl
1314 public:
1315 FadeThroughBlackTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1316 : OGLTransitionImpl(rScene, rSettings)
1319 private:
1320 virtual void displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) SAL_OVERRIDE;
1323 void FadeThroughBlackTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
1325 CHECK_GL_ERROR();
1326 applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
1328 glDisable(GL_DEPTH_TEST);
1330 glDisable(GL_LIGHTING);
1331 glEnable(GL_BLEND);
1332 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1333 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1334 if( nTime < 0.5 ) {
1335 glColor4f( 1, 1, 1, 1 - nTime*2 );
1336 displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
1337 } else {
1338 glColor4f( 1, 1, 1, (nTime - 0.5)*2 );
1339 displaySlide( nTime, glEnteringSlideTex, getScene().getEnteringSlide(), SlideWidthScale, SlideHeightScale );
1341 glDisable(GL_BLEND);
1342 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1343 glEnable(GL_LIGHTING);
1345 glEnable(GL_DEPTH_TEST);
1346 CHECK_GL_ERROR();
1349 shared_ptr<OGLTransitionImpl>
1350 makeFadeThroughBlackTransition(
1351 const Primitives_t& rLeavingSlidePrimitives,
1352 const Primitives_t& rEnteringSlidePrimitives,
1353 const TransitionSettings& rSettings)
1355 return make_shared<FadeThroughBlackTransition>(
1356 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
1357 rSettings)
1363 boost::shared_ptr<OGLTransitionImpl> makeFadeThroughBlack()
1365 Primitive Slide;
1367 Slide.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
1368 Slide.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
1369 Primitives_t aLeavingSlide;
1370 aLeavingSlide.push_back (Slide);
1371 Primitives_t aEnteringSlide;
1372 aEnteringSlide.push_back (Slide);
1374 TransitionSettings aSettings;
1375 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
1377 return makeFadeThroughBlackTransition(aLeavingSlide, aEnteringSlide, aSettings);
1380 namespace
1383 class ShaderTransition : public OGLTransitionImpl
1385 protected:
1386 ShaderTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1387 : OGLTransitionImpl(rScene, rSettings)
1388 , m_nProgramObject(0)
1389 , m_nHelperTexture(0)
1392 private:
1393 virtual void displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) SAL_OVERRIDE;
1394 virtual void prepareTransition( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex ) SAL_OVERRIDE;
1395 virtual void finishTransition() SAL_OVERRIDE;
1396 virtual GLuint makeShader() = 0;
1398 void impl_preparePermShader();
1400 private:
1401 /** GLSL program object
1403 GLuint m_nProgramObject;
1405 /** various data */
1406 GLuint m_nHelperTexture;
1409 void ShaderTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
1410 double SlideWidthScale, double SlideHeightScale )
1412 CHECK_GL_ERROR();
1413 applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
1415 if( m_nProgramObject ) {
1416 GLint location = glGetUniformLocation( m_nProgramObject, "time" );
1417 if( location != -1 ) {
1418 glUniform1f( location, nTime );
1422 glActiveTexture( GL_TEXTURE2 );
1423 glBindTexture( GL_TEXTURE_2D, glEnteringSlideTex );
1424 glActiveTexture( GL_TEXTURE0 );
1426 displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
1427 CHECK_GL_ERROR();
1430 void ShaderTransition::prepareTransition( ::sal_Int32 /* glLeavingSlideTex */, ::sal_Int32 /* glEnteringSlideTex */ )
1432 m_nProgramObject = makeShader();
1434 impl_preparePermShader();
1437 void ShaderTransition::finishTransition()
1439 CHECK_GL_ERROR();
1440 if( m_nProgramObject ) {
1441 glDeleteProgram( m_nProgramObject );
1442 m_nProgramObject = 0;
1444 if ( m_nHelperTexture )
1446 glDeleteTextures( 1, &m_nHelperTexture );
1447 m_nHelperTexture = 0;
1449 CHECK_GL_ERROR();
1452 int permutation256 [256]= {
1453 215, 100, 200, 204, 233, 50, 85, 196,
1454 71, 141, 122, 160, 93, 131, 243, 234,
1455 162, 183, 36, 155, 4, 62, 35, 205,
1456 40, 102, 33, 27, 255, 55, 214, 156,
1457 75, 163, 134, 126, 249, 74, 197, 228,
1458 72, 90, 206, 235, 17, 22, 49, 169,
1459 227, 89, 16, 5, 117, 60, 248, 230,
1460 217, 68, 138, 96, 194, 170, 136, 10,
1461 112, 238, 184, 189, 176, 42, 225, 212,
1462 84, 58, 175, 244, 150, 168, 219, 236,
1463 101, 208, 123, 37, 164, 110, 158, 201,
1464 78, 114, 57, 48, 70, 142, 106, 43,
1465 232, 26, 32, 252, 239, 98, 191, 94,
1466 59, 149, 39, 187, 203, 190, 19, 13,
1467 133, 45, 61, 247, 23, 34, 20, 52,
1468 118, 209, 146, 193, 222, 18, 1, 152,
1469 46, 41, 91, 148, 115, 25, 135, 77,
1470 254, 147, 224, 161, 9, 213, 223, 250,
1471 231, 251, 127, 166, 63, 179, 81, 130,
1472 139, 28, 120, 151, 241, 86, 111, 0,
1473 88, 153, 172, 182, 159, 105, 178, 47,
1474 51, 167, 65, 66, 92, 73, 198, 211,
1475 245, 195, 31, 220, 140, 76, 221, 186,
1476 154, 185, 56, 83, 38, 165, 109, 67,
1477 124, 226, 132, 53, 229, 29, 12, 181,
1478 121, 24, 207, 199, 177, 113, 30, 80,
1479 3, 97, 188, 79, 216, 173, 8, 145,
1480 87, 128, 180, 237, 240, 137, 125, 104,
1481 15, 242, 119, 246, 103, 143, 95, 144,
1482 2, 44, 69, 157, 192, 174, 14, 54,
1483 218, 82, 64, 210, 11, 6, 129, 21,
1484 116, 171, 99, 202, 7, 107, 253, 108
1487 void initPermTexture(GLuint *texID)
1489 CHECK_GL_ERROR();
1490 glGenTextures(1, texID);
1491 glBindTexture(GL_TEXTURE_2D, *texID);
1493 static bool initialized = false;
1494 static unsigned char permutation2D[256*256*4];
1495 if( !initialized ) {
1496 int x, y;
1498 for( y=0; y < 256; y++ )
1499 for( x=0; x < 256; x++ )
1500 permutation2D[x*4 + y*1024] = permutation256[(y + permutation256[x]) & 0xff];
1502 initialized = true;
1505 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, permutation2D );
1506 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
1507 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1508 CHECK_GL_ERROR();
1511 void ShaderTransition::impl_preparePermShader()
1513 CHECK_GL_ERROR();
1514 if( m_nProgramObject ) {
1515 glUseProgram( m_nProgramObject );
1517 GLint location = glGetUniformLocation( m_nProgramObject, "leavingSlideTexture" );
1518 if( location != -1 ) {
1519 glUniform1i( location, 0 ); // texture unit 0
1522 glActiveTexture(GL_TEXTURE1);
1523 if( !m_nHelperTexture )
1524 initPermTexture( &m_nHelperTexture );
1525 glActiveTexture(GL_TEXTURE0);
1527 location = glGetUniformLocation( m_nProgramObject, "permTexture" );
1528 if( location != -1 ) {
1529 glUniform1i( location, 1 ); // texture unit 1
1532 location = glGetUniformLocation( m_nProgramObject, "enteringSlideTexture" );
1533 if( location != -1 ) {
1534 glUniform1i( location, 2 ); // texture unit 2
1537 CHECK_GL_ERROR();
1542 namespace
1545 class StaticNoiseTransition : public ShaderTransition
1547 public:
1548 StaticNoiseTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1549 : ShaderTransition(rScene, rSettings)
1552 private:
1553 virtual GLuint makeShader() SAL_OVERRIDE;
1556 GLuint StaticNoiseTransition::makeShader()
1558 return OpenGLHelper::LoadShaders( "basicVertexShader", "staticFragmentShader" );
1561 shared_ptr<OGLTransitionImpl>
1562 makeStaticNoiseTransition(
1563 const Primitives_t& rLeavingSlidePrimitives,
1564 const Primitives_t& rEnteringSlidePrimitives,
1565 const TransitionSettings& rSettings)
1567 return make_shared<StaticNoiseTransition>(
1568 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
1569 rSettings)
1575 boost::shared_ptr<OGLTransitionImpl> makeStatic()
1577 Primitive Slide;
1579 Slide.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
1580 Slide.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
1581 Primitives_t aLeavingSlide;
1582 aLeavingSlide.push_back (Slide);
1583 Primitives_t aEnteringSlide;
1584 aEnteringSlide.push_back (Slide);
1586 TransitionSettings aSettings;
1587 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
1588 aSettings.mnRequiredGLVersion = 2.0;
1590 return makeStaticNoiseTransition(aLeavingSlide, aEnteringSlide, aSettings);
1593 namespace
1596 class DissolveTransition : public ShaderTransition
1598 public:
1599 DissolveTransition(const TransitionScene& rScene, const TransitionSettings& rSettings)
1600 : ShaderTransition(rScene, rSettings)
1603 private:
1604 virtual GLuint makeShader() SAL_OVERRIDE;
1607 GLuint DissolveTransition::makeShader()
1609 return OpenGLHelper::LoadShaders( "basicVertexShader", "dissolveFragmentShader" );
1612 shared_ptr<OGLTransitionImpl>
1613 makeDissolveTransition(
1614 const Primitives_t& rLeavingSlidePrimitives,
1615 const Primitives_t& rEnteringSlidePrimitives,
1616 const TransitionSettings& rSettings)
1618 return make_shared<DissolveTransition>(
1619 TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
1620 rSettings)
1626 boost::shared_ptr<OGLTransitionImpl> makeDissolve()
1628 Primitive Slide;
1630 Slide.pushTriangle (glm::vec2 (0,0), glm::vec2 (1,0), glm::vec2 (0,1));
1631 Slide.pushTriangle (glm::vec2 (1,0), glm::vec2 (0,1), glm::vec2 (1,1));
1632 Primitives_t aLeavingSlide;
1633 aLeavingSlide.push_back (Slide);
1634 Primitives_t aEnteringSlide;
1635 aEnteringSlide.push_back (Slide);
1637 TransitionSettings aSettings;
1638 aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
1639 aSettings.mnRequiredGLVersion = 2.0;
1641 return makeDissolveTransition(aLeavingSlide, aEnteringSlide, aSettings);
1644 boost::shared_ptr<OGLTransitionImpl> makeNewsflash()
1646 Primitive Slide;
1648 Slide.pushTriangle(glm::vec2(0,0),glm::vec2(1,0),glm::vec2(0,1));
1649 Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
1650 Slide.Operations.push_back(makeSRotate(glm::vec3(0,0,1),glm::vec3(0,0,0),3000,true,0,0.5));
1651 Slide.Operations.push_back(makeSScale(glm::vec3(0.01,0.01,0.01),glm::vec3(0,0,0),true,0,0.5));
1652 Slide.Operations.push_back(makeSTranslate(glm::vec3(-10000, 0, 0),false, 0.5, 2));
1653 Primitives_t aLeavingSlide;
1654 aLeavingSlide.push_back(Slide);
1656 Slide.Operations.clear();
1657 Slide.Operations.push_back(makeSRotate(glm::vec3(0,0,1),glm::vec3(0,0,0),-3000,true,0.5,1));
1658 Slide.Operations.push_back(makeSTranslate(glm::vec3(-100, 0, 0),false, -1, 1));
1659 Slide.Operations.push_back(makeSTranslate(glm::vec3(100, 0, 0),false, 0.5, 1));
1660 Slide.Operations.push_back(makeSScale(glm::vec3(0.01,0.01,0.01),glm::vec3(0,0,0),false,-1,1));
1661 Slide.Operations.push_back(makeSScale(glm::vec3(100,100,100),glm::vec3(0,0,0),true,0.5,1));
1662 Primitives_t aEnteringSlide;
1663 aEnteringSlide.push_back(Slide);
1665 Operations_t aOverallOperations;
1666 aOverallOperations.push_back(makeSRotate(glm::vec3(0,0,1),glm::vec3(0.2,0.2,0),1080,true,0,1));
1668 return makeSimpleTransition(aLeavingSlide, aEnteringSlide, aOverallOperations);
1671 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */