S60 3rd Edition SDK for Symbian OS
Example Applications Guide

RainContainer.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : RainContainer.h
00004 *  Part of     : OpenGLEx / Rain
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #ifndef RAINCONTAINER_H
00017 #define RAINCONTAINER_H
00018 
00019 // INCLUDES
00020 #include <coecntrl.h>
00021 #include <GLES\egl.h>
00022 #include "rain.h"
00023 #include <akndef.h>
00024 
00025 
00026 // CLASS DECLARATION
00027 
00028 /**
00029  * Container control class that handles the OpenGL ES initialization and deinitializations.
00030  * Also uses the CRain class to do the actual OpenGL ES rendering.
00031  */
00032 class CRainContainer : public CCoeControl, MCoeControlObserver
00033     {
00034     public: // Constructors and destructor
00035         
00036         /**
00037          * EPOC default constructor. Initializes the OpenGL ES for rendering.
00038          * @param aRect Screen rectangle for container.
00039          */
00040         void ConstructL(const TRect& aRect);
00041 
00042         /**
00043          * Destructor. Destroys the CPeriodic, CRain and uninitializes OpenGL ES.
00044          */
00045         virtual ~CRainContainer();
00046 
00047     public: // New functions
00048 
00049         /**
00050          * Callback function for the CPeriodic. Calculates the current frame, keeps the background
00051          * light from turning off and orders the CRain to do the rendering for each frame.
00052          *@param aInstance Pointer to this instance of CRainContainer.
00053          */
00054         static TInt DrawCallBack( TAny* aInstance );
00055 
00056     private: // Functions from base classes
00057 
00058         /**
00059          * Method from CoeControl that gets called when the display size changes.
00060          * If OpenGL has been initialized, notifies the renderer class that the screen
00061          * size has changed.
00062          */
00063         void SizeChanged();
00064 
00065          /**
00066           * Handles a change to the control's resources. This method
00067           * reacts to the KEikDynamicLayoutVariantSwitch event (that notifies of
00068           * screen size change) by calling the SetExtentToWholeScreen() again so that
00069           * this control fills the new screen size. This will then trigger a call to the
00070           * SizeChanged() method.
00071           * @param aType Message UID value, only KEikDynamicLayoutVariantSwitch is handled by this method.
00072           */
00073          void HandleResourceChange(TInt aType); 
00074 
00075 
00076         /**
00077          * Method from CoeControl. Does nothing in this implementation.
00078          */
00079         TInt CountComponentControls() const;
00080 
00081         /**
00082          * Method from CCoeControl. Does nothing in this implementation.
00083          */
00084         CCoeControl* ComponentControl(TInt aIndex) const;
00085 
00086         /**
00087          * Method from CCoeControl. Does nothing in this implementation.
00088          * All rendering is done in the DrawCallBack() method.
00089          */
00090         void Draw(const TRect& aRect) const;
00091 
00092         /**
00093          * Method from MCoeControlObserver that handles an event from the observed control.
00094          * Does nothing in this implementation.
00095                  * @param aControl   Control changing its state.
00096                  * @param aEventType Type of the control event.
00097          */
00098         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
00099         
00100     private: // Data
00101 
00102         /** Display where the OpenGL ES window surface resides. */
00103         EGLDisplay     iEglDisplay;  
00104 
00105         /** Window surface where the OpenGL ES rendering is blitted to. */
00106         EGLSurface     iEglSurface;  
00107 
00108         /** OpenGL ES rendering context. */
00109         EGLContext     iEglContext;  
00110 
00111         /** Active object that is the timing source for the animation. */
00112         CPeriodic*     iPeriodic;    
00113 
00114         /** Frame counter variable, used in the animation. */
00115                 TInt iFrame;
00116 
00117         /**
00118          * Flag that indicates if OpenGL ES has been initialized or not.
00119          * Used to check if SizeChanged() can react to incoming notifications.
00120          */
00121         TBool iOpenGlInitialized;
00122 
00123     public:  //data
00124 
00125         /** Used in DrawCallBack() method to do the actual OpenGL ES rendering.  */
00126                 CRain* iRain;
00127     };
00128 
00129 #endif
00130 
00131 // End of File

© Nokia 2006

Back to top