LCOV - code coverage report
Current view: top level - slideshow/source/engine/OGLTrans/unx - OGLTrans_TransitionImpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 767 0.0 %
Date: 2012-08-25 Functions: 0 74 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2008 by Sun Microsystems, Inc.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      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.
      15                 :            :  *
      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).
      21                 :            :  *
      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.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "OGLTrans_TransitionImpl.hxx"
      30                 :            : #include "OGLTrans_Shaders.hxx"
      31                 :            : #include <GL/gl.h>
      32                 :            : #include <math.h>
      33                 :            : 
      34                 :            : 
      35                 :          0 : void OGLTransitionImpl::clear()
      36                 :            : {
      37                 :          0 :     for(unsigned int i( 0 ); i < OverallOperations.size(); ++i)
      38                 :          0 :         delete OverallOperations[i];
      39                 :          0 :     OverallOperations.clear();
      40                 :          0 :     maLeavingSlidePrimitives.clear();
      41                 :          0 :     maEnteringSlidePrimitives.clear();
      42                 :          0 :     for(unsigned int i(0); i < maSceneObjects.size(); ++i)
      43                 :          0 :         delete maSceneObjects[i];
      44                 :          0 :     maSceneObjects.clear();
      45                 :            : 
      46                 :          0 :     mbReflectSlides = false;
      47                 :            : 
      48                 :            : #ifdef GL_VERSION_2_0
      49                 :          0 :     if( mProgramObject ) {
      50                 :          0 :         OGLShaders::glDeleteProgram( mProgramObject );
      51                 :          0 :         mProgramObject = 0;
      52                 :            :     }
      53                 :            : 
      54                 :          0 :     if( mVertexObject ) {
      55                 :          0 :         OGLShaders::glDeleteShader( mVertexObject );
      56                 :          0 :         mVertexObject = 0;
      57                 :            :     }
      58                 :            : 
      59                 :          0 :     if( mFragmentObject ) {
      60                 :          0 :         OGLShaders::glDeleteShader( mFragmentObject );
      61                 :          0 :         mFragmentObject = 0;
      62                 :            :     }
      63                 :            : #endif
      64                 :            : 
      65                 :          0 :     if( maHelperTexture ) {
      66                 :          0 :         glDeleteTextures( 1, &maHelperTexture );
      67                 :          0 :         maHelperTexture = 0;
      68                 :            :     }
      69                 :            : 
      70                 :          0 :     if( mmClearTransition )
      71                 :          0 :         (this->*mmClearTransition)();
      72                 :          0 : }
      73                 :            : 
      74                 :          0 : OGLTransitionImpl::~OGLTransitionImpl()
      75                 :            : {
      76                 :          0 :     clear();
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : void OGLTransitionImpl::prepare( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex )
      80                 :            : {
      81                 :          0 :     for(unsigned int i(0); i < maSceneObjects.size(); ++i) {
      82                 :          0 :         maSceneObjects[i]->prepare();
      83                 :            :     }
      84                 :            : 
      85                 :          0 :     if( mmPrepareTransition )
      86                 :          0 :         (this->*mmPrepareTransition)( glLeavingSlideTex, glEnteringSlideTex );
      87                 :          0 : }
      88                 :            : 
      89                 :          0 : void OGLTransitionImpl::finish()
      90                 :            : {
      91                 :          0 :     for(unsigned int i(0); i < maSceneObjects.size(); ++i) {
      92                 :          0 :         maSceneObjects[i]->finish();
      93                 :            :     }
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : static void blendSlide( double depth )
      97                 :            : {
      98                 :          0 :     double showHeight = -1 + depth*2;
      99                 :          0 :     GLfloat reflectionColor[] = {0, 0, 0, 0.25};
     100                 :            : 
     101                 :          0 :     glDisable( GL_DEPTH_TEST );
     102                 :          0 :     glBegin( GL_QUADS );
     103                 :          0 :     glColor4fv( reflectionColor );
     104                 :          0 :     glVertex3f( -1, -1, 0 );
     105                 :          0 :     glColor4f( 0, 0, 0, 1 );
     106                 :          0 :     glVertex3f(-1,  showHeight, 0 );
     107                 :          0 :     glVertex3f( 1,  showHeight, 0 );
     108                 :          0 :     glColor4fv( reflectionColor );
     109                 :          0 :     glVertex3f( 1, -1, 0 );
     110                 :          0 :     glEnd();
     111                 :            : 
     112                 :          0 :     glBegin( GL_QUADS );
     113                 :          0 :     glColor4f( 0, 0, 0, 1 );
     114                 :          0 :     glVertex3f( -1, showHeight, 0 );
     115                 :          0 :     glVertex3f( -1,  1, 0 );
     116                 :          0 :     glVertex3f(  1,  1, 0 );
     117                 :          0 :     glVertex3f(  1, showHeight, 0 );
     118                 :          0 :     glEnd();
     119                 :          0 :     glEnable( GL_DEPTH_TEST );
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : static void slideShadow( double nTime, Primitive& primitive, double sw, double sh )
     123                 :            : {
     124                 :          0 :     double reflectionDepth = 0.3;
     125                 :            : 
     126                 :          0 :     glEnable(GL_BLEND);
     127                 :          0 :     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     128                 :          0 :     glDisable(GL_LIGHTING);
     129                 :            : 
     130                 :          0 :     glPushMatrix();
     131                 :          0 :     primitive.applyOperations( nTime, sw, sh );
     132                 :          0 :     blendSlide( reflectionDepth );
     133                 :          0 :     glPopMatrix();
     134                 :            : 
     135                 :          0 :     glDisable(GL_BLEND);
     136                 :          0 :     glEnable(GL_LIGHTING);
     137                 :          0 : }
     138                 :            : 
     139                 :          0 : void OGLTransitionImpl::display( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
     140                 :            :                                  double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
     141                 :            : {
     142                 :            :     double SlideWidthScale, SlideHeightScale;
     143                 :            : 
     144                 :          0 :     SlideWidthScale = SlideWidth/DispWidth;
     145                 :          0 :     SlideHeightScale = SlideHeight/DispHeight;
     146                 :            : 
     147                 :          0 :     if( mmPrepare ) {
     148                 :          0 :         clear();
     149                 :          0 :         (this->*mmPrepare)( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight );
     150                 :            :     }
     151                 :            : 
     152                 :          0 :     glPushMatrix();
     153                 :          0 :     displaySlides( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale );
     154                 :          0 :     displayScene( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight );
     155                 :          0 :     glPopMatrix();
     156                 :          0 : }
     157                 :            : 
     158                 :          0 : void OGLTransitionImpl::applyOverallOperations( double nTime, double SlideWidthScale, double SlideHeightScale )
     159                 :            : {
     160                 :          0 :     for(unsigned int i(0); i < OverallOperations.size(); ++i)
     161                 :          0 :         OverallOperations[i]->interpolate(nTime,SlideWidthScale,SlideHeightScale);
     162                 :          0 : }
     163                 :            : 
     164                 :          0 : void OGLTransitionImpl::displaySlide( double nTime, ::sal_Int32 glSlideTex, std::vector<Primitive>& primitives,
     165                 :            :                                       double SlideWidthScale, double SlideHeightScale )
     166                 :            : {
     167                 :            :    //TODO change to foreach
     168                 :          0 :     glBindTexture(GL_TEXTURE_2D, glSlideTex);
     169                 :            : 
     170                 :            :     // display slide reflection
     171                 :            :     // note that depth test is turned off while blending the shadow
     172                 :            :     // so the slides has to be rendered in right order, see rochade as example
     173                 :          0 :     if( mbReflectSlides ) {
     174                 :          0 :         double surfaceLevel = -0.04;
     175                 :            : 
     176                 :            :         /* reflected slides */
     177                 :          0 :         glPushMatrix();
     178                 :            : 
     179                 :          0 :         glScaled( 1, -1, 1 );
     180                 :          0 :         glTranslated( 0, 2 - surfaceLevel, 0 );
     181                 :            : 
     182                 :          0 :         glCullFace(GL_FRONT);
     183                 :          0 :         for(unsigned int i(0); i < primitives.size(); ++i)
     184                 :          0 :             primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
     185                 :          0 :         glCullFace(GL_BACK);
     186                 :            : 
     187                 :          0 :         slideShadow( nTime, primitives[0], SlideWidthScale, SlideHeightScale );
     188                 :            : 
     189                 :          0 :         glPopMatrix();
     190                 :            :     }
     191                 :            : 
     192                 :          0 :     for(unsigned int i(0); i < primitives.size(); ++i)
     193                 :          0 :         primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
     194                 :          0 : }
     195                 :            : 
     196                 :          0 : void OGLTransitionImpl::displaySlides( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
     197                 :            :                                        double SlideWidthScale, double SlideHeightScale )
     198                 :            : {
     199                 :          0 :     if( mmDisplaySlides )
     200                 :          0 :         (this->*mmDisplaySlides)( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale );
     201                 :            :     else {
     202                 :          0 :         applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
     203                 :            : 
     204                 :          0 :         glEnable(GL_TEXTURE_2D);
     205                 :          0 :         displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
     206                 :          0 :         displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
     207                 :            :     }
     208                 :          0 : }
     209                 :            : 
     210                 :          0 : void OGLTransitionImpl::displayScene( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
     211                 :            : {
     212                 :          0 :     glEnable(GL_TEXTURE_2D);
     213                 :          0 :     for(unsigned int i(0); i < maSceneObjects.size(); ++i)
     214                 :          0 :         maSceneObjects[i]->display(nTime, SlideWidth, SlideHeight, DispWidth, DispHeight);
     215                 :          0 : }
     216                 :            : 
     217                 :          0 : void Primitive::display(double nTime, double WidthScale, double HeightScale)
     218                 :            : {
     219                 :          0 :     glPushMatrix();
     220                 :            : 
     221                 :          0 :     applyOperations( nTime, WidthScale, HeightScale );
     222                 :            : 
     223                 :          0 :     glEnableClientState( GL_VERTEX_ARRAY );
     224                 :          0 :     if(!Normals.empty())
     225                 :            :     {
     226                 :          0 :         glNormalPointer( GL_DOUBLE , 0 , &Normals[0] );
     227                 :          0 :         glEnableClientState( GL_NORMAL_ARRAY );
     228                 :            :     }
     229                 :          0 :     glEnableClientState( GL_TEXTURE_COORD_ARRAY );
     230                 :          0 :     glTexCoordPointer( 2, GL_DOUBLE, 0, &TexCoords[0] );
     231                 :          0 :     glVertexPointer( 3, GL_DOUBLE, 0, &Vertices[0] );
     232                 :          0 :     glDrawArrays( GL_TRIANGLES, 0, Vertices.size() );
     233                 :          0 :     glPopMatrix();
     234                 :          0 : }
     235                 :            : 
     236                 :          0 : void Primitive::applyOperations(double nTime, double WidthScale, double HeightScale)
     237                 :            : {
     238                 :          0 :     for(unsigned int i(0); i < Operations.size(); ++i)
     239                 :          0 :         Operations[i]->interpolate( nTime ,WidthScale,HeightScale);
     240                 :          0 :     glScaled(WidthScale,HeightScale,1);
     241                 :          0 : }
     242                 :            : 
     243                 :          0 : Primitive::~Primitive()
     244                 :            : {
     245                 :          0 :     for(unsigned int i( 0 ); i < Operations.size(); ++i)
     246                 :          0 :         delete Operations[i];
     247                 :          0 : }
     248                 :            : 
     249                 :            : 
     250                 :          0 : void SceneObject::display(double nTime, double /* SlideWidth */, double /* SlideHeight */, double DispWidth, double DispHeight )
     251                 :            : {
     252                 :          0 :     for(unsigned int i(0); i < maPrimitives.size(); ++i) {
     253                 :            :         // fixme: allow various model spaces, now we make it so that
     254                 :            :         // it is regular -1,-1 to 1,1, where the whole display fits in
     255                 :          0 :         glPushMatrix();
     256                 :          0 :         if (DispHeight > DispWidth)
     257                 :          0 :             glScaled(DispHeight/DispWidth, 1, 1);
     258                 :            :         else
     259                 :          0 :             glScaled(1, DispWidth/DispHeight, 1);
     260                 :          0 :         maPrimitives[i].display(nTime, 1, 1);
     261                 :          0 :         glPopMatrix();
     262                 :            :     }
     263                 :          0 : }
     264                 :            : 
     265                 :          0 : void SceneObject::pushPrimitive(const Primitive &p)
     266                 :            : {
     267                 :          0 :     maPrimitives.push_back(p);
     268                 :          0 : }
     269                 :            : 
     270                 :          0 : SceneObject::SceneObject()
     271                 :          0 :     : maPrimitives()
     272                 :            : {
     273                 :          0 : }
     274                 :            : 
     275                 :          0 : SceneObject::~SceneObject()
     276                 :            : {
     277                 :          0 : }
     278                 :            : 
     279                 :          0 : Iris::Iris()
     280                 :          0 :     : SceneObject ()
     281                 :            : {
     282                 :          0 : }
     283                 :            : 
     284                 :          0 : void Iris::display(double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
     285                 :            : {
     286                 :          0 :     glBindTexture(GL_TEXTURE_2D, maTexture);
     287                 :          0 :     SceneObject::display(nTime, SlideWidth, SlideHeight, DispWidth, DispHeight);
     288                 :          0 : }
     289                 :            : 
     290                 :          0 : void Iris::prepare()
     291                 :            : {
     292                 :            :     static GLubyte img[3] = { 80, 80, 80 };
     293                 :            : 
     294                 :          0 :     glGenTextures(1, &maTexture);
     295                 :          0 :     glBindTexture(GL_TEXTURE_2D, maTexture);
     296                 :          0 :     glTexImage2D(GL_TEXTURE_2D, 0, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, img);
     297                 :          0 :     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
     298                 :          0 :     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
     299                 :          0 :     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
     300                 :          0 :     glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
     301                 :          0 : }
     302                 :            : 
     303                 :          0 : void Iris::finish()
     304                 :            : {
     305                 :          0 :     glDeleteTextures(1, &maTexture);
     306                 :          0 : }
     307                 :            : 
     308                 :          0 : void OGLTransitionImpl::makeOutsideCubeFaceToLeft()
     309                 :            : {
     310                 :          0 :     clear();
     311                 :          0 :     Primitive Slide;
     312                 :            : 
     313                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     314                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     315                 :            : 
     316                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     317                 :            : 
     318                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,-1),90,false,0.0,1.0));
     319                 :            : 
     320                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     321                 :            : 
     322                 :          0 :     OverallOperations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,-1),-90,true,0.0,1.0));
     323                 :          0 : }
     324                 :            : 
     325                 :          0 : void OGLTransitionImpl::makeInsideCubeFaceToLeft()
     326                 :            : {
     327                 :          0 :     clear();
     328                 :          0 :     Primitive Slide;
     329                 :            : 
     330                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     331                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     332                 :            : 
     333                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     334                 :            : 
     335                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,1),-90,false,0.0,1.0));
     336                 :            : 
     337                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     338                 :            : 
     339                 :          0 :     OverallOperations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,1),90,true,0.0,1.0));
     340                 :          0 : }
     341                 :            : 
     342                 :          0 : void OGLTransitionImpl::makeFallLeaving()
     343                 :            : {
     344                 :          0 :     clear();
     345                 :          0 :     Primitive Slide;
     346                 :            : 
     347                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     348                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     349                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     350                 :            : 
     351                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(1,0,0),basegfx::B3DVector(0,-1,0), 90,true,0.0,1.0));
     352                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     353                 :            : 
     354                 :          0 :     mbUseMipMapEntering = false;
     355                 :          0 : }
     356                 :            : 
     357                 :          0 : void OGLTransitionImpl::makeTurnAround()
     358                 :            : {
     359                 :          0 :     clear();
     360                 :          0 :     Primitive Slide;
     361                 :            : 
     362                 :          0 :     mbReflectSlides = true;
     363                 :            : 
     364                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     365                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     366                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     367                 :            : 
     368                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0),-180,false,0.0,1.0));
     369                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     370                 :            : 
     371                 :          0 :     OverallOperations.push_back(new STranslate(basegfx::B3DVector(0, 0, -1.5),true, 0, 0.5));
     372                 :          0 :     OverallOperations.push_back(new STranslate(basegfx::B3DVector(0, 0, 1.5), true, 0.5, 1));
     373                 :          0 :     OverallOperations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0, 1, 0),basegfx::B3DVector(0, 0, 0), -180, true, 0.0, 1.0));
     374                 :          0 : }
     375                 :            : 
     376                 :          0 : void OGLTransitionImpl::makeTurnDown()
     377                 :            : {
     378                 :          0 :     clear();
     379                 :          0 :     Primitive Slide;
     380                 :            : 
     381                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     382                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     383                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     384                 :            : 
     385                 :          0 :     Slide.Operations.push_back(new STranslate(basegfx::B3DVector(0, 0, 0.0001), false, -1.0, 0.0));
     386                 :          0 :     Slide.Operations.push_back(new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(-1, 1, 0), -90, true, 0.0, 1.0));
     387                 :          0 :     Slide.Operations.push_back(new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(-1, 1, 0), 90, false, -1.0, 0.0));
     388                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     389                 :            : 
     390                 :          0 :     mbUseMipMapLeaving = false;
     391                 :          0 : }
     392                 :            : 
     393                 :          0 : void OGLTransitionImpl::makeIris()
     394                 :            : {
     395                 :          0 :     clear();
     396                 :          0 :     Primitive Slide;
     397                 :            : 
     398                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
     399                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
     400                 :          0 :     maEnteringSlidePrimitives.push_back (Slide);
     401                 :            : 
     402                 :          0 :     Slide.Operations.push_back (new STranslate (basegfx::B3DVector (0, 0,  0.000001), false, -1, 0));
     403                 :          0 :     Slide.Operations.push_back (new STranslate (basegfx::B3DVector (0, 0, -0.000002), false, 0.5, 1));
     404                 :          0 :     maLeavingSlidePrimitives.push_back (Slide);
     405                 :            : 
     406                 :            : 
     407                 :          0 :     Primitive irisPart, part;
     408                 :          0 :     int i, nSteps = 24, nParts = 7;
     409                 :          0 :     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;
     410                 :            : 
     411                 :          0 :     for (i=1; i<=nSteps; i++) {
     412                 :          0 :         x = cos ((3*2*M_PI*t)/nParts);
     413                 :          0 :         y = -sin ((3*2*M_PI*t)/nParts);
     414                 :          0 :         cx = (f*x + 1)/2;
     415                 :          0 :         cy = (f*y + 1)/2;
     416                 :          0 :         lcx = (f*lx + 1)/2;
     417                 :          0 :         lcy = (f*ly + 1)/2;
     418                 :          0 :         cxo = (of*x + 1)/2;
     419                 :          0 :         cyo = (of*y + 1)/2;
     420                 :          0 :         lcxo = (of*lx + 1)/2;
     421                 :          0 :         lcyo = (of*ly + 1)/2;
     422                 :            :         irisPart.pushTriangle (basegfx::B2DVector (lcx, lcy),
     423                 :            :                                basegfx::B2DVector (lcxo, lcyo),
     424                 :          0 :                                basegfx::B2DVector (cx, cy));
     425                 :            :         irisPart.pushTriangle (basegfx::B2DVector (cx, cy),
     426                 :            :                                basegfx::B2DVector (lcxo, lcyo),
     427                 :          0 :                                basegfx::B2DVector (cxo, cyo));
     428                 :          0 :         lx = x;
     429                 :          0 :         ly = y;
     430                 :          0 :         t += 1.0/nSteps;
     431                 :            :     }
     432                 :            : 
     433                 :          0 :     Iris* pIris = new Iris();
     434                 :          0 :     double angle = 87;
     435                 :            : 
     436                 :          0 :     for (i = 0; i < nParts; i++) {
     437                 :          0 :         irisPart.Operations.clear ();
     438                 :            :         double rx, ry;
     439                 :            : 
     440                 :          0 :         rx = cos ((2*M_PI*i)/nParts);
     441                 :          0 :         ry = sin ((2*M_PI*i)/nParts);
     442                 :          0 :         irisPart.Operations.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(rx, ry, 0),  angle, true, 0.0, 0.5));
     443                 :          0 :         irisPart.Operations.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(rx, ry, 0), -angle, true, 0.5, 1));
     444                 :          0 :         if (i > 0) {
     445                 :          0 :             irisPart.Operations.push_back (new STranslate (basegfx::B3DVector(rx, ry, 0),  false, -1, 0));
     446                 :          0 :             irisPart.Operations.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(0, 0, 0), i*360.0/nParts, false, -1, 0));
     447                 :          0 :             irisPart.Operations.push_back (new STranslate (basegfx::B3DVector(-1, 0, 0),  false, -1, 0));
     448                 :            :         }
     449                 :          0 :         irisPart.Operations.push_back(new STranslate(basegfx::B3DVector(0, 0, 1), false, -2, 0.0));
     450                 :          0 :         irisPart.Operations.push_back (new SRotate (basegfx::B3DVector(1, .5, 0), basegfx::B3DVector(1, 0, 0), -30, false, -1, 0));
     451                 :          0 :         pIris->pushPrimitive (irisPart);
     452                 :            :     }
     453                 :            : 
     454                 :          0 :     maSceneObjects.push_back (pIris);
     455                 :            : 
     456                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
     457                 :          0 : }
     458                 :            : 
     459                 :          0 : void OGLTransitionImpl::displaySlidesRochade( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
     460                 :            :                           double SlideWidthScale, double SlideHeightScale )
     461                 :            : {
     462                 :          0 :     applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
     463                 :            : 
     464                 :          0 :     glEnable(GL_TEXTURE_2D);
     465                 :            : 
     466                 :          0 :     if( nTime > .5) {
     467                 :          0 :         displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
     468                 :          0 :         displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
     469                 :            :     } else {
     470                 :          0 :         displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
     471                 :          0 :         displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
     472                 :            :     }
     473                 :          0 : }
     474                 :            : 
     475                 :          0 : void OGLTransitionImpl::makeRochade()
     476                 :            : {
     477                 :          0 :     clear();
     478                 :          0 :     Primitive Slide;
     479                 :            : 
     480                 :          0 :     mbReflectSlides = true;
     481                 :          0 :     mmDisplaySlides = &OGLTransitionImpl::displaySlidesRochade;
     482                 :            : 
     483                 :            :     double w, h;
     484                 :            : 
     485                 :          0 :     w = 2.2;
     486                 :          0 :     h = 10;
     487                 :            : 
     488                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
     489                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
     490                 :            : 
     491                 :          0 :     Slide.Operations.push_back(new SEllipseTranslate(w, h, 0.25, -0.25, true, 0, 1));
     492                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), -45, true, 0, 1));
     493                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
     494                 :            : 
     495                 :          0 :     Slide.Operations.clear();
     496                 :          0 :     Slide.Operations.push_back(new SEllipseTranslate(w, h, 0.75, 0.25, true, 0, 1));
     497                 :          0 :     Slide.Operations.push_back(new STranslate(basegfx::B3DVector(0, 0, -h), false, -1, 0));
     498                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), -45, true, 0, 1));
     499                 :          0 :     Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), 45, false, -1, 0));
     500                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
     501                 :            : 
     502                 :          0 : }
     503                 :            : 
     504                 :            : // TODO(Q3): extract to basegfx
     505                 :          0 : inline basegfx::B2DVector clamp(const basegfx::B2DVector& v)
     506                 :            : {
     507                 :          0 :     return basegfx::B2DVector(min(max(v.getX(),-1.0),1.0),
     508                 :          0 :                               min(max(v.getY(),-1.0),1.0));
     509                 :            : }
     510                 :            : 
     511                 :            : // TODO(Q3): extract to basegfx
     512                 :            : inline basegfx::B3DVector clamp(const basegfx::B3DVector& v)
     513                 :            : {
     514                 :            :     return basegfx::B3DVector(min(max(v.getX(),-1.0),1.0),
     515                 :            :                               min(max(v.getY(),-1.0),1.0),
     516                 :            :                               min(max(v.getZ(),-1.0),1.0));
     517                 :            : }
     518                 :            : 
     519                 :          0 : inline double randFromNeg1to1()
     520                 :            : {
     521                 :          0 :     return ( ( static_cast<double>( rand() ) / static_cast<double>( RAND_MAX ) ) * 2.0 ) - 1.0;
     522                 :            : }
     523                 :            : 
     524                 :            : // TODO(Q3): extract to basegfx
     525                 :          0 : inline basegfx::B3DVector randNormVectorInXYPlane()
     526                 :            : {
     527                 :          0 :     basegfx::B3DVector toReturn(randFromNeg1to1(),randFromNeg1to1(),0.0);
     528                 :          0 :     return toReturn/toReturn.getLength();
     529                 :            : }
     530                 :            : 
     531                 :          0 : void OGLTransitionImpl::makeRevolvingCircles( ::sal_uInt16 nCircles , ::sal_uInt16 nPointsOnCircles )
     532                 :            : {
     533                 :          0 :     clear();
     534                 :          0 :     double dAngle(2*3.1415926/static_cast<double>( nPointsOnCircles ));
     535                 :          0 :     if(nCircles < 2 || nPointsOnCircles < 4)
     536                 :            :     {
     537                 :          0 :         makeNByMTileFlip(1,1);
     538                 :          0 :         return;
     539                 :            :     }
     540                 :          0 :     double Radius(1.0/static_cast<double>( nCircles ));
     541                 :          0 :     double dRadius(Radius);
     542                 :          0 :     double LastRadius(0.0);
     543                 :          0 :     double NextRadius(2*Radius);
     544                 :            : 
     545                 :            :     /// now we know there is at least two circles
     546                 :            :     /// the first will always be a full circle
     547                 :            :     /// the last will always be the outer shell of the slide with a circle hole
     548                 :            : 
     549                 :            :     //add the full circle
     550                 :          0 :     vector<basegfx::B2DVector> unScaledTexCoords;
     551                 :          0 :     double TempAngle(0.0);
     552                 :          0 :     for(unsigned int Point(0); Point < nPointsOnCircles; ++Point)
     553                 :            :     {
     554                 :          0 :         unScaledTexCoords.push_back( basegfx::B2DVector( cos(TempAngle - 3.1415926/2.0) , sin(TempAngle- 3.1415926/2.0) ) );
     555                 :            : 
     556                 :          0 :         TempAngle += dAngle;
     557                 :            :     }
     558                 :            : 
     559                 :            :     {
     560                 :          0 :         Primitive EnteringSlide;
     561                 :          0 :         Primitive LeavingSlide;
     562                 :          0 :         for(int Point(0); Point + 1 < nPointsOnCircles; ++Point)
     563                 :            :         {
     564                 :          0 :             EnteringSlide.pushTriangle( basegfx::B2DVector( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point + 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) );
     565                 :          0 :             LeavingSlide.pushTriangle( basegfx::B2DVector( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point + 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ Point ] / 2.0 + basegfx::B2DVector( 0.5, 0.5) );
     566                 :            :         }
     567                 :          0 :         EnteringSlide.pushTriangle( basegfx::B2DVector(0.5,0.5) , Radius * unScaledTexCoords[ 0 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius * unScaledTexCoords[ nPointsOnCircles - 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) );
     568                 :          0 :         LeavingSlide.pushTriangle( basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     569                 :            : 
     570                 :          0 :         basegfx::B3DVector axis(randNormVectorInXYPlane());
     571                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
     572                 :          0 :         LeavingSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
     573                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
     574                 :            : 
     575                 :          0 :         maEnteringSlidePrimitives.push_back(EnteringSlide);
     576                 :          0 :         maLeavingSlidePrimitives.push_back(LeavingSlide);
     577                 :          0 :         LastRadius = Radius;
     578                 :          0 :         Radius = NextRadius;
     579                 :          0 :         NextRadius += dRadius;
     580                 :            :     }
     581                 :            : 
     582                 :          0 :     for(int i(1); i < nCircles - 1; ++i)
     583                 :            :     {
     584                 :          0 :         Primitive LeavingSlide;
     585                 :          0 :         Primitive EnteringSlide;
     586                 :          0 :         for(int Side(0); Side < nPointsOnCircles - 1; ++Side)
     587                 :            :         {
     588                 :          0 :             EnteringSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     589                 :          0 :             EnteringSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     590                 :            : 
     591                 :          0 :             LeavingSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     592                 :          0 :             LeavingSlide.pushTriangle(Radius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     593                 :            :         }
     594                 :            : 
     595                 :          0 :         EnteringSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     596                 :          0 :         EnteringSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     597                 :            : 
     598                 :          0 :         LeavingSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     599                 :          0 :         LeavingSlide.pushTriangle(Radius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     600                 :            : 
     601                 :          0 :         basegfx::B3DVector axis(randNormVectorInXYPlane());
     602                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
     603                 :          0 :         LeavingSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, Radius/2.0 , (NextRadius + 1)/2.0 ) );
     604                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
     605                 :            : 
     606                 :          0 :         maEnteringSlidePrimitives.push_back(EnteringSlide);
     607                 :          0 :         maLeavingSlidePrimitives.push_back(LeavingSlide);
     608                 :            : 
     609                 :          0 :         LastRadius = Radius;
     610                 :          0 :         Radius = NextRadius;
     611                 :          0 :         NextRadius += dRadius;
     612                 :          0 :     }
     613                 :            :     {
     614                 :          0 :         Radius = sqrt(2.0);
     615                 :          0 :         Primitive LeavingSlide;
     616                 :          0 :         Primitive EnteringSlide;
     617                 :          0 :         for(int Side(0); Side < nPointsOnCircles - 1; ++Side)
     618                 :            :         {
     619                 :            : 
     620                 :          0 :             EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     621                 :          0 :             EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius*unScaledTexCoords[Side + 1])/2.0 + basegfx::B2DVector(0.5,0.5) );
     622                 :            : 
     623                 :          0 :             LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
     624                 :          0 :             LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[Side])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[Side + 1]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius*unScaledTexCoords[Side + 1])/2.0 + basegfx::B2DVector(0.5,0.5) );
     625                 :            :         }
     626                 :            : 
     627                 :          0 :         EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     628                 :          0 :         EnteringSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius*unScaledTexCoords[0])/2.0 + basegfx::B2DVector(0.5,0.5) );
     629                 :            : 
     630                 :          0 :         LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[nPointsOnCircles - 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
     631                 :          0 :         LeavingSlide.pushTriangle(clamp(Radius*unScaledTexCoords[nPointsOnCircles - 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius*unScaledTexCoords[0]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius*unScaledTexCoords[0])/2.0 + basegfx::B2DVector(0.5,0.5) );
     632                 :            : 
     633                 :          0 :         basegfx::B3DVector axis(randNormVectorInXYPlane());
     634                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, (LastRadius + dRadius)/2.0 , 1.0 ) );
     635                 :          0 :         LeavingSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , 180, true, (LastRadius + dRadius)/2.0 , 1.0 ) );
     636                 :          0 :         EnteringSlide.Operations.push_back( new SRotate( axis , basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
     637                 :            : 
     638                 :          0 :         maEnteringSlidePrimitives.push_back(EnteringSlide);
     639                 :          0 :         maLeavingSlidePrimitives.push_back(LeavingSlide);
     640                 :          0 :     }
     641                 :            : }
     642                 :            : 
     643                 :          0 : void OGLTransitionImpl::makeHelix( ::sal_uInt16 nRows )
     644                 :            : {
     645                 :          0 :     clear();
     646                 :          0 :     double invN(1.0/static_cast<double>(nRows));
     647                 :          0 :     double iDn = 0.0;
     648                 :          0 :     double iPDn = invN;
     649                 :          0 :     for(unsigned int i(0); i < nRows; ++i)
     650                 :            :     {
     651                 :          0 :         Primitive Tile;
     652                 :            : 
     653                 :          0 :         Tile.pushTriangle(basegfx::B2DVector( 1.0 , iDn ) , basegfx::B2DVector( 0.0 , iDn ) , basegfx::B2DVector( 0.0 , iPDn ));
     654                 :            : 
     655                 :          0 :         Tile.pushTriangle(basegfx::B2DVector( 1.0 , iPDn ) , basegfx::B2DVector( 1.0 , iDn ) , basegfx::B2DVector( 0.0 , iPDn ));
     656                 :            : 
     657                 :          0 :         Tile.Operations.push_back( new SRotate( basegfx::B3DVector( 0 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0 , 180 ,
     658                 :          0 :                                                 true,min(max(static_cast<double>(i - nRows/2.0)*invN/2.0,0.0),1.0),
     659                 :          0 :                                                 min(max(static_cast<double>(i + nRows/2.0)*invN/2.0,0.0),1.0) ) );
     660                 :            : 
     661                 :          0 :         maLeavingSlidePrimitives.push_back(Tile);
     662                 :            : 
     663                 :          0 :         Tile.Operations.push_back( new SRotate( basegfx::B3DVector( 0 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0 , -180 , false,0.0,1.0) );
     664                 :            : 
     665                 :          0 :         maEnteringSlidePrimitives.push_back(Tile);
     666                 :            : 
     667                 :          0 :         iDn += invN;
     668                 :          0 :         iPDn += invN;
     669                 :          0 :     }
     670                 :          0 : }
     671                 :            : 
     672                 :          0 : void OGLTransitionImpl::makeNByMTileFlip( ::sal_uInt16 n, ::sal_uInt16 m )
     673                 :            : {
     674                 :          0 :     clear();
     675                 :          0 :     double invN(1.0/static_cast<double>(n));
     676                 :          0 :     double invM(1.0/static_cast<double>(m));
     677                 :          0 :     double iDn = 0.0;
     678                 :          0 :     double iPDn = invN;
     679                 :          0 :     for(unsigned int i(0); i < n; ++i)
     680                 :            :     {
     681                 :          0 :         double jDm = 0.0;
     682                 :          0 :         double jPDm = invM;
     683                 :          0 :         for(unsigned int j(0); j < m; ++j)
     684                 :            :         {
     685                 :          0 :             Primitive Tile;
     686                 :            : 
     687                 :          0 :             Tile.pushTriangle(basegfx::B2DVector( iPDn , jDm ) , basegfx::B2DVector( iDn , jDm ) , basegfx::B2DVector( iDn , jPDm ));
     688                 :            : 
     689                 :          0 :             Tile.pushTriangle(basegfx::B2DVector( iPDn , jPDm ) , basegfx::B2DVector( iPDn , jDm ) , basegfx::B2DVector( iDn , jPDm ));//bottom left corner of tile
     690                 :            : 
     691                 :          0 :             Tile.Operations.push_back( new SRotate( basegfx::B3DVector( 1 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0 , 180 , true, iDn*jDm/2.0 , ((iPDn*jPDm)+1.0)/2.0 ) );
     692                 :          0 :             maLeavingSlidePrimitives.push_back(Tile);
     693                 :          0 :             Tile.Operations.push_back( new SRotate( basegfx::B3DVector( 1 , 1 , 0 ) , ( Tile.getVertices()[1] + Tile.getVertices()[3] )/2.0 , -180, false, iDn*jDm/2.0 , ((iPDn*jPDm)+1.0)/2.0 ) );
     694                 :            : 
     695                 :          0 :             maEnteringSlidePrimitives.push_back(Tile);
     696                 :            : 
     697                 :          0 :             jDm += invM;
     698                 :          0 :             jPDm += invM;
     699                 :          0 :         }
     700                 :          0 :         iDn += invN;
     701                 :          0 :         iPDn += invN;
     702                 :            :     }
     703                 :          0 : }
     704                 :            : 
     705                 :          0 : SRotate::SRotate(const basegfx::B3DVector& Axis,const basegfx::B3DVector& Origin,double Angle, bool bInter, double T0, double T1):axis(Axis),origin(Origin),angle(Angle)
     706                 :            : {
     707                 :          0 :     nT0 = T0;
     708                 :          0 :     nT1 = T1;
     709                 :          0 :     bInterpolate = bInter;
     710                 :          0 : }
     711                 :            : 
     712                 :          0 : SScale::SScale(const basegfx::B3DVector& Scale,const basegfx::B3DVector& Origin, bool bInter, double T0, double T1):scale(Scale),origin(Origin)
     713                 :            : {
     714                 :          0 :     nT0 = T0;
     715                 :          0 :     nT1 = T1;
     716                 :          0 :     bInterpolate = bInter;
     717                 :          0 : }
     718                 :            : 
     719                 :          0 : RotateAndScaleDepthByWidth::RotateAndScaleDepthByWidth(const basegfx::B3DVector& Axis,const basegfx::B3DVector& Origin,double Angle, bool bInter, double T0, double T1):axis(Axis),origin(Origin),angle(Angle)
     720                 :            : {
     721                 :          0 :     nT0 = T0;
     722                 :          0 :     nT1 = T1;
     723                 :          0 :     bInterpolate = bInter;
     724                 :          0 : }
     725                 :            : 
     726                 :          0 : RotateAndScaleDepthByHeight::RotateAndScaleDepthByHeight(const basegfx::B3DVector& Axis,const basegfx::B3DVector& Origin,double Angle, bool bInter, double T0, double T1):axis(Axis),origin(Origin),angle(Angle)
     727                 :            : {
     728                 :          0 :     nT0 = T0;
     729                 :          0 :     nT1 = T1;
     730                 :          0 :     bInterpolate = bInter;
     731                 :          0 : }
     732                 :            : 
     733                 :            : 
     734                 :          0 : STranslate::STranslate(const basegfx::B3DVector& Vector, bool bInter, double T0, double T1):vector(Vector)
     735                 :            : {
     736                 :          0 :     nT0 = T0;
     737                 :          0 :     nT1 = T1;
     738                 :          0 :     bInterpolate = bInter;
     739                 :          0 : }
     740                 :            : 
     741                 :          0 : inline double intervalInter(double t, double T0, double T1)
     742                 :            : {
     743                 :          0 :     return ( t - T0 ) / ( T1 - T0 );
     744                 :            : }
     745                 :            : 
     746                 :          0 : void STranslate::interpolate(double t,double SlideWidthScale,double SlideHeightScale)
     747                 :            : {
     748                 :          0 :     if(t <= nT0)
     749                 :          0 :         return;
     750                 :          0 :     if(!bInterpolate || t > nT1)
     751                 :          0 :         t = nT1;
     752                 :          0 :     t = intervalInter(t,nT0,nT1);
     753                 :          0 :     glTranslated(SlideWidthScale*t*vector.getX(),SlideHeightScale*t*vector.getY(),t*vector.getZ());
     754                 :            : }
     755                 :            : 
     756                 :          0 : void SRotate::interpolate(double t,double SlideWidthScale,double SlideHeightScale)
     757                 :            : {
     758                 :          0 :     if(t <= nT0)
     759                 :          0 :         return;
     760                 :          0 :     if(!bInterpolate || t > nT1)
     761                 :          0 :         t = nT1;
     762                 :          0 :     t = intervalInter(t,nT0,nT1);
     763                 :          0 :     glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),origin.getZ());
     764                 :          0 :     glScaled(SlideWidthScale,SlideHeightScale,1);
     765                 :          0 :     glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ());
     766                 :          0 :     glScaled(1/SlideWidthScale,1/SlideHeightScale,1);
     767                 :          0 :     glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-origin.getZ());
     768                 :            : }
     769                 :            : 
     770                 :          0 : void SScale::interpolate(double t,double SlideWidthScale,double SlideHeightScale)
     771                 :            : {
     772                 :          0 :     if(t <= nT0)
     773                 :          0 :         return;
     774                 :          0 :     if(!bInterpolate || t > nT1)
     775                 :          0 :         t = nT1;
     776                 :          0 :     t = intervalInter(t,nT0,nT1);
     777                 :          0 :     glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),origin.getZ());
     778                 :          0 :     glScaled((1-t) + t*scale.getX(),(1-t) + t*scale.getY(),(1-t) + t*scale.getZ());
     779                 :          0 :     glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-origin.getZ());
     780                 :            : }
     781                 :            : 
     782                 :          0 : void RotateAndScaleDepthByWidth::interpolate(double t,double SlideWidthScale,double SlideHeightScale)
     783                 :            : {
     784                 :          0 :     if(t <= nT0)
     785                 :          0 :         return;
     786                 :          0 :     if(!bInterpolate || t > nT1)
     787                 :          0 :         t = nT1;
     788                 :          0 :     t = intervalInter(t,nT0,nT1);
     789                 :          0 :     glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),SlideWidthScale*origin.getZ());
     790                 :          0 :     glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ());
     791                 :          0 :     glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-SlideWidthScale*origin.getZ());
     792                 :            : }
     793                 :            : 
     794                 :          0 : void RotateAndScaleDepthByHeight::interpolate(double t,double SlideWidthScale,double SlideHeightScale)
     795                 :            : {
     796                 :          0 :     if(t <= nT0)
     797                 :          0 :         return;
     798                 :          0 :     if(!bInterpolate || t > nT1)
     799                 :          0 :         t = nT1;
     800                 :          0 :     t = intervalInter(t,nT0,nT1);
     801                 :          0 :     glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),SlideHeightScale*origin.getZ());
     802                 :          0 :     glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ());
     803                 :          0 :     glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-SlideHeightScale*origin.getZ());
     804                 :            : }
     805                 :            : 
     806                 :          0 : SEllipseTranslate::SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1)
     807                 :            : {
     808                 :          0 :     nT0 = T0;
     809                 :          0 :     nT1 = T1;
     810                 :          0 :     bInterpolate = bInter;
     811                 :          0 :     width = dWidth;
     812                 :          0 :     height = dHeight;
     813                 :          0 :     startPosition = dStartPosition;
     814                 :          0 :     endPosition = dEndPosition;
     815                 :          0 : }
     816                 :            : 
     817                 :          0 : void SEllipseTranslate::interpolate(double t,double /* SlideWidthScale */,double /* SlideHeightScale */)
     818                 :            : {
     819                 :          0 :     if(t <= nT0)
     820                 :          0 :         return;
     821                 :          0 :     if(!bInterpolate || t > nT1)
     822                 :          0 :         t = nT1;
     823                 :          0 :     t = intervalInter(t,nT0,nT1);
     824                 :            : 
     825                 :            :     double a1, a2, x, y;
     826                 :          0 :     a1 = startPosition*2*M_PI;
     827                 :          0 :     a2 = (startPosition + t*(endPosition - startPosition))*2*M_PI;
     828                 :          0 :     x = width*(cos (a2) - cos (a1))/2;
     829                 :          0 :     y = height*(sin (a2) - sin (a1))/2;
     830                 :            : 
     831                 :          0 :     glTranslated(x, 0, y);
     832                 :            : }
     833                 :            : 
     834                 :          0 : STranslate* STranslate::clone()
     835                 :            : {
     836                 :          0 :     return new STranslate(*this);
     837                 :            : }
     838                 :          0 : SRotate* SRotate::clone()
     839                 :            : {
     840                 :          0 :     return new SRotate(*this);
     841                 :            : }
     842                 :            : 
     843                 :          0 : SScale* SScale::clone()
     844                 :            : {
     845                 :          0 :     return new SScale(*this);
     846                 :            : }
     847                 :            : 
     848                 :          0 : SEllipseTranslate* SEllipseTranslate::clone()
     849                 :            : {
     850                 :          0 :     return new SEllipseTranslate(*this);
     851                 :            : }
     852                 :            : 
     853                 :          0 : RotateAndScaleDepthByWidth* RotateAndScaleDepthByWidth::clone()
     854                 :            : {
     855                 :          0 :     return new RotateAndScaleDepthByWidth(*this);
     856                 :            : }
     857                 :            : 
     858                 :          0 : RotateAndScaleDepthByHeight* RotateAndScaleDepthByHeight::clone()
     859                 :            : {
     860                 :          0 :     return new RotateAndScaleDepthByHeight(*this);
     861                 :            : }
     862                 :            : 
     863                 :          0 : const Primitive& Primitive::operator=(const Primitive& rvalue)
     864                 :            : {
     865                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Operations.size(); ++i)
     866                 :          0 :         Operations.push_back(rvalue.Operations[i]->clone());
     867                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Vertices.size(); ++i)//SPEED! use copy or something. this is slow.
     868                 :          0 :         Vertices.push_back(rvalue.Vertices[i]);
     869                 :          0 :     for(unsigned int i( 0 ); i < rvalue.TexCoords.size(); ++i)//SPEED! use copy or something. this is slow.
     870                 :          0 :         TexCoords.push_back(rvalue.TexCoords[i]);
     871                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Normals.size(); ++i)//SPEED! use copy or something. this is slow.
     872                 :          0 :         Normals.push_back(rvalue.Normals[i]);
     873                 :          0 :     return *this;
     874                 :            : }
     875                 :            : 
     876                 :          0 : Primitive::Primitive(const Primitive& rvalue)
     877                 :            : {
     878                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Operations.size(); ++i)
     879                 :          0 :         Operations.push_back(rvalue.Operations[i]->clone());
     880                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Vertices.size(); ++i)//SPEED! use copy or something. this is slow.
     881                 :          0 :         Vertices.push_back(rvalue.Vertices[i]);
     882                 :          0 :     for(unsigned int i( 0 ); i < rvalue.TexCoords.size(); ++i)//SPEED! use copy or something. this is slow.
     883                 :          0 :         TexCoords.push_back(rvalue.TexCoords[i]);
     884                 :          0 :     for(unsigned int i( 0 ); i < rvalue.Normals.size(); ++i)//SPEED! use copy or something. this is slow.
     885                 :          0 :         Normals.push_back(rvalue.Normals[i]);
     886                 :          0 : }
     887                 :            : 
     888                 :          0 : void Primitive::pushTriangle(const basegfx::B2DVector& SlideLocation0,const basegfx::B2DVector& SlideLocation1,const basegfx::B2DVector& SlideLocation2)
     889                 :            : {
     890                 :          0 :     vector<basegfx::B3DVector> Verts;
     891                 :          0 :     vector<basegfx::B2DVector> Texs;
     892                 :          0 :     Verts.reserve(3);
     893                 :          0 :     Texs.reserve(3);
     894                 :            : 
     895                 :          0 :     Verts.push_back(basegfx::B3DVector( 2*SlideLocation0.getX() - 1, -2*SlideLocation0.getY() + 1 , 0.0 ));
     896                 :          0 :     Verts.push_back(basegfx::B3DVector( 2*SlideLocation1.getX() - 1, -2*SlideLocation1.getY() + 1 , 0.0 ));
     897                 :          0 :     Verts.push_back(basegfx::B3DVector( 2*SlideLocation2.getX() - 1, -2*SlideLocation2.getY() + 1 , 0.0 ));
     898                 :            : 
     899                 :            :     //figure out if they're facing the correct way, and make them face the correct way.
     900                 :          0 :     basegfx::B3DVector Normal( basegfx::cross( Verts[0] - Verts[1] , Verts[1] - Verts[2] ) );
     901                 :          0 :     if(Normal.getZ() >= 0.0)//if the normal is facing us
     902                 :            :     {
     903                 :          0 :         Texs.push_back(SlideLocation0);
     904                 :          0 :         Texs.push_back(SlideLocation1);
     905                 :          0 :         Texs.push_back(SlideLocation2);
     906                 :            :     }
     907                 :            :     else // if the normal is facing away from us, make it face us
     908                 :            :     {
     909                 :          0 :         Texs.push_back(SlideLocation0);
     910                 :          0 :         Texs.push_back(SlideLocation2);
     911                 :          0 :         Texs.push_back(SlideLocation1);
     912                 :          0 :         Verts.clear();
     913                 :          0 :         Verts.push_back(basegfx::B3DVector( 2*SlideLocation0.getX() - 1, -2*SlideLocation0.getY() + 1 , 0.0 ));
     914                 :          0 :         Verts.push_back(basegfx::B3DVector( 2*SlideLocation2.getX() - 1, -2*SlideLocation2.getY() + 1 , 0.0 ));
     915                 :          0 :         Verts.push_back(basegfx::B3DVector( 2*SlideLocation1.getX() - 1, -2*SlideLocation1.getY() + 1 , 0.0 ));
     916                 :            :     }
     917                 :            : 
     918                 :          0 :     Vertices.push_back(Verts[0]);
     919                 :          0 :     Vertices.push_back(Verts[1]);
     920                 :          0 :     Vertices.push_back(Verts[2]);
     921                 :            : 
     922                 :          0 :     TexCoords.push_back(Texs[0]);
     923                 :          0 :     TexCoords.push_back(Texs[1]);
     924                 :          0 :     TexCoords.push_back(Texs[2]);
     925                 :            : 
     926                 :          0 :     Normals.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
     927                 :          0 :     Normals.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
     928                 :          0 :     Normals.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
     929                 :          0 : }
     930                 :            : 
     931                 :          0 : void OGLTransitionImpl::makeDiamond()
     932                 :            : {
     933                 :          0 :     mmPrepare = &OGLTransitionImpl::prepareDiamond;
     934                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
     935                 :          0 : }
     936                 :            : 
     937                 :          0 : void OGLTransitionImpl::prepareDiamond( double nTime, double /* SlideWidth */, double /* SlideHeight */, double /* DispWidth */, double /* DispHeight */ )
     938                 :            : {
     939                 :          0 :     Primitive Slide1, Slide2;
     940                 :            : 
     941                 :          0 :     Slide1.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
     942                 :          0 :     Slide1.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
     943                 :          0 :     maEnteringSlidePrimitives.push_back (Slide1);
     944                 :            : 
     945                 :            : 
     946                 :          0 :     if( nTime >= 0.5 ) {
     947                 :          0 :         double m = 1 - nTime;
     948                 :            : 
     949                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (m,0), basegfx::B2DVector (0,m));
     950                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (nTime,0), basegfx::B2DVector (1,0), basegfx::B2DVector (1,m));
     951                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (1,nTime), basegfx::B2DVector (1,1), basegfx::B2DVector (nTime,1));
     952                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0,nTime), basegfx::B2DVector (m,1), basegfx::B2DVector (0,1));
     953                 :            :     } else {
     954                 :          0 :         double l = 0.5 - nTime;
     955                 :          0 :         double h = 0.5 + nTime;
     956                 :            : 
     957                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0.5,l));
     958                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0.5,l), basegfx::B2DVector (1,0), basegfx::B2DVector (h,0.5));
     959                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (1,1), basegfx::B2DVector (h,0.5));
     960                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (h,0.5), basegfx::B2DVector (1,1), basegfx::B2DVector (0.5,h));
     961                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0.5,h), basegfx::B2DVector (1,1), basegfx::B2DVector (0,1));
     962                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (l,0.5), basegfx::B2DVector (0.5,h), basegfx::B2DVector (0,1));
     963                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (l,0.5), basegfx::B2DVector (0,1));
     964                 :          0 :         Slide2.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (0.5,l), basegfx::B2DVector (l,0.5));
     965                 :            :     }
     966                 :          0 :     Slide2.Operations.push_back (new STranslate (basegfx::B3DVector (0, 0, 0.00000001), false, -1, 0));
     967                 :          0 :     maLeavingSlidePrimitives.push_back (Slide2);
     968                 :          0 : }
     969                 :            : 
     970                 :          0 : void OGLTransitionImpl::makeVenetianBlinds( bool vertical, int parts )
     971                 :            : {
     972                 :            :     static double t30 = tan( M_PI/6.0 );
     973                 :          0 :     double n, ln = 0;
     974                 :          0 :     double p = 1.0/parts;
     975                 :            : 
     976                 :          0 :     for( int i=0; i<parts; i++ ) {
     977                 :          0 :         Primitive Slide;
     978                 :          0 :         n = (i + 1)/(double)parts;
     979                 :          0 :         if( vertical ) {
     980                 :          0 :             Slide.pushTriangle (basegfx::B2DVector (ln,0), basegfx::B2DVector (n,0), basegfx::B2DVector (ln,1));
     981                 :          0 :             Slide.pushTriangle (basegfx::B2DVector (n,0), basegfx::B2DVector (ln,1), basegfx::B2DVector (n,1));
     982                 :          0 :             Slide.Operations.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(n + ln - 1, 0, -t30*p), -120, true, 0.0, 1.0));
     983                 :            :         } else {
     984                 :          0 :             Slide.pushTriangle (basegfx::B2DVector (0,ln), basegfx::B2DVector (1,ln), basegfx::B2DVector (0,n));
     985                 :          0 :             Slide.pushTriangle (basegfx::B2DVector (1,ln), basegfx::B2DVector (0,n), basegfx::B2DVector (1,n));
     986                 :          0 :             Slide.Operations.push_back(new RotateAndScaleDepthByHeight(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - n - ln, -t30*p), -120, true, 0.0, 1.0));
     987                 :            :         }
     988                 :          0 :         maLeavingSlidePrimitives.push_back (Slide);
     989                 :            : 
     990                 :          0 :         if( vertical ) {
     991                 :          0 :             Slide.Operations.push_back(new SRotate(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(2*n - 1, 0, 0), -60, false, -1, 0));
     992                 :          0 :             Slide.Operations.push_back(new SRotate(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(n + ln - 1, 0, 0), 180, false, -1, 0));
     993                 :            :         } else {
     994                 :          0 :             Slide.Operations.push_back(new SRotate(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - 2*n, 0), -60, false, -1, 0));
     995                 :          0 :             Slide.Operations.push_back(new SRotate(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - n - ln, 0), 180, false, -1, 0));
     996                 :            :         }
     997                 :          0 :         maEnteringSlidePrimitives.push_back (Slide);
     998                 :          0 :         ln = n;
     999                 :          0 :     }
    1000                 :          0 : }
    1001                 :            : 
    1002                 :          0 : void OGLTransitionImpl::displaySlidesFadeSmoothly( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
    1003                 :            : {
    1004                 :          0 :     applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
    1005                 :            : 
    1006                 :          0 :     glDisable(GL_DEPTH_TEST);
    1007                 :            : 
    1008                 :          0 :     displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
    1009                 :            : 
    1010                 :          0 :     glDisable(GL_LIGHTING);
    1011                 :          0 :     glEnable(GL_BLEND);
    1012                 :          0 :     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1013                 :          0 :     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    1014                 :          0 :     glColor4f( 1, 1, 1, nTime );
    1015                 :          0 :     displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
    1016                 :          0 :     glDisable(GL_BLEND);
    1017                 :          0 :     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    1018                 :          0 :     glEnable(GL_LIGHTING);
    1019                 :            : 
    1020                 :          0 :     glEnable(GL_DEPTH_TEST);
    1021                 :          0 : }
    1022                 :            : 
    1023                 :          0 : void OGLTransitionImpl::makeFadeSmoothly()
    1024                 :            : {
    1025                 :          0 :     Primitive Slide;
    1026                 :            : 
    1027                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
    1028                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
    1029                 :          0 :     maLeavingSlidePrimitives.push_back (Slide);
    1030                 :          0 :     maEnteringSlidePrimitives.push_back (Slide);
    1031                 :            : 
    1032                 :          0 :     mmDisplaySlides = &OGLTransitionImpl::displaySlidesFadeSmoothly;
    1033                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
    1034                 :          0 : }
    1035                 :            : 
    1036                 :          0 : void OGLTransitionImpl::displaySlidesFadeThroughBlack( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
    1037                 :            : {
    1038                 :          0 :     applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
    1039                 :            : 
    1040                 :          0 :     glDisable(GL_DEPTH_TEST);
    1041                 :            : 
    1042                 :          0 :     glDisable(GL_LIGHTING);
    1043                 :          0 :     glEnable(GL_BLEND);
    1044                 :          0 :     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1045                 :          0 :     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    1046                 :          0 :     if( nTime < 0.5 ) {
    1047                 :          0 :         glColor4f( 1, 1, 1, 1 - nTime*2 );
    1048                 :          0 :         displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
    1049                 :            :     } else {
    1050                 :          0 :         glColor4f( 1, 1, 1, (nTime - 0.5)*2 );
    1051                 :          0 :         displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
    1052                 :            :     }
    1053                 :          0 :     glDisable(GL_BLEND);
    1054                 :          0 :     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    1055                 :          0 :     glEnable(GL_LIGHTING);
    1056                 :            : 
    1057                 :          0 :     glEnable(GL_DEPTH_TEST);
    1058                 :          0 : }
    1059                 :            : 
    1060                 :          0 : void OGLTransitionImpl::makeFadeThroughBlack()
    1061                 :            : {
    1062                 :          0 :     Primitive Slide;
    1063                 :            : 
    1064                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
    1065                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
    1066                 :          0 :     maLeavingSlidePrimitives.push_back (Slide);
    1067                 :          0 :     maEnteringSlidePrimitives.push_back (Slide);
    1068                 :            : 
    1069                 :          0 :     mmDisplaySlides = &OGLTransitionImpl::displaySlidesFadeThroughBlack;
    1070                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
    1071                 :          0 : }
    1072                 :            : 
    1073                 :            : static const char* basicVertexShader = "\n\
    1074                 :            : varying vec2 v_texturePosition;\n\
    1075                 :            : \n\
    1076                 :            : void main( void )\n\
    1077                 :            : {\n\
    1078                 :            :     gl_Position = ftransform();\n\
    1079                 :            :     v_texturePosition = gl_MultiTexCoord0.xy;\n\
    1080                 :            : }\n\
    1081                 :            : ";
    1082                 :            : 
    1083                 :            : static const char* staticFragmentShader = "\n\
    1084                 :            : uniform sampler2D leavingSlideTexture;\n\
    1085                 :            : uniform sampler2D enteringSlideTexture;\n\
    1086                 :            : uniform sampler2D permTexture;\n\
    1087                 :            : uniform float time;\n\
    1088                 :            : varying vec2 v_texturePosition;\n\
    1089                 :            : \n\
    1090                 :            : float snoise(vec2 P) {\n\
    1091                 :            : \n\
    1092                 :            :   return texture2D(permTexture, P).r;\n\
    1093                 :            : }\n\
    1094                 :            : \n\
    1095                 :            : \n\
    1096                 :            : #define PART 0.5\n\
    1097                 :            : #define START 0.4\n\
    1098                 :            : #define END 0.9\n\
    1099                 :            : \n\
    1100                 :            : void main() {\n\
    1101                 :            :     float sn = snoise(10.0*v_texturePosition+time*0.07);\n\
    1102                 :            :     if( time < PART ) {\n\
    1103                 :            :         float sn1 = snoise(vec2(time*15.0, 20.0*v_texturePosition.y));\n\
    1104                 :            :         float sn2 = snoise(v_texturePosition);\n\
    1105                 :            :         if (sn1 > 1.0 - time*time && sn2 < 2.0*time+0.1)\n\
    1106                 :            :             gl_FragColor = vec4(sn, sn, sn, 1.0);\n\
    1107                 :            :         else if (time > START )\n\
    1108                 :            :             gl_FragColor = ((time-START)/(PART - START))*vec4(sn, sn, sn, 1.0) + (1.0 - (time - START)/(PART - START))*texture2D(leavingSlideTexture, v_texturePosition);\n\
    1109                 :            :         else\n\
    1110                 :            :             gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
    1111                 :            :     } else if ( time < PART ) {\n\
    1112                 :            :             gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
    1113                 :            :     } else if ( time > END ) {\n\
    1114                 :            :         gl_FragColor = ((1.0 - time)/(1.0 - END))*vec4(sn, sn, sn, 1.0) + ((time - END)/(1.0 - END))*texture2D(enteringSlideTexture, v_texturePosition);\n\
    1115                 :            :     } else \n\
    1116                 :            :         gl_FragColor = vec4(sn, sn, sn, 1.0);\n\
    1117                 :            : }\n\
    1118                 :            : ";
    1119                 :            : 
    1120                 :            : static const char* dissolveFragmentShader = "\n\
    1121                 :            : uniform sampler2D leavingSlideTexture;\n\
    1122                 :            : uniform sampler2D enteringSlideTexture;\n\
    1123                 :            : uniform sampler2D permTexture;\n\
    1124                 :            : uniform float time;\n\
    1125                 :            : varying vec2 v_texturePosition;\n\
    1126                 :            : \n\
    1127                 :            : float snoise(vec2 P) {\n\
    1128                 :            : \n\
    1129                 :            :   return texture2D(permTexture, P).r;\n\
    1130                 :            : }\n\
    1131                 :            : \n\
    1132                 :            : void main() {\n\
    1133                 :            :      float sn = snoise(10.0*v_texturePosition);\n\
    1134                 :            :      if( sn < time)\n\
    1135                 :            :          gl_FragColor = texture2D(enteringSlideTexture, v_texturePosition);\n\
    1136                 :            :      else\n\
    1137                 :            :          gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
    1138                 :            : }\n\
    1139                 :            : ";
    1140                 :            : 
    1141                 :            : int permutation256 [256]= {
    1142                 :            : 215, 100, 200, 204, 233,  50,  85, 196,
    1143                 :            :  71, 141, 122, 160,  93, 131, 243, 234,
    1144                 :            : 162, 183,  36, 155,   4,  62,  35, 205,
    1145                 :            :  40, 102,  33,  27, 255,  55, 214, 156,
    1146                 :            :  75, 163, 134, 126, 249,  74, 197, 228,
    1147                 :            :  72,  90, 206, 235,  17,  22,  49, 169,
    1148                 :            : 227,  89,  16,   5, 117,  60, 248, 230,
    1149                 :            : 217,  68, 138,  96, 194, 170, 136,  10,
    1150                 :            : 112, 238, 184, 189, 176,  42, 225, 212,
    1151                 :            :  84,  58, 175, 244, 150, 168, 219, 236,
    1152                 :            : 101, 208, 123,  37, 164, 110, 158, 201,
    1153                 :            :  78, 114,  57,  48,  70, 142, 106,  43,
    1154                 :            : 232,  26,  32, 252, 239,  98, 191,  94,
    1155                 :            :  59, 149,  39, 187, 203, 190,  19,  13,
    1156                 :            : 133,  45,  61, 247,  23,  34,  20,  52,
    1157                 :            : 118, 209, 146, 193, 222,  18,   1, 152,
    1158                 :            :  46,  41,  91, 148, 115,  25, 135,  77,
    1159                 :            : 254, 147, 224, 161,   9, 213, 223, 250,
    1160                 :            : 231, 251, 127, 166,  63, 179,  81, 130,
    1161                 :            : 139,  28, 120, 151, 241,  86, 111,   0,
    1162                 :            :  88, 153, 172, 182, 159, 105, 178,  47,
    1163                 :            :  51, 167,  65,  66,  92,  73, 198, 211,
    1164                 :            : 245, 195,  31, 220, 140,  76, 221, 186,
    1165                 :            : 154, 185,  56,  83,  38, 165, 109,  67,
    1166                 :            : 124, 226, 132,  53, 229,  29,  12, 181,
    1167                 :            : 121,  24, 207, 199, 177, 113,  30,  80,
    1168                 :            :   3,  97, 188,  79, 216, 173,   8, 145,
    1169                 :            :  87, 128, 180, 237, 240, 137, 125, 104,
    1170                 :            :  15, 242, 119, 246, 103, 143,  95, 144,
    1171                 :            :   2,  44,  69, 157, 192, 174,  14,  54,
    1172                 :            : 218,  82,  64, 210,  11,   6, 129,  21,
    1173                 :            : 116, 171,  99, 202,   7, 107, 253, 108
    1174                 :            : };
    1175                 :            : 
    1176                 :          0 : void initPermTexture(GLuint *texID)
    1177                 :            : {
    1178                 :          0 :   glGenTextures(1, texID);
    1179                 :          0 :   glBindTexture(GL_TEXTURE_2D, *texID);
    1180                 :            : 
    1181                 :            :   static bool initialized = false;
    1182                 :            :   static unsigned char permutation2D[256*256*4];
    1183                 :          0 :   if( !initialized ) {
    1184                 :            :       int x, y;
    1185                 :            : 
    1186                 :          0 :       for( y=0; y < 256; y++ )
    1187                 :          0 :           for( x=0; x < 256; x++ )
    1188                 :          0 :               permutation2D[x*4 + y*1024] = permutation256[(y + permutation256[x]) & 0xff];
    1189                 :            : 
    1190                 :          0 :       initialized = true;
    1191                 :            :   }
    1192                 :            : 
    1193                 :          0 :   glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, permutation2D );
    1194                 :          0 :   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    1195                 :          0 :   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    1196                 :          0 : }
    1197                 :            : 
    1198                 :          0 : void OGLTransitionImpl::preparePermShader()
    1199                 :            : {
    1200                 :            : #ifdef GL_VERSION_2_0
    1201                 :          0 :     if( mProgramObject ) {
    1202                 :          0 :         OGLShaders::glUseProgram( mProgramObject );
    1203                 :            : 
    1204                 :          0 :         GLint location = OGLShaders::glGetUniformLocation( mProgramObject, "leavingSlideTexture" );
    1205                 :          0 :         if( location != -1 ) {
    1206                 :          0 :             OGLShaders::glUniform1i( location, 0 );  // texture unit 0
    1207                 :            :         }
    1208                 :            : 
    1209                 :          0 :         glActiveTexture(GL_TEXTURE1);
    1210                 :          0 :         if( !maHelperTexture )
    1211                 :          0 :             initPermTexture( &maHelperTexture );
    1212                 :          0 :         glActiveTexture(GL_TEXTURE0);
    1213                 :            : 
    1214                 :          0 :         location = OGLShaders::glGetUniformLocation( mProgramObject, "permTexture" );
    1215                 :          0 :         if( location != -1 ) {
    1216                 :          0 :             OGLShaders::glUniform1i( location, 1 );  // texture unit 1
    1217                 :            :         }
    1218                 :            : 
    1219                 :          0 :         location = OGLShaders::glGetUniformLocation( mProgramObject, "enteringSlideTexture" );
    1220                 :          0 :         if( location != -1 ) {
    1221                 :          0 :             OGLShaders::glUniform1i( location, 2 );  // texture unit 2
    1222                 :            :         }
    1223                 :            :     }
    1224                 :            : #endif
    1225                 :          0 : }
    1226                 :            : 
    1227                 :          0 : void OGLTransitionImpl::prepareStatic( ::sal_Int32 /* glLeavingSlideTex */, ::sal_Int32 /* glEnteringSlideTex */ )
    1228                 :            : {
    1229                 :          0 :     mProgramObject = OGLShaders::LinkProgram( basicVertexShader, staticFragmentShader );
    1230                 :            : 
    1231                 :          0 :     preparePermShader();
    1232                 :          0 : }
    1233                 :            : 
    1234                 :          0 : void OGLTransitionImpl::displaySlidesShaders( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
    1235                 :            :                                               double SlideWidthScale, double SlideHeightScale )
    1236                 :            : {
    1237                 :          0 :     applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
    1238                 :            : 
    1239                 :            : #ifdef GL_VERSION_2_0
    1240                 :          0 :     if( mProgramObject ) {
    1241                 :          0 :         GLint location = OGLShaders::glGetUniformLocation( mProgramObject, "time" );
    1242                 :          0 :         if( location != -1 ) {
    1243                 :          0 :             OGLShaders::glUniform1f( location, nTime );
    1244                 :            :         }
    1245                 :            :     }
    1246                 :            : 
    1247                 :          0 :     glActiveTexture( GL_TEXTURE2 );
    1248                 :          0 :     glBindTexture( GL_TEXTURE_2D, glEnteringSlideTex );
    1249                 :          0 :     glActiveTexture( GL_TEXTURE0 );
    1250                 :            : #endif
    1251                 :            : 
    1252                 :          0 :     displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
    1253                 :          0 : }
    1254                 :            : 
    1255                 :          0 : void OGLTransitionImpl::makeStatic()
    1256                 :            : {
    1257                 :          0 :     Primitive Slide;
    1258                 :            : 
    1259                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
    1260                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
    1261                 :          0 :     maLeavingSlidePrimitives.push_back (Slide);
    1262                 :          0 :     maEnteringSlidePrimitives.push_back (Slide);
    1263                 :            : 
    1264                 :          0 :     mmDisplaySlides = &OGLTransitionImpl::displaySlidesShaders;
    1265                 :          0 :     mmPrepareTransition = &OGLTransitionImpl::prepareStatic;
    1266                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
    1267                 :            : 
    1268                 :          0 :     mnRequiredGLVersion = 2.0;
    1269                 :          0 : }
    1270                 :            : 
    1271                 :          0 : void OGLTransitionImpl::prepareDissolve( ::sal_Int32 /* glLeavingSlideTex */, ::sal_Int32 /* glEnteringSlideTex */ )
    1272                 :            : {
    1273                 :          0 :     mProgramObject = OGLShaders::LinkProgram( basicVertexShader, dissolveFragmentShader );
    1274                 :            : 
    1275                 :          0 :     preparePermShader();
    1276                 :          0 : }
    1277                 :            : 
    1278                 :          0 : void OGLTransitionImpl::makeDissolve()
    1279                 :            : {
    1280                 :          0 :     Primitive Slide;
    1281                 :            : 
    1282                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
    1283                 :          0 :     Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
    1284                 :          0 :     maLeavingSlidePrimitives.push_back (Slide);
    1285                 :          0 :     maEnteringSlidePrimitives.push_back (Slide);
    1286                 :            : 
    1287                 :          0 :     mmDisplaySlides = &OGLTransitionImpl::displaySlidesShaders;
    1288                 :          0 :     mmPrepareTransition = &OGLTransitionImpl::prepareDissolve;
    1289                 :          0 :     mbUseMipMapLeaving = mbUseMipMapEntering = false;
    1290                 :            : 
    1291                 :          0 :     mnRequiredGLVersion = 2.0;
    1292                 :          0 : }
    1293                 :            : 
    1294                 :          0 : void OGLTransitionImpl::makeNewsflash()
    1295                 :            : {
    1296                 :          0 :     Primitive Slide;
    1297                 :            : 
    1298                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
    1299                 :          0 :     Slide.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
    1300                 :          0 :     Slide.Operations.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0,0,0),3000,true,0,0.5));
    1301                 :          0 :     Slide.Operations.push_back(new SScale(basegfx::B3DVector(0.01,0.01,0.01),basegfx::B3DVector(0,0,0),true,0,0.5));
    1302                 :          0 :     Slide.Operations.push_back(new STranslate(basegfx::B3DVector(-10000, 0, 0),false, 0.5, 2));
    1303                 :          0 :     maLeavingSlidePrimitives.push_back(Slide);
    1304                 :            : 
    1305                 :          0 :     Slide.Operations.clear();
    1306                 :          0 :     Slide.Operations.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0,0,0),-3000,true,0.5,1));
    1307                 :          0 :     Slide.Operations.push_back(new STranslate(basegfx::B3DVector(-100, 0, 0),false, -1, 1));
    1308                 :          0 :     Slide.Operations.push_back(new STranslate(basegfx::B3DVector(100, 0, 0),false, 0.5, 1));
    1309                 :          0 :     Slide.Operations.push_back(new SScale(basegfx::B3DVector(0.01,0.01,0.01),basegfx::B3DVector(0,0,0),false,-1,1));
    1310                 :          0 :     Slide.Operations.push_back(new SScale(basegfx::B3DVector(100,100,100),basegfx::B3DVector(0,0,0),true,0.5,1));
    1311                 :          0 :     maEnteringSlidePrimitives.push_back(Slide);
    1312                 :            : 
    1313                 :          0 :     OverallOperations.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0.2,0.2,0),1080,true,0,1));
    1314                 :          0 : }
    1315                 :            : 
    1316                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10