Nokia N97 SDK
Example Applications Guide

Slideshow.h

00001 /*
00002  * ==============================================================================
00003  *  Name        : Slideshow.h
00004  *  Part of     : OpenGLEx / Slideshow
00005  *
00006  *  Copyright (c) 2005-2006 Nokia Corporation.
00007  *  This material, including documentation and any related
00008  *  computer programs, is protected by copyright controlled by
00009  *  Nokia Corporation.
00010  * ==============================================================================
00011  */
00012 
00013 #ifndef __SLIDESHOWH__
00014 #define __SLIDESHOWH__
00015 
00016 //  INCLUDES
00017 
00018 #include <e32base.h> // for CBase definition
00019 #include <GLES\gl.h>      // OpenGL ES header file
00020 #include "Slideshowrenderers.h"
00021 #include "Textureutils.h"
00022 #include "Mathutils.h"
00023 #include "Utils3d.h"
00024 
00025 // FORWARD DECLARATIONS
00026 
00027 /**
00028  * Class that does the actual OpenGL ES rendering.
00029  * Subclass of CFiniteStateMachine because the application
00030  * needs to handle loading textures and running states.
00031  */
00032 class CSlideshow
00033         : public CFiniteStateMachine, public MTextureLoadingListener
00034         {
00035         public: // Constructors and destructor
00036 
00037         /**
00038          * Factory method for creating a new CSlideshow object.
00039                  * Calls the hidden constructors.
00040          */
00041                 static CSlideshow* NewL( TUint aWidth, TUint aHeight );
00042 
00043         /**
00044          * Destructor. Does nothing.
00045          */
00046                 virtual ~CSlideshow();
00047 
00048         protected: // Hidden constructors
00049 
00050         /**
00051          * Standard constructor that must never Leave.
00052          * Stores the given screen width and height.
00053          * @param aWidth Width of the screen.
00054          * @param aHeight Height of the screen.
00055          */
00056                 CSlideshow( TUint aWidth, TUint aHeight );
00057 
00058         /**
00059          * Second phase constructor that can call methods that may leave. Does nothing.
00060          */
00061                 void ConstructL( void );
00062 
00063 
00064         public: // New methods
00065 
00066         /**
00067          * Initializes OpenGL ES, sets the vertex and color
00068          * arrays and pointers. Also selects the shading mode and
00069          * creates the CTextureManager instance and starts loading
00070          * of required textures.
00071          */
00072                 void AppInitL( void );
00073 
00074         /**
00075          * Called upon application exit. Destroys the CTextureManager
00076          * instance that was created in AppInitL() method.
00077          */
00078                 void AppExit( void );
00079 
00080         /**
00081          * Renders one frame.
00082          * @param aFrame Number of the frame to be rendered.
00083                  * @param aTimeSecs Seconds elapsed since the application started running.
00084                  * @param aDeltaTimeSecs Seconds elapsed since last call to AppCycle().
00085          */
00086                 void AppCycle( TInt aFrame, TReal aTimeSecs, TReal aDeltaTimeSecs );
00087 
00088         /**
00089          *  Advances the slideshow to the next picture.
00090          */
00091         void ShowNextPicture ( void );
00092 
00093         /**
00094          *  Advances the slideshow to the previous picture.
00095          */
00096         void ShowPreviousPicture ( void );
00097 
00098         /**
00099          * Called when the finite state machine enters a new state.
00100          * Does nothing in this implementation.
00101          * @param aState State that is about to be entered.
00102          */
00103                 void OnEnterStateL( TInt aState);
00104 
00105         /**
00106          * Called when texture manager starts loading the textures.
00107          * Sets the current state to "loading textures".
00108          */
00109                 void OnStartLoadingTexturesL();
00110 
00111         /**
00112          * Called when texture manager has completed texture loading.
00113          * Changes the current state to "running".
00114          */
00115                 void OnEndLoadingTexturesL();
00116 
00117         /**
00118          * Notifies that the screen size has dynamically changed during execution of
00119          * this program. Resets the viewport to this new size and sets this size
00120          * to the CTextureManager.
00121          * @param aWidth New width of the screen.
00122          * @param aHeight New height of the screen.
00123          */
00124         void SetScreenSize( TUint aWidth, TUint aHeight );
00125 
00126         public: // Data
00127         /**
00128          * Application states:
00129          * ELoadingTextures - indicates that the app. is loading textures.
00130          * ERunning - indicates that the app. is running.
00131          */
00132                 enum
00133                     {
00134                     ELoadingTextures,
00135                     ERunning
00136                     };
00137 
00138         /**
00139          *  The ways one can navigate a slideshow.
00140          */
00141         enum TDirection
00142             {
00143             ENext,
00144             EPrevious,
00145             };
00146 
00147     private: // Methods
00148         /**
00149          *  Creates a new random transition renderer.
00150          *  @param dir The direction we are moving in the slideshow.
00151          *  @returns a pointer to the transition renderer.
00152          */
00153         MTransitionRenderer* CreateTransitionRenderer(TDirection dir);
00154 
00155         private: // Data
00156         /** Texture manager that is used to load the used textures. */
00157                 CTextureManager* iTextureManager;
00158         /** Width of the screen */
00159         TUint iScreenWidth;
00160         /** Height of the screen */
00161         TUint iScreenHeight;
00162 
00163         /** Pictures to cycle */
00164         TTexture iPictures[5];
00165 
00166         /** Number of pictures to cycle */
00167         TUint iPictureCount;
00168 
00169         /** Index of the currently visible picture */
00170         TUint iCurrentPicture;
00171 
00172         /** Index of the picture we are transitioning to */
00173         TUint iNextPicture;
00174 
00175         /** Number of pictures to go forward or backward */
00176         TInt iRequestedPictureDelta;
00177 
00178         /** Transition masks */
00179         TTexture iMasks[2];
00180 
00181         /** Static picture renderer */
00182         CStaticRenderer iStaticRenderer;
00183 
00184         /** Transition renderer */
00185         MTransitionRenderer* iTransitionRenderer;
00186 
00187         /** Time to transition completion */
00188         TReal iTransitionTime;
00189         };
00190 
00191 #endif
00192 
00193 // End of File
00194 

© Nokia 2009

Back to top