S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SnowContainer.h

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

© Nokia 2006

Back to top