1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OGLTrans_TransitionImpl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_OGLTRANS_TRANSITIONIMPL_HXX_
31 #define INCLUDED_OGLTRANS_TRANSITIONIMPL_HXX_
33 #include <basegfx/vector/b2dvector.hxx>
34 #include <basegfx/vector/b3dvector.hxx>
36 #include <tools/prewin.h>
37 #include <tools/postwin.h>
40 #include <tools/prewin.h>
41 #include <tools/postwin.h>
43 #elif defined( QUARTZ )
57 /** OpenGL 3D Transition class. It implicitly is constructed from XOGLTransition
59 This class is capable of making itself into many difference transitions. It holds Primitives and Operations on those primitives.
61 class OGLTransitionImpl
65 mbUseMipMapLeaving( true ),
66 mbUseMipMapEntering( true ),
67 mnRequiredGLVersion( 1.0 ),
68 maLeavingSlidePrimitives(),
69 maEnteringSlidePrimitives(),
71 mbReflectSlides( false ),
77 mmPrepareTransition( NULL
),
78 mmClearTransition( NULL
),
79 mmDisplaySlides( NULL
)
84 void prepare( ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
);
85 void display( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
);
88 void makeOutsideCubeFaceToLeft();
89 void makeInsideCubeFaceToLeft();
90 void makeNByMTileFlip( ::sal_uInt16 n
, ::sal_uInt16 m
);
91 void makeRevolvingCircles( ::sal_uInt16 nCircles
, ::sal_uInt16 nPointsOnCircles
);
92 void makeHelix( ::sal_uInt16 nRows
);
93 void makeFallLeaving();
94 void makeTurnAround();
98 void makeVenetianBlinds( bool vertical
, int parts
);
101 void makeNewsflash();
106 void makeFadeSmoothly();
107 void makeFadeThroughBlack();
109 /** Whether to use mipmaping for slides textures
111 bool mbUseMipMapLeaving
;
112 bool mbUseMipMapEntering
;
114 /** which GL version does the transition require
116 float mnRequiredGLVersion
;
119 /** clears all the primitives and operations
123 /** All the primitives that use the leaving slide texture
125 vector
<Primitive
> maLeavingSlidePrimitives
;
127 /** All the primitives that use the leaving slide texture
129 vector
<Primitive
> maEnteringSlidePrimitives
;
131 /** All the surrounding scene objects
133 vector
<SceneObject
*> maSceneObjects
;
135 /** All the operations that should be applied to both leaving and entering slide primitives. These operations will be called in the order they were pushed back in. In OpenGL this effectively uses the operations in the opposite order they were pushed back.
137 vector
<Operation
*> OverallOperations
;
139 /** Whether to reflect slides, the reflection happens on flat surface beneath the slides.
140 ** Now it only works with slides which keep their rectangular shape together.
142 bool mbReflectSlides
;
144 /** GLSL objects, shaders and program
146 GLuint mVertexObject
, mFragmentObject
, mProgramObject
;
149 GLuint maHelperTexture
;
151 /** When this method is not NULL, it is called in display method to prepare the slides, scene, etc.
152 ** We might later replace this by cleaner derived class.
154 void (OGLTransitionImpl::*mmPrepare
)( double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
);
156 /** When this method is not NULL, it is called after glx context is ready to let the transition prepare GL related things, like GLSL program.
157 ** We might later replace this by cleaner derived class.
159 void (OGLTransitionImpl::*mmPrepareTransition
)( ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
);
161 /** When this method is not NULL, it is called when the transition needs to clear after itself, like delete own textures etc.
162 ** We might later replace this by cleaner derived class.
164 void (OGLTransitionImpl::*mmClearTransition
)();
166 /** When this method is not NULL, it is called in display method to display the slides.
167 ** We might later replace this by cleaner derived class.
169 void (OGLTransitionImpl::*mmDisplaySlides
)( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
171 void displaySlides( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
172 void displaySlide( double nTime
, ::sal_Int32 glSlideTex
, std::vector
<Primitive
>& primitives
, double SlideWidthScale
, double SlideHeightScale
);
173 void displayScene( double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
);
174 void applyOverallOperations( double nTime
, double SlideWidthScale
, double SlideHeightScale
);
176 /** various transitions helper methods
178 void prepareDiamond( double nTime
, double SlideWidth
, double SlideHeight
,double DispWidth
, double DispHeight
);
179 void displaySlidesFadeSmoothly( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
180 void displaySlidesFadeThroughBlack( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
181 void displaySlidesRochade( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
182 void displaySlidesShaders( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
);
183 void prepareStatic( ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
);
184 void prepareDissolve( ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
);
185 void preparePermShader();
193 virtual void prepare() {};
194 virtual void display(double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
);
195 virtual void finish() {};
197 void pushPrimitive (const Primitive
&p
);
200 /** All the surrounding scene primitives
202 vector
<Primitive
> maPrimitives
;
205 class Iris
: public SceneObject
210 virtual void prepare();
211 virtual void display(double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
);
212 virtual void finish();
219 /** This class is a list of Triangles that will share Operations, and could possibly share
225 // making copy constructor explicit makes the class un-suitable for use with stl containers
226 Primitive(const Primitive
& rvalue
);
229 void applyOperations(double nTime
, double SlideWidthScale
, double SlideHeightScale
);
230 void display(double nTime
, double SlideWidthScale
, double SlideHeightScale
);
231 const Primitive
& operator=(const Primitive
& rvalue
);
233 /** PushBack a vertex,normal, and tex coord. Each SlideLocation is where on the slide is mapped to this location ( from (0,0) to (1,1) ). This will make sure the correct aspect ratio is used, and helps to make slides begin and end at the correct position. (0,0) is the top left of the slide, and (1,1) is the bottom right.
235 @param SlideLocation0
236 Location of first Vertex on slide
238 @param SlideLocation1
239 Location of second Vertex on slide
241 @param SlideLocation2
242 Location of third Vertex on slide
245 void pushTriangle(const basegfx::B2DVector
& SlideLocation0
,const basegfx::B2DVector
& SlideLocation1
,const basegfx::B2DVector
& SlideLocation2
);
247 /** clear all the vertices, normals, tex coordinates, and normals
249 void clearTriangles();
251 /** guards against directly changing the vertices
256 const vector
<basegfx::B3DVector
>& getVertices() const {return Vertices
;}
258 /** guards against directly changing the vertices
260 const vector
<basegfx::B3DVector
>& getNormals() const {return Normals
;}
262 /** guards against directly changing the vertices
265 the list of Texture Coordinates
268 const vector
<basegfx::B2DVector
>& getTexCoords() const {return TexCoords
;}
270 /** list of Operations to be performed on this primitive.These operations will be called in the order they were pushed back in. In OpenGL this effectively uses the operations in the opposite order they were pushed back.
273 the list of Operations
276 vector
<Operation
*> Operations
;
281 vector
<basegfx::B3DVector
> Vertices
;
285 vector
<basegfx::B3DVector
> Normals
;
287 /** list of Texture Coordinates
289 vector
<basegfx::B2DVector
> TexCoords
;
292 /** This class is to be derived to make any operation (tranform) you may need in order to construct your transitions
298 virtual ~Operation(){}
300 /** Should this operation be interpolated . If TRUE, the transform will smoothly move from making no difference from t = 0.0 to nT0 to being completely transformed from t = nT1 to 1. If FALSE, the transform will be inneffectual from t = 0 to nT0, and completely transformed from t = nT0 to 1.
304 /** time to begin the transformation
308 /** time to finish the transformation
312 /** this is the function that is called to give the Operation to OpenGL.
315 time from t = 0 to t = 1
317 @param SlideWidthScale
318 width of slide divided by width of window
320 @param SlideHeightScale
321 height of slide divided by height of window
324 virtual void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
) = 0;
326 /** return a copy of this operation
328 virtual Operation
* clone() = 0;
331 /** this class is a generic CounterClockWise(CCW) rotation with an axis angle
333 class SRotate
: public Operation
336 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
337 virtual SRotate
* clone();
345 position that rotation axis runs through
348 angle in radians of CCW rotation
354 transformation starting time
357 transformation ending time
360 SRotate(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
,bool bInter
, double T0
, double T1
);
363 /** axis to rotate CCW about
365 basegfx::B3DVector axis
;
367 /** position that rotation axis runs through
369 basegfx::B3DVector origin
;
371 /** angle in radians of CCW rotation
376 /** scaling transformation
378 class SScale
: public Operation
381 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
390 position that rotation axis runs through
396 transformation starting time
399 transformation ending time
402 SScale(const basegfx::B3DVector
& Scale
, const basegfx::B3DVector
& Origin
,bool bInter
, double T0
, double T1
);
405 basegfx::B3DVector scale
;
406 basegfx::B3DVector origin
;
409 /** translation transformation
411 class STranslate
: public Operation
414 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
426 transformation starting time
429 transformation ending time
432 STranslate(const basegfx::B3DVector
& Vector
,bool bInter
, double T0
, double T1
);
435 /** vector to translate by
437 basegfx::B3DVector vector
;
440 /** translation transformation
442 class SEllipseTranslate
: public Operation
445 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
446 SEllipseTranslate
* clone();
457 transformation starting time
460 transformation ending time
463 SEllipseTranslate(double dWidth
, double dHeight
, double dStartPosition
, double dEndPosition
, bool bInter
, double T0
, double T1
);
464 ~SEllipseTranslate(){}
466 /** width and length of the ellipse
468 double width
, height
;
470 /** start and end position on the ellipse <0,1>
472 double startPosition
;
476 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the width of the window.
478 class RotateAndScaleDepthByWidth
: public Operation
481 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
482 RotateAndScaleDepthByWidth
* clone();
484 RotateAndScaleDepthByWidth(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
,bool bInter
, double T0
, double T1
);
485 ~RotateAndScaleDepthByWidth(){}
487 basegfx::B3DVector axis
;
488 basegfx::B3DVector origin
;
492 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the height of the window.
494 class RotateAndScaleDepthByHeight
: public Operation
497 void interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
);
498 RotateAndScaleDepthByHeight
* clone();
500 RotateAndScaleDepthByHeight(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
,bool bInter
, double T0
, double T1
);
501 ~RotateAndScaleDepthByHeight(){}
503 basegfx::B3DVector axis
;
504 basegfx::B3DVector origin
;
508 #endif // INCLUDED_SLIDESHOW_TRANSITION_HXX_